# Do I have something wrong when solving $y'+2y=6$?

Solve $$y'+2y=6.$$

When I do $$y'=2(3-y)\implies\int\frac{\mathrm dy}{3-y}=2\int\mathrm dx\implies-\ln{|3-y|}=2x+c\implies3-y=ke^{-2x}\therefore y=\boxed{3-ke^{-2x}},\quad c,k\in\Bbb R.$$ It satisfies the ODE because $$2ke^{-2x}+6-2ke^{-2x}=6=6.$$ However, when I try another solution, namely first solve the homogeneous equation: $$y'+2y=0\implies\int\frac{\mathrm dy}y=-2\int\mathrm dx\implies\ln{|y|}=-2x+c\implies y=ke^{-2x},\quad c,k\in\Bbb R$$ then $$y_P=k(x)e^{-2x}$$, so then $$y'_P=k'(x)e^{-2x}-2k(x)e^{-2x}\implies k'(x)e^{-2x}-2k(x)e^{-2x}+2k(x)e^{-2x}=6\implies k'(x)=6e^{2x}\implies k(x)=3e^{2x}\implies y_P=3e^{2x}e^{-2x}=3\therefore y=y_H+y_P=\boxed{3+ke^{-2x}},$$ where this solution also satisfies $$y'+2y=6$$, because $$-2ke^{-2x}+6+2ke^{-2x}=6=6.$$ My question is, how can we express both solutions with the same expression of $$y$$? I would like both solutions to be identical, but how?

Thanks!

## 3 Answers

Both solutions are the same, $$k$$ is a real number, you can write $$3+(-k)e^{-2x}$$.

• Oh I forgot that, thank you!! – manooooh Jan 15 at 0:32

They are identical. You have no reason to expect $$k$$ from one method to be exactly the same from the other method. If you include an initial condition, you'll get the same solution in both cases.

• There is indeed an initial condition, but I wanted to know why I end up with two "different" solutions. Thanks! – manooooh Jan 15 at 0:34

To see both are the same: $$-\ln|3-y|=2x+A \Rightarrow \ln|3-y|=-2x-A \Rightarrow |3-y|=e^{-2x-A} \Rightarrow |3-y|=e^{-A}e^{-2x} \Rightarrow 3-y=-Ce^{-2x} \Rightarrow y=3+Ce^{-2x}.$$ Alternatively (instead of variations): $$y=y_h+y_p=Ce^{-2x}+A;\\ [Ce^{-2x}+A]'+2[Ce^{-2x}+A]=6 \Rightarrow \\ 2A=6 \Rightarrow A=3 \Rightarrow \\ y=Ce^{-2x}+3.$$

• Oh, you did $e^{-A}\to-C$ when $|3-y|\to(3-y)$ instead of $e^{-A}\to C$, that is nice! Also I like your approach $\ddot\smile$. – manooooh Jan 15 at 1:15