Professional Documents
Culture Documents
Notes
Notes
Lecture materials
1.1 Ordinary differential equations
Terminology 1.1. (1) A differential equation (DE ) is an equation that contains one or
more derivatives of a differentiable function.
(2) An ordinary differential equation (ODE ) is a DE in which the differentiable function
is of one variable only.
(3) The order of a DE is the order of the equation’s highest order derivative.
(4) A DE is linear if it can be put in the form
N (y) y 0 = M (x),
1
Strategy 1.7 (solving a separable DE).
Solution. y 0 = (1 + y 2 ) ex
1
⇔ y 0 = ex
1 + y2
Z Z
1
⇔ dy = ex dx
1 + y2
⇔ tan−1 y = ex + c for some constant c
x
⇔ y = tan(e + c) for some constant c.
(3) Differentiate both sides with respect to x using the product rule to give y 0 =
v + v 0 x.
(4) Substitute v = y/x and y 0 = v + v 0 x into the DE to get v + v 0 x = g(v).
(5) Rearrange into separable form
1 1
v0 = .
g(v) − v x
2
into (∗) gives
v2 − 1
v + v0 x =
2v
1 0 1
⇔ v 2 −1
v =
2v − v
x
2v 1
⇔ − 2 v0 =
v +1 x
⇔ − ln(v 2 + 1) = ln |x| + C
⇔ v 2 + 1 = A |1/x|
y2 1
+1=A·
x2 |x|
⇔ y 2 + x2 = A |x| .
3
for some constant d. Substituting in u = x − 2y gives
x − 2y ln |4(x − 2y) + 11|
− =x+d
2 8
⇔ 4x + 8y + ln |4x − 8y + 11| = k
Equating the two, we deduce that RP y + Ry 0 = QR. Dividing both sides by R gives
y 0 + P (x) y = Q(x), as required.
Example 1.14. Find a general solution to y 0 − y = e2x .
R
−dx
Solution. Note that e = e−x+C for some constant C. Let R(x) = e−x . Then
Z Z
1 2x −x x
y = −x e · e dx = e ex dx = ex (ex + D)
e
for some constant D.
4
(2) Rearrange the DE into (1 − n) y 0 y −n + (1 − n) p(x) y 1−n = (1 − n) q(x).
(3) Substitute in the expressions of z and z 0 above to get z 0 + (1 − n) p(x) z =
(1 − n) q(x).
(4) Solve this linear first-order ODE for z using an integrating factor.
(5) Substitute z = y 1−n into the result to obtain a solution to the original DE.
−y 0 y −2 − y −1 = −x2 .
0 0 2
R in the expressions for z and z above gives z − z = −x .
Substituting
−dx −x+C −x
Note e =e where C is a constant. Let R(x) = e . Then
Z Z
1
y −1 = z = −x −x2 e−x dx = ex x2 e−x − e−x · 2x dx
e
Z
= x2 + 2ex xe−x − e−x dx = x2 + 2x − 2ex (−e−x + D) = x2 + 2x + 2 + Aex
Video materials
Example 1.17 (radioactive decay). Experiments show that a radioactive substance decom-
poses at a rate proportional to the amount present.
Let m(t) denote the mass of the radioactive substance present at time t in mg. Then
dm
= −km,
dt
where k is a positive constant. So
1 dm
· = −k
mZ dt Z
dm
⇔ = −k dt
m
⇔ ln m = −kt + C as m > 0;
−kt+C −kt
⇔ m=e = Ae ,
5
where k is a positive constant. Hence
1 dT
· = −k
TZ− 30 dt Z
dT
⇔ = −k dt
T − 30
⇔ ln(T − 30) = −kt + C as T > 30
−kt
⇔ T = Ae + 30,
where C, A are constants. Substituting this into T (0) = 100 and T (3) = 70 gives
1
Z e0.03 t
N = 0.03 t e0.03 t × 0.75 dt = e−0.03 t × 0.75 + D = 25 + Ae−0.03 t ,
e 0.03
where D, A are constants. Substituting this into N (0) = 20 gives A = 20 − 25 = −5. So
N = 25 − 5e−0.03 t .
Example 1.20 (Uranium–Thorium Dating). In Example 1.17, we saw that radioactive sub-
stances typically decay at a rate proportional to the amount present. Sometimes the product
of a radioactive decay is itself a radioactive substance which in turn decays (at a different
rate). An interesting example of this is provided by Uranium–Thorium Dating, which is
a method used by palaeontologists to determine how old certain fossils (especially ancient
corals) are. Corals filter the sea-water in which they live. Sea-water contains a tiny amount
of a certain kind of uranium-234 and the corals absorb this into their bodies. Uranium-234
decays, with a half-life of 245000 years, into thorium-230, which itself decays with a half-life
of 75000 years. Thorium-230 is not found in sea-water; so when the coral dies, it has a
certain amount of uranium-234 in it but virtually no thorium-23, because the lifetime of a
coral polyp is negligible compared with 245000 years. It is possible to measure the ratio of
the amounts of uranium-234 and thorium-230 in any given sample. From this ratio we want
to work out the age of the sample, i.e., the time when it died. This is important if we want
to know whether global warming is causing corals to die now.
6
Let U (t) be the number of atoms of uranium-234 in a particular sample of ancient coral
and let T (t) be the number of atoms of thorium-230. Since each decay of one uranium-234
atom produces one thorium-230 atom, thorium-230 atoms are being born at exactly the same
rate at which uranium-234 atoms die. So we have
dU
= −kU U , (†)
dt
dT
= kU U − kT T, (‡)
dt
where kU , kT are constants (related to the half-lives) with kU 6= kT , and U (0) = U0 , T (0) = 0.
We want to find the age of the coral given the current values of T and U .
Start with (†). As in Example 1.17,
1 dU
· = −kU
ZU dt Z
1
⇔ dU = −kU dt
U
⇔ ln(U ) = −kU t + C
⇔ U = Ae−kU t ,
where C, A are constants with A > 0. Substituting this into U (0) = U0 gives A = U0 . So
U = U0 e−kU t . (§)
kU U0 e(kT −kU )t
Z Z
1 −kU t kU U0
T = kT t e kT t
· kU U0 e dt = kT t e(kT −kU )t dt = kT t +E ,
e e e kT − kU
where E is a constant. Substituting this into T (0) = 0 gives E = −1/(kT − kU ). So
kU U0 e(kT −kU )t 1 kU U0
e−kU t − e−kT t .
T = − = (¶)
ek T t kT − kU kT − kU kT − kU
Dividing (¶) by (§) gives
T kU U0 1 kU
e−kU t − e−kT t · 1 − e(kU −kT )t .
= =
U kT − kU U0 e−kU t kT − kU
So now if we measure the ratio T /U at the present time, we can solve this for t and we have
our answer.
Summary
Strategy 1.7 (solving a separable DE). (0) Write it in separable form N (y) y 0 = M (x).
(1) Integrate both sides wrt x to give
Z Z
N (y) dy = M (x) dx + c.
7
Reduction to separable form. • y 0 = g(y/x) → let v = y/x. (Strategy 1.9)
• y 0 = f (ax + by + c), where b 6= 0 → let u = ax + by + c. (Strategy 1.11)
0
Strategy 1.13 (solving a DE of the form y + P (x) y = Q(x)).
R
P (x) dx
(1) Find the integrating factor R(x) = e .
(2) The solution is y = R1 QR dx.
R
Strategy 1.15 (solving a Bernoulli equation, i.e., a DE of the form y 0 + p(x) y = q(x) y n ,
where 0 6= n 6= 1). Let z = y 1−n .
Matlab materials
1.4 Matlab installation
The National University of Singapore has a Total Academic Headcount licence for Matlab.
Students may use it for academic, research, and learning. The license allows students to
install Matlab on personally-owned computers.
(1) If you are not using NUS network, you are required to use nVPN:
https://webvpn.nus.edu.sg/
and sign in with your NUSNET ID in the format nusstu\nusnetid and password.
If you are using NUS network, proceed directly to Step 2.
(2) Go to https://sm05.stf.nus.edu.sg/studentmatlab/ to download Matlab. You
need to sign in with your NUSNET ID in the format nusstu\nusnetid and password.
Then follow the instructions.
(3) Follow the instructions in Section 1.5 to create a MathWorks account.
(4) If you are not logged in to MathWorks yet, then do so at https://www.mathworks.
com/login. When you are logged in, click “Download”, then choose “R2020b” and
your operating system. After the download finishes, run the installer.
(a) When prompted, log in with your MathWorks Account (your NUS e-mail address).
(b) Select your licence (40707750, Student, Academic—Total Headcount).
(c) Choose installation folder.
(d) Select products to install.
(2) You will receive an e-mail from service@mathworks.com with title “Verify Email Ad-
dress”. Click the link in the e-mail to verify your account.
(3) Finish creating the profile. Then you should be able to see the following information:
Your account has been created and license 40707750 has been associated with
your account.
8
1.6 Basic Matlab operation
1.6.1 Arithmetic and standard mathematical functions
In its most elementary use, Matlab is an extremely powerful calculator. For example, type
>> (50^2 - 4*10)/3 + 61
Here the symbol ^ stands for exponentiation, i.e., the expression we were evaluating was
actually (502 − 4 × 10) ÷ 3 + 61.
There is a list of mathematical functions that are built into Matlab, for example:
abs(x) returns the absolute valuep |x| of x;
sqrt(x) returns the square root x of x;
exp(x) returns the exponential ex of x;
log(x) returns the natural logarithm ln x of x;
log10(x) returns the base-10 logarithm log10 x of x;
sin(x) returns the sine sin x of x;
asin(x) returns the inverse sine sin−1 x of x.
The following functions are also included in the list:
cos(x), tan(x), csc(x), sec(x), cot(x),
acos(x), atan(x), acsc(x), asec(x), acot(x),
sinh(x), cosh(x), tanh(x), csch(x), sech(x), coth(x),
asinh(x), acosh(x), atanh(x), acsch(x), asech(x), acoth(x).
Use the following command to see the list of elementary functions supported by Matlab:
>> help elfun
All of these functions can be combined to give complicated expressions. For example,
>> sinh(1)*exp(sqrt(2))+1
Matlab also contains the standard
√ constant π and is able to compute in complex numbers,
using i (as well as j) to denote −1. Try the following:
>> sqrt(-1)
>> sqrt(-3)
>> i^2
>> 16/(8i)
>> pi
>> exp(2*pi*i)
variable = expression
9
>> x = 1 + 10
>> x
>> x + 2
>> ans
>> y = ans + 3
• clear will clear all previously assigned variables. You can clear variables individually
by typing “clear variable”.
• Typing the statement “help topic” will give information and usage about the specified
topic. Try typing “help clc” or “help i”.
1.6.4 Precision
All numeric computations in Matlab are performed with about 16 decimal digits of precision.
The format of the displayed output can be controlled by the following commands:
format short fixed point, 4 decimal places, default setting
format long fixed point, 15 decimal places (for double values)
format shortE scientific notation, 4 decimal places
format longE scientific notation, 15 decimal places (for double values)
format rat approximate fractions
Type the following:
>> format shortE
>> 235.556
>> format long
>> pi
>> format short
>> pi
It is clear that this method will only work well when we choose a large number of points
which are close together. Matlab allows us to very efficiently replicate this process. Type
the following:
>> x = 0 : 0.2 : 1;
>> y = sin(x).*sin(x);
>> plot(x,y)
We get
10
0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0
0 0.2 0.4 0.6 0.8 1
This does not look like the graph that we want because we used a bad choice of points. Type
the following:
>> x = 0 : 0.01 : 6.28;
>> y = sin(x).*sin(x);
>> plot(x,y)
We get
1
0.8
0.6
0.4
0.2
0
0 1 2 3 4 5 6
This graph looks much better because we used 629 points to plot our graph. Let us dissect
these commands line by line.
(1) The first line was
Here we are declaring x as an array (or a row vector) containing the numbers from 0
to 6.28, in increments of 0.01. So x contains 629 values. Notice that the size of x in the
Workspace window now says 1 × 629. Double-click on x to see all the individual values.
The semicolon “;” asks Matlab to execute the command but suppresses the output.
Type the same line again, this time without the semicolon and see what happens.
You can also work with individual elements in your array. For example,
11
>> x(10) * 2
will get the value of the 10th element of your array x and multiply it by 2.
(2) The second line was
>> y = sin(x).*sin(x);
This command computes sin(x) × sin(x) and saves the answer into an array y. Notice
that we used .* instead of the usual * to denote array multiplication, i.e., multiplying
629 values to 629 values. The “.” reminds Matlab to do the right thing and operate
element by element in order. Other examples are:
>> z = 2 + x.*exp(-x.^2);
Pay attention to where we need to add the “.” and note that mathematical functions
like sin(x) are smart enough to compute element by element.
>> plot(x,y)
Matlab can also plot graphs via the fplot command using ‘anonymous function handles’
as in
>> f = @(x) sin(x).*sin(x);
>> fplot(f,[0,2*pi])
12
MA1512 Week 2
Lecture materials
2.1 Linear second-order ODEs
Definition 2.1. A linear second-order ODE
y 00 + ay 0 + by = r(x)
is λ2 + aλ + b = 0.
13
constants. (Note that −a/2 is the (double) root of the characteristic equation
of the DE.)
2
Case 3: ap − 4b < 0. A general solution is y = e−ax/2 (c1 cos(wx)+c2 sin(wx)), where
w = b − a2 /4 and c1 , c2 are constants. (Note that the solutions to the char-
acteristic equation of the DE are (−a/2) ± iw.)
Solution. We are in Case 2 because 82 −4×16 = 0. So a general solution is y = (c1 +c2 x)e−4x ,
where c1 , c2 are constants.
Example 2.11. Solve y 00 + 2y 0 + 5y = 0.
p
Solution. We are in Case 3 because 22 − 4 × 5 = −16 < 0. Now w = 5 − 22 /4 = 2. So a
general solution is y = e−x (c1 cos(2x) + c2 sin(2x)), where c1 , c2 are constants.
is y = c1 y1 + c2 y2 + yp , where
• c1 , c2 are arbitrary constants;
• y1 , y2 are linearly independent solutions to the homogeneous DE
y 00 + p(x) y 0 + q(x) y = 0
Remark 2.13. In view of Fact 2.5, another way to write the general solution to (∗)
given by Fact 2.12 is
y = yh + yp ,
where yh is a general solution to the homogeneous DE corresponding to (∗).
14
Theorem 2.14 (Superposition Principle). Let c1 , c2 be constants and y1 , y2 be particular
solutions to the DEs
y 00 + p(x) y 0 + q(x) y = r1 (x) and y 00 + p(x) y 0 + q(x) y = r2 (x)
respectively. Then y = c1 y1 + c2 y2 is a particular solution to the DE
y 00 + p(x) y 0 + q(x) y = c1 r1 (x) + c2 r2 (x).
Proof (non-examinable). If y = c1 y1 + c2 y2 , then
y 00 + p(x) y 0 + q(x) y
= (c1 y1 + c2 y2 )00 + p(x) (c1 y1 + c2 y2 )0 + q(x) (c1 y1 + c2 y2 )
= c1 (y100 + p(x) y10 + q(x) y1 ) + c2 (y200 + p(x) y20 + q(x) y2 ) by the linearity of differentiation;
= c1 r1 (x) + c2 r2 (x) by the choice of y1 , y2 .
Strategy 2.15 (Method of Undetermined Coefficients, polynomial case). Given the DE
y 00 + ay 0 + by = p(x),
where p(x) is a polynomial of degree n and a, b are constants, try
u(x),
if 0 is not a root of the characteristic equation of the DE;
y = x u(x), if 0 is a simple root of the characteristic equation of the DE;
2
x u(x), if 0 is a double root of the characteristic equation of the DE,
where u(x) is a polynomial of degree n with undetermined coefficients.
Example 2.16. Find a particular solution to y 00 − 4y 0 + y = x2 + x + 2.
Solution. Note that 0 is not a root of the characteristic equation λ2 − 4λ + 1 = 0. So try
y = Ax2 + Bx + C. Then y 0 = 2Ax + B and y 00 = 2A. Substituting into the DE gives
2A − 4(2Ax + B) + (Ax2 + Bx + C) = x2 + x + 2.
Equating coefficients gives A = 1 and −8A + B = 1 and 2A − 4B + C = 2. Solving this
system of equations gives A = 1 and B = 9 and C = 36. Substituting these back into
y = Ax2 + Bx + C gives the particular solution y = x2 + 9x + 36 to the DE.
Strategy 2.17 (Method of Undetermined Coefficients, exponential case). Given the DE
y 00 + ay 0 + by = p(x) ekx ,
where p(x) is a polynomial of degree n and a, b, k are constants, try
kx
u(x) e ,
if k is not a root of the characteristic equation of the DE;
kx
y = x u(x) e , if k is a simple root of the characteristic equation of the DE;
2
x u(x) ekx , if k is a double root of the characteristic equation of the DE,
where u(x) is a polynomial of degree n with undetermined coefficients.
Example 2.18. Find a particular solution to y 00 − 4y 0 + 4y = 20x3 e2x .
Solution. Note that 2 is a double root of the characteristic equation λ2 − 4λ + 4 = 0. So try
y = x2 ue2x , where u = Ax3 + Bx2 + Cx + D. Then
y 0 = (x2 u)0 e2x + 2(x2 u)e2x and y 00 = (x2 u)00 e2x + 4(x2 u)0 e2x + 4(x2 u)e2x .
Substituting into the DE gives (x2 u)00 e2x = 20x3 e2x . Note
(x2 u)00 = (Ax5 + Bx4 + Cx3 + Dx2 )00 = (5Ax4 + 4Bx3 + 3Cx2 + 2Dx)0
= 20Ax3 + 12Bx2 + 6Cx + 2D.
Equating coefficients gives A = 1 and B = C = D = 0. So a particular solution to the DE is
y = x2 x3 e2x = x5 e2x .
15
Strategy 2.19 (Method of Undetermined Coefficients, special exponential case). Given the
DE
y 00 + ay 0 + by = cxn ekx ,
where n is a non-negative integer and a, b, c, k are constants with c 6= 0 6= k, if k is a double
root of the characteristic equation of the DE, then try
y = Axn+2 ekx ,
Fact 2.20 (Euler’s formula). ex+iy = ex (cos y + i sin y) for all real numbers x, y.
z 00 + az 0 + bz = p(x) e(`+im)x ;
Solution. Consider the complex DE z 00 + 4z = 16xei2x . Note that 2i is a (simple) root of the
characteristic equation λ2 + 4 = 0. So try z = xuei2x , where u = Ax + B. Then
Substituting into the complex DE gives (xu)00 ei2x + 4i(xu)0 ei2x = 16xei2x . Since xu =
Ax2 + Bx, we have
(xu)0 = 2Ax + B and (xu)00 = 2A.
Equating coefficients gives 8iA = 16 and 2A + 4iB = 0. So A = −2i and B = 1. Hence
z 00 + az 0 + bz = p(x) e(`+im)x ;
Strategy 2.24 (Method of Undetermined Coefficients, all cases). Let p(x) be a poly-
16
nomial of degree n. Consider the DE
p(x)
(polynomial case)
p(x) ekx
(exponential case)
y 00 + ay 0 + by = `x
p(x) e cos(mx) (cosine case)
p(x) e`x sin(mx) (sine case)
Video materials
y 00 + p(x) y 0 + q(x) y = 0;
17
where C, D are constants. Choosing C = D = 0 gives the particular solution
y = uy1 + vy2 = sin(x) − ln |sec(x) + tan(x)| (cos x) + (− cos x)(sin x)
= − cos(x) ln |sec(x) + tan(x)| .
Example 2.29 (energy conservation). Consider the DE mẍ = −kx, where m, k are con-
stants. By Observation 2.27, the DE can be rewritten as
d ẋ2
k
= − x.
dx 2 m
ẋ2
Z
k
= −
x dx
2 m
k x2
=− · +E
m 2
1 1
⇔ mẋ2 + kx2 = E,
2 2
where E is a constant.
Summary
Strategy 2.8 (solving a DE of the form y 00 + ay 0 + by = 0, where a, b are constants).
Case 1: a2 − 4b > 0. A general solution is y = c1 eλ1 x + c2 eλ2 x , where λ1 , λ2 are the roots
of the characteristic equation of the DE, and c1 , c2 are constants.
Case 2: a2 − 4b = 0. A general solution is y = (c1 + c2 x)e−ax/2 , where c1 , c2 are constants.
(Note that −a/2 is the (double) root of the characteristic equation of the DE.)
Case p3: a2 − 4b < 0. A general solution is y = e−ax/2 (c1 cos(wx) + c2 sin(wx)), where w =
b − a2 /4 and c1 , c2 are constants. (Note that the solutions to the characteristic
equation of the DE are (−a/2) ± iw.)
Fact 2.12 (formulated informally). A general solution to the nonhomogeneous linear
second-order ODE
y 00 + p(x) y 0 + q(x) y = r(x).
is
y = (general solution to y 00 + p(x) y 0 + q(x) y = 0) + (any particular solution).
18
Strategy 2.24 (Method of Undetermined Coefficients). Let p(x) be a polynomial of
degree n. Consider the DE
p(x) (polynomial case)
p(x) ekx
(exponential case)
y 00 + ay 0 + by = `x
p(x) e cos(mx) (cosine case)
`x
p(x) e sin(mx) (sine case)
y 00 + p(x) y 0 + q(x) y = 0;
Strategy 2.28 (solving a DE of the form ẍ = f (x) for ẋ > 0 via energy conservation).
d ẋ2 d ẋ2
(1) Substitute ẍ = into the DE to get = f (x).
dx 2 dx 2
(2) Integrate both sides with respect to x to get ẋ2 /2 = F (x) + D, where F (x) is an
antiderivative of f (x) with respect to x, and D is a constant.
(3) Proceed to solve for x if needed.
Matlab materials
Suppose we want to plot several graphs on the same diagram, we can use the command
hold on to superimpose any new graphs on the current one. The command hold off turns
off this feature, i.e., any new plot will overwrite the current graph.
Several other commands are available for enhancing your plots. For example, you can use
the following commands to label the x- and the y-axis and to title your graph.
19
>> xlabel(’t’)
>> ylabel(’y’)
>> title(’Graph of y = t^2’)
You can also use the command
>> axis([xmin xmax ymin ymax])
to set the maximum and minimum values of your x- and your y-axis. Lastly, use
>> plot(x,y,’b’)
to plot in blue. In place of “b”, use “g” for green, “r” for red, “y” for yellow, and “k” for
black. For black-and-white plots, we can use
>> plot(x,y,’-’); plot(x,y,’-.’); plot(x,y,’--’)
for solid lines, dash-dotted lines and dashed lines respectively. More options can be found
with help plot.
Example 2.30. A forced (undamped) harmonic oscillator has a beat if the natural frequency
is close to the forcing frequency. An example of such a solution is
t 23t
x(t) = 2 sin sin .
2 2
We can graph this solution as follows:
>> t = linspace(0,4*pi,1000);
>> x = 2*sin(t/2).*sin(23*t/2);
>> plot(t,x)
>> xlabel(’t’)
>> ylabel(’x(t)’)
>> title(’Beats’)
>> axis([0 4*pi -2 2])
>> hold on
>> y = 2*sin(t/2);
>> plot(t,y,’r--’)
>> hold off
Here the linspace command produces 1000 equally spaced points between 0 and 4π.
Beats
2
1.5
0.5
x(t)
-0.5
-1
-1.5
-2
0 2 4 6 8 10 12
t
20
MA1512 Week 3
Lecture materials
3.1 Oscillation
Convention 3.1. Unless otherwise stated, all inputs to trigonometric functions are in radi-
ans.
Notation 3.2. Dots above a function denote derivatives with respect to time, e.g.,
dx d2 x
ẋ = , ẍ = , ....
dt dt2
Terminology 3.3. (1) Let x = A cos(γt) + B sin(γt) + C, where A, B, C, γ are constants.
Then the angular frequency of x is γ.
(2) Let x = A cos(γt) or x = A sin(γt), where A, γ are constants and A > 0. Then the
amplitude of x is A.
Fact 3.4. Let x = A cos(γt) + B sin(γt) + C, where A, B, C, γ are constants. Then the period
of x, i.e., the smallest T > 0 such that x(t + T ) = x(t) for all t, is 2π/γ.
Newton’s Second Law. Let F~ be the net force applied to a body, m be the mass of the
body, and ~a be the body’s acceleration. Then
F~ = m~a.
spring motor
−kx F0 cos(αt)
α>0
mass
m
spring constant k > 0
x
natural position
Situation 3.5. Consider the situation depicted in Figure 3.1. By Newton’s Second Law,
21
√
A= C 2 + D2 D
δ
C
3.1.1 When F0 = 0
The corresponding homogeneous DE is
mẍ + kx = 0
k
⇔ ẍ + ω 2 x = ẍ + x = 0,
m
p
where ω = k/m. Note x1 = cos(ωt) and x2 = sin(ωt) are linearly independent solutions to
the homogeneous DE. So, by Fact 2.5, a general solution to the homogeneous DE is
p C D
x = C cos(ωt) + D sin(ωt) = C 2 + D2 cos(ωt) √ + sin(ωt) √
C 2 + D2 C 2 + D2
= A cos(ωt) cos(δ) + sin(ωt) sin(δ) = A cos(ωt − δ),
where C, D, A, δ are constants satisfying A > 0 and the relationship depicted in Figure 3.2.
F0 /m F0 /m
• So z = ω 2 −α2 eiαt = ω 2 −α2 (cos(αt) + i sin(αt)) by Euler’s Formula.
A particular solution to the original DE is
F0 /m
x = Re(z) = cos(αt)
ω 2 − α2
A general solution to the original DE is
F0 /m
x = A cos(ωt − δ) + 2 cos(αt),
| {z } ω − α2
| {z }
general solution
particular
to the corresponding
solution
homogeneous equation
22
3.1.3 When F0 6= 0 and α = ω
F0
Consider the complex DE mz̈ + kz = F0 eiαt , or equivalently, the DE z̈ + ω 2 z = m eiαt .
• iα = iω is a (simple) root of the characteristic equation λ2 + ω 2 = 0.
• Try z = Dteiαt . Then ż = iαDteiαt + Deiαt and z̈ = −α2 Dteiαt + 2iαDeiαt .
• Substituting these into the complex DE gives
F0 iαt
(−α2 Dteiαt + 2iαDeiαt ) + ω 2 · Dteiαt = e
m
F0 /m F0 /m
⇔ D= =− i.
2iα 2α
• So z = − F02α
/m
iteiαt = − F02α
/m
it(cos(αt) + i sin(αt)) by Euler’s Formula.
A particular solution to the original DE is
F0 /m F0 /m
x = Re(z) = t sin(αt) = t sin(ωt).
2α 2ω
A general solution to the original DE is
F0 /m
x = A cos(ωt − δ) + t sin(ωt),
| {z } | 2ω {z }
general solution
particular
to the corresponding
solution
homogeneous equation
Definition 3.6. This situation in which the external frequency α is equal to the
natural frequency ω of the system is called resonance.
3.2 Population
3.2.1 The Malthus model
Let N (t) denote the size of the population at time t, and N̂ = N (0).
Definition 3.7. The per capita birth rate is the number of individuals born per unit of time,
divided by the number of individuals. The per capita death rate is the number of individuals
died per unit of time, divided by the number of individuals.
Model 3.8 (Malthus). Denote by B and D the per capita birth rate and the per
capita death rate respectively. Then B, D are positive constants and
dN
= (B − D)N.
dt
23
N B>D
B=D
N̂
t B<D
N̂ > N∞
N∞ N̂ = N∞
N̂ < N∞
where A, C are constants with A > 0. Substituting in N (0) = N̂ reveals that N̂ = N (0) =
Ae(B−D)·0 = A. So
N (t) = N̂ e(B−D)t .
Note 3.10. In the Logistic Model above, the B is the per capita birth rate, and the sN is
the per capita death rate.
Terminology 3.11. The N∞ , which is defined to be B/s above, is called the carrying
capacity.
Definition 3.12. An equilibrium solution to a DE is a solution of the form N (t) ≡ c, where
c is a constant.
24
Terminology 3.13. An equilibrium solution N (t) ≡ c to a DE is stable if N (t) stays close
to c whenever N (t) is a solution to the same DE such that N (0) is sufficiently close to c. An
equilibrium solution is unstable if it is not stable.
Remark 3.14. Note N → N∞ as t → ∞ whenever N̂ > 0. So N ≡ 0 is an unstable
equilibrium, while N ≡ N∞ is a stable equilibrium.
Working. Suppose N̂ > 0. Rearranging the DE gives the Bernoulli form Ṅ + (−B)N =
(−s)N 2 or equivalently,
N −2 Ṅ − BN −1 = −s.
Let z = N 1−2 = N −1 . Then ż = −N −2 Ṅ . Substituting these in gives
ż + Bz = s.
R
B dt
Note e = eBt+C , where C is a constant. Use the integrating factor eBt to get
Z Bt
1 1 1 e s
= z = Bt Bt
se dt = Bt s + C0 = + C0 e−Bt ,
N e e B B
where C0 is a constant. Substituting this into the initial condition N (0) = N̂ gives
1 s
+ C0 e−B·0
=
N̂ B
1 s
∴ C0 = − .
N̂ B
Therefore, as N∞ = B/s,
1 N∞
N= s 1 s
= N∞
.
e−Bt
B + N̂
− B 1+ N̂
− 1 e−Bt
dN
= (B − sN )N − E,
dt
where B, s, E are positive constants.
Note 3.16. In the Logistic Model with Harvesting above, the B is the per capita birth rate,
the sN is the per capita death rate, and the E is the harvest rate.
Behaviour of solutions. Let F (N ) = (B − sN )N − E = −sN 2 + BN − E. Consider B 2 −
4(−s)(−E) = B 2 − 4sE.
Case 1: B 2 − 4sE < 0. This means E > B 2 /4s.
• dN
dt = F (N ) < 0 for all N because the coefficient of N 2 in F (N ) is negative.
• So there is no equilibrium solution.
• N decreases until it reaches 0, no matter what N̂ is.
Case 2: B 2 − 4sE > 0. This means E < B 2 /4s.
25
dN dN dN
F (N ) = dt F (N ) = dt F (N ) = dt
N N
0 0 β
N
0 β1 β2
• β is an unstable equilibrium.
Video materials
Taylor’s Theorem (informal version). If f (x) is a differentiable function and a is a constant,
then for all x near a,
f (x) ≈ f (a) + f 0 (a)(x − a).
Example 3.17 (pendulum). Consider the situation depicted in Figure 3.6. Applying New-
ton’s Second Law in the tangential direction, we get
d2
−mg sin θ = m (Lθ)
dt2
d2 θ
⇔ −g sin θ = L 2
dt
= Lθ̈,
26
θ
mg sin θ
mg mg cos θ
θ
p
where ω = g/L. As in Section 3.1.1, the solution is
θ = A cos(ωt − δ),
Summary
• Simple harmonic motions are modelled by DE’s of the form ẍ + ω 2 x = 0, where ω is
the natural frequency of the oscillator. A general solution is x = A cos(ωt − δ).
• Forced oscillations are modelled by DE’s of the form ẍ + ω 2 x = F (t), where F (t)
represents the external force.
• In a forced oscillation, resonance occurs when the frequency of the external force,
represented by F (t) above, is equal to the natural frequency ω of the oscillator.
Let N (t) denote the size of the population at time t, and N̂ = N (0). Then
dN
= (B − D)N − E,
dt
where B is the per capita birth rate, D is the per capita death rate, and E is the harvest
rate.
27
The Logistic Model with Harvesting (Model 3.15): D = sN where B, s, E are con-
stants.
• If E > B 2 /4s, then N decreases until it reaches 0.
• If E < B 2 /4s, then
– if 0 < N̂ < β1 , then N decreases until it reaches 0;
– if N̂ > β1 , then N → β2 as t → ∞,
where β1 , β2 are roots of (B − sN )N − E = 0 with β1 < β2 .
Matlab materials
We shall learn how to approximate solutions using Matlab’s numerical solver called ode45:
ode45(f ,[a,b],x0 )
solves the initial value problem (IVP)
dx
= f (t, x), a 6 x 6 b, x(a) = x0 .
dt
Note that the initial condition should always be supplied because we are approximating a
unique particular solution and not the whole family of solutions.
Let us start with the following simple IVP:
dx t
= , 0 6 t 6 2, x(0) = 1.
dt x
>> f = @(t,x) t/x;
>> ode45(f, [0 2], 1)
• The first line creates a function f (t, x) with two input arguments t, x. Unlike previously
where we had to input specific values into an array, this syntax allows us to define a
function. Note that there is no need to use “./” for dividing in inline functions.
• The second command plots an approximate solution to f on the interval [0, 2] with the
last argument specifying the initial value, i.e., the value of x at the left end-point of
the interval.
2.4
2.2
1.8
1.6
1.4
1.2
1
0 0.5 1 1.5 2
In the graph, the circles indicate points at which ode45 computed the approximate solution
and the centers of these circles are connected by line segments. √
Since the DE involved is separable, we can solve the IVP to get x(t) = t2 + 1. In order
to compare the two graphs, we get the numerical values from ode45 by specifying, continuing
from the above,
28
>> [t, xa] = ode45(f, [0 2], 1);
>> X = sqrt(t.^2+1);
>> plot(t, xa, ’b’)
>> hold on
>> plot(t, X, ’r--’)
>> hold off
The array t stores the values where approximations were computed with the corresponding
approximated values stored in xa.
2.4
2.2
1.8
1.6
1.4
1.2
1
0 0.5 1 1.5 2
Note that you actually cannot see any difference graphically. To see how good the approx-
imations are, we use the following commands (again continuing from the above) and note
how many decimal places the two sets of values agree to.
>> format long
>> [X, xa]
ans =
1.000000000000000 1.000000000000000
1.001249219725039 1.001249322543948
1.004987562112089 1.004987583459220
1.011187420807834 1.011187326457656
1.019803902718557 1.019803900300028
1.030776406404415 1.030776612066473
1.044030650891055 1.044030686115661
1.059481005020855 1.059480836490066
1.077032961426901 1.077032958001759
1.096585609973066 1.096585753293474
1.118033988749895 1.118034010569499
1.141271221051333 1.141271106376989
1.166190378969060 1.166190374350517
1.192686044187656 1.192686089325686
1.220655561573370 1.220655563240067
1.250000000000000 1.249999957951388
1.280624847486570 1.280624841656901
1.312440474840669 1.312440463130154
1.345362404707371 1.345362394665262
29
1.379311422413372 1.379311419833795
1.414213562373095 1.414213555992425
1.450000000000000 1.449999970112113
1.486606874731851 1.486606861428621
1.523975065412817 1.523975075188232
1.562049935181331 1.562049928842014
1.600781059358212 1.600781029466687
1.640121946685672 1.640121934170242
1.680029761641144 1.680029771788671
1.720465053408525 1.720465047403860
1.761391495380854 1.761391470858097
1.802775637731995 1.802775627123471
1.844586674569672 1.844586681704933
1.886796226411321 1.886796220832688
1.929378138157474 1.929378119272440
1.972308292331602 1.972308283568230
2.015564437074637 2.015564441077208
2.059126028197400 2.059126023043852
2.102974084481309 2.102974070103894
2.147091055358389 2.147091048072739
2.191460700081113 2.191460701682836
2.236067977499790 2.236067972737249
We remark that ode45 is one of several numerical solvers available and is sufficient for
our purposes. More advanced users can try to study the difference between ode45 and ode23
or ode113 etc.
30
MA1512 Week 4
Lecture materials
4.1 Laplace transform
Definition 4.1. Let f be a function defined for all t > 0. The Laplace transform of f ,
denoted L(f ), is the function F (s) defined by
Z ∞
F (s) = e−st f (t) dt,
0
R∞ Rb
where 0 e−st f (t) dt ..= limb→∞ 0 e−st f (t) dt and we treat s as a constant when we evaluate
the integral. If F (s) = L(f ), then we call f (t) the inverse Laplace transform of F (s), and
write L−1 (F ) = f (t).
Convention 4.2. Original functions are denoted by lowercase letters with variable t, and
their Laplace transforms by the same letters in uppercase with variable s.
Fact 4.3. The inverse Laplace transform of a function, if it exists, is unique up to a “zero-
length set”.
Example 4.4. (The intermediate calculations are not examinable.) Let a be a constant and
f (t) = eat . Then
Z ∞ Z b
at −st at
F (s) = L(f ) = L(e ) = e e dt = lim e(a−s)t dt
0 b→∞ 0
(a−s)t b (a−s)b
e(a−s)·0
e e
lim = lim − = ∞, if s < a;
b→∞ a − s 0 b→∞ a − s a−s
(a−s)t b (a−s)b
e(a−s)·0
= e e −1 1
lim = lim − = = , if s > a;
b→∞ a − s 0 b→∞ a − s a−s a−s s−a
Z b
b
lim
dt = lim t 0 = lim (b − 0) = lim b = ∞, if s = a.
b→∞ 0 b→∞ b→∞ b→∞
Hence
1
F (s) = for s > a.
s−a
Example 4.5. (The intermediate calculations are not examinable.) Let n be a fixed non-
31
negative integer. Then
Z ∞
−1 ∞ n de−st
Z
L(tn ) = e−st tn dt = t · dt
0 s 0 dt
Z ∞ n
−1 n −st ∞ −st dt
= t e 0
− e · dt integrating by parts;
s 0 dt
Z ∞
as tn e−st → 0 as t → ∞,
−1
= (0 − 0) − n e−st tn−1 dt
s 0 and tn = 0 when t = 0;
n n n−1 n n−1 1
= L(tn−1 ) = · L(tn−2 ) = · · · = · · · · · · L(t0 )
s s s s s s
n! 1 n! 1
= n · = n+1 as L(e0·t ) = by Example 4.4
s s s s−0
for s > 0. Hence
n!
L(tn ) = for s > 0.
sn+1
Proposition 4.6 (linearity of the Laplace transform). Let f, g be functions defined for all
t > 0, and a, b be constants. Then
Proof (non-examinable). This follows from the linearity of integrals and limits.
Proposition 4.7 (linearity of the inverse Laplace transform). Let f, g be functions defined
for all t > 0, and a, b be constants. If F (s) = L(f ) and G(s) = L(g), then
Proof (non-examinable).
Example 4.8. (The intermediate calculations are not examinable.) Let a, b be complex
constants. Let w be a real constant. On the one hand, Euler’s formula implies
1 1 s + iw s w
L(eiwt ) = = · = 2 2
+i 2 .
s − iw s − iw s + iw s +w s + w2
Equating the real and the imaginary parts gives, for all s > 0,
s w
L(cos(wt)) = and L(sin(wt)) = .
s2 + w2 s2 + w2
2s + 5 s 5 3
Example 4.9. L−1 = L−1 2 · 2 + ·
s2 + 9 s + 32 3 s2 + 32
s 5 −1 3
= 2 L−1 + L
s2 + 32 3 s2 + 32
5
= 2 cos(3t) + sin(3t).
3
32
fh (t)
δ(t)
1
h
t t
0
0 h
u(t) u(t − a)
1 1
t t
0 0 a
Fact 4.11 (non-examinable). Let g(t) be a function and a be a non-negative constant. Then
Z ∞ Z ∞ Z a+h
1
g(t) δ(t − a) dt = g(t) · lim fh (t − a) dt = lim g(t) · dt
0 0 h→0 h→0 a h
Z a+h Z a+h
1
= lim g(t) dt = g(a) as g(t) dt ≈ g(a) · h when h is small.
h→0 h a a
Example 4.12. L(δ(t − a)) = e−as for all a > 0. In particular, we have L(δ(t)) = 1.
R∞
Proof (non-examinable). L(δ(t − a)) = 0
e−st δ(t − a) dt = e−sa .
4.2 Shifts
Example 4.14. Let a, b be constants such that a < b, and g(t) be a function.
33
(
0, t < a;
(1) u(t − a) =
1, t > a.
0,
if t < a;
(2) u(t − a) − u(t − b) = 1, if a < t < b;
0, if t > b.
0, if t < a;
(3) g(t) u(t − a) − u(t − b) = g(t), if a < t < b;
0, if t > b.
Proposition 4.15 (t-shifting). Let f (t) be a function. Then for all a > 0,
Proof (non-examinable).
Z ∞ Z ∞
e−st · f (t − a) u(t − a) dt = e−st f (t − a) dt
L f (t − a) u(t − a) =
0 a
Z ∞
= e−s(τ +a) f (τ ) dτ = e−as L(f ) = e−as F (s).
0
e−as
Example 4.16. t-shifting implies L(u(t − a)) = e−as L(1) = for all a > 0.
s
L(t2 u(t − 1)) = L ((t − 1) + 1)2 u(t − 1)
Example 4.17.
= L (t − 1)2 + 2(t − 1) + 1) u(t − 1)
Proof (non-examinable).
Z ∞ Z ∞
L(ect f (t)) = e−st · ect f (t) dt = e−(s−c)t f (t) dt = F (s − c).
0 0
34
4.3 Derivatives
Theorem 4.20. Let a be a constant and f (t) be a continuous function such that
L(f ) exists at all s > a and f 0 (t) is piecewise continuous on [0, ∞). Then
Proof for the case when f 0 (t) is continuous at all t > 0 (non-examinable). For all s > a,
Z ∞ Z ∞
0 −st 0
−st ∞ de−st
L(f ) = e f (t) dt = e f (t) 0 − f (t) dt
0 dt
Z ∞ 0
= lim e−sb f (b) − e−s·0 f (0) − f (t) · e−st · (−s) dt
b→∞ 0
Z ∞
= 0 − f (0) + s e−st f (t) dt = s L(f ) − f (0)
0
as L(f ) exists at s.
Corollary 4.21. Let n be a positive integer and f (t) be a function such that
f (t), f 0 (t), . . . , f (n−1) (t) are continuous and their Laplace transforms exist at all s > a.
Suppose further that f (n) (t) is piecewise continuous on [0, ∞). Then
L(f (n) ) = sn L(f ) − sn−1 f (0) − sn−2 f 0 (0) − · · · − s1 f (n−2) (0) − f (n−1) (0).
Strategy 4.22 (solving initial value problems using the Laplace transform). Consider
the initial value problem
(
y 00 + ay 0 + by = r(t)
y(0) = k0 , y 0 (0) = k1
where a, b, k0 , k1 are constants and r(t) is a function with Laplace transform R(s).
(1) Take the Laplace transform on both sides of the DE to get, via linearity,
s2 L(y) − s y(0) − y 0 (0) + a s L(y) − y(0) + b L(y) = L(r).
(4) Reduce the expression above to a sum of terms whose inverse Laplace transforms
can be found. The sum of the inverse Laplace transforms is the solution y(t) to
the initial value problem.
35
Example 4.23. Solve y 00 + 2y 0 + 5y = 0, y(0) = 2, y 0 (0) = −4.
Solution. Taking the Laplace transform on both sides of the DE gives, via linearity,
Video materials
Example 4.24. Let w be a constant. Find L(t sin wt).
Solution. Let f (t) = t sin wt. Then
Theorem 4.25. Let a be a constant and f (t) be a function that is piecewise con-
tinuous on [0, ∞) and whose Laplace transform exists at all s > a. Then, for all
s > max{0, a}, Z t
L(f )
L f (τ ) dτ = .
0 s
Rt
Proof (non-examinable). Let g(t) = 0 f (τ ) dτ . Then g(0) = 0 and g 0 (t) = f (t) by the
Fundamental Theorem of Calculus. The latter implies g is continuous and L(g) exists at all
s > a. In view of Theorem 4.20, for all s > a,
36
On the other hand,
Z t t !
1 1 − cos(wτ ) (− cos(wt)) − (−1)
L sin(wτ ) dτ = L =L .
w 0 w w 0 w2
1−cos(wt) 1
So L w2 = s(s2 +w2 ) .
Example 4.27 (parameter reconstruction). We have a spring with a mass attached which
is initially at rest at the equilibrium position. Then by Newton’s Second Law, the displace-
ment x of the mass satisfies
M ẍ = −kx − bẋ
where M is the mass, k is the spring constant, and b is the frictional coefficient. We poke it
with a unit impulse at time t = 1; in other words, the applied force is δ(t − 1). We observe
that the displacement of the mass is
Summary
See Table 4.1 for some Laplace transforms we established.
Strategy 4.22 (solving initial value problems using the Laplace transform). Con-
sider the initial value problem
(
y 00 + ay 0 + by = r(t)
y(0) = k0 , y 0 (0) = k1
where a, b, k0 , k1 are constants and r(t) is a function with Laplace transform R(s).
(1) Take the Laplace transform on both sides of the DE to get, via linearity,
37
g(t) G(s) = L(g) hypothesis
1
eat for s > a
s−a
1
1 for s > 0
s
n!
tn for s > 0 n>0
sn+1
s
cos(wt) for s > 0
s2 + w2
w
sin(wt) for s > 0
s2 + w2
δ(t − a) e−as a>0
δ(t) 1
ect f (t) F (s − c) for s > a + c F (s) = L(f ) and it is defined for all s > a
n!
ect tn for s > c n>0
(s − c)n+1
s−c
ect cos(wt) for s > c
(s − c)2 + w2
w
ect sin(wt) for s > c
(s − c)2 + w2
f (t) is continuous and
f 0 (t) s L(f ) − f (0)
f 0 (t) is piecewise continuous on [0, ∞)
f (t), f 0 (t) are continuous and
f 00 (t) s2 L(f ) − s f (0) − f 0 (0)
f 00 (t) is piecewise continuous on [0, ∞)
Z t
f (t) is piecewise continuous on [0, ∞) and
f (τ ) dτ L(f )/s for s > 0
0 its Laplace transform exists at all s > 0
Here a, c, n, w are constants, n is an integer, f (t) is a function.
38
(3) Solve for L(y) to get
R(s) + (s + a)k0 + k1
L(y) = .
s2 + as + b
(4) Reduce the expression above to a sum of terms whose inverse Laplace transforms can
be found. The sum of the inverse Laplace transforms is the solution y(t) to the initial
value problem.
39
MA1512 Week 5
Lecture materials
5.1 Partial differential equations
Definition 5.1. A partial differential equation (PDE ) is an equation containing an unknown
function u(x, y, . . . ) of two or more independent variables x, y, . . . and its partial derivatives
with respect to these variables.
Example 5.2. Consider the PDE uxy − 2x + y = 0. A solution is
1 2
u(x, y) = x2 y − xy + F (x) + G(y),
2
where F (x) and G(y) are arbitrary functions, because then
1 2 1
ux = 2xy − y + F 0 (x) and uxy = 2x − · 2y = 2x − y.
2 2
Adding to the PDE the conditions u(x, 0) = x3 and u(0, y) = sin(3y) gives
(
x2 · 0 − 12 x · 02 + F (x) + G(0) = u(x, 0) = x3 , (∗)
2 1 2
0 ·y− 2 0 · y + F (0) + G(y) = u(0, y) = sin(3y). (†)
1
Hence u(x, y) = x2 y − 2 xy 2 + x3 + sin(3y).
Remark 5.3. General solutions to ODEs contain arbitrary constants, while general solutions
to PDEs contain arbitrary functions.
Definition 5.4. (1) The order of a PDE is the order of the equation’s highest order deriva-
tive.
(2) A first-order linear PDE in u(x, y) has the form
40
PDE order linear homogeneous
4uxx − ut = 0 2 yes yes
x2 Ryyy = y 3 Rxx 3 yes yes
tutx + 2ux = x2 2 yes no
4uxx − uut = 0 2 no N/A
(ux )2 + (uy )2 = 2 1 no N/A
So u(x, y) = 3(x2 −y 2 )−7ex cos y+10 ln(x2 +y 2 ) is again a solution to the DE by Theorem 5.5.
Remark 5.9. A similar strategy applies to higher-order PDEs with 2 independent variables.
Example 5.10. Solve ux + xuy = 0 by separating the variables.
Solution. Let u(x, y) ..= X(x) Y (y) which satisfies the PDE. Then
41
Temperature
u uxx < 0
↓
uxx < 0
↓
x
0 L
↑
uxx > 0
u(x, 0) = f (x).
Solution. The method of separation of variables gives the following solutions to the
Heat Equation with Boundary Conditions 5.12(1):
nπ nπ 2
u(x, t) = B sin x exp − c2 t ,
L L
where B is a constant and n is an integer. One can then fit such solutions to Initial
Condition 5.12(2), using Theorem 5.5 if needed.
42
Solution. Let u(x, t) = X(x) T (t) be the solution. Then X(x) T 0 (t) = 2X 00 (x) T (t), or
2X 00 (x) T 0 (t)
=k= ,
X(x) T (t)
where k is a constant. Rewrite the two ODEs as X 00 − (k/2)X = 0 and T 0 /T = k.
(1) The boundary conditions tell us X(0) T (t) = 0 = X(3) T (t) for all t > 0. If T ≡ 0 or
X ≡ 0, then u = XT ≡ 0, which contradicts the initial condition. So T (t) 6= 0 for
some t > 0. This implies X(0) = 0 = X(3) by the boundary conditions.
√ √
(2) Suppose k/2 > 0. Then 02 − 4 × (−k/2) = 2k > 0. So X = Ce k/2 x + De− k/2 x ,
where
√ C, D are constants.
√ Substituting into X(0) = 0 gives C√ + D = 0. √ Thus X =
k/2 x − k/2 x 3 k/2 −6 k/2
Ce − Ce . Substituting into X(3) = 0 gives Ce (1 − e ) = 0.
The second and the third factors on the LHS cannot be 0 because k 6= 0. Hence C = 0.
This implies X ≡ 0, which contradicts point (1) above.
(3) Suppose k/2 = 0. Integrating the first ODE twice gives X = Cx + D, where C, D are
constants. Substituting into X(0) = 0 gives D = 0. Thus X = Cx. Substituting into
X(3) = 0 gives C = 0. This implies X ≡ 0, which contradicts point (1) above again.
(4) The two contradictions here show k/2 < 0. Let a be such that −k/2 = a2 . Then the
ODEs become X 00 + a2 X = 0 and T 0 /T = −2a2 .
(5) Observe that X = cos(ax) and X = sin(ax) are linearly independent solutions to the
first ODE. So X = c1 cos(ax) + c2 sin(ax), where c1 , c2 are constants. Putting this into
the first boundary condition gives
c1 cos(a · 0) + c2 sin(a · 0) = X(0) = 0.
So c1 = 0. This makes X = c2 sin(ax). Putting this into the second boundary condition
gives
c2 sin(a · 3) = X(3) = 0.
If c2 = 0, then X = 0 · sin(ax) ≡ 0, which is not true by point (1). So sin(3a) = 0, or
equivalently 3a = nπ for some integer n. Fix an integer n such that a = nπ/3.
(6) Integrating both sides of the second ODE with respect to t gives ln |T | = −2a2 t + d
and thus T = A exp(−2a2 t), where A, d are constants.
2
(7) Hence u(x, t) = B sin(ax) exp(−2a2 t) = B sin n3 πx exp −2n
2
9 π t , where B is a con-
stant.
(8) Substituting this into the initial condition gives
n −2n2 n
5 sin(4πx) = u(x, 0) = B sin πx exp π 2 · 0 = B sin πx .
3 9 3
Comparing the two sides gives B = 5 and n/3 = 4. This implies n = 12. Thus
−2 × 122
u(x, t) = 5 sin(4πx) exp π 2 t = 5 sin(4πx) exp(−32π 2 t).
9
Video materials
Equation 5.14 (The Wave Equation). A light string which lies stretched tightly along the
x-axis has its ends fixed at x = 0 and x = π, and is stationary at t = 0. Assuming tension is
the only force acting on the string, its position y(t, x) in the y-direction follows
ytt = c2 yxx , y(t, 0) = 0, y(t, π) = 0, y(0, x) = f (x), yt (0, x) = 0,
where c is a positive constant, and f (x) is a continuous bounded function on [0, π] describing
the initial shape of the string.
43
Solution (D’Alembert). The following function satisfies the Wave Equation with the
initial and boundary conditions above when one extends f to an odd function of
period 2π:
1
y(t, x) = f (x + ct) + f (x − ct) .
2
Example 5.15 (2017/18 Semester 1 Exam Question 4(b)(ii)). Let y(t, x) be the solution of
the Wave Equation
ytt = yxx , 0 6 t, 0 6 x 6 π,
with y(t, 0) = y(t, π) = 0, y(0, x) = sin3 x, yt (0, x) = 0. Find the value of y( π6 , π3 ).
π π 1 π π π π
y , = sin3 + + sin3 − = 0.562 . . . .
6 3 2 3 6 3 6
Summary
Strategy 5.8 (separation of variables for first-order PDEs). Suppose a first-order
PDE has a solution of the form u(x, y) = X(x) Y (y).
(1) Substitute u = XY and ux = X 0 Y and uy = XY 0 into the PDE.
(2) Rearrange into the form f (x, X, X 0 ) = g(y, Y, Y 0 ).
uxx (x, y) = X 00 (x) Y (y), uxy (x, y) = X 0 (x) Y 0 (y), uyy (x, y) = X(x) Y 00 (y), ....
44
Matlab materials
5.4 Surface plots
Solutions to the Heat Equation and the Wave Equation have two independent variables. One
way to visualize them is to use a 3-dimensional surface plot.
We can make such plots in Matlab using the surf command. As a demonstration, let
us plot the solution u(x, t) = 5 sin(4πx) exp(−32π 2 t) to Example 5.13 from x = 0 to x = 3
and from t = 0 to t = 0.02. We first need to decide what sample values of x and t we use to
make our plot. After some trials, it seems the following choice works fine.
>> x = 0:0.06:3;
>> t = 0:0.001:0.02;
As we saw before, the first line produces an array x that starts from 0 and progresses to 3 in
steps of 0.06, i.e., this array contains
Similarly, the second line produces an array t that starts from 0 and progresses to 0.02 in
steps of 0.001, i.e., this array contains
45
Note that the overlapping of these two matrices gives the matrix of pairs we want. So these
can readily be used calculate the required sample values of u.
>> U = 5*sin(4*pi*X).*exp(-32*pi*pi*T);
>> surf(x,t,U)
>> title(’Analytic solution’)
>> xlabel(’Distance x’)
>> ylabel(’Time t’)
One can rotate the plot, zoom in, or zoom out in Matlab.
where m is either 0, 1, or 2, and c, f , s are functions. Note that the Heat Equation is of this
form, but the Wave Equation is not. For demonstration, let us use Example 5.13 again. To
fit into the form where pdepe is applicable, let us rewrite the PDE ut = 2uxx there as
∂u ∂ 0 ∂u
1· = x−0 x ·2 + 0,
∂t ∂x ∂x
so that
∂u ∂u ∂u ∂u
m = 0, c x, t, u, = 1, f x, t, u, =2 , s x, t, u, = 0.
∂x ∂x ∂x ∂x
Recall that we saw function handles at the end of Section 1.6.
46
• Let us store m in a new variable.
>> m=0;
• The command pdepe takes in c, f and s via one function handle, in exactly that order.
The deal here puts the c, f and s into a form (called a comma-separated list in Matlab)
that is suitable to be fed into pdepe.
• We define a function handle for the initial condition u(x, 0) = 5 sin(4πx) via:
xL 6 x 6 xR ,
xL = 0 and xR = 3.
Rewrite our boundary conditions u(0, t) = 0 and u(3, t) = 0 into the required form as
∂u
uL + 0 · f xL , t, uL , =0 and
∂x x=xL
∂u
uR + 0 · f xR , t, uR , = 0,
∂x x=xR
so that
The command pdepe takes in pL , qL , pR , qR via one function handle, in exactly that
order.
We do not need to include f here as this can be inferred from the other inputs of pdepe.
• One then specifies the x values at which we want the solution approximated. In general,
if these are denser, then the approximation is better, but the computation is heavier.
47
This command makes an array (i.e., a row vector) called xmesh with 50 equally spaced
entries starting from 0 and ending at 3. So the array xmesh will contain as entries
approximately
3 3 3 3 3 3
0=0× , 1× , 2× , 3× , ..., 48 × , 49 × = 3.
49 49 49 49 49 49
Feed everything into pdepe. Let us store the approximated solution in sol.
48
Compare this with what we got from the analytic solution in Section 5.4.
We can also extract numerical values from the approximated solution. For instance,
suppose we want to get an approximated value for u(1.1, 0.001). We first find an entry in
xmesh that is closest to 1.1, and an entry in tspan that is closest to 0.001.
>> [xmindiff,xindex]=min(abs(xmesh-1.1));
>> [tmindiff,tindex]=min(abs(tspan-0.001));
Then we extract the approximated u value using the indices obtained. Note that the order
of the inputs in the output of pdepe is different from our usual order.
>> uapprox(tindex,xindex)
ans =
3.7483
One may compare this with the value that is found analytically.
>> 5*sin(4*pi*1.1)*exp(-32*pi*pi*0.001)
ans =
3.4675
49
MA1512 Summary
This summary contains all the important information. For full information, see the main
part of the notes. Formulas not listed in this summary (or in the notes/tutorials) may not
be quoted in the examination.
Strategy 1.15 (solving a Bernoulli equation, i.e., a DE of the form y 0 + p(x) y = q(x) y n ,
where 0 6= n 6= 1). Let z = y 1−n , then rearrange to apply Strategy 1.13.
Example 1.17 (radioactive decay). Let m(t) denote the mass of the radioactive substance
present at time t. Then
dm
= −km,
dt
where k is a positive constant. Suppose m0 denotes the amount of the substance present at
time 0. Then
m = m0 e−kt .
Here k can be calculated from the half-life t1/2 of the radioactive substance via the formula
ln 2
k= .
t1/2
Example 1.18 (cooling). The rate of change of the temperature T of an object is propor-
tional to the difference between T and the temperature Tenv of the surrounding medium:
dT
= −k(T − Tenv ),
dt
where k is a positive constant. If T0 = T (0), then
T = Tenv + (T0 − Tenv ) e−kt .
50
Example 1.19 (mixing). A tank contains N0 grams of salt dissolved in V litres of water
at time t = 0. Water containing ρ grams of salt per litre is entering the tank at a rate of
a litres per minute, and the well stirred solution is leaving the tank at the same rate. Let
N (t) denotes the amount of salt in the tank at time t. Then
dN a
= ρa − N.
dt V
Solving gives
a
N = ρV + (N0 − ρV )e− V t .
Example 1.20 (Uranium–Thorium Dating). Let U (t) be the number of atoms of uranium-
234 in a particular sample of ancient coral and let T (t) be the number of atoms of thorium-230.
We have U (0) = U0 and T (0) = 0, and
dU
= −kU U ,
dt
dT
= kU U − kT T,
dt
where kU , kT are constants that can be calculated from the half lives of uranium-234 and
thorium-230 as in Example 1.17. Solving the DEs:
kU U0
U = U0 e−kU t e−kU t − e−kT t .
and T =
kT − kU
Dividing gives
T kU
1 − e(kU −kT )t .
=
U kT − kU
51
polynomial cosine sine
case exponential
Set k = 0. Set k = ` + im.
Consider z 00 + az 0 + bz = p(x) e(`+im)x .
k is not a
Try y = u. Try y = uekx . Try z = ue(`+im)x .
root of (♦)
Take y = Re(z). Take y = Im(z).
00 0
Consider z + az + bz = p(x) e(`+im)x .
k is a simple
Try y = xu. Try y = xuekx . Try z = xue(`+im)x .
root of (♦)
Take y = Re(z). Take y = Im(z).
00 0
Consider z + az + bz = p(x) e(`+im)x .
k is a double
Try y = x2 u. Try y = x2 uekx . Try z = x2 ue(`+im)x .
root of (♦)
Take y = Re(z). Take y = Im(z).
Here u(x) is a polynomial of degree n with undetermined coefficients.
Strategy 2.25 (Method of Variation of Parameters). Given the DE
y 00 + p(x) y 0 + q(x) y = 0;
Strategy 2.28 (solving a DE of the form ẍ = f (x) for ẋ > 0; energy conservation).
d ẋ2 d ẋ2
(1) Substitute ẍ = into the DE to get = f (x).
dx 2 dx 2
(2) Integrate both sides with respect to x to get ẋ2 /2 = F (x) + D, where F (x) is an
antiderivative of f (x) with respect to x, and D is a constant.
(3) Proceed to solve for x if needed.
Oscillation
Terminology 3.3(1). Let x = A cos(γt) + B sin(γt) + C, where A, B, C, γ are constants.
Then the angular frequency of x is γ.
Section 3.1.1. Simple harmonic motions are modelled by DE’s of the form ẍ + ω 2 x = 0,
where ω is the natural frequency of the oscillator. General solutions are
ẍ + ω 2 x = B cos(αt)
is (
B
A cos(ωt − δ) + ω 2 −α2 cos(αt), if α 6= ω;
x= B
A cos(ωt − δ) + 2ω t sin(ωt), if α = ω.
B
In the case when α = ω, if x(0) = 0 and ẋ(0) = 0, then x = 2ω t sin(ωt).
52
Definition 3.6. Forced oscillations are modelled by DE’s of the form ẍ + ω 2 x = F (t), where
F (t) represents the external force. Resonance occurs when the frequency of the external
force, represented by F (t) above, is equal to the natural frequency ω of the oscillator.
Example 3.17 (pendulum). When a pendulum is near its stable equilibrium position, its
angular displacement θ exhibits simple harmonic motion with frequency
r
g
ω= ,
L
Models of population
Let N (t) denote the size of the population at time t, and N̂ = N (0). Then
dN
= (B − D)N − E,
dt
where B is the per capita birth rate, D is the per capita death rate, and E is the harvest
rate.
dN
F (N ) = dt
N
0 β1 β2
53
Laplace transform
Table 4.1. Here a, c, n, w are constants, n is an integer, and f (t) is a function.
δ(t) 1
ect f (t) F (s − c) for s > a + c F (s) = L(f ) and it is defined for all s > a
n!
ect tn for s > c n>0
(s − c)n+1
s−c
ect cos(wt) for s > c
(s − c)2 + w2
w
ect sin(wt) for s > c
(s − c)2 + w2
f (t) is continuous and
f 0 (t) s L(f ) − f (0)
f 0 (t) is piecewise continuous on [0, ∞)
f (t), f 0 (t) are continuous and
f 00 (t) s2 L(f ) − s f (0) − f 0 (0)
f 00 (t) is piecewise continuous on [0, ∞)
Z t
f (t) is piecewise continuous on [0, ∞) and
f (τ ) dτ L(f )/s for s > 0
0 its Laplace transform exists at all s > 0
2ws
t sin(wt)
(s2 + w2 )2
w2
1 − cos(wt)
s(s + w2 )
2
2
sin2 t 2
s(s + 4)
Strategy 4.22 (solving initial value problems using the Laplace transform). Consider the
initial value problem (
y 00 + ay 0 + by = r(t)
y(0) = k0 , y 0 (0) = k1
where a, b, k0 , k1 are constants and r(t) is a function with Laplace transform R(s).
(1) Take the Laplace transform on both sides of the DE to get, via linearity,
54
(2) Substitute in the initial conditions and L(r) = R(s) to get
s2 L(y) − sk0 − k1 + a s L(y) − k0 + b L(y) = R(s).
55