Non-homogeneous linear ODEs
Contents
Non-homogeneous linear ODEs#
Recap from last class#
For the 2nd order, linear, constant coefficients, homogeneous differential equation \(y'' + ay' + by = 0\) where \(a^2-4b<0\), the general solution is:
where \(A\) and \(B\) are our arbitrary constants. All components of the solution are real.
Example#
$y’’ + 2y’ + 3y = 0\( ; \)\hspace{0.5cm}y(0) = 2\( and \)y’(0) = -3$\
Characteristic equation:
Since \(a^2 - 4b = -8\), we have complex roots
Great, so we know our general solution is:
To find \(A\) and \(B\), we will also need an expression for \(y'(x)\)
Using Initial Conditions:
and,
\(\underline{\text{Summary}}\): Homogeneous, linear \(2^\circ\) ODEs with constant coefficients
Three types of solutions, arising from three cases for the characteristic equation \(\lambda^2 + a\lambda + b = 0\)
Two real and different roots
(257)#\[\begin{align} y(x) = c_1 ^{\lambda_1x} + c_2 e^{\lambda_2x} && \text{where } \lambda = \frac{1}{2}(-a \pm \sqrt{a^2 - 4b}) \end{align}\]Real, double roots
(258)#\[\begin{align} y(x) = c_1 e^{\lambda x} + c_2 x e^{\lambda x} \end{align}\]Complex roots
(259)#\[\begin{align} y(x) = c_1 e^{-\frac{a}{2}x}[A \sin(\omega x) + B \cos(\omega x)] && \text{where } \omega = \sqrt{b - \frac{1}{4}a^2} \end{align}\]
In each case, we have a basis of \(\underline{\text{two}}\) linearly independent solutions (for \(2^{nd}\) order). \(\rightarrow\) in case there’s just one, this necessitates that \(\lambda_1 \neq \lambda_2\), which is the definition of the case
Non-homogeneous Linear \(2^\circ\) ODEs (sec 2.8)#
We build upon our knowledge of solving the homogenous case to solve non-homogeneous case.
\(\underline{\text{General solution}}\):
where \(y_H(x) = c_1y_1(x) + c_2y_2(x)\), which is the “homogeneous solution” for \(r(x)\equiv 0\) and \(y_P(x)\) is the “particular solution” which accounts for non-homogeneous part and has no arbitrary constants (we need only two for a \(2^\circ\) ODE)
\(\underline{\text{NOTE}}\): \(c_1\) and \(c_2\) must be found using \(y(x) = y_H(x) + y_P(x)\), not just \(y_H(x)\)
We will do an example first and then describe the general method to find \(y_P(x)\)
Example#
\(y'' + 4y = e^x \) ; \(\hspace{0.5cm}y(0) = \frac{3}{5} \) and \(y'(0)=\frac{4}{5}\)
First, solve the homogeneous case:
characteristic equation:
\(\implies\) for imaginary roots, we know the solution is:
Now, I will tell you that
Plugging these into original non-homogeneous equation:
Now we need the particular solution to the general solution of non-homogeneous equation using initial conditions. 1.
(267)#\[\begin{align} y(0) = \frac{3}{5} &= c_1 \sin(2\cdot 0) + c_2 \cos (2\cdot 0) + \frac{1}{5} e^0\\ \frac{3}{5} &= c_2 + \frac{1}{5}\\ c_2 &= \frac{2}{5} \end{align}\]We need expression for \(y'(x)\) for \(2^{nd}\) I.C.
(268)#\[\begin{align} y'(x) &= 2c_1\cos(2x) - 2c_2 \sin(2x) + \frac{1}{5}e^x\\ y'(0) = \frac{4}{5} &= 2c_1 \cos(2\cdot 0) - 2c_2 \sin(2\cdot 0) + \frac{1}{5}e^0\\ \frac{4}{5} &= 2c_1 + \frac{1}{5}\\ c_1 &= \frac{3}{10} \end{align}\](269)#\[\begin{align} \therefore y(x) = \frac{3}{10} \sin(2x) + \frac{2}{5} \cos(2x) + \frac{1}{5} e^x \implies \text{particular solution to non-homogeneous linear $2^\circ$ ODE} \end{align}\]How do we determine \(y_P(x)\)?
Method of Undetermined Coefficients (sec 2.9)#
If \(r(x)\) is a function s.t. \(r'(x)\) is like \(r(x)\), e.g. \(e^{\lambda x}\), \(\sin(\omega x)\), \(\cos(\omega x)\), \(x^n\)… we can choose \(y_P(x)\) based on \(r(x)\) \
Rules (from textbook)#
Table 2.1:
If \(r(x)=\) |
Choose \(y_P(x)=\) |
---|---|
$\(ke^{rx}\)$ |
$\(ce^{rx}\)$ |
\(kx^n\) (\(n=0,1,2...\)) |
\(K_nx^n + K_{n-1}x^{n-1} + ... + K_1x + K_0\) |
\(k\cos(\omega x)\) or \(k\sin(\omega x)\) |
\(K\cos(\omega x) + M\sin(\omega x)\) |
\(ke^{\alpha x}\cos(\omega x)\) or \(ke^{\alpha x}\sin(\omega x)\) |
\(e^{\alpha x}(K\cos(\omega x) + M\sin(\omega x))\) |
Here are some additional rules; we’ll see why these are important later:
Basic Rule. If \(r(x)\) is one of the functions in the first column in Table 2.1, choose in the same line and determine its undetermined coefficients by substituting \(y_p\) and its derivatives into the differential equation.
Modification Rule. If a term in your choice for \(y_p\) happens to be a solution of the homogeneous ODE corresponding to (4), multiply this term by x (or by \(x^2\) if this solution corresponds to a double root of the characteristic equation of the homogeneous ODE).
Sum Rule. If is a sum of functions in the first column of Table 2.1, choose for the sum of the functions in the corresponding lines of the second column.
\(\underline{\text{Recap}}\):
Given \(y'' + ay' + by = r(x) \hspace{3cm} (*)\)
Solve \(y'' + ay' + by = 0\) to get \(y_H(x) = c_1y_1 + c_2y_2\)
Then choose \(y_P(x)\) based on \(r(x)\)
Plug back into \((*)\) to check:
Therefore, \(y_P'' + ay_P' + by_P = r(x)\) and \(y_P\) is a linear solution to the problem (which is why only some functions work)
Example: \(y'' + 2y' - 3y = 4e^{2x}\)#
Find \(y_H(x)\)
Choose \(y_P(x)\) based on \(r(x)\)
\(\implies\) Since \(r(x) = 4e^{2x}\), let’s pick \(y_p(x) = Ke^{2x}\), where \(K\) is the undetermined coefficient (not arbitrary)Find \(K\) from non-homogeneous ODE
Write down general solution
Still need 2 IC’s to find \(c_1\) and \(c_2\)
In-class problem#
Consider the differential equation $\(y''+y=0.001x^2\)\( The homogeneous solution is \)\(y_h=A\cos x+B\sin x\)$, as we saw in class last week. Find a particular solution to this differential equation using the MoUC rules above.
Non-homogeneous Linear \(2^\circ\) ODEs Continued#
\(\underline{\text{Caution}}\): If you choose a \(y_P(x)\) that is not linearly independent of \(y_1\) and \(y_2\), things will go wrong.
Example: \(y'' - 4y = 4e^{2x}\)#
Solve \(y'' - 4y = 0\)
Choose \(y_P(x)\) based on \(r(x)\)
Since \(r(x) = 4e^{2x}\), choose \(y_P(x) = Ke^{2x}\) as before.
SPOILER: \(Ke^{2x}\) is not linearly independent of \(y_1(x) = e^{2x}\)Find \(K\) from non-homogeneous ODE
Step back:
If \(y(p)\) isn’t linearly independent, it can’t be absorbed into \(y_H(x)\).
Solution: If \(y_P(x)\) is linearly dependent on \(y_1(x)\) or \(y_2(x)\), multiply \(y_P(x)\) by \(x\) to obtain a linearly independent new \(y_P(x)\) based on Reduction of Order.
Therefore, choose \(y_P(x) = Kxe^{2x}\). Then,
Find \(K\)
General Solution
Another place to be careful:
\(\implies\) Double roots yields a homogeneous solution
\(\implies\) Again, you must be careful to select \(y_P(x)\) s.t. it is linearly independent.
\(\implies\) if \(r(x) \propto e^{\lambda x} \) or \(xe^{\lambda x}\), then \(y_P(x) = Kx^2e^{\lambda x}\) (Obtained from a second reduction of order)
More complex example: \(y'' + 2y' -3y = -3x^2 + \sin(x)\)#
Solve the homogeneous ODE
Choose \(y_P(x)\) based on \(r(x)\)
\(\underline{\text{Rule}}\): If \(r(X)\) is a sum of wo functions, then \(y_P(x)\) should be a sum of the corresponding functions.
Find undetermined coefficients from ODE
Plugging into ODE:
Rearrange to collect ‘like’ terms
Determine the values of the coefficients on each \(f(x)\) that will solve the equation
\(-3Ax^2 = -3x^2 \implies A = 1\)
\((4A-3B)x - 0\) because \(r(x)\) has no ‘\(x\)’ term . Hence, \(4-3B = 0 \implies B = \frac{4}{3}\)
\(2A + 2B - 3C = 0 \implies 2+\frac{8}{3} - 3C = 0 \implies C=\frac{14}{9}\)
\(-K -2M -3K = 1 \implies 2M = -4K -1 \implies M = -2K -\frac{1}{2}\)
(291)#\[\begin{align} -M + 2K -3M = 0\\ 2K = 4M\\ K = 2(-2K-\frac{1}{2}) = -4K-1\\ \implies K = -\frac{1}{5}\\ \implies M = -\frac{1}{10} \end{align}\](292)#\[\begin{align} \therefore y_P(x) = -3x^2 + \frac{4}{3}x + \frac{14}{9}-\frac{1}{10}(2\sin x + \cos x) \end{align}\]
Write down the general solution