function z = recip(R)
% RECIP  Use Newton to invert: R -> 1/R.  Requires R > 0.

k = floor(log10(R))  % an actual application would use internal
x = 10^(-k-1)        %   representation of R to get this starting point

for j=1:10
  x = x * (2 - R * x)
end

z = x
