-   Math (
-   -   "ODD" Square root Algorithm (

petrw1 2008-03-06 22:18

"ODD" Square root Algorithm
Odd to me anyway ... some of you may be familiar with it or why it works.


m_f_h 2008-03-08 20:45

[quote=petrw1;127976]Odd to me anyway ... some of you may be familiar with it or why it works.

Did you read at the end of the page:
[QUOTE] [B]More information[/B]

After asking on the usenet group [B]sci.math.num-analysis[/B] I was pointed in the right direction and was told, that the algorithm was known and used in mechanical calculators ("Friede desk calculator") in the early 60s at Boeing already. Later Hewlett Packard sold calculators such as the HP9100, which used a similiar or identical algorithm utilizing BCD (binary coded decimals).
I found this [URL=""]reference[/URL] to the inner workings of the HP Model 9100A and the mathematical background for the algorithm. The background is that:
Σ 2*i - 1 = n2
so it says that the sum of all 2*i-1 for i starting with 1 up to n is equal to the square of n. I would be interested to learn how to write the corresponding formula for the cubic numbers, any [EMAIL=""]hints[/EMAIL]?

petrw1 2008-03-08 22:49

Yes I did in fact read that but didn't take enough time to absorb how that extends to the algorithm he describes.

For example to calculate sqrt(1024) only requires adding 1+3+5 and later 61+63, rather than all odds from 1 to 63.

(1+3+5) * 100 = 900 = sum of odds to 60. Cool...

As I continue to investigate it starts to make sense .... so let me at it for a while and I'll be fine.


nibble4bits 2008-03-15 07:35

Do I understand right? That this is based on this formula for quadratics:
(n+1)^2=n^2+2n+1; let m=n+1
Thus consecutive squares are always 2n+1 appart.

That formule you mentioned is equivilent to this code:
Let x = 0
For i = 1 to n
x = x + i + i - 1
Next i
REM Returns in x, the square of n using recursive addition instead of multiplication.

The optimizes trivially without multiplication to:
Let x=0
For i = 1 to n
x = x + i + i
Next i
x = x - n

You can further remove the For...Next loop using an identity but you get this:
Let x = 2 * n * (n + 1) / 2 - n
Let x = n * (n + 1) - n
Let x = n^2 + n - n

As you can see, this leads you back to your original equation of x=n^2.

You should note that for m=n+1:
m^3 - n^3 - 1 =
(n+1)^3 - n^3 - 1 =
n^3 + 3n^2 + 3n + 1 - n^3 - 1 =
3(n^2 + n) =

All times are UTC. The time now is 16:19.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.