MATH3475 Prof. M A Kelmanson
L1/HO
(MATH5476M) MATH3475
(Advanced) Modern Numerical Methods
Professor M A Kelmanson
Handouts for lectures 5 to 14
and Examples Sheets 2 to 4
0
MATH3475 Prof. M A Kelmanson
L6/HO
19
2 Example 1.11 Rayleigh-Ritz solution of a MM BVP
The MM BVP of Example 1.10 is solved for the specific case
−u′′ = sin πx − cos πx x ∈ (−1, 1)
u(−1) + u′ (−1) = −1
u′ (1) + 2 u(1) = 2 ,
for which the exact solution is
u(x) =
π2 − π + 1
sin πx − cos πx 4π − 1
+
x
−
.
π2
3π
π2
Using the Rayleigh-Ritz method with basis functions φi = xi−1 , the problem is solved in Maple worksheet 3475 2.mws by calculating only half of the symmetric coefficient matrix.
The following plot shows the values of log10 |u(x) − u
eM (x)| for M = 5, 6, 7 and 8.
–1
–2
–3
–4
–5
–6
–7
–0.8 –0.6 –0.4 –0.2
0
0.2
0.4
0.6
0.8
1
x
Note that the basis functions satisfy neither of the two mixed conditions; there is freedom to choose these
as long as they span the solution in the optimal sense required.
Note also, from the error plots, that the weak formulations of Examples 1.3 and 1.11 give machineaccurate values of u
eM at ±1 irrespective of the BCs, but that this feature is not evident in the strong
formulation (collocation) of Example 1.5. 2
MATH3475 Prof. M A Kelmanson
1.3.3
L7/HO
21
Rayleigh-Ritz method for 2-D BVPs
The Galerkin and Rayleigh-Ritz methods of §§1.2.2 and 1.3.2 can be extended to 2-D and 3-D BVPs. As
in 1-D, the problem is first reformulated as one in which all Dirichlet conditions are homogeneous but,
since BCs can now vary with position, such reformulation typically depends upon geometric simplicity
of the solution domain.
2 Example 1.11 Representing 2-D inhomogeneous Dirichlet BCs via a single function
Consider the Poisson equation
− ∆U = G (G prescribed) for U = U (x, y) in the unit square
R = [0, 1] × [0, 1] with inhomogeneous Dirichlet BCs prescribed around the boundary:
U (x, 0) = 1 − x
x ∈ [0, 1]
(linear variation from 1 to 0 along “southern” edge)
x ∈ [0, 1]
(quadratic variation from 1 to 0 along “northern” edge)
U (0, y) = 1
y ∈ [0, 1]
(constant on “western” edge)
U (1, y) = y(1 − y)
y ∈ [0, 1]
(quadratic variation from 0 to 0 along “eastern” edge) .
U (x, 1) = (1 − x)2
One can verify that U is continuous on the boundary C of R. We now construct the function v(x, y) ,
the 2-D counterpart of D(x) in (1.10), that accounts for all four given BCs; as such, it must contain at
least the polynomial terms 1, x, y, x2 and y 2 present above.
The simplest possibility permitting v(x, 1) = (1 − x)2 is v(x, y) = (1 − x)2 y , which contains the
further polynomial terms xy and x2 y . Similarly, the simplest possibility permitting v(1, y) = y(1−y)
is v(x, y) = xy(1 − y) , which contains the further (new) polynomial term xy 2 . Thus the simplest
form of v(x, y) that is able to reproduce all four Dirichlet BCs is
v(x, y) = a0 + a1 x + a2 y + a3 x2 + a4 xy + a5 y 2 + a6 x2 y + a7 xy 2 ,
in which the (eight) constants ai are determined by matching v(x, y) to the (four) BCs above; this can be
done because the equations are nonlinear, yielding (see Maple worksheet 3475 2.mws)
v(x, y) = 1 − x + x2 y − xy 2 .
With v(x, y) determined, the function u ≡ U − v therefore has homogeneous Dirichlet BCs around the
boundary of the unit square, within which it satisfies the Poisson equation
−∆u = −∆U + ∆v = G + 2(y − x) ≡ f ,
say, which is in a form we can readily solve numerically. 2
(1.50)
MATH3475 Prof. M A Kelmanson
L7/HO
22
In order to solve the 2-D BVP − ∆u = f using a variational principle, we require the 2-D form of the
Euler-Lagrange equation. For u = u(x, y), this is simply
∂ ∂F
∂u
∂ ∂F
∂u
∂F
−
and uy =
.
−
= 0 , where ux =
∂u ∂x ∂ux
∂y ∂uy
∂x
∂y
(1.51)
2 Example 1.12 Finding F (u, ux , uy ) for the 2-D Poisson equation −∆u = f
Comparing the positive-definite form −uxx − uyy = f of the self-adjoint Poisson equation with (1.51),
we require
∂ ∂F
∂ ∂F
= −uxx ,
−
= −uyy ,
∂x ∂ux
∂y ∂uy
with consistent solution F (u, ux , uy ) = 21 u2x + u2y − f u . 2
∂F
= −f ,
∂u
−
We now illustrate the Rayleigh-Ritz formulation for solving Poisson’s equation for u = u(x, y) in a
domain R ⊆ R2 with boundary C = C1 ∪ C2 , on which Dirichlet and Neumann/mixed conditions are
respectively prescribed. Let s denote the variable that parameterises C. The model “homogeneous-DM”
BVP is then
−∆u = f
(x, y) ∈ R
u(s) = 0 on C1
∂u
(s) + β(s)u(s) = B(s) on C2 ,
∂n
(1.52)
in which the derivative in the mixed BC is in the direction of the unit normal vector n̂ to C: when this
points out of R, s is traversed in an anticlockwise sense, and vice-versa. From Example 1.12 we have
F (u, ux , uy ) =
1 2
ux + u2y − f u
2
and, by analogy with (1.48) in Example 1.10, the functional is
Z
ZZ
2
2
βu2 − 2Bu ds .
ux + uy − 2f u dA +
E[u] =
(1.53)
C2
R
The trial function is postulated to be
u
eM (x, y) =
M
X
ci φi (x, y) ,
(1.54)
i=1
in which φi (x, y) = 0 on C1 , i = 1(1)M . By analogy with (1.45), (1.46) and (1.49), a stationary value
of the functional in (1.53) leads to the (symmetric) equations
M
X
j=1
cj
ZZ R
Z
∂φi ∂φj
∂φi ∂φj
+
dx dy + β φi φj ds
∂x ∂x
∂y ∂y
C2
ZZ
Z
f φi dx dy i = 1(1)M .
= B φi ds +
C2
R
Note that C2 may itself comprise subcomponents, as the following example shows.
(1.55)
MATH3475 Prof. M A Kelmanson
L7/HO
23
2 Example 1.13 Mixed BCs on a square domain
Consider a specific case of the mixed BC in (1.52) in which C2 comprises two sections, the “eastern” and
“northern” sides of the unit square, on which (taking the outward normal derivative)
∂u
(1, y) + βe (y)u(1, y) = Be (y)
∂x
∂u
(x, 1) + βn (x)u(x, 1) = Bn (x)
∂y
and
respectively. Then on the LHS of (1.55) we have
Z
Z 1
Z
βe (y) φi (1, y) φj (1, y) dy +
β(s) φi (s) φj (s) ds =
C2
=
y=0
Z 1
βe (y) φi (1, y) φj (1, y) dy +
C2
βn (x) φi (x, 1) φj (x, 1) (−dx)
x=1
Z 1
βn (x) φi (x, 1) φj (x, 1) dx ,
x=0
y=0
and on the RHS we therefore have
Z
Z
B(s) φi (s) ds =
0
1
Be (y) φi (1, y) dy +
Z
1
Bn (x) φi (x, 1) dx .
x=0
y=0
These results are implemented in the following example. 2
2 Example 1.14 Rayleigh-Ritz solution of Poisson equation in the unit square
The Rayleigh-Ritz method is used to solve the Poisson equation
−∆u = 8y + 18xy − 6x2 y − 2y 3
in R = [0, 1] × [0, 1], with homogeneous Dirichlet BCs on x = 0 and y = 0 and mixed BCs on x = 1
and y = 1. Using the notation of Example 1.13, we take
βe (y) = y/2
Be (y) = 4y + 4y 2 − y 3 − y 4
βn (x) = x/3
Bn (x) = 3x + 2x2 − x3 .
The BVP so constructed has exact solution
u(x, y) = xy(3 − x)(4 − y 2 ) = 12xy − 4x2 y − 3xy 3 + x2 y 3 ,
in whose absence our choice of basis functions would be uninformed. All we could then say is that the
homogeneous Dirichlet conditions on x = 0 and y = 0 and the polynomial nature of the PDE’s RHS and
BCs suggest u(x, y) = xyP (x, y) for some polynomial P (x, y) = a0 + (a1 x + a2 y) + (a3 x2 + a4 xy +
a5 y 2 ) + . . ., implying the sequence of basis functions xy, x2 y, xy 2 , x3 y, x2 y 2 , xy 3 , . . ..
However, inspired by the exact solution, we shall select elements of this sequence as follows,
φ1 = xy
φ2 = x2 y
φ3 = xy 2
φ4 = xy 3
φ5 = x2 y 3 ,
noting that φ3 is not contained in u(x, y), and so we expect its coefficient to vanish with increasing M .
MATH3475 Prof. M A Kelmanson
L7/HO
25
In Maple worksheet 3475 2.mws we implement the setup and solution of the symmetric system
(1.55), using the approach of Example 1.14 to incorporate the mixed BCs. The coefficients ci are substituted into (1.54) to yield
u
e2 (x, y) =
8231
873 xy
u
e4 (x, y) =
5841403
509662 xy
u
e3 (x, y) =
−
212827
16898 xy
2647 2
873 x y
−
506161 2
152082 x y
−
15381353 2
4586958 x y
−
336047
2
101388 xy
+
256697
2
3057972 xy
−
580369
3
254831 xy
u
e5 (x, y) = 12xy − 4x2 y − 3xy 3 + x2 y 3 ,
in which, as predicted, the coefficient of φ3 is small (≈ 0.084) in u
e4 and zero in u
e5 .
The error EM (x, y) ≡ u(x, y) − u
eM (x, y)
M = 2(1)5 , in the above trial functions over the unit square
is plotted below for M = 2, 3, 4 and 5. The 3-D view is from a point above the line y = x in the
first quadrant, looking towards the origin. We note: the vertical scale in each plot clearly demonstrates
convergence of u
eM to u with increasing M ; although {φ1 , . . . , φ5 } spans the exact solution, the errors
in the final plot are non-zero because of the use of double-precision floating-point arithmetic, and; by
construction of the basis functions, the error is zero where essential BCs are prescribed.
0.4
0.05
0.2
0
0
–0.05
–0.2
–0.1
–0.4
0
0
0.6
0.6
0.8
0.4
0.4
x
y
0.8
1
0
0
0.2
0.2
0.4
0.4
0.6
0.6
0.8
0.8
1
x
x
0.8
1
0.08
0.06
0.04
0.02
0
–0.02
–0.04
1
0.6
0.6
0.8
1
y
0.2
0.2
0.4
0.4
y
0
0
0.2
0.2
1
6e–15
4e–15
2e–15
0
–2e–15
–4e–15
–6e–15
0
0
0.2
0.2
0.4
0.4
y
0.6
0.6
0.8
0.8
1
1
x
MATH3475 Prof. M A Kelmanson
Exs 2
113
(MATH5476M) MATH3475: (Advanced) Modern Numerical Methods
Example Sheet 2 (Prof Kelmanson)
Variational Methods for 1-D and 2-D BVPs
The following questions are based upon the material covered in Lectures 5 to 7.
Equation numbers refer to those in the course notes.
Q1 Consider the the 2-point self-adjoint BVP
−(1 + x)u′′ − u′ = x
x ∈ (0, 1)
u(0) = u(1) = 0 .
(i) Solve the BVP to obtain the exact solution,
1
ln(1 + x)
2
u(x) = −
x − 2x +
.
4
ln 2
(ii) Using the Rayleigh-Ritz method with trial functions φ1 (x) = x(1 − x) and φ2 (x) = x2 (1 − x) in
a suitable amendment of (1.47), show that the approximate solution u
e2 (x) of the BVP is
u
e2 (x) =
1
x(1 − x)(5x + 19) .
131
(iii) You are given that the error function E2 (x) = u(x) − u
e2 (x) has three turning points in [0, 1], at
x1 ≈ 0.11231, x2 ≈ 0.50077 and x3 ≈ 0.88691. Use this information to compute ||u − u
e2 ||∞ and,
hence, the maximum value of the relative error, ρ2 (x) ≡ |E2 (x)/u(x)| of u
e2 (x) on [0, 1]. 2
Q2 Consider Poisson’s equation − ∆U = 2(x + y) − 4 on the unit square [0, 1] × [0, 1] with BCs
U (0, y) = y 2
U (x, 0) = x2
∂U
(1, y) = 2 − 2y − y 2
∂x
∂U
(x, 1) = 2 − 2x − x2 .
∂y
(i) Determine the function v(x, y) that satisfies all non-homogeneous Dirichlet BCs (cf. Example 1.11),
and so determine the Poisson equation satisfied by u ≡ U − v . Determine also the BCs satisfied by u.
(ii) Following the procedure in Example 1.13, insert the information in (i) into the general form (1.55)
of the Rayleigh-Ritz equations. Hence show that the equations to be solved for the coefficients of the
basis functions in the trial function u
e2 (x, y) = c1 φ1 (x, y) + c2 φ2 (x, y) are
2
X
j=1
cj
Z 1Z 1
0 0
∂φi ∂φj
∂φi ∂φj
+
∂x ∂x
∂y ∂y
dx dy = −
Z
1
(2y + y 2 ) φi (1, y) dy −
1
(2x + x2 ) φi (x, 1) dx
0
0
+2
Z
Z 1Z
0 0
1
(x + y) φi dx dy
i = 1(1)2 .
MATH3475 Prof. M A Kelmanson
Exs 2
114
(iii) Using the specific trial functions φ1 (x, y) = xy and φ2 (x, y) = xy(x + y) in the equations
derived in (ii), obtain the equations for c1 and c2 and note that they may be solved by inspection.
(iv) Hence show that the approximate solution of the original BVP is
e2 (x, y) = x2 + y 2 − xy(x + y) .
U
e
e
e2 , and comment on the results. 2
e2 (x, 0), U
e2 (0, y), ∂ U2 (1, y), ∂ U2 (x, 1) and ∆U
Evaluate U
∂x
∂y
Hints, comments and quick-check answers to numerical questions
1
b1 = − 12
and
R
x2 dx
1
17
1+x using the substitution v = 1+x. (ii) A11 = − 2 , A12 = A21 = − 60 , A22
1
b2 = − 20
. (iii) E2 (x1 ) = −2.75 × 10−4 and ρ2 (x1 ) ≈ 1.88 × 10−2 ≈ 1.9%.
A1 (i) Integrate
7
= − 30
,
A2 (i) This is easier than you think! (ii) Here βe (y) = βn (x) = 0 and part (i) gives Be (y) and Bn (x).
R1
R1
R1R1
1
(iii) The calculations are simplified by noting that 0 xm dx = 0 y m dy = m+1
and 0 0 xm y n dx dy =
1
(m+1)(n+1) . Also,
b1 = − 67 and b2 =
use symmetry of x and y where possible. A11 = 23 , A12 = A21 = 76 , A22 =
− 103
45 .
103
45 ,
MATH3475 Prof. M A Kelmanson
1.4
L8/HO
26
The finite element method
1.4.1
FEM definition of basis functions
In the FEM, the solution domain x ∈ Ω ⊆ Rn (n = 1, 2, 3) is discretised by dividing it into nonoverlapping elements e(k) of arbitrary shape and size: this feature makes the FEM method far more
flexible than its FDM counterpart. Within each element, a certain number of nodes are defined at which
the unknown nodal values ui are to be determined. These nodal values are used to approximate the exact
solution u(x) of a BVP by a finite linear combination of local basis functions using
X
u
e(x) ≡
Ni (x) ui
x ∈ Ω.
(1.56)
all nodes i
Thus one basis function Ni (x) is attached to each local nodal value ui ≡ u(xi ). Note that this differs
from the collocation approximation (1.13), in which each basis function φi (x) was associated with an
unknown global coefficient ci .
Unlike the methods of §1.1.3, which use global basis functions, the FEM employs basis functions that are
locally defined polynomials within each element e(k) , each of which is zero outside e(k) . The contribution
(k)
to Ni (x) from the piecewise polynomial defined on e(k) is denoted by Ni (x). Since the coefficients in
the expansion (1.56) are ui , the unknown nodal values of u, the basis functions must satisfy the following
conditions on each element e(k) , with xi being a node in element e(k) :
(k)
Ni (x) = 0
(k)
Ni (xj ) = δij
if x 6∈ e(k) ,
(“locality”) ;
because ui ≡ u
e(xi ) ,
In addition, if u
e = constant then (1.56) and (1.57) require
X (k)
Ni (x) = 1 for all x ∈ e(k) .
(1.57)
(“sifting”) .
(1.58)
(1.59)
i
(k)
The global basis function Ni (x) is obtained by assembling the contributions Ni (x) from all the elements to which node xi belongs:
X
(k)
Ni (x) =
Ni (x) .
(1.60)
k such that
xi ∈e(k)
As a result of the limited inter-element differentiability of the Ni (x) thus constructed, two families of
elements are generally considered.
• If the nodal values are the unknown values of u(x), C 0 inter-element continuity is sufficient for
differential equations no higher than second order. The elements and the associated basis functions
are called Lagrangian elements. The simplest Lagrangian element in 1-D, considered in §1.4.2,
therefore uses piecewise-linear interpolation and two nodes.
• If, especially in BVPs of higher than second order, the nodal values also include the unknown
values of first-order partial derivatives of u(x), C 1 inter-element continuity must be imposed.
The elements satisfying these conditions are called Hermitian elements. The simplest Hermitian
element in 1-D therefore uses piecewise-cubic interpolation and two nodes.
In 2- or 3-D, if the required degree of inter-element continuity is satisfied along every point of the interelement boundary, the element is called conforming; otherwise it is non-conforming.
MATH3475 Prof. M A Kelmanson
1.4.3
L9/HO
30
Galerkin FEM for two-point BVPs
We implement a finite element version of Galerkin’s method which, as we have seen, is more widely applicable than those based on variational principles. Subdivide the interval [a, b] into N linear Lagrangian
elements with endpoints at the N + 1 nodes a = x0 < x1 < x2 < · · · < xN = b and, via (1.56), use the
piecewise-linear trial function
u
eN (x) =
N
X
Ni (x) ui ,
(1.67)
i=0
where ui = u
eN (xi ), i = 0(1)N , are (global) nodal values of the approximate solution, and Ni are as in
(1.63). Over each local universal element [x1 , x2 ], approximate u by the linear interpolant (1.66),
u
e(ξ) =
2
X
i=1
Ni (ξ) ui ,
(1.68)
in which ξ is given by (1.64). In order to find the unknown ui we require, by analogy with (1.16), that
the following weighted residuals vanish on each element:
Z
x2
x1
Ni R(e
u) dx =
Z
x2
x1
Ni
X
2
j=1
p Nj′′ + q Nj′ + r Nj uj − f
dx = 0
i = 1, 2 ,
(1.69)
in which (1.15) and (1.68) have been used. This gives an element contribution to the global equations of
2
X
j=1
uj
Z
x2
x1
Ni p Nj′′ + q Nj′ + r Nj dx ≍
Z
x2
x1
Ni f dx
i = 1(1)2 ,
(1.70)
in which the symbol ≍ is used to indicate a local contribution to global equality. Because of the inter-
element-boundary discontinuities in piecewise-polynomial basis functions, care must be taken before
integrating (1.70) by parts to derive a weak formulation analogous to (1.18).
N1′ (ξ)
N1 (ξ)
x1
N2 (ξ)
x2
N2′ (ξ)
For x ∈ [x1 , x2 ], N1′ = −1 and N2′ = +1, though discontinuous at the nodes, are bounded; these, along
with N1 and N2 , are readily integrated in (1.70). However, the above figure reveals that both N1′′ (x1 )
and N2′′ (x2 ) are “infinitely negative”, whereas N1′′ (x2 ) and N2′′ (x1 ) are “infinitely positive”.
MATH3475 Prof. M A Kelmanson
L9/HO
31
Therefore the local shape functions have singular second derivatives of the form
N1′′ (x) = δ(x − x2 ) − δ(x − x1 )
N2′′ (x) = δ(x − x1 ) − δ(x − x2 )
x ∈ [x1 , x2 ] ,
(1.71)
in which δ(x − a) is the Dirac delta function (a “spike” of infinite height and infinitesimal width located
at x = a) satisfying the integral relations
Z ∞
δ(x − a) dx = 1
and
−∞
Z
∞
−∞
δ(x − a) p(x) dx = p(a) ,
(1.72)
the latter of which is called the sifting property. Putting all this into (1.70), we may integrate by parts the
Ni′′ terms to obtain
2
X
j=1
uj
Z
x2
x1
n
o
(p Ni )′ − q Ni Nj′ − r Ni Nj dx ≍ −
Z
x2
x1
Ni f dx
i = 1(1)2 .
(1.73)
Thus the fundamental difference between this local contribution and its global equivalent in (1.22) is that
here, the element-endpoint singularities in the 2nd derivatives of the shape functions annihilate the interelement-boundary terms, which may therefore be ignored a priori. This makes physical sense: forcing
terms should arise only through the external BCs, not the inter-element boundaries that are artefacts of
the FEM.
Finally, the element contributions are assembled, to construct a global system of equations for the ui . In
the simplest case of a DD 2-point BVP, the assembly is as follows.
• On the first element [x0 , x1 ] (global numbering), u0 is given by the left BC, hence (1.73) is used
only once, with i = 2;
• On all internal elements (1.73) is used twice, with both i = 1 and i = 2;
• On the last element [xN −1 , xN ] (global numbering), uN is given by the right-hand BC, hence (1.73)
is used only once, with i = 1.
(1.74)
MATH3475 Prof. M A Kelmanson
L9/HO
29
2 Example 1.15 Galerkin FEM solution of a two-point DD BVP
In Maple worksheet 3475 3.mws, the piecewise-linear Galerkin method is used to find the approximate solution u
e5 (x) of the DD BVP
(x + 5) u′′ + u′ + u = 2 x ∈ (0, 5)
u(0) = 1 u(5) =
5
2
.
(1.74)
Nodes are regularly spaced at xi = i, i = 0(1)5, and only the interior values ui = u
e5 (xi ), i = 1(1)4, are
sought since u0 and u5 are given explicitly by the Dirichlet BCs.
First, the local weighted-residual conditions (1.73) are evaluated on each element. The symbol ≍ is
used as in (1.70), since each nodal value occurs in two elements and cannot therefore be determined in
isolation; all equations must be solved together.
On element 1, (1.73) with i = 2, augmented by the BC u0 = 1, gives
31
14
0
0
0
u
1
6
3
0 0 0 0 u 0
2
≍
0 0 0 0 u3 0
u4
0 0 0 0
0
On element 2, (1.73) with i = 1, 2 gives
37
− 20
6
3
− 20
37
3
6
0
0
0
0
0 0
0
.
−1
u
1
0 0 u2
≍
0 0
u3
0 0
u4
On element 3, (1.73) with i = 1, 2 gives
0
0
0
0
43
− 23
6
3
43
0 − 23
3
6
0
0
0
−1
.
0
0
u1
0
u1
0
0
u2 −1
≍
.
0
u3 −1
u4
0
0
On element 4, (1.73) with i = 1, 2 gives
0 0
0
0
0 0
0
0
49
26
0 0
−3
6
49
26
0 0 −3
6
u 0
2
≍
.
u3 −1
−1
u4
On element 5, (1.73) with i = 1, augmented by the BC u5 = 25 , gives
0 0 0 0
u1
0
0 0 0 0 u 0
2
≍
0 0 0 0 u3 0
139
u
0 0 0 55
4
6
6
.
MATH3475 Prof. M A Kelmanson
L9/HO
Second, all contributions can now be assembled to obtain
20
31 37
−
u1
+
0
0
6 206 37 343
23
u2
−3
0
−3
6 + 6
23
43 49
26
0
−
+
−
u3
3
6
6
3
49 55
0
0
− 26
u4
3
6 + 6
so that
34
3
− 20
3
− 20
3
0
0
0
40
3
23
−3
0
− 23
3
46
3
− 26
3
0
u1
32
14
3 −1
−1−1
=
−1−1 ,
139
−1+ 6
11
3
u2 −2
0
u = −2 .
− 26
3
3
52
133
u4
3
6
(1.75)
(1.76)
Written as Au = b, A is known as the stiffness matrix and b the force vector. The solution of this tridiage 4 ≈ (1.26157, 1.59648, 1.93720, 2.24744).
onal system is readily found using the methods of §3 in MATH3474 to be u
If the same BVP is solved using the finite-difference method with a mesh size of h = 1 and 2nd-order
central differencing for the derivatives, the nodal values Ui , i = 1(1)4 satisfy the equations
7
11 − 13
0
0
U
1
2
13
2
15
−2
13
−
0
U
2
2 = −2 ,
15
17
0 −2
15 − 2 U3 −2
87
17
0
0 −2
U4
17
4
(1.77)
e 4 ≈ (1.26026, 1.59429, 1.93788, 2.24835). It is to be remembered that the coefficients
with solution U
in (1.76) and (1.77) differ (N.B. only slightly) because the former equations arise through a minimisation principle applied globally to the trial functions defined by (1.61) whereas the latter arise through
satisfying (a discretisation of) the ODE in (1.74) at the nodes.
The exact solution of the BVP yields
√
√
u(x) ≈ 2.73305 J0 (2 x + 5) + 0.57264 Y0 (2 x + 5) + 2 ,
in which J0 and Y0 are respectively Bessel functions of the first and second kind. Using the exact
solution, the infinity norms of the nodal-error vectors of the FEM and FDM (with N uniform elements)
may be computed; they are tabulated below for different values of N .
e N eN ||∞
N
||u − u
Ratio u − U
Ratio
5
10
20
2.899 ×
10−3
1.963 ×
10−4
7.816 ×
10−4
—
3.70
3.98
2.563
6.456
1.602
∞
−3
× 10
× 10−4
× 10−4
—
3.97
4.03
Note that both the FEM and FDM nodal errors reduce by a factor of approximately 4 as the mesh size
is halved, indicating 2nd-order convergence: this arises through the use of piecewise-linear Lagrange
interpolation in the FEM and 3-point CD formulae in the FDM. 2
MATH3475 Prof. M A Kelmanson
1.4.5
L11/HO
35
Quadratic Lagrange elements
Linear, two-node Lagrangian elements were used in §1.4.2 to illustrate the Galerkin FEM algorithm,
which yielded the 2nd-order convergence of numerical results observed in Example 1.15. In principle,
higher-order elements can be used to improve this convergence.
The next-simplest Lagrangian element is a quadratic, three-node element, [x1 , x3 ] in local coordinates,
in which the nodal value u2 at the interior point x2 = 21 (x1 +x3 ) is absent from the equations on adjacent
elements. Corresponding to (1.64), we now define
ξ≡2
x − x2
,
x3 − x1
(1.88)
so that ξ ∈ [−1, 1]. The universal forms of the piecewise-quadratic basis functions are then
1
N1 (ξ) ≡ ξ(ξ − 1)
2
1
N3 (ξ) ≡ ξ(ξ + 1)
2
N2 (ξ) ≡ 1 − ξ 2
(1.89)
and the universal quadratic Lagrange interpolant on any element [x1 , x3 ] is therefore
u
e(ξ) = N1 (ξ) u1 + N2 (ξ) u2 + N3 (ξ) u3
ξ ∈ [−1, 1] .
(1.90)
The arguments in §1.4.3 regarding inter-element discontinuities again apply and, corresponding to (1.73),
we now obtain an elemental contribution to the global equations of
3
X
j=1
uj
Z
x3
x1
n
o
(p Ni )′ − q Ni Nj′ − r Ni Nj dx ≍ −
Z
x3
x1
Ni f dx
i = 1(1)3 .
(1.91)
In assembling the global matrix note that: (a) on the first element, only the contributions from i = 2
and i = 3 are taken in (1.91), and; (b) on the last element, only those from i = 1 and i = 2 are used.
Note also that N must be even in order for each element to comprise two subintervals [x1 , x2 ] ∪ [x2 , x3 ].
When N = 2 and there is only one quadratic element, only the i = 2 contribution is used.
As presented, the integrals in (1.70) and (1.91) are in terms of both x and ξ; e.g. the integral on the RHS
of (1.91) is
Z
x3
x1
Ni ξ(x) f (x) dx
and so may be computed using either
Z x3
2x − 2x2
Ni
f (x) dx
x3 − x1
x1
or
or
Z
x3 − x1
2
1
dx
dξ ,
Ni (ξ) f x(ξ)
dξ
−1
Z
1
−1
Ni (ξ) f
x2 +
x3 − x1
ξ
2
dξ .
(1.92)
Although both forms in (1.92) are readily used in an algebraic manipulation package such as Maple, for
intensive numerical work only the latter lends itself to efficient computation because it has been reduced
to a universal interval to which quadrature may be applied. This is pursued in detail in §1.5.
MATH3475 Prof. M A Kelmanson
L11/HO
34
The following figure shows the quadratic basis functions of (1.89) on the universal interval [−1, 1]. It is
immediately evident that Ni (ξj ) = δij , where {ξ1 , ξ2 , ξ3 } = {−1, 0, 1}.
1
N1 (ξ)
N2 (ξ)
0.8
N3 (ξ)
0.6
0.4
0.2
–1
–0.8 –0.6 –0.4 –0.2
0.2
0.4
0.6
ξ
0.8
1
MATH3475 Prof. M A Kelmanson
L11/HO
37
2 Example 1.17 Piecewise-quadratic Galerkin FEM
Consider again the BVP (1.75) solved by the piecewise-linear Galerkin FEM in Example 1.15, and by
the piecewise-linear Rayleigh-Ritz FEM in Example 1.16. In each of these cases, we recall that the
numerical error was inversely proportional to N 2 , i.e. it exhibited 2nd-order convergence.
In Maple worksheet 3475 4.mws, a quadratic-Lagrangian Galerkin FEM is used to solve the BVP
with N = 4. Hence there are two elements with global coordinates e(1) = [x0 , x2 ], with interior node
x1 , and e(2) = [x2 , x4 ], with interior node x3 . When the element contributions (1.92) from e(1) and e(2)
are assembled, the pre-processed system is
i = 1 [ignore]
[ 29
2 ]
(− 37 )
6
i = 1 and i = 3 ( 11
2 )
i=2
0
i = 3 [ignore]
0
i=2
[− 37
6 ]
[ 11
2 ]
12
− 15
2
− 15
2
0
0
37 43
6 + 6
− 53
6
[ 54 ]
0
0
0
0
(u0 )
u1
5
u2
− 53
(
)
6
4
61
52
(−
)
u3
3
6
61
17
(u4 )
−[ 6 ] [ 2 ]
− 56
− 10
3
5 5
= −6−6
− 10
3
− 56
,
in which u0 and u4 are specified by the Dirichlet BCs. Transferring all known information (in parentheses) to the RHS, we therefore have
12
− 15
2
0
− 15
2
0
37 43
6 + 6
− 53
6
u1
10
( 37
6 )(u0 )− 3
= −( 11 )(u0 )− 5 − 5 −( 5 )(u4 ) .
− 53
6 u2
2
6 6
4
61
10
52
(
u
)(u
)−
3
4
3
6
3
Hence with u0 = 1 and u4 = 25 , the unknown nodal values satisfy the equations
12
− 15
2
0
− 15
2
40
3
− 53
6
0
u1
=
− 53
6 u2
52
u3
3
17
6
− 137
24
265
12
,
with solution (u1 , u2 , u3 ) ≈ (1.3395, 1.7655, 2.1737). The FEM solution u
e4 (x) is then a piecewise-
quadratic function comprising two parabolae, one passing through (x0 , u0 ), (x1 , u1 ) and (x2 , u2 ), the
other through (x2 , u2 ), (x3 , u3 ) and (x4 , u4 ).
e 4 ||∞ ≈ 1.577 × 10−3 . The process is automated for arbitrary N in
The nodal values satisfy ||u − u
Maple worksheet 3475 4.mws. 2
MATH3475 Prof. M A Kelmanson
1.4.6
L11/HO
36
Non-uniform finite elements
Non-uniform element size can be trivially incorporated in the FEM; recall that this was not the case for
the finite-difference method. We may, for example, scale each element by a factor α according to
xk+1 − xk = α (xk − xk−1 ) ,
(1.93)
so that α = 1 leaves all elements the same size, whereas α < 1 and α > 1 respectively compress and
expand the elements in the direction of the positive x-axis: then, the N th element is σ ≡ αN times
smaller/bigger than the first. Of course, other element rescalings may be used.
2 Example 1.18 The effect on errors of non-uniform elements
The BVP of Example 1.17 is solved (see Maple worksheet 3475 4.mws) using a piecewise-quadratic
Galerkin method with α = 1.0 and α = 1.1. As the following results show, even a slight stretching may
subtantially alter the error distribution.
[1] Plots of the piecewise-quadratic-interpolant error u(x) − u
e8 (x), the nodal error values u(xi ) − u
e8 (xi )
e8 ||∞ for α = 1.0 (left) and α = 1.1 (right). Note that increasing α from 1.0 to 1.1 reduces
and ± ||u − u
e8 ||∞ . Note that the weak
the continuous-error norm ||u − u
e8 ||∞ but increases the nodal-error norm ||u − u
formulation means that, in general, the errors do not vanish at the nodes (see §1.4.8).
0.0015
0.0015
0.001
0.001
0.0005
0.0005
0
1
2
x
3
4
5
0
–0.0005
–0.0005
–0.001
–0.001
–0.0015
–0.0015
1
2
x
3
4
5
[2] Plots of the piecewise-quadratic-interpolant error u(x) − u
e16 (x), the nodal error values u(xi ) − u
e16 (xi )
e16 ||∞ for α = 1.0 (left) and α = 1.1 (right). By increasing N , and therefore σ, the relative
and ± ||u − u
e16 ||∞ in the left and right figures is larger than that in
disparity between the nodal-error norms ||u − u
e 8 ||∞ in [1].
||u − u
0.0002
0.0002
0.0001
0.0001
0
1
2
x
3
4
5
0
–0.0001
–0.0001
–0.0002
–0.0002
1
2
x
3
4
5
MATH3475 Prof. M A Kelmanson
L11/HO
37
e′8 (x) and exact u′ (x) for α = 1.0 (left) and α = 1.1 (right). Note
[3] Plots of the piecewise-linear u
the barely-visible small jumps (i.e. not just the change in gradient) in u
e′8 (x) at element endpoints in the
left-hand figure.
0.35
0.35
0.3
0.3
0.25
0.25
0.2
0.2
0.15
0.15
0.1
0.1
0.05
0.05
0
1
2
x
3
4
5
0
1
2
x
3
4
5
[4] Plots of the piecewise-constant u
e′′8 (x) and exact u′′ (x) for α = 1.0 (left) and α = 1.1 (right). It is the
inter-element jumps that give rise to the singular terms that annihilate the inter-element boundary terms
in (1.91).
0.15
0.15
0.1
0.1
0.05
0.05
0
1
–0.05
2
x
3
4
5
0
1
2
x
3
4
5
–0.05
eN ||∞ is smaller for α = 1.0 than for α = 1.1, whereas the converse is
In the plots in [1] and [2], ||u − u
eN ||∞ .
true for ||u − u
Since piecewise-quadratic integration in Simpson’s rule has 4th-order convergence with 1/N , we might
expect the same here. It transpires that the order of convergence depends upon both the norm used and
the uniformity of the mesh: a discussion of this is deferred until §1.4.8. 2
MATH3475 Prof. M A Kelmanson
L12/HO
39
The following figure shows the Hermite interpolation polynomials (1.96) on the universal interval [−1, 1].
It is immediately evident that they satisfy the conditions (1.95). In particular, note the unit slopes
H2′ (−1) = H4′ (1) = 1, highlighted here by tangential straight-line segments.
1
H1 (ξ)
H3 (ξ)
0.8
0.6
H2 (ξ)
0.4
0.2
–1 –0.8 –0.6 –0.4 –0.2 0
0.2
0.4 ξ 0.6
0.8
1
–0.2
H4 (ξ)
Quadratic Lagrangian and cubic Hermitian elements can also be used in the Rayleigh-Ritz procedure
by extending the arguments in §1.4.4 in a natural way. Because of the limitation of this approach to
self-adjoint problems, the details are not pursued.
It is clear that the main cost of implementing quadratic-Lagrangian and cubic-Hermitian elements is the
increasing cost of integration in the elemental contributions. When exact-arithmetic packages such as
Maple and Mathematica are used, this is not really an issue. However, when numerical-methods
packages such as Matlab and SciLab are used, sophisticated numerical integration methods are required. This motivates the Gaussian Quadrature considered in §1.5.
SciLab is an excellent freeware package that is downloadable from http://www.scilab.org
MATH3475 Prof. M A Kelmanson
L13/HO
42
2 Example 1.19 Convergence of quadratic FEM
Formulae (1.102) and (1.106) are tested on the BVP and FEM implementation of Example 1.18 using N
eN ||∞ .
uniform elements. Also presented are the infinity norms of the nodal errors, ||u − u
As the number of elements is doubled, theory predicts error ratios of 23 = 8, 22 = 4 and 23 = 8 for
eN ||∞ respectively.
||u − u
eN ||0 , ||u − u
eN ||1 and ||u − u
L2 norm
Energy norm
Nodal errors
N
||u − u
eN ||0
Ratio
||u − u
eN ||1
Ratio
eN ||∞
||u − u
Ratio
4
1.063 × 10−2
—
2.921 × 10−2
—
1.577 × 10−3
—
8
1.354 ×
10−3
7.85
7.129 ×
10−3
4.10
16
1.701 ×
10−4
7.96
1.770 ×
10−3
32
2.128 × 10−5
7.99
4.418 × 10−4
64
2.661 ×
8.00
1.104 ×
10−6
10−4
1.285 ×
10−4
12.3
4.03
9.283 ×
10−6
13.84
4.00
6.248 × 10−7
14.86
4.00
4.053 ×
15.41
10−8
Convergence in the L2 norm is of 3rd order, as predicted by (1.102). Convergence in the energy norm is
of 2nd order, as predicted by (1.106). The agreement between the numerical convergence rates and the
predictions is impressive given both the assumptions on which the error analysis is conducted, and the
cumulative effects of the error bounds.
Convergence in the nodal norm clearly tends to 4th order, i.e. 24 = 16. This is an example of superconvergence, a complete explanation of which requires the theory of projection operators. 2
2 Example 1.20 Non-uniform elements and erosion of convergence
When the elements in Example 1.19 are scaled by a factor α = 1.05 as in (1.93), the results in the
following table are obtained. Recall that σ ≡ αN represented the size ratio between the smallest and
largest elements.
L2 norm
Energy norm
Nodal errors
N
||u − u
eN ||0
Ratio
||u − u
eN ||1
Ratio
e N ||∞
||u − u
Ratio
σ
4
9.537 × 10−3
—
2.701 × 10−2
—
1.882 × 10−3
—
1.215
8
1.083 × 10−3
8.81
5.937 × 10−3
4.55
1.361 × 10−4
13.8
1.477
16
1.310
× 10−4
8.27
1.382 ×
10−3
4.30
1.118 ×
10−5
12.2
2.183
32
2.519 × 10−5
5.20
3.974 × 10−4
3.48
1.949 × 10−6
5.74
4.765
64
× 10−5
2.27
2.068 ×
1.92
8.366 ×
2.33
22.70
1.111
10−4
10−7
Increasing σ clearly erodes the order of convergence, since the largest elements are effectively dominating in the error bounds. As N increases, the superconvergence of the nodal errors accordingly vanishes,
bringing the nodal ratio into line with the L2 ratio. An analysis of this phenomenon is beyond the scope
of the course. 2
MATH3475 Prof. M A Kelmanson
Exs 3
104
(MATH5476M) MATH3475: (Advanced) Modern Numerical Methods
Example Sheet 3 (Prof Kelmanson)
Finite Element Methods for 1-D BVPs
The following questions are based upon the material covered in Lectures 8 to 13.
Equation numbers refer to those in the course notes.
Q1 Consider the 2-point DD BVP
−u′′ + u′ = x
x ∈ (0, 1)
u(0) = 0
u(1) = 1 .
(i) Solve the BVP to obtain the exact solution,
1
u(x) = x +
2
ex − 1
x −
e−1
2
.
(ii) You are to compute the approximate solution of the BVP using a piecewise-linear Galerkin FEM
with N = 3 uniform elements in [0, 1]. Show that (1.73) here gives an elemental contribution of
2
X
j=1
uj
Z
0
1
3
dNi
+ Ni
dξ
1
dNj
dξ ≍
dξ
3
Z
1
x1 +
0
ξ
3
Ni dξ
i = 1, 2 ,
in which the Ni (ξ) are the piecewise-linear basis functions defined in (1.65) and x1 is the left-hand
element-endpoint in global coordinates.
(iii) Using the formula in (ii), follow the procedure of Example 1.15 to show that the assembled system
of equations for the unknown nodal values u1 and u2 is
!
!
u1
6 − 25
− 72
6
u2
=
1
9
49
18
!
.
(iv) Solve the system in (iii) and use the exact solution in (i) to evaluate the nodal errors. Hence
e3 ||∞ ≈ 5.502 × 10−4 . You are given that ||u − u
e6 ||∞ ≈
show that the maximum nodal error is ||u − u
1.365 × 10−4 . Is there any evidence of the superconvergence of nodal values witnessed in the quadraticelement Galerkin FEM in Example 1.19?
(v) You are given that the L2 and energy error norms of the approximate solution calculated above are
respectively ||u − u
e3 ||0 ≈ 5.555 × 10−3 and ||u − u
e3 ||1 ≈ 5.026 × 10−2 . You are also given that
||u − u
e6 ||0 ≈ 1.397 × 10−3 and ||u − u
e6 ||1 ≈ 2.505 × 10−2 . What does this tell you about the orders of
convergence of the piecewise-linear Galerkin FEM in the two norms? Are your answers consistent with
the predictions (1.102) and (1.106)?
MATH3475 Prof. M A Kelmanson
Exs 3
105
Q2 For the DD BVP
−u′′ = 1 + x
x ∈ (0, 1)
u(0) = 2
u(1) = 1 ,
both (1.40) and Example 1.10 yield the energy functional
Z 1
E[u] =
u′2 − 2(1 + x)u dx .
0
(i) Using the piecewise-linear Rayleigh-Ritz FEM of §1.4.4 with N = 3 uniform elements in [0, 1],
follow the procedure of Example 1.16 to deduce that the functional on element e(i) ≡ [x1 , x2 ] (in local
coordinates) is
10
u1 − 13 x1 + 11
Ei (u1 , u2 ) = 3(u2 − u1 )2 − 31 x1 + 27
27 u2 .
(ii) By taking suitable partial derivatives of the result in (i), show that the assembled matrix for the
minimisation condition is
!
!
!
116
u1
12 −6
9
= 64
.
u2
−6 12
9
(iii) Solve the equations in (ii), and use the exact solution u(x) = 2 − 61 x(x + 1)(x + 2) to evaluate u
e3 ||∞ . Explain your result.
at the nodes, and hence compute the maximum nodal error ||u − u
Q3 An approximate solution of the DD BVP of Q1 is sought using a piecewise-quadratic Galerkin FEM
with N = 2 uniform elements in [0, 1], i.e. a single, three-node, quadratic element.
(i) Show that (1.91) here gives the single elemental contribution of
Z 1
Z
3
X
dNj
dN2
1 1
uj
2
+ N2
dξ ≍
(1 + ξ) N2 dξ ,
dξ
dξ
4 −1
−1
j=1
in which the Ni (ξ) are the piecewise-quadratic basis functions in (1.89) and, from (1.88), ξ = 2x − 1.
(ii) Perform the integrations in (i) to show that the equation for u1 , the approximation to u( 12 ), is
16
1
10
e2 ||∞ ≈ 1.27 × 10−3 .
3 u1 = 3 + 3 u0 + 2u2 , and so show that ||u − u
e4 ||∞ ≈ 9.78 × 10−5 . What is the order of convergence of the maximum
(iii) You are given that ||u − u
nodal error? Is this consistent with the L2 -norm prediction (1.101)? What phenomenon is being observed
here?
Hints, comments and quick-check answers to numerical questions
R
A1 (i) Show that x2 e−x dx = −e−x (x2 + 2x + 2). (ii) Convert (1.73) from x to ξ coordinates. (iii)
602
u1 = 269
981 and u2 = 981 .
A2 (i) First convert from x ∈ [x1 , x2 ] to ξ ∈ [0, 1]. (ii) Recall that the BCs u0 and u3 respectively
appear in E1,2 and E3,1 , and should be taken to the RHS in the matrix assembly. (iii) Consider (1.97) in
the notes.
R1
A3 (i) Recall that only i = 2 is used when N = 2. (ii) Note that −1 ξ n dξ = 0 when n is odd and
R1
2
when n is even.
2 0 ξ n dξ = n+1
MATH3475 Prof. M A Kelmanson
L14/HO
45
2 Example 1.21 GLQ weights and abscissae
The first five Legendre polynomials are
P0 (x) = 1 P1 (x) = x
1
P2 (x) = (3x2 −1)
2
P3 (x) =
1
(5x3 −3x)
2
1
P4 (x) = (35x4 −30x2 +3) .
8
In the following table, the abscissae are obtained from (1.115) as the roots of Pn (x) for n = 2(1)6,
and the weights are then computed using (1.116). Although explicit algebraic forms can be obtained for
these, they are presented in the form of double-precision data suitable for use in numerical computations.
Unlike the trapezoidal rule and Simpson’s rule, interval endpoints are not included in the abscissae, making GLQ an open quadrature rule.
j
1
2
n=2
x2,j
w2,j
-0.5773502691896258
1.000000000000000
0.5773502691896258
1.000000000000000
j
1
2
3
n=3
x3,j
w3,j
-0.7745966692414834 0.5555555555555556
0.0000000000000000 0.8888888888888889
0.7745966692414834 0.5555555555555556
n=4
j
1
2
3
4
x4,j
-0.8611363115940526
-0.3399810435848563
0.3399810435848563
0.8611363115940526
w4,j
0.3478548451374539
0.6521451548625461
0.6521451548625461
0.3478548451374539
n=5
j
1
2
3
4
5
x5,j
-0.9061798459386640
-0.5384693101056831
0.0000000000000000
0.5384693101056831
0.9061798459386640
w5,j
0.2369268850561891
0.4786286704993665
0.5688888888888889
0.4786286704993665
0.2369268850561891
n=6
j
1
2
3
4
5
6
x6,j
-0.9324695142031520
-0.6612093864662645
-0.2386191860831969
0.2386191860831969
0.6612093864662645
0.9324695142031520
w6,j
0.1713244923791703
0.3607615730481386
0.4679139345726910
0.4679139345726910
0.3607615730481386
0.1713244923791703
Such data need be computed only once then stored for subsequent multiple use. 2
MATH3475 Prof. M A Kelmanson
L14/HO
49
✷ Example 1.22 Exponential error decay
The exponential error decay of (1.120) is demonstrated on the test integral
Z π
sin X dX = 2 .
0
By the transformation (1.110),
I(f ) =
π
2
Z
1
sin
−1
Z
πx π 1
dx ,
(1 + x) dx =
cos
2
2 −1
2
π
the latter of which is approximated by GLQ in Maple worksheet 3475 5.mws for n = 2(1)6. Because of the infinite differentiability of the integrand, we expect GLQ to perform well. The following
results are obtained. The table columns are, from left to right, the: true numerical error, En (f ); ratio of
successive errors, En (f )/En+1 (f ) ; error bound (1.118), and; asymptotic error bound (1.120).
n
2
3
4
5
6
En (f )
6.418 × 10−2
Ratio
Equation (1.118)
Equation (1.120)
—
7.084 × 10−2
7.824 × 10−2
1.676 × 10−5
1.772 × 10−5
1.389 × 10−3
46.2
1.103 × 10−7
143
1.577 × 10−5
88.1
5.227 × 10−10
211
1.498 × 10−3
1.161 × 10−7
5.462 × 10−10
1.609 × 10−3
1.215 × 10−7
5.676 × 10−10
The results clearly demonstrate the exponential order of convergence of the error predicted by (1.120):
doubling n from 2 to 4 reduces the error by a factor of ≈ 46 × 88 ≈ 4000, and doubling n from 3 to
6 reduces the error by a factor of ≈ 88 × 143 × 211 ≈ 2, 600, 000. These doubling ratios should be
compared with the 4 of the trapezoidal rule and 16 of Simpson’s rule.
π 2n+1
πx π
, so that f (2n) ∞ =
is used in the error bounds. It is
For this example, f (x) = cos
2
2
2
clear from the above results that the predicted bounds agree well with the true numerical error.
It is only fair to point out that this remarkable efficiency is highly sensitive to the differentiability of the
integrand, and erodes considerably when there is a weak singularity or discontinuity in [a, b].
This example is automated in Maple worksheet 3475 5.mws. ✷
MATH3475 Prof. M A Kelmanson
Exs 4
106
(MATH5476M) MATH3475: (Advanced) Modern Numerical Methods
Example Sheet 4 (Prof Kelmanson)
Gauss-Legendre Quadrature
The following questions are based upon the material covered in Lecture 14.
Equation numbers refer to those in the course notes.
Q1 (i) Using the Legendre polynomials P2 (x) = 21 (3x2 − 1) and P3 (x) = 21 (5x3 − 3x), use n = 2 in
(1.115) and (1.116) to derive (1.113),
I2 (f ) = f − √13 + f √13 .
(ii) Using the Legendre polynomials P3 (x) = 21 (5x3 − 3x) and P4 (x) = 81 (35x4 − 30x2 + 3), use n = 3
in (1.115) and (1.116) to derive
I3 (f ) =
q q
5 8
5 3
f − 35 + f (0) + f
5 ,
9
9
9
and state the degree of the polynomial exactly integrated by this formula.
Q2 (i) Using (1.1.3), rescale the integral I ≡
R1
I(f ) ≡ −1 f (x) dx. Hence deduce that
(2n) f
∞
=
R1
0
eX dX into one on [−1, 1] and so determine f (x) in
e
1
||f ||∞ = 2n+1 .
2n
2
2
(ii) Show that the formulae for I2 (f ) and I3 (f ) derived in Q1 respectively lead to errors |E2 (f )| ≈
3.854 × 10−4 and |E3 (f )| ≈ 8.241 × 10−7 in I(f ).
(iii) Using the asymptotic formula (1.119) and the information from part (i), derive the Gauss-Legendre
error bound
|En (f )| ≤
πe
,
24n+1 (2n)!
and compute the bound for n = 2 and n = 3 in order to compare with the true errors found in (ii).
Hints, comments and quick-check answers to numerical questions
A2 (ii) The error decreases by a factor of ≈ 47 simply by increasing n from 2 to 3. (iii) The asymptotic
estimate is surprisingly good even for low values of n.
© Copyright 2026 Paperzz