Ask Your Question

# 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

## 1 Answer

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

## Comments

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

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()


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

## Your Answer

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

Add Answer

## Stats

Asked: 2017-12-29 17:08:41 +0200

Seen: 578 times

Last updated: Dec 30 '17