math 428: algorithms and numerical solutions of...

Post on 27-Apr-2020

7 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Math 428:Algorithms and Numerical Solutions

ofDifferential Equations

L. F. Rossi

rossi@math.udel.edu

University of Delaware

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.1/30

Part 0: Course logistics

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.2/30

Course overview and syllabus

Description

Objectives

Resources

Grading

Exams, homework, projects, etc.

A word on student conduct...

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.3/30

Course overview and syllabus

Description... Scientific computation can be studied abstractly, andit can be practiced by professionals to solve problems.This course emphasizes both in equal parts. ...

Objectives

Resources

Grading

Exams, homework, projects, etc.

A word on student conduct...

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.3/30

Course overview and syllabus

Description

Objectives

Resources

Grading

Exams, homework, projects, etc.

A word on student conduct...

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.3/30

Course overview and syllabus

Description

Objectives

Resources→ Time, textbook, office hours, etc.

Grading

Exams, homework, projects, etc.

A word on student conduct...

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.3/30

Course overview and syllabus

Description

Objectives

Resources

Grading→ Straight scale

Exams, homework, projects, etc.

A word on student conduct...

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.3/30

Course overview and syllabus

Description

Objectives

Resources

Grading

Exams, homework, projects, etc.

A word on student conduct...

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.3/30

Course overview and syllabus

Description

Objectives

Resources

Grading

Exams, homework, projects, etc.

A word on student conduct...

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.3/30

Part 1: Essentials

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.4/30

Essentials - Taylor’s theorem (1D)

Taylor’s theorem is the first (and often best) tool to locallyanalyze an approximation. (See KC, pp 6-9 for a primer.)Theorem (Taylor):If f ∈ Cn+1([a, b]), then for any points x and x + h in theinterval [a, b],

f(x + h) =n∑

k=0

1

k!f (k)(x)hk +

1

(n + 1)!f (n+1)(ξ)hn+1

where ξ lies between x and x+h. The latter term, called the

remainder, often corresponds to the error in some approxi-

mate scheme.

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.5/30

Taylor’s theorem (n-D)

Theorem (Taylor):If f ∈ Cn+1(D), then for any points ~x = [x1, x2, . . . xm]T and~x + ~h in a region D ∈ Rm containing the line segment from ~x

to ~x + ~h,

f(~x + ~h) =

n∑

k=0

1

k!

|~i|=k

∂kf

∂xi11 ∂xi2

2 . . . ∂ximm

(~x)hi11 hi2

2 . . . himm +

1

(n + 1)!

|~i|=n+1

∂n+1f

∂xi11 ∂xi2

2 . . . ∂ximm

(~ξ)hi11 hi2

2 . . . himm

where ~ξ lies between ~x and ~x + ~h, and~i is a multi-index.Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.6/30

Taylor’s theorem (n-D)

D

x

x+h

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.6/30

Taylor’s theorem (n-D)

For example, consider a first order approximation in 3dimensions.

f(~x + ~h) =

f(~x) +∂f

∂x1(~x)h1 +

∂f

∂x2(~x)h2 +

∂f

∂x3(~x)h3+

1

2

∂2f

∂x21

(~ξ)h21 +

1

2

∂2f

∂x22

(~ξ)h22 +

1

2

∂2f

∂x23

(~ξ)h23+

∂2f

∂x1∂x2(~ξ)h1h2 +

∂2f

∂x2∂x3(~ξ)h2h3 +

∂2f

∂x1∂x3(~ξ)h1h3

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.6/30

Part 2: Numerical quadrature

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.7/30

A naive look at numerical quadrature

Suppose we would like to compute the area under thecurve of some function f(x) on the interval [a, b].Remember, midpoint rule from calculus...

∫ b

a

f(x)dx ≈N∑

i=1

f

(xi+1 + xi

2

)h

x2 x3 x4 x(N+1) = bx1 = a

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.8/30

A naive look at numerical quadrature

Suppose we would like to compute the area under thecurve of some function f(x) on the interval [a, b].Remember, midpoint rule from calculus...

∫ b

a

f(x)dx ≈N∑

i=1

f

(xi+1 + xi

2

)h

∫ b

a

f(x)dx =N∑

i=1

∫ xi+1

xi

f(x)dx

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.8/30

A naive look at numerical quadrature

Suppose we would like to compute the area under thecurve of some function f(x) on the interval [a, b].Remember, midpoint rule from calculus...

∫ b

a

f(x)dx ≈N∑

i=1

f

(xi+1 + xi

2

)h

∫ b

a

f(x)dx =N∑

i=1

∫ xi+1

xi

{f

(xi+1 + xi

2

)+

f ′

(xi+1 + xi

2

) (x −

xi+1 + xi

2

)+

1

2f ′′(ξi)

(x −

xi+1 + xi

2

)2}

dx

Note: ξi depends upon x, the variable of integration.Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.8/30

A naive look at numerical quadrature

Suppose we would like to compute the area under thecurve of some function f(x) on the interval [a, b].Remember, midpoint rule from calculus...

∫ b

a

f(x)dx ≈N∑

i=1

f

(xi+1 + xi

2

)h

∫ b

a

f(x)dx =N∑

i=1

∫ xi+1

xi

{f

(xi+1 + xi

2

)+

f ′

(xi+1 + xi

2

) (x −

xi+1 + xi

2

)+

1

2f ′′(ξi)

(x −

xi+1 + xi

2

)2}

