Ask Your Question

solving nonlinear second order ordinary differential equations numerically

asked 2017-12-29 10:08:41 -0500

Wayne gravatar image

Are there any Sage tools that will numerically solve equations of, for example, this form:


(where the derivatives are with respect to t)?

Thanks, Wayne

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2017-12-29 15:05:49 -0500

eric_g gravatar image

Yes there are such tools, but you have first to write your second order differential equation as a system of two first order equations, by introducing $z(t) = y'(t)$: $$y'(t)=z(t), \qquad z'(t) = -f(t) z(t)^2 - g(t)$$ Then you can use desolve_system_rk4. Type desolve_system_rk4? for details. An example of use is in cell 44 and below of this notebook.

edit flag offensive delete link more


Thanks Eric,

I meant the g(t) term to be a y(t) term so the equation looks like

y''(t)+f(t)(y'(t))^2 +y(t)=0

I don't think this is easily turned into a first order equation.


Wayne gravatar imageWayne ( 2017-12-29 18:10:40 -0500 )edit

@eric_g's solution can handle this. Just replace $g(t)$ with $y(t)$. Here is an example with $f(t)=-2+\frac{t}{1+t}$.

var('t y z')
Q=[ [t1,y1] for t1,y1,z1 in P]
calc314 gravatar imagecalc314 ( 2017-12-30 06:49:28 -0500 )edit

Thanks very much Calc314! Clearly I have a lot to learn. I will work on this.

Wayne gravatar imageWayne ( 2017-12-30 21:13:14 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2017-12-29 10:08:41 -0500

Seen: 54 times

Last updated: Dec 29 '17