Your grandparents have an annuity. The value of the annuity increases each month by an automatic deposit of 1% interest on the previous month’s balance. Your grandparents withdraw $1,000 at the beginning of each month for living expenses. Currently, they have $50,000 in the annuity. Model the annuity with a dynamical system. Will the annuity run out of money? When? Hint: What value will an have when the annuity is depleted?
The changes to the annuity can be model as follow for a given month, the amount of the annuity will be assess by:
Hence, \({ a }_{ n }\quad =\quad ({ a }_{ n-1 }\quad +\quad 0.01\cdot { a }_{ n-1 })\quad -\quad w\), where \({ a }_{ 0 }\quad =\quad 50,000.00\) and w = 1,000.00
or, \({ a }_{ n }=1.01\times { a }_{ n-1 }\quad -w\), where \({ a }_{ 0 } =50,000.00\) and w = 1,000.00
Let us calculate a few terms, we would like to know when the annuity will be depleted. In our model, that correspond the n value for \({ a }_{ n }\) to be zero.
a1 = (50,000.00 + 0.01x50,000.00) - 1,000.00 = 49,500.00
a2 = (49,500.00 + 0.01x49,500.00) - 1,000.00 = 48,995.00
a3 = (48,995.00 + 0.01x48.995.00) - 1,000.00 = 48,484.95
We will built the successive iterations with r code.
a <- 50000
i_rate <- 0.01
w <- 1000
n <- 0
loop_indicator <- TRUE
a_n <- double()
while(loop_indicator){
n <- n + 1
b <- a*i_rate + a - w
a <- b
a_n <- c(a_n, b)
a_n
n
if(b<=0){
loop_indicator <- FALSE
}
}
lst_mth <- n
amt_lst_mth <- round((a_n[n-1]*0.01) + a_n[n-1], 2)
It will take 70 months for the annuity to be depleted. On this month, our grand-parents would only be able to withdraw = 661.83
The data in the accompanying table show the speed n (in increments of 5 mph) of an automobile and the associated distance \({ a }_{ n }\) in feet required to stop it once the brakes are applied.
For instance, n = 6 (representing 6 x 5 = 30 mph) requires a stopping distance of \({ a }_{ 6 }\) = 47 ft.
Calculate and plot the change \(\Delta { a }_{ n }\) versus n.
Does the graph reasonably approximate a linear relationship?
Based on your conclusions in part (a), find a difference equation model for the stopping distance data. Test your model by plotting the errors in the predicted values against n. Discuss the appropriateness of the model.
n | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
\({ a }_{ n }\) | 3 | 6 | 11 | 21 | 32 | 47 | 65 | 87 | 112 | 140 | 171 | 204 | 241 | 282 | 325 | 376 |
\(\Delta { a }_{ n }\) | 3 | 5 | 10 | 11 | 15 | 18 | 22 | 25 | 28 | 31 | 33 | 37 | 41 | 43 | 51 |
We will now plot the graph.
library(ggplot2)
# Set variables
n_vector <- seq(1, 15, 1)
delta_a <- c(3, 5, 10, 11, 15, 18, 22, 25, 28, 31, 33, 37, 41, 43, 51)
dt <- cbind.data.frame(n_vector, delta_a)
g <- ggplot(dt, aes(x=n_vector, y=delta_a)) + geom_point(colour = "blue")
g <- g + xlab("n") + ylab("Delta")
g
From the graph, it appears that the graph approximate a positive relation. Further more, it looks like the slope of the line = 3 and the y-intercept = 0. We will add this line to the graph and determine whether this is a fit.
g <- g + geom_abline(intercept = 0, slope = 3)
g
From the graph, it appears that \(\Delta { a }_{ n+1 }\) = 3.n or \({ a }_{ n }\) - \({ a }_{ n-1}\) = 3.(n-1)
This would lead to \({ a }_{ n }\) = \({ a }_{ n-1 }\) + 3.(n-1) and \({ a }_{ 1 }\) = 3
We will now calculate the values of \({ a }_{ n }\) based on our model.
n | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
\({ a }_{ n }\) | 3 | 6 | 11 | 21 | 32 | 47 | 65 | 87 | 112 | 140 | 171 | 204 | 241 | 282 | 325 | 376 |
predicted \({ a }_{ n }\) | 3 | 6 | 12 | 21 | 33 | 48 | 66 | 87 | 111 | 138 | 168 | 201 | 237 | 276 | 318 | 363 |
Error | 0 | 0 | -1 | 0 | -1 | -1 | -1 | 0 | 1 | 2 | 3 | 3 | 4 | 6 | 7 | 13 |
error <- c(0, 0, -1, 0, -1, -1, 0, 1, 2, 3, 3, 4, 6, 7, 13)
dt_error <- cbind.data.frame(n_vector, error)
g_e <- ggplot(dt_error, aes(x=n_vector, y=error)) + geom_point(colour = "red")
g_e <- g_e + xlab("n") + ylab("Errors")
g_e <- g_e + geom_abline(intercept = 0, slope = 0, colour = "red")
g_e
The line represent no error, it is clear that the model breaks down for higher values of n as the error is increasing. This would be expected as larger n would make the error more apparent.
Consider the spreading of a rumor through a company of 1000 employees, all working in the same building. We assume that the spreading of a rumor is similar to the spreading of a contagious disease
(see Example 3, Section 1.2) in that the number of people hearing the rumor each day is proportional to the product of the number who have heard the rumor previously and the number who have not heard the rumor.
This is given by \({ r }_{ n+1 }={ r }_{ n }\quad +\quad k{ r }_{ n }(10000-{ r }_{ n })\), where k is a parameter that depends on how fast the rumor spreads and n is the number of days.
Assume k=0.001 and further assume that four people initially have heard the rumor. How soon will all 1000 employees have heard the rumor?
Let us calculate a few terms, note that \({ r }_{ 0 }=4\)
r1 = 4 + 0.001x4(1000-4)=7.984 r2 = 7.984 + 0.001x7.984(1000-7.984) = 15.904
We will write r code to perform the successive iterations. We are looking for n when \({ r }_{ n }\)=1000.
Please note that since we are dealing with person, we will truncate our result to the interger closed to zero. hence, for example, 9.99991 will be consider 9 persons (not 10)
p <- 1000
n <- 0
r0 <- 4
k <- 0.001
r <- r0
loop_continue <- TRUE
r_n <- double()
while(loop_continue){
n <- n + 1
b <- r
r <- b + k*b*(p-b)
i <- trunc(r)
r_n <- c(r_n, i)
if(i>=p){
loop_continue <- FALSE
}
}
It will take 14 days for the rumor to spread to all 1000 employees.
We will now graph the progression of the rumor by plotting numbers of persons that heard the rumors vs the number of days.
# Set variables
n_vector <- seq(1, 14, 1)
dt <- cbind.data.frame(n_vector, r_n)
g3 <- ggplot(dt, aes(x=n_vector, y=r_n)) + geom_point(colour = "blue")
g3 <- g3 + xlab("Days") + ylab("Rumor Spreading")
g3 <- g3 + geom_text(aes(label = r_n, y=r_n-50), size = 3)
g3
From the graph and the data calculated it is clear that the spreading of the rumor is very fast until we reach day = 10 where the rumor has reach 983 people. It will take another 4 days to reach all 1000 employees (we have selected to truncate the results).