Euler equation:
{xn+1=xn+hyn+1=yn+Anh
{h=stepsizeAn=f(xn,yn)
Error of solution
error = exact solution – approximate solution
Method 1: smaller step
Euler first-order: e∼c1h, proportional to step size
Method 2: find a better slop An
Heun’s method = improved Euler method = modified Euler method = RK2
{xn+1=xn+hyn+1=yn+h(An+Bn2)
in which, Bn=f(xn+1,yn+1)
Second-order method: e∼ch2
Method 3: RK4
Standard method – accurate, used in computer programs
Rung-Kutta method
An+2Bn+2Cn+Dn6
Pitfalls
#1 Find in assignments
#2 Singularity
Ex. y′=y2
Solus: y=1c−x with singularity at x=c, y(2)=∞
First-order linear ODE
a(x)y′+b(x)y=c(x)
when c(x)=0, the equation is homogeneous.
Standard linear form: the coefficient of y′ equals to 1.
y′+p(x)y=q(x)
Models: Temp-conc model (Temperature-concentration model), Decay model, Bank account, Motion
Newton cooling law: dTdt=k(Te−T)
t = time, T = temperature, k>0 is the conductivity
Diffusion model: dCdt=k(Ce−C)
C = salt concentration inside
Derivation of solution method
y′+p(x)y=q(x)
uy′+puy=qu
(uy)′=qu
u′=pu→u′u=p→lnu=p→u=e∫pdx
u(x) is defined as integration factor
Method:
- standard linear form
- calculate integration factor e∫pdx
- multiply both sides by e∫pdx
- integrate
Example 1:
(1+cosx)y′−(sinx)y=2x
- y′−sinx1+cosxy=2x1+cosx
- I.F. e∫sinx1+cosxdx=eln(1+cosx)=1+cosx
- (1+cosx)y′−(sinx)y=2x
- [(1+cosx)y]′=2x→(1+cosx)y=x2+c→y=x2+c1+cosx
Example 2: linear with constant k
Temp: dTdt+kT=kTe
- I.F. ekt
- (ektT)′=kTeekt
- ektT=∫kTe(t)ektdt+c
- T=e−kt∫kTe(t)ektdt+ce−kt
e−kt∫kTe(t)ektdt is steady state solution, and ce−kt is transient solution because k>0,t→∞,ce−kt→0.
Changing variables
scaling: x1=xa,y1=yb
Aims:
- change units
- make variables dimensionless
- reduce the number of constants, or simplify constants
Newton cooling law: dTdt=k(M4−T4)
T=internal temperature, M=constant external temperature
T1=TM→T=T1M
MdTdt=kM4(1−T41)→dTdt=kM3(1−T41)
Direct substitution and indirect substitution
Bernoulli equation: y′=p(x)y+q(x)yn(n≠0)
y′yn=p(x)1yn−1+q(x)
v=1yn−1=y1−n→v′=(1−n)y−ny′
v′1−n=p(x)v+q(x)
we can get linear equation then.
Example 1:
y′=yx+y2⇒y=2xx2+c
Homogeneous ODE
Invariant under the operation zoom:
y′=F(y/x)
Example: y′=x2yx3+y3=y/x1+(y/x)3
Example 1
The light try to track a boat on the sea and the boat travels at a angle of 45° with the light, as figured below, what is the travel path of the boat, assuming the initial point is (x,y).
y′=tan(α+45∘)=tanα+tan45∘1−tanαtan45∘
y′=y/x+11−y/x=y+xx−y
z=y/x→y′=z′x+z
z′x+z=z+11−z
xdzdx=z+11−z−z=1+z21−z
1+z21−zdz=1xdx
(11+z2−z1+z2)dz=1xdx
tan−1z−12ln(1+z2)=lnx+c
tan−1(yx)=lnx+ln√1+y2x2+c=ln√x2+y2+c
θ=lnr+c→r=c1eθ
Exponential spiral: r=ceθ
Autonomous First-order ODE
No independent variables on the right
dydt=f(y)
It is not easy to get the solution, but we can get qualitative information about the solution with direction field. For any t, f(y)= constant, which means the slopes are the same. Thus, the curves of solutions can be translated along the x-axis.
The critical point: y′=f(y0)=0 or y=y0 is a solution.
Proof: dy0dt=0=f(y0), both sides of the equation equal to zero.
Method to know the qualitative information of the solution:
- find the critical points
- graph f(y), if f(y)>0, the solution increases, or decreases
Example: y is the money in account, r is the continuous interest, w is the rate of embezzlement with certain amount.
dydt=ry−w
critical point: y−w=0→y=wr
Logistic Equation
Population behavior: y(t), k = growth rate. If k = constant, this is simple growth. If k≠constant, this is Logistic growth. Normally k declines as y increases, and we choose the simplest one k=a−by, then the population behavior is:
dydt=ay−by2
Obviously, we can get the solution of this equation by separating variables and though partial integration. Here we only look at the characteristic of the solution. The critical points can be calculated as
ay−by2=0→y=0,y=ab
The critical point y=ab is a stable critical point because the solutions goes close, the point y=0 is an unstable critical point because the solutions goes away.
What is there is only one critical point? The critical point is stable on one side and unstable on the other side, which can be called simi-stable critical point, as shown below.
Logistic Equal with Harvesting
Assuming the harvest at constant time rate is h. This model is very useful for animal or plant raising.
dydt=ay−by2−h
The maximum time rate is hm=a24b, which is the only critical point of the solution.
Complex number
i2=−1
z=a+bi,¯z=a−bi
Polar representation
a+bi=rcosθ+irsinθ=reiθ
Euler definition: eiθ=cosθ+isinθ
Exponential function:
- exponential law: eiθ1eiθ2=ei(θ1+θ2)
- initial value: ei∗0=1
- infinite series: ddteit=eit
Proof 1:
eiθ1eiθ2=(cosθ1+isinθ1)(cosθ2+isinθ2)=(cosθ1cosθ2−sinθ1sinθ2)+i(cosθ1sinθ2+cosθ2sinθ1)=cos(θ1+θ2)+isin(θ1+θ2)=ei(θ1+θ2)
Proof 2:
ei∗0=cos0+isin0=1
Proof 3:
ddteit=ddt(cost+isint)=−sint+icost=i(cost+isint)=eit
Advantage of polar representation: good for multiplication
Example:
∫e−xcosxdx=Re(∫e(−1+i)x)=12e−x(−cosx+sinx)
∫e(−1+i)x=e(−1+i)x−1+i=1−1+ie−x(cosx+isinx)=−1−i2e−x(cosx+isinx)
n√1 has n answers as complex numbers. For example, 5√1 can be expressed with a circle with radius equals to 1 and the circle is divided with five lines equally, as shown below.
ξ=ei25π→ξ5=ei25π⋅5=e2πi=1
First-order differential equation with complex numbers
y′+ky=q(t)
Solution:
y=e−kt∫q(t)ektdt+ce−kt
The first part e−kt∫q(t)ektdt is steady-state solution, also called long-term solution, the second part ce−kt is transient solution. We usually choose the simplest answer as steady-state solution, usually c=0. If k>0, the solution is steady solution, the solution goes close to the steady-state value, otherwise, the solution is transient.
y′+ky=kqe(t),qe(t)=coswt
w = angular frequency = number of complete oscillation
complexified equation:
˜y′+k˜y=keiwt
complex solution: ˜y=y1+iy2
y=realpartof˜y
(˜ye–kt)′=ke(k+wi)t→˜ye–kt=kk+iwe(k+wi)t
˜y=k(k–iw)k2+w2eiwt=11+iwkeiwt
Method 1: Go polar
Reminder: α is a complex number, then
1α⋅α=1→arg(1α)+arg(α)=arg(1)=0→arg(1α)–arg(α)
1α⋅α=1→|1α|=1|α|
Polar form:
11+i(w/k)=Ae–iϕ=1√1+(w/k)2e–iϕ
arg(1+iwk)→ϕ=tan–1(w/k)
So, the solution of the ODE , which is the real part of the complex solution, is
˜y=Aeiwt–iϕ=1√1+(w/k)2ei(wt–ϕ)→y1=1√1+(w/k)2cos(wt–ϕ)
in which, A is the amplitude and ϕ is the phase lag. If the conductivity k increases, the amplitude A also increases, which is consistent with our common sense.
Method 2: Go Cartesian
˜y=11+i(w/k)eiwt=1–i(w/k)1+(w/k)2(coswt+isinwt)
y1=11+(w/k)2(coswt+(w/k)sinwt)=11+(w/k)2√1+(w/k)2cos(wt–ϕ)=1√1+(w/k)2cos(wt–ϕ)
The following equation is used in the derivation, which is very important and we can just remember it with the triangle as figured above.
acosθ+bsinθ=ccos(θ–ϕ),c=√a2+b2,ϕ=tan–1(b/a)
Proof of this equation:
Method 1: high school method, write all from the right side and compare with the left side.
Method 2: 18.08 proof
<a,b>⋅<cosθ,sinθ>=|<a,b>|⋅1⋅cos(θ–ϕ)
Definition: →a⋅→b=n∑i=1aibi=a1b1+a2b2+⋅⋅⋅+anbn=|a||b|cosθ
Method 3: 18.03 proof
(a–bi)(cosθ+isinθ)=√a2+b2e–iϕ⋅eiθ=√a2+b2ei(θ–ϕ)
Take real parts of both sides:
acosθ+bsinθ=√a2+b2cos(θ–ϕ)
Summary: basic linear ODE
y′+ky=kqe(t),k>0
y′+ky=q(t)
y′+p(t)y=q(t)
Mixing example
x(t) = amount of salt in tank at time t, Ce = concentration of incoming salt, V is the volume of the tank, r = rate of salt inflow = rate of salt outflow. Then, the variation of salt in tank equals to the amount of salt inflow minus the amount of salt outflow expressed by equation:
dxdt=rCe–rxV
Standard form: dCdt+rVC=rVCe
How dose the tank concentration C(t) follows the inflow salt concentration ({C_e}\left( t \right)\)? If the volume of the tank V is very small, then the tank concentration C(t) is very close to Ce(t), so the the amplitude A≈1 and ϕ≈0.
For the second kind of linear ODE, if k<0, none of the terminology of transient, steady-state input response applies. However, k<0 is used in economy, biology etc. expressed in the following equation.
dydt–ay=q(t),a>0