Description Usage Arguments Value Author(s) References Examples
Determine the argument of the minimum by polynomial or rational interpolation of given points x, y
.
1 2 3 4 5 | setupInterp(x, y, doPoly = TRUE)
evalInterp(xi, ss)
minInterp(x, y, add = FALSE, doPoly = TRUE)
quadmin(x, y)
lerp(p1, p2, t)
|
x |
vector of x-coordinates |
y |
vector of y-coordinates |
xi |
argument x of interpolation |
p1,p2 |
point coordinates for linear interpolation |
t |
0 <= t <= 1, linear interpolation distance |
ss |
setup given by setupInterp |
add |
if TRUE, one more point is used than for FALSE (default) |
doPoly |
if TRUE, polynomial interpolation is used, if FALSE, rational interpolation is used, with three points and four points respectively (latter for add=FALSE) |
setupInterp |
Generate structure |
minInterp, quadmin |
x-value of the minimum. NA if too few points are given or no minimumm exists in |
lerp |
linerly interpolated point, t=0 -> p1, t=1 -> p2 |
Christian W. Hoffmann <christian@echoffmann.ch>
Stoer, J., 1989. Numerische Mathematik 1ed. 5. Springer, Berlin. Applied and Computational Complex Analysis, Vol.2. Wiley,
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | opar <- par(mfrow=c(2,2))
x <- c(1,2,4,6); y <- 1/x
pint <- function( x, y, add, dopoly, ylab="" ) {
print(paste(" minimum at = ", minInterp(x,y,add=add,doPoly=dopoly) ) )
xP <- setupInterp(x,y,TRUE)
xT <- setupInterp(x,y,FALSE)
x0 <- seq(0,7,0.1); yP <- evalInterp(x0,xP)
yT <- evalInterp(x0,xT)
plot(x,y,xlim=c(-0.5,7.5),ylim=c(min(y)-2,max(y)+2),cex=2,ylab=ylab)
lines(x0,yP,col=2,cex=0.5)
lines(x0,yT,col=4,cex=0.5,pch="+")
legend(x="bottom",c("polynomial", "rational"), col = c(2,4),
text.col= "black", lty = 1, merge = TRUE, bg='white')
}
pint(x,y,add=FALSE,dopoly=TRUE,"1/x") # 6 ?? = minimum
pint(x, (x-3)^2,add=FALSE,dopoly=TRUE,"(x-3)^2") # 3
pint(x,x+1.0/x,add=FALSE,dopoly=FALSE,"x+1.0/x dopoly=F") # 1 -1
pint(x,x+1.0/x,add=TRUE,dopoly=TRUE,"x+1.0/x dopoly=T") # 8.3471982 0.3194685
par(opar)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.