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?

  • 1
    $\begingroup$ 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. $\endgroup$ – Vsevolod A. Mar 18 '19 at 7:37
  • $\begingroup$ You have a type in your M code, you typed G_y for Gy $\endgroup$ – Nasser Mar 18 '19 at 7:47
  • $\begingroup$ @Nasser corrected $\endgroup$ – enea19 Mar 18 '19 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]}

Mathematica graphics

btw, Maple also does similar thing here.


Mathematica graphics

Sometimes you have to manipulate the CAS output a little.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.