11 ms·
Calculus with Julia
- jagged-chisel 2y agoPDF link in the page header is 404
- mhd 2y agoI assume they turned it off intentionally: "These notes may be compiled into a pdf file through Quarto. As the result is rather large, we do not provide that file for download. For the interested reader, downloading the repository, instantiating the environment, and running quarto to render to pdf in the quarto subdirectory should produce that file (after some time)."
- dfee 2y agoI skipped around in the book a bit and found it interesting. I’d consider encouraging my kids to learn calculus this way. However, I am curious about the first paragraph of the preface: > Julia is an open-source programming language with an easy to learn syntax that is well suited for this task. Why is Julia better suited than any other language?
- patagurbon 2y agoJulia inherited a lot of MATLAB DNA like standard library linear algebra and 1 based indices. In addition it's got very commonly used Unicode support and intentionally can look like pseudocode in many cases.
- blagie 2y agoThis is a good overview: https://computationalthinking.mit.edu/Spring21/ https://computationalthinking.mit.edu/Spring21/ The very short story is that it's a language somewhat similar to Python (and, likewise, easy-to-use), but with much richer syntax for expressing mathematics directly. It also has richer notebooks. The key property is that in python notebooks, you run cells. In julia notebooks, it handles things like dependencies. If I change x, either as a number or a slider, all the dependencies things update. You can define a plot, add sliders, and it just works. (Also: I'm not an expert in Julia; most of my work is in Python and JavaScript. I'm sure there are other reasons as well, but the two above come out very clearly in similar courses)
- dnfsod 2y agoI also clicked around and felt the formatting and progression of the book was a bit confusing, but found some of the Julia features intriguing. (like “postfixing” allowing the same pencil notation of f’ and f’’ et al) In my opinion, and experience, the best “calculus book” is Learn Physics with Functional Programming which only relies on libraries for plotting, and uses Haskell rather than Julia. https://www.lpfp.io/ https://www.lpfp.io/ > Why is Julia better suited than any other language? Julia is known as a “programming language for math” and was designed with that conceit steering a lot of its development. Explicitly it supports a lot of mathematical notation that matches handwritten or latex symbols. Implicitly they may be referencing the simplified (see Pythtonic) syntax, combined with broad interoperability (this tutorial uses SymPy for a lot of the heavy lifting), lots of built in parallel computing primitives, and its use of JIT compilation allowing for fast iteration/exploration.
- barrenko 2y agoThank you for reminding me of LPFP!
- jakderrida 2y agoI'm just guessing, but: 1. Open Source. 2. Easy to learn. (kind of) 3. Robust plotting and visualization capabilities, which are integral (I f*cking swear no pun intended) to understanding calculus, the foundational purpose of calculus being to find the area under the curve. (something I really wish they told me day one of Pre-Calc) 4. This one is just a vague feeling, but the fact that Python's most robust Symbolic Regression package, SymPy, relies on running Julia in the background to do all the real work suggests to me that Julia is somehow just superior when it comes to formulas as opposed to just calculations. IDK how, though.
- constantcrying 2y ago1-3 apply exactly the same to python, 4 is just false, SymPy is written in python, it has nothing to do with Julia.
- patagurbon 2y agoThey're thinking of PySR but you are right on all points!
- constantcrying 2y ago>Why is Julia better suited than any other language? Because it is a language specifically targeted for doing numerical analysis. Python, which is it's main "competitor" has a notoriously poor syntax for mathematical operations with miniscule standard library support for mathematics, a very limited type system and abysmal runtime performance. Julia addresses all of these issues and gives a relatively simple to read language, which often closely resembles mathematical notation and has quite decent performance.
- mgaunard 2y ago"its" not "it's" numpy has similar syntax to MATLAB and Julia Python's type system is pretty rich and allows overloading all operators
- constantcrying 2y ago>numpy has similar syntax to MATLAB and Julia Numpy has absolutely awful syntax compared to Julia or MATLAB. It is fundamentally limited by pythons syntax, which was never meant to support the rich operations you can do in Julia. I have done quite a bit in both languages and it is extremely clear which language was designed for numerical analysis and which wasn't . >Python's type system is pretty rich and allows overloading all operators The language barely has support for type annotations. Duck typing is actually a very bad thing for doing numerical analysis, since you actually care a lot about the data types you are operating on. Pythons type system is so utterly inadequate that you need an external library to have things like proper float types.
- mgaunard 2y agoYou're just repeating that it's bad without any argument. Numpy's syntax is the same as MATLAB's. Both MATLAB and Julia also use dynamic typing, though it is true Julia does have support for ad-hoc static typing through annotations in a way that is stricter than Python's. Numpy does provide all the traditional floating-point types.
- staplung 2y agoJulia has a bunch of little niceties for mathematics: * Prefixing a variable with a scaler will implicitly multiply, as in standard math notation (e.g. 3x would evaluate to 6 if x is 2) * Lots of unicode support. Some feel almost gratuitous (∈ and ∉ are operators that work as you would expect) but it's pretty nice to have π predefined (it's even an irrational datatype) and to use √ as an operator (e.g. √2 is a valid expression and evaluates to a float). It's not just that Julia supports these constructions but provides a convenient way to get them to appear. * This is a little less relevant for calculus but vectors and matrices are fist class types in Julia. Entering and visually parsing matrices is so much easier in Julia than in Python. m = [1 2 3; 4 5 6; 7 8 9] vs. m = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] Transposition is a single character operator ('). Dot product can be done with the dot operator (m ⋅ n). A\b works as it does in matlab. * Julia supports broadcasting. It also has comprehensions but with broadcasting I personally find much less need for comprehensions. * Rationals are built-in with very simple syntax (1//2))
- RivieraKid 2y agoI quite like and use Julia but wish there was a language mixing the best aspects of Julia and Swift (which I think can be done without many compromises, i.e. it would be a better language overall). Some things I don't like about Julia: - array.mean().round(digits=2) is more readable than round(mean(array), digits=2) - Poor support for OOP (no, pure FP is not the optimal programming approach).
- patagurbon 2y agoYou can overload your own types to get a lot of those things (poor support for OOP is harder but you can sort of emulate it with traits). Overloading `getproperty` for the former case. Of course it's not built in, which I understand is annoying if that's your preferred coding style. I personally am sad that really good traits aren't encoded in the language.
- abisen 2y agoIf I am not using named arguments I find myself using the pipe operator a lot. I also find it more readable. array |> mean |> round For scenarios with named arguments there is a little not so cleaner workaround array |> mean |> x->round(x, digits=2)
- g0wda 2y agoMultiple-dispatch is the right abstraction for programming mathematics. It provides both the flexibility required to create scientific software in layers (science has a LOT more function overloading compared to any other field.), and the information required to compile to fast machine code.
- michaelcampbell 2y ago> > Julia is an open-source programming language with an easy to learn syntax that is well suited for this task. > Why is Julia better suited than any other language? Why must it be better suited than ANY other language, for the bit you quoted to be true?
- blagie 2y agoI like the concept. I'd much rather have this built on top of or from something like MOOCulus. https://ximera.osu.edu/mooculus/calculus1 https://ximera.osu.edu/mooculus/calculus1 Holistically, I prefer MOOCulus. However, the value-add of Calculus with Julia is large. If the two could integrate somehow... the key thing about MOOCulus is the writing quality is better (much less verbose), and the integrated exercises means kids follow it closely. It's also very refined, from a lot of classroom use. If it were forked and Julia-enhanced, that would be a very big step up, though. As would the addition of applications.
- bmitc 2y agoI checked out the website, and it's really hard to even know how to use. Plus, the first thing I clicked on, "Equal or Not?", has errors.
- blagie 2y ago* The usability issues are 95% CSS issues, and would require a good UX designer. They're distracting for the first 10 minutes, but really need a fix. * I've had students go through two semesters of courses. We ran into two minor errors. We fixed them. In my experience, the content is rather bug-free. Contributing a fix takes all of five minutes. Hit "edit" at the top right, make the change in the github UX, and submit a PR. The quality of your bug report here leaves much to be desired. Are you talking about the Devyn / Riley dialogue at the top? If so, many of those appear designed to highlight misconceptions which are then addressed in the text. See "vicarious learning" for research evidence on how this works (and in practice, students seem to like the dialogues too).
- Alifatisk 2y agoFor someone coming from Matlab, is Julia a valid replacement?
- goerz 2y agoVery much so. See https://docs.julialang.org/en/v1/manual/noteworthy-differences/ https://docs.julialang.org/en/v1/manual/noteworthy-differenc... for some details
- BenFranklin100 2y agoWhile not a Matlab nor Julia user, I think you may be neglecting the nearly 40 years of code, toolboxes, and countless examples of common engineering problems solved in Matlab. Engineers tend to be more of a practical sort than developers, and just want to apply a known solution to a problem than mess around with newish software languages.
- agucova 2y agoThis is true, but even engineers see the advantages of Julia. My engineering school has went from almost pure Matlab usage to many key engineering courses switching to Julia due to its simplicity and friendliness. It's also SOTA for many engineering applications, particularly for acausal modelling and scientific machine learning (see https://sciml.ai https://sciml.ai), which has led to big companies like Pfizer adopting it [1]. And for engineers writing novel libraries, it clearly has a strong edge. See for example the work by NASA's JPL [2, 3], the FAA [4] or the CliMa project [5]. [1]: https://juliahub.com/case-studies/pfizer/ https://juliahub.com/case-studies/pfizer/ (see also https://info.juliahub.com/case-studies https://info.juliahub.com/case-studies) [2]: https://exoplanets.nasa.gov/news/1669/seven-rocky-trappist-1-planets-may-be-made-of-similar-stuff/ https://exoplanets.nasa.gov/news/1669/seven-rocky-trappist-1... [3]: https://ntrs.nasa.gov/citations/20170008266 https://ntrs.nasa.gov/citations/20170008266 [4]: https://youtu.be/19zm1Fn0S9M https://youtu.be/19zm1Fn0S9M [5]: https://clima.caltech.edu/ https://clima.caltech.edu/
- 2y ago
- tiffanyh 2y agoLuaJIT faster I find it interesting that after all these year of little development on LuaJIT, and active development in Julia - that LuaJIT is still faster (while also being general purpose). https://julialang.org/benchmarks/ https://julialang.org/benchmarks/
- slwvx 2y agoI find it interesting that after all these years of HN, commenters still ignore the main topic of the OP (a calculus book) to focus on the language it's written in
- dang 2y agoPlease don't respond to a bad comment by breaking the site guidelines yourself. That only makes things worse. https://news.ycombinator.com/newsguidelines.html https://news.ycombinator.com/newsguidelines.html
- patagurbon 2y agoLuaJIT is only appreciably faster on text ingestion and printing in those benchmarks. Julia is also plenty general purpose, just targeted (initially at least) towards the numerical community. LuaJIT is fantastically impressive though.
- gc9 2y agoNote that "The benchmark data shown above were computed with Julia v1.0.0" (2018)
- dang 2y ago"Please don't post shallow dismissals, especially of other people's work. A good critical comment teaches us something." https://news.ycombinator.com/newsguidelines.html https://news.ycombinator.com/newsguidelines.html
- neonsunset 2y agoNow they need to include .NET and System.Numerics.Tensors but that would make a lot of popular options look bad :) (particularly go which has no business being used in this area)
- kickingvegas 2y agoRelated: if you use Emacs it has the Calc package which supports computer algebra. I recently published an interface for Calc that makes it significantly easier to use and wrote about it here. http://yummymelon.com/devnull/mathing-in-emacs-with-casual.html http://yummymelon.com/devnull/mathing-in-emacs-with-casual.h...
- fiforpg 2y agoNice work! Emacs folks may also like the Maxima mode, a very capable interface to a full-blown CAS: https://www.emacswiki.org/emacs/MaximaMode https://www.emacswiki.org/emacs/MaximaMode
- ultrasounder 2y agoThis comes at a very opportune time in my life. when, my ward enters their HS -Junior year and they are taking SVC. Question to the Author(in case they are monitoring this thread), is it appropriate for a High-schooler with just an intro to Python?
- nl 2y agoStick with Python. Try SymPy.
- ultrasounder 2y agoGreat. Thanks. Any suggestions for a book or course that uses sympy to teach calculus( svc)?
- nl 2y agohttps://www.coursera.org/learn/applied-calculus-with-python https://www.coursera.org/learn/applied-calculus-with-python https://www.udemy.com/course/pycalc1_x/ https://www.udemy.com/course/pycalc1_x/
- ssivark 2y agoI imagine a language with decent support for macros would be much much more ergonomic for symbolic computation. Even ignoring all the other pros & cons, just this one reason would push one strongly towards Julia, Lisp(s), Mathematica, etc for symbolic computation.
- cfgauss2718 2y agoSympy is a poor tool to learn because it simply doesn’t scale to problems one most often encounters, even in schooling. Frankly, CAS are so general and unintelligent that problems with well known and elegant closed-form solutions, when presented to a system like sympy, result in an output which is often not even human readable - thousands of algebraic terms for instance to describe the equations of motion for a simple double pendulum. Personally I have found that the best tools are 1) a firm grasp of elementary calculus (differential, series, and integral) and 2) exposure to simple numerical methods that apply to a broad range of problems. Armed with this knowledge, in my opinion, Julia is a far superior language to python and its package ecosystem has a brighter future. Indeed, the language has been built with a focus on mathematical modeling and efficient numerical computation. It is a more natural starting point for those with an interest in mathematical modeling and engineering science, and will serve anyone who learns it better than python+numpy+sympy+scipy.
- fiforpg 2y agoOne has to be a little careful with designing courses like this. They are most likely to be of interest to people who already know, at least to some extent, both (i) calculus and (ii) programming. That is, the (presumable) target audience — those who are learning either of these subjects — is not really ready to take in such a class. Anecdotally, my personal attempts at incorporating only slightly exotic CASes (Maxima or Sagemath) into calculus courses were met with tepid response at best. Part of the issue was, I believe, that freshmen are rarely interested in setting up software for a non-CS course. That being said, for slightly higher-level classes it can work quite well as an optional component — I've had really good results with Python projects in an ODE course. Python not being a niche language certainly helped, too.
- dr_kiszonka 2y agoThis is a common challenge in teaching stats where students have to learn statistical concepts and using statistical software simultaneously. In the end, I think it is worth the challenge and beats having students calculate everything by hand & look up values in tables.
- Egrodo 2y agoAs a self taught programmer who never got farther than algebra, this looks awesome to me and I may be that small target audience haha.
- __rito__ 2y ago> "I've had really good results with Python projects in an ODE course." Which textbook did you use for this course? What were the reference material? Could you share with me anything about this course? Lecture notes, code, slides, books, anything.
- anthk 2y agoMaxima with Gnuplot with the bundled docs it's pretty good. Also, I think there was a pretty complete intro/guide to Maxima in PDF.
- DeathArrow 2y agoFunnily enough I just started to re-learn math (linear algebra, calculus and statistics) because I want to learn ML. While I learn various things I also try to use them in simple Python implementations (to my shame, I never use Python before). It's quite nice how you can rotate vectors, plot functions using mathplotlib. I can draw things by hand but not as nicely.
- richrichie 2y ago“A computation is a temptation that must be resisted as long as possible.” - J.P. Boyd.