dn.poly: Mutli-dimensional Chebychev approximation

Description Usage Arguments Value See Also Examples

View source: R/dn.R

Description

Standard Chebychev approximation of an arbitrary function. **Currently only works for two-dimensional approximation**

Usage

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

Arguments

fn

a function f(x_1,..., x_n) or f(x_1, ..., x_n,β) 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, given as a list of vectors. Eg for a 3-dimensional function approximated over [1,2] * [-1,2] * [0,4], would be range = list( c(1,2), c(-1,2), c(0,4) )

iOrder

the vector of orders of the polynomial approximation. Eg. to approximate using polynomials of order 3 and 5 in the 1st and 2nd dimensions respectively, would be iOrder=c(5,6)

iPts

the vector of number of points at which the approximation is computed. Must be at least as large as iOrder (element-by-element).

fn.opts

(optional) options passed to fn [NOT YET FUNCTIONAL]

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. Should be submitted as a list of vectors for the grids in each dimension.

details

If TRUE, returns extra details about the approximation.

Value

A function which approximates the input fn over the box defined by range. If details=TRUE, also includes the polynomial desciption over [-1,1], as well as the approximation errors

See Also

d1.poly

Examples

1
2
3
4
5
6
7
test.fn <- function( x,y ) x^2*y^.5
ff <- dn.poly( test.fn, list( c(0,4), c(0,4) ), c( 6, 6), c(12,12) )
XX <- seq(0,4,.05)
plot( XX, mapply( test.fn, XX, 1 ), type='l' )
lines( XX, mapply( ff, XX, 1 ), col=2 )
plot( XX, mapply( test.fn, 1, XX ), type='l' )
lines( XX, mapply( ff, 1, XX ), col=2 )

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