How to find the Square Root of floating Point number based on Newton iterative method in javascript
This article mainly introduces javascript based on Newton iterative method to achieve floating point square root of the relevant knowledge, the content is detailed and easy to understand, simple and fast operation, has a certain reference value, I believe that after reading this javascript based on Newton iterative method how to achieve floating point square root article will have a harvest, let's take a look.
The first is the principle of Newton iterative method.
For example, we ask for the square root of a, first make a random guess of an approximate value x, and then keep making x equal to the average of x and a big x. After several iterations, the value of x is already quite accurate.
As we require, the mathematical assumption is axi7, var xantha.
(7 + 7thumb 7) / 2 = 3.64287514
(3.64287514 + 7thumb 3.64287514) / 2 =?
The following is implemented using JavaScript
Var G = {result:0, sqrt:function (a) {var Xantha; for (var iTuno