Including packages:

#install.packages("sp")

Loading the libraries:

library(sp)

Defining the logistic growth functions:

x <- c(-100:100)/100 # A vector of values in the interval of interest. 

g <- function(arg1) {
  #print(2*arg1*(.5-arg1)*(1-arg1))
  #print(2*arg1*(1-arg1))
  #print(2.2*arg1*(1-arg1)*(arg1+1))
  print(10*arg1*(.5-arg1)*(arg1+.5))
}

Initializing values:

p <- c(0:20)
lin <- array(c(p,p),dim = c(40,2), dimnames = list(c(1:40),c("x","y"))) # to plot the line y=x

Setting the \(x_0\) value.

x0 <- -0.4

Plotting \(y=x\) and \(y=g(x)\)

plot(x,x, col = "red", type = "l",ylab = "y")
lines(x,g(x), col = "blue", add = T)

Iterating the steps of the function:

plot(x,x, col = "red", type = "l",ylab = "y")
lines(x,g(x), col = "blue", add = T)

for(i in c(1:20)) {
  points(x0, g(x0), col = "blue")
  lin[2*i-1,] <- c(x0,x0)
  lin[2*i,] <-  c(x0,g(x0))
  x0 <- g(x0)
}

lines(lin)