Answered step by step
Verified Expert Solution
Link Copied!

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 1[35 marks]
The Newton-Raphson method is one of the most commonly used methods for finding roots of general functions. Given a function f(x), whose roots are to be found, and an initial guess x0, the method can be used to obtain a better approximation of the root as:
x1=x0-f(x0)f'(x0).
The process can be repeated as:
xn+1=xn-f(xn)f'(xn)
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 receive/return the following input/output arguments:
Input arguments
float/None 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 n iterations', where n 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: a, where a is the best accuracy achieved by the method, defined as the absolute value of f at the last iteration
performed.
In case a zero derivative is encountered, it should contain the message: 'Solution interrupted after n iterations, zero derivative encountered' where n
should be replaced by the number of the iteration where the zero derivative was encountered.
In [1]: # YOUR CODE HERE
def Newton , tol=1e-10, maxiterations =28, epsilon=1e-14):
(.....
Newton-Raphson method for finding roots of a function.
Parameters:
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Systems

Authors: Sham Navathe,Ramez Elmasri

5th Edition

B01FGJTE0Q, 978-0805317558

More Books

Students also viewed these Databases questions

Question

3. Outline the four major approaches to informative speeches

Answered: 1 week ago

Question

4. Employ strategies to make your audience hungry for information

Answered: 1 week ago