dx

Note: ξi depends upon x, the variable of integration.Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.8/30

A naive look at numerical quadrature

Suppose we would like to compute the area under thecurve of some function f(x) on the interval [a, b].Remember, midpoint rule from calculus...Let’s remember why that red term is zero. This will be avery common theme in this course.

∫ xi+1

xi

f ′

(xi+1 + xi

2

) (x −

xi+1 + xi

2

)dx =

f ′

(xi+1 + xi

2

) ∫ xi+1

xi

(x −

xi+1 + xi

2

)dx =

f ′

(xi+1 + xi

2

)· 0 = 0

� � � � � � � � � � � �

� � � � � � � � � � � �

� � � � � � � � � � � �

� � � � � � � � � � � �

� � � � � � � � � � � �

� � � � � � � � � � � �

� � � � � � � � � � � �

� � � � � � � � � � � �

� � � � � � � � � � � �

� � � � � � � � � � � �

� � � � � � � � � � � �

� � � � � � � � � � � �

� � � � � � � � � � � �

� � � � � � � � � � � �

� � � � � � � � � � � �

� � � � � � � � � � � �

� � � � � � � � � � � �

� � � � � � � � � � � �

� � � � � � � � � � � �

� � � � � � � � � � � �

� � � � � � � � � � � �

� � � � � � � � � � � �

� � � � � � � � � � � �

� � � � � � � � � � � �

x(i) x(i+1)x(i+1/2)

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.8/30

A naive look at numerical quadrature

Suppose we would like to compute the area under thecurve of some function f(x) on the interval [a, b].Remember, midpoint rule from calculus...And, this is true for any odd function of a symmetric interval.

For instance...∫ xi+1

xi

(x −

xi+1 + xi

2

)3

dx = 0

� � � � � � � � � � �

� � � � � � � � � � �

� � � � � � � � � � �

� � � � � � � � � � �

� � � � � � � � � � �

� � � � � � � � � � �

� � � � � � � � � � �

� � � � � � � � � � �

� � � � � � � � � � �

� � � � � � � � � � �

� � � � � � � � � � �

� � � � � � � � � � �

� � � � � � � � � � �

� � � � � � � � � � �

� � � � � � � � � � �

� � � � � � � � � � �

� � � � � � � � � � �

� � � � � � � � � � �

� � � � � � � � � � �

� � � � � � � � � � �

� � � � � � � � � � �

� � � � � � � � � � �

x(i) x(i+1)x(i+1/2)

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.8/30

A naive look at numerical quadrature

Suppose we would like to compute the area under thecurve of some function f(x) on the interval [a, b].Remember, midpoint rule from calculus...

∫ b

a

f(x)dx =N∑

i=1

f

(xi+1 + xi

2

)h+

N∑

i=1

∫ xi+1

xi

1

2f ′′(ξi)

(x −

xi+1 + xi

2

)2

dx

Note: ξi depends upon x, the variable of integration.

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.8/30

A naive look at numerical quadrature

Suppose we would like to compute the area under thecurve of some function f(x) on the interval [a, b].Remember, midpoint rule from calculus...

∫ b

a

f(x)dx −N∑

i=1

f

(xi+1 + xi

2

)h =

N∑

i=1

∫ xi+1

xi

1

2f ′′(ξi)

(x −

xi+1 + xi

2

)2

dx

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.8/30

A naive look at numerical quadrature

Suppose we would like to compute the area under thecurve of some function f(x) on the interval [a, b].Remember, midpoint rule from calculus...

∣∣∣∣∣

∫ b

a

f(x)dx −N∑

i=1

f

(xi+1 + xi

2

)h

∣∣∣∣∣ =

∣∣∣∣∣

N∑

i=1

∫ xi+1

xi

1

2f ′′(ξi)

(x −

xi+1 + xi

2

)2

dx

∣∣∣∣∣

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.8/30

A naive look at numerical quadrature

Suppose we would like to compute the area under thecurve of some function f(x) on the interval [a, b].Remember, midpoint rule from calculus...

∣∣∣∣∣

∫ b

a

f(x)dx −N∑

i=1

f

(xi+1 + xi

2

)h

∣∣∣∣∣≤

1

2

N∑

i=1

∫ xi+1

xi

∣∣∣∣∣f′′(ξi)

(x −

xi+1 + xi

2

)2∣∣∣∣∣ dx

This is nothing more than the triangle inequality applied tothe sum and the integral.

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.8/30

A naive look at numerical quadrature

Suppose we would like to compute the area under thecurve of some function f(x) on the interval [a, b].Remember, midpoint rule from calculus...

∣∣∣∣∣

∫ b

a

f(x)dx −N∑

i=1

f

(xi+1 + xi

2

)h

∣∣∣∣∣ ≤

1

2

N∑

i=1

∫ xi+1

xi

∣∣f ′′(ξi)∣∣∣∣∣∣∣

(x −

xi+1 + xi

2

)2∣∣∣∣∣ dx

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.8/30

A naive look at numerical quadrature

Suppose we would like to compute the area under thecurve of some function f(x) on the interval [a, b].Remember, midpoint rule from calculus...

∣∣∣∣∣

∫ b

a

f(x)dx −N∑

i=1

f

(xi+1 + xi

2

)h

∣∣∣∣∣ ≤

M

2

N∑

i=1

∫ xi+1

xi

(x −

xi+1 + xi

2

)2

dx

where |f ′′(ξ)| ≤ M for all ξ ∈ [a, b].

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.8/30

A naive look at numerical quadrature

Suppose we would like to compute the area under thecurve of some function f(x) on the interval [a, b].Remember, midpoint rule from calculus...

∣∣∣∣∣

∫ b

a

f(x)dx −N∑

i=1

f

(xi+1 + xi

2

)h

∣∣∣∣∣ ≤M

2

N∑

i=1

h3

12

where |f ′′(ξ)| ≤ M for all ξ ∈ [a, b]. Remember, h = b−aN or

N = b−ah .

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.8/30

A naive look at numerical quadrature

Suppose we would like to compute the area under thecurve of some function f(x) on the interval [a, b].Remember, midpoint rule from calculus...

∣∣∣∣∣

∫ b

a

f(x)dx −N∑

i=1

f

(xi+1 + xi

2

)h

∣∣∣∣∣ ≤Mh2(b − a)

24=

M(b − a)3

24N2

where |f ′′(ξ)| ≤ M for all ξ ∈ [a, b].Thus, this is a crude, O(N2), method.

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.8/30

An example using Matlab

We would like to accurately compute

∫ 2

1

1

xdx.

Define the function in Matlab (in a simple file calledmidptf.m).function y = midptf(x)y = 1/x;

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.9/30

An example using Matlab (cont’d)

>> x = linspace(1,2,200);>> plot(x,midptf(x));

1 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 20.5

0.55

0.6

0.65

0.7

0.75

0.8

0.85

0.9

0.95

1

Looks good! Let’s try the midpoint rule.

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.10/30

An example using Matlab (cont’d)

1 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 20.5

0.55

0.6

0.65

0.7

0.75

0.8

0.85

0.9

0.95

1

Remember, we expect to pick up one digit of accuracy forevery factor of 10 decrease in h2. We know the exactanswer, ln 2, but in practice we would not. However, bychoosing h really, really small, we would have a goodapproximation that we could use for a refinement study.

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.10/30

An example using Matlab (cont’d)

N Error

5 0.0012393>> x = linspace(1,2,6);>> m5 = sum(midptf((x(1:5)+x(2:6))/2))* ...(x(2)-x(1));>> log(2)-m5

ans =

1.239294844010197e-03

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.11/30

An example using Matlab (cont’d)

N Error

5 0.001239310 0.0003118>> x = linspace(1,2,11);>> m10 = sum(midptf((x(1:10)+x(2:11))/2))* ...(x(2)-x(1));>> log(2)-m10

ans =

3.118201499844320e-04

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.12/30

An example using Matlab (cont’d)

N Error

5 0.001239310 0.000311820 0.0000781>> x = linspace(1,2,21);>> m20 = sum(midptf((x(1:20)+x(2:21))/2))* ...(x(2)-x(1));>> log(2) - m20

ans =

7.808233435779854e-05

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.13/30

Another way to look the midpoint rule

Consider that there are really two functions. One functionf(x) is a function of a continuous variable x ∈ [a, b]. Theother, f̂(x̂), is a discrete function of discrete variable,x̂ ∈ {x1, x2, . . . , xn}. Moving from one space to another iscalled restriction and prolongation.

x1 x2 x3 x4

x

restriction

Restriction can be defined explicitly in many settings.Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.14/30

Another way to look the midpoint rule

Consider that there are really two functions. One functionf(x) is a function of a continuous variable x ∈ [a, b]. Theother, f̂(x̂), is a discrete function of discrete variable,x̂ ∈ {x1, x2, . . . , xn}. Moving from one space to another iscalled restriction and prolongation.

x1 x2 x3 x4

x

prolongation

Notice that prolongation is not so easy to define.Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.14/30

Another way to look the midpoint rule

x1 x2 x3 x4

x

prolongation

Notice that prolongation is not so easy to define.The midpoint rule uses piecewise constant functions toprolong the discrete function f̂ . The resulting integral is theexact integral of this prolongation.

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.14/30

Making better methods...

Now that we understand the midpoint rule so well, let’s tryto improve it using our error analysis. If MN is the midpointquadrature using N panels or intervals, we know how toestimate the error over one interval.

∣∣∣∣∫ xi+1

xi

f(x)dx − f(xi+ 1

2

)h

∣∣∣∣ ≤|f ′′(ξ)|h3

24

where ξ ∈ [xi, xi+1] and xi+ 1

2

= xi+xi+1

2 . But, with an eyetoward improvement, let’s not bound things right away.Rather, let’s keep an extra terms from the Taylor series.

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.15/30

Making better methods...

Now that we understand the midpoint rule so well, let’s tryto improve it using our error analysis. If MN is the midpointquadrature using N panels or intervals, we know how toestimate the error over one interval.

∫ xi+1

xi

f(x)dx − f(xi+ 1

2

)h =

∫ xi+1

xi

[f ′(xi+ 1

2

)(x − xi+ 1

2

) +1

2f ′′(xi+ 1

2

)(x − xi+ 1

2

)2+

1

3!f ′′′(xi+ 1

2

)(x − xi+ 1

2

)3 +1

4!f (iv)(ξ)(x − xi+ 1

2

)4]

dx

The two red terms are zero (why?).

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.15/30

Making better methods...

Now that we understand the midpoint rule so well, let’s tryto improve it using our error analysis. If MN is the midpointquadrature using N panels or intervals, we know how toestimate the error over one interval.

∫ xi+1

xi

