Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Steffensen\'s Method (pseudo-code) reliminary check for convergenc Since Steffen

ID: 2265048 • Letter: S

Question

Steffensen's Method (pseudo-code) reliminary check for convergenc Since Steffensen's method is particularly prone to floating-point error, we do ap before the Aitken's delta-squared step. This helps prevent large e Assumptions: Fixed point iteration converges to a fixed point of f with initial value to Input: Initial value zoi function f; desired accuracy tol; maximum number of iterations N. Step 1: For j = 1 . . . N do Steps 2-6: Step 2: Set x1 = f(zo); z2 = f(n) Step 3: If l-il S tol then return 2 Step 4: Set z =zo-In-ro Step 5: If a-ol S tol then return #2-211+ -zo Step 6: Set zo=z; Step 7: Print "Method failed. Maximum iterations exceeded." Output: Approximation a near exact fixed point, or message of failure.

Explanation / Answer

Following is the python code as per your question. Please note that I have converted x0 to float to make sure x0 is a float. If x0 is an integer then it may create problems. You can check this by commenting conversion line. The input are set so that method fails. Setting N = 5 method gives approximation for default f. You need to adjust the definition of f and values of x0, tol and N for your problem.

--------------------------------------------------

# Python code using while loop

def stef(x0, f, tol, N):
#convert x0 to a float as integer may create problem in f
x0 = float(x0)
  
#step 1
j = 1
while j<=N:
  
#Step 2
x1 = f(x0)
x2 = f(x1)
  
#step 3
if abs(x2-x1)<= tol:
return x2
  
#step 4
x = x0 - (x1-x0)**2/(x2-2*x1+x0)

#step 5
if abs(x-x0)<= tol:
return x
  
#step 6
x0 = x
  
#increment iterator
j = j+1
  
#step 7
print("Method Failed. Maximum iterations exceeded")

# define function f   
def f(x):
return x**0.5/3
  
# set up other inputs   
x0 = 2
tol = 0.0000000001
N = 4

# call the calculator function
x = stef(x0, f, tol, N)

# print result. If x is None then the method failed
if x!=None:
print(x)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote