# Solving the ODE $\frac{d^2 \bar{\phi}}{dx^2} - s \bar{\phi} = \frac{\cos(x)}{s}$ Using Method of Undetermined Coefficients

I am trying to solve the ODE $\dfrac{d^2 \bar{\phi}}{dx^2} - s \bar{\phi} = \dfrac{\cos(x)}{s}$.

If I am not mistaken, I can solve this using the method of undetermined coefficients.

Solving the homogeneous equation

$$\dfrac{d^2 \bar{\phi}}{dx^2} - s \bar{\phi} = 0,$$

we get the characteristic equation

$$m^2 - s = 0,$$

which gives us

$$m = \pm \sqrt{s}.$$

Therefore, the complementary equation is

$$y_c(x) = Ae^{x\sqrt{s}} + Be^{-x\sqrt{s}}$$

What I'm now confused about is the form of the particular solution. Given that we have $\dfrac{\cos(x)}{s}$, how do I go about solving this?

I would appreciate it if people could please take the time to clarify this.

The equation is in $x$, so you can treat $s$ as a constant. Let the particular solution be

$$\phi_p(x) = A\cos x + B\sin x$$

Then ${\phi_p}'' = -A\cos x - B\sin x = -(A\cos x + B\sin x)$, therefore

$${\phi_p}'' - s\phi_p = -(A\cos x + B\sin x) - s(A\cos x + B\sin x) = -(1+s)(A\cos x + B\sin x)$$

This gives

$$A = - \frac{1}{s(1+s)}, B = 0$$

• Thanks for the answer. Where did the $-$ symbol come from? I got $y_p(x) = \left( \dfrac{1}{s^2 - s} \right) \cos(x)$. – The Pointer Aug 28 '18 at 8:47
• That's incorrect. $$-A\cos x - B\sin x - s(A\cos x + B\sin x) = (-1-s)A\cos x + (-1-s)B\sin x = \cdots$$ – Dylan Aug 28 '18 at 8:48
• Hmm, I don't understand where you're getting ${\phi_p}'' = -\phi_p$ from? – The Pointer Aug 28 '18 at 8:50
• Take the second derivative of $\phi_p$, and compare it to $\phi_p$. – Dylan Aug 28 '18 at 8:52
• Again, you did it wrong. Check your signs. $$\left(\frac{1}{s^2-s}\cos x\right)'' - \frac{s}{s^2-s}\cos x = \frac{1}{s-s^2}\cos x + \frac{s}{s-s^2}\cos x = \frac{1+s}{s^2-s}\cos x$$ – Dylan Aug 28 '18 at 8:54

For the particular solution, consider $$A \cos x + B \sin x$$ and find your $A$ and $B$.

• Thanks for the answer. But what about the $\dfrac{1}{s}$? This is what stumped me. – The Pointer Aug 28 '18 at 6:39
• That is a constant and your A and B will depend on it. – Mohammad Riazi-Kermani Aug 28 '18 at 6:45
• I get $-A\cos(x) - B\sin(x) - s(A\cos(x) + B\sin(x)) = \dfrac{\cos(x)}{s}$, but I don't think this is correct. Again, there's something not right with the constant $\dfrac{1}{s}$. – The Pointer Aug 28 '18 at 6:59
• Oh, wait, I actually think that's correct. We get $B = 0$, $A = \dfrac{1}{s^2 - s}$. So we have that $y_p(x) = \left( \dfrac{1}{s^2 - s} \right) \cos(x)$. We now have that $y_p'(x) = \left( -\dfrac{1}{s^2 - s} \right) \sin(x) = \left( \dfrac{1}{s - s^2} \right) \sin(x)$, $y_p'(x) = \left( \dfrac{1}{s - s^2} \right) \cos(x)$. Substituting this back into the ODE, we have $\left( \dfrac{1}{s - s^2} \right) \cos(x) - s \left( \dfrac{1}{s^2 - s} \right) \cos(x) = \left( \dfrac{1}{s - s^2} \right) \cos(x) - \left( \dfrac{1}{s - 1} \right) \cos(x) =$ [...] – The Pointer Aug 28 '18 at 7:44
• [...] $\left( \dfrac{1 - s}{s - s^2} \right) \cos(x) = \left( \dfrac{1}{s} \right) \cos(x)$, as required. – The Pointer Aug 28 '18 at 7:45