# solve $y'=ay+b$ [duplicate]

I have this differential equation which I want to solve

$\displaystyle\frac{dT_i}{dt}=\frac{1}{RC}(T_a-T_i)+\frac{1}{C} \Phi_h$

I know it is in the form

$y'=ay+b$

But how can I solve it ?

If you have $$y'(x)=ay(x)+b(x),$$for constant $a$, then the simpliest way is to multiply the equation by $e^{-ax}$ (nonzero everywhere) and deduce that $$(y(x)e^{-ax})' = e^{-ax}b(x),$$which implies that $$y(x)e^{-ax} - y(0) = \int_0^x e^{-as}b(s)ds.$$ Finally, $$y(x) = y(0)e^{ax} + \int_0^x e^{-a(x-s)}b(s)ds.$$

• Reminds me of the Laplace transform. Dec 17, 2014 at 21:03
• Why solve an equation the OP didn't propose? And if so, why stop at $b(x)$? Consider $b(y)$ as well! Dec 17, 2014 at 21:41
• @JohnD calm down, please. From the initial question it is unclear whether $a$ and/or $b$ are constant or are functions of $x$. In my answer I used the case $b=b(x)$ because the proposed method still works and because it could be of help for other readers. Dec 17, 2014 at 21:47
• This is solving what the OP asked. He identified the general equation form, and this is just rearranging that. Therefore, I would say that you set up the answer to the question he asked, without getting bogged down in the specific terms he has in his equations. +1. Dec 17, 2014 at 22:17

As a separable equation:

\begin{align} {dy\over dx}&=ay+b\\ {dy\over ay+b}&=dx\\ \int {dy\over ay+b}&=\int\,dx\\ {1\over a}\ln|ay+b|&=x+C\\ \ln|ay+b|&=ax+aC\\ e^{\ln|ay+b|}&=e^{ax+aC}\\ |ay+b|&=e^{ax}e^{aC}\\ ay+b&=\pm e^{aC}e^{ax}\\ ay+b&=De^{ax}, \quad D\not= 0\\ y&=Ke^{ax}-{b\over a} \end{align}

You can also solve it via an integrating factor:

\begin{align} y'-ay&=b \qquad\quad\therefore\text{integrating factor is }e^{\int -a\,dx}=e^{-ax}\\ e^{-ax}(y'-ay)&=e^{-ax}b\\ [e^{-ax}y]'&=be^{-ax}\\ \int[e^{-ax}y]'\,dx&=\int be^{-ax}\,dx\\ e^{-ax}y&={be^{-ax}\over -a}+C\\ y&=-{b\over a}+Ce^{ax} \end{align}

• The separation of variables can lead to many errors... Dec 17, 2014 at 21:00
• Any method done incorrectly can. Separating the variables is a perfectly legitimate method. Dec 17, 2014 at 21:06
• Indeed, it is a legitimate method. Yet what happens with your deductions when $ya+b=0$? Moreover, if $b$ is a function of $x$, then this method fails, too. Dec 17, 2014 at 21:35
• If $y'=0$, it isn't a differential equation so we don't undertake the method. Yes it fails if $b$ is a function of $x$. It also fails if $b$ is an elephant, too. But neither was asserted in the problem statement. The context indicates that $a$ and $b$ are constants here. Dec 17, 2014 at 21:39
• No, the problem here come from the fact that a priori when you make the first division, you can not guarantee that the denominator $ay+b$ is not zero - hence you need to use the argument along the lines of given the initial data, we have a non-zero right hand side is some neighbourhood of initial data, therefore we can divide by $ay+b$ and only then you can make some integrations and finally prove that $ay+b$ is never zero. Dec 17, 2014 at 21:44

$$\dfrac{1}{a}\int \dfrac{dy}{y+\dfrac{b}{a}}=\dfrac{1}{a}\int\dfrac{d\left(y+\dfrac{b}{a}\right)}{y+\dfrac{b}{a}}=\int dx$$