Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Question 1 [ 3 5 marks ] The Newton - Raphson method is one of the most commonly used methods for finding roots of general
Question marks
The NewtonRaphson method is one of the most commonly used methods for finding roots of general functions. Given a function whose roots are to be found, and an initial guess the method can be used to obtain a better approximation of the root as:
The process can be repeated as:
until a sufficiently accurate approximation of the root has been obtained.
Write a function, named Newton, implementing the method in Python. Given a function, its derivative, and an initial guess for the root, the Newton function should update the solution using the above formula until a root of sufficient accuracy has been obtained or a predefined number of iterations has been performed. To determine whether solutions are sufficiently accurate, the value of the function for each candidate solution should be compared with a predefined tolerance to ensure it is sufficiently close to zero. In order to avoid zero division errors, the function should test whether the values of the function derivative are less than a predefined numerical tolerance and stop the solution if that is the case. Finally, the function should receivereturn the following inputoutput arguments:
Input arguments
floatNone Final solution obtained. In case a zero derivative is encountered, then None should be returned.
Status string, containing information about the solution. Based on how the solution progresses, it should contain the following:
In case the solution has converged, it should contain the message: 'Solution converged after iterations', where should be replaced by the number
of iterations performed.
In case the solution has not converged to the required accuracy, it should contain the message: 'Solution not found within the required accuracy,
accuracy of current solution: where is the best accuracy achieved by the method, defined as the absolute value of at the last iteration
performed.
In case a zero derivative is encountered, it should contain the message: 'Solution interrupted after iterations, zero derivative encountered' where
should be replaced by the number of the iteration where the zero derivative was encountered.
In : # YOUR CODE HERE
def Newton tole maxiterations epsilone:
NewtonRaphson method for finding roots of a function.
Parameters:
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