Solving differential equations
Lecture 29
Recap
$$ % Colors
% Coordinate vectors and matrices
% Common sets
% Abstract vector symbols
% Norms / absolute value
% Optional: dot product spacing (looks nicer in slides)
% Operators $$
Diagonalization
- Let \(A\) be an \(n\times n\) matrix.
- Suppose that \(\{\vec{u}_1,\dots,\vec{u}_n\}\) is an eigenbasis of \(A\) with eigenvalues \(\lambda_1,\dots,\lambda_n\).
- Let \[ P=[\vec{u}_1 \ \cdots \ \vec{u}_n], \quad D=\operatorname{diag}(\lambda_1,\dots,\lambda_n). \]
- Then \(A\) is diagonalizable and \[ A=PDP^{-1} \] is called a diagonalization of \(A\).
- Geometric intuition: in the eigenbasis, \(A\) acts simply by scaling each coordinate by \(\lambda_i\).
Applications
- Suppose \(A=PDP^{-1}\).
- Matrix powers: \[ A^k = PD^kP^{-1}, \quad D^k=\operatorname{diag}(\lambda_1^k,\dots,\lambda_n^k). \]
- Matrix exponential: \[ e^A = Pe^DP^{-1}, \quad e^D=\operatorname{diag}(e^{\lambda_1},\dots,e^{\lambda_n}). \]
- Recall: \[ e^A = I + A + \frac{A^2}{2!} + \frac{A^3}{3!} + \cdots \]
Solving linear differential equations
Quantities over time
- In many real-world models, a quantity changes over time and we want to understand its behavior.
- Let \(y:[0,\infty)\to\mathbb R\) where \(y(t)\) represents the quantity at time \(t\).
- Often we know information about derivatives rather than the function itself.
- The derivative measures instantaneous change, which is often easier to observe.
- Example: velocity is easier to measure than total distance traveled.
- By the Fundamental Theorem of Calculus: \[ y(t)=y(0)+\int_0^t y'(s)\,ds. \]
Ordinary differential equations
In many practical situations, the rate of change of a quantity depends on the current amount itself.
This leads to equations that relate a function and its derivatives.
Example (population growth):
- Suppose a bacteria population grows in a lab.
- Each bacterium reproduces independently, so the total growth rate is proportional to the current population: \[ y'(t)=\alpha y(t) \]
- Here \(\alpha\) represents the growth rate (reproductivity).
- Solution: \[ y(t)=Ce^{\alpha t} \]
- Another example (spring motion, Hooke’s law):
- By Newton’s law, \(F=ma\) and acceleration is \(y''(t)\).
- For a spring, the restoring force is proportional to displacement: \[ F=-ky(t) \]
- So: \[ m y''(t) = -k y(t) \]
- Solution: \[ y(t)=C_1\cos(\omega t)+C_2\sin(\omega t), \quad \omega=\sqrt{k/m}. \]
- These equations, involving a function and its derivatives (possibly higher order), are called ordinary differential equations (ODEs).
Linear differential equations
We now focus on an important and tractable class: linear ODEs.
Notation: \(y^{(k)}(t)\) denotes the \(k\)th derivative of \(y\) at \(t\) (e.g. \(y=y^{(0)}\), \(y'=y^{(1)}\), \(y''=y^{(2)}\)).
A linear ODE of order \(n\) has the form: \[ y^{(n)} + a_{n-1} y^{(n-1)} + \cdots + a_1 y' + a_0 y = 0, \] where \(a_0,\dots,a_{n-1}\) are constants.
Our previous examples:
- \(y'=\alpha y\) (growth/decay)
- \(my''=-ky\) (oscillation)
are both linear ODEs.
From order \(n\) to a system
- One can convert a higher-order ODE into a system of first-order equations.
- Let \[ y_0 = y,\quad y_1 = y',\quad \dots,\quad y_{n-1}=y^{(n-1)}. \]
- Then: \[ y_0' = y_1,\quad y_1' = y_2,\quad \dots \] \[ y_{n-1}' = -a_0 y_0 - a_1 y_1 - \cdots - a_{n-1} y_{n-1}. \]
- Let \(Y=\langle y_0,\dots,y_{n-1} \rangle\). Then: \[ Y' = AY \] where \[ A = \begin{bmatrix} 0 & 1 & 0 & \cdots & 0 \\ 0 & 0 & 1 & \cdots & 0 \\ \vdots & & & \ddots & \vdots \\ -a_0 & -a_1 & -a_2 & \cdots & -a_{n-1} \end{bmatrix}. \]
System of linear differential equations
- In general, consider \(n\) functions \(y_1,\dots,y_n\): \[ y_1' = a_{11}y_1 + \cdots + a_{1n}y_n \] \[ \vdots \] \[ y_n' = a_{n1}y_1 + \cdots + a_{nn}y_n. \]
- In vector form: \[ Y'(t)=AY(t), \] where \(Y(t)=\langle y_1(t),\dots,y_n(t) \rangle\) and \(A=[a_{ij}]\).
Derivative of matrix exponential
For a single equation: \[ y' = ay \quad \Rightarrow \quad y(t)=Ce^{at}. \] This suggests exponential functions naturally solve linear equations.
For systems \(Y'(t)=AY(t)\), we guess the solution involves the matrix exponential \(e^{At}\).
By definition, \[ e^{At}=I+(At)+\frac{(At)^2}{2!}+\frac{(At)^3}{3!}+\cdots \]
Differentiate term-by-term (power rule): \[ \frac{d}{dt}(At)^k = kA(At)^{k-1}. \] So, \[ \frac{d}{dt}e^{At} = A + A(At) + \frac{A(At)^2}{2!} + \cdots = A e^{At}. \]
Solving linear differential equations
Consider a linear differential equation \(Y'(t)=AY(t)\).
Let \(W(t)=e^{At}\). Then: \[ W'(t)=AW(t). \]
Try a solution of the form: \[ Y(t)=e^{At}\vec{c}. \] Then: \[ Y'(t)=Ae^{At}\vec{c} = AY(t), \] so it satisfies the differential equation.
Use the initial condition: \[ Y(0)=e^{A\cdot 0}\vec{c} = I\vec{c} = \vec{c}. \]
Final solution: \[ Y(t)=e^{At}Y(0). \]
Interpretation: \(e^{At}\) plays the same role for systems as \(e^{at}\) does for scalar equations.
General solution of linear ODEs
We have seen that the solution of \[ Y'(t)=AY(t) \] is \[ Y(t)=e^{At}Y(0). \]
If \(A\) is diagonalizable, write \[ A=PDP^{-1}, \] where the columns of \(P\) are eigenvectors \(\vec{u}_1,\dots,\vec{u}_n\), and \[ D=\operatorname{diag}(\lambda_1,\dots,\lambda_n). \]
Then \[ e^{At}=Pe^{Dt}P^{-1}, \quad e^{Dt}=\operatorname{diag}(e^{\lambda_1 t},\dots,e^{\lambda_n t}). \]
Instead of computing \(P^{-1}\) explicitly, let \[ \vec{c} = \langle c_1,\dots,c_n \rangle = P^{-1}Y(0). \]
Then the solution becomes \[ Y(t)=Pe^{Dt}\vec{c}. \]
Expanding this gives \[ Y(t)=c_1 e^{\lambda_1 t}\vec{u}_1 + \cdots + c_n e^{\lambda_n t}\vec{u}_n. \]
This expression is called the general solution:
- it describes all possible solutions in terms of constants \(c_1,\dots,c_n\).
To obtain a specific solution, use the initial condition \(Y(0)\) to determine \(\vec{c}\) (i.e., solve \(P\vec{c}=Y(0)\)).
Example
Solve the system \[ \begin{cases} y_1' = y_2, \\ y_2' = -2y_1 - 3y_2, \end{cases} \quad \text{with } y_1(0)=1,\; y_2(0)=0. \]
In vector form, let \(Y=\langle y_1,y_2 \rangle\). Then: \[ Y'(t)=AY(t), \quad A=\begin{bmatrix} 0 & 1 \\ -2 & -3 \end{bmatrix}, \quad Y(0)=\langle 1,0 \rangle. \]
Compute eigenvalues: \[ \det(A-\lambda I) =\lambda^2+3\lambda+2 =(\lambda+1)(\lambda+2), \] so \(\lambda_1=-1\), \(\lambda_2=-2\).
Find eigenvectors:
- For \(\lambda=-1\): \(\vec{u}_1=\langle 1,-1 \rangle\)
- For \(\lambda=-2\): \(\vec{u}_2=\langle 1,-2 \rangle\)
General solution: \[ Y(t)=c_1 e^{-t}\vec{u}_1 + c_2 e^{-2t}\vec{u}_2. \]
Use initial condition: \[ \langle 1,0 \rangle =c_1\langle 1,-1 \rangle+c_2\langle 1,-2 \rangle \Rightarrow c_1=2,\; c_2=-1. \]
Final solution: \[ Y(t)=2e^{-t}\langle 1,-1 \rangle-e^{-2t}\langle 1,-2 \rangle. \]
Example
Consider the second-order ODE \[ y'' + 3y' + 2y = 0. \]
Define \[ y_1 = y, \quad y_2 = y'. \]
Then \[ y_1' = y_2, \quad y_2' = -2y_1 - 3y_2. \]
In vector form: \[ Y=\langle Y_1,Y_2 \rangle=\langle y_1,y_2 \rangle, \quad Y' = AY, \quad A=\begin{bmatrix} 0 & 1 \\ -2 & -3 \end{bmatrix}. \]
This is exactly the same system as the previous example.
From the previous example, \[ Y(t)=c_1 e^{-t}\langle 1,-1 \rangle + c_2 e^{-2t}\langle 1,-2 \rangle. \]
Therefore, \[ Y_1(t)=c_1 e^{-t} + c_2 e^{-2t}, \quad Y_2(t)=-c_1 e^{-t} - 2c_2 e^{-2t}. \]
Since \(y(t)=y_1(t)=Y_1(t)\), we obtain \[ y(t)=c_1 e^{-t} + c_2 e^{-2t}. \]
Key idea: solving higher-order ODEs reduces to solving matrix systems.
Summary
Higher-order linear ODEs can be rewritten as a system of linear ODEs: \[ Y'(t)=AY(t). \]
The solution is given by \[ Y(t)=e^{At}Y(0). \]
If \(A\) is diagonalizable (\(A=PDP^{-1}\)), then \[ e^{At}=Pe^{Dt}P^{-1}, \] which makes computation much easier.
In particular, if \(\vec{u}_1,\dots,\vec{u}_n\) are eigenvectors with eigenvalues \(\lambda_1,\dots,\lambda_n\), then the general solution is \[ Y(t)=c_1 e^{\lambda_1 t}\vec{u}_1 + \cdots + c_n e^{\lambda_n t}\vec{u}_n. \]
If an initial condition \(Y(0)\) is given, the constants \(c_1,\dots,c_n\) can be determined.