[Math] Solve second order differential equation of resonance.

ordinary differential equations

Solve equation
$$ y'' + y = \sin x $$

$$y=e^{rx}$$

$$r^2e^{rx}+e^{rx}=0$$

$$r^2 +1 =0$$

$$r=-i, \ r =i \tag{1}$$

I use the equation
$$y=y_0 + A e^{\alpha x} \cos\beta x + Be^{\alpha x} \sin\beta x$$

where from $(1)$: $\alpha = 0 ,\ \beta = 1 $ or $\alpha = 0 ,\ \beta = -1 $

I get
$$y = A \cos x + B \sin x $$ $$y = A \cos x – B \sin x$$

because $A,\ B$ are real constants the only solution is:

$$ y = y_0 + A \cos x + B \sin x ,\ A,B \in \mathbb{R} $$

$$ y_0 = u_1(x) \cos x + u_2(x) \sin x $$

$$ y_0' = u_1'\cos x -u_1\sin x + u_2' \sin x + u_2 \cos x \tag{2} $$

There is assumption which I don't understand:

$$ u_1' \cos x + u_2'\sin x =0 $$

and with this assumption from $(2)$

$$ y_0'= -u_1\sin x + u_2\cos x $$

$$y_0'' = -u_1'\sin x -u_1\cos x + u_2'\cos x -u_2\sin x $$

And then we have two equations which we have to solve:

$$ u_1'\cos x +u_2'\sin x = 0 $$

$$ -u_1'\sin x +u_2'\cos x = \sin x $$

Best Answer

$$y''+y=\sin(x)$$ This is a second order linear non-homogeneous ODE.

First, solve the associated second order linear homogeneous ODE : $$Y''+Y=0 \quad\to\quad Y=A\cos(x)+B\sin(x)$$ $A$ and $B$ are constants.

Second, find a solution of the non-homogeneous ODE thanks to the variation of parameters method (for example). That is, remplace the constants by functions : $$y_0(x)=f(x)\cos(x)+g(x)\sin(x)$$ Note that we don't need to solve for the general solution $y(x)$ but only for any one solution $y_0(x)$ A short way should be to guess a simple form for the functions $f(x)$ and $g(x)$, linear in the present case. Supposing that we cannot guess, then :

$y_0'=(f'+g)\cos(x)+(g'-f)\sin(x)$

$y_0''=(f''+2g'-f)\cos(x)+(g''-2f'-g)\sin(x)$

$y_0''+y_0=\sin(x)=(f''+2g'-f)\cos(x)+(g''-2f'-g)\sin(x)+f\cos(x)+g\sin(x)$

$(f''+2g')\cos(x)+(g''-2f')\sin(x)=\sin(x)\quad\to\quad \begin{cases}f''+2g'=0\\g''-2f'=1\end{cases}$

Of course, we could continue and use a sledgehammer to crack a nut! But since we don't need all solutions, but only one, obviously $\quad f=-\frac{x}{2}\quad $ and $\quad g=0\quad$ is sufficient. $$y_0(x)=-\frac{x}{2}\cos(x)$$ The general solution of $y''+y=\sin(x)$ is : $\quad y(x)=y_0(x)+Y(x)$ $$y(x)=-\frac{x}{2}\cos(x)+A\cos(x)+B\sin(x)$$