Sale!

Project Five: Adaptive Integration

$30.00

Category:
Rate this product

Numerical Analysis, Section 2
Project Five: Adaptive Integration

1. Project Description
In this project, you will write two C functions to perform adaptive integration. Recall that the Nth
order Chebyshev expansion of the function f on the interval [a, b] is the polynomial
p(x) = X
N
n=0
0
anTn
ˆ
2
b − a
x −
b + a
b − a
˙
, (1)
where the coefficients {an} are defined via the formula
an =
2
N + 1
X
N
j=0
f
ˆ
b − a
2
xj +
b + a
2
˙
Tn pxj q
with x0, x1, . . . , xN given by
xj = cos ˜
j +
1
2
N + 1
π
¸
.
The Nth order piecewise Chebyshev expansion of the function f : [a, b] → R
n given on the partition
a = a0 < a1 < a2 < . . . < am = b (2)
consists of m polynomials of degree N
p0, p1, . . . , pm−1. (3)
The i
th polynomial pi
is the Nth order Chebyshev expansion of f on the interval [ai
, ai+1]. It is
defined by the formula
pi(x) = X
N
n=0
0
c
i
n Tn
ˆ
2
ai+1 − ai
x −
ai+1 + ai
ai+1 − ai
˙
,
where the coefficients ?
c
i
n

are
c
i
n =
2
N + 1
X
N
j=0
f
ˆ
ai+1 − ai
2
xj +
ai+1 + ai
2
˙
Tn pxj q. (4)
Your task is to implement two functions, “chebint” and “chebadap int”. These functions will be
placed in a C file called “chebint.c”. The first of them, “chebint”, will evaluate the definite integral
Z b
a
p(x) dx
1
of an expansion p of the form (1) given the coefficients a0, a1, . . . , aN . The second of these functions, “chebadap int” will, given a piecewise Chebyshev expansion of a function f consisting of the
partition (2) and the expansions (3), approximate the integral
Z b
a
f(x) dx
by computing the sum
mX−1
j=0
Z aj+1
aj
pj (x) dx. (5)
Presumably, each term in the sum (5) will be evaluated via a call to your “chebint” function. The
calling syntaxes for both of these functions are in the “chebint.c” file.
2. Testing and grading
A public test code is given in the file inttest1.c. Another test code, called inttest2.c, will be used
to test your function as well. Half of the project grade will come from the first test file, and the
second half will come from the second. The commands
gcc -o inttest1 chebexp.c chebadap.c chebint.c inttest1.c -lm
./inttest1
can be used to compile and execute your program. There are five tests of your function in
“inttest1.c”, and the program will tell your score out of 5. We will also test your code by compiling
against inttest2.c, which we will not release until after the projects are due. You will get a 0 on
your project if it does not compile and run. Please start work on your project early and come see
either myself or our TA, Karry Wong, if you are having difficulties getting it to compile.
You should feel free to use either my versions of the files “chebexp.c” and “chebadap.c”, or your
own.
3. Submitting your project
You will submit your project using canvas. You should submit only your “chebint.c” fule. You
must submit your file by 11:59 PM on the due data. Late assignments will not be accepted.
2

Open chat
Need help?
Hello
Can we help you?