Graphics Programs Reference
In-Depth Information
The M-file of the functionintegratedis
functiony=fex6
11(x)
% Function used in Example 6.11
y = (sin(x)/x)ˆ2;
_
The program produced the following output:
I=
1.41815026780139
n=
5
EXAMPLE 6.12
Evaluate numerically
1
.
5
f
(
x
)
dx
, where
f
(
x
) is representedbythe unevenly spaced
data
x
1
.
2
1
.
7
2
.
0
2
.
4
2
.
9
3
.
3
f
(
x
)
−
0
.
362 36
0
.
128 84
0
.
416 15
0
.
737 39
0
.
970 96
0
.
987 48
Knowing that the datapoints lieon the curve
f
(
x
)
=−
cos
x
,evaluate the accuracy of
the solution.
Solution
We approximate
f
(
x
) by the polynomial
P
5
(
x
)that intersects all the data
points, and then evaluate
3
1
f
(
x
)
dx
≈
3
1
5
P
5
(
x
)
dx
with the Gauss-Legendreformula.
Since the polynomial isofdegree five, only three nodes (
n
.
5
.
=
3) are requiredinthe
quadrature.
FromEq. (6.28) and Table 6.3, weobtain for the abscissasofthenodes
3
+
1
.
5
3
−
1
.
5
x
1
=
+
(
−
0
.
774597)
=
1
.
6691
2
2
3
+
1
.
5
x
2
=
=
2
.
25
2
3
+
1
.
5
3
−
1
.
5
x
3
=
+
(0
.
774597)
=
2
.
8309
2
2
We now compute the values of the interpolant
P
5
(
x
) at the nodes. Thiscan be done
using the functions
newtonPoly
or
neville
listedinArt. 3.2. The results are
P
5
(
x
1
)
=
0
.
098 08
P
5
(
x
2
)
=
0
.
628 16
P
5
(
x
3
)
=
0
.
952 16
Using Gauss-Legendrequadrature
3
3
−
.
3
1
5
I
=
P
5
(
x
)
dx
=
A
i
P
5
(
x
i
)
2
1
.
5
i
=
1
Search WWH ::
Custom Search