Sunday, August 7, 2016

HP 12C Programming III: Refinancing, Advance Payments in a Lease, NPV, NFV, NUS

HP 12C Programming III: Refinancing, Advance Payments in a Lease, NPV, NFV, NUS


HP 12C Programming Part I:  Modulus, GCD, PITI 

HP 12C Programming Part II:  Weekday Number, Gross Up Calculation


HP 12C Refinancing:  When refinancing “resets” the clock.

Sometimes when a long term mortgage is refinanced, the original length of term is reset.  We will assume payments are made monthly.

Input: 

Store the following amounts in the registers:

Clear the TVM variables by pressing [ f ] [x<>y] (CLEAR FIN)
Original number of payments,  [ n ]
Annual rate, [ 12÷ ] [ I ]
Loan Amount, [ PV ]

Number of payments that have been made prior to refinance, [STO] [ 0 ]  (R0)
New annual rate, [ENTER], 12, [ ÷ ], [STO] [ 1 ]  (R1)

Run the program by pressing [R/S].  The original payment is calculated.  Press [R/S] again to get the balance.  Enter any additional monies (can be $0.00) received due to the refinance.  Finally, press [R/S] again, and the new payment is calculated.

Program:
STEP
CODE
KEY
01
45, 11
RCL n
02
44, 2
STO 2
03
14
PMT
04
14
PMT \\ calculate payment
05
31
R/S
06
45, 0
RCL 0
07
11
n
08
15
FV
09
31
R/S  \\ calculate balance, ask for amount of withdrawn
10
30
-
11
16
CHS
12
13
PV
13
0
0
14
15
FV
15
45, 1
RCL 1
16
12
i
17
45, 2
RCL 2
18
11
n
19
14
PMT
20
43, 33, 00
GTO 00

Example: 

A couple purchased a house for $185,000.  The mortgage lasts for 30 years (360 months) with a 4.8% interest rate (0.4% periodic rate).   180 payments have passed, and the couple is able to refinance the mortgage (but pay that amount in 30 years) at a rate of 3.84%.  $15,000 is also cashed out.

Input:

360 [ n ]
0.4 [ i ]
185000 [PV]
180 [STO] [ 0 ]
0.32 [STO] [ 1 ]

Results:

[R/S]    -970.63  (The original payment is $970.63)
[R/S]    -124,373.78   (Balance of $124,373.78)
Enter 15000, press [R/S] -652.60   (New payment is $652.60)

HP 12C:  Advance Payments in a Lease

The program calculates the payment where you pay number of payments in advance.

Formula:

PMT = (-PV – FV*(SPPV(I%/12:N))) ÷ (UPSV(I%/12:N-ADV)+ADV)

Where:
SPPV:  present value of $1, where FV is equal to 1
USPV:  present value of $1, where PMT is equal to 1

Input:

Number of payments, [ STO ] [ 0 ]
Number of payments made in advance, [ STO ] [ 1 ]
Periodic Rate, [STO] [ 2 ]
Price of the Lease, [STO] [ 3 ]
Salvage Value, [ STO ] [ 4 ]

Calculate lease payment by pressing [R/S].

STEP
CODE
KEY
01
42, 34
Clear FIN  ([ f ] [x<>y])
02
1
1
03
16
CHS
04
15
FV
05
45, 2
RCL 2
06
12
i
07
45, 0
RCL 0
08
11
n
09
13
PV
10
45, 4
RCL 4
11
20
*
12
16
CHS
13
45, 3
RCL 3
14
30
-
15
45, 11
RCL n
16
45, 1
RCL 1
17
30
-
18
11
n
19
45, 15
RCL FV
20
14
PMT
21
0
0
22
15
FV
23
13
PV
24
45, 1
RCL 1
25
40
+
26
10
÷
27
43, 33, 00
GTO 00

Example:

A machine with a cost of $40,000.00 is leased for 48 months.  Two advanced payments are required.  Interest rate is 10% (monthly periodic rate is 10%/12).  The residual value is estimated to be $15,000.

Input:

48 [STO] [ 0 ]   \\ term
2 [STO] [ 1 ]   \\ 2 advanced payments
10 [ENTER] 12 [ ÷ ] [STO] [ 2 ]  \\ interest rate
40000 [STO] [ 3 ]  \\ cost
15000 [STO] [ 4 ] \\ salvage value

Result:

[R/S]  -1249.30    (Each payment is $1,249.30.  Two advanced payments are $2,498.60).

Source:  HP 17bII+ Financial Calculator User’s Guide.  Hewlett Packard.  Edition 3:  2007

HP 12C: Net Present Value, Net Future Value, Net Utility Stream

