Question: ub History. AS Consider the function f(x) r2-Z, and observe that when r-VZ./(r) 0. Also notice that although square roots are difficult to compute, it
ub History. AS Consider the function f(x) r2-Z, and observe that when r-VZ./(r) 0. Also notice that although square roots are difficult to compute, it is easy to evaluate the value of f(x) for any provided z value. Newton's method starts with an initial guess for r (for example, z 1) and then iterati the value of z to improve the approximation. At each step, the new value of z is computed to be f(x) where f"(z) is the derivative of f(z). For the specific case of the function /(z) = r2-Z, the formula would be 2r The table below shows an example of Newton's method with 5 steps using the function fr)-6 (that is, where the value of Z is set to 6). The initial guess for is 1.0. Notice how, at each step, the value of a2 gets closer to the goal value of 6. Step Ol d value Old r value (squared) ew r value New value (squared) 10000000000 3.5000000000 2.6071428571 2.4542563601 2.4494943716 1.0000000000 12.2500000000 6.7971938776 6.0233742810 6.0000226763 3.5000000000 2.6071428571 2.4542363601 2.4491943716 12.2300000000 6.7971938776 6.02337 42810 6.0000226763 2.44948974286.0000000000 1.1 Your task Write a syntactically and semantically correct C program which uses the formulation of Newton's method described above. Your code should be stored in a file called "nevton.c". The number of steps and the goal value (Z) should be easy to adjust in your code. This can be achieved by having variables called num.ateps and Z at the top of your program. During your demo, you will be expected to show the evaluator how to change both values. You should use a loop to perform the iterative process (instead of simply copying and pasting code). since otherwise it will not be possible to use a very large number of steps Your program should produce the tollowing output Before the computation starts. print the number of steps and the value of Z . At each step of the iteration, print the step nunber (with the first step numbered I) and t old value of to 10 decinal places . After the end of the last step, print the inal value of s to 10 decimal places
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
