# Trouble verifying a solution to a differential equation

I am reading a physics book which has discussed one approach towards solving the differential equation

$$\frac{d^2 x(t)}{dt^2} = Cx(t)$$

as follows: Using Mathematica to solve the equation. I tried using Mathematica to solve the equation as follows:

In:= DSolve[x''[t] == C x[t], x[t], t]

Out= {{x[t] -> E^(Sqrt[c] t) C + E^(-Sqrt[c] t) C}}


But it gives a different (and I assume more general/proper) solution than the one offered by the book.

Question: How can I verify that the solution offered in the physics book has a form which matches the solution offered by Mathematica?

Attempt: Trying

Solve[E^(Sqrt[C] t) C + E^(-Sqrt[C] t) C ==
C Cos[Sqrt[-C] t] + C Sin[Sqrt[-C] t], C]


yields • If you just want the solution in the textbook you can DSolve[x''[t] == -ω^2 x[t], x[t], t]. Prove the solution involving $C$ is equivalent to that involving $\omega$ is another story, though. – xzczd Aug 4 at 3:14
• Why square ω in that DSolve equation? Isn't x''[t] == -ω^2 x[t] a different differential equation than x''[t] == C x[t]? – George Aug 4 at 3:27
• Solve[ω == Sqrt[-c], c] => {{c -> -ω^2}} – xzczd Aug 4 at 7:31

I'd like to extend my comments to an answer. If one just want to obtain the result in textbook, we just need

ref = DSolve[x''[t] == -ω^2 x[t], x[t], t][]
(* {x[t] -> C Cos[t ω] + C Sin[t ω]} *)


because as mentioned in the screenshot, $$-\omega^2=C$$.

However, if one wants to prove the output of

sol = DSolve[x''[t] == c x[t], x[t], t][]
(* {x[t] -> E^(Sqrt[c] t) C + E^(-Sqrt[c] t) C} *)


is equivalent to ref given that -ω^2 == c, the process is a bit involved. We need to:

1. Substitute in -ω^2 == c and express the solution with Sinh and Cosh.

sol /. c -> -ω^2 // ExpToTrig
(* {x[t] ->
C Cosh[t Sqrt[-ω^2]] + C Cosh[t Sqrt[-ω^2]] +
C Sinh[t Sqrt[-ω^2]] - C Sinh[t Sqrt[-ω^2]]} *)

2. Expand the Sqrt[-ω^2] with PowerExpand. Notice Assumptions -> True is necessary to obtain a generally correct result.

PowerExpand[%, Assumptions -> True] // Simplify
(* {x[t] -> (C + C) Cos[(-1)^Ceiling[Arg[ω]/π] t ω] +
I (C - C) Sin[(-1)^Ceiling[Arg[ω]/π] t ω]} *)

3. At this point it's obvious that (-1)^Ceiling[Arg[ω]/π] can only be $$\pm 1$$, but still, we stick on proving with Mathematica. We simplify (-1)^… term with FullSimplify.

% /. (-1)^a_ :> FullSimplify[(-1)^a]
(* {x[t] -> (C + C)*Cos[t*ω*Piecewise[{{-1, Arg[ω] > 0}}, 1]] +
I*(C - C)*Sin[t*ω*Piecewise[{{-1, Arg[ω] > 0}}, 1]]} *)

4. Finally simplify the Piecewise[…] further by classified discussion.

Simplify[%, #] & /@ {Arg[ω] > 0, Arg[ω] <= 0}
(* {{x[t] -> (C + C) Cos[t ω] - I (C - C) Sin[t ω]},
{x[t] -> (C + C) Cos[t ω] + I (C - C) Sin[t ω]}} *)


C and C are constants, thus C + C and ± I (C - C) are constants, too. QED.

Since Mathematica uses a symbol similar to C for arbitrary constants in the solutions provided by DSolve, I suggest using a different symbol like MU to avoid confusion. If MU is positive in your original equation, you will get one type of solution, if negative another. To see this, try DSolve[x''[t]==3 x[t], x[t], t] and DSolve[x''[t]==-3 x[t], x[t], t]. With that, you should be able to understand the general solution you are getting.

Or try getting rid of the arbitrary constants by supplying initial conditions as

sol = DSolve[{x''[t] == MU x[t], x == AA, x' == 0}, x[t], t]

And then

sol /. MU -> 3 // ExpToTrig // Simplify

And

sol /. MU -> -3 // ExpToTrig // Simplify

to see what is going on.

Recall Cosh[x] will increase with x (look up the definition), which makes sense from the original equation.

(Normally it is best practice to not use upper-case names like MU or AA.)