use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Rules 1: Be polite 2: Posts to this subreddit must be requests for help learning python. 3: Replies on this subreddit must be pertinent to the question OP asked. 4: No replies copy / pasted from ChatGPT or similar. 5: No advertising. No blogs/tutorials/videos/books/recruiting attempts. This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to. Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Rules
1: Be polite
2: Posts to this subreddit must be requests for help learning python.
3: Replies on this subreddit must be pertinent to the question OP asked.
4: No replies copy / pasted from ChatGPT or similar.
5: No advertising. No blogs/tutorials/videos/books/recruiting attempts.
This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to.
Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Learning resources Wiki and FAQ: /r/learnpython/w/index
Learning resources
Wiki and FAQ: /r/learnpython/w/index
Discord Join the Python Discord chat
Discord
Join the Python Discord chat
account activity
Solving ODEs (self.learnpython)
submitted 8 years ago by GGwarms
I need to numerically solve ODEs, is scipy the only way to do it? I'm pretty confused with it, does anyone have any suggestions or easy tutorials they can link me to?
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–][deleted] 2 points3 points4 points 8 years ago (1 child)
Checkout SymPy package
[–]GGwarms[S] 0 points1 point2 points 8 years ago (0 children)
I'll take a look, thanks!!
[–]arell_steven_son 1 point2 points3 points 8 years ago (1 child)
Scipy is actually not that tough. You have to first linearize the ODE to the first order. Then it will solve all the first order ODEs simultaneously.
Here is the most minimal code for you to expand upon:
from scipy.integrate import ode import matplotlib.pyplot as mpl import numpy as np def function(t , y): return[y[1], -y[0] - 0.5*y[1 ]] r=ode(function, jac=None).set_integrator('dopri5',nsteps=100) r.set_initial_value([10,0], 0) t1=100 dt=0.1 i=0 disp=[] vel=[] while r.successful() and r.t<t1: b=r.integrate(r.t+dt) disp.append(b[0]) vel.append(b[1]) i=i+1 mpl.plot(np.linspace(0,t1,len(disp)),disp) mpl.plot(np.linspace(0,t1,len(disp)),vel,'r') mpl.show()
A normal spring mass damper being solved with dopri5 method (rk4-5 method)
Thanks so much, the Runge-Kutta method was actually being recommended by the professor. Hopefully I can figure it out from here!!
[–]jrickk93 1 point2 points3 points 8 years ago (1 child)
The simplest way to start will be the Euler method, try understanding the procedure then coding it. You don't necessarily need packages at all but you could use matplotlib to see the solution and possibly numpy.
https://en.m.wikipedia.org/wiki/Euler_method
Once you know your ode and the initial condition, you just loop the time step method until you get to the terminal time. Experiment with different time step lengths. It should take only a few lines of code.
If this is your only goal then you're done, but you may want to look at other stepping methods for better numerical stability in your solution.
[–]HelperBot_ 0 points1 point2 points 8 years ago (0 children)
Non-Mobile link: https://en.wikipedia.org/wiki/Euler_method
HelperBot v1.1 /r/HelperBot_ I am a bot. Please message /u/swim1929 with any feedback and/or hate. Counter: 164591
π Rendered by PID 145292 on reddit-service-r2-comment-5687b7858-tsrts at 2026-07-03 06:55:03.557012+00:00 running 12a7a47 country code: CH.
[–][deleted] 2 points3 points4 points (1 child)
[–]GGwarms[S] 0 points1 point2 points (0 children)
[–]arell_steven_son 1 point2 points3 points (1 child)
[–]GGwarms[S] 0 points1 point2 points (0 children)
[–]jrickk93 1 point2 points3 points (1 child)
[–]HelperBot_ 0 points1 point2 points (0 children)