Input:

Clear the registers/finance registers
Press [ g ] (GTO) 00 to get the pointer to line 00.  (000 for the HP 12C Platinum editions.  Remember, the Platinum editions have up to 400 steps and line numbers are in triple digits)
Store -1 in [ n ] (don’t worry, n is incremented in the main loop)
Store periodic interest rate in [ i ].
Store 0 in register 0  (0 [STO] [ 0 ]).  Register 0 is use for calculating NPV

Enter each cash flow one at a time, and press [R/S].

Ready to calculate:

Press [ g ] (GTO) 10  (or 010) to get the pointer to line 10. 
Press [R/S] to get NPV (net present value)
Press [R/S] to get NFV (net future value)
Press [R/S] to get NUS (net utility stream)

Program:
STEP
CODE
KEY
01
16
CHS  // main loop: input data
02
15
FV
03
45, 11
RCL n
04
1
1
05
40
+
06
11
n
07
13
PV
08
44, 40, 0
STO+ 0
09
43, 33, 0
GTO 00  // finish main loop
10
45, 0
RCL 0 // calculation part
11
31
R/S  // net present value
12
1
1
13
16
CHS
14
13
PV
15
0
0
16
14
PMT
17
15
FV
18
45, 0
RCL 0
19
20
*
20
31
R/S  // net future value
21
45, 0
RCL 0
22
1
1
23
16
CHS
24
14
PMT
25
0
0
26
15
FV
27
13
PV
28
10
÷
29
31
R/S  // net utility stream


Example:

Rate:  15%
Cash Flow #
Flow
0
-10,000.00
1
2500.00
2
3500.00
3
5000.00
4
5000.00

Input:
[ f ] CLEAR FIN, [ f ] CLEAR PRGM
-1 [ n ]  // do this on each new problem
0 [STO] [ 0 ]   // do this on each new problem

15 [ i ]
10000 [CHS] [R/S]
2500 [R/S]
3500 [R/S]
5000 [R/S]
5000 [R/S]

Results:

[GTO] 10  [R/S]:   NPV = 966.76
[R/S]:   NFV = 1690.88
[R/S]:   NUS = 338.62

Input slowly and carefully.

This blog entry is property of Edward Shore, 2016.



Friday, August 5, 2016

TI-84 Plus CE: Calories Burned While Walking

TI-84 Plus CE: Calories Burned While Walking

Introduction

Caution:  These programs give an estimate on the number of total calories burned.  Other factors such as the intensity of the walk may be needed to taken into consideration.  This blog entry should not be considered professional medical advice.

There are two programs that estimate the number of calories burned during a single walking session.  WALKCAL uses your stride and the number of steps as inputs.  If your stride isn’t known, an average stride is estimated based on your height.  WALKDIST uses distance traveled and time it took to travel such distance as input.  WALKDIST is the more simple program of the two.

All units are entered in U.S. units.  Since the formulas use SI units, some conversions are necessary.  The programs will perform all necessary conversions upon execution.


1 ft = 30.48 cm
1 mi = 5,280 ft
1 m/min = 26.82 mph
1 lb = 0.453592 kg
3.5 V02 = 1 MET

WALKCAL

WALKCAL:  Calories burned by inputting your stride (in feet), weight (in pounds), number of steps walked, and the time of the walk (in hours). 

TI-84 Plus Program WALKCAL
Menu("STRIDE KNOWN?","YES",0,"NO",1)
Lbl 1
Disp "HEIGHT: (FT/IN)"
Input "FEET:",F
Input "INCHES:",I
F+I/12→H
Menu("GENDER","FEMALE",2,"MALE",3)
Lbl 2
0→G
Goto 4
Lbl 3
1→G
Lbl 4
iPart(30.48H*(.413+.002G))/30.48→X
Disp "STRIDE (FT):",X
Goto 5
Lbl 0
Input "STRIDE (FT):",X
Lbl 5
Input "NO. STEPS:",S
SX/5280→D
Input "TIME (HRS):",T
D/T→V
Input "AVG. GRADE (DEC):",E
3.5+(26.82V*.1+26.82V*E*1.8)→Y
Input "WEIGHT (LB):",W
Y/3.5*W*.453592→B
Disp "DIST (MI):",D
Disp "AVG SPEED:",V
Disp "CALORIES BURNED:",BT

Example:
5’3” female (stride unknown), walks 7500 steps in 1 hour.  She weighs 108 pounds.  Grade averages to be about 1% (0.01).
Results:
DIST (MI):  3.075787402
AVG SPEED:  3.075787402
CALORIES BURNED:  185.232189

WALKDIST

