Question: In Calculus you will learn an algorithm called Newton's Method for finding the roots of a equation f(x) = 0. The technique starts from an initial guess x1 and computes a next estimate x2 by:...


in C++


Question: In Calculus you will learn an algorithm called Newton's Method for finding the roots of a<br>equation f(x) = 0. The technique starts from an initial guess x1 and computes a next estimate x2 by:<br>f (x1)<br>f'(x1)<br>X2 = x1<br>We then apply the procedure again starting from x2 (in place of x1 in the right-hand-side) and we<br>keep repeating this until successive estimates differ by less than some preset tolerance. Note that each<br>repetition is called an iteration.<br>Write a program called root.c which finds a root of the function f(x) = sin x<br>of the user provided starting guess x1.<br>Your program must consist of a main program, which opens the output file rootout.txt for ap-<br>pending (mode =

Extracted text: Question: In Calculus you will learn an algorithm called Newton's Method for finding the roots of a equation f(x) = 0. The technique starts from an initial guess x1 and computes a next estimate x2 by: f (x1) f'(x1) X2 = x1 We then apply the procedure again starting from x2 (in place of x1 in the right-hand-side) and we keep repeating this until successive estimates differ by less than some preset tolerance. Note that each repetition is called an iteration. Write a program called root.c which finds a root of the function f(x) = sin x of the user provided starting guess x1. Your program must consist of a main program, which opens the output file rootout.txt for ap- pending (mode = "a"), reads the initial guess (x1) and desired error tolerance (tol) from the user, calls the function newton (), described below, and writes the estimated root (root) and number of iterations(iter) required to the output file. Aside from the main, your program must consist of the following three functions; - 2e-* in the vicinity • f() which takes an argument x and returns f(x) = sin(x) – 2e¬ª, • df () which takes an argument x and returns f'(x) = cos(x) + 2e-ª • newton () which takes the initial guess x1 and the desired tolerance tol as arguments and calculates and sets (in main) both the estimated root (root) and the number of iterations (iter) required to find this root within the desired tolerance. Assume that the tolerance in this case refers to an absolute tolerance, i.e. quit when x2 – x1| < tol.="" -="">
Here is a plot of sin x – 2e-*:<br>y = sin(x) – 2exp(-x)<br>0.5<br>-0.5<br>-1<br>-1.5<br>3<br>4<br>There are roots near 1.0 and 3.0. For marking purposes run your program twice with starting<br>values of 1.0 and 3.0, both times with an error tolerance of 0.0001.<br>Your output should look like:<br>After 3 iterations the estimated root near 1.000000 is: 0.921025<br>Copy and paste your program into the box below.<br>#include <stdio.h><br>#include <math.h><br>/* function prototypes */<br>int main(void)<br>/* you fill in here */<br>return 0;<br>}<br>/* function definitions */<br>

Extracted text: Here is a plot of sin x – 2e-*: y = sin(x) – 2exp(-x) 0.5 -0.5 -1 -1.5 3 4 There are roots near 1.0 and 3.0. For marking purposes run your program twice with starting values of 1.0 and 3.0, both times with an error tolerance of 0.0001. Your output should look like: After 3 iterations the estimated root near 1.000000 is: 0.921025 Copy and paste your program into the box below. #include #include /* function prototypes */ int main(void) /* you fill in here */ return 0; } /* function definitions */
Jun 05, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here