# Can compound growth and decay be expressed as a single function?

**URL:** <https://boards.straightdope.com/t/can-compound-growth-and-decay-be-expressed-as-a-single-function/803073>\
**Category:** Factual Questions\
**Created:** [November 29, 2017, 6:26pm UTC](https://boards.straightdope.com/t/can-compound-growth-and-decay-be-expressed-as-a-single-function/803073 "2017-11-29T18:26:36Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![D18](https://avatars.discourse-cdn.com/v4/letter/d/c57346/32.png) [@D18](https://boards.straightdope.com/u/D18)\
**Post date:** [November 29, 2017, 6:26pm UTC](https://boards.straightdope.com/t/can-compound-growth-and-decay-be-expressed-as-a-single-function/803073/1 "2017-11-29T18:26:36Z")

</div>

Say one invested $100 at 5% growth, annually, compounded. Assuming I’m not screwing up the formula, the value of the investment at the end of any given year can be expressed as f(t)=100(1.05)^t where t is the number of years that have elapsed since the initial investment.

Say after 20 years, the investment started to lose money at a rate of 5%, annually, compounded. The value of the investment at the end of any year can be expressed, again, assuming I’m not screwing up the formula, as f(t’)=f(20)(.95)^t’, where t’ is the number of years that have elapsed since the investment started to loss money. Say this happened for 20 years.

Is there a way of expressing the total growth and loss by a single function over the entire 40 years, rather than saying f(t) is in place for years 1 to 20 and f(t’) is in place for years 21 to 40?

---

<div class="post-metadata">

**Author:** ![Snarky\_Kong](https://avatars.discourse-cdn.com/v4/letter/s/a183cd/32.png) [@Snarky\_Kong](https://boards.straightdope.com/u/Snarky_Kong)\
**Post date:** [November 29, 2017, 6:48pm UTC](https://boards.straightdope.com/t/can-compound-growth-and-decay-be-expressed-as-a-single-function/803073/2 "2017-11-29T18:48:59Z")

</div>

f(t1,t2)=($100)(1.05)^t1\*(0.95)^(t2-t1)

Where t1 is the length of time until you start losing money and t2 is the final time.

---

<div class="post-metadata">

**Author:** ![Chronos](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/chronos/32/134_2.png) [@Chronos](https://boards.straightdope.com/u/Chronos)\
**Post date:** [November 29, 2017, 6:57pm UTC](https://boards.straightdope.com/t/can-compound-growth-and-decay-be-expressed-as-a-single-function/803073/3 "2017-11-29T18:57:21Z")

</div>

Is the change from growth to shrinking abrupt, right at 20 years? If so, then there’s not going to be any nice, clean, well-behaved way to do it. But sometimes the world isn’t nice, clean, and well-behaved, and so there’s a function called the Heaviside function for dealing with such things. The Heaviside function itself is simple: H(x) = 0 for x \< 0, and H(x) = 1 for x \> 0 (what H(0) itself is, usually isn’t worried about; you can make it 0, 1/2, or 1, but since it’s only one point, it usually doesn’t matter).

To make a piecewise function like yours, then, you’d take f(t) = H(20-t)\*f[sub]1/sub + H(t-20)\*f[sub]2/sub. For the first timespan, the first Heaviside function is 1 and the second is zero, and so you’ve just got the first function, and for the second timespan, the first Heaviside function is 0 and the second is 1, so you’ve just got the second function.

EDIT: **Snarky\_Kong** , that’s just the function for the shrinking part, which he already has. It won’t work for the growth part. The difficulty isn’t in either part; it’s in joining the two parts together.

---

<div class="post-metadata">

**Author:** ![markn\_1](https://avatars.discourse-cdn.com/v4/letter/m/f9ae1b/32.png) [@markn\_1](https://boards.straightdope.com/u/markn_1)\
**Post date:** [November 29, 2017, 7:07pm UTC](https://boards.straightdope.com/t/can-compound-growth-and-decay-be-expressed-as-a-single-function/803073/4 "2017-11-29T19:07:57Z")

</div>

You could also use the [Iverson bracket](https://en.wikipedia.org/wiki/Iverson_bracket), a somewhat more general form of the Heaviside step function or Kronecker delta. You put any boolean proposition in the function and it returns 1 if the proposition is true or 0 if it is false. So your function would be f(t) = [t\<20]\*f[sub]1/sub + [t\>=20]\*f[sub]2/sub.

---

<div class="post-metadata">

**Author:** ![naita](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/naita/32/5862_2.png) [@naita](https://boards.straightdope.com/u/naita)\
**Post date:** [November 29, 2017, 7:20pm UTC](https://boards.straightdope.com/t/can-compound-growth-and-decay-be-expressed-as-a-single-function/803073/5 "2017-11-29T19:20:32Z")

</div>

You can approximate nearly any shape with a function that is the sum of a large number of functions, but why would you want to?

---

<div class="post-metadata">

**Author:** ![D18](https://avatars.discourse-cdn.com/v4/letter/d/c57346/32.png) [@D18](https://boards.straightdope.com/u/D18)\
**Post date:** [November 30, 2017, 2:06pm UTC](https://boards.straightdope.com/t/can-compound-growth-and-decay-be-expressed-as-a-single-function/803073/6 "2017-11-30T14:06:42Z")

</div>

Thank you for your answers! I’ll look into the Heaviside and Iverson brackets.
