Saturday, June 29, 2019

HP 42S/DM42/Free 42: Auto Solvers

HP 42S/DM42/Free 42:  Auto Solvers

Introduction

This blog entry has four solvers for use the on the HP 42S (or Free42, DM42) in the subject of automobiles:

1.  Displacement, Bore, Strokes
2.  Gear Ratio, MPH, RPM
3.  Quarter Mile Estimation:  Elapsed Time, Car's Weight, Horsepower
4.  Tire Sizes

If you  are entering these programs by hand, I suggest that you create the needed variables ahead of time by storing an arbitrary value (it doesn't matter) into the variable.  Therefore when you recall the variables, they will be available in the soft menu.  Activate the solvers by pressing the orange shift key ([SHIFT]) [ 7 ] (SOLVER).

Link to the programs can be downloaded here:  https://drive.google.com/file/d/1N4wpO9Q-Mhyp51kdubAh5guf2xZhp8Tc/view?usp=sharing

1.  Displacement, Bore, Strokes  (File:  displacement.raw)

00 { 79-Byte Prgm }
01▸LBL "DISPMNT"
02 MVAR "DISPMNT"
03 MVAR "BORE"
04 MVAR "STROKE"
05 MVAR "#CYLIN"
06 PI
07 4
08 ÷
09 RCL "BORE"
10 X↑2
11 ×
12 RCL× "STROKE"
13 RCL× "#CYLIN"
14 RCL- "DISPMNT"
15 .END.

Variables:

(DISPM):  displacement of the a cylinder (cubic inches)
(BORE):  diameter of the cylinder (inches)
(STRO):  distance traveled by the piston (inches)
(#CYLI):  number of cylinders

Equation:

π/4 * bore^2 * stroke * #cylinders - displacement = 0

Example:

Bore = 4 in
Stroke = 3.5 in
4-cylinder engine

Result:  Displacement = 175.9292 in^3

2.  Gear Ratio, MPH, RPM  (File:  gearratio.raw)

00 { 74-Byte Prgm }
01▸LBL "GEARRTO"
02 MVAR "RPM"
03 MVAR "MPH"
04 MVAR "TIREDIA"
05 MVAR "GEARRAT"
06 PI
07 RCL× "RPM"
08 RCL× "TIREDIA"
09 RCL÷ "MPH"
10 1056
11 ÷
12 RCL- "GEARRAT"
13 .END.

Variables:

(RPM):  the tire's revolution per minute
(MPH):  speed of the vehicle (miles/hour)
(TIREDI): diameter of the tire (inches)
(GEAR):  gear ratio = transmission ratio * final drive ratio

Equation:

(RPM * π * tire_diameter) / (MPH * 1056) - gear_ratio = 0

Example:

RPM = 3,400 rpm
Tire Diameter = 28 in
Gear Ratio = 3.85

Result:  MPH = 73.5635 mph

3.  Quarter Mile Estimation:  Elapsed Time, Car's Weight, Horsepower
(File:  quartermile.raw)

00 { 52-Byte Prgm }
01 ▸ LBL "QRTMI"
02 MVAR "ET"
03 MVAR "WEIGHT"
04 MVAR "HP"
05 5.825
06 RCL "WEIGHT"
07 RCL÷ "HP"
08 3
09 1/X
10 Y↑X
11 ×
12 RCL- "ET"
13 .END.

Variables:

(ET): elapsed time for the car to travel 1/4 mile (seconds)
(WEIG):  weight of the car including passengers, drivers, fuel, and other items carried (pounds)
(HP):  horsepower

Equation:

(weight/horsepower)^(1/3) * 5.825 - elapsed_time = 0

Note:  MPH = (horsepower/weight)^(1/3) * 234 = 1363.05/elapsed_time

Example:

Weight:  3,540 lb
HP:  215 hp

Result:

ET: 14.8190
(MPH = 91.9802 mph,  [SHIFT] (TOP.FCN) ( 1/X ) 1363.05 [ * ])

4.  Tire Sizes (file name:  tiresize.raw)

00 { 87-Byte Prgm }
01 ▸ LBL "TIRESZE"
02 MVAR "SECWDTH"
03 MVAR "RIMDIA"
04 MVAR "ASPECT"
05 MVAR "TIREDIA"
06 2
07 RCL× "SECWDTH"
08 RCL× "ASPECT"
09 2540
10 ÷
11 RCL+ "RIMDIA"
12 RCL- "TIREDIA"
13 .END.

Variable:

(SECW):  section width (millimeter)
(RIMDI):  rim diameter (inches)
(ASEPC):  aspect ratio
(TIREDI):  tire diameter (inches)

On a side of a tire, we can get three of the four values by from a code that looks like this:

P235 / 75R17

P:  passenger car  (L for light trucks)
235:  section width
75:  aspect ratio
R:  radial tire
17: rim diameter

Equation:

(2 * section_width * aspect_ratio) / 2540 + rim_diameter - tire_diameter = 0

Example:  Use the stats of the tire above to calculate tire diameter.

Result:  30.8780 in

Source:

John Lawlor.  "Auto Math Handbook:  Mathematical Calculations, Theory, and Formulas for Automotive Enthusiasts"  HPBooks:  New York 1992  ISBN 1-55788-020-4

Eddie

All original content copyright, © 2011-2019.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.

Saturday, June 22, 2019

Time Value of Money: Using Present Value Factors

Time Value of Money:  Using Present Value Factors

Introduction

The time value of money equation is:

0 = PV + PMT * PVAF + FV * PVSF

where

PVAF = present value of annuity factor = Σ( (1 + i%)^(-k), k, 1, n )
PVSF = present value of single factor = (1 + i%)^-n
n = number of payments
i% = periodic interest rate (as a decimal)

The cash flow convention is maintained with this model.  Cash outflows (payments) are negative, cash inflows (receipts) are positive.

Solving for Payment (PMT)

0 = PV + PMT * PVAF + FV * PVSF
-PMT * PVAF = PV + FV * PVSF
-PMT = (PV + FV * PVSF) / PVAF
PMT = -(PV + FV * PVSF) / PVAF

Example

PV = $50,000.00
FV = -$10,000.00
n = 60  (5 years of monthly payments)
i% = 0.05/12

PVAF = 52.99071
PVSF = 0.77921

PMT = -(50000 - 10000 * 0.77921) / 52.99071 = -796.5150873
(cash payment of $796.52)

Solving for Future Value (FV)

0 = PV + PMT * PVAF + FV * PVSF
-FV * PVSF = PV + PMT * PVAF
FV = -( PV + PMT * PVAF ) / PVSF

Example

PV = -$1,000.00
PMT = -$250.00
n = 60  (5 years of monthly payments)
i% = 0.05/12

PVAF = 52.99071
PVSF = 0.77921

FV = -( -1000 - 250 * 52.99071) / 0.77921 = 18284.7724
(future value of deposit $18,284.77)

We can use this method with any calculator.  A partial present value factor table, one for single payment, and one for annuity, is presented below.





Source:

"HP 17BII Financial Calculator Owner's Manual"  Edition 1  Hewlett Packard.  Corvallis, OR.  December 1989.

Have fun,

Eddie

All original content copyright, © 2011-2019.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.

Saturday, June 15, 2019

HP 42S and TI-60: Dimensions of a Race Track

HP 42S and TI-60:  Dimensions of a Race Track



We have a race track that consists of two rectangular tracks connected by a circular ring that is cut in half.  A half ring attaches to each end. 

Let the variables define the following measurements:

R0 = radius from the center of the circular ring to the outside of the track
RI = radius from the center of the circular ring to the inside of the track
C = length of the rectangular potion of the track
R0 - RI = width of the rectangular portion of the track

I am taking an imaginary line in the middle of the track (see the pink dotted line on the right side of the illustration).  The radius from the center of the ring to the pink dotted line is:
 RI + (R0 - RI)/2.

Area: 

Area
= area of the circular ring + area of the top rectangular portion + area of the bottom rectangular portion
= (π * RO^2 - π * RI^2) + C * (RO - RI) + C * (RO -RI)
= π * (RO^2 - RI^2) + 2 * C * (RO - RI)

Perimeter:

Perimeter
= circumference of the circle at the half way point between the outside and inside radius + length of the top rectangular portion + length of the bottom rectangular potion
= 2 * π * (RI + (RO - RI)/2) + C + C
= 2 * π * (RI + (RO - RI)/2) + 2 * C
= 2 * π * 1/2 * (2 *RI + RO - RI) + 2 * C
= π * (RO - RI) + 2 * C

Now that we have the calculations, let's put them to practice.

Input Variables (see above):

R0 = RO
R1 = RI
R2 = C

Ouput Variables:

R3 = area
R4 = perimeters

HP 42S/DM42/Free42 Program RACETRK

00  {68-Byte Prgm}
01  LBL "RACETRK"
02  RCL 00
03  X ↑ 2
04  RCL 01
05 X ↑ 2
06  -
07  PI
08  *
09  2 
10  RCL * 02
11  RCL 00
12  RCL - 01
13  *
14  +
15  STO 03
16  "AREA="
17  AVIEW
18  STOP
19  2
20  RCL * 02
21  RCL 01
22  RCL + 00 
23  PI
24  *
25  +
26  STO 04
27  "MID PERIMETER="
28  AVIEW
29  RTN
30  END

TI-60 Program Race Track

Format:   line number :  key code : key

00 :  91  :  π
01  :  65  :  *
02  :  53  :  (
03  : 71  : RCL
04  :  00 :  0
05  :  96  : x^2
06  :  75  :  -
07  :  71  :  RCL
08  :  01  :  1
09  :  96  :  x^2
10  :  54  :  )
11  :  85  :   +
12  :  02  :  2
13  :  65 :  *
14  :  71  :  RCL
15  :  02 :  2
16  :  65  :  *
17  :  53  :  (
18  :  71   :  RCL
19  :  00  :  0
20  :  75  :  -
21  :  71  :  RCL
22  :  01  :  1
23  :  54   :  )
24 :  95  :  =
25  :  61  :  STO
26  :  03  :  3
27  :  13   : R/S
28  :  02  :  2
29  :  65  :  *
30  :  71   :  RCL
31   :  02 :  2
32  :  85  :  +
33  :  91  :  π
34  :  65  :  *
35  :  53  :  (
36  :  71  : RCL
37  :  00  :  0
38 :  85  :  +
39  :  71  :  RCL
40  :  01 :  1
41  :  54  :  )
42  :  95  :  =
43  :  61  :  STO
44  :  04  :  4
45  :  13  : R/S
46  :  22  :  RST

Example

R0 = radius to outside ring = 12 ft
R1 = radius to inside ring = 8 ft
R2 = length of the rectangular portion of the trace = 45 ft

Results:

Area (R3) = 611.3274123 ft^2
Perimeter of the mid-line (R4) = 152.8318531 ft

Eddie

All original content copyright, © 2011-2019.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.

Friday, June 7, 2019

Casio fx-5800P: Cash Flow Program (Pierre Gillet)

Casio fx-5800P:  Cash Flow Program (Pierre Gillet)

Introduction:  Cash Flows Using the Stat List

Today's program comes from Pierre Gillet, who emailed me a set of programs to calculate net present value (NPV) and internal rate of return (IRR) for the Casio fx-5800P.  A key feature is that these programs use the statistical lists List X and List Freq from the SD mode.

There are three programs listed:

"NPV":  calculates Net Present Value.  Store the interest rate in decimal in variable X in Comp mode before running "NPV".

"SOLVE":  solves for the Internal rate of return (IRR) using the secant method.  Again, use decimals for interest rates.  For the IRR, your YTARGET is always 0.

"YFX":  The function to solve.  In this case, YFX refers the program to "NPV".

The programs here are from Pierre Gillet and are presented with permission.

Casio fx-5800P program "NPV"  (Pierre Gillet) 

Notes:
1.  Small n  is from the Statistics variable n.  [ FUNCTION ], 7:  STAT, 2: VAR, 1: n
2.  Call up the Stat lists by:  [ FUNCTION ], 7: STAT, 1: LIST  (1: List, 2:  Freq, or type X for List X)

0 → Y : 1 → U : 2 → W 
Lbl 1
U + List Freq[W] → V
Lbl 2
Y (1 + X) + List X[W] → Y
Isz U
U < V ⇒ Goto 2
Isz W
U < n ⇒ Goto 1
List X[1] + Y ÷ ( ( 1 + X ) ^ ( n - 1 ) ) → Y

Casio fx-5800P program "SOLVE"  (Pierre Gillet)

Note:  Keep recycling the loop with [ EXE ] until an error occurs.  The final result is the IRR (stored in X).

Note: The frequency of the first data point (X[1]) is not considered in the calculation.

"X1" ? → A
"X2" ? → B
"YTARGET" ? → T
A → X : Prog "YFX"
Y - T → R
B → X : Prog "YFX"
Y - T → S
Lbl 1
B - S ( B - A ) ÷ ( S - R ) → C
C → X ⊿
Prog "YFX" : Y - T → Q
A → B : R → S : C → A : Q → R
Goto 1

Casio fx-5800P program "YFX"  (Pierre Gillet)

Prog "NPV"

Example

Go to SD mode.  Make sure that the Frequency is turned on by pressing [ SHIFT ],  ( SETUP), 5: STAT, 1: FreqOn

Data:  List X, Freq
-5600, 1
1300, 1
2500, 1
3000, 1

NPV:  interest rate of 8%.  (store 0.08 in X)

Result:  $128.55

Solve for IRR,  run SOLVE with guesses X1 = 0, X2 = .15, and YTARGET = 0.

Final result:  0.0912 (9.12%)

Thank you Pierre Gillet!

Note: I wasn't called to jury duty - back to normal life for me.  I'm also posting this a day early. 

Eddie

All original content copyright, © 2011-2019.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.

Sunday, June 2, 2019

TI-Nspire Survival Guide

TI-Nspire Survival Guide









With both the TI-Nspire CX II and the TI-Nspire CX II CAS here, there is a renewed interest in the TI-Nspire.  To be honest, I have not used the TI-Nspire CX in quite while, so I had to re-learn some of the basics of the calculator.

The TI-Nspire calculators operates like a computer, with files, folders, documents, and each file containing a set of problems.

I put together a tns (TI-Nspire) documents, TI-Nspire Guide, available for download.  This document is for both the non-CAS and CAS version.  Hopefully, this document provides help with learning some of the basics for the TI-NSpire.

Problems (Table of Contents):

1.  Calculator Basics
2.  Programming functions to use anywhere (public functions)
3.  Graphing
4.  Data and Statistics
5.  Geometry
6.  Other Functions

 Link:  https://drive.google.com/open?id=15XolSFnCFLkj6pPm446PTdvpmVJfwcfw

Eddie

All original content copyright, © 2011-2019.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.

Saturday, June 1, 2019

HP Prime and Casio fx-CG 50: Black Scholes-Merton Model

HP Prime and Casio fx-CG 50:  Black Scholes-Merton Model

Introduction

The Black Scholes-Merton model, often known as the Black-Scholes model, is a model to estimate the call and put options.  Even though this model is designed for European options, the model is used on options worldwide.  The formula to calculate the call option is:

C = S * N(d1) - K * e^(-r * T) * N(d2)

where:

C = call price
S = stock price
K = exercise price
r = risk free rate (percent)
v = implied volatility (standard deviation of log returns) (percent)
(also symbolized as σ)
T = the time until the stock matures, in the measure in years  (if you are given the number days, divide this number by 365 (or 365.25, 366, 360))

N(d1) and N(d2):  lower tail probability of the Normal Distribution of points d1 and d2, respectively.  (NormCDF( -∞,d1) and NormCDF(-∞,d2))

d1 and d2:

d1 =  ( ln(S/K) + ( r^2 + v^2/2 ) * T ) / ( v * √T )

d2 = d1 - v * √T

Normal Distrubtion:

NormCDF(a, b) = 1 / √(2 * π) * ∫( e^(-t^2/2) dt, a, b)

Also note:

Expected Stock Value = S * N(d1)
Expected Strike Value =  K * e^(-r * T) * N(d2)
Call Price = Expected Stock Value - Expected Strike Value

HP Prime:  Black-Scholes Model

There is no need to enter a program to calculate Call Price and Put Price.  The Black-Scholes Model is in the Finance app.  Select Black-Scholes on the Symb page.  Enter and solve for call and put price on the Num screen.



Casio fx-CG50 Program BLACKSCH

This program calculates the expected stock value, expected strike value, and the call price. 

"BLACK SCHOLES"
"STOCK PRICE: "? → S
"STRIKE PRICE: "? → K
"TIME-EXPIR. (DAYS): "? → T
T ÷ 365.25 → T
"RISK FREE %: "? → R
R ÷ 100 → R
"VOLITALITY σ%: "? → V
V ÷ 100 → V
(ln (S ÷ V) + (R + V^2 ÷ 2 ) * T) ÷ ( V * √T ) → D
D - V * √T → E
S * NormCD(-10,D) → W
K * e^(-R * T) * NormCD(-10, E) → X
W - X → C
"EXEPECTED STOCK VALUE"
RndFix(W,2) ⊿
"EXPECTED STRIKE VALUE"
RndFix(X,2) ⊿
"CALL PRICE"
RndFix(C,2)

Example

Input:
Stock Price:  $55.00
Strike Price: $41.00
Days to Expiration: 90 days    (90/365.25 ≈ 0.25 year)
Risk Free Rate:  2.5%
Volatility Rate:  25%

Output:
Expected Stock Value: $54.64
Expected Strike Value:  $40.37
Call Option: $14.27

Source:

Black-Scholes-Merton Brilliant.org.  Retrieved April 24, 2019, from https://brilliant.org/wiki/black-scholes-merton/

Eddie

All original content copyright, © 2011-2019.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.

Casio fx-9750GIII and fx-CG 50: Playing Games with the Probability Simulation Mode

Casio fx-9750GIII and fx-CG 50: Playing Games with the Probability Simulation Mode The Probability Simulation add-in has six type...