What is the numerical solution of the fixed-point equation , ?
To calculate this, program a function
fixedPoint(f, x)
, which takes a function
f
and a starting value
x
as inputs and returns the fixed point
y = f(y)
as an output.
1 2 3 4 5 6 7 |
|
Bonus question: Why does the algorithm work?
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
A common algorithm for solving nonlinear equations is the fixed point iteration. For this the following sequence is calculated x n = f ( x n − 1 ) = n times f ( f ( … f ( x 0 ) … ) ) = ( f n ) ( x 0 ) , n ∈ N where x 0 is a suitable starting value. When this sequence converges, we can break the iteration and have found our fixpoint. The fact that this sequence converges for the cosine can be proved by the Banach fixed point theorem. The criteria for convergence are accordingly:
Then the fixed point iteration converges for a starting value x 0 ∈ I . These criteria are fulfilled in the case f ( x ) = cos ( x ) and I = [ 0 , 1 ] .
With a few lines of code you can therefore solve a non-linear equation, if the starting value has been chosen appropriately and the fixed point is stable: