Exercise: Newton's Method

Write code to solve the problem.

Question

Write a program to estimate the square root of 612 using Newton’s method, using five iterations. Here are the necessary detail on Newton’s method:

  1. The square root of 612 is the root of the equation x2612=0x^2−612 = 0.

  2. Suppose f(x)=x2612f(x)=x^2−612 , then its derivative f(x)=2xf^{\prime}(x)=2x.

  3. To find the root of f(x)=0f(x)=0, we start with an initial guess x1x_1 as the root, say x1=10x_1=10.

  4. With i=1,2,i=1,2,\cdots, we iteratively compute the values xi+1=xif(xi)f(xi)x_{i+1}=x_i-\frac{f(x_i)}{f^{\prime}(x_i)}

If for any xix_i, where i{1,2,},f(xi)=0i\in\{1,2,\cdots\}, f(x_i​)=0 that’s our solution. Otherwise, we iterate a few times to get better approximations. Newton’s method does not guarantee termination.

Exercise: Newton's Method

Write code to solve the problem.

Question

Write a program to estimate the square root of 612 using Newton’s method, using five iterations. Here are the necessary detail on Newton’s method:

  1. The square root of 612 is the root of the equation x2612=0x^2−612 = 0.

  2. Suppose f(x)=x2612f(x)=x^2−612 , then its derivative f(x)=2xf^{\prime}(x)=2x.

  3. To find the root of f(x)=0f(x)=0, we start with an initial guess x1x_1 as the root, say x1=10x_1=10.

  4. With i=1,2,i=1,2,\cdots, we iteratively compute the values xi+1=xif(xi)f(xi)x_{i+1}=x_i-\frac{f(x_i)}{f^{\prime}(x_i)}

If for any xix_i, where i{1,2,},f(xi)=0i\in\{1,2,\cdots\}, f(x_i​)=0 that’s our solution. Otherwise, we iterate a few times to get better approximations. Newton’s method does not guarantee termination.

C
#include <stdio.h>
int main(void) {
// Your code goes here
return 0;
}