Linear ODEs
A First Order Linear ODE can be written as follows:
$$ y'(x) + p(x) y(x) = r(x) $$
It is said to be homogeneous if \(r(x)=0\). The equation does not change its form with the scaling of the dependent variable if \(r=0\):
$$ y \rightarrow a y $$
If it is homogeneous then it is also separable then we know how to integrate. But if it is not homogeneous it may not be separable or
exact. Then we need to find an integrating factor.
$$ f(x) y'(x) + f(x) p(x) y(x) = f(x) r(x) $$
To be exact
$$ (f y)' = f y' + f' y = f r $$
which requires
$$ f' = f p $$
which is separable and has a solution of the form
$$ f(x) = e^{\int p(x) dx} $$
Then the solution of the ODEs
$$ (f y)' = f r \rightarrow f y = \int f r dx + c_1 $$
$$ y(x) = e^{-\int{p(x) dx}} (\int{ e^{\int p(x) dx} r(x) dx} + c_1)$$
Example 1
Solve the following ODE $$ y' - y = 0 $$
solution: separable
$$ \frac{dy}{y} = dx $$
Integration gives: \(log(y) = x + c\) after exponentiation:
$$ y(x) = c_1 e^{x}$$
Method of integrating factor
Example 2
Solve the following ODE $$ y' + (x-1) y = x^2 $$
solution:
$$ f = e^{\int (x-1) dx} = e^{x^2/2 - x}$$
$$ f y' + f (x-1) y = (f y)' = f x^2 $$
$$ f y = \int e^{x^2/2 - x} x^2 dx = e^{1/2 (x - 2) x} (x + 1) + c_1 $$
$$ y(x) = c_1 e^{x - x^2/2} + x + 1 $$
Example 3
Solve the initial value problem $$ y' + 2x y = x,\;\; y(0) = 2 $$
solution:
$$ f = e^{\int 2 x dx} = e^{x^2}$$
$$ f y' + f 2x y = (f y)' = f x $$
$$ f y = \int e^{x^2} x dx = \frac{1}{2} e^{x^2} + c_1 $$
$$ y(x) = c_1 e^{-x^2} + \frac{1}{2} $$
$$ y(0) = c_1 + \frac{1}{2} = 2 \to c_1 = \frac{3}{2}$$
$$ y(x) = \frac{3}{2} e^{-x^2} + \frac{1}{2} $$