## TVM and Amortization For Old Casio Calculators

These programs enable easily and accurately calculating TVM and amortization problems on old Casio calculators in about 350 bytes of code. This is a fairly simple implementation, without any controls over P/Y or C/Y, so you will need to enter an appropriate periodic interest rate, not an APR. Special care is taken in accurately calculating ln(x+1) and e^x-1 for extremely small values of x, so the solutions will be accurate even for very small interest rates. Solutions are found using the secant method, and should very closely agree with other commercial financial calculators.

### Requirements

These programs will work on any of the older Casios that use array-style memory indexing (e.g. C), which the secant-method solver relies on to solve for any variable in the formula. If your Casio has a "Defm" function, either somewhere on the keyboard (probably Shift-0 or Shift-.), or in the Mode function list for the really old models, it will most likely work.

A very non-exhaustive list of some models that will work (there are definitely more than this):

• fx-7000G, fx-8000G, fx-8500G
• fx-4000P
• fx-6300G
• fx-7300G
• fx-7700G, fx-7800G, fx-8700G, fx-8800G
• fx-9700GE
• cfx-9800G

You'll need around 350 bytes of free space, and enough empty program slots to store all 7 (or 8 if you want amortization) programs. You don't need to allocate any additional memories (i.e. Defm 0 is fine).

### Usage

These variables are used for TVM:

• N - Number of periods
• I - i% (periodic interest rate, NOT annual interest rate)
• P - Present value
• M - Payment amount
• F - Future value
• B - Beginning-period-payments mode (1 for beginning, 0 for ending)

To solve a TVM problem, simply store the known values in the variables above, and run one of these programs to calculate the desired variable (ordered to match the order in which the five variables typically appear on the keys of a financial calculator):

• Prog 1 - N
• Prog 2 - I
• Prog 3 - P
• Prog 4 - M
• Prog 5 - F

The result will be displayed immediately, and also stored in the corresponding variable.

Example:

```Mcl
30×12→N
4.75/12→I
141000→P
Prog 4

-735.5227445
```

To calculate an amortization schedule, first store 0 into N (not strictly necessary, but results will be incorrect in Beginning mode if this is not done), then run Prog 7. You will be prompted for a number of payments to amortize, and after a few moments of calculation, the program will display the total number of payments amortized so far, the interest and principal for the amortized periods, and the remaining balance. Amortization will store results in the following variables:

• N - Total payments amortized so far
• J - Interest for amortized periods
• K - Principal for amortized periods
• P - Remaining balance

### Program Code

Programs are listed below with numeric program IDs (Prog 0-9), which are supported on all compatible models. For models that support letter program IDs, it's suggested to use the following identifiers so that the programs match the variables they calculate. If you wish to do this, update any references between the programs as needed.

• Prog 1 → Prog N
• Prog 2 → Prog I
• Prog 3 → Prog P
• Prog 4 → Prog M
• Prog 5 → Prog F
• Prog 8 → Prog S (Secant method solver shell)
• Prog 9 → Prog T (TVM formula)
• Prog 7 → Prog A (Amortization)

Prog 1 - Solve for N

```13→A
Prog 8
```

Prog 2 - Solve for I

```8→A
Prog 8
```

Prog 3 - Solve for P

```15→A
Prog 8
```

Prog 4 - Solve for M

```12→A
Prog 8
```

Prog 5 - Solve for F

```5→A
Prog 8
```

Prog 8 - Secant-method solver

```Prog 9
Ans→W
W=0⇒Goto 9
A[A]→V
V+1→X
X→A[A]
Prog 9
Ans→Y
Lbl 1
X-(X-V)×Y÷(Y-W)→T
T→A[A]
Prog 9
Ans→U
Y→W:X→V:U→Y:T→X
Y≠0⇒Y≠W⇒Goto 1
Lbl 9
A[A]
```

Prog 9 - TVM formula ("J+1-1" is not a typo! "^-1" should be replaced with the "x^-1" operator.)

```I÷100→J
ln(J+1)×J÷(J+1-1)→L
NL÷2→K
sinh K×2eK×(J^-1+B)→K
Pe(NL)+KM+F
```

Prog 7 - Amortization (Optional. "Deg" is a dummy no-op instruction.)

```"PMTS"?→C
Int Abs C→C
0→J~K:0→T
C=0⇒Goto 9
B=1⇒N=0⇒Goto 5
Lbl 1
Isz N:Deg
P×I÷100→T
T:Rnd
M<0⇒-Ans
Ans+J→J
Lbl 5
M:Rnd:T+Ans→T
T+K→K
T+P→P
Dsz C:Goto 1
"PMTS":N◢ (replace the : with ◢ for "one-line" models like the fx-4000P, fx-6300G)
"INT":J◢
"PRIN":K◢
"BAL":P◢
```