Description Usage Arguments Details Value References See Also Examples
Interpolate a monotone function from a two-column table
1 2 | pcderiv(x,fn)
pcinterpolate(x,fn,deriv,xnew)
|
x |
vector of x values |
fn |
function values corresponding to each value in x |
deriv |
vector of (estimated) derivative values assuming monotonicity, output of pcderiv and input to pcinterpolate |
xnew |
vector of new x values to interpolate values of the function. |
The monotone piecewise cubic interpolation algorithm is from the references given below.
deriv |
for pcderiv, estimated derivatives at x values |
y |
for pcinterpolate, length(xnew) x 2 matrix of interpolated fn values and derivatives |
Fritsch FN and Carlson RE (1980), Monotone piecewise cubic interpolation. Siam J Numerical Analysis, 17, 238-246.
Kahaner D, Moler CB and Nash S (1989). Numerical Methods and Software Prentice Hall.
1 2 3 4 5 6 7 8 9 10 11 | n=21
x=seq(0,pi/2,length=n)
fn=sin(x)
der=pcderiv(x,fn)
print(cbind(der,cos(x)))
xnew=seq(.05,1.,.05)
out=pcinterpolate(x,fn,der,xnew)
fval=sin(xnew)
print(cbind(out[,1],fval,abs(out[,1]-fval)))
cat("max err in deriv : ", max(abs(der-cos(x))), "\n")
cat("max err in interp : ", max(abs(out[,1]-fval)), "\n")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.