Purpose
To Visualize lim sup

> getInterval <- function(n) {
+     if (n%%2 != 0) {
+         a <- 1/3 - 1/(n + 1)
+         b <- 1 + 1/(n + 1)
+     }
+     else {
+         a <- 1/(n + 1)
+         b <- 2/3 - 1/(n + 1)
+     }
+     res <- c(a, b)
+     sort(res)
+ }
> N <- 1000
> par(mfrow = c(2, 1))
> result <- numeric(0)
> i <- 1
> cols <- rainbow(20)
> plot.new()
> for (i in 1:20) {
+     interval <- getInterval(i)
+     x <- seq(interval[1], interval[2], length.out = 100)
+     result <- c(result, x)
+     par(new = T)
+     plot(sort(result), rep(i, length(result)), col = cols[i],
+         xlim = c(0, 1), ylim = c(1, 20), pch = 19)
+     par(new = T)
+ }
> par(new = F)
> result <- numeric(0)
> i <- 1
> cols <- rainbow(20)
> plot.new()
> for (i in 10:20) {
+     interval <- getInterval(i)
+     x <- seq(interval[1], interval[2], length.out = 100)
+     result <- c(result, x)
+     par(new = T)
+     plot(sort(result), rep(i, length(result)), col = cols[i],
+         xlim = c(0, 1), ylim = c(1, 20), pch = 19)
+     par(new = T)
+ }
> par(new = F)

LimSup_LimInf-001.jpg

To Visualize lim inf

> getInterval <- function(n) {
+     if (n%%2 != 0) {
+         a <- 1/3 - 1/(n + 1)
+         b <- 1 + 1/(n + 1)
+     }
+     else {
+         a <- 1/(n + 1)
+         b <- 2/3 - 1/(n + 1)
+     }
+     res <- c(a, b)
+     sort(res)
+ }
> N <- 1000
> par(mfrow = c(2, 1))
> result <- numeric(0)
> i <- 2
> cols <- rainbow(20)
> plot.new()
> for (i in 1:20) {
+     temp <- numeric(0)
+     j <- 1
+     for (j in 1:i) {
+         interval <- getInterval(j)
+         temp <- c(temp, interval)
+     }
+     interval <- sort(temp)[1:2]
+     x <- seq(interval[1], interval[2], length.out = 100)
+     result <- x
+     par(new = T)
+     plot(sort(result), rep(i, length(result)), col = cols[i],
+         xlim = c(0, 1), ylim = c(1, 20), pch = 19)
+     par(new = T)
+ }
> par(new = F)
> result <- numeric(0)
> i <- 1
> cols <- rainbow(20)
> plot.new()
> for (i in 10:20) {
+     temp <- numeric(0)
+     j <- 1
+     for (j in 1:i) {
+         interval <- getInterval(j)
+         temp <- c(temp, interval)
+     }
+     interval <- sort(temp)[1:2]
+     x <- seq(interval[1], interval[2], length.out = 100)
+     result <- x
+     par(new = T)
+     plot(sort(result), rep(i, length(result)), col = cols[i],
+         xlim = c(0, 1), ylim = c(1, 20), pch = 19)
+     par(new = T)
+ }
> par(new = F)

LimSup_LimInf-002.jpg