On Fri, 3 Oct 2003, Russell McMahon wrote: > > If anyone's interested, I optimized the (already optimized) 16-bit square > > root routine that I wrote for the 18F family. It now takes between 55 and > > 68 cycles to compute the square root of a 16-bit number. The new version > > unrolls the loop and takes advantage of the invariant states. At the cost > > of nearly doubling the code size, 7 more execution cycles could be saved. > > However, one can only stoop so low to shave cycles... > > FWIW, and you all may have better ways of doing this, square root can be > used directly to build a log function using otherwise only shift and add. It > may be that this information is more useful to people with a 4 function plus > sqrt calculators who want a log function :-) > > eg using said calculator > > log10(X) ~= (sqrt.sqrt.sqrt.sqrt.sqrt.sqrt.sqrt.sqrt.(X) - 1 ) x 889 This can be re-written as: log10(X) ~= (X^(1/2^11) - 1) * 889 (11 instead of 10 because of a subsequent RM post). I don't see any 'obvious' analytical way to prove this. However, it might be instructive to look at series expansions of log10 and X^Y and see if there's some way to correlate the coefficients of the terms in the expansions. -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu