Absolute value approximations by rationals
Peter Lax mentioned to me recently an example that no doubt various people have thought about over the years. Suppose we think of as a given number and we try to find its square root by solving the equation
for using Newton's method beginning from the guess . The successive iterates are given by the formula
After steps we have a rational function of type , and these functions will approach the function .
Let's see the iteration in action:
x = chebfun('x');
r = chebfun('1');
LW = 'linewidth'; lw = 1.6; FS = 'fontsize'; fs = 12;
for k = 0:5
subplot(3,2,k+1)
plot(r,LW,lw), axis([-1 1 -.2 1.2]), grid on
err = norm(r-abs(x),inf);
s = sprintf('error=%4.1e len=%d',err,length(r));
title(s,FS,fs)
r = (r.^2+x.^2)./(2*r);
end
The curves look nice, but the exponentially growing chebfun lengths do not. To improve this, we can put a breakpoint at :
x = chebfun('x',[-1 0 1]);
r = chebfun('1',[-1 0 1]);
for k = 0:5
subplot(3,2,k+1)
plot(r,LW,lw), axis([-1 1 -.2 1.2]), grid on
err = norm(r-abs(x),inf);
s = sprintf('error=%4.1e length = %d',err,length(r));
title(s,FS,fs)
r = (r.^2+x.^2)./(2*r);
end
It's interesting to look at the error. In the outer half of the interval, we've already achieved machine precision, whereas near the errors remain large.
clf, semilogy(abs(r-abs(x)),LW,lw)
axis([-1 1 1e-18 10]), grid on
xlabel('x',FS,fs)
title('Error',FS,fs)
Let's take six more steps of the iteration:
for k = 0:5
subplot(3,2,k+1)
plot(r,LW,lw), axis([-1 1 -.2 1.2]), grid on
err = norm(r-abs(x),inf);
s = sprintf('error=%4.1e length = %d',err,length(r));
title(s,FS,fs)
r = (r.^2+x.^2)./(2*r);
end
Here is the error:
clf, semilogy(abs(r-abs(x)),LW,lw)
axis([-1 1 1e-18 10]), grid on
xlabel('x',FS,fs)
title('Error',FS,fs)
Evidently we are getting convergence to , for all . In the -norm, the rate looks pretty disappointing. Donald Newman showed that the optimal type rational approximants to achieve accuracy [1,2], whereas here the maximum error is exactly $2^{-k}$ after steps, which corresponds to $1/n$ for the type approximation. Away from , however, the accuracy is , thanks to the quadratic convergence of Newton's method.
Incidentally, note that this last curve is not very close to symmetrical about . I wonder why not?
References
- D. J. Newman, Rational approximation of , Michigan Mathematical Journal, 11 (1964), 11-14.
- L. N. Trefethen, Approximation Theory and Approximation Practice, SIAM, 2013.