Graphics Programs Reference
In-Depth Information
if abs(g + f) >= abs(g - f); dx = n/(g + f);
else; dx = n/(g - f); end
x=x-dx;
if abs(dx) < tol; return; end
end
error('Too many iterations in laguerre')
functionb=deflpoly(a,r)
% Horner's deflation:
% a(1)*xˆn + a(2)*xˆ(n-1) + ... + a(n+1)
% = (x - r)[b(1)*xˆ(n-1) + b(2)*xˆ(n-2) + ...+ b(n)].
n = length(a) - 1;
b = zeros(n,1);
b(1) = a(1);
fori=2:n;b(i)=a(i)+r*b(i-1);end
Since the roots arecomputedwith finite accuracy,each deflationintroduces small
errors in the coefficients of the deflatedpolynomial. The accumulatedroundoff error
increaseswith the degree of the polynomial and canbecomesevere if the polynomial is
ill-conditioned (small changes in the coefficients produce largechanges in the roots).
Hence the results shouldbe viewedwith cautionwhendealing with polynomials of
high degree.
The errorscausedbydeflation can be reducedbyrecomputing each root using
the original, undeflatedpolynomial. The roots obtainedpreviouslyinconjunction
with deflationareemployedas the starting values.
EXAMPLE 4.10
A zeroofthepolynomial P 4 ( x )
3 x 4
10 x 3
48 x 2
=
2 x
+
12 is x
=
6
.
Deflate the
polynomial with Horner's algorithm, i.e., find P 3 ( x )sothat( x
6) P 3 ( x )
=
P 4 ( x )
.
Solution With r
=
6 and n
=
4
,
Eqs. (4.13) become
b 1
=
a 1
=
3
b 2 =
a 2 +
6 b 1 =−
10
+
6(3)
=
8
b 3 =
a 3 +
6 b 2 =−
48
+
6(8)
=
0
b 4 =
a 4 +
6 b 3 =−
2
+
6(0)
=−
2
Therefore,
3 x 3
8 x 2
P 3 ( x )
=
+
2
Search WWH ::




Custom Search