Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a program that finds an approximation to the solution of the equation cos (x) = x using Newton's method. It is forbidden to use
Write a program that finds an approximation to the solution of the equation cos (x) = x using Newton's method.
It is forbidden to use break, nor any other instruction not explained in class until now.
INPUT:
1. x0 = Initial approximation
2. MaxIter = Maximum iterations: in case the method fails
3. TOL = Tolerance for the difference of successive approximations, which will be one of the criteria to complete the cycle that generates the approximations. If the absolute value of the difference of two successive approximations is less than TOL ends cycle.
4. TOLZERO: remember that if the derivative is equal to zero in the generated approximation, the method fails. Another of the criteria to complete the cycle would be if the absolute value of the derivative evaluated in the approximation is less than TOLZERO.
OUTPUT:
1. In the case that the method does not fail, print the approximations generated by method 2. Message indicating that the maximum number of iterations allowed is passed if that is the case.
3. Message indicating that the method fails because the derivative is equal to zero if that is the case.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started