# Solving a second order DE

I have this second order DE:

$$\frac{1}{3\phi } \left( \frac{\dot{a}\dot{\phi} }{a} + \ddot{\phi} \right) + 2 \frac{\ddot{a}}{a} = \partial_x^2 \phi,$$

where $$\phi(x,t) = \frac{1}{4} e^{k(t-x)} - \frac{1}{4} e^{-k(t-x)},$$ and the initial condition is $$a(0)=0$$.

Can this equation be solved analytically to get $$a(t)$$?

Here is my trial:

ϕ[x_, t_, k_] := (1/4)*Exp[k*(t - x)] - (1/4)*Exp[(-k)*(t - x)]

eq[x_, t_, k_] = (1/(3*ϕ[x, t, k]))*((D[a[t], t]*D[ϕ[x, t, k], t])/a[t] +
D[ϕ[x, t, k], {t, 2}]) + 2*(D[a[t], {t, 2}]/a[t]) - D[ϕ[x, t, k], {x, 2}]

DSolve[{eq[x, t, k] == 0, a[0] == 0}, a[t], t]


Which returns the same DSolve input.

I think separation of variables is needed, because a part of the equation depends on t and the other part depends on x.

• First thing I'd try is setting $k$ equal to $1$ or some other simple trial value. If that works, try adding an assumption like $k > 0$. It's a complicated looking equation, and may not be solvable (symbolically). If not, consider whether a numerical solution could be satisfactory. (Sorry, but I've got to go now. No time to try at present.) Commented Dec 24, 2023 at 15:13
• Please indicate when cross-posted: community.wolfram.com/groups/-/m/t/3090534 Commented Dec 24, 2023 at 16:30
• Multiplying the ode by $a(t)$ it becomes a linear ode. Commented Dec 25, 2023 at 17:52
• As a linear homogeneous ode, with initial conditions $a(0)=0$, one solution is the trivial solution: $a(t) = 0$ Commented Dec 25, 2023 at 18:17

Mathematica can solve the homogeneous ode but can't find particular solution.

ϕ[x_, t_, k_] := (1/4)*Exp[k*(t - x)] - (1/4)*Exp[(-k)*(t - x)]
eq[x_, t_, k_] := (1/(3*ϕ[x, t, k]))*((D[a[t], t]*D[ϕ[x, t, k], t])/
a[t] + D[ϕ[x, t, k], {t, 2}]) + 2*(D[a[t], {t, 2}]/a[t]) -
D[ϕ[x, t, k], {x, 2}]
Collect[eq[x, t, k], k] == 0


Notice this:

Solve the homogeneous ode only:

DSolve[k ((E^(-k (t-x)) a'[t])/(12 (-(1/4) E^(-k (t-x))+1/4 E^(k (t-x))) a[t])+(E^(k (t-x)) a'[t])/(12 (-(1/4) E^(-k (t-x))+1/4 E^(k (t-x))) a[t]))+(2 a''[t])/a[t]==0,a[t],t]


It can't even integrate it. So not possible to find particular solution since can't use variation of parameters as it needs basis solutions for homogeneous ode to make any progress.

If you want full solution may be try specific numerical values for $$k$$ and see if makes it easier for DSolve.

Adding global assumption that k>0 it can solve it

$Assumptions = k > 0 DSolve[eq[x, t, k] == 0, a[t], t]  And with IC $Assumptions=k>0
DSolve[{eq[x,t,k]==0,a[0]==0},a[t],t]


But all these results contain differential root. So not sure how useful they will be for you

  InputForm[%]

{
{
a[t] ->
(-(C[1]*DifferentialRoot[Function[{\[FormalY], \[FormalX]}, {(-\[FormalX] + E^(k*x))*(\[FormalX] + E^(k*x))*(-3*\[FormalX]^2 + 4*\[FormalX]*E^(k*x) + 3*E^(2*k*x))*\[FormalY][\[FormalX]] + (-28*\[FormalX]^4*E^(k*x) + 20*\[FormalX]^2*E^(3*k*x))*Derivative[1][\[FormalY]][\[FormalX]] +
(-24*\[FormalX]^5*E^(k*x) + 24*\[FormalX]^3*E^(3*k*x))*Derivative[2][\[FormalY]][\[FormalX]] == 0, \[FormalY][1] == 0, Derivative[1][\[FormalY]][1] == 1}]][E^(k*t)]*
DifferentialRoot[Function[{\[FormalY], \[FormalX]}, {(-\[FormalX] + E^(k*x))*(\[FormalX] + E^(k*x))*(-3*\[FormalX]^2 + 4*\[FormalX]*E^(k*x) + 3*E^(2*k*x))*\[FormalY][\[FormalX]] + (-28*\[FormalX]^4*E^(k*x) + 20*\[FormalX]^2*E^(3*k*x))*Derivative[1][\[FormalY]][\[FormalX]] +
(-24*\[FormalX]^5*E^(k*x) + 24*\[FormalX]^3*E^(3*k*x))*Derivative[2][\[FormalY]][\[FormalX]] == 0, \[FormalY][1] == 1, Derivative[1][\[FormalY]][1] == 0}]][1]) +
C[1]*DifferentialRoot[Function[{\[FormalY], \[FormalX]}, {(-\[FormalX] + E^(k*x))*(\[FormalX] + E^(k*x))*(-3*\[FormalX]^2 + 4*\[FormalX]*E^(k*x) + 3*E^(2*k*x))*\[FormalY][\[FormalX]] + (-28*\[FormalX]^4*E^(k*x) + 20*\[FormalX]^2*E^(3*k*x))*Derivative[1][\[FormalY]][\[FormalX]] +
(-24*\[FormalX]^5*E^(k*x) + 24*\[FormalX]^3*E^(3*k*x))*Derivative[2][\[FormalY]][\[FormalX]] == 0, \[FormalY][1] == 0, Derivative[1][\[FormalY]][1] == 1}]][1]*
DifferentialRoot[Function[{\[FormalY], \[FormalX]}, {(-\[FormalX] + E^(k*x))*(\[FormalX] + E^(k*x))*(-3*\[FormalX]^2 + 4*\[FormalX]*E^(k*x) + 3*E^(2*k*x))*\[FormalY][\[FormalX]] + (-28*\[FormalX]^4*E^(k*x) + 20*\[FormalX]^2*E^(3*k*x))*Derivative[1][\[FormalY]][\[FormalX]] +
(-24*\[FormalX]^5*E^(k*x) + 24*\[FormalX]^3*E^(3*k*x))*Derivative[2][\[FormalY]][\[FormalX]] == 0, \[FormalY][1] == 1, Derivative[1][\[FormalY]][1] == 0}]][E^(k*t)])/
DifferentialRoot[Function[{\[FormalY], \[FormalX]}, {(-\[FormalX] + E^(k*x))*(\[FormalX] + E^(k*x))*(-3*\[FormalX]^2 + 4*\[FormalX]*E^(k*x) + 3*E^(2*k*x))*\[FormalY][\[FormalX]] + (-28*\[FormalX]^4*E^(k*x) + 20*\[FormalX]^2*E^(3*k*x))*Derivative[1][\[FormalY]][\[FormalX]] +
(-24*\[FormalX]^5*E^(k*x) + 24*\[FormalX]^3*E^(3*k*x))*Derivative[2][\[FormalY]][\[FormalX]] == 0, \[FormalY][1] == 0, Derivative[1][\[FormalY]][1] == 1}]][1]}}

• As far as I know, the term homogeneous is only used for linear differential equations. Commented Dec 26, 2023 at 13:13
• @UlrichNeumann This is first time I hear this. But I've seen this used before in many places. Here is one paper titled Nonlinear second order inhomogeneous differential equations I have to ask my math teacher at school when I get chance. So what should one call ode such as $y y''+y'+3 y=\sin(x)$? i.e. one where the RHS is not zero? Is there different term other than inhomogeneous ode to use for nonlinear ode's ? Commented Dec 26, 2023 at 15:41
• Your example is self-explanatory, don't bother your teacher ( ;-) ). On the other hand wikipedia: Homogeneous differential equation only deals with the linear case. Here my counterexample (wellknown oscillation equation): What is the homogenous part of the ode x''[t]/x[t]+x'[t]/x[t]+1== F[t]/x[t]? Commented Dec 26, 2023 at 16:47
• @UlrichNeumann for the ode you show, this is inhomogeneous second order linear ode. The inhomogeneous term is F[t] because the ode can be rewritten as x''[t]+x'[t]-x[t]==F[t] Did I get this right? Commented Dec 26, 2023 at 16:54
• Agreed! If you now multiply the ode, QP asked for, by a[t] you get a quasilinear homogenous ode in a[t] Commented Dec 26, 2023 at 16:56

To long for a comment:

For this timedependent problem the transformation \[Tau]->k (t - x), a[t]-> \[Alpha][k (t - x)] simplifies the ode

ode = eq[x, t, k] a[t] // Expand // ExpToTrig
(ode/2 /. a -> (\[Alpha][k (# - x)] &) )/k^2 // Simplify[#, k > 0] &;
ode\[Tau] = % /. k (t - x) -> \[Tau] // Expand


$$\frac{1}{6} \coth (\tau ) \alpha '(\tau )+\alpha ''(\tau)+\frac{\alpha (\tau )}{6}-\frac{1}{4} \alpha (\tau ) \sinh(\tau )=0$$

Unfortunately Mathematica can't solve it symbollically

DSolve[{ode\[Tau] == 0 }, \[Alpha], \[Tau]]


You may be stuck with numerical solutions. The substitution $$t = x+(\log s)/k$$ changes the DE to a parameter-free one with a holonomic solution. The substitution puts the parameter dependence all in the argument, which seems a great improvement. But I can't get the DifferentialRoot solution to evaluate except at machine precision, and it seems to oscillate wildly. Maybe NDSolve with numeric k and x would work better for you.

\[Phi][x_, t_, k_] := (1/4)*Exp[k*(t - x)] - (1/4)*Exp[(-k)*(t - x)];
eq[x_, t_,
k_] = (1/(3*\[Phi][x, t, k]))*((D[a[t], t]*D[\[Phi][x, t, k], t])/
a[t] + D[\[Phi][x, t, k], {t, 2}]) + 2*(D[a[t], {t, 2}]/a[t]) -
D[\[Phi][x, t, k], {x, 2}];

eq2 = eq[x, t, k] // Together // Numerator;
sub = t == Log[s]/k + x;
newEQ = DSolveChangeVariables[
Inactive[DSolveValue][eq2 == 0, a[t], t], u, s, sub] //
Simplify[#, k > 0 && \[Xi] > 0 && s > 0,
TransformationFunctions -> {Automatic, PowerExpand}] &
Clear[asol];
asol[t_, k_, x_] =
Activate[newEQ] /. First@Solve[sub, s, Reals] //
Simplify[#, k > 0 && x \[Element] Reals && s > 0] &


I tried to find a ratio C[1]/C[2] that would satisfy the initial condition, but the sign oscillates wildly. I'm not sure that the values can be trusted.

Block[{C = Through[{Cos, Sin}[-0.05477431032]][[#]] &},
asol[0, 2, 1.16]
]
Block[{C = Through[{Cos, Sin}[-0.05477430932]][[#]] &},
asol[0, 2, 1.16]
]

  2.25921*10^21
-4.25624*10^22


The outputs are machine precision, despite the arbitrary precision inputs.

AsymptoticDSolveValue also works, without the boundary condition and not with it. One can get the BC solution from the general series expansion, though:

aymptsol[t_, k_, x_] =
AsymptoticDSolveValue[{newEQ[[1]]},
u[s], {s, s /. First@Solve[sub, s, Reals] /. t -> 0, 3}] /.
First@Solve[sub, s, Reals] // Collect[
#, {C[1], C[2]},
Simplify[# // Expand,
k > 0 && x \[Element] Reals && s > 0] &] &;
0 == % /. t -> 0 // Simplify
aymptsol[t, k, x] /. First@Solve[%]


If all you need is the asymptotic expansion, I guess you're in luck. Otherwise, it looks like a very difficult DE to handle symbolically.