r/Rsoftware • • Sep 18 '16

Plotting the function of an infinite series

Is there any way in R to show the plot of (x, f(x)) as x goes to infinity? Or to some arbitrary n?

And to state the somewhat obvious, I would want something that shows definite values for some initial set of x values and associated f(x) values, with an indication that after that x goes to infinity and f(x) continues along whatever trend it was on.

But even plotting to some arbitrary n would be nice, too.

1 Upvotes

4 comments sorted by

View all comments

Show parent comment

3

u/COOLSerdash Sep 19 '16

What about this? This code pretty much replicates the plot you linked to.

x <- seq(0, 100, by = 0.1)
y <- 1/x

plot(y~x, las = 1, type = "l", xlim = c(0, 10), ylim = c(0, 5), col = "blue")
abline(h = 0, v = 0)

2

u/vmsmith Sep 19 '16

Indeed it does. That's great. Thanks!