d1.poly: 1-dimensional Chebychev approximation

Description Usage Arguments Value See Also Examples

View source: R/d1.R

Description

Standard Chebychev approximation of an arbitrary function.

Usage

1
2
d1.poly(fn, range, iOrder, iPts, fn.opts = NULL, fn.vals = NULL,
  grid = NULL, details = FALSE)

Arguments

fn

a function f(x) or f(x,β) for β a list of function parameters. If the latter, must be coded with second argument a list names opts, i.e. fn <- function( x, opts )

range

the range of the approximation.

iOrder

the order of the polynomial approximation.

iPts

the number of points at which the approximation is computed. Must be at least as large as iOrder.

fn.opts

(optional) options passed to fn

fn.vals

the values of fn on grid. Useful if fn is very slow to evaluate.

grid

(optional) the grid on which the function is to be approximated.

details

If TRUE, returns extra details about the approximation.

Value

A function which approximates the input fn over the interval range. If details=TRUE, return is a list with entries fn, poly, fn.deriv, poly.deriv, residuals, which are, respectively, the approximating function, the polynomial desciption over [-1,1], the derivative of the approximation, the polynomial desciption of the derivative, and the approximation errors.

See Also

sp1.poly

Examples

1
2
3
cube <- function( x, opts ) opts$A * x^3
approx <- d1.poly( cube, c(-4,2), 4, 20, fn.opts=list(A=2) )
sapply( c(-3, -2, 0, .5 ), function( x ) abs( approx(x) - 2 * x ^ 3 ) )

squipbar/cheby documentation built on May 30, 2019, 8 a.m.