Mathematical Roots
Written by:  dimport  Published by:  Nightscript  Published on:  20030621 07:19:46  Topic:  maths 

 
do you ever wonder how a computer calculates a square root?it's pretty simple, you just need to know how to multiply, divide, and subtract. 
the method i will show you is the NewtonRaphson mthod for aproximation. it's calculus but it can be simplified for dummies.
I'll begin with the floating number 3.15
Let's turn it into a polinomial equation equaling 0;
0=(x*x)  3.15;
I hope that you understood everything by now because it's a little more complicated than that.
There is a mathematical term called the derivative //it's ok if you don't know what it means.
the derivative of x^23.15 is 2x
Lets take the function in the beginning and divide it by its derivative
((x*x)3.15)/(2x)
Now we'll make an approximation called y=1 //it cannot be equal to 0 because you can't divide by 0. For this step you will need to subtract our function from that approximation (in variable form) and replace the y by an x.
x1 = x0  (((x0*x0)3.15)/(2x0)) //the numbers next to the xs are subscipts
x2 = x1  (((x1*x1)3.15)/(2x1))
x3 = x2  (((x2*x2)3.15)/(2x2))
x4 = x3  (((x3*x3)3.15)/(2x3))
x5 = x4  (((x4*x4)3.15)/(2x4))
x6 = x5  (((x5*x5)3.15)/(2x5))
x7 = x6  (((x6*x6)3.15)/(2x6))
x8 = x7  (((x7*x7)3.15)/(2x7))
x9 = x8  (((x8*x8)3.15)/(2x8))
having more than 10 iterations is just excessive so we'll stop.
here is how it looks in evaluated form:
2.075
1.796536145
1.774955137
1.77482394
1.774823935
1.774823935
1.774823935
1.774823935
1.774823935
1.774823935
You see how the value 1.774823935 is being repeated, that means that 1.774823935 is the answer
caesar4.
This article was originally written by caesar4 
This is an article from http://www.osix.net  view the original at: http://www.osix.net/modules/article/?id=367 