f(x)dx − f(xi+ 1

2

)h =

∫ xi+1

xi

[1

2f ′′(xi+ 1

2

)(x − xi+ 1

2

)2 +1

4!f (iv)(ξ)(x − xi+ 1

2

)4]

dx

Remember that the ξ depends upon the variable ofintegration, x, so we cannot evaluate the integral of the lastterm.

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.15/30

Making better methods...

Now that we understand the midpoint rule so well, let’s tryto improve it using our error analysis. If MN is the midpointquadrature using N panels or intervals, we know how toestimate the error over one interval.

∫ xi+1

xi

f(x)dx − f(xi+ 1

2

)h =

1

24f ′′(xi+ 1

2

)h3 +1

4!

∫ xi+1

xi

f (iv)(ξ)(x − xi+ 1

2

)4dx

Remember that the ξ depends upon the variable ofintegration, x. Here, we must stop now that we haveidentified an specific error term that we wish to eliminate.

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.15/30

Aside: Big O notation

Often in mathematics, we are interested in the generalbehavior of a quantity with respect to a variable, but thespecifics to not matter. For instance, the error terms 5h2

and 10h2 mean almost the same thing. Though the firstterm is smaller than the second, both errors refer toquadratic convergence. We introduce a new notation O(h2)to describe both terms.

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.16/30

Aside: Big O notation

Definition (Big O):The expression O(hp) (said “big oh of h to the p”) is definedas follows.

f(h) = g(h) + O(hp)

means that|f(h) − g(h)| ≤ Chp

for all h and some fixed p where the constant C does notdepend on h.

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.16/30

Aside: Big O notation

Definition (Big O):The expression O(hp) (said “big oh of h to the p”) is definedas follows.

f(h) = g(h) + O(hp)

means that|f(h) − g(h)| ≤ Chp

for all h and some fixed p where the constant C does notdepend on h.Example (Big O example 1):From Taylor’s Theorem, we know that

f(x + h) = f(x) + O(h).

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.16/30

Aside: Big O notation

Definition (Big O):The expression O(hp) (said “big oh of h to the p”) is definedas follows.

f(h) = g(h) + O(hp)

means that|f(h) − g(h)| ≤ Chp

for all h and some fixed p where the constant C does notdepend on h.Example (Big O example 2):From Taylor’s Theorem, we also know that

f(x + h) = f(x) + f ′(x)h + O(h2).

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.16/30

Making better methods (cont’d)...

Midpoint rule leading order error:

∫ xi+1

xi

f(x)dx − f(xi+ 1

2

)h =

1

24f ′′(xi+ 1

2

)h3+C

∫ xi+1

xi

f (iv)(ξ)(x−xi+ 1

2

)4dx � � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

xi x(i+1)

It can be shown that for trapezoid rule:

∫ xi+1

xi

f(x)dx −

[1

2f(xi) +

1

2f(xi+1)

]h =

−1

12f ′′(xi+ 1

2

)h3+D

∫ xi+1

xi

f (iv)(ξ)(x−xi+ 1

2

)4dx � � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

xi x(i+1)

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.17/30

Making better methods (cont’d)...

Midpoint rule leading order error:

∫ xi+1

xi

f(x)dx − f(xi+ 1

2

)h =

1

24f ′′(xi+ 1

2

)h3 + O(h5)

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

xi x(i+1)

It can be shown that for trapezoid rule:

∫ xi+1

xi

f(x)dx −

[1

2f(xi) +

1

2f(xi+1)

]h =

−1

12f ′′(xi+ 1

2

)h3 + O(h5) � � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

xi x(i+1)

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.17/30

Making better methods (cont’d)...

Midpoint rule leading order error:

∫ xi+1

xi

f(x)dx − f(xi+ 1

2

)h =

1

24f ′′(xi+ 1

2

)h3 + O(h5)

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

xi x(i+1)

It can be shown that for trapezoid rule:

∫ xi+1

xi

f(x)dx −

[1

2f(xi) +

1

2f(xi+1)

]h =

−1

12f ′′(xi+ 1

2

)h3 + O(h5) � � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

xi x(i+1)

How can we use this information to develop a bettermethod? Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.17/30

Making better methods (cont’d)...

Midpoint rule leading order error:

∫ xi+1

xi

f(x)dx − f(xi+ 1

2

)h =

1

24f ′′(xi+ 1

2

)h3 + O(h5)

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

xi x(i+1)

It can be shown that for trapezoid rule:

∫ xi+1

xi

f(x)dx −

[1

2f(xi) +

1

2f(xi+1)

]h =

−1

12f ′′(xi+ 1

2

)h3 + O(h5) � � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

xi x(i+1)

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.17/30

Simpson’s Rule

Eliminate the leading error terms from midpoint andtrapezoidal rule because they are two comparable O(h2)methods.

1

3

{3

∫ xi+1

xi

f(x)dx − 2f(xi+ 1

2

)h −

[1

2f(xi) +

1

2f(xi+1)

]h

}=

1

3

[2

1

24f ′′(xi+ 1

2

)h3 −1

12f ′′(xi+ 1

2

)h3

]+ O(h5)

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.18/30

Simpson’s Rule

Eliminate the leading error terms from midpoint andtrapezoidal rule because they are two comparable O(h2)methods.

∫ xi+1

xi

f(x)dx−2

3f(xi+ 1

2

)h−

[1

6f(xi) +

1

6f(xi+1)

]h = O(h5)

Or, if MN is the midpoint rule, TN is the trapezoid rule andSN is Simpson’s rule, then

SN =2

3MN +

1

3TN .

The global accuracy of this quadrature is O(h4) becausewe must add up N = O(h−1) errors.

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.18/30

Simpson’s Rule

Or, if MN is the midpoint rule, TN is the trapezoid rule andSN is Simpson’s rule, then

SN =2

3MN +

1

3TN .

Note: Simpson’s rule is often written with double panels,treating the midpoint and the endpoints of each panel as aseparate mesh point. This effectively doubles N .

∫ b

a

f(x)dx ≈

h

6[f(x1) + 4f(x2) + 2f(x3) + 4f(x4) + 2f(x5) + . . . + f(xN+1)]

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.18/30

A matlab interlude...

Consider that nasty old integral

∫ 1

1

10

cos(

ln xx

)

xdx.

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.19/30

A matlab interlude...

Consider that nasty old integral

∫ 1

1

10

cos(

ln xx

)

xdx.

N MN M2N −MN TN T2N − TN SN S2N − SN

100 2.8664e-01 8.8986e-03 3.1909e-01 -1.6223e-03 2.9746e-01 5.2458e-04

200 2.9554e-01 1.8820e-03 3.0286e-01 -3.6624e-03 2.9798e-01 3.3855e-05

400 2.9742e-01 4.4824e-04 2.9920e-01 -8.9022e-04 2.9801e-01 2.0871e-06

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.19/30

Simpson’s rule: Another perspective.

One can also derive Simpson’s rule by usingthree points per panel to interpolate f(x) witha parabola, p(x). The Simpson’s rule approxi-mation is the area under the parabola.

� � � � � � � � � � �

� � � � � � � � � � �

� � � � � � � � � � �

� � � � � � � � � � �

� � � � � � � � � � �

� � � � � � � � � � �

� � � � � � � � � � �

� � � � � � � � � � �

� � � � � � � � � � �

� � � � � � � � � � �

� � � � � � � � � � �

� � � � � � � � � � �

� � � � � � � � � � �

� � � � � � � � � � �

� � � � � � � � � � �

� � � � � � � � � � �

� � � � � � � � � � �

� � � � � � � � � � �

� � � � � � � � � � �

� � � � � � � � � � �

� � � � � � � � � � �

� � � � � � � � � � �

� � � � � � � � � � �

� � � � � � � � � � �

� � � � � � � � � � �

� � � � � � � � � � �

� � � � � � � � � � �

� � � � � � � � � � �

� � � � � � � � � � �

� � � � � � � � � � �

� � � � � � � � � � �

� � � � � � � � � � �

x(i) x(i+1)x(i+1/2)

p(x) = f(xi)(x − xi+ 1

2

)(x − xi+1)

(xi − xi+ 1

2

)(xi − xi+1)+

f(xi+ 1

2

)(x − xi)(x − xi+1)

(xi+ 1

2

− xi)(xi+ 1

2

− xi+1)+

f(xi+1)(x − xi)(x − xi+ 1

2

)

(xi+1 − xi)(xi+1 − xi+ 1

2

).

This is Newton’s interpolating polynomial for these threedata points. We shall be seeing more of these.Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.20/30

A cruder way to gauge accuracy.

Assuming f(x) is continuously differentiable enough times,integrating f(x) is the same as integrating its Taylor series.Thus, you can judge a quadrature by how well it integratespolynomials.

The midpoint rule exactly integrates constant functionsand linear functions f(x) = c0 + c1x, so we conclude thatits accuracy is at least O(h2). We have seen that this istrue.

The same reasoning can be applied to the trapezoidrule.

Simpson’s rule will exactly integrate cubic polynomials,f(x) = c0 + c1x + c2x

2 + c3x3!

The downside of this approach is that it does not appear totell you the exact form of the leading error term...Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.21/30

A cruder way to gauge accuracy.

In fact, this is not true! For instance, we can study themidpoint rule by testing it against a quadratic.

p(x) = c0 + c1x +1

2c2x

2.

Written this way, c2, is the second derivative of my little testpolynomial.Also, we can simplify the problem a bit because know thatthe specific endpoints, [a, b], of the interval do not matter somuch as the length of the interval. So, we shall letL = b − a, and integrate on [0, L].The exact integral is easy to find.

∫ L

0p(x)dx = c0L + c1

L2

2+ c2

L3

6.

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.21/30

A cruder way to gauge accuracy.

∫ L

0p(x)dx = c0L + c1

L2

2+ c2

L3

6

Now, let’s see what the midpoint rule does and compare itto the exact integral.

MN = hN∑

i=1

p( xi+ 1

2

)

where h = LN and xi+ 1

2

= h(i − 1

2

)= L

N

(i − 1

2

).

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.21/30

A cruder way to gauge accuracy.

∫ L

0p(x)dx = c0L + c1

L2

2+ c2

L3

6

Now, let’s see what the midpoint rule does and compare itto the exact integral.

MN = hN∑

i=1

p( xi+ 1

2

)

where h = LN and xi+ 1

2

= h(i − 1

2

)= L

N

(i − 1

2

).

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.21/30

A cruder way to gauge accuracy.

∫ L

0p(x)dx = c0L + c1

L2

2+ c2

L3

6

Now, let’s see what the midpoint rule does and compare itto the exact integral.

MN = hN∑

i=1

p( xi+ 1

2

)

