Solving Differential Equations In Python In Less Than 5 Minutes (General Solution)

Поделиться
HTML-код
  • Опубликовано: 29 дек 2024

Комментарии • 116

  • @SmajdalfFrogi12
    @SmajdalfFrogi12 5 лет назад +49

    Andrew: "equation function"
    Classes: am I a joke to you?

  • @mattRRgraham1996
    @mattRRgraham1996 6 лет назад +35

    While I didn't use python for it, I used Matlab to solve for some interesting nonlinear differential equations in my Nonlinear Dynamics and Chaos Theory class. I used Matlab to play with the Lorenz equations and reproduce his results in his original paper which was SUPER cool. I'd be happy to send you my code if you'd want. That was probably my favorite thing I did in the class. Idk if I still have it or not, but there was also a general relativity equation that I used Matlab to help solve because it wasn't immediately obvious to me what to do on paper for the homework assignment, so I tried using Matlab instead. I love these Coding videos and hearing about what's going on with you and grad school, research internship, etc., it's inspiring! Keep up the good work man! I love this channel. It's a gem amongst the sea of youtubers. I'll be applying to math grad school this upcoming fall so it's nice to see somebody in similar shoes a bit further down the road from me.

    • @abhaspradhan1459
      @abhaspradhan1459 5 лет назад

      I am actually planning to solve the Lorenz equations too and that's why I'm here!

    • @amangangwar2535
      @amangangwar2535 4 года назад

      how to solve nonlinear second order diff eqq Matlab or python?

    • @bilalhussein9730
      @bilalhussein9730 4 года назад

      @@amangangwar2535 I prefer Mathematica for DEs: reference.wolfram.com/language/tutorial/DSolveOrdinaryDifferentialEquations.html#6538.
      Matlab works fine too: www.mathworks.com/help/symbolic/solve-a-single-differential-equation.html#:~:text=Represent%20the%20derivative%20by%20creating,Solve%20ode%20for%20y%20 though.

    • @leonardocabrera9253
      @leonardocabrera9253 3 года назад +3

      Python is free so Matlab is not an alternative for non students.

    • @temiladeadeniran7811
      @temiladeadeniran7811 7 месяцев назад

      Can I see your code ? …. The one you used to solve Lorenz equations

  • @quahntasy
    @quahntasy 6 лет назад +34

    I love these coding videos.Keep it up!

  • @amearaadan9214
    @amearaadan9214 Год назад

    THANK U!! I decided to do nothing for my coding module this entire semester thinking we had no work then he throws an individual project at us worth 50% of the module due in a few days so I have to learn everything I missed rlly quick:( this helped a lot

  • @prashant.tiwariOO7
    @prashant.tiwariOO7 2 года назад

    Short , simple and clear. great

  • @AstroRoxy
    @AstroRoxy 6 лет назад +3

    I'm too jus getting started in python, somewhere in the loops section, even though I didn't understood how u got the end result, I hav did the exact same in paper, looking forward to solve using python too.
    will come here, when I do that 😎

  • @starship1701
    @starship1701 6 лет назад +4

    Cool! I like how simple it is.
    What resource(s) did you use to learn how to code in python, just in general?

  • @ゾカリクゾ
    @ゾカリクゾ 6 лет назад +5

    also do some numerical solution to a differential equation! (preferably one with no analytical solution, such as the pendulum one, or if you can do it, some crazy thing with pendulums, atwood machines and springs using lagrangians and stuff)

  • @danburstein1637
    @danburstein1637 2 месяца назад

    The explanation is very good. Do you have a video that explain how to solve the differential equation with initial conditions?

  • @miltonincsw
    @miltonincsw 5 лет назад +3

    Ryan Reynolds teaching python, can life get better than this

  • @leonardocabrera9253
    @leonardocabrera9253 3 года назад +3

    Hey does someone know hot to plot the solutions, and how to define initial values to find c1 and c 2?

  • @Mark00747
    @Mark00747 6 лет назад +4

    How can you solve for the constants in Python?

  • @thed_motivation4897
    @thed_motivation4897 Год назад +1

    I love the video. But, I am using Python 3.11.4 and it isn't running this particular code. I am using window 11, please do recommend site to check for download for this to work. Can this work for fourth differential equation

  • @xabiergarciaandrade2656
    @xabiergarciaandrade2656 6 лет назад +2

    Mmm why do you use two lines of code to import the whole sympy library instead of just typing import sympy as sp?

  • @ashutoshsharma1640
    @ashutoshsharma1640 4 года назад

    Thanks a lot a very helpful and nicely made crisp video

  • @DanielLima-bd8sv
    @DanielLima-bd8sv 5 лет назад +2

    Great videos! Helped me a lot. Could you please make a video about PDE's ? Thanks

  • @parzival_zd_1156
    @parzival_zd_1156 6 лет назад +3

    Nice..😄😄👍👍
    I'm also Learning... Python..😅😅
    I've started before a Week.
    😆😆
    This Journey of Learning Python is Going Good...😅
    I hope I will learn All very Soon..😆😆😆😆

  • @MrZak-rf3vq
    @MrZak-rf3vq 4 года назад +1

    This is literally magic.

  • @nonamenoname2618
    @nonamenoname2618 3 года назад

    Are there step-by-step solutions for this, like there are for Wolframalpha?

  • @sheikhakbar2067
    @sheikhakbar2067 4 года назад

    Excellent video, thank you very much!

  • @shamsnoor7043
    @shamsnoor7043 5 лет назад +5

    Eq(-5*f(x) + Derivative(f(x), (x, 2)), 0)
    This keeps appearing as my output instead of the clear d/dx form your output takes. Could you please point out what I'm doing wrong?

    • @tonynguyen8166
      @tonynguyen8166 4 года назад +2

      Im late to this but what did u use print instead of display? print just prints out what u wrote display shows the function in the correct form.

    • @shamsnoor7043
      @shamsnoor7043 4 года назад +1

      @@tonynguyen8166 Apparently I was missing a map file when I was using Pycharm. I started using Jupyter later on and the program itself prompted me to download the missing file. The issue got fixed by that.

    • @tonynguyen8166
      @tonynguyen8166 4 года назад +1

      @@shamsnoor7043 That also makes sense the program shouldnt run if you don't have the package for it. Just out of curiosity why were u using pycharm? I only use notebook since it has most of the packages i need and it's easier to read and view.

    • @piyomaru479
      @piyomaru479 4 года назад

      I used python application and we're having the same result. I don't know how to fix it. 😭

    • @tonynguyen8166
      @tonynguyen8166 4 года назад +1

      @@piyomaru479 if you are using python instead of juypter u r gonna have to download the sympy package

  • @ywk7282
    @ywk7282 2 года назад

    Thank you fo rthe video!!:) Is there any way to put in values in x and get the output values form f? If there is it would be great to know

  • @Oakenhelm1
    @Oakenhelm1 6 лет назад

    Nice vid, easier to follow than my class is

  • @hakulab920
    @hakulab920 2 года назад

    why did you write both "from sympy import *" and "import sympy as sp" ? Can I use import sympy as sp only?

  • @oanmachi2629
    @oanmachi2629 5 лет назад

    so for example, if i want to set f(0)=1 to sovle C1, C2. plz tell me how to write that?

  • @LeMon-ss3us
    @LeMon-ss3us 2 года назад

    How can i write cos and sin in this code cuz i have trying and it appears a error named cant convert expresstion to float

  • @aishwaryadas2859
    @aishwaryadas2859 2 года назад

    Thanks for this video, can you do the same for delayed differential equation using ddeint. I want to try it for multiple delays. Can you help me out?

  • @abhisheksingh-xf8kb
    @abhisheksingh-xf8kb 3 года назад

    How can I solve n second order coupled differential equation (Fermi pasta ulam chain)

  • @kayeassy
    @kayeassy 6 лет назад

    Well can we solve for special functions as well??

  • @sauvikdas5932
    @sauvikdas5932 5 лет назад

    If I want to solve some differential eqtn containing exponential terms. What should I write?

  • @googlegoogle1610
    @googlegoogle1610 2 года назад

    Please, can you teach us how to solve the finite difference method in python?

  • @anuragmishra6262
    @anuragmishra6262 4 года назад

    It was really helpful

  • @carloswayne8640
    @carloswayne8640 3 года назад

    Hi! I would like to know how to define a constant in the code. I ought to solve an equation with no number constants. I really liked your video

  • @sayansagar6868
    @sayansagar6868 4 года назад

    Hello Andrew why are you used "printing, latex=true" statement here. I can't understand the 2 nd line of programming. Explain me brother

  • @malayapaul458
    @malayapaul458 5 лет назад +1

    Can you please start a series on learning python

  • @yinyl
    @yinyl 4 года назад

    cool video~ Thanks

  • @ahmadalghooneh2105
    @ahmadalghooneh2105 5 лет назад

    Dear andrew, people are mostly interested in numerical solvers, do you have a video about that?

  • @rickandelon9374
    @rickandelon9374 5 лет назад

    Andrew, Can I ask you why are you not using Mathematica?

  • @Israel220500
    @Israel220500 5 лет назад +1

    Why bother importing sympy as sp if you already polluted the namespace?

  • @VishalSingh-zs5tr
    @VishalSingh-zs5tr 3 года назад

    Sir can u show how to solve fourth order differential equation in two variables x,y

  • @ejinduyoung5046
    @ejinduyoung5046 4 года назад

    How do you account for initial conditions?

  • @abhisheksingh-xf8kb
    @abhisheksingh-xf8kb 4 года назад

    Sir, I want to use solution of differential Equation in other code of python how can I do this.

  • @raulrios5748
    @raulrios5748 4 года назад +1

    I need to get the c1 and c2 values, how can I do that?, I already have the initial conditions.

    • @sayanjitb
      @sayanjitb 4 года назад

      Just insert initial conditions into the solution and solve for c1 and c2

    • @dracula2227
      @dracula2227 3 года назад

      @@sayanjitb how do we do that?

    • @sayanjitb
      @sayanjitb 3 года назад

      @@dracula2227general solution of a second-order diff equation contains two arbitrary constants, and in order to fix those just insert two initial values or boundary values that are already provided to you.

  • @ruffnck4637
    @ruffnck4637 5 лет назад +1

    What about the system of equations?

  • @Katabatic44
    @Katabatic44 5 лет назад +7

    did you learn programming before or after starting grad school?

    • @charlesmarseille123
      @charlesmarseille123 4 года назад +3

      the first day you ask about coding should be the first day you start. Whatever your background, skills or grades. If you can google, you can code.

  • @TheNewPhysics
    @TheNewPhysics 3 года назад

    What about nonlinear differential equations?

  • @loconino5498
    @loconino5498 Год назад

    thank you so much

  • @jacobkammer2843
    @jacobkammer2843 4 года назад

    what does * signify in the third line of code where your are importing sympy?

    • @jacobkammer2843
      @jacobkammer2843 4 года назад +1

      @@AbhishekSharmaabolt9 Thanks. I had never seen that in the past so thought it was strange and now I know not recommended. thanks a bunch

  • @mther123
    @mther123 5 лет назад

    Great

  • @Felipe-53
    @Felipe-53 4 года назад

    good one, thanks!

  • @unknown360ful
    @unknown360ful 6 лет назад

    Hey Andrew! Nice vid! But just wondering, why do you call that format 'LATECH', isn't it LATEX? As in Latex the material?

    • @unknown360ful
      @unknown360ful 6 лет назад

      Thanks! It really was helpful! I had no clue! I always thought it was LATEX as in the material...

    • @heyredwhale
      @heyredwhale 6 лет назад +2

      Actually that is just partially true. TeX, the typesetting sytem LaTeX is build on, is an abbreviation for the Greek "techne", so the letters are actually the Greek letters tau epsilon chi. Chi is pronounced differently than the English X and it is there the pronunciation of TeX comes from.

    • @carlosvargas2907
      @carlosvargas2907 6 лет назад

      Don't care. I'll say LAHTEKS

  • @lisaroy.588
    @lisaroy.588 Год назад

    Cool

  • @hamidouhrir4910
    @hamidouhrir4910 4 года назад

    Pls How to use that solution to plot. Thnks

  • @engineering_chaos2749
    @engineering_chaos2749 3 года назад

    Love this

  • @nurudeennajeem6605
    @nurudeennajeem6605 Год назад

    Thanks

  • @mrinalrajak5526
    @mrinalrajak5526 5 лет назад

    Thank you Sir....

  • @saibharath5510
    @saibharath5510 4 года назад

    Thanks man!!!

  • @santiagobrouardmartin965
    @santiagobrouardmartin965 4 года назад +1

    Thank you for the video, Andrew. I tried to solve something like {dy/dt +b*x+a*y= 0, dx/dt- b*y-a*x=0}, with a and b being arbitrary constants, and get into trouble with dsolve. Could you help me with that, please?

  • @khanrabbi5465
    @khanrabbi5465 6 лет назад +1

    Hello Andrew. Thank you for your wonderful video. I want to know how I can use Python to solve 3rd order non-linear homogenous ODE like below:
    d3y/dx3 = (dy/dx)^2 - y*(d2y/dx2)

    • @tonynguyen8166
      @tonynguyen8166 4 года назад

      U use sympy the same as what he did all u do is adjust the equation that he wrote to urs.

  • @elafmoataz6051
    @elafmoataz6051 4 года назад

    Can you please help me solving this non linear second ODE. i^2 = (m/Kt) * X'' + (K/Kt) X? TIA.

  • @AdityaKumar-ij5ok
    @AdityaKumar-ij5ok 6 лет назад

    I came across this differential equation while studying damped oscillation can you please tell how to solve it?
    M x'' + B x' + K x = 0
    The derivatives of position are, of course, with respect to time.

    • @gagers78
      @gagers78 5 лет назад +2

      use an auxiliary equation method. let x = e^kt and differentiate to get x' and x''. then you should get a quadratic in terms of k and the constants of the differential equation all multiplied by e^kt. You can then divide through by e^kt to get a quadratic you can solve in k.
      This gives you 2 solutions. The general solution is then x=c1e^k1t+c2e^k2t. It will look nicer when you write it out. If the values are complex it will still work just the constants c1,c2 are different. you could expand the equation out using Euler's formula to get a function in sin and cos. Alternatively if k1,k2 are complex rework the question but with x=c1sin(k1t)+c2cos(k2t) as your function to differentiate.

  • @NTC
    @NTC 2 года назад

    you're smart! :D

  • @begatbegat7273
    @begatbegat7273 5 лет назад

    thank you!

  • @MosPol1698
    @MosPol1698 3 года назад

    Hello , please how can I plot this Equations ? please

  • @teben2622
    @teben2622 3 года назад +1

    Is this pde or ode?

  • @SO-dl2pv
    @SO-dl2pv 6 лет назад +1

    if you have already imported everything from sympy then why do bother yourself using sp prefix? or if you have imported sympy as sp then why you import everything from sympy!!!!!

  • @prateekyadav7679
    @prateekyadav7679 2 года назад

    How to define f?

  • @MathPhysicsFunwithGus
    @MathPhysicsFunwithGus 4 года назад

    please do a P.D.E video!

  • @abhinaba__saha
    @abhinaba__saha 4 года назад

    this is magic

  • @oulimatatall5567
    @oulimatatall5567 4 года назад

    how to get C1?

  • @annie_munoz
    @annie_munoz 5 лет назад

    OMG Thank you!!!!!!!!!!

  • @darchcruise
    @darchcruise 6 лет назад

    Hi Andrew. Do you tutor (Diff Equation) via Skype?

  • @chadurdy7555
    @chadurdy7555 3 года назад

    😧🤯🧠✨😎🖤

  • @vijayyadav3673
    @vijayyadav3673 2 года назад

    Dear Andrew can you please solve the equation
    dG/dt=G_in-f_2 (G(t))-f_3 (G(t)) f_4 (I(t-τ_2))+c
    dI/dt=f_1 (G(t-τ_1)) (k_0 I(t-τ_2))/(e^cI(t-τ_2 ) -1)-d_i (t)
    also plot plot the solution.
    thanks

  • @fraktasticful
    @fraktasticful 5 лет назад +1

    Why is Ben Affleck teaching me python?

  • @prateek2849
    @prateek2849 6 лет назад +4

    I gave it the equation for *forced damped oscillations* and 'he' (not assuming genders, sorry feminists) solved it beautifully 👏😂

  • @GojoSenpai25
    @GojoSenpai25 6 лет назад +1

    Why use python when matlab can solve 2nd order dif eqs

    • @edvanbruggen550
      @edvanbruggen550 6 лет назад +6

      Python is free, open source, and the standard in the scientific community

    • @GojoSenpai25
      @GojoSenpai25 6 лет назад

      Ed van Bruggen however at least in engineering they care more about using matlab plus some universities have access to it for free

    • @edvanbruggen550
      @edvanbruggen550 6 лет назад +1

      DocAlex yeah I true Matlab is more common in engineering circles compared to the scientific world, in my experience in research there seems to be a slow shift away from matlab. I go to a large research university and while a lot of our applied math classes are in matlab we do not get it free. From what I can tell most no physicists use matlab and it is completely unheard of in astronomy, both using mainly python, and some C++ or even fortan. While I can tell it is definitely much more common in engineering most engineerings I have worked with prefer to use python when possible.

    • @edgardparra6497
      @edgardparra6497 6 лет назад +1

      If your job is to make software, then you need to do differential equations in python, C, or whatever the environment that you require. Since your asking why use python, then you're obviously not a software developer. Stick to Matlab if that's what you know.

  • @jake_runs_the_world
    @jake_runs_the_world 6 лет назад +1

    Where's your beard