# How to approach the numerical solution of the Ermakov–Pinney equation? [closed]

Suppose we have the following non-linear differential equation

$$\displaystyle{\ddot{x}+\omega^2(t) x-\frac1{x^3}}=0,$$

where $x(t)$ is a function of time $t$ a and where we choose $\omega^2(t)$ to be some (positive) periodic function, to be more specific, let us say

$$\omega_1(1+\sin^2(\omega_2 t)),$$

with $\omega_1$ and $\omega_2$ being positive constants.

Let us choose $\omega_1=1$ and $\omega_2=2$, and the initial conditions e.g. $x(0)=1$, $x'(0)=1$.

How to approach the solution in Mathematica?

• When I searched the documentation for "differential equation" the first hit was this guide to differential equations that points out both symbolic and numerical solvers. What happened when you searched? Apr 29 '17 at 18:41
• @wondering Did you saw my answer?
– zhk
May 3 '17 at 6:49
• @zhk Yes, thank you, this answers my question. Btw., you must be from India, right? --> "Did you SEE my answer?" :-) May 5 '17 at 10:21
• @wondering Close! I am grandson of Taliban supreme leader Mullah Umar. Thx for the correction.
– zhk
May 5 '17 at 10:54

For numerical solution to ODE's/PDE's you can use NDSolve. For more details visit here.

1.$\omega(t)$ as a triangle function

w[t_] = UnitTriangle[t]

ODE = x''[t] + w[t]^2*x[t] - 1/x[t]^3 == 0;

sol = NDSolve[{ODE, x[0] == 1, x'[0] == 1}, x[t], {t, -10, 10}]

Plot[x[t] /. sol, {t, -10, 10}]

2.$\omega^2(t)=\omega_1(1+\sin^2(\omega_2 t))$

w[t_] = w1*(1 + Sin[w2*t]^2);

w1 = 1; w2 = 2;

ODE = x''[t] + w[t]*x[t] - 1/x[t]^3 == 0;

sol = NDSolve[{ODE, x[0] == 1, x'[0] == 1}, x[t], {t, -10, 10}];

Plot[x[t] /. sol, {t, -10, 10}]