WALKDIST:  Calories burned by inputting your weight (in pounds), the distance walked (in miles), the time of walk (in hours). 

TI-84 Plus Program WALKDIST
Input "DIST (MI):",D
Input "TIME (HRS):",T
D/T→V
Input "AVG. GRADE (DEC):",E
3.5+(26.82V*.1+26.82V*E*1.8)→Y
Input "WEIGHT (LB):",W
Y/3.5*W*.453592→B
Disp "AVG SPEED:",V
Disp "CALORIES BURNED:",BT

Example:
Walk 5.2 miles in 1.8 hours, and the person weighs 150 pounds.  Use average grade of 1% (0.01).
Results:
AVG SPEED: 2.888888889
CALORIES BURNED:  442.3834566

Sources:

American College of Sports Medicine.  “Metabolic Equations for Gross V02 in Metric Units” http://certification.acsm.org/metabolic-calcs   2015.   Retrieved July 24, 2016.

“Accurate Formulas To Determine Calories Burned Jogging”  http://community.myfitnesspal.com/en/discussion/134478/accruate-formula-to-determine-calories-burned-jogging   November 14, 2010.   Retrieved July 24, 2016

Hope you find this useful!  Have a great day,

Eddie


This blog is property of Edward Shore, 2016.

HP Prime CAS: Degree of a Polynomial and Homogeneous Test

HP Prime CAS: Degree of a Polynomial and Homogeneous Test

Note

The following two programs degpoly and ishomogeneous are CAS Mode specific programs.  When you are creating a new program file in this instance, make sure the CAS box is checked on the New Program screen (see below).



Degree of a Polynomial

The program degpoly is a more complete version of the degree command.  The degree command tests a single variable, default to x if no variable is specified.  The program degpoly calculates the degree of a polynomial, considering four variables:  x, y, z, and t. Combinations of these four variables, such as x*y, x*y*z, and t*z are also considered.     

HP Program degpoly:
#cas
degpoly(poly):=
BEGIN
// 2016-07-31 EWS
// x,y,z,t
LOCAL tms,cnt,pt,lst,wp,dg,dgr;
tms:=part(poly);
lst:={};

FOR pt FROM 1 TO tms DO
wp:=part(poly,pt);
dg:=degree(wp,x)+degree(wp,y)+
degree(wp,z)+degree(wp,t);
lst:=concat(lst,{dg});
END;

dgr:=MAX(lst);
return dgr;
END;
#end

I recommend that you type out the commands when programming in CAS mode.  Make sure the suffix “CAS.” is removed from any command inside the program. 

Accessing CAS Programs

In CAS mode, press [Vars], then the soft key (CAS), select Program for the list of programs

Examples:
degpoly(x^2 + 3*x – 1) returns 2
degpoly(x^2 + 3*y – 1) returns 2
degpoly(x*y – y^2 + t) returns 2
degpoly(x^2*y^2 – 3*z^2) returns 4

Polynomial Homogeneous Test

A polynomial is homogeneous if all of the nonzero terms has the same degree.  Tests a polynomial of four variables x, y, z, and t and their combinations (x*y, x*z, x*y*z, etc).  If the polynomial in question is homogeneous, the program returns a 1 (for true), otherwise 0 is returned (for false).

HP Prime Program ishomogeneous
#cas
ishomogeneous(poly):=
BEGIN
// 2016-08-03 EWS
// x,y,z,t
LOCAL tms,cnt,pt,lst,wp,dg,dgr;
tms:=part(poly);
lst:={};

FOR pt FROM 1 TO tms DO
wp:=part(poly,pt);
dg:=degree(wp,x)+degree(wp,y)+
degree(wp,z)+degree(wp,t);
lst:=concat(lst,{dg});

// test
IF pt≥2 THEN
IF lst(pt)≠lst(pt-1) THEN
RETURN 0;
KILL;
END;
END;

END;
return 1;
END;
#end


Examples:
ishomogeneous(x^2 + 3) returns 0
ishomogeneous(x^2 + 3*y^2) returns 1  (all terms are of degree 2)
ishomogeneous(x^2*z – 3*y^2*t + x^3) returns 1  (all terms are of degree 3)
ishomogeneous(x^2*z – 3*y^2) returns 0

Source: 

Avner Ash and Robert Gross.  “Elliptic Tales.  Curves, Counting, and Number Theory”  Princeton University Press, New Jersey 2016.


This blog is property of Edward Shore, 2016.

Symmetric Quartic Equation - Python

Symmetric Quartic Equation - Python Note: The code is programmed with a TI-84 Evo. No modules are used, so the scripts should be adopt...