0
from numpy import log as ln def g(x): return ln(4+x-x**2) def FixedPoint(p0,tolerance): p = g(p0) abs_error = abs(p-p0) p0 = p while abs_error>=tolerance: p = g(p0) abs_error = abs(p-p0) p0 = p return p starting_point = 2 tolerance = 10**-10 fixed_point = FixedPoint(starting_point,tolerance) print('Fixed-point of g(x) = {0} is x = {1:.7f}'.format(formula,fixed_point)) 

So, i have this fixed point root finding algorithm to find the root of ln(4+x-x^2), how do i add the aitken sequence program to increase the rate of convergence of finding the root of ln(4+x-x^2). im having trouble in keeping the value of each iterations.

1
  • I hope you are solving exp(x)=4+x-x^2. What did you already try for Aitken's delta squared process? It could look similar to math.stackexchange.com/a/3109837/115115 Commented Nov 5, 2019 at 11:00

1 Answer 1

1

I would reduce the number of lines in the fixed-point iteration via

def FixedPoint(p0,tolerance): p1 = g(p0) while abs(p1-p0)>=tolerance: p0,p1 = p1,g(p1) print(p0) return p1 

This requires 29 evaluations of g for the given test case

The Aitken delta-squared process can be implemented as

def FixedPointAitken(p0,tolerance): while True: p1=g(p0); p2=g(p1); print(p0,p1,p2) if abs(p1-p0)<tolerance: break p0 = p0 - (p1-p0)**2/(p0+p2-2*p1) return p0 

This requires 5 steps with 15 evaluations of g to reach the target accuracy.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.