# solving nonlinear second order ordinary differential equations numerically

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

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

(where the derivatives are with respect to t)?

Thanks, Wayne

edit retag close merge delete

Sort by ยป oldest newest most voted

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.

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

( 2017-12-30 01:10:40 +0200 )edit
1

@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')
P=desolve_system_rk4([z,-z^2*(-2+t/(1+t))-y],[y,z],ics=[0.1,10,2],ivar=t,end_points=100)
Q=[ [t1,y1] for t1,y1,z1 in P]
line(Q).show()

( 2017-12-30 13:49:28 +0200 )edit

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

( 2017-12-31 04:13:14 +0200 )edit

## Stats

Seen: 929 times

Last updated: Dec 30 '17