Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

use python need 3-5 3.(4 points) Modify fixedpoint.py to perform fixed point iterations on g(x) = x^3 starting from x = 0.5 with tolerance =

use python image text in transcribed
image text in transcribed
need 3-5
3.(4 points) Modify fixedpoint.py to perform fixed point iterations on g(x) = x^3 starting from x = 0.5 with tolerance = 1e- 15. Which root did it converge to? How many iterations did it take? What is the exact forward error? What is the exact backward error? Provide the errors in scientific notation with at least 4 significant digits. 4. (5 points) Modify fixedpoint.py to add an iteration counter and modify the termination criteria so it terminates when either the desired tolerance has been reached *or* the maximum number of iterations has been reached. (Hint: the while statement will have an *and* in it.) Attach the code here. 5. (8 points) Set the maximum number of iterations to 10 (tolerance is still 1e-15) and try to estimate each of the other two roots by starting slightly above the real root. Then try to do it by starting slightly below the root. Report the results of all four attempts: what is the method converging to, if anything? After how many iterations does it terminate? 1 import math 2 3 # define g(x) 4 def g(x): 5 return math.cos(x) 6 7 def fp(g, startpoint, tolerance): 8 x = startpoint # initialize x to the starting point 9 # while x and g(x) are too far apart 10 while abs(x-g(x)) > tolerance: 11 x = g(x) # compute new value of x by setting it to g(x) 12 print(x) # print x 13 return x # return the result 14 15 print('Fixed point estimate: ', fp(g,0.5, 1e-7)) 16

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

Learning MySQL Get A Handle On Your Data

Authors: Seyed M M Tahaghoghi

1st Edition

0596529465, 9780596529468

Students also viewed these Databases questions