Define a function called approximate_newton (f, h, x0, epsilon, maximum iterations), where f is the name of the function whose root you are trying to approximate, h is a small positive stepsize to be used in approximating the derivative of fat the different approximate roots (see approximate formula for f'(x) below), x0 is the initial guess of the root, epsilon is a small positive number used in the stopping condition of the algo- rithm, and maximum_iterations is the maximum number of iterations the method should have. This function should do an approximate version of Newton's method in which the derivative term is replaced by the following approximation to the derivative: f'(x) ≈ ƒ(x + h) − f (x) - h In the argument list of the function, epsilon should be assigned the default value of 0.00001 and maximum_iterations should be assigned the default value of 100. If the maxmimum number of iterations is exceeded, an error message should be printed stating that the method did not converge within the specified maximum number of iterations and the function should return None. The stopping condition for the main loop enacting the algorithm should be: STOP when abs(f(xn)) < epsilon for the first time OR maximum_iterations has been exceeded, where xn is the latest approximation to the root. Ensure that for each iteration of your approximate Newton's method, the following are displayed: the iteration number n; the approximate root xn; and f(xn).

Calculus For The Life Sciences
2nd Edition
ISBN:9780321964038
Author:GREENWELL, Raymond N., RITCHEY, Nathan P., Lial, Margaret L.
Publisher:GREENWELL, Raymond N., RITCHEY, Nathan P., Lial, Margaret L.
Chapter3: The Derivative
Section3.CR: Chapter 3 Review
Problem 8CR
icon
Related questions
Question

numerical mathematics 

Define a function called approximate_newton(f, h, x0, epsilon, maximum_iterations),
where
f is the name of the function whose root you are trying to approximate,
h is a small positive stepsize to be used in approximating the derivative of f at
the different approximate roots (see approximate formula for f'(x) below),
x0 is the initial guess of the root,
epsilon is a small positive number used in the stopping condition of the algo-
rithm, and
maximum iterations is the maximum number of iterations the method should
have.
This function should do an approximate version of Newton's method in which the
derivative term is replaced by the following approximation to the derivative:
-
f(x + h) − f (x)
h
ƒ'(x)≈
In the argument list of the function, epsilon should be assigned the default value
of 0.00001 and maximum_iterations should be assigned the default value of 100.
If the maxmimum number of iterations is exceeded, an error message should be
printed stating that the method did not converge within the specified maximum
number of iterations and the function should return None.
The stopping condition for the main loop enacting the algorithm should be:
STOP when abs (f(xn)) < epsilon for the first time OR maximum_iterations
has been exceeded, where în is the latest approximation to the root.
Ensure that for each iteration of your approximate Newton's method, the following
are displayed: the iteration number n; the approximate root xn; and f(xn).
Transcribed Image Text:Define a function called approximate_newton(f, h, x0, epsilon, maximum_iterations), where f is the name of the function whose root you are trying to approximate, h is a small positive stepsize to be used in approximating the derivative of f at the different approximate roots (see approximate formula for f'(x) below), x0 is the initial guess of the root, epsilon is a small positive number used in the stopping condition of the algo- rithm, and maximum iterations is the maximum number of iterations the method should have. This function should do an approximate version of Newton's method in which the derivative term is replaced by the following approximation to the derivative: - f(x + h) − f (x) h ƒ'(x)≈ In the argument list of the function, epsilon should be assigned the default value of 0.00001 and maximum_iterations should be assigned the default value of 100. If the maxmimum number of iterations is exceeded, an error message should be printed stating that the method did not converge within the specified maximum number of iterations and the function should return None. The stopping condition for the main loop enacting the algorithm should be: STOP when abs (f(xn)) < epsilon for the first time OR maximum_iterations has been exceeded, where în is the latest approximation to the root. Ensure that for each iteration of your approximate Newton's method, the following are displayed: the iteration number n; the approximate root xn; and f(xn).
Expert Solution
steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Similar questions
Recommended textbooks for you
Calculus For The Life Sciences
Calculus For The Life Sciences
Calculus
ISBN:
9780321964038
Author:
GREENWELL, Raymond N., RITCHEY, Nathan P., Lial, Margaret L.
Publisher:
Pearson Addison Wesley,
Mathematics For Machine Technology
Mathematics For Machine Technology
Advanced Math
ISBN:
9781337798310
Author:
Peterson, John.
Publisher:
Cengage Learning,
College Algebra
College Algebra
Algebra
ISBN:
9781305115545
Author:
James Stewart, Lothar Redlin, Saleem Watson
Publisher:
Cengage Learning