<s>
Clenshaw	B-Algorithm
–	I-Algorithm
Curtis	I-Algorithm
quadrature	I-Algorithm
and	O
Fejér	B-Algorithm
quadrature	I-Algorithm
are	O
methods	O
for	O
numerical	B-Algorithm
integration	I-Algorithm
,	O
or	O
"	O
quadrature	O
"	O
,	O
that	O
are	O
based	O
on	O
an	O
expansion	O
of	O
the	O
integrand	O
in	O
terms	O
of	O
Chebyshev	O
polynomials	O
.	O
</s>
<s>
Equivalently	O
,	O
they	O
employ	O
a	O
change	O
of	O
variables	O
and	O
use	O
a	O
discrete	B-General_Concept
cosine	I-General_Concept
transform	I-General_Concept
(	O
DCT	B-General_Concept
)	O
approximation	O
for	O
the	O
cosine	O
series	O
.	O
</s>
<s>
Besides	O
having	O
fast-converging	O
accuracy	O
comparable	O
to	O
Gaussian	B-Algorithm
quadrature	I-Algorithm
rules	I-Algorithm
,	O
Clenshaw	B-Algorithm
–	I-Algorithm
Curtis	I-Algorithm
quadrature	I-Algorithm
naturally	O
leads	O
to	O
nested	O
quadrature	B-Algorithm
rules	I-Algorithm
(	O
where	O
different	O
accuracy	O
orders	O
share	O
points	O
)	O
,	O
which	O
is	O
important	O
for	O
both	O
adaptive	B-Algorithm
quadrature	I-Algorithm
and	O
multidimensional	O
quadrature	O
(	O
cubature	B-Algorithm
)	O
.	O
</s>
<s>
In	O
practice	O
,	O
the	O
integration	O
weights	O
for	O
the	O
value	O
of	O
the	O
function	O
at	O
each	O
node	O
are	O
precomputed	O
,	O
and	O
this	O
computation	O
can	O
be	O
performed	O
in	O
time	O
by	O
means	O
of	O
fast	O
Fourier	O
transform-related	O
algorithms	O
for	O
the	O
DCT	B-General_Concept
.	O
</s>
<s>
A	O
simple	O
way	O
of	O
understanding	O
the	O
algorithm	O
is	O
to	O
realize	O
that	O
Clenshaw	B-Algorithm
–	I-Algorithm
Curtis	I-Algorithm
quadrature	I-Algorithm
(	O
proposed	O
by	O
those	O
authors	O
in	O
1960	O
)	O
amounts	O
to	O
integrating	O
via	O
a	O
change	O
of	O
variable	O
.	O
</s>
<s>
one	O
must	O
again	O
perform	O
a	O
numeric	B-Algorithm
integration	I-Algorithm
,	O
so	O
at	O
first	O
this	O
may	O
not	O
seem	O
to	O
have	O
simplified	O
the	O
problem	O
.	O
</s>
<s>
Unlike	O
computation	O
of	O
arbitrary	O
integrals	O
,	O
however	O
,	O
Fourier-series	O
integrations	O
for	O
periodic	O
functions	O
(	O
like	O
,	O
by	O
construction	O
)	O
,	O
up	O
to	O
the	O
Nyquist	O
frequency	O
,	O
are	O
accurately	O
computed	O
by	O
the	O
equally	O
spaced	O
and	O
equally	O
weighted	O
points	O
for	O
(	O
except	O
the	O
endpoints	O
are	O
weighted	O
by	O
1/2	O
,	O
to	O
avoid	O
double-counting	O
,	O
equivalent	O
to	O
the	O
trapezoidal	B-Algorithm
rule	I-Algorithm
or	O
the	O
Euler	B-Algorithm
–	I-Algorithm
Maclaurin	I-Algorithm
formula	I-Algorithm
)	O
.	O
</s>
<s>
That	O
is	O
,	O
we	O
approximate	O
the	O
cosine-series	O
integral	O
by	O
the	O
type-I	O
discrete	B-General_Concept
cosine	I-General_Concept
transform	I-General_Concept
(	O
DCT	B-General_Concept
)	O
:	O
</s>
<s>
Because	O
only	O
is	O
needed	O
,	O
the	O
formula	O
simplifies	O
further	O
into	O
a	O
type-I	O
DCT	B-General_Concept
of	O
order	O
,	O
assuming	O
N	O
is	O
an	O
even	O
number	O
:	O
</s>
<s>
From	O
this	O
formula	O
,	O
it	O
is	O
clear	O
that	O
the	O
Clenshaw	B-Algorithm
–	I-Algorithm
Curtis	I-Algorithm
quadrature	I-Algorithm
rule	O
is	O
symmetric	O
,	O
in	O
that	O
it	O
weights	O
f(x )	O
and	O
f( −x	O
)	O
equally	O
.	O
</s>
<s>
Because	O
of	O
aliasing	B-Error_Name
,	O
one	O
only	O
computes	O
the	O
coefficients	O
up	O
to	O
,	O
since	O
discrete	O
sampling	O
of	O
the	O
function	O
makes	O
the	O
frequency	O
of	O
indistinguishable	O
from	O
that	O
of	O
N	O
–	O
2k	O
.	O
</s>
<s>
Fejér	O
proposed	O
two	O
quadrature	B-Algorithm
rules	I-Algorithm
very	O
similar	O
to	O
Clenshaw	B-Algorithm
–	I-Algorithm
Curtis	I-Algorithm
quadrature	I-Algorithm
,	O
but	O
much	O
earlier	O
(	O
in	O
1933	O
)	O
.	O
</s>
<s>
These	O
are	O
the	O
roots	O
of	O
,	O
and	O
are	O
known	O
as	O
the	O
Chebyshev	B-Algorithm
nodes	I-Algorithm
.	O
</s>
<s>
which	O
is	O
precisely	O
the	O
type-II	O
DCT	B-General_Concept
.	O
</s>
<s>
However	O
,	O
Fejér	O
's	O
first	O
quadrature	O
rule	O
is	O
not	O
nested	O
:	O
the	O
evaluation	O
points	O
for	O
do	O
not	O
coincide	O
with	O
any	O
of	O
the	O
evaluation	O
points	O
for	O
,	O
unlike	O
Clenshaw	B-Algorithm
–	I-Algorithm
Curtis	I-Algorithm
quadrature	I-Algorithm
or	O
Fejér	O
's	O
second	O
rule	O
.	O
</s>
<s>
Despite	O
the	O
fact	O
that	O
Fejér	O
discovered	O
these	O
techniques	O
before	O
Clenshaw	O
and	O
Curtis	O
,	O
the	O
name	O
"	O
Clenshaw	B-Algorithm
–	I-Algorithm
Curtis	I-Algorithm
quadrature	I-Algorithm
"	O
has	O
become	O
standard	O
.	O
</s>
<s>
The	O
classic	O
method	O
of	O
Gaussian	B-Algorithm
quadrature	I-Algorithm
evaluates	O
the	O
integrand	O
at	O
points	O
and	O
is	O
constructed	O
to	O
exactly	O
integrate	O
polynomials	O
up	O
to	O
degree	O
.	O
</s>
<s>
In	O
contrast	O
,	O
Clenshaw	B-Algorithm
–	I-Algorithm
Curtis	I-Algorithm
quadrature	I-Algorithm
,	O
above	O
,	O
evaluates	O
the	O
integrand	O
at	O
points	O
and	O
exactly	O
integrates	O
polynomials	O
only	O
up	O
to	O
degree	O
.	O
</s>
<s>
It	O
may	O
seem	O
,	O
therefore	O
,	O
that	O
Clenshaw	O
–	O
Curtis	O
is	O
intrinsically	O
worse	O
than	O
Gaussian	B-Algorithm
quadrature	I-Algorithm
,	O
but	O
in	O
reality	O
this	O
does	O
not	O
seem	O
to	O
be	O
the	O
case	O
.	O
</s>
<s>
In	O
practice	O
,	O
several	O
authors	O
have	O
observed	O
that	O
Clenshaw	O
–	O
Curtis	O
can	O
have	O
accuracy	O
comparable	O
to	O
that	O
of	O
Gaussian	B-Algorithm
quadrature	I-Algorithm
for	O
the	O
same	O
number	O
of	O
points	O
.	O
</s>
<s>
In	O
fact	O
,	O
recent	O
theoretical	O
results	O
argue	O
that	O
both	O
Gaussian	O
and	O
Clenshaw	B-Algorithm
–	I-Algorithm
Curtis	I-Algorithm
quadrature	I-Algorithm
have	O
error	O
bounded	O
by	O
for	O
a	O
k-times	O
differentiable	O
integrand	O
.	O
</s>
<s>
One	O
often	O
cited	O
advantage	O
of	O
Clenshaw	B-Algorithm
–	I-Algorithm
Curtis	I-Algorithm
quadrature	I-Algorithm
is	O
that	O
the	O
quadrature	O
weights	O
can	O
be	O
evaluated	O
in	O
time	O
by	O
fast	O
Fourier	O
transform	O
algorithms	O
(	O
or	O
their	O
analogues	O
for	O
the	O
DCT	B-General_Concept
)	O
,	O
whereas	O
most	O
algorithms	O
for	O
Gaussian	B-Algorithm
quadrature	I-Algorithm
weights	O
required	O
time	O
to	O
compute	O
.	O
</s>
<s>
As	O
a	O
practical	O
matter	O
,	O
high-order	O
numeric	B-Algorithm
integration	I-Algorithm
is	O
rarely	O
performed	O
by	O
simply	O
evaluating	O
a	O
quadrature	O
formula	O
for	O
very	O
large	O
.	O
</s>
<s>
Instead	O
,	O
one	O
usually	O
employs	O
an	O
adaptive	B-Algorithm
quadrature	I-Algorithm
scheme	O
that	O
first	O
evaluates	O
the	O
integral	O
to	O
low	O
order	O
,	O
and	O
then	O
successively	O
refines	O
the	O
accuracy	O
by	O
increasing	O
the	O
number	O
of	O
sample	O
points	O
,	O
possibly	O
only	O
in	O
regions	O
where	O
the	O
integral	O
is	O
inaccurate	O
.	O
</s>
<s>
In	O
contrast	O
,	O
Gaussian	B-Algorithm
quadrature	I-Algorithm
rules	O
are	O
not	O
naturally	O
nested	O
,	O
and	O
so	O
one	O
must	O
employ	O
Gauss	B-Algorithm
–	I-Algorithm
Kronrod	I-Algorithm
quadrature	I-Algorithm
formulas	I-Algorithm
or	O
similar	O
methods	O
.	O
</s>
<s>
Nested	O
rules	O
are	O
also	O
important	O
for	O
sparse	B-Algorithm
grids	I-Algorithm
in	O
multidimensional	O
quadrature	O
,	O
and	O
Clenshaw	B-Algorithm
–	I-Algorithm
Curtis	I-Algorithm
quadrature	I-Algorithm
is	O
a	O
popular	O
method	O
in	O
this	O
context	O
.	O
</s>
<s>
Clenshaw	B-Algorithm
–	I-Algorithm
Curtis	I-Algorithm
quadrature	I-Algorithm
can	O
be	O
generalized	O
to	O
this	O
case	O
as	O
follows	O
.	O
</s>
<s>
As	O
before	O
,	O
it	O
works	O
by	O
finding	O
the	O
cosine-series	O
expansion	O
of	O
via	O
a	O
DCT	B-General_Concept
,	O
and	O
then	O
integrating	O
each	O
term	O
in	O
the	O
cosine	O
series	O
.	O
</s>
<s>
For	O
example	O
,	O
special	O
methods	O
have	O
been	O
developed	O
to	O
apply	O
Clenshaw	B-Algorithm
–	I-Algorithm
Curtis	I-Algorithm
quadrature	I-Algorithm
to	O
integrands	O
of	O
the	O
form	O
with	O
a	O
weight	O
function	O
that	O
is	O
highly	O
oscillatory	O
,	O
e.g.	O
</s>
<s>
Note	O
that	O
Gaussian	B-Algorithm
quadrature	I-Algorithm
can	O
also	O
be	O
adapted	O
for	O
various	O
weight	O
functions	O
,	O
but	O
the	O
technique	O
is	O
somewhat	O
different	O
.	O
</s>
<s>
In	O
Clenshaw	B-Algorithm
–	I-Algorithm
Curtis	I-Algorithm
quadrature	I-Algorithm
,	O
the	O
integrand	O
is	O
always	O
evaluated	O
at	O
the	O
same	O
set	O
of	O
points	O
regardless	O
of	O
,	O
corresponding	O
to	O
the	O
extrema	O
or	O
roots	O
of	O
a	O
Chebyshev	O
polynomial	O
.	O
</s>
<s>
In	O
Gaussian	B-Algorithm
quadrature	I-Algorithm
,	O
different	O
weight	O
functions	O
lead	O
to	O
different	O
orthogonal	O
polynomials	O
,	O
and	O
thus	O
different	O
roots	O
where	O
the	O
integrand	O
is	O
evaluated	O
.	O
</s>
<s>
It	O
is	O
also	O
possible	O
to	O
use	O
Clenshaw	B-Algorithm
–	I-Algorithm
Curtis	I-Algorithm
quadrature	I-Algorithm
to	O
compute	O
integrals	O
of	O
the	O
form	O
and	O
,	O
using	O
a	O
coordinate-remapping	O
technique	O
.	O
</s>
<s>
to	O
transform	O
an	O
infinite	O
or	O
semi-infinite	O
interval	O
into	O
a	O
finite	O
one	O
,	O
as	O
described	O
in	O
Numerical	B-Algorithm
integration	I-Algorithm
.	O
</s>
<s>
There	O
are	O
also	O
additional	O
techniques	O
that	O
have	O
been	O
developed	O
specifically	O
for	O
Clenshaw	B-Algorithm
–	I-Algorithm
Curtis	I-Algorithm
quadrature	I-Algorithm
.	O
</s>
<s>
The	O
factor	O
multiplying	O
sin(θ )	O
,	O
f( 	O
...	O
)	O
/	O
(	O
...	O
)	O
2	O
,	O
can	O
then	O
be	O
expanded	O
in	O
a	O
cosine	O
series	O
(	O
approximately	O
,	O
using	O
the	O
discrete	B-General_Concept
cosine	I-General_Concept
transform	I-General_Concept
)	O
and	O
integrated	O
term-by-term	O
,	O
exactly	O
as	O
was	O
done	O
for	O
f(cosθ )	O
above	O
.	O
</s>
<s>
In	O
this	O
case	O
,	O
we	O
have	O
used	O
the	O
fact	O
that	O
the	O
remapped	O
integrand	O
is	O
already	O
periodic	O
and	O
so	O
can	O
be	O
directly	O
integrated	O
with	O
high	O
(	O
even	O
exponential	O
)	O
accuracy	O
using	O
the	O
trapezoidal	B-Algorithm
rule	I-Algorithm
(	O
assuming	O
f	O
is	O
sufficiently	O
smooth	O
and	O
rapidly	O
decaying	O
)	O
;	O
there	O
is	O
no	O
need	O
to	O
compute	O
the	O
cosine	O
series	O
as	O
an	O
intermediate	O
step	O
.	O
</s>
<s>
(	O
If	O
f	O
decays	O
exactly	O
as	O
1/x2	O
,	O
then	O
the	O
integrand	O
goes	O
to	O
a	O
finite	O
value	O
at	O
the	O
endpoints	O
and	O
these	O
limits	O
must	O
be	O
included	O
as	O
endpoint	O
terms	O
in	O
the	O
trapezoidal	B-Algorithm
rule	I-Algorithm
.	O
)	O
.	O
</s>
<s>
However	O
,	O
if	O
f	O
decays	O
only	O
polynomially	O
quickly	O
,	O
then	O
it	O
may	O
be	O
necessary	O
to	O
use	O
a	O
further	O
step	O
of	O
Clenshaw	B-Algorithm
–	I-Algorithm
Curtis	I-Algorithm
quadrature	I-Algorithm
to	O
obtain	O
exponential	O
accuracy	O
of	O
the	O
remapped	O
integral	O
instead	O
of	O
the	O
trapezoidal	B-Algorithm
rule	I-Algorithm
,	O
depending	O
on	O
more	O
details	O
of	O
the	O
limiting	O
properties	O
of	O
f	O
:	O
the	O
problem	O
is	O
that	O
,	O
although	O
is	O
indeed	O
periodic	O
with	O
period	O
π	O
,	O
it	O
is	O
not	O
necessarily	O
smooth	O
at	O
the	O
endpoints	O
if	O
all	O
the	O
derivatives	O
do	O
not	O
vanish	O
there	O
[	O
e.g.	O
</s>
<s>
Another	O
coordinate-remapping	O
approach	O
was	O
suggested	O
for	O
integrals	O
of	O
the	O
form	O
,	O
in	O
which	O
case	O
one	O
can	O
use	O
the	O
transformation	O
to	O
transform	O
the	O
integral	O
into	O
the	O
form	O
where	O
,	O
at	O
which	O
point	O
one	O
can	O
proceed	O
identically	O
to	O
Clenshaw	B-Algorithm
–	I-Algorithm
Curtis	I-Algorithm
quadrature	I-Algorithm
for	O
f	O
as	O
above	O
.	O
</s>
<s>
In	O
practice	O
,	O
it	O
is	O
inconvenient	O
to	O
perform	O
a	O
DCT	B-General_Concept
of	O
the	O
sampled	O
function	O
values	O
f(cosθ )	O
for	O
each	O
new	O
integrand	O
.	O
</s>
<s>
These	O
weights	O
are	O
also	O
computed	O
by	O
a	O
DCT	B-General_Concept
,	O
as	O
is	O
easily	O
seen	O
by	O
expressing	O
the	O
computation	O
in	O
terms	O
of	O
matrix	B-Architecture
algebra	B-Language
.	O
</s>
<s>
where	O
D	O
is	O
the	O
matrix	B-Architecture
form	O
of	O
the	O
(	O
N/2	O
+1	O
)	O
-point	O
type-I	O
DCT	B-General_Concept
from	O
above	O
,	O
with	O
entries	O
(	O
for	O
zero-based	O
indices	O
)	O
:	O
</s>
<s>
As	O
discussed	O
above	O
,	O
because	O
of	O
aliasing	B-Error_Name
,	O
there	O
is	O
no	O
point	O
in	O
computing	O
coefficients	O
beyond	O
,	O
so	O
D	O
is	O
an	O
matrix	B-Architecture
.	O
</s>
<s>
(	O
Note	O
,	O
however	O
,	O
that	O
these	O
weight	O
factors	O
are	O
altered	O
if	O
one	O
changes	O
the	O
DCT	B-General_Concept
matrix	B-Architecture
D	O
to	O
use	O
a	O
different	O
normalization	O
convention	O
.	O
</s>
<s>
For	O
example	O
,	O
it	O
is	O
common	O
to	O
define	O
the	O
type-I	O
DCT	B-General_Concept
with	O
additional	O
factors	O
of	O
2	O
or	O
factors	O
in	O
the	O
first	O
and	O
last	O
rows	O
or	O
columns	O
,	O
which	O
leads	O
to	O
corresponding	O
alterations	O
in	O
the	O
d	O
entries	O
.	O
)	O
</s>
<s>
Since	O
the	O
transposed	O
matrix	B-Architecture
is	O
also	O
a	O
DCT	B-General_Concept
(	O
e.g.	O
,	O
the	O
transpose	O
of	O
a	O
type-I	O
DCT	B-General_Concept
is	O
a	O
type-I	O
DCT	B-General_Concept
,	O
possibly	O
with	O
a	O
slightly	O
different	O
normalization	O
depending	O
on	O
the	O
conventions	O
that	O
are	O
employed	O
)	O
,	O
the	O
quadrature	O
weights	O
w	O
can	O
be	O
precomputed	O
in	O
O(NlogN )	O
time	O
for	O
a	O
given	O
N	O
using	O
fast	O
DCT	B-General_Concept
algorithms	O
.	O
</s>
