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) x2 = x1 f'(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 – 2e¬® in the vicinity 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; • 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.
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) x2 = x1 f'(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 – 2e¬® in the vicinity 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; • 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.
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
in C++
![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.
- r.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F0ea15aad-ce09-44c1-ae1a-fd69c581a5af%2F2b005539-a69e-43a7-b80a-c104b16411ec%2Fsla7pwg_processed.png&w=3840&q=75)
Transcribed Image 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.
- r.
![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 <stdio.h>
#include <math.h>
/* function prototypes */
int main(void)
/* you fill in here */
return 0;
}
/* function definitions */](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F0ea15aad-ce09-44c1-ae1a-fd69c581a5af%2F2b005539-a69e-43a7-b80a-c104b16411ec%2Fakdjcyu_processed.png&w=3840&q=75)
Transcribed Image 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 <stdio.h>
#include <math.h>
/* function prototypes */
int main(void)
/* you fill in here */
return 0;
}
/* function definitions */
Expert Solution
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Recommended textbooks for you
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY