How can a $\sin x$ come out of the equation $\frac{d^2}{dx^2}f(x)=-f(x)$ as the solution, while there's no sign of a trigonometric function in it? This is a differential equation:
$$\frac{d^2}{dx^2}f(x)=-f(x)$$
Turns out that the answer is $\sin x$. But HOW?!
It is impossible to achieve a trigonometric function by integrating that equation. How have mathematicians solved this?
I agree that $\sin x$ is the correct answer because its second derivative is $-\sin x$, but I have no idea how one may have obtained it from the equation.
Other examples are like:
$$\frac{d}{dx}f(x)=f(x)$$
Which leads to $e^x$.
 A: You might in a related way ask "how does a radical show up in the solution to $x^2 + 3x + 7 = 0$?" or "How does a fraction show up in the solution to $3x + 2 = 9$? 
There were no square roots in the first equation, and no fractions in the second...
The answer, to some degree, is  that "sine and cosine are the names we give to the fundamental class of solutions to 2nd order linear ODEs with constant coefficients and the right sort of discriminant," and that "exponentials are the name we give to a class of functions that satisfy linear first order differential equations with constant coefficients." 
Now you might say "Wait a minute! Sines and cosines come from triangles! And exponentials come from ... well...taking powers of 2, for instance!" 
But those powers of two can be related to a discrete version of the differential equation that defines exponentials, and (with more work) things having to do with triangles and circles can be tied to the constant coeff diff. eqns that produce sines and cosines. So it's really a chicken and egg problem. 
But I'll stand back for a moment and agree with you: it is surprising at first, and delightful, to see these disparate things related. 
A: Using the differential equation to get a recursion for a power series expansion for solutions, and recognizing the power series expansion of sine and/or cosine, succeeds.
An approach that avoids power series, and avoids exponential functions: write $y''=-y$ as $d(y')/dx=-y$, multiply by $1/{dy\over dx}$ to have (heuristically!) $d(y')/dy=-y/y'$ and then $y'\,dy'=-y\,dy$. Integrate to $(y')^2=C-y^2$. Taking $C=1$ and multiplying through by $dx$ (!), this gives $dy/\sqrt{1-y^2}=dx$, which integrates to $\arcsin y=x+C$. :)
A: Even without using complex numbers, one can show the solution $y(x)$ of the equation, which satisfies the initial conditions $y(0)=0,\;y'(0)=1$ is necessarily periodic, first increases, then decreases, then increases gain. 
The theory of trigonometric functions can be entirely based on this differential equation. If I remember well, it is an exercise in M. Spivak's Calculus.
I'll show this equation ‘contains’ the seeds of all properties of trigonometric functions on a simple example: we have 
$$y^2+y'^2=1.$$
Indeed, the derivative of the l.h.s. is 
$$$2yy'+2y'y''=2yy'-2y'y=0,$$
hence by the Mean value theorem, $y^2+y'^2$ is a constant function. This constant is equal to $y(0)+y'(0)=1$.
Note
If you interpret the equation $y''+y=0$ as the equation which rules a mechanical system such as a pendulum, the relation $y^2+y'^2=\sin^2x+\cos^2x=1$ is but the law of conservation of energy.
A: If you know that $\sin x=\sum\limits_{n=0}^\infty {(-1)^n x^{2n+1}\over(2n+1)!}$ and $\cos x=\sum\limits_{n=0}^\infty {(-1)^n x^{2n}\over(2n)!}$, then you can try solve it with a power series solution.
Let $f(x)=\sum\limits_{n=0}^\infty a_n x^n$, then $f''(x)=\sum\limits_{n=0}^\infty n(n-1)a_n x^{n-2}=\sum\limits_{n=2}^\infty n(n-1)a_n x^{n-2}=\sum\limits_{n=0}^\infty (n+2)(n+1)a_{n+2} x^{n}$
Since $f''(x)=-f(x)$ then $$\sum\limits_{n=0}^\infty -a_n x^n=\sum\limits_{n=0}^\infty (n+2)(n+1)a_{n+2} x^{n}$$
So with some arguments about linear independence of $\{x^n\}_{n\in\Bbb n}$, term by term they must agree so:
$-a_n=(n+2)(n+1)a_{n+2}$ or $a_{n+2}=\frac{-a_n}{(n+2)(n+1)}$.
This splits for odd and even $n$, $a_{2n}$ is solved in terms of $a_0$, and $a_{2n+1}$ in terms of $a_1$
So $a_{2n}=\frac{a_0(-1)^n}{(2n)!}$ and $a_{2n+1}=\frac{a_1(-1)^n}{(2n+1)!}$
Initial conditions on the differential equation will nail down $a_0$ and $a_1$, but the general solution can be written with some care taken noting convergence as $$f(x)=\sum\limits_{n=0}^\infty a_n x^{2n}=\sum\limits_{n=0}^\infty a_{2n} x^n+ a_{2n+1}x^{2n+1}=\sum\limits_{n=0}^\infty a_{2n} x^n+ \sum\limits_{n=0}^\infty a_{2n+1}x^{2n+1}$$
$$=\sum\limits_{n=0}^\infty \frac{a_0(-1)^n}{(2n)!} x^n+ \sum\limits_{n=0}^\infty \frac{a_1(-1)^n}{(2n+1)!}x^{2n+1}=a_0 \cos(x)+a_1\sin(x)$$
A: Basically, the thought process could go like this:


*

*If I derive twice, that's the same as multiplying the function with $-1$

*Hence, if I derive once and it's the same as multiplying with $\pm i$, I'm done 

*Thus, $e^{\pm ix}$ both yield a solution
Now, we note that $\sin{x}=\frac{e^{ix}-e^{-ix}}{2i}$, and there's our trigonometric function.
A: I found it helpful to think about the two dimensional problem of a particle traveling on a circular path.
the position at time $t,(x,y) = (\cos t, \sin t)$
The direction of travel (velocity) is perpendicular to radius.  $(x',y') = (-\sin t, \cos t) = (-y, x)$
The acceleration is centripetal.  $(x'', y'') = (-\cos t, - \sin t) = (-x,-y)$
With the model of circular motion in mind, it makes it seem less strange to go to weights on springs, and periodic motion, and the differential equation in the more abstract sense.
And as the work above shows  $\cos t$ and $\sin t$ are both in the solution set of the differential equation $y'' = -y$
A: If you're not familiar with how to solve differential eqs of the form $$a\frac{d^2y}{dx^2} + b\frac{dy}{dx} + cy = f(x)$$ where a b, and c are arbitrary constants, it's just guess and check. You just write down a guess, like $A\sin x + B\cos x + Ce^x$ in your example, where A, B, and C are constants. The reason I chose $A\sin x + B\cos x + Ce^x$ as my guess was because sines and cosines are they're own derivatives (up to a minus sign) and $e^x$ is it's own derivative. Then:


*

*Take the first and second derivative of your guess. In your example, it would be $
guess' = A\cos x - B\sin x + Ce^x$ and $guess'' = -A\sin x - B\cos x + Ce^x. $

*Evaluate $a\frac{d^2y}{dx^2} + b\frac{dy}{dx} + cy$. In your example, it would be $A\sin x + B\cos x + Ce^x =-\left(-A\sin x - B\cos x + Ce^x\right)$.

*Solve for A, B, and C. Since $$-\left(-A\sin x - B\cos x + Ce^x\right) \ne A\sin x + B\cos x + Ce^x,$$ the only possible value for C is $0$, and A and B can be anything.


For an example, look here. The $y_h = C_1e^{4x} + C_2e^{-x}$ in the video comes from here.
A: You can use, Laplace transform:
$$f''(x)=-f(x)\Longleftrightarrow$$
$$\mathcal{L}_x\left[f''(x)\right]_{(s)}=\mathcal{L}_x\left[-f(x)\right]_{(s)}\Longleftrightarrow$$

Now, use:


*

*$$\mathcal{L}_x\left[f(x)\right]_{(s)}=\text{F}(s)$$

*$$\mathcal{L}_x\left[f''(x)\right]_{(s)}=s^2\text{F}(s)-sf(0)-f'(0)$$


$$s^2\text{F}(s)-sf(0)-f'(0)=-\text{F}(s)\Longleftrightarrow$$
$$s^2\text{F}(s)+\text{F}(s)=sf(0)+f'(0)\Longleftrightarrow$$
$$\text{F}(s)\left[s^2+1\right]=sf(0)+f'(0)\Longleftrightarrow$$
$$\text{F}(s)=\frac{sf(0)+f'(0)}{s^2+1}$$
Now, with inverse Laplace transform:
$$\text{F}(s)=\frac{sf(0)+f'(0)}{s^2+1}\Longleftrightarrow$$
$$\mathcal{L}_s^{-1}\left[\text{F}(s)\right]_{(x)}=\mathcal{L}_s^{-1}\left[\frac{sf(0)+f'(0)}{s^2+1}\right]_{(x)}\Longleftrightarrow$$
$$f(x)=\mathcal{L}_s^{-1}\left[\frac{sf(0)}{s^2+1}+\frac{f'(0)}{s^2+1}\right]_{(x)}\Longleftrightarrow$$
$$f(x)=\mathcal{L}_s^{-1}\left[\frac{sf(0)}{s^2+1}\right]_{(x)}+\mathcal{L}_s^{-1}\left[\frac{f'(0)}{s^2+1}\right]_{(x)}\Longleftrightarrow$$
$$f(x)=f(0)\cdot\mathcal{L}_s^{-1}\left[\frac{s}{s^2+1}\right]_{(x)}+f'(0)\cdot\mathcal{L}_s^{-1}\left[\frac{1}{s^2+1}\right]_{(x)}\Longleftrightarrow$$

Now, use:


*

*$$\mathcal{L}_s^{-1}\left[\frac{s}{s^2+1}\right]_{(x)}=\cos(t)$$

*$$\mathcal{L}_s^{-1}\left[\frac{1}{s^2+1}\right]_{(x)}=\sin(t)$$



$$f(x)=f(0)\cos(t)+f'(0)\sin(t)$$
