# Working with complex roots in a second order linear ODE

The ODE I'm trying to solve is: $y''+2y'+2y = 3$. I've never tried to solve an ODE with complex roots until this problem so it's challenge for me. These are my steps for getting r: $$a_2r^2 +a_1r+a_0=0$$ $$r^2+2r+2=0$$ $$(r+1)^2 = -1$$ $$r = \pm i-1$$ $Q_2(x) = \frac32$ and these are my last few steps plugging everything into the final equation: $$y = c_1e^{r_1x}+c_2e^{r_2x}+Q_k(x)$$ $$y = c_1e^{(i-1)x} + c_2e^{(-i-1)x} + \frac32$$ $$y = c_1 e^{-x} (\cos{x}+i\sin{x})+ c_2 e^{-x} (\cos{x}-i\sin{x})+\frac32$$

I think somehow the imaginary answers should cancel each other out, but they don't. Wolfram alpha gives

$$y = c_1 e^{-x}\sin{x} + c_2e^{-x}\cos{x}+\frac32$$

Where did I go wrong?

• With complex roots, the coefficients can be complex, so that ultimately the solution will be a real-valued function. – Bernard Mar 23 '17 at 23:59

I don't think that you went wrong anywhere but the solution for complex roots $r = \alpha \pm i \beta$ can be expressed as $C_1 e^{\alpha x}\cos(\beta x) + C_2 e^{\alpha x}\sin(\beta x)$. Your solution $r = \pm i -1= -1 \pm i$ gives $\alpha = -1$ and $\beta = 1$, which leads to $C_1 e^{- x}\cos (x) + C_2 e^{- x}\sin( x)$.

Ff you rearrange the solution you found, you'll get

$y = (c_1 + c_2) e^{-x} \cos x + i(c_1 - c_2) e^{-x} \sin x + \frac{3}{2}$

Then, use the substitution $a_1 = c_1 + c_2$, $a_2 = i(c_1 - c_2)$ to get the solution Wolfram Alpha found.

But, you may ask, doesn't that mean that some of those constants might be complex? Well, yes. But that's fine - nothing in there prevented any of that happening, and it can happen no matter how you rearrange the formula (there's nothing stopping $a_1$ and $a_2$ from being complex). However, this is just the general form of the solution. Particular solutions could wind up having completely real coefficients, depending on how they're defined.

$y =$$C_1e^{-x}(\cos x + i \sin x) + C_2e^{-x}(\cos x - i \sin x)+\frac32\\ (C_1 + C_2) e^{-x}(\cos x + i \sin x) + (iC_1 - iC_2) e^{-x} \sin x + \frac 32$

$(C_1 + C_2)$ is just an arbitrary constant. As is $(iC_1 - iC_2).$ There nothing that says that arbitrary constants cannot be complex.