Prove that if $f''(x)+25f(x)=0$ then $f(x)=Acos(5x)+Bsin(5x)$ for some constants $A,B$ Suppose $f: \mathbb{R} \rightarrow \mathbb{R}$ is twice differentiable.

Prove that if $f''(x)+25f(x)=0$ then $f(x)=Acos(5x)+Bsin(5x)$ for some constants $A,B$



Consider $g(x):= f(x)-Acos(5x)-Bsin(5x)$ where $A$ and $B$ are chosen so that $g(0)=g'(0)=0$ [this portion is given, so can someone explain why it is important?]

For reference, we note that
$g(x):= f(x)-Acos(5x)-Bsin(5x)$
$g'(x):= f'(x)+5Asin(5x)-5Bcos(5x)$
$g''(x):= f''(x)+25Acos(5x)+25Bsin(5x)$

Consider the derivative of $\frac{25}{2}g(x)^2+\frac{1}{2}g'(x)^2$

$25g(x)g'(x)+g''(x)g'(x)$ if and only if $g'(x)[25g(x)+g''(x)]$

Following substitution, we conclude that 

$g'(x)[25g(x)+g''(x)]=g'(x)(0)=0$

Therefore, by the Constancy Theorem, $\frac{25}{2}g(x)^2+\frac{1}{2}g'(x)^2=C_0$, where $C_0$ is a constant

$25g(x)^2+g'(x)^2=C$, where $C$ is a constant

Thus, 

$25(f(x)-Acos(5x)-Bsin(5x))^2 + (f'(x)+5Asin(5x)-5Bcos(5x))^2=C$



Where do I go from here?
By steps: $g(0)=g'(0)=0$ is important because you have a homogenous differential equation, therefore zero initial data implies that the solution is zero everywhere.

After obtaining that $25(f(x)-A\cos(5x)-B\sin(5x))^2 + (f'(x)+5A\sin(5x)-5B\cos(5x))^2=C$, use initial data $g(0)=g'(0)=0$.

We chose $A$ and $B$ to get $f(x)-A\cos(5x)-B\sin(5x)=0$  and $f'(x)+5A\sin(5x)-5B\cos(5x)=0$ at $x=0$. Therefore we can find $C$ by putting $x=0$:
$$25(f(x)-A\cos(5x)-B\sin(5x))^2 + (f'(x)+5A\sin(5x)-5B\cos(5x))^2=C = 25(f(0)-A\cos(0)-B\sin(0))^2 + (f'(0)+5A\sin(0)-5B\cos(0))^2=0.$$

Hence  $$\forall x\quad 25(f(x)-A\cos(5x)-B\sin(5x))^2 + (f'(x)+5A\sin(5x)-5B\cos(5x))^2 =0.$$
You have the sum of squares equal to zero, therefore each term is zero itself. We can conclude that $\forall x\, (f(x)-A\cos(5x)-B\sin(5x))^2=0$ and, therefore,
$$\forall x\quad  f(x)=A\cos(5x)+B\sin(5x).$$

We conclude that all solutions of the initial differential equation has the above form.
Is it easier just to substitute?
$$f(x)=Acos(5x)+Bsin(5x)$$
then
$$\dot f(x)=-5Asin(5x)+5Bcos(5x)$$
$$\ddot f(x)=-25Acos(5x)-25Bsin(5x)$$
finally:
$$-25Acos(5x)-25Bsin(5x)+25( Acos(5x)+Bsin(5x)) =0 $$
?