# Solving IVP with differential equation $y'' - 2y' + 2y = x + 1$

I need to solve the following IVP. I've just recently started to learn about differential equations, so I would appreciate if you could check my work, and point out any mistakes. Also, should problems of this type always be solved by the next method?

Problem: Solve the following initial value problem: \begin{align*} y'' - 2 y' + 2y = x + 1, \qquad y(0) = a, \quad y'(0) = 0. \end{align*}

Attempt: The associated homogeneous differential equation $$y'' - 2 y' + 2y = 0$$ has characteristic equation $$r^2 - 2r + 2 = 0.$$ The complex roots of this equation are $$r_{1,2} = 1 \pm i.$$ Hence the homogeneous differential equation has the following general solution: \begin{align*} y_h (x) = e^x (c_1 \cos x + c_2 \sin x), \end{align*} with $c_1, c_2$ constants. The RHS $f(x) = x + 1$ of the original ODE can be solved by the method of undetermined coefficients, and we guess a solution has the form $$y_p(x) = Ax + B$$ with $y_p'(x) = A$ and $y_p''(x) = 0$. Substituting this in the original differential equation gives $$0 - 2A + 2(Ax + B) = x + 1.$$ Equating coefficients of like powers gives \begin{align*} \begin{cases} 2A &= 1 \\ -2A + 2B &= 1 \end{cases} \end{align*} so that $A = 1/2$ and $B = 1$. So a particular solution of the ODE is $$y_p(x) = \frac{1}{2} x + 1.$$ But this does not have the required initial conditions. So we write the general solution of the ODE as \begin{align*} y(x) &= y_h(x) + y_p(x) \\ &= e^x (c_1 \cos x + c_2 \sin x) + \frac{1}{2} x + 1 \end{align*} so that \begin{align*} y'(x) = c_1 e^x (\cos x - \sin x) + c_2 e^x (\sin x + \cos x) + \frac{1}{2}. \end{align*} Then, on applying the initial conditions: \begin{align*} y(0) = a = c_1 + 1 \qquad \text{and} \qquad y'(0) = 0 = c_1 + c_2 + \frac{1}{2} \end{align*} Together this gives $c_1 = a - 1$ and $c_2 = \frac{1}{2} - a$. Hence the solution of the given IVP is $$y(x) = (a-1) e^x \cos x + (\frac{1}{2} - a) e^x \sin x + \frac{1}{2}x + 1.$$

• Looks fine to me. W|A agrees. – dbanet Oct 2 '15 at 22:37
• Looks good to me. – Mark Watson Oct 2 '15 at 22:57
• Ok, Thank you. Then I guess it is correct. Wasn't sure =-) – Kamil Oct 2 '15 at 22:59