Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python coding question a The Newton-Raphson Method Be sure to watch the video introducing the Newton-Raphson method before proceeding We begin our exploration of numerical

Python coding question
image text in transcribed
image text in transcribed
a The Newton-Raphson Method Be sure to watch the video introducing the Newton-Raphson method before proceeding We begin our exploration of numerical methods with a cool algorithm for finding the roots (zeros) of a function: the Newton-Raphson method, sometimes simply called Newton's method. Between 1665 and 1666, Isaac Newton (1642 - 1727) spent his days under lockdown in his countryside home at Woolsthorpe, England while the Great Plague was ravaging London. During these so-called "plague years" Newton was free to think, observe, and create. His many discoveries from this productive period of his life include the development of calculus, the laws of classical mechanics, the theory of gravitation, and the workings of optics. Among these massive achievements was a little algorithmic gem that we will now discuss. The algorithm The algorithm in question - which later became known simply as "Newton's Method" or the "Newton-Raphson Method" after Joseph Raphson (c. 1648 - c. 1715) who elaborated on the algorithm - could be used to find the roots of an arbitrary function. Finding a root of a function f() just means finding a value of such that t) = 0. Newton's method involves computing a series of increasing accurate estimates of the root as follows: 1. Choose an initial value for the root, 7, and call it to 2. Compute an improved estimate x142 11 - where f[?[?][?](x) is the derivative of f(x). 3. Go back to step 2 The above generates an intinite sequence of t; In practice we stop as soon as we have a sufficiently good" estimate of the actual root, as will be explained in the information panels and questions that follow. Write a function called newton_sartalpho, x0, tolerance that takes a non-negative floating point value alpha and calculates the positive square root of atpha to the specified tolerance, using the value xe as the first estimate. The algorithm should be exactly as in the previous question, but you will need to modify the function f(x) to take an additional parameter, Notes: You may not use anport for this question. The string '**' must not appear anywhere in your program. If you need to calculate , use * * *not x + 2. For example: Test Result The first FOUR tests are as in the previous question. 1.000000 . In this one the initial value satisfies the termination # condition. ans = newton_sqrt(1.5, 1.0, 0.5) print("ans:0.71)") ans - newton_sqrt{1.5, 2.5, 1.6) 1.5500000 printf(ansi 0.7+)") 4 Answer: (penalty regime: 0, 10, 20,...) Reset answer 1 Newton's square root finder www 2 3.def f(x, alpha): win Function to be solved 5 return xx - alpha 6 7def f prime(): 8 Derivative of the function to be solved *** 9 return 2x 10 11def newton sart(alpha, xo, tolerance) 12 Computes the square root of alpha using Newton's method 13 14 * Your code goes here. Don't forget to test your code in Wing

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_2

Step: 3

blur-text-image_3

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

Securing SQL Server Protecting Your Database From Attackers

Authors: Denny Cherry

3rd Edition

0128012757, 978-0128012758

More Books

Students also viewed these Databases questions