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.

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:
https://drive.google.com/open?id=1A06e_pAPk7fMik07Pbi1tyjbLSUkVUN2

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, [[0],[3]] }, "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

Keypad

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.

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