I'll explain the specific problem in more detail, in case there's an easier way to do it that doesn't involve TVM.

I'm trying to make a solver formula that will calculate the amount of interest saved over the remaining life of a loan if I were to make an extra principal pay-down of a given size. This is the general calculation process that I use:

1. Make sure N, I%, PV, PMT, and FV reflect the current (or opening) state of the loan.

2. Subtract the extra principal payment from PV, and update PV.

3. Recalculate N to determine the new number of payments remaining to pay off the reduced principal. This will probably be a non-integer value, i.e. an odd payment at the end.

4. Recalculate FV using FLOOR(N) to determine the remaining balance for the final odd period.

5. Calculate the total interest paid on the original principal using the original values in "N*PMT+PV" (gives a negative value representing total interest paid).

6. Calculate the total interest paid on the reduced principal, using the new values of N, PV, and FV in "PMT*FLOOR(N)+FV*(1+I%/100)+PV" (multiplies the payment amount by the number of full payments, and calculates the periodic interest on the final odd period).

7. Subtract the original interest (step 5) from the reduced interest (step 6) to obtain the total savings (a positive number).

As an example, suppose you've got a loan with these properties:

N=360

I%/YR=4.75%

PV=141,000

PMT=-735.52

FV=0

The total interest payments on the loan would be ($123,788.19). If you paid an extra $1,000 in principal, then N becomes 354.41, and the total interest paid is ($120,679.83), giving a total savings of $3,108.36.

Here's the program I have on my DM42 for calculating this. It relies on my TVM program, which isn't listed here, but it should be fairly obvious how it's used in this example: XEQ "N" and XEQ "FV" recalculate the respective TVM variables, updating the variable directly, and also leaving the new value in X, lifting the stack. Also, XEQ "SS" is a stack-save routine, and XEQ "R_YZTX" restores the saved stack, but keeps whatever value was in X at the time it's called (represented by the underscore), and puts the old value of X into L (so it's the same stack behavior you would see from single-argument functions like LN). I've added a few comments to the code.

Code:

`00 { 163-Byte Prgm }`

01▸LBL "PAYDOWN"

02 STO "_A" {Save the pay-down amount}

03 XEQ "SS" {Save the stack}

04 RCL "PV"

05 STO "_PV" {Save the old value of PV}

06 X<>Y {Subtract the pay-down amount from PV...}

07 -

08 STO "PV" {...and update PV}

09 RCL "N"

10 STO "_N" {Save the old value of N...}

11 XEQ "N" {...and recalculate N with the new lower balance}

12 IP

13 STO "N" {Only keep the number of whole payments}

14 RCL "FV"

15 STO "_FV" {Save the old value of FV...}

16 XEQ "FV" {...and recalculate FV with the smaller principal and number of payments}

17 RCL "PMT"

18 RCL× "_N" {Calculate total amount paid on the old loan balance}

19 RCL "PMT"

20 RCL× "N"

21 RCL+ "FV"

22 RCL "FV"

23 RCL× "I%YR"

24 RCL÷ "P/YR"

25 100

26 ÷

27 +

28 RCL- "_A" {Calculate total amount paid on the new loan balance}

29 - {Take the difference between the two totals}

30 RCL "_PV" {Restore all the TVM variables' original values}

31 STO "PV"

32 R↓

33 RCL "_FV"

34 STO "FV"

35 R↓

36 RCL "_N"

37 STO "N"

38 R↓

39 CLV "_N" {Clear temp variables}

40 CLV "_PV"

41 CLV "_FV"

42 CLV "_A"

43 XEQ "R_YZTX" {Restore the stack (leave X alone, put old X in L)}

44 END

I have this algorithm implemented on many different calculators (DM42, HP 200LX solver, Casio fc-200, Casio fx-9860G - both as a program and a spreadsheet, and a version for any old Casio scientific with array memories, covering the fx-7000G through fx-9700GE, which also requires a TVM program I wrote), but it would be nice to have it on my 17BII since it's a financial calculator.