# Concerning the origin of four terms in DSolve's hyperbolic solution to an ODE

Typing

DSolve[{g''[y] - k^2/Gy g[y] == 0}, g[y], y]


where $$k$$ and $$G_y$$ are constants gives $$\left\{\left\{g(y)\to C_1 \exp\left(\frac{k y}{\sqrt{G_y}}\right)+C_2 \exp\left(-\frac{k y}{\sqrt{G_y}}\right)\right\}\right\}$$ This anwer can be expressed in terms of hyperbolic functions $$g(y)=C_1\cosh\left(\frac{k y}{\sqrt{G_y}}\right)+C_2\sinh\left(\frac{k y}{\sqrt{G_y}}\right)$$ where $$C_1$$ and $$C_2$$ are not technically the same as the constants for the exponential form but for the purposes of this question it doesn't matter. When I type ExpToTrig[DSolve[{ g''[y] - k^2/Gy g[y] == 0}, g[y], y]] I get $$\left\{\left\{g(y)\to C_1 \sinh \left(\frac{k y}{\sqrt{G_y}}\right)-C_2 \sinh \left(\frac{k y}{\sqrt{G_y}}\right)+C_1 \cosh \left(\frac{k y}{\sqrt{G_y}}\right)+C_2 \cosh \left(\frac{k y}{\sqrt{G_y}}\right)\right\}\right\}$$

How come Mathematica creates four terms instead of two? Doesn't this make finding solutions more difficult?

• Mathematica does not know that C1 and C2 are arbitrary constants, but you do, and you can write C1*Sinh+C2*Cosh. There is no mistake here. Mar 18, 2019 at 7:37
• You have a type in your M code, you typed G_y for Gy Mar 18, 2019 at 7:47
• @Nasser corrected Mar 18, 2019 at 8:47

Mathematica always did this, and I do not know of an option or assumption to avoid this. But I always did something like this for this case

ClearAll[g, y, k, Gy];
sol = DSolve[{g''[y] - k^2/Gy g[y] == 0}, g[y], y];
sol = Simplify[ExpToTrig[sol]];
sol /. {C[1] + C[2] -> C[3], C[1] - C[2] -> C[4]}


btw, Maple also does similar thing here.

ode:=diff(g(y),y\$2)-k^2/Gy*g(y)=0;
sol:=dsolve(ode,g(y));
convert(sol,trig);
simplify(%);


Sometimes you have to manipulate the CAS output a little.