Charles
Give this a try
'----------- Start PicBasicPro Code--------
'Taylor expansion to compute 1% accurate square roots scaled up by 64
'Copyright by Dave Saum 2009, no rights reserved
'Please email me if you find errors or improvements: DSaum at infiltec dot com
'
'Variables:
Sqr64x var word 'output 1% accurate sq root scaled up by 64
Input var word 'input integer for sq root
'
'Calculation:
Sqr64x=sqr Input 'first approximation to square root, unscaled
Sqr64x=(Sqr64x<<6)+((((Input-(Sqr64x*Sqr64x))<<5)+(Sqr64x>>1))/Sqr64x) 'more accurate sqr root, scaled up by 64
'
'Sample Calculation:
'If you take the sq root of 5 and scale it up by 64, the answer is (5^0.5)*64=143.108
'If you use the PBP sqr function for this: sqr(5)*64 = 2*64 = 128 or 10.6% error under 143.108
'But, using the Sqr64x code above:
'Sqr64x= (2*64)+((((5-(2*2))*32)+(2/2))/2)
' = 128+(((32+1))/2 = 128 +16 = 144 or 0.6% error over 143.108
'------------- end code ------
Hope this helps,
Dave
http://www.infiltec.com/seismo
http://www.infiltec.com/Infrasound@home
http://www.infiltec.com/SID-GRB@home
http://www.infiltec.com/inf-fun.htm
Bookmarks