| exports | kernelspec | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
from pylab import *
The problem is to compute the numerical value of the definite integral
where
:tags: remove-input
figure(figsize=(8,5))
xp = linspace(0.05,0.95,10)
x = linspace(0,1,100)
f = lambda x: 2 + sin(2*pi*x)*cos(2*pi*x)
plot([0,1],[0,0],'k+-')
plot(xp,0*xp,'o')
plot(x,f(x),'r-',label='f(x)')
plot(xp,f(xp),'sk')
for xx in xp:
plot([xx,xx],[0,f(xx)],'b--')
axis([-0.1,1.1,-0.3,2.7])
d = 0.1
text(xp[0],-d,'$x_0$',va='top',ha='center')
text(xp[1],-d,'$x_1$',va='top',ha='center')
text(xp[-2],-d,'$x_{n-1}$',va='top',ha='center')
text(xp[-1],-d,'$x_n$',va='top',ha='center')
text(0,d,'$x=a$',ha='center')
text(1,d,'$x=b$',ha='center')
legend(), xlabel('x');
and approximate the integral by a formula of the type
where the
-
Given the nodes
${ x_j }$ how to find the weights to obtain a good approximation ? -
Can we find both the nodes and weights so that the formula is as accurate as possible ?
To measure the accuracy, we may establish a result like
Then the approximations converge fast if
Let
i.e., they converge uniformly an also in a pointwise sense. Define the quadrature rule
Then the error in the integral is
so that
We thus automatically obtain convergence of the integral approximations.
:::{prf:remark}
Usually, we take the approximations
:::
:::{prf:remark}
The approximation
-
global: a single approximation in the whole interval
$[a,b]$ -
local: partition
$[a,b]$ into many sub-intervals and construct$f_n$ in a piecewise manner in each sub-interval :::