Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
For fun, ask your banker or investment advisor why the Rule of 72 works.
It works because in the short run, it’s a linear world – approximately. A little more mathematical is that, in a small enough neighborhood, any differentiable function is approximately linear.
For the Rule of 72 we are solving for n in the equation 1 * (1 + i/100) n = 2. We take natural logarithms of both sides:
1 * (1 + i/100) n = 2
LN (1 + i/100) n = LN 2
n * LN (1 + i/100) = LN 2
n = LN 2 / LN (1 + i/100)
n ≈ .693 / LN (1 + i/100)
n ≈ .693 / (i/100)
n ≈ 69.3 / i
n ≈ 72 / i
The key step three lines above is that for small values of x, LN (1 + x) is approximately equal to x. One way to see this is that the Taylor series (sorry, not invented by Taylor Swift) expansion around a = 0 is:
LN (1+x) = x – x 2 / 2 + x 3 / 3 – x 4 / 4 + … .
For small x, LN (1+x) is approximately equal to x.
In the following plots, the plot on the left shows that the logarithmic function 1 of y = LN (1 + x) is surely different than the linear function 2 of y = LN (1.05) + (1/1.05)*(x – .05). Function 2 is the equation of the tangent line to function 1 at x = .05. (To derive the tangent line, recall from calculus that if y = LN(1 + x), then dy/dx = 1/(1 + x) ). The plot on the right is of the same two functions, but with the x range shrunk to (0.0, 0.1). In this small range the two functions are indistinguishable. In this small neighborhood, the differentiable function y = LN(1 + X) is indistinguishable from its linear tangent.
Of course a “Rule of 69.3”, where LN 2 is .693 to three decimal places, would be a better approximation to the compound interest formula than the “Rule of 72”, but 72 is close enough and is useful because 72 has so many integer divisors.
In the real world we often assume linearity holds within a small range. For example in cooking a turkey (not that I have ever done this), one website says to allow about 15 minutes per pound (on average!) at 350°F to cook a stuffed turkey. But their time estimates by pound are not linear, so for example their time estimate to cook a 24-pounder is less than twice as long to cook a 12-pounder. Perhaps a better approximation is a power curve y = a * (x b) . Presumably there are some physics considerations that are non-linear.
The Newton-Raphson method, x n+1 = x n – f (x n ) / f ‘ (x n ), for finding approximations to roots of a function, is an example of a mathematical use of linearity. N-R iteratively finds the x-intercept of the tangent of the graph of f. A number of R packages have N-R functions.
And before we end the subject of “it’s a linear world – approximately”, you can certainly measure the straight line distance between two cities, but if you travel by airplane, the airplane is flying the distance between two points on a sphere. Given the latitude and longitude coordinates and the central angle between the two points, the spherical distance can be calculated by the Haversine Formula.
R makes it easy not to settle for linearity. But for those of who are not doing something where great precision is required, linearity may be just fine,
Here is the R-code to plot the graphs. Note that in R, log(x) is the natural log function. This is also true in Python and Excel.
library(ggplot2) common_theme <- theme( legend.position="right", plot.title = element_text(size=15, face="bold"), plot.subtitle = element_text(size=12.5, face="bold"), axis.title = element_text(size=15, face="bold"), axis.text = element_text(size=15, face="bold"), axis.title.y = element_text(angle = 0), legend.title = element_text(size=15, face="bold"), legend.text = element_text(size=15, face="bold")) a <- 0.0 b <- 1.0 x_values <- seq(a, b, by = 0.01) func1 <- function(x) {log(1 + x)} func2 <- function(x) {log(1.05) + (1/1.05)*(x - .05)} df1 <- data.frame(x = x_values, y = log(1 +x_values), func = "Function 1") df2 <- data.frame(x = x_values, y = log(1.05) + (1/1.05)*(x_values - .05), func = "Function 2") combined_df <- rbind(df1, df2) ggplot(combined_df, aes(x = x, y = y, color = func)) + geom_line(size = 1.5) + scale_color_manual(values = c("Function 1" = "#E41A1C", "Function 2" = "royalblue4")) + ylim(c(0, 1)) + labs(title = "Plot of LN and Linear Functions", x = "x", y = "y", color = "Functions") + common_theme ggplot(combined_df, aes(x = x, y = y, color = func)) + geom_line(size = 1.5) + scale_color_manual(values = c("Function 1" = "#E41A1C", "Function 2" = "royalblue4")) + xlim(c(0, 0.1)) + ylim(c(0, 0.11)) + labs(title = "Plot of LN Function and its Tangent Line at x = .05", x = "x", y = "y", color = "Functions") + common_themeEnd < >
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.