Graphics Programs Reference
In-Depth Information
EXAMPLE 6.10
Evaluate as accuratelyas possible
x
3
x
+
e x dx
F
=
0
Solution Inits presentform, the integral is not suited to any of the Gaussian quadra-
tures listedinthis article.But using the transformation
t 2
x
=
dx
=
2 tdt
wehave
2
0
3) e t 2 dt
3) e t 2 dt
( t 2
( t 2
F
=
+
=
+
−∞
which can beevaluated exactlywith Gauss-Hermite formulausing only two nodes
( n
=
2). Thus
A 1 ( t 1
A 2 ( t 2 +
=
+
+
F
3)
3)
886 227 (0
3 +
886 227 (
3
707107) 2
707107) 2
=
0
.
.
+
0
.
0
.
+
=
6
.
20359
EXAMPLE 6.11
Determinehowmany nodes are required to evaluate
π
sin x
x
2
dx
0
with Gauss-Legendrequadraturetosix decimal places. The exact integral, rounded
to six places, is 1
.
418 15.
Solution The integrand is a smooth function; hence it issuited for Gauss-Legendre
integration. There is anindeterminacyat x
0,butthisdoesnotbother the quadrature
since the integrand is never evaluatedatthat point.We used the following program
thatcomputes the quadraturewith 2
=
,
3
,...
nodes until the desiredaccuracyis reached:
% Example 6.11 (Gauss-Legendre quadrature)
a=0;b=pi;Iexact=1.41815;
forn=2:12
I = gaussQuad(@fex6
_
11,a,b,n);
if abs(I - Iexact) < 0.00001
I
n
break
end
end
Search WWH ::




Custom Search