Intuition behind Showing if $f + f'' = 0$ and if $f(0)=a$ and $f'(0)=b$, then $f(x) = b \sin x + a \cos x$ I'm reading chapter 15 of Spivak's Calculus book, 'Trigonometric functions', and at some point, after defining sin and cos, he proves the 'addition formula' $\sin(x+y) = \sin(x)\cos(y) + \cos(x)\sin(y)$
He first starts with a lemma:
Suppose f has a second derivative everywhere and:
$f'' + f = 0$,
$f'(0) = 0$,
$f(0)= 0$,
then 
$$f = 0$$
The proof he gives is elementary and it's at the end of the post.
Then he proves this theorem:
Suppose f has a second derivative everywhere and:
$f'' + f = 0$
$f'(0) = b$
$f(0)= a$
then $$f = a\cos(x) + b\sin(x)$$
Now at this point I was totally impressed, nowhere in the hypoteses did sin or cos appear and they magically appear at the end.
The proof:
Let $$g(x) = f(x) - b\sin(x) - a\cos(x)$$
then $g'(x) = f'(x) -b\cos(x) + a\sin(x)$ and $g''(x) = f''(x) +b\sin(x) + a\cos(x)$
Then $g'' + g = 0$, $g(0) = 0$,$g'(0) = 0$
And then $$g = 0,$$ the conclusion follows. Then proving the addition formula is actually really easy.
I am just shocked, I understand every part of the proof, but, why???,
Why, if a function f satistfies those conditions, then it's related to sin and cos. It's impressive because the only information he used was the derivatives of sin and cos, nothing else.
Is there a nice intuition behind this??
Also, how do you even think on such a proof?, it's seems so elementary but so complicated at the same time, those kind of proofs are really common in his book and really cool, but i have a hard time imagining myself coming up with this kind of proofs.
Lemma:

 A: Elaborating on the comments I made above, it's easier to see what's going on here if you realize the lemma above (call it Lemma 1 now) is equivalent to a uniqueness statement. So if you find any solution, it will be the solution. With that in mind, here's another version of the same proof that might be easier to digest. 
Lemma 2. Suppose $f, g$ satisfy $$f(0) = g(0) = a,$$ $$f'(0) = g'(0) = b,$$ and $$f'' + f = g'' + g = 0.$$  Then $f = g$. 
Proof: Let $h = f-g$.  Then $h(0) = f(0) - g(0) = a - a = 0$, and similarly $h'(0) = f'(0) - g'(0) = b-b = 0$; and $$h'' + h = (f - g)'' +  (f-g) = (f'' + f) - (g'' + g) = 0 - 0 = 0.$$  So $h$ satisfies the conditions of Lemma 1 above, so $h = 0$, and $f = g$.
Theorem. Suppose $f$ satisfies 
$f'(0) = b$, $f(0)= a$, and $f'' + f = 0$.
Then $$f(x) = a\cos(x) + b\sin(x).$$
Proof.  Let $g(x) = a\cos(x) + b\sin(x)$.  Then $g$ satisfies $g(0) = a$, $g'(0) = b$, and $g'' + g = 0$ (check this.)  By Lemma 2, $f = g$.
A: If you play a little with derivatives of functions, you can observe
$$(x^n)''=n(n-1)x^{n-2},$$
$$(\log x)''=-\frac1{x^2},$$
$$(e^x)''=e^x,$$
$$(\cos x)''=-\cos x,$$
$$(\sin x)''=-\sin x,$$
$$\cdots$$
Hence you notice that the last two functions fulfill $f''+f=0$. This is a well-known mathematical fact and a basic property of the trigonometric functions.

Based on the interesting observation that $$(e^x)'=e^x$$ one can in fact solve any homogeneous linear differential equation with contant coefficients. Because we can generalize
$$(e^{ax})'=ae^{ax},$$
$$(e^{ax})''=a^2e^{ax},$$
$$(e^{ax})^{(n)}=a^ne^{ax},$$
and with an equation like
$$f''+3f'+2f=0,$$ by plugging $e^{at}$ we get
$$f''+3f'+2f=a^2e^{at}+3ae^{at}+2e^{at}=(a^2+3a+2)e^{at}=0$$ which is true with $a=-1$ or $a=-2$, the roots of the polynomial.

In the case of $$f''+f=0,$$ the polynomial is $a^2+1=0$ and the roots $\pm i$, giving the solutions
$$e^{\pm ix}=\cos x\pm i\sin x.$$

Final note: the general solution of a linear differential equation of order $n$ is always a linear combination of $n$ linearly independent functions.
Hence
$$f''+f=0\iff f(x)=ce^{ix}+de^{-ix}=a\cos x+b\sin x$$ for suitable constants that you can determine for example knowing two initial conditions $f(0)=a\cos 0+b\sin 0, f'(0)=-a\sin0+b\cos0$.
