Ask Your Question
0

solving nonlinear second order ordinary differential equations numerically

asked 2017-12-29 17:08:41 +0100

Wayne gravatar image

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 flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2017-12-29 22:05:49 +0100

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

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

Wayne gravatar imageWayne ( 2017-12-30 01:10:40 +0100 )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()
calc314 gravatar imagecalc314 ( 2017-12-30 13:49:28 +0100 )edit

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

Wayne gravatar imageWayne ( 2017-12-31 04:13:14 +0100 )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

Stats

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

Seen: 1,007 times

Last updated: Dec 30 '17