# Linear Differential Equations

fact
A linear first-order differential equation is a differential equation that can be placed in the form: $$\frac{dy}{dt} + p(t)y = g(t)$$ Where both $$p(t)$$ and $$g(t)$$ are continuous functions.
fact
The solution to a first-order differential equation is given by: $$y = \frac{\int \mu (t)g(t)dt + c}{\mu (t)}$$ Where $$\mu (t) = e^{\int p(t)dt}$$ And $$c$$ is the integration constant from the integration in the numerator. We write it explicitly because it's very important to include and is incredibly common to forget about.
example

Solve $$y' = 9.8 - 0.196t$$

Rearrange to get it into canonical form: $$y' + 0.196t = 9.8$$ Here $$p(t) = 0.196$$ and $$g(t) = 9.8$$ So $$\mu = e^{\int 0.196dt} = e^{0.196t}$$ Now $$y = e^{-0.196t}(\int 9.8e^{0.196t}dt + c) = 50 + ce^{-0.196t}$$
example

Solve $$xy' + 2y = x^2 - x + 1$$

Rearranging into linear canonical form by dividing everything by $$x$$ we get: $$y' + \frac{2}{x}y = x - 1 + \frac{1}{x}$$ So $$p(x) = \frac{2}{x}$$ and $$g(x) = x - 1 + \frac{1}{x}$$ Then $$\mu = e^{\int \frac{2}{x}dx} = e^{2\ln(x)} = e^{\ln(x^2)} = x^2$$ And $$y = x^{-2}(\int x^2\times (x - 1 + \frac{1}{x})dx + c)$$ $$y = x^{-2}(\int (x^3 - x^2 + x)dx + c)$$ $$y = x^{-2}(\frac{x^4}{4} - \frac{x^3}{3} + \frac{x^2}{2} + c)$$ $$y = \frac{x^2}{4} - \frac{x}{3} + \frac{1}{2} + \frac{c}{x^2}$$
example

Solve $$y' - y - xe^x = 0$$

Rewrite into standard form: $$y' - y = xe^x$$ Now $$p(x) = -1$$ and $$g(x) = xe^x$$ So $$\mu = e^{\int -1dx} = e^{-x}$$ And $$y = e^x(\int(e^{-x}xe^xdx) + c)$$ $$y = e^x(\frac{1}{2}x^2 + c)$$
practice problems