**R provides a number of commands for writing output to a file**

**r <- 0.11 # Annual interest rate**

**> term <- 10 # Forecast duration (in years)**

**> period <- 1/12 # Time between payments (in years)**

**> payments <- 100**

**> r <- 0.11 # Annual interest rate**

**> n <- floor(term/period)**

**> pension <- 0**

**> (i in 1:n) {**

**for (i in 1:n) {**

**+ pension[i+1] <- pension[i]*(1 + r*period) + payments**

**+ }**

**> time <- (0:n)*period**

**> plot(time, pension)**

**> x <- seq(0, 5, by = 0.01)**

**> > y.upper <- 2*sqrt(x)**

**> y.lower <- -2*sqrt(x)**

**> y.max <- max(y.upper)**

**> y.upper <- 2*sqrt(x)**

**> y.max <- max(y.upper)**

**> plot(c(-2, 5), c(y.min, y.max), type = "n", xlab = "x", ylab = "y")**

**> plot(c(-2, 5), c(y.min, y.max), type = "n", xlab = "x", ylab = "y")**

**> y.min <- min(y.lower)**

**> plot(c(-2, 5), c(y.min, y.max), type = "n", xlab = "x", ylab = "y")**

**> lines(x, y.upper)**

**> lines(x, y.lower)**

**> abline(v=-1)**

**> points(1, 0)**

**> text(1, 0, "focus (1, 0)", pos=4)**

**> text(-1, y.min, "directrix x = -1", pos = 4)**

**> title("The parabola y^2 = 4*x")**

**> par(mfrow = c(2, 2), mar=c(5, 4, 2, 1))**

**> curve(x*sin(x), from = 0, to = 100, n = 1001)**

**> curve(x*sin(x), from = 0, to = 10, n = 1001)**

**> curve(x*sin(x), from = 0, to = 1, n = 1001)**

**> curve(x*sin(x), from = 0, to = 0.1, n = 1001)**

**> par(mfrow = c(1, 1))**

## No comments:

## Post a comment