In this case we are going to use the 'Babylonian Method' to get the square root of any positive number.
We must set an error for the final result. Say, smaller than 0.001. In other words we will try to find the square root value with at least 2 correct decimal places.
Step 1:
Divide the number (5.5) by 2 to get the first guess for the square root .
First guess = 5.5/2 = 2.75.Step 2:
Divide 5.5 by the previous result. d = 5.5/2.75 = 2.
Average this value (d) with that of step 1: (2 + 2.75)/2 = 2.375 (new guess).
Error = new guess - previous value = 2.75 - 2.375 = 0.375.
0.375 > 0.001. As error > accuracy, we repeat this step again.Step 3:
Divide 5.5 by the previous result. d = 5.5/2.375 = 2.3157894737.
Average this value (d) with that of step 2: (2.3157894737 + 2.375)/2 = 2.3453947369 (new guess).
Error = new guess - previous value = 2.375 - 2.3453947369 = 0.0296052631.
0.0296052631 > 0.001. As error > accuracy, we repeat this step again.Step 4:
Divide 5.5 by the previous result. d = 5.5/2.3453947369 = 2.3450210378.
Average this value (d) with that of step 3: (2.3450210378 + 2.3453947369)/2 = 2.3452078874 (new guess).
Error = new guess - previous value = 2.3453947369 - 2.3452078874 = 0.0001868495.
0.0001868495 <= 0.001. As error <= accuracy, we stop the iterations and use 2.3452078874 as the square root.
So, we can say that the square root of 5.5 is 2.345 with an error smaller than 0.001 (in fact the error is 0.0001868495. this means that the first 3 decimal places are correct. Just to compare, the returned value by using the javascript function 'Math.sqrt(5.5)' is 2.345207879911715.
Note: There are other ways to calculate square roots. This is only one of them.