mitmath / computational-thinking Goto Github PK
View Code? Open in Web Editor NEWCourse 18.S191 at MIT, Fall 2022 - Introduction to computational thinking with Julia
Home Page: https://computationalthinking.mit.edu/
License: Other
Course 18.S191 at MIT, Fall 2022 - Introduction to computational thinking with Julia
Home Page: https://computationalthinking.mit.edu/
License: Other
Hi, based on the discussion in the class discord (copied below), should these conditionals be switched/tweaked?
https://github.com/mitmath/18S191/blob/1dddcc9cb2cb88dce5fb17dea23b67a7e70da9b7/homework/homework6/hw6.jl#L818-L821
I.e., to something like this?
if result ≈ 1462
correct()
elseif result ≈ 6358
almost(md"Use ``f'(a)``, not ``f'(a+h)``.")
Copied from discord server:
user1 Yesterday at 11:22 AM
Hi guys, silly question, but why in the Euler step they make us use:Use f'(a+h) instead of f'(a)?
I've tried to infer it geometrically, but I get lost in the approximation details - does someone has a video/resource that explains the rationale behind this trick to improving accuracy?
Is it just because we're integrating 'forward' ?
IanWeaver Yesterday at 6:50 PM
Oh, I totally missed that! Thanks for pointing that out, I think they might have just hard-coded the wrong branches in the test, but this would definitely be something worth following up with the instructors about. For example, I think 6358 and 1462 might be switched, and that the almost message should read "Use f'(a), not f'(a + h)." instead. The later implementations of this method also look to agree with this.There are certainly different numerical methods though where you can use the slope at different points, RK4 probably being the most famous example. You can also just use the slope at the end of the step, but that would then turn it into an implicit scheme known as backward Euler. In general, this would require a root-finding method or fixed-point iteration to solve. If you happen to be interested in those kinds of methods, I made a brief write up about it here, but I haven't updated that package in a while:
https://spacejam.readthedocs.io/en/latest/background.html#backgroundOne of the nice things about implicit methods is how stable they are, but I think that is outside the scope of this homework assignment, which is another reason why I think the above problem you brought up might just be a typo.
Finally, for a quick intro to numerical methods, you can't beat the OGs:
https://www.youtube.com/watch?v=RGtCw5E7gBc
https://www.youtube.com/watch?v=q87L9R9v274(edited)
[6:53 PM]
I'll go ahead and open an issue about this and link to the discussion here 
Link to issue: #61
user2 Yesterday at 7:04 PM
yea, i was also weirded out by that because they used f'(a) in the preceding equation
The link at the end of the readme file
https://github.com/mitmath/computational-thinking/blob/578736f39c6eeb388ff5c51f9f28f0b8d8f29670/README.md
points to the Spring21 version instead of the latest version.
# Go to [computationalthinking.mit.edu](https://computationalthinking.mit.edu/Spring21/) to learn more!
should be
# Go to [computationalthinking.mit.edu](https://computationalthinking.mit.edu/) to learn more!
I have started following the course, and read through the first two notebooks. In both I get the following error that disables some of the code examples in the notebooks:
Failed to show value:
MethodError: no method matching length(::Nothing)
Closest candidates are:
length(!Matched::BitSet)
@ Base bitset.jl:348
length(!Matched::Base.AsyncGenerator)
@ Base asyncmap.jl:390
length(!Matched::RegexMatch)
@ Base regex.jl:285
...
Stack trace
Here is what happened, the most recent locations are first:
_similar_shape(itr::Nothing, ::Base.HasLength) @ [array.jl:710](https://github.com/JuliaLang/julia/tree/bd47eca2c8aacd145b6c5c02e47e2b9ec27ab456/base/array.jl#L710)
_array_for(::Type{Core.MethodInstance}, itr::Nothing, isz::Base.HasLength) @ [array.jl:726](https://github.com/JuliaLang/julia/tree/bd47eca2c8aacd145b6c5c02e47e2b9ec27ab456/base/array.jl#L726)
_method_instances(f_type::Any, t_type::Any) @ Tricks.jl:136
#s1#1 @ Tricks.jl:20
var"#s1#1"(T::Any, ::Any, f::Any, t::Any) @
(::Core.GeneratedFunctionStub)(::UInt64, ::LineNumberNode, ::Any, ::Vararg{Any}) @ boot.jl:602
content(x::HypertextLiteral.Result) @ convert.jl:91
show(io::IOContext{IOBuffer}, m::MIME{Symbol("text/html")}, toc::PlutoUI.TableOfContentsNotebook.TableOfContents) @ TableOfContents.jl:502
Not a real issue.
The url referenced by a hint "In Section 1.1, we drew a red square on top of the image Philip with a simple command..." leads to a 404 "File not found" page.
See here: https://computationalthinking.mit.edu/Fall20/lecture26/#what_is_a_discrete_fourier_transform and then look at the difference on YouTube
Hi, I am running Pluto in chrome on windows 10 and get following error on the third code block. Is it possible to run the code on windows? curl.exe is installed.
failed process: Process('C:\WINDOWS\System32\curl.exe' -s -S -g -L -f -o 'C:\Users\ruper\AppData\Local\Temp\jl_2fRSvgqCWA' https://cdn.shortpixel.ai/spai/w_1086+q_lossy+ret_img+to_webp/https://wisetoast.com/wp-content/uploads/2015/10/The-Persistence-of-Memory-salvador-deli-painting.jpg
, ProcessExited(35)) [35]
[email protected]:525[inlined]
download_curl(::String, ::String, ::String)@download.jl:44
[email protected]:62[inlined]
download(::String)@download.jl:89
top-level scope@Local: 17[inlined]
@fonsp: Symbolic expansion isn't working on the published version. Maybe it just needs regenerating with a current version of Symbolics.jl?
Neither via copying the link on the MIT OCW page and pasting it to Pluto nor copying directly the link to the .jl file is working, as Pluto seems to not recognize it as a notebook.
I'm not quite sure what the problem really is.
When run inverse_climate_model notebook, the following error appeared above the add and using package block.
Failed to precompile Plots [91a5bcdd-55d7-5caf-9e0b-520d859cae80] to /Users/.julia/compiled/v1.6/Plots/jl_iDFh4p.
error(::String)@error.jl:33
compilecache(::Base.PkgId, ::String, ::Base.PipeEndpoint, ::Base.PipeEndpoint)@loading.jl:1360
compilecache(::Base.PkgId, ::String)@loading.jl:1306
_require(::Base.PkgId)@loading.jl:1021
require(::Base.PkgId)@loading.jl:914
require(::Module, ::Symbol)@loading.jl:901
top-level scope@Local: 13
The link that takes one to the summary of the course materials seems to be not working
Which GitHub do you mean? The website?
Not strictly an issue; I just thought this may be useful to others. Also not an expert in Julia so if there's an easier way to do this please do correct the script.
I wanted to access the notebooks offline but due to Pluto installing packages per notebook, each notebook must be instantiated while having internet access. This script does that for every notebook in the notebooks
directory in the Spring21
branch:
using Glob
import Pluto
import Pkg
function main()
dirs = glob("./week*/*.jl")
for jl_file in dirs
println(jl_file)
Pluto.activate_notebook_environment(jl_file)
Pkg.instantiate()
end
end
main()
Hi,
Just wanted to let you know that the test for the answer to Ex 3.5 in Hw1 doesn't appear to be working properly. I get a correct answer for the following (obviously wrong) code:
function noisify(x::Number, s)
rand_num = rand()
noisy_num = x + rand_num
noisy_num = clamp(noisy_num, 0., 1.)
return noisy_num
end
Afraid I'm not not sure how to fix it though.
In section 1.6 on newton method, in the 2D implementation the julia code doesn't match the latex equations.
The new approximation is defined to be x1 = x0 + δ
, but in the julia function it's written as return x0 - δ
.
This works in the code because in the definition of δ
the minus sign is also missing, so practically it doesn't matter (they cancel out). However, I think it would be more intuitive if the code matched the latex equations
I think a picture does better here
If I go to HW0 and click "set up Julia and Pluto"
then weirdness ensues
Yet if I copy and paste the link into my browser, it works fine
I suspect this is an issue with the plutonotebookpage
styling?
I couldn't find any usage of it. Just wondering if it is needed? (seems to run without issues without it)
I get this error when i try to run 02-covid_data.jl in Pluto. I thought I was just missing a Pkg.add() but it seems plot() used to be available in earlier versions of Julia, but has been deprecated for quite a while, and I am not sure where the plot() should be coming from. (In the course website you write that you are using Julia 1.5.1.)
This will help with discoverability for certain contents
When I try to watch Lecture 4 from Denmark.
YouTube just gives the message: "This video is not available in your country"
I think raw versions of the hw links need to be used if you want people to be able to indeed download the files by right clicking.
e.g.,
https://github.com/mitmath/18S191/raw/master/homework/homework0/hw0.jl
or
https://raw.githubusercontent.com/mitmath/18S191/master/homework/homework0/hw0.jl
for hw0, instead of
https://github.com/mitmath/18S191/blob/master/homework/homework0/hw0.jl
Redirect the http to https for the computationalthinking.mit.edu URL. Or click "Enforce HTTPS" in settings.
Also, update the URL for the class on the repo.
This page: https://computationalthinking.mit.edu/Fall20/installation/
Looks fine on GitHub but on the website literal HTML entities are shown.
For example:
Failed to load notebook
The file D:\Julia SoftWare\18S191 SUBMISSION\hw0 (1).jl could not be loaded. Please report this error!
Go back
Error message:
File is not a Pluto.jl notebook
Stacktrace:
[1] error(::String) at .\error.jl:33
[2] load_notebook_nobackup(::IOStream, ::String) at C:\Users\user.julia\packages\Pluto\qC4PK\src\notebook\Notebook.jl:113
[3] #8 at C:\Users\user.julia\packages\Pluto\qC4PK\src\notebook\Notebook.jl:164 [inlined]
[4] open(::Pluto.var"#8#9"{String}, ::String, ::Vararg{String,N} where N; kwargs::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at .\io.jl:325
[5] open at .\io.jl:323 [inlined]
[6] load_notebook_nobackup(::String) at C:\Users\user.julia\packages\Pluto\qC4PK\src\notebook\Notebook.jl:163
[7] load_notebook(::String) at C:\Users\user.julia\packages\Pluto\qC4PK\src\notebook\Notebook.jl:180
[8] open(::Pluto.ServerSession, ::String; run_async::Bool) at C:\Users\user.julia\packages\Pluto\qC4PK\src\webserver\SessionActions.jl:16
[9] open at C:\Users\user.julia\packages\Pluto\qC4PK\src\webserver\SessionActions.jl:10 [inlined]
[10] (::Pluto.var"#try_launch_notebook_response#96"{Pluto.var"#try_launch_notebook_response#85#97"{Pluto.ServerSession}})(::String; title::String, advice::String, home_url::String) at C:\Users\user.julia\packages\Pluto\qC4PK\src\webserver\Static.jl:63
[11] (::Pluto.var"#serve_openfile#99")(::HTTP.Messages.Request) at C:\Users\user.julia\packages\Pluto\qC4PK\src\webserver\Static.jl:92
[12] handle(::HTTP.Handlers.RequestHandlerFunction{Pluto.var"#serve_openfile#99"}, ::HTTP.Messages.Request) at C:\Users\user.julia\packages\HTTP\atT5q\src\Handlers.jl:253
[13] handle(::HTTP.Handlers.Router{Symbol("##253")}, ::HTTP.Messages.Request) at C:\Users\user.julia\packages\HTTP\atT5q\src\Handlers.jl:467
[14] (::Pluto.var"#190#196"{Pluto.ServerSession,HTTP.Handlers.Router{Symbol("##253")}})(::HTTP.Streams.Stream{HTTP.Messages.Request,HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}}) at C:\Users\user.julia\packages\Pluto\qC4PK\src\webserver\WebServer.jl:123
[15] handle at C:\Users\user.julia\packages\HTTP\atT5q\src\Handlers.jl:269 [inlined]
[16] #4 at C:\Users\user.julia\packages\HTTP\atT5q\src\Handlers.jl:345 [inlined]
[17] macro expansion at C:\Users\user.julia\packages\HTTP\atT5q\src\Servers.jl:367 [inlined]
[18] (::HTTP.Servers.var"#13#14"{HTTP.Handlers.var"#4#5"{HTTP.Handlers.StreamHandlerFunction{Pluto.var"#190#196"{Pluto.ServerSession,HTTP.Handlers.Router{Symbol("##253")}}}},HTTP.ConnectionPool.Transaction{Sockets.TCPSocket},HTTP.Streams.Stream{HTTP.Messages.Request,HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}}})() at .\task.jl:356
For week 1 in Exercise 2.3 the student is required to write a function to quantize instances of subtypes of AbstractRGB
e.g. RGB
. The live docs imply that the functions red(c)
green(c)
and blue(c)
can be used to "pull out" the RGB values from a pixel.
However, the function red(c)
is overwritten by a later variable assignment to red
on L301
This causes an error to be displayed if the student assumes that red
is a function, and tries to call it
Commenting out the variable assignment reverts the function override
I suggest that the variable red
should be renamed to something like color_red
to avoid overriding the function
Hi,
I am preparing a course based on Pluto notebooks and I would like to base some of the material on notebooks from this repo. Since there is no license in this repository, would you mind clarifying under which conditions I can reuse some of the material?
In particular, I would like to use your install instructions, the hw0.jl and the notebook on basic syntax.
Best,
Fabian
Hi, all,
The invite link for Discord is expired. Could you help to create a new one?
THX!
Add a button to hide the sidebar on website
Reference: Sidebar of youtube can be toggled full size, vs collapsed.
I feel like the check might be inadequate?
Since it is checking 0.3, floor
with any digits
≥ 1 will pass, when really we want digits=1
.
Hi everyone,
I'm sorry to open this issue here on GitHub but there seem to be not many people active on the Discord server at the moment.
I am wondering if MIT will hold the course in Fall21.
Thanks!
import Pkg
Pkg.activate(mktempdir())
Pkg.add([
Pkg.PackageSpec(name="Images", version="0.22.4"),
Pkg.PackageSpec(name="QuartzImageIO"),
Pkg.PackageSpec(name="PlutoUI", version="0.7"),
Pkg.PackageSpec(name="HypertextLiteral", version="0.5"),
Pkg.PackageSpec(name="ForwardDiff"),
Pkg.PackageSpec(name="NonlinearSolve"),
Pkg.PackageSpec(name="StaticArrays")
])
this cause a lot of problem, when opening the notebook every time it shows I need to add another packages, even though the packages do exists, these lines acutually does not add any packages to Julia, so it makes opening the notebook a pain.
Could you please do not add those lines in Notebook?
Thanks in advance
It looks like much of the content on the readme and index page are the same. This may lead to confusion for those making website updates.
@fonsp I can take a shot at this unless you would rather do it
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.