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 + 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) 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.

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

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.

Thursday, May 30, 2019

HP Prime and HP 17BII: Trapezoid Rule Using Distinct Points

HP Prime and HP 17BII: Trapezoid Rule Using Distinct Points

Introduction

We can estimate the area of any surface by the use of sums and integral.  In calculus, we usually are given a function f(x), but here we are using measurements from one end to the other at various intervals.

Technically, the intervals between each measurement do not have to be equal length.  However, having intervals of equal length makes things a lot easier, and in this blog entry, we assume they are.

We have various methods to estimate the area.  One of the easiest ways is the Trapezoid Rule:

Area ≈ h/2 * ( y_1 + y_n + 2 * Σ( y_k , k, 2, n-1 ) )

Where:

h = interval length
y_k = length of each measurement, there are  n measurements
y_1 and y_n:  measurement of lengths at each end, respectively

Another rule to estimate area is the Simpson's Rule:

Area ≈ h/3 ( y_0 + y_n + 4 * Σ( y_k, k, 1, n-1, 2) + 2 * Σ( y_k, k, 2, n-2, 2) )

The program presented here uses the Trapezoid Rule.

HP Prime Program AREAHGT

Two arguments:  h, a list of measurements

EXPORT AREAHGT(h, ms)
BEGIN
// h:  increment between measurements
// ms: list of measurements
// 2019-05-09 EWS
LOCAL k,n:=SIZE(ms);
RETURN h/2 * (ms(1) + ms(n) + 2 * Σ( ms(k), k, 2, n-1 ));
END;

HP 17BII+ (Silver)/HP 17BII Solver:  Trapezoid Rule

First:  define a SUM list named MS.  The solver uses that list to get the reference measurements.

Solver:

