A program computes without a square-root routine

PHYSICS · Multi-part · Fermi University Physics · Mathematical Methods for Physics · Computational Physics · Scientific programming for physicists

Scientific Computing for Physicists, Ch Letting the computer do advanced algebra: operators, series and differentiated programs

Problem

A program computes x\sqrt x without a square-root routine, by three Newton steps yk+1=12(yk+x/yk)y_{k+1}=\tfrac12(y_k+x/y_k) from y0=1y_0=1. ((a)) Write the dual-number rules for addition, multiplication by a real constant and division that this loop needs. Run the loop on x=2+εx=2+\varepsilon by hand and report the value and the ε\varepsilon part after each step. ((b)) Compare the final value with 2\sqrt2 and the final ε\varepsilon part with the derivative of x\sqrt x at x=2x=2, giving both relative differences. ((c)) Forward-mode differentiation is exact to rounding, yet the ε\varepsilon part is not 1/(22)1/(2\sqrt2). Exactly what has it differentiated, and what does this imply for differentiating a program that only approximates the function we care about?

Browse the problem library