R ^
Raise a growth factor to a power to repeat the same multiplication over several periods.
A simple example
^
- Start with 2 and 3
- Do this Raise 2 to the third power
- Result 8
cat(2.0 ^ 3.0, "\n", sep = "")
8
Syntax
factor ^ periods
Run these examples in R
Save one example at a time as Lesson.R. Use R 4.x.
Rscript --vanilla Lesson.RProject repeated doubling
A print job branches into additional copies at each round. Use the starting count and the number of rounds to project the final batch before reserving paper.
factor <- 2.0
periods <- 5.0
cat(sprintf("%.3f\n", factor ^ periods))
32.000
Five doublings turn one seedling tray into 32 trays.
Estimate copies in a branching print run
A print center branches each master copy into several copies in every round. Project the final count from the branching factor so the operator can budget paper before starting the job.
copies <- 3.0
rounds <- 4.0
cat(sprintf("%.3f\n", copies ^ rounds))
81.000
Starting with one page and tripling its copies through four rounds produces 81 pages.
Count cells after repeated subdivision
A designer starts with one square on a poster. Each round replaces every square with four smaller squares, and the design goes through three rounds.
The factor four applies three times to the starting square.
What to watch for
For exact currency, use decimal arithmetic or integer minor units and a stated rounding policy.