iterate: Perform a point iteration

Description Usage Arguments Value Examples

View source: R/iterate.R

Description

Run a point iteration, saving intermediate values. This is a convenient building block for convergence acceleration.

Usage

1
iterate(x, f, n, save = TRUE, ...)

Arguments

x

the start value of the iteration (not saved)

f

the function that performs the iteration

n

the number of iterations to do

save

do we save the iteration history?

...

extra arguments for f

Value

the output of the iteration. If save is TRUE, it has an attribute 'history', which gives the iteration history as a length(x) x n matrix.

Examples

1
2
iterate(0.2, cos, 100, save=FALSE)
iterate(c(-1, 1), function(x) { - x }, 100)

pdmetcalfe/extrapolatr documentation built on June 12, 2021, 8:09 p.m.