AREAHGT: AREA = 0 * L(N:SIZES(MS)) + H÷2 * (ITEM(MS:1) + ITEM(MS:G(N)) + 2 * Σ(K:2: G(N)-1: 1: ITEM(MS:K) )

Example

h = 0.5

MS:
y_1 = 1174
y_2 = 1078
y_3 = 979
y_4 = 984
y_5 = 810
y_6 = 779
y_7 = 800
y_8 = 852
y_9 = 966

Area:  3676

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.

Monday, May 27, 2019

Fractal Plots: TI-84 Plus CE and HP Prime

Fractal Plots:  TI-84  Plus CE and HP Prime

Introduction

The program CHAOS1 plots a fractal to simulate a Julia Set.  Given the complex numbers z_k and c, repeats the equation:

z_n = z_n-1 + c^2

The program will ask for a sample graphing space with the a border B.  The viewing window will be set up as:

Xmin = -B
Xmax = B
Ymin = -B
Ymax = B

The program CHAOS1 will also as for the number of points (G), this will determine the number of points plotted in the graph.  The higher G is, the more detailed the fractal is; however, the plot will take longer to complete.

We start with each point on the graph z_0 = a + b*i, where i = √-1.  Then we calculate:

z_1 = z_0^2 + c
z_2 = z_1^2 + c
z_3 = z_2^2 + c
and so on.

For each z_0, we have two possibilities for the repeated calculations:

1.  |z_n| = abs(z_n) eventually goes towards infinity or

2.  |z_n| = abs(z_n) eventually settles (or converges) to a specific point.

A color is assigned to each point z_0.  The color is determined by the amount of iterations it takes to reach |z| > 2.  For such points that fit criteria 2, and never reaches |z| >2, the point is colored black.  This method creates the Julia set for any given c.

For the program CHAOS1, I set up a rank of colors to plot each point, and arbitrary pick a maximum amount of iterations.  For example, I picked 9 colors for the TI-84 Plus CE version.  Hence for each point, if |z| ≤ 2 after 9 iterations, color the point black.

Obviously the more levels (colors) we have, the more accurate our fractal is.  With the programs listed, you can adjust the number of colors.   Keep in mind the TI-84 Plus CE has up to 15 colors, the Casio fx-CG50 has up to 7, and the HP Prime's colors have 256 levels of red, green, and blue.

You can download CHAOS1 for both the TI-84 Plus CE and HP Prime here:

TI-84 Plus CE Program CHAOS1  (File:  CHAOS1.8xp)

For the Ti-84 Plus CE, I recommend the number of grid points of no more than 75.

The list of colors that I use in this code is:

1.  WHITE:  color value of 20
2. LTGRAY: color value of 21
3.  YELLOW: color value of 19
4.  ORANGE:  color value of 15
5.  BROWN: color value of 16
6.  GREEN: color value of 14
7.  LTBLUE:   color value of 18
8.  BLUE:  color value of 10
9.  BLACK: color value of 12

Note:  ⅈ represents √-1 ([Shift] [ 3 ])

Func: a+b ⅈ
FnOff: ClrDraw
Input "BORDER: ",B
Input "NO. GRID PTS: ",G
Input "PT C X+Yi: ", C
{20,21,19,15,16,14,18,10,12} → L6
dim(L6) → S
-B → Xmin: B → Xmax
-B → Ymin: B → Ymax
For(I, -B, B, 2B/G)
For(J, -B, B, 2B/G)
1 → K
I + J ⅈ→ Z
Lbl A
If abs(Z)>2 or K=S
Goto B
Z^2 + C → Z
1 + K → K
Goto A
Lbl B
L6(K) → L
Pt-On(I, J, 3, L)
End

Examples B = 1, G = 75, C = -0.79 + 0.15i B = 1, G = 75, C = 0.334 - 0.169i

HP Prime Program CHAOS1 (File:  CHAOS1.hpprgm)

I set 18 color levels, starting from white to black.   Because of the faster processor and calculating speed, I have increased the number of grid points to 500.  250 makes a picture with lines.

Note:  I use the parenthesis notation (x,y) for the complex number x + yi because the imaginary character i unfortunately does not transfer to computer text.  (updated 5/27/2019 - this allows for copying the code to the HP Prime connectivity kit/emulator)

EXPORT CHAOS1()
BEGIN
// 2019-05-19 EWS
LOCAL b,g,c,l6,s;
LOCAL i,k,j,z,l;
STARTAPP("Function");
INPUT( {b, g, {c, [,] }, "Fractal",
{ "Border: ", "Grid: ", "C: "},
{ "Min/Max - X/Y", "# Grid Pts", "C: x + yi " });
// size the screen
Xmin:=-b; Xmax:=b;
Ymin:=-b; Ymax:=b;
// clear the screen
RECT();
// list of colors
l6:= { #FFFFFFh, #C0C0C0h,
#D0D0D0h, #FFFF00h,
#B0B0B0h, #FF8000h,
#905000h, #400808h,
#00FF00h, #004060h,
#003000h, #00FFFFh,
#80D0FFh, #0000FFh,
#000080h, #400080h,
#404040h, #000000h};
// plotting
s:=SIZE(l6);

FOR i FROM -b TO b STEP (2*b)/g DO
FOR j FROM -b TO b STEP (2*b)/g DO
k:=0;

REPEAT
k:=k+1;
IF k==1 THEN
z:=(i,j);
ELSE
z: = z^2 + c;
END;
UNTIL ABS(z)>2 OR k==s;

l:=l6(k);
PIXON(i,j,l);
END;
END;

WAIT(0);
END;

Examples B = 1, G = 500, C = 0.38 + 0.008i B = 1, G = 500, C = -0.11 -0.8i

Have fun!  Explore the possibilities,

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.

Thursday, May 23, 2019

Review: EAI-350 Scientific Calculator

Review:  EAI-350 Scientific Calculator

Basic Facts

Type:  Scientific
Display:  Two Line:  entry on the top and result on the bottom
Power:  Solar with battery backup, LR44
Memory Registers: 8:  A,B,C,D,E,F,X,Y,M
Price: \$8.67, sold online:  https://www.eaieducation.com/Product/560440/CalcPal%C2%AE_EAI-350_Scientific_Calculator.aspx
Documentation:  2 fold out manuals, one full manual and one short manual detailing the more advanced functions

The EAI-350 scientific calculator is similar to the Casio fx-991MS and fx-115MS.  The differences:

The keys are blue, white, and lime green.  The case is dark silver.  The keys work fine, but I don't think they are as solid as the Casio calculators.  The biggest flaw came in the keypad, I had to press the up on the keypad several times and with a firm touch.  This is not a deal breaker, just be something to aware of.

Modes

The EAI-350 has a rich set of features.    The modes include:

*  Compute mode (general math mode)
*  Complex Mode  (arithmetic, x^2, √, Abs, arg, rectangular/polar conversions)
*  Statistics (single variable, Linear Regression, Logarithmic Regression, Exponential Regression, Power Regression, Inverse Regression, Quadratic Regression)
*  Base Operations (Decimal, Hexadecimal, Octal, Binary)
*  Equation Mode (2 x 2 and 3 x 3 linear systems, quadratic equations, cubic equations)
*  Matrices (3 matrices, up to 3 x 3)
*  Vectors (3 vectors, up to 3 elements)

One thing that I noted is that the logic functions only include AND, OR, and XOR.  Entering negative integers will require the use of the minus ([ - ]) key.

Fractions

Fractions can be entered and calculated.  Results are simplified.  Fractions can be displayed as mixed fractions or improper fractions.

Calculus

Calculus functions of the EAI-350 include the numeric integral, numeric derivative, evaluation, and a solve function.  The solve function can solve for any variable.

Engineering Symbols

You can attach engineering symbols (powers of 10) to numbers from f (10^-15) to T (10^12).

Constants and Conversions

The EAI-350 has 40 sets of conversions and 40 scientific constants.  You will need the fold out manual because calling the conversion and constants by numerical code.  The manual states that the constants are based on the 1992 ISO Standard and 1998  CODATA recommended values.  (a little dated)

Verdict

The EAI-350 is a good alternative to the Casio calculators.  The keyboard could be more solid, but it works.  I wish I could adjust the screen contrast, so be aware of where the calculator is operated because the screen can reflect.

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.

Monday, May 20, 2019

Intensity/Illumination, Days Since Jan. 1, Derivatives: HP 20S and 21S

Intensity/Illumination, Days Since Jan. 1, Derivatives: HP 20S and 21S

1.  Intensity and Illumination
2.  Days Since January 1
3.  Numerical Derivative

Disclaimer: I believe the key codes for the programs in this blog entry are the all the same even though the HP 20S and HP 21S have slightly different codes.  Format:   Step  Key: Key Code.  I took turns programming the HP 20S and HP 21S.

1.  Intensity and Illumination

The follow equation relates the luminous intensity (measured in candelas, cd) and illuminance (measured in lux) of a light source.  The equation assumes the light source radiates a spherical matter.

E = I / R^2

E = illuminance
I = luminous intensity
R = radius of the sphere's light (meters)

LBL A:  Solve for E
LBL B:  Solve for I
LBL C:  Solve for R

Registers:
R0 = E
R1 = I
R2 = R

Store the following values in the register and execute the appropriate label.

Program:

01  LBL A:  61,41,A
02 RCL 1:  22, 1
03 ÷:  45
04 RCL 2:  22, 2
05 x^2:  51, 11
06 =: 74
07 STO 0:  21, 0
08 R/S:  26
09 LBL B:  61,41,B
10  RCL 0: 22,0
11  *:  55
12  RCL 2: 22,2
13  x^2:  51,11
14  =:  74
15  STO 1: 21, 1
16  R/S:  26
17  LBL C: 61,41,C
18  RCL 1: 22,1
19 ÷: 45
20 RCL 0: 22,0
21  =:  74
22 √:  11
23 STO 2: 21, 2
24 R/S:  26

Example 1:
R1 = I = 400, R2 = R = 2.
Solve for E,  XEQ A returns 100

Example 2:
R0 = E = 180, R2 = R = 3
Solve for I, XEQ B returns 1620

Example 3:
R1 = I =420, R0 = E = 195
Solve for R, XEQ C returns 1.467598771

2.  Days Since January 1

Input:
R1:  day
R2: month
R3: 0 if we are working in a non-leap year, 1 if we are working in a leap year

Output:
R4:  number of days since January 1

Program:

01 LBL A: 61,41,A
02 RCL 1:  22,1
03 STO 4: 21, 4
04 3:  3
05 5:  5
06 STO - 4:  21,65,4
07 RCL 2: 22,2
08  INPUT:  31
09  2:  2
10  x ≤ y?:  61,42
11  GTO 2:  51,41,2
12  RCL 2: 22,2
13  *:  55
14  3:  3
15  0:  0
16  . : 73
17 6:  6
18  +:  75
19  1:  1
20  .  : 73
21  6:  6
22  =:  74
23  IP:  51, 45
24  STO + 4:  21,75,4
25  RCL 3:  22,3
26  STO + 4:  21,75,4
27  RCL 4: 22,4
28  RTN:  61, 26
29  LBL 2:  61,41,2
30  RCL 2:  22,2
31   *:  55
32  3:  3
33  0:  0
34  .  : 73
35  6:  6
36  +:  75
37  3:  3
38  6:  6
39  8:  8
40:  .  : 73
41  8:  8
42 =: 74
43  IP:  51,45
44  STO + 4:  21,75,4
45  3:  3
46  6:  6
47  5:  5
48  STO - 4:  21,65,4
49  RCL 4:  22,4
50  RTN:  61,26

Example 1:
1/1/2019 - 5/7/2019  (non-leap year)
R1:  7,  R2:  5,  R3:  0
Result:  R4 = 126

Example 2:
1/1/2020 - 11/14/2020  (leap year)
R1:  14,  R2:  11, R3:  1
Result:  R4 = 318

3.  Numerical Derivative

f'(x0) ≈ ( f(x0 + h) - f(x0 - h) ) / ( 2*h )

x = point
h = small change of x, example h = 0.0001

LBL A:  Main Progam
LBL F:  f(X), where R0 acts as X

Input variables:
R1 = h
R2 = point x0

Used variables:
R0 = x   (use R0 for f(x), LBL F)

Calculated Variables:
R3 = f'(x)

Program:

01  LBL A:  61,41A
03  RCL 2:  22,2
04  +:  75
05  RCL 1:  22, 1
06  =:  74
07  STO 0:  21,0
08 XEQ F:  41,F
09  STO 3:  21, 3
10  RCL 2: 22,2
11 -:  65
12 RCL 1: 22,1
13 =:  74
14 STO 0: 21,0
15 XEQ F:  41,F
16 STO - 3:  21,65,3
17 2:  2
18 STO ÷ 3:  21,45,3
19  RCL 1:  22,1
20 STO ÷ 3: 21,45,3
21  RCL 3:  22,3
22 R/S:  26
23 LBL F:  61,41,F
...
xx  RTN:  61,26  (end f(X) with RTN)

Example:  e^x * sin x

LBL F
RCL 0
e^x
*
RCL 0
SIN

RTN

R1 = 0.0001
R2 = x0 = 0.03
Result:  1.060899867

R1 = 0.0001
R2 = x0 = 1.47
Result:  4.7648049

Note:  I am going on vacation this week and I have jury duty in June. So far, I have blog entries scheduled to be posted throughout June 22.  I plan to have a weekly post every Saturday in June.  - E

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.

Thursday, May 16, 2019

Casio fx-CG50 and HP Prime: Azimuth/Bearing Conversions

Casio fx-CG50 and HP Prime: Azimuth/Bearing Conversions

Introduction

The programs A2B (Azimuth to Bearing) and B2A (Bearing to Azimuth) convert angles between two measuring systems that are commonly used by civil engineers and navigators.

The program uses an unusual approach: the use of the arcsine, sine, and cosine functions.   These functions are used on because on scientific calculators, the trigonometric functions return answers in specific ranges.

Let x be a real number.  then:

asin(x) returns answers in the range -90° to 90°  (-π/2 to π/2 radians)

acos(x) returns answers in the range 0° to 180°  (0 to π radians)

atan(x) returns answers in the range -90° to 90°  (-π/2 to π/2 radians)

This was used in the HP 33E program from the calculator book "HP 33E: Surveying Applications".  See Source below.

Formulas:

A = azimuth
B = bearing

Azimuth to Bearing:

B = abs( asin( sin A ) )
Q = int(A/90 + 1)

(Yes, the asin/sin is there for a purpose: to get an angle in the range of -90° to 90°)

Bearing to Azimuth:

A = 180° * int(Q/2) - B * cos(Q * 180°)

In the programs A2B and B2A, both input and output will be degrees-minutes-seconds format.

To enter degrees-minutes-seconds:

Casio fx-CG50:  [ OPTN ] [ F6 ] (more) [ F5 ] (ANGLE)  [ F4 ] (° ' ")

HP Prime:  [ Shift ] [ a b/c ] or [ Shift ] [ 9 ] (select °, ', or '' from the menu)

Azimuth to Bearing Program A2B

Casio fx-CG50 Program A2B (Azimuth to Bearing)

ClrText
Locate 1,4,"AZIMUTH TO BEARING"
Deg
"AZ: "? → A
Abs( sin^-1 ( sin A ) ) → B
"BEARING ="
B ▶ DMS ◢
Intg( A ÷ 90 + 1 ) → Q
Q = 1 ⇒ "NE"
Q = 2 ⇒ "SE"
Q = 3 ⇒ "SW"
Q = 4 ⇒ "NW"

HP Prime Program A2B (Azimuth to Bearing)

EXPORT A2B(A)
BEGIN
// Azimuth to Bearing
HAngle:=1;  // Degrees
LOCAL B, Q, L0:={"NE","SE","SW","NW"};
B:=ABS(ASIN(SIN(A)));
Q:=IP(A/90+1);
RETURN { →HMS(B), L0(Q) }
END;

Example 1:  220° 15' 36"
Result:  40°15'36". SW

Example 2:  184°00'14"
Result: 4°00'14"  SW

Bearing to Azimuth Program B2A

Casio fx-CG50 Program B2A  (Bearing to Azimuth)

ClrText
Locate 1,4,"BEARING TO AZIMUTH"
Deg
"BEARING: "? → B
Lbl 1: 1 → Q: Goto 5
Lbl 2: 2 → Q: Goto 5
Lbl 3: 3 → Q: Goto 5
Lbl 4: 4 → Q: Goto 5
Lbl 5
180 * Intg( Q ÷ 2 ) - B * cos( Q * 180 ) → A
"AZ ="
A ▶ DMS

HP Prime Program B2A (Bearing to Azimuth)

Arguments:  Bearing, Quadrant.  You can enter Quadrant by a string or numerical quadrant.  "NE" = 1,  "SE" = 2,  "SW" = 3, "NW" = 4

EXPORT B2A(B,q)
BEGIN
// Bearing to Azimuth
// q "NE", "SE", "SW", "NW"
// or 1,2,3,4
LOCAL A, L0:={"NE","SE","SW","NW"};
HAngle:=1;  // Degrees
// deal with strings
IF TYPE(q)==2 THEN
q:=POS(L0,q);
END;
A:= 180 * IP(q/2) - B * cos(q * 180);
RETURN →HMS(A);
END;

Example 3:  43°21'55"  SW (q = 3)
Result:  223°21'55"

Example 4:  13°14'56"  SE (q = 2)
Result:  166°45'04"

Source:

Hewlett Packard.  "HP33E:  Surveying Applications"  Hewlett Packard Company.  March 1978

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.

Monday, May 13, 2019

HP 42S/DM42/Free42: Room Cavity Ratio, Luminous Intensity and Illuminance

HP 42S/DM42/Free42:  Room Cavity Ratio, Luminous Intensity and Illuminance

Room Cavity Ratio

The room cavity ratio is used to assist in calculating lighting efficiency in determining where to place ceiling lights in an office room.  The formula is:

RCR = INT( ( 5 * H * ( L + W ) ) / ( L * W ) )

where:
L = length of the room
H = height difference between floor cavity and ceiling cavity
W = width of the room

HP 42S/DM42/Free42:  Solver RCR

LBL "RCR"
MVAR "H"
MVAR "L"
MVAR "W"
MVAR "RCR"
5
RCL * "H"
RCL "L"
RCL + "W"
*
RCL "L"
RCL * "W"
÷
IP
RCL - "RCR"
END

Examples

Example 1:
Input:  H = 5.5, L = 16.8, W = 13.7.   Result:  RCR = 3

Example 2:
Input: H = 5.5, L = 16.8, RCR = 4.  Result:  H = 7.1650

Sources:

Dilouie, Craig.  "Lighting Design:  Example of Role Surfaces Play in Lighting Efficiency"  LightNOW  https://www.lightnowblog.com/2010/06/example-of-role-surfaces-play-in-lighting-efficiency/  June 16, 2010.  Retrieved March 31, 2019

"Room Cavity Ratio, RCR" Illuminating Engineering Society.  https://www.ies.org/definitions/room-cavity-ratio-rcr/  July 5, 2018.  Retrieved April 28, 2019

Luminous Intensity and Illuminance

The follow equation relates the luminous intensity (measured in candelas, cd) and illuminance (measured in lux) of a light source.  The equation assumes the light source radiates a spherical matter.

E = I / R^2

E = illuminance
I = luminous intensity
R = radius of the sphere's light (meters)

HP 42S/DM42/Free42:  Solver ILSPH

LBL "ILSPH"
MVAR "E"
MVAR "I"
MVAR "R"
RCL "E"
RCL "I"
RCL "R"
x ↑ 2
÷
-
END

Examples

Example 1:
Input:  I = 10 cd, R = 2 m.  Result:  2.5 lux

Example 2:
Input:  R = 3.65 m, E = 30 lux.  Result:  I = 399.6750 cd

Sources:

Daryanani, Sital  Building Systems Design With Programmable Calculators Architectural Record Books.  McGraw-Hill Book Company: New York.  1980.  ISBN 0-07-015415-5

Zumtobel "The Lighting Handbook" Zumtobel Lighting GmbH.  Dornbirn, Austria.  6th Edition: 2018  https://www.zumtobel.com/PDB/Ressource/teaser/en/Lichthandbuch.pdf

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, May 11, 2019

Casio Calculators and the Percent Key

Casio Calculators and the Percent Key

Introduction

The percent function on Casio calculators varies based on the calculator itself.  Let's compare six key algorithms on six Casio calculators, five current and one from the past.  We will go from the most consistent behavior to the least.

The calculators used in this study are:

SL-300VC  (four function calculator)
fx-260 Solar II  (scientific calculator - one line display)
fx-300MS 2nd Edition (scientific calculator - one line display)
fx-115ES Plus  (scientific calculator - textbook display)
fx-991EX Classwiz (scientific calculator - textbook display)
fx-115D  (scientific calculator introduced in 1991 - one line display)

Let A and B be real numbers.  In the following examples, required press of the [SHIFT] key are implied as required.

Algorithm 1:  Multiply

Keystrokes:  A [ × ] B [ % ]

Let A = 82, B = 30

SL-300VC:  24.6
fx-260 Solar II:  24.6
fx-300MS 2nd Edition:  24.6
fx-115ES Plus**:  123/5 ([ S<>D] 24.6)
fx-991EX Classwiz**:  123/5  ( [ S<>D] 24.6)
fx-115D:  24.6

A [ × ] B  [ % ] calculates A * B/100.  No surprise that the results will be consistent across the board.

**Pressing equals ( [ = ] ) is required to complete calculations involving percent calculations for the calculators with textbook display.

Algorithm 2:  Division

Keystrokes:  A [ ÷ ] B [ % ]

Let A = 82, B = 30

SL-300VC:  273.33333
fx-260 Solar II:  273.3333333
fx-300MS 2nd Edition:  273.3333333
fx-115ES Plus:  820/3 ([S <> D] 273.3333333)
fx-991EX Classwiz:  820/3 ([S <> D] 273.3333333)
fx-115D: 273.3333333

A [ ÷ ] B calculates A  * 100/B.   Results are consistent across the board.

Keystrokes:  A [ × ] B [ % ] [ + ]

A = 57, B = 11

SL-300VC: 63.27
fx-260 Solar II: 63.27
fx-300MS 2nd Edition:  63.27
fx-115D:  63.27

This calculates A * (1 + B/100)

If you tried the exact algorithm with the textbook style calculators like the fx-115ES Plus and the fx-991EX Classwiz, you get an error.  Use the following instead:   A [ (  ] 1 [ +  ] B [ % ] [  ) ] [ = ]

Algorithm 4:  Subtracting Percents

Keystrokes:  A [ - ] B [ % ] [ + ]

A = 57, B = 11

SL-300VC: 50.73
fx-260 Solar II: 50.73
fx-300MS 2nd Edition:  50.73
fx-115D:  50.73

This calculates A * (1 - B/100)

If you tried the exact algorithm with the textbook style calculators like the fx-115ES Plus and the fx-991EX Classwiz, you get an error.  Use the following keystroke algorithm instead:   A [ (  ] 1 [ -  ] B [ % ] [  ) ] [ = ]

Algorithm 5:  A - B%

Keystrokes:  A [ - ] B [ % ]

SL-300VC: 12.5
fx-260 Solar II: 12.5
fx-300MS 2nd Edition: 12.5
fx-115ES Plus:  1784/25 ( [S<>D] 71.36)
fx-991EX Classwiz:  1784/25 ( [S<>D] 71.36)
fx-115D: 12.5

We see some difference on how this algorithm is calculated and it depends on the type of calculator used.

For four-function basic calculators and one-line scientific calculators, A - B% calculates the percent change:  (A - B)/B * 100

For the  textbook display calculators, the B is merely divided by 100 and subtracted from A:  A - B/100

Algorithm 6:  A + B%

Keystrokes:  A [ + ] B [ % ]

SL-300VC: 200
fx-260 Solar II: 300
fx-300MS 2nd Edition: 300
fx-115ES Plus:  201/2 ( [S<>D] 100.5)
fx-991EX Classwiz:  201/2 ( [S<>D] 100.5)
fx-115D: 300

This is the most inconsistent.  Quite honestly, I don't recommend this algorithm.

What I learned:

1.  Check your manual on how to use the percent function ( % ), not matter what calculator you use.

2.  Calculators with textbook display, the percent function ( % ) merely divides the argument by 100.

3.  This is an sample of six calculators, and as you can see, your mileage may vary.

Have fun calculating,

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.

Thursday, May 9, 2019

Review: Casio fx-300MS 2nd Edition

Review:  Casio fx-300MS 2nd Edition

General Information

Company:  Casio
Type:  Scientific - Algebra (Perfect Algebra Method)
Display: 10 digits with 2 digit exponents
Power:  Solar with battery backup (LR-44)
Memory Registers:  8: A, B, C, D, E, F, X, Y, M
Years In Production: 2019 - present
Cost:  \$10 - \$20 (CVS sells this for \$21, the only place in Southern California that carries the fx-300MS 2nd Edition - for now (as of 4/26/2019))
Documentation:  Manual, can be found online

Also known as:  fx-85MS 2nd Edition

Quick Overview of the Features

*  Trigonometry, Exponential, Logarithms
*  Factorial (of positive integers up to 69), Combinations, Permutations
*  Evaluating Algebraic Expressions up to 79 Characters
*  Memory Arithmetic with M  (M+ and M-)
*  Multi-statement analysis (connected by a colon  ( : ))
*  Statistics including six regressions:  Linear, Logarithm, Exponential, Power, Inverse, Quadratic
*  Fractions: Simplification, conversion between mixed and improper
* Contrast setting
* Two line display: the top line is for the expression and the bottom line is displays the answer

Function wise, the fx-300MS 2nd Edition is the same as the original edition of the fx-300MS and fx-85WA.  For my review on the Casio fx-85WA, click here:     http://edspi31415.blogspot.com/2019/01/retro-review-casio-fx-85wa.html

What is Different of the Second Edition? Left:  fx-300MS,  Right:  fx-300MS 2nd Edition

Last year, Casio introduced its revamped MS series with the goal of redesigning the calculator series.

The MS loses its curvy shape in favor of a rounded box design, which is made to feel more comfortable when operating in the calculator in the hand. I favor this design as the 2nd Edition feels more comfortable in the hand. Close up of the numeric keys:  Left:  fx-300MS Plus, Right:  fx-300MS Plus 2nd Edition

The fonts on the keys are larger and the keys have better font-background ratio, which results in the keys being more readable.  The number keys are bigger hand have a charcoal black background instead of a gray background.

The arrow keyboard is replaced with four separate arrow keys.  Instead of four rounded keys for [SHIFT], [ALPHA],[MODE], and [CLEAR], the keys are circular.  The exponent key [ EXP ] has been replaced with [ x10^x ], a trend with Casio scientific and graphing calculators.

I like the feel of the keys on the 2nd Edition a lot better than the previous edition, the keys feel more firm and steady to the touch.

The display is similar to the previous edition, except that it is more sensitive to the touch.  Just be careful when you are handling the calculator near the display. Slide Case for the fx-300MS 2nd Edition

I don't know if this is first, but the MS series slide case is designed to attach and detach in two ways, so no matter where the top of the calculator is pointed, the case will fit on.  This is a really neat feature which I assume that Casio is going to continue when producing future scientific calculators.

Verdict

I like the keyboards of the 2nd Edition MS series, the calculators look more high-tech, the keyboard is firmer,  and I love the large font on the keys.  I am now looking to get the fx-991 MS 2nd Edition.  That said, if you have the original edition, there really isn't a need to trade it or be rid of it, the original edition is still adequate for use.

I guess it boils down to a matter of preference.  If you want the 2nd Edition and can find one (especially in the United States, I may have to go online for the fx-991 MS 2nd Edition), go for it.

Happy calculating,

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.

Monday, May 6, 2019

HP Prime and HP 42S/DM42/Free42: Length of V Belts Solver

HP Prime and HP 42S/DM42/Free42:  Length of V Belts Solver

Introduction

The following equation relates the length of a V belt, the center to center distance between two pulleys or sheaves:

L = 2 * C + 1.57 * (D + d) + (D - d)^2/(4 * C)

where:

L = length of the V belt, the belt that wraps around two pulleys (or sheaves)
C = center to center distance
D = diameter of the large pulley/sheave
d = diameter of the small pulley/sheave

HP Program VBELT

This program creates four global variables:

beltlength = L
centerdist = C
lrgpulley = D
smpulley = d

The program then takes you to the Num page of the Solve app.  This allows us to create descriptive variables to help us in the Solve app.

Global variables are created outside the main program.

// create global variables
// outside the main program
EXPORT beltlength;
EXPORT centerdist;
EXPORT lrgpulley;
EXPORT smpulley;

EXPORT VBELT()
BEGIN
// 2019-04-28 EWS

STARTAPP("Solve");

// uncheck E0-E9
LOCAL k;
FOR k FROM 0 TO 9 DO
Solve.UNCHECK(k);
END;

// enter equation to E1
E1:="beltlength=2*centerdist+
1.57*(lrgpulley+smpulley)+
(lrgpulley-smpulley)^2/
(4*centerdist)";
Solve.CHECK(1);

// go to Num View
STARTVIEW(2);

END;

HP 42S/DM42/Free 42 Solver Program VBELT

Use the SOLVER function win calling VBELT.

LPULLEY:  large pulley/sheave diameter
SPULLEY: small pulley/sheave diameter

LBL "VBELT"
MVAR "LENGTH"
MVAR "CENTER"
MVAR "LPULLEY"
MVAR "SPULLEY"
2
RCL * "CENTER"
RCL "LPULLEY"
RCL + "SPULLEY"
1.57
*
+
RCL "LPULLEY"
RCL - "SPULLEY"
X ↑ 2

÷
RCL ÷ "CENTER"
+
RCL - "LENGTH"
END

Examples

Example 1:
Large Pulley Diameter = 1 in
Small Pulley Diameter = 3/4 in
Center to Center Distance = 1.5 in
Result:  V Belt Length ≈ 5.7579 in

Example 2:
Large Pulley Diameter = 1 in
Small Pulley Diameter = 7/16 in
V Belt Length = 6.24 in
Result: Center to Center Distance ≈ 1.975 in

Source:

Gladstone, John Air Conditioning Testing and Balancing: A Field Practice Manual Van Nostrand Reinhold Company: New York.  1974  ISBN 0-442-22703-5

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.

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 ri...