wincess2203 wincess2203
  • 28-01-2022
  • Computers and Technology
contestada

Write a program to compute the square root of a number. Do not use any math libraries/methods in this program.

Respuesta :

tonb
tonb tonb
  • 28-01-2022

Answer:

private double sqrt(double x) {

   double g = x / 2;

   while(true) {

       double average = (g + x/g) / 2;

       if(average == g || average == x/g) break;

       g = average;

   }

   return g;

}

Explanation:

Newton's method is to improve an initial guess "x / 2" by averaging between the guess and x / guess. You continue that until numerically your guess equals x/ guess.

Answer Link

Otras preguntas

Help anyone need it asap 8th grade math
Suppose the real rate is 4.5 percent and the inflation rate is 6.1 percent. What rate would you expect to see on a Treasury bill
Am i correct i will give you brainliest (no unnecessary stuff I will report)
The United States has prohibited the import of products from Iran due to the political situation in that nation. This complete ban is an example of a(n)
find the mass of an object which is acted upon by a force of 650 n to produce an acceleration of 10m/ s2​
please help!! The solution of the equation is x = ? .
Savings A/c and Current A/c aredeposits.​
Read the excerpt. From “Hope’ is the Thing with Feathers” by Emily Dickinson “Hope” is the thing with feathers– That perches in the soul– And sings the tune wit
Someone help I really need to pass this exam!!asap I will give u a Brainly crown if correct;)))
I need help and yeah