#WSQ13 #TC1017

The babilonian method

This program calculates the square root of a number with an algorith invented a lot of centuries ago by the babilonians. The basic idea of the babilonian method is that the number you want to get the square root from is an area. Then, you give the lenght of the sides of this area. Let them be b and h. For example, the number (area) is 10, then, 5 and 2 can be its sides ‘couse 5*2=10. Now, you want both numbers to be equal to form a square of the same area (10), so one of the sides will be equal to the square root of 10. To do this, you can use the following algorithm.

1. Chose numbers b and h, such that b*h=area.

2. If b=h, go to steo 6. If not follow next step.

3. Side b=(h+b)/2          You assign to side b the average of both sides.

4. Side h=area/b           Now that b is different, h has to be area/b to keep the value of the area.

5. Return to step 2.

6. sqrt(area)=b

I recreated this algorithm in a C++ code. Here’s the link:

https://github.com/alanvaldo/my-tc1017-stuff/blob/master/wsq13.cpp

To know hot to do this I found useful information in Wikipedia. Here’s the link:

http://es.wikipedia.org/wiki/C%C3%A1lculo_de_la_ra%C3%ADz_cuadrada#Descripci.C3.B3n_formal

CC BY 4.0 #WSQ13 #TC1017 by Alan is licensed under a Creative Commons Attribution 4.0 International License.

Comments are closed.