Description Usage Arguments Details Value Examples
A poor-man's approximation on uniform grids. If you for some reason can't evaluate your function on a Chebyshev-grid, but instead have a uniform grid, you may use this function to create an interpolation.
1 2 3 |
... |
Further arguments to |
val |
Array. Function values on a grid. |
intervals |
List of vectors of length two. Specifying the hypercube extent in each dimension |
fun |
Function to be interpolated. |
dims |
Integer. Number of grid points in each dimension. |
This does about the same as chebappxg for unform grids, though
no grid map function is constructed, as a fixed such function is used.
A Chebyshev-interpolation ch is made for val with
chebappx. Upon evaluation the uniform grid in each dimension
is mapped differentiably to the Chebyshev-knots so that ch is
evaluated in sin(0.5*pi*x*(1-n)/n) where n is the number of knots
in the dimension, possibly after x has been remapped from the
hypercube interval to [-1,1].
Thus, the interpolation is not a polynomial.
For ucappx the function values are provided, the number of grid
points in each dimension is to be found in dim(val). For
ucappxf the function to be interpolated is fun, and the number
of grid points is passed in dims.
As the example shows, this approximation is better than the Chebyshev approximation for some functions.
A function(x) defined on the hypercube, approximating the
given function.
1 2 3 4 5 6 7 8 9 10 11 12 | ## Not run:
# Runge function
f <- function(x) 1/(1+25*x^2)
grid <- seq(-1,1,length.out=15)
val <- f(grid)
uc <- Vectorize(ucappx(val))
# and the Chebyshev
ch <- Vectorize(chebappxf(f,15))
# test it at 10 random points
t(replicate(10,{a<-runif(1,-1,1); c(arg=a, uc=uc(a), true=f(a), cheb=ch(a))}))
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.