## Not run:
# x <- linspace(0, 15, 151); y <- sin(x)/x
# rA <- rationalfit(x, y, 10, 10); p1 <- rA$p1; p2 <- rA$p2
# ys <- polyval(p1,x) / polyval(p2,x)
# plot(x, y, type="l", col="blue", ylim=c(-0.5, 1.0))
# points(x, Re(ys), col="red") # max(abs(y-ys), na.rm=TRUE) < 1e-6
# grid()
#
# # Rational approximation of the Zeta function
# x <- seq(-5, 5, by = 1/16)
# y <- zeta(x)
# rA <- rationalfit(x, y, 10, 10); p1 <- rA$p1; p2 <- rA$p2
# ys <- polyval(p1,x) / polyval(p2,x)
# plot(x, y, type="l", col="blue", ylim=c(-5, 5))
# points(x, Re(ys), col="red")
# grid()
#
# # Rational approximation to the Gamma function
# x <- seq(-5, 5, by = 1/32); y <- gamma(x)
# rA <- rationalfit(x, y, 10, 10); p1 <- rA$p1; p2 <- rA$p2
# ys <- polyval(p1,x) / polyval(p2,x)
# plot(x, y, type="l", col = "blue")
# points(x, Re(ys), col="red")
# grid()## End(Not run)
Run the code above in your browser using DataLab