# MACM 316 – Assignment 6

\$30.00

Rate this product

MACM 316 – Assignment 6
A. Computing Assignment – Numerical Integration of an unpleasant function
In this assignment you will be computing the integral
I =
Z 1
0
x
−1
sin(x
−1
log(x)) dx.
It is known that I ≈ −0.5. This is a challenging integral to compute, however, because the integrand
f(x) = x
−1
sin(x
−1
log(x)) has infinitely-many oscillations in the interval [0, 1] and is also singular
at x = 0. You may quickly want to check that any standard numerical quadrature (e.g. Trapezoidal,
Simpson’s, etc) gives you poor approximations to I.
To compute this integral, you will be using a subdivision scheme based on splitting [0, 1] into
subintervals defined by the zeros of f(x). Note that f(x) = 0 at the points
1 > a1 > a2 > a3 > . . . > 0,
where ai = exp(−bi) and bi
is the unique solution to the equation
b exp(b) − iπ = 0, 1 < b < ∞. (0.1)
To compute I, you first need to find these roots. Recalling Part 3 of the course, this can be done
in Matlab using the fzero command:
1 b=fzero(@(x) x*exp(x)-i*pi,0);
2 a(i)=exp(-b);
Given the a1, a2, . . . , an, we can now approximate I as follows:
I ≈ Qn =
Xn
i=0
Ii
, Ii =
Z ai+1
ai
f(x) dx, a0 = 1.
Write a code that computes Qn by applying a standard numerical quadrature to each integral Ii
. I
recommend you use a built-in routine to evaluate each Ii
, e.g. Matlab’s integral or quad commands.
List your results for n = 100, 200, 300, . . . , 1000. How many digits of I can you accurately compute?
1
You will hopefully have noticed that Qn is converging to I rather slowly. Fortunately, there’s a way
to get a faster converging approximation, known as Aitken’s ∆2 Method (see Burden & Faires, Sec
2.5). Given the sequence {Qn}∞
n=0 we define the new sequence {Qˆ
n}∞
n=0 by

n = Qn −
(Qn+1 − Qn)
2
Qn+2 − 2Qn+1 + Qn
.
Compute this new sequence and use it to get as good an approximation to I as you can (in reasonable
computing time). State your answer to as many digits as you believe are correct. Make sure to
justify the number of digits you give.
Computing Assignment – Bonus credit
This bonus questions is worth one mark and must be submitted as part of your one-page report.
It is therefore possible to get 6 marks for this computing assignment.