# finance calculator

Version 4.5 2015.11.23

(double-click any word to see its definition)

Instructions: Type in four known values, then press one of the buttons at the right to compute the unknown value.

*(to solve an example problem, press the “$fv$” button above)*

Interest computation is not a simple matter of applying an equation, and many problems have more than one solution, only one of which is likely to be meaningful. If you get an interest rate that doesn’t seem right, try entering an approximation of the expected rate, then press “$ir$” again.

The variables used are:

- $pv$ (present value) = The starting balance in an account. This number can be zero, positive (when you take out a loan), or negative (when you make a deposit).
- $fv$ (future value) = The ending balance after the specified number of payment periods ($np$).
- $np$ (number of periods) = The number of payment periods, usually expressed in months.
- $pmt$ (payment) = The amount of each periodic payment, usually a negative amount.
- $ir$ (interest rate) = The per-period interest rate on the account.

These equations are similar to those used to calculate Population Increase , but they allow you to specify interest and payments as separate variables.

### ** An Example **

Let’s say you want to know how much money you will have in an investment that has an annual interest rate of 12%. The account has a starting balance of \$0.00 and you are planning to deposit \$100 per month. For the interest rate per period (per month in this case), divide the annual interest rate of 12% by 12 = 1% per month (is this correct?). Result: in 10 years (120 months) you will have a balance of \$23,003.87 (click here to test this result with the calculator above).

### ** Equation List **

Here are the equations for all the directly computable forms this problem can take, including the variations created by choosing payment-at-beginning and payment-at-end.

**Payment at Beginning:**

When using these equations, be sure to use negative values for owed balances and money paid into the account, positive values for balances in your favor and money withdrawn from the account. For these equations, enter percentages as ratios, thus 8% = 0.08 yes, the financial calculator at the top of the page accepts percentages as integers, but these equations are more portable and universal in part because they avoid certain kinds of hand-holdy conversions.

There are several boundary conditions implicit in these equations (conditions for which no meaningful result can be obtained). Example: if a payment is chosen that exactly offsets the accrued interest per period and you try to solve for $np$, the computation will fail because there are an infinite number of periods in that case.

**Status indicator:** There is a status indicator at the bottom of the calculator display to alert you that the computation is not complete. This indicator is meant to remind you that new numbers have been entered but a value button has not yet been pressed, which means the displayed values may not represent a consistent result.

**Interest rate per period:** This business of dividing an interest rate by 12 is not mathematically correct, but since banks use the procedure * it’s wise to go along, otherwise your numbers will not agree with those of the bank.

**Interest rate ($ir$) computation:** The case of $ir$ cannot be solved without iteration (using a method for which we are indebted to Isaac Newton). This calculator solves for $ir$ using an efficient iteration method that will work for most problems, but a multiple-root possibility exists (more than one correct, if meaningless, result). If a particular problem will not yield an interest rate or produces a meaningless rate, you may want to try typing an estimate of the correct rate in the interest rate display window and pressing the “$ir$” button again.

While reviewing the access logs for arachnoid.com, I noticed some visitors had been trying to specify values for Financial Calculator to save time when computing common problems. This is a useful feature, so I have added it to the current version of Financial Calculator.

Here is an example of an URL that specifies values for Financial Calculator in order to compute a payment amount:

If you click the link above, it will reload this page and insert the values listed at the right. This feature allows you to predefine a problem in a link to this page.

In this example problem, the defined values are $pv$, $fv$, $np$, and $ir$. Because four of the five financial variables have been defined, the fifth variable ($pmt$) will be calculated as the page loads.

Here is an example URL that a Web page designer might create to call this page with predefinend values:

The basic URL syntax for using this feature looks like this:

Normally the calling parameters are added to the URL that identifies this page.

The idea of this feature is that if a caller provides any four of the five required financial variables, the fifth value will be computed. If fewer or greater than four values are provided, they are accepted into the calculator, but no computation is performed (and the status indicator alerts you that the computation is not complete).

There is one special variable supported by this feature that is not named in the formal description provided earlier (and that is not counted in the total of four financial values) the value $pb$, which means “payment at beginning.” If you set this value to “true” or “false” in a calling URL, the calculator will accept your choice and compute accordingly. Defining this value is optional * , but if you want consistent results, it’s a good idea to specify it.

In a recent revision, to improve this page’s appearance and avoid the possibility of typographical errors I decided to automatically generate all the financial equation’s computable forms by deriving them from a canonical equation I wrote many years ago:

\begin

Using the Python symbolic math library sympy, which over a period of years has become quite powerful, I set up a code block in which the above equation is solved for each of its computable variables (interest rate can’t be computed directly):

The idea of the LaTeX generator is that it exploits the existence of MathJax rendering support in this page to display the equations with little struggle or chance for errors.

This arrangement has a number of advantages, among which are a great reduction in effort, and a way to avoid the kinds of transcription errors that make online code listings so unreliable.

I also created numerical functions for each of the equation forms and tested them for consistency:

In the above test, I compute a payment amount for an ending balance of 100,000 after 200 payment periods. I then apply that payment amount to a round-robin in which a future value is computed, then that future value is applied to tbe problem of computing a present value for the same parameters. The results were:

The second value, which in principle should be zero, shows the effect of limited precision in computer numerical mathematics.

This programming effort honors the mathematical principle that applications of an established, reliable result should be derived carefully, with as little room for error as possible.

The full Python listing to generate the above results is located here.