where h = LN and xi+ 1

2

= h(i − 1

2

)= L

N

(i − 1

2

).

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.21/30

A cruder way to gauge accuracy.

∫ L

0p(x)dx = c0L + c1

L2

2+ c2

L3

6

MN =L

N

N∑

i=1

[c0 + c1

L

N

(i −

1

2

)+

c2

2

(L

N

)2 (i −

1

2

)2]

=L

N

[N∑

i=1

c0 + c1L

N

N∑

i=1

(i −

1

2

)+

c2

2

(L

N

)2 N∑

i=1

(i −

1

2

)2]

=L

N

[c0N + c1

L

N

N∑

i=1

i − c1L

2+

c2

2

(L

N

)2 N∑

i=1

(i2 − i +

1

4

)]

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.21/30

A cruder way to gauge accuracy.

∫ L

0p(x)dx = c0L + c1

L2

2+ c2

L3

6

MN =L

N

[c0N + c1

L

N

N∑

i=1

i − c1L

2+

c2

2

(L

N

)2 N∑

i=1

(i2 − i +

1

4

)]

Recall,N∑

i=1

i =N(N + 1)

2.

Maple knows all these identities by the way...

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.21/30

A cruder way to gauge accuracy.

∫ L

0p(x)dx = c0L + c1

L2

2+ c2

L3

6

MN =L

N

[c0N + c1

L

N

N(N + 1)

2− c1

L

2+

c2

2

(L

N

)2 N∑

i=1

(i2 − i +

1

4

)]

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.21/30

Aside: Useful summation formulae.

N∑

i=1

i =N(N + 1)

2

N∑

i=1

i2 =

N(N + 1)(2N + 1)

6

N∑

i=1

i3 =

N2(N + 1)2

4

N∑

i=1

i4 =

N(N + 1)(2N + 1)(3N2 + 3N + 1)

30

Again, Maple can find these for you. Just ask:> simplify(sum(iˆ5,i=1..N));

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.22/30

A cruder way (cont’d)

∫ L

0p(x)dx = c0L + c1

L2

2+ c2

L3

6

MN =L

N

[c0N + c1

L

N

N(N + 1)

2− c1

L

2+

c2

2

(L

N

)2 N∑

i=1

(i2 − i +

1

4

)]

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.23/30

A cruder way (cont’d)

∫ L

0p(x)dx = c0L + c1

L2

2+ c2

L3

6

MN =L

N

[c0N + c1

LN

2+

c2

2

(L

N

)2 N∑

i=1

(i2 − i +

1

4

)]

= c0L + c1L2

2+

c2

2

(L

N

)3 N∑

i=1

(i2 − i +

1

4

)

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.23/30

A cruder way (cont’d)

∫ L

0p(x)dx = c0L + c1

L2

2+ c2

L3

6

MN = c0L + c1L2

2+

c2

2

(L

N

)3 N∑

i=1

(i2− i +

1

4

)

= c0L + c1L2

2+

c2

2

(L

N

)3 [N(N + 1)(2N + 1)

6−

N(N + 1)

2+

N

4

]

= c0L + c1L2

2+

c2

2

(L

N

)3 4N3−N

12

= c0L + c1L2

2+

c2L3

6−

c2L3

24N2

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.23/30

Summary: Accuracy of quadratures

We have discussed two methods of analyzing the accuracyof a given quadrature, IN .

Taylor expansion method.

Begin with∫ xi+1

xif(x)dx − IN .

Use Taylor’s theorem to expand f(x) to reproducethe quadrature at zeroth order.Integrate the remaining terms of the Taylor’s seriesuntil a nonzero term emerges.This nonzero term is the error over one panel.Sum the error over all panels to determine to totalerror.

Polynomial test function method.

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.24/30

Summary: Accuracy of quadratures

We have discussed two methods of analyzing the accuracyof a given quadrature, IN .

Taylor expansion method.

Polynomial test function method.

Insert a test polynomial of order q, p(x) =∑q

k=0ck

k!xk

into the quadrature.Compare the sum to the exact integral of thepolynomial.The first term that does not agree is the error. Theleading coefficient, cn, represents the dependenceon the nth derivative of the function being integrated.

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.24/30

Designing quadratures

So, it would seem that there are a lot of different ways todesign quadratures on a panel.

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

� � � � � �

x(i-1) x(i+2)x(i) x(i+1)

So, we can interpolate a function using a lot of points insidea panel or we can use outside points to interpolate afunction. No matter what we do, we must learn aboutpolynomial interpolation.

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.25/30

Designing quadratures

So, it would seem that there are a lot of different ways todesign quadratures on a panel.

� � � � � �� � � � � �� � � � � �� � � � � �� � � � � �� � � � � �� � � � � �� � � � � �� � � � � �� � � � � �� � � � � �� � � � � �� � � � � �

� � � � � �� � � � � �� � � � � �� � � � � �� � � � � �� � � � � �� � � � � �� � � � � �� � � � � �� � � � � �� � � � � �� � � � � �

x(i-1) x(i+2)x(i) x(i+1)

This quadrature would be called Q3,1 because we are usinga third order (cubic) quadrature (over four points), and weare integrating over one subinterval.

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.25/30

Designing quadratures

So, it would seem that there are a lot of different ways todesign quadratures on a panel.

x(i+1/3) x(i+1)

� � � � � � � � � � � � � � �

� � � � � � � � � � � � � � �

