I'm trying a problem but first I have to plot in r
(x+1)(x+2)...(x+n),
with n being a fixed integer.
Any idea how to create this routine?
I'm trying a problem but first I have to plot in r
(x+1)(x+2)...(x+n),
with n being a fixed integer.
Any idea how to create this routine?
Provided x is greater than -1, this might be most efficiently computed by exploiting the relationship
(x + 1)*(x + 2)* ... *(x + n) = Gamma(x+n+1) / Gamma(x+1).
Gammas are computed internally in terms of their logarithms, so use these logs in the form of lgamma:
f <- function(x, n) exp(lgamma(x+n+1) - lgamma(x+1))
A plot can then be obtained via curve, for instance, as in
curve(f(x,3), 0, pi)
 
    
    You want something like this?
f <- function(x, n) {
  return(prod(1/(x+(1:n))))
}
