4 ms·
I guess I'm confused by the fact that you are repeating step 2 which reassigns Y... Clear on N thanks. An example would make this easier...
by jpwagner 18y ago
I guess I'm confused by the fact that you are repeating step 2 which reassigns Y...
Clear on N thanks.
An example would make this easier...
- jibiki 18y agoYeah, it should read "repeat step three". Frequently, if you want to find x satisfying f(x) = x you can just let x be the limit of the sequence t, f(t), f(f(t)), f(f(f(t))) where t is some arbitrary number. In this case, we have: f(Y) = Y*(300-XYY)/200 If f(Y) = Y, then: Y = Y*(300-XYY)/200 1 = (300-XYY)/200 200 = 300 - XYY 100 = XYY So it looks like the algorithm calculates an inverse square root instead, and then multiplies it by the original number (step 5.)
- cperciva 18y agoYeah, it should read "repeat step three". Oops, quite right. So it looks like the algorithm calculates an inverse square root instead, and then multiplies it by the original number (step 5.) Exactly. The nice thing about this method is that it converges nicely even if you make errors (arithmetical or rounding) along the way -- so you can start by working with only a few digits and only use full precision right at the end. You could compute square roots using a direct NR iteration (Y := (Y + X/Y) / 2), but that requires that you perform a division at each step -- most people find multiplications to be easier and faster.