# Answer format for ordinary differential equations

My professor's worked example for solving a partial differential equation using variable splitting seems to choose the format of solutions for the ordinary differential equations at random. For example, splitting the 1D diffusion equation $$\frac{\delta^2\rho}{\delta x^2} = \frac{1}{c}\frac{\delta \rho}{\delta t}$$ into $$\rho(x, t) = X(x)T(t)$$ gave me the ODE $$\frac{d^2 x}{dx^2} + kx^2 = 0$$, which I solved as $$X(x) = Ae^{ikx}+Be^{-ikx}$$ (which is correct). My professor gave $$X(x) = A\sin(kx) + B\cos(kx)$$. I'm aware that these are equivalent, but why did she choose to answer using trig functions? We've been taught to solve ODEs using exponentials so it's not like the answer was just in that form, and the other ODE was answered using an exponential. I understand that it could make the rest of the problem easier to solve but is that even recognisable at that point in the working?

• The expression for $X(x)$ is manifestly real, and in applications one often only wants real solutions. Commented May 16, 2023 at 19:44
• In your solution, the coefficients $A,B$ are complex numbers; in your professor's, they are real. They both (should!) amount to the same solution, which can be verified with Euler's formula. Commented May 16, 2023 at 19:50
• And also, the representation in terms of sines and cosines lends itself to apply boundary conditions. Commented May 16, 2023 at 19:50

$$y'' + k^2 y = 0$$
where $$y$$ is a real-valued function of $$x$$, is $$y = A \cos kx + B \sin kx$$.
You can do this just by identifying that the DE can also be written as $$y'' = -k^2 y$$, and noting that the sine and cosine functions both have the property that their second derivatives are the negative of the function itself.
As you noted, you can also write the general solution as $$y = C e^{ikx} + D e^{-ikx}$$, but you then have to do extra work to note that if $$y$$ is restricted to taking real values then there are restrictions on $$C$$ and $$D$$ (which are going to be complex numbers) to ensure that the imaginary parts of the expression cancel out.