� � � � � � � � � � � � � � �

� � � � � � � � � � � � � � �

� � � � � � � � � � � � � � �

� � � � � � � � � � � � � � �

� � � � � � � � � � � � � � �

� � � � � � � � � � � � � � �

� � � � � � � � � � � � � � �

� � � � � � � � � � � � � � �

� � � � � � � � � � � � � � �

� � � � � � � � � � � � � � �

� � � � � � � � � � � � � � �

� � � � � � � � � � � � � � �

� � � � � � � � � � � � � � �

� � � � � � � � � � � � � � �

� � � � � � � � � � � � � � �

� � � � � � � � � � � � � � �

� � � � � � � � � � � � � � �

� � � � � � � � � � � � � � �

� � � � � � � � � � � � � � �

� � � � � � � � � � � � � � �

� � � � � � � � � � � � � � �

� � � � � � � � � � � � � � �

x(i) x(i+2/3)

This quadrature would be called Q3,3 because we are usinga third order quadrature (over four points), and we areintegrating over three subintervals.

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.25/30

Designing quadratures

So, it would seem that there are a lot of different ways todesign quadratures on a panel.

x(i+1/3) x(i+1)

� � � � � � � � � � � � � � �

� � � � � � � � � � � � � � �

� � � � � � � � � � � � � � �

� � � � � � � � � � � � � � �

� � � � � � � � � � � � � � �

� � � � � � � � � � � � � � �

� � � � � � � � � � � � � � �

� � � � � � � � � � � � � � �

� � � � � � � � � � � � � � �

� � � � � � � � � � � � � � �

� � � � � � � � � � � � � � �

� � � � � � � � � � � � � � �

� � � � � � � � � � � � � � �

� � � � � � � � � � � � � � �

� � � � � � � � � � � � � � �

� � � � � � � � � � � � � � �

� � � � � � � � � � � � � � �

� � � � � � � � � � � � � � �

� � � � � � � � � � � � � � �

� � � � � � � � � � � � � � �

� � � � � � � � � � � � � � �

� � � � � � � � � � � � � � �

� � � � � � � � � � � � � � �

� � � � � � � � � � � � � � �

x(i) x(i+2/3)

Generally, Qp,q, means we find a pth degree polynomialextending over p + 1 points, and integrate it over the inner qsubpanels. There is a whole “industry” dedicated todesigning these quadratures, but we will focus onNewton-Cotes quadratures which is when p = q.

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.25/30

Designing quadratures

So, it would seem that there are a lot of different ways todesign quadratures on a panel.

x(i+1/3) x(i+1)

� � � � � � � � � � � � � � � � �

� � � � � � � � � � � � � � � � �

� � � � � � � � � � � � � � � � �

� � � � � � � � � � � � � � � � �

� � � � � � � � � � � � � � � � �

� � � � � � � � � � � � � � � � �

� � � � � � � � � � � � � � � � �

� � � � � � � � � � � � � � � � �

� � � � � � � � � � � � � � � � �

� � � � � � � � � � � � � � � � �

� � � � � � � � � � � � � � � � �

� � � � � � � � � � � � � � � � �

� � � � � � � � � � � � � � � � �

� � � � � � � � � � � � � � � �

� � � � � � � � � � � � � � � �

� � � � � � � � � � � � � � � �

� � � � � � � � � � � � � � � �

� � � � � � � � � � � � � � � �

� � � � � � � � � � � � � � � �

� � � � � � � � � � � � � � � �

� � � � � � � � � � � � � � � �

� � � � � � � � � � � � � � � �

� � � � � � � � � � � � � � � �

� � � � � � � � � � � � � � � �

� � � � � � � � � � � � � � � �

x(i) x(i+2/3)

For instance, Q2,2 is Simpson’s rule. This quadrature isresults in a method,∫ xi+1

xi

f(x)dx ≈ h

[1

8f(xi) +

3

8f(xi+ 1

3

) +3

8f(xi+ 2

3

) +1

8f(xi+1)

],

also known as “Simpson’s 38 rule.”

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.25/30

Designing quadratures

General comments, offered without proof, on Newton-Cotesquadratures.

If n is even, Qn,n is O(nn+3).

If n is odd, Qn,n is O(nn+2).

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.25/30

Finding interpolating polynomials.

Given a set of n + 1 mesh points, we will discuss two waysto finding the interpolating polynomial of degree p.

Lagrange polynomials: Easy to manipulate theoretically.Tougher to actually compute.

Divided differences: Nasty to manipulate. Easier tocompute mechanically.

Another method which is less practical uses Vandermondematrices (see Ch. 6.1).

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.26/30

Lagrange polynomials

Given a set of n + 1 mesh points, there is a uniquepolynomial of degree n that passes each point (xi, f(xi)).One way to express this polynomial is to use Lagrange’sinterpolation formula.

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.27/30

Lagrange polynomials

Given a set of n + 1 mesh points, there is a uniquepolynomial of degree n that passes each point (xi, f(xi)).One way to express this polynomial is to use Lagrange’sinterpolation formula.

p(x) =

n+1∑

i=1

f(xi)li(x)

where

li(x) =∏

j 6=i

x − xj

xi − xj.

Notice, each li(x) has degree n, and p(x) passes througheach data point.

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.27/30

Lagrange polynomials

Consider an interpolation over the data points f(0) = 2,f(2) = 1, f(3) = −1 and f(4) = 1.For example,

