1. Calculate: \[ S_{1} = 1 + 2 +...+ 2020 \]
x <- c(1:2020)
sum(x)
## [1] 2041210
2. Calculate \[ S_{2} = 1^2 + 2^2 +...+ 2020^2 \]
x <- c(1:2020)
sum(x^2)
## [1] 2749509870
3. Calculate \[ S = \frac{1^3 + 2^3 +...+ 2020^3}{2020} \]
x <- c(1:2020)
sum(x^3)/2020
## [1] 2062642705
# Or
mean(x^3)
## [1] 2062642705
4. Calculate \[ S = 1\cdot 2 + 3 \cdot 4 + 5 \cdot 6 + 7 \cdot 8 +...+ 2019 \cdot 2020 \]
x <- seq(1, 2019, 2)
y <- seq(2, 2020, 2)
sum(x*y)
## [1] 1374754430
5. Calculate \[ S = \frac{1}{2} + \frac{2}{3} + \frac{3}{4} + ...+ \frac{2020}{2021} \]
x <- c(1:2020)
y <- c(2:2021)
sum(x/y)
## [1] 2012.811
6. Is this summation convergent or divergent?
\[ S = 1+\frac{1}{4}+\frac{1}{9}+\frac{1}{16}+\frac{1}{25}+... \]
\[ S = 1+\frac{1}{2^2}+\frac{1}{3^2}+\frac{1}{4^2}+\frac{1}{5^2}+... \]
# The sum of the first 1000 terms
n <- 1000
x <- c(1:n)
sum(1/x^2)
## [1] 1.643935
# The sum of the first 10000 terms
n <- 10000
x <- c(1:n)
sum(1/x^2)
## [1] 1.644834
The series converges!