-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
37 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,39 @@ | ||
======================== | ||
Amount Functions | ||
======================== | ||
======================== | ||
|
||
Although we have introduced the familiar cases of simple and compound interest, not all growth patterns are linear or geometric. Sometimes a growth pattern might be geometric, cubic, or some arbitrary user-defined pattern. | ||
|
||
To accommodate these new patterns, we can define an **amount function**, which specifies how money grows for an arbitrary growth pattern: | ||
|
||
.. math:: | ||
A_K(t) | ||
Where :math:`K` specifies the amount of principal, :math:`t` specifies the amount of time, and :math:`A_K(t)` returns the value at time :math:`t` of :math:`K` invested at time 0. | ||
|
||
Examples | ||
======================== | ||
|
||
Suppose money exhibits a quadratic growth pattern, specified by the amount function: | ||
|
||
.. math:: | ||
A_K(t) = K(.05t^2 + .05t + 1) | ||
If we invest :math:`K=5` at time 0, how much does it grow to at time 5? | ||
|
||
TmVal's *Amount* class allows us to model this behavior. To solve the above problem, simply call the class and supply the growth function and principal. First, define the growth function as a Python function that takes the time and principal as arguments: | ||
|
||
.. ipython:: python | ||
from tmval import Amount | ||
def f(t, k): | ||
return k * (.05 * (t **2) + .05 * t + 1) | ||
Now supply the growth_function to the Amount class, and call :code:`my_amt.val(5)` to get the answer: | ||
|
||
.. ipython:: python | ||
my_amt = Amount(f=f, k=5) | ||
print(my_amt.val(5)) |