l1 =(x − 2)(x − 3)(x − 4)

(−2)(−3)(−4)

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.27/30

Lagrange polynomials

Consider an interpolation over the data points f(0) = 2,f(2) = 1, f(3) = −1 and f(4) = 1.

0 1 2 3 4

x

−2

−1

0

1

2

3

4

y

l1

l2

l3

l4

p(x)

Example: Lagrange polynomials and interpolationsf(0) = 2, f(2) = 1, f(3) = −3, f(4) = 1

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.27/30

Lagrange polynomials

With remainder,

f(x) =

n+1∑

i=1

f(xi)li(x) +f (n+1)(ξ)

(n + 1)!

n+1∏

i=1

(x − xi)

where

li(x) =∏

j 6=i

x − xj

xi − xj

and ξ is somewhere on the interval [x1, xn+1].

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.27/30

Divided differences

Yet another way to think about interpolating polynomials isusing divided differences.Each divided difference approximates a derivative on themesh.

f [x1, x2] =f(x2) − f(x1)

x2 − x1.

This expression approximates the derivative of f on [x1, x2].Remember,

df

dx(x2) = lim

x2→x1

f(x2) − f(x1)

x2 − x1.

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.28/30

Divided differences

Yet another way to think about interpolating polynomials isusing divided differences.Each divided difference approximates a derivative on themesh.

f [x1, x2] =f(x2) − f(x1)

x2 − x1.

This expression approximates the derivative of f on [x1, x2].Similarly, a second derivative can be approximatedrecursively.

f [x1, x2, x3] =f [x2, x3] − f [x1, x2]

x3 − x1.

This is a difference of differences.

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.28/30

Divided differences

Yet another way to think about interpolating polynomials isusing divided differences.Each divided difference approximates a derivative on themesh.

f [x1, x2] =f(x2) − f(x1)

x2 − x1.

This expression approximates the derivative of f on [x1, x2].Similarly, a second derivative can be approximatedrecursively.

f [x1, x2, x3] =f [x2, x3] − f [x1, x2]

x3 − x1.

This is a difference of differences.

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.28/30

Divided differences

So, we can build a table of these differences.x1 f [x1]

f [x1, x2]

x2 f [x2] f [x1, x2, x3]

f [x2, x3]

x3 f [x3]

And, we can use such tables to express the interpolatingpolynomial,

p(x) = f [x1] + f [x1, x2](x − x1) + f [x1, x2, x3](x − x1)(x − x2).

See Chapter 6.2 for further discussion and an example.

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.28/30

Divided differences

Let’s try the example (again): f(0) = 2, f(2) = 1, f(3) = −1and f(4) = 1

0 2

−1/2

2 1 −1/2

−2 5/8

3 −1 2

2

4 1

And, we can use such tables to express the interpolatingpolynomial,

p(x) = 2 −1

2x −

1

2x(x − 2) +

5

8x(x − 2)(x − 3).

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.28/30

Gaussian quadrature

We have seen how one can design quadratures bychoosing mesh points and determining the “weights” foreach point based on interpolating polynomials. Thus, ageneral n-point quadrature over one panel has a form

I ≈ hn∑

i=1

αkf(xik).

For instance, for the midpoint rule, n = 1, xi1 = xi+ 1

2

, andα1 = 1. For the trapezoid rule, n = 2, xi1 = xi, xi2 = xi+1,α1 = 1

2 and α2 = 12 . The key point is that the quadrature

points are chosen, and the weights are computed.

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.29/30

Gaussian quadrature

Gauss proposed choosing both the mesh points and theweights so that one would have more degrees of freedomand therefore higher accuracy. For instance, a two-pointquadrature does not have to be the trapezoid rule. We canselect xi1 and xi2 to make the quadrature more accurate. If Ican choose the α’s and the xik ’s, I should get O(h2n)accuracy.

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.29/30

Gaussian quadrature in practice

This downside of Gaussian quadrature is solving thenonlinear equations for the weights and the quadraturepoints.Let us consider a very simple problem in general. Let ourpanel span [0, L], and let us suppose we want to use twopoints.

IG = L [A1f(α1L) + A2f(α2L)] .

We expect fourth order convergence, so we should be ableto match terms for the polynomial test function

p(x) = c0 + c1x + c2x2 + c3x

3.

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.30/30

Gaussian quadrature in practice

So, we try Gaussian quadrature...

IG = L [A1p(α1L) + A2p(α2L)]

= c0L(A1 + A2) + c1L2(A1α1 + A2α2)+

c2L3(A1α

21 + A2α

22) + c3L

4(A1α31 + A2α

32)

...when we know the exact integral is

I = c0L + c1L2

2+ c2

L3

3+ c3

L4

4.

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.30/30

Gaussian quadrature in practice

So, we arrive at the nonlinear system of equations:

A1 + A2 = 1

A1α1 + A2α2 =1

2

A1α21 + A2α

22 =

1

3

A1α31 + A2α

32 =

1

4

What is solution? Ask maple!

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.30/30

Gaussian quadrature in practice

In fact, it makes more sense to probe the symmetric interval[−L/2, L/2]. By symmetric, we expect α1 = −α2 andA1 = A2. We expect this method to be correct forpolynomials of degree 3, so we should match up terms forthe test polynomial

p(x) = c0 + c1x +c2

2x2 +

c3

6x3.

Math 428 lecture notes - c©2002 - Prof. Louis F Rossi – p.30/30

top related