# second order nonlinear ode

I need to solve the following equation for $u_n(t)$:

$u''=\frac{u'^2}{2u}+\frac{3u^3}{2}+4tu^2+2\left(t^2+\frac{n}{2}+(2p+1)\frac{1+3(-1)^n}{4}\right)u-\frac{n+(2p+1)(1-(-1)^n)}{4u}$

where $p$ is a constant.

I there any way to do this algebraically (preferably exactly, but series solution would do) in mathematica (or matlab or maple)? How could I do it?

Thanks!!

From OP's comment:

My input was

eqn = u''[t] = u'[t]/(2 u[t]) + 3 u[t]^3/2 + 4 tu[t]^2 + 2 (t^2 + n/2 + (2 p + 1)*
(1 + 3*(-1)^n)/4)* u[t] - (n + (2 p + 1)*(1 - (-1)^n))/(4 u[t]);

sol = Dsolve[eqn, u, t]


and I got

Dsolve[4 tu[t]^2 - (n + (1 + (-1)^(1 + n)) (1 + 2 p))/(4 u[t]) +
2 (n/2 + 1/4 (1 + 3 (-1)^n) (1 + 2 p) + t^2) u[t] + (3 u[t]^3)/2 +
Derivative[1][u][t]/(2 u[t]),
u, t]

• What happened when you tried using DSolve[]? – J. M. will be back soon Jul 8 '15 at 2:56
• My input was eqn = u''[t] = u'[t]/(2 u[t]) + 3 u[t]^3/2 + 4 tu[t]^2 + 2 (t^2 + n/2 + (2 p + 1)*(1 + 3*(-1)^n)/4)* u[t] - (n + (2 p + 1)*(1 - (-1)^n))/(4 u[t]); sol = Dsolve[eqn, u, t], and I got Dsolve[4 tu[t]^2 - (n + (1 + (-1)^(1 + n)) (1 + 2 p))/(4 u[t]) + 2 (n/2 + 1/4 (1 + 3 (-1)^n) (1 + 2 p) + t^2) u[t] + (3 u[t]^3)/2 + Derivative[1][u][t]/(2 u[t]), u, t] – mj_indefinite Jul 8 '15 at 3:04
• Welcome to Mathematica.SE! I hope you will become a regular contributor. To get started, 1) take the introductory Tour now, 2) when you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge, 3) remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign, and 4) give help too, by answering questions in your areas of expertise. – bbgodfrey Jul 8 '15 at 3:27
• I added your code from your comment to your question, which is the place to put it. You can format inline code and code blocks by selecting the code and clicking the {} button above the edit window. The edit window help button ? is also useful for learning how to format your questions and answers. – Michael E2 Jul 8 '15 at 3:47
• That (-1)^n is nasty if DSolve is treating n as an arbitrary complex number....and Dsolve is not the same as DSolve. – Michael E2 Jul 8 '15 at 3:49

## 1 Answer

== is needed instead of = in eqn, and a space needs to be inserted in ut. With these changes, sol = DSolve[eqn, u, t] returns unevaluated. This is not surprising, because DSolve generally can solve only equations that are known to be solvable analytically. Instead, try

sol = NDSolveValue[{(eqn /. {p -> 1, n -> 0}), u[1] == 1, u'[1] == 0},
u, {t, 1, 1.5}]
Plot[sol[t], {t, 1, 1.5}]


The choice of parameters and boundary conditions are just what came to mind, of course. What are your preferences? For the choices here, u grows rapidly with t.

Series Expansion at t == 0

A series expansion for u[t] about any given t0 can be derived in a compact manner. So, for t == 0,

cl = CoefficientList[Series[eqn[[1]] - eqn[[2]], {t, 0, 5}] // Normal,
t] /. {u[0] -> a[0], Derivative[i_][u][0] -> a[i]};
tr = First@Solve[cl[[1]] == 0, a[2]];
Do[tr = Join[tr, First@Solve[(cl[[i - 1]] /. tr) == 0, a[i]]], {i, 3, 7}];
sereval = Sum[a[i] t^i, {i, 0, 7}] /. tr;


Comparing this expansion with the numerical solution shows that it does not converge well for t larger than 0.2, at least for the parameters chosen.

sol = NDSolveValue[{(eqn /. {p -> 1, n -> 0}), u[0] == 1,
u'[0] == -2.334}, u, {t, 0, 3.2}];
Plot[{sol[t], sereval /. {a[0] -> 1, a[1] -> -2.334, n -> 0, p -> 1}}, {t, 0, 2.5},
PlotRange -> {-10, 10}]


The blue curve is the numerical solution, and the orange, the expansion. That the expansion diverges quickly is obvious from

sereval /. {a[0] -> 1, a[1] -> -2.334, n -> 0, p -> 1}
(* 1 - 2.334 t + 6.333 t^2 - 20.0643 t^3 + 81.6056 t^4 - 464.523 t^5 +
3546.1 t^6 - 32360.4 t^7 *)


Adding more terms does not help.

Large u[t] Behavior

Insight into the behavior of the solution for large u[t] can be obtained by solving the equation exactly in that limit.

jac = (DSolve[u''[t] == (3/2) u[t]^3, u[t], t][[1, 1, 2]]) //
Simplify[#, C[1] > 0 && C[2] > 0 && t > 0] &
(* -(-(1/3))^(1/4) Sqrt[2] C[1]^(1/4)
JacobiSN[(-(1/2) + I/2) 3^(1/4) C[1]^(1/4) (t + C[2]), -1] *)


which is singular at t == 2/C[1]^(1/4) - C[2].

Plot[Chop[jac /. {C[1] -> 1, C[2] -> 0}], {t, 0, 4}]


Note that the parameters n and p drop out in this limit, so it is valid not just for the choices made for the earlier numerical solution.

• One could also make a function out of it, sol[n_, p_] = NDSolve[eqn, u, t]. Or use ParametricNDSolve to do the same thing. – Michael E2 Jul 8 '15 at 4:07
• @MichaelE2 I agree. Thanks – bbgodfrey Jul 8 '15 at 4:09
• For the series expansion, how do I interpret the output? I get a list of coefficients(?) also, are initial conditions needed for this? – mj_indefinite Jul 8 '15 at 15:38
• @mj_indefinite a[0] and a[1] need to be specified, and the other a[i] are given by tr. – bbgodfrey Jul 8 '15 at 15:43