5 ms·
Solving First Order Differential Equations with Julia
- anigbrowl 2y agoX^2 - 3x - 18 =0 [...] This is how the equation is created: x(x+3) = 18 wat Maybe don't do very fast recaps if you're not going to proofread them. Incidentally I assume the formulae in this article were done with MathJax or its Julia equivalent, they render great but can't be copied from the text. Overall a good article (and a great ad for Julia) but stumbling blocks like the one above ensure some readers won't make it any farther.
- grandempire 2y agoIs the issue here quadratic factorization is not obvious or that the sign is wrong? Note that x(x+3) = 18 and x(x-3) = 18 are valid models of the same problem. One finds the longer side in terms of the shorter, or vice versa
- hansvm 2y agoLooks like proofreading (sign being wrong) to me.
- __rito__ 2y agoYes, it is absolutely that. I have corrected it, and it should be okay now.
- zombot 2y agoBoth variants (+3 & -3) have the same shape, and so do their derivatives, but they do land in different places on the X axis. Is that irrelevant?
- __rito__ 2y ago> "Note that x(x+3) = 18 and x(x-3) = 18 are valid models of the same problem. One finds the longer side in terms of the shorter, or vice versa" That is the reason I made the mistake initially. They both were correct in my mind. But that's no excuse for the mistake, and I made a correction.
- beepbooptheory 2y agoWell if they made it that far, they also read that this article is for "people who are already familiar with Differential Equations from Mathematics." I think if you're already familiar, a single wrong sign is not something thats going to be particularly hindering. It's more just something to jump on if you are, for some reason, itching to criticize it.
- __rito__ 2y agoIt was my fault, and was created by a moment of absent-mindedness. They are both correct individually, but definitely wrong when read together. I corrected it. Thanks for reading the article and pointing out the obvious mistake. I will proofread more carefully and use a spell checker from the next time. There were some typos, too, that I corrected since then. Like 'langauge', 'equaion', etc. I wrote the article in Jupyter Lab with a Julia kernel. I just wrote LaTeX in Markdown cells. I rendered the article with quarto and quarto is also how the blog is created. I am ignorant about how it renders LaTeX in webpages. Pandoc and MathJax seems to be involved. I am not sure. > "Overall a good article (and a great ad for Julia) but stumbling blocks like the one above ensure some readers won't make it any farther." Thank you for your compliment. I absolutely don't want people not making it any farther due to a small mistake I made. I will be more mindful about it from the next time.
- kelseyfrog 2y ago[flagged]
- selimthegrim 2y agoWould that be worth a blogpost?
- kelseyfrog 2y agoNo. I used o3-mini so it's not interesting but for different reasons. It's also not interesting unless you're into the equations of nuclear kinetics and fluid flow.
- gessha 2y agoPeople are at different stages of their learning journey and a blog post like this one might be a stepping stone for a blog post with some of the work that you’ve done.
- gerdesj 2y ago"but this is so elementary as to not be interesting." Well that's a bit desultory. The second stanza of the OP (post Intro) describes the potential Audience that they are aiming at. You may have written something far more exciting but you forgot to publish it and link it here.
- __rito__ 2y agoI know this is easy, but I still had to spend ~1 hour going through docs and videos- to start using the package in Julia comfortably . I think that writing it might help somebody in future. And as I use Python almost exclusively in my work, the blogpost also serves as a note for my future self. I believe in some tenets when it comes to writing blogposts. Those tenets also have some elements regarding the choice of topic of a blogpost. Here the key tenet was: Would the content of my blogpost have been helpful to me a week ago? From [0] [0]: https://jvns.ca/blog/2016/05/22/how-do-you-write-blog-posts/#how-do-you-decide-what-s-worth-writing-about https://jvns.ca/blog/2016/05/22/how-do-you-write-blog-posts/...
- 2y ago
- forgotpwd16 2y agoThe first example is also the very first example in the docs[1], but rather f!(du,u,p,t) that modifies du, it passes f(u,p,t) that returns du. Searching the help for ODEProblem() function, it's explained[2] that the first way is more memory-efficient, but if mutation is not allowed, the second way is more suitable. It will be of interest to write a follow-up post elaborating on this part. [1]: https://docs.sciml.ai/DiffEqDocs/stable/examples/classical_physics/#Radioactive-Decay-of-Carbon-14 https://docs.sciml.ai/DiffEqDocs/stable/examples/classical_p... [2]: https://docs.sciml.ai/DiffEqDocs/stable/types/ode_types/#SciMLBase.ODEProblem https://docs.sciml.ai/DiffEqDocs/stable/types/ode_types/#Sci...
- selimthegrim 2y agoI think I had volunteered to do something similar to this - let me check
- __rito__ 2y agoAuthor here. Yes, f(u,p,t) returning du is the suggested way to do things, but this pattern of updating du through in-place updating is more memory efficient when a system of equations (say 10-100) is involved. The suggested way, when we don't need to think about memory efficiency, is easier to write and reason about. I have plans to write more on this topic, and make it to a series. After I finish that, if there is enough interest, I will try and do a benchmark of mutating versus non-mutating styles with varying numbers of equations in a system of DEs. Thanks for reading the article and providing your opinion.
- fussypart 2y agocan anyone recommend a good textbook on differential equations?
- __rito__ 2y agoCould you tell me a bit about your background, your level in mathematics, and the type of book you prefer? Do you enjoy highly rigorous, proof-heavy texts, or do you prefer books where the author explains concepts in a more conversational and detailed way—still rigorous, of course, but more wordy?
- fussypart 2y agoI have a CS degree but haven't done math in a few years. Last course I completed was an MITx - intro to probability. While I enjoyed its rigor and detail, I am looking for something practical without proofs.
- seanhunter 2y agoOh well you might really like this, which I think is amazing. Steve Brunton from U Washington has an incredible course on DEs and dynamical systems. It’s a playlist on youtube where he talks through everything on a lightboard in a really incredibly clear way, there are tons of great examples, and he illustrates all the models using python and matlab code. And then a bunch of notes, problem sets etc are available online at the link. https://faculty.washington.edu/sbrunton/me564/ https://faculty.washington.edu/sbrunton/me564/
- lagrange77 2y agoI second that. Also recommend this course by Gilbert Strang @ MIT: https://ocw.mit.edu/courses/res-18-009-learn-differential-equations-up-close-with-gilbert-strang-and-cleve-moler-fall-2015/ https://ocw.mit.edu/courses/res-18-009-learn-differential-eq... https://www.youtube.com/playlist?list=PLUl4u3cNGP63oTpyxCMLKt_JmB0WtSZfG https://www.youtube.com/playlist?list=PLUl4u3cNGP63oTpyxCMLK...
- deleted 2y ago
- nxpnsv 2y agoI didn't find a link to the package in the article. It seems to be a quite capable package, and the given two examples that are trivial to solve analytically don't really do it justice.
- __rito__ 2y agoI have added a link to the package now. The first mention of the package in the body now contains a link to the official page for the package. > and the given two examples that are trivial to solve analytically don't really do it justice. Yes, I know. I plan to write more in the future.
- nxpnsv 2y agoCool, the link is helpful, and the package is pretty cool. I'd just add that the examples are simple and be done with it, you can revisit with more later. Keep writing :)
- leephillips 2y agoIt’s probably the best library for DEs in any language. I’m pretty sure that DifferentialEquations.jl, by itself, is the reason many scientists and engineers are using Julia. https://docs.sciml.ai/DiffEqDocs/stable/ https://docs.sciml.ai/DiffEqDocs/stable/
- __rito__ 2y agoI use Diffrax and my own stuff with Numba/CuPy JIT-ing. Can you compare the Python ecosystem for DEs with Julia according to your experience?
- leephillips 2y agoNo, I’m not familiar with the Python ecosystem for DEs.
- nxpnsv 2y agoI didn't try it yet, but the docs looks great.
- sundarurfriend 2y agodoggo dot jl mention! Thanks for the article. It gave me a little bit of familiarity with the DiffEq side of Julia, but even more valuable to me was the comparison between ordinary equations and diffeqs: > In normal equations, we solve the equation to find out values of variables previously unknown to us. In case of Differential Equations, we solve to find out functions previously unknown to us. That's a simple, easy to remember nugget of information that gives me some context to this whole field.
- __rito__ 2y agoI really wish that somebody told me this when I was in High School. In HS, DEs were just solving integrals with a simple step away around as far as the student is concerned. I learned about them much more deeply when in college, and later independently. As you know this now- if you come across a young person studying DEs, feel free to share this line with him/her. Thanks for reading the article and sharing your opinion.