fp: Turn a function into a fixed point iteration

Description Usage Arguments Value Author(s) See Also Examples

Description

Given a function f, return g such that g(x) is a fixed point of f (or at least an approximate one). Generally speaking the idea will be iterate f(f(f(f(....f(x))))) until a fixed point is reached, which of course may fail entirely if there are no stable fixed points.

Usage

1
fp(f)

Arguments

f

a function

Value

g another function

Author(s)

Simon Barthelme

See Also

iter (for fixed length iterations), viewer (for viewing intermediate results), store (for storing them)

Examples

1
2
3
4
5
6
7
8
#This function has a fixed point at x = 0, i.e. 0/2 = 0
f <- function(x) x/2
g <- fp(f)
g
g(3) #The fixed point is only approximate.
g(-2) 
#The default criterion is all.equal(f(x),x). Check:
all.equal(g(3),f(g(3)))

dahtah/fixedpoints documentation built on May 14, 2019, 3:25 p.m.