How can I solve $~f''(x)+f(x)=0~$ for $~x~$ is real number? I know how to solve this when domain of $f$ is complex number. but domain of $f$ is real number, I can't solve. I know $f$ is smooth function. So I show
$$ f(x)^2+f'(x)^2 $$is constant
and$$ f(x)=C\sin{g(x)}~.$$ But I don't know $g(x)$ has derivative. How can I solve this? do you have other way?
 A: Suppose $y=f(x)$ then the equation reduces to $\frac{d^2y}{dx^2}+y=0$ and so the Auxilary equation becomes $m^2+1=0$ [which we obtained by putting $y=e^{mx}$ and $e^{mx}$ never vanishes] thus $m=\pm i$ and so the general solution is $y=A\cos x+B\sin x$ where $A,B$ are arbitrary constants.
Again by suitable substitution [try for yourself], we can show that the solution can be written of the form $y=A'\sin (x+B')$ where $A', B'$ are arbitrary constants.
Thus $y=f(x)=A'\sin(x+B')$ and $f'(x)=A'\cos(x+B')$ and hence $f'^2+f^2=A'^2$ which is constant. Further setting $g(x)=x+B'$ gives $f(x)=A'\sin g(x)$.
Hope it works.
A: Without complex numbers, but with Picard-Lindelöf I will show that the general solution of the differential equation 
$$(1) \quad f''(x)+f(x)=0$$
is given by
$$(2) \quad f(x)=A \sin x+ B \cos x,$$
where $A,B \in \mathbb R.$
It is easy to see that the functions in $(2)$ are all solutions of $(1)$.
Now let $z: \mathbb R \to \mathbb R$ be a solution of $(1)$. Then put $z_0:=z(0), z_1:=z'(0)$ and
$$y(x)=z_1 \sin x +z_0 \cos x.$$
Then the functions $z$ and $y$ are both solutions of the IVP
$$ f''(x)+f(x)=0, \quad f(0)=z_0, \quad f'(0)=z_1.$$
By Picard-Lindelöf, we get that $z=y$, hence $z$ is of the form $(2)$.
A: Continue with the observation $f'(x)=C\cos(g(x))$, following from interpreting
$$
f(x)^2+f'(x)^2=C^2
$$
as circle equation. As long as $C>0$, the transformation of the pair $(f(x),f'(x))$ into polar coordinates is a smooth transformation, as one locally gets
\begin{align}
f(x+h)&=C\sin(g(x+h))=f(x)\cos(g(x+h)-g(x))+f'(x)\sin(g(x+h)-g(x))\\
f'(x+h)&=C\cos(g(x+h))=f'(x)\cos(g(x+h)-g(x))-f(x)\sin(g(x+h)-g(x))
\end{align}
so that
$$
g(x+h)=g(x)+\arctan\left(\frac{f(x+h)f'(x)-f'(x+h)f(x)}{f(x+h)f(x)+f'(x+h)f'(x)}\right)
$$
so that indeed $g$ is as smooth as $f$ is, so at least twice continuously differentiable.
Next compare the derivatives
$$
C\cos(g(x))=f'(x)=\frac{d}{dx}(C\sin(g(x)))=C\cos(g(x))g'(x)
$$
from which $g'(x)=1$ follows. The situation at points with $\cos(g(x))=0$, constant solutions or a switch to a constant segment, can be excluded by referring back to the original second order equation.
A: So you can do this (if you will allow complex numbers to be used in the workings):
$$f''(x)-if'(x)+if'(x)+f(x)=0=f''(x)-if'(x)+i(f'(x)-if(x))$$
Now let $g(x)=f'(x)-if(x)$ so that $g'(x)+ig(x)=0$
Next let $h(x)=e^{ix}g(x)$ so that $h(x)=ie^{ix}g(x)+e^{ix}g'(x)=0$
This means $h(x)=C$ is constant and $f'(x)-if(x)=Ce^{-ix}$
By similar means (using $-i$ instead of $i$) obtain $f'(x)+if(x)=De^{ix}$
And these can be solved for $f(x)=Ae^{ix}+Be^{-ix}=P \sin x + Q \cos x$ and will evidently generate a real valued solution for $f(x)$ when $P$ and $Q$ are real.
