Saturday, September 9, 2017

Next Week... and Plans for October 2017

I'm so excited, can't want for next week's HHC 2017 calculator conference in Nashville!  It is my annual calculator conference I attend.  I am also giving a short talk on the HP 12C this year: expanding the use of the HP 12C to include applications beyond finance.

http://hhuc.us/2017/

If you can't make it, I will let you know some details (that I can disclose) when I get back.

What I am planning to do for October is to spend at least two weeks working with the Python programming language.  I am aiming to work with either a Raspberry Pi or QPython3 android app (it's free) or both.


Eddie

This blog is property of Edward Shore, 2017

Wednesday, September 6, 2017

Fun with the TI-80

Fun with the TI-80


TI-80 Program D2DMS - Decimal to Degrees-Minutes-Seconds

Variables:

Decimal Format:
D = decimal

DMS Format:
H = degrees/hours, M = minute, S = seconds

INPUT “DEC:”,D
IPART D→H
IPART (60*FPART D)→M
60 * FPART (60 * FPART D)→S
DISP “H,M,S:”,H,M,S

TI-80 Program DMS2D - Degrees-Minutes-Seconds to Decimal

Variables:

Decimal Format:
D = decimal

DMS Format:
H = degrees/hours, M = minute, S = seconds

INPUT “H:”,H
INPUT “M:”,M
INPUT “S:”,S
H + M/60 + S/3600 → D
DISP “DEC:”,D

TI-80 Program QUADRAT - Quadratic Equation

Variables:

A, B, C are coefficients of the equation Ax^2 + Bx + C, where the discriminant D:

D = B^2 – 4*A*C
If D≥0, then the roots are real and stored in X and Y.

If D<0, then the roots are complex and are in the form of conjugates X ± Yi.  X is the real part, Y is the imaginary part.



DISP “AX^2+BX+C=0”
INPUT “A:”,A
INPUT “B:”,B
INPUT “C:”,C
B^2 – 4AC → D
DISP D 
-B / (2A) → E
IF D≥0
THEN
E + √D/(2A) → X
E - √D/(2A) → Y
DISP “R1:”,X
DIPS “R2:”,Y
ELSE
E → X
√-D / (2A) → Y
DISP “RE:”,X
DISP “IM :”,Y
END

Annuity Factors

Variables:
I = periodic interest rate
N = number of payments/periods/deposits

TI-80 Program USFV – Annuity Future Value Factor

INPUT “I:”,I
INPUT “N:”,N
( (1+.01)^N – 1)/(.01I) → F
DISP F

TI-80 Program USPV – Annuity Present Value Factor

INPUT “I:”,I
INPUT “N:”,N
(1 – (1 + .01I)^-N)/(.01I) → P
DISP P

Two Dimensional Vector Operations

Let two vectors be defined as V1 = [A, B] an V2 = [C, D].  The program calculates the dot product, stored in E, norm of V1, stored in F, norm of V2, stored in G, and the angle between V1 and V2 in degrees, stored in H.

TI-80 Program VECTOR2

DEGREE
DISP “V1:”
INPUT A
INPUT B
DISP “V2:”
INPUT C
INPUT D
AC + BD → E
√(A^2 + B^2) → F
√(C^2 + D^2) → G
COS^-1 (E /(F*G)) → H
DISP “NORM V1:”, F
DISP “NORM V2:”, G
PAUSE
DISP “DOT:”, E
DISP “ANGLE:”, H

Simplistic Logistic Regression

Fit data (x,y) to the equation:

Y = 1 / (A + B*e^(-X))


TI-80 Program SIMPLOG

INPUT “L1:”, L1
INPUT “L2:”, L2
e^-L1 → L1
1/L2 → L2
LINREG(aX+b) L1, L2
a→A: b→B
DISP “1/(B+Ae^X)”,A,B
PAUSE
DISP “CORR^2”,r^2





Eddie


This blog is property of Edward Shore, 2017

Monday, September 4, 2017

Retro Review: Texas Instruments TI-80

TI-80


TI-80 (left), TI-84 Plus CE (right)
Look how thin the TI-80 is
Retro Review: Texas Instruments TI-80

First, thank you Nano for the TI-80 (along with giving me a pair of slide rules and an astronomy poster)!  Much appreciated!
  
Essentials

Company:  Texas Instruments
Years:  1995
Type:  Graphing, Programming
Memory:  7,034 bytes
Operating System: Algebraic
Memory Registers: 27 (A-Z, θ)
Screen:  Monochrome

Batteries:  2 CR2032 batteries

Graphing Modes:  Function (4), Parametric (3).  Table included. 

Regressions:  6: Linear (ax + b), Quadratic, Linear (a + bx), Logarithmic, Exponential, Power

Lists: Up to 99 entries per lists, 6 lists available (L1 through L6)

Matrices: none

Complex Numbers:  none

Keyboard

The keyboard is what one would expect on a Texas Instruments graphing calculator: nice and responsive. 

Screen

The screen is small.  Not kidding.  The screen is only 48 x 64 pixels big, accompanying 8 lines of 16 characters.  That means that the font is small.  What is wild is that the pi symbol (π) does not conform to the rest of the font, and is twice as long as the rest of the characters.

The screen is still bigger than the mini-graphing calculators such as the Casio fx-6300g or the Hewlett Packard HP-9g.

Is the TI-80 a simplified TI-81?

For the most part, no.  Sure, the TI-80 does not have matrices and hyperbolic functions (sinh, cosh, etc) like the TI-81.  However, the TI-80 has fractions (see the next section), integer division and remainder function, random integer, a complementary table mode, and lists.  The number of stat plots increased to 3, which they don’t have to depend on the statistics mode.

As far as programming memory, the TI-80 beats the TI-81: 7,034 bytes to 2,400 bytes.  Also, you can go beyond 37 programs for the TI-80, as the names are not restricted to one character.

Fractions

The TI-80 has a dedicated fraction menu, which allow users to convert between improper and proper form, as well as conversion between fraction and decimal approximation.  The Manual Simplification mode allows fractions to not be automatically simplified on calculation. 

To enter fractions, the format is:  A _ B / C
Note that the slash is bold.  Merely pressing the division key will not register the fraction.

To separate the whole part from the fraction, press [ 2nd ] [ + ] (UNIT_).

To separate the numerator from the denominator, press [ 2nd ] [ ÷ ] (b/c).

Example:  Enter 2 3/4
Keystrokes:  2 [ 2nd ] [ + ] 3 [ 2nd ] [ ÷ ] 4

According to Datamath (http://www.datamath.org/Graphing/TI-80.htm ), the TI-80 would get replaced with the TI-73 in 1998.  This may mean that the TI-80 became the base for the TI-73 series (TI-73, TI-73 explorer).

Lists

The TI-80 allows for 6 lists, each with a 99 element capacity.  Arithmetic can be operated on two same-sized lists, on an element-by-element functions.  Lists functions include sorting, dimension, minimum, maximum, sum of the elements, product of the elements, and sequence generation.

Programming

Programming is fairly basic for the TI-81.  Commands:
If-Then-Else-End Structure (IF, THEN, ELSE, END)
Quick if structure
For-End structure (no IS>, DS< this time) (FOR, END)
Labels:  one character and local labels (LBL, GOTO)
Subroutines (PRGM_, RETURN)
Drawing commands include points, shading (three types, general, Y<, Y>)

Since the only built-in calculus function of the TI-80 is numerical derivation (NDERIV), two programs for Newton’s Method and Simpson’s Rule are presented below.

TI-80 Program:  SOLVEY1  (Newton’s Method)

80 bytes
The equation is stored in Y1.  The program solves for X in Y1(X) = 0

INPUT “GUESS:”, X
LBL 0
X-Y1/NDERIV(Y1,X,X)→N
IF ABS (X-N)>1E-10
THEN
N→X
GOTO 0
END
N→X
DISP “X = “, X

Example: X^2-3X+1, guess X = 3
Result:  X = 2.618033989

TI-80 Program: SIMPY1 (Integral, Simpson’s Rule)

140 bytes
The equation is stored in Y1.  The program calculates ∫(Y1,X,A,B)

RADIAN
INPUT “A:”,A
INPUT “B:”,B
INPUT “N (EVEN):”,N
(B-A)/N→H
0→T
FOR(I,1,N-1)
A+IH→X
T+2*Y1→T
IF FPART(I/2)≠0
2*Y1+T→T
END
(T+Y1(A)+Y1(B))H/3→T
DISP “INTEGRAL:”,T

Example: X^2-3X+1, with A = 0 to B = 5 and N = 10
Result:  X = 9.166666667

Final Verdict

The TI-80 is a nice introductory calculator, and thanks to programming a lot can be done with it.  I wish the screen was bigger and degree/degrees-minutes-seconds conversions were available, but other than that, it was a great calculator which provides a lot of features (maybe not as intimidating as more advanced calculators). 

It is a nice calculator to add to the collection, and I thank you Nano immensely. 

Eddie


This blog is property of Edward Shore, 2017.

Friday, September 1, 2017

TI-84 Plus CE: Fitting Points to an Ellipse

TI-84 Plus CE: Fitting Points to an Ellipse

Back to one of my favorite subjects: curve fitting.



The program ELLIPFIT attempts to fit a parametric curve for a collection of points (x, y) to an ellipse using the following equations:

x = a * cos t + b
y = c * sin t + d

where the independent variable is t.  The program also plots the estimated line and the scatter plot.  I decided to keep the correlation (r^2) separate, so we can tell how well the line fits both the x and y data. 

The program uses the range of 0 ≤ t ≤ 2*π, where t is in radians.

The user is asked to provide two lists, x and y.   The list of t values is determined by the atan2, angle, or arg function of the complex number point x + y*i.  The angle is adjusted to the range of [0, 2*π].

Quadrant I: x ≥ 0, y ≥ 0, angle(x + y*i)
Quadrant II: x < 0, y ≥ 0, angle(x + y*i)
Quadrant III: x < 0, y < 0, angle(x + y*i) + 2*π
Quadrant IV: x ≥ 0, y < 0, angle(x + y*i) + 2*π

TI-84 Plus CE Program ELLIPFIT

Notes:

L1: list 1, [ 2nd ] [ 1 ]; L2: list 2, [ 2nd ] [ 2 ], etc.  X1T, Y1T are from the [ vars ], Y-VARS, Parametric submenu

[square] is from [2nd] [ y= ] (stat plot) , MARK submenu, option 1

The complex variable i = √-1 is found by pressing [ 2nd ] [ . ].

Program:

"ELLIPTICAL FIT"
"2017-08-31 EWS"
Param:Radian:a+bi
Input "X LIST: ",L2
Input "Y LIST: ",L3
FnOff
L2→L1
For(I,1,dim(L1))
angle(L2(I)+L3(I)*i)→T
If L3(I)<0
Then
T+2π→T
End
T→L1(I)
End
PlotsOff
cos(L1)→L4
LinReg(ax+b) L4,L2
a→A:b→B:r²→E
"Acos(T)+B"→X1T
ClrHome
Disp "X = A*cos(T)+B"
Disp A
Disp B
Disp "CORR: "
Pause E
sin(L1)→L4
LinReg(ax+b) L4,L3
a→C:b→D:r²→F
"Csin(T)+D"→Y1T
ClrHome
Disp "Y = C*sin(T)+D"
Disp C
Disp D
Disp "CORR: "
Pause F
FnOn 1
PlotsOn 1
GraphColor(1,RED)
Plot1(Scatter,L2,L3,[square],GREEN)
0→Tmin
2π→Tmax
ZoomStat

(Obviously use the colors and makers you like.   If you are working with a monochrome TI-83/TI-84, ignore the color commands.)

You can get a download here:

Example 1

A perfect circle:

X
Y
0
1
1
0
0
-1
-1
0

Results:
x = cos t (r^2 = 1)
y = sin t (r^2 = 1)




Example 2

X
Y
1.0
0.0
0.5
0.5
0.0
1.0
-0.5
0.5
-1.0
0.0
-0.5
-0.5
0.0
-1.0
0.5
-0.5

Results:
x = 0.8535533906 cos t (r^2  ≈ 0.97140)
y = 0.8535533906 sin t  (r^2 ≈ 0.97140)

 


Eddie


This blog is property of Edward Shore, 2017.

Wednesday, August 30, 2017

TI-84 Plus CE: Fitting a Parametric Line

TI-84 Plus CE:  Fitting a Parametric Line

The program PARLIN attempts to fit a parametric line for a collection of points (x(t), y(t)) using the following equations:

x = a * t + b
y = c * t + d

where the independent variable is t.  The program also plots the estimated line and the scatter plot.  I decided to keep the correlation (r^2) separate, so we can tell how well the line fits both the x and y data. 

TI-84 Plus CE Program PARAM

Notes:

L1: list 1, [ 2nd ] [ 1 ]; L2: list 2, [ 2nd ] [ 2 ], etc.  X1T, Y1T are from the [ vars ], Y-VARS, Parametric submenu

[square] is from [2nd] [ y= ] (stat plot) , MARK submenu, option 1

Program:

Param
Input "T LIST: ",L1
Input "X LIST: ",L2
Input "Y LIST: ",L3
FnOff
PlotsOff
LinReg(ax+b) L1,L2
a→A:b→B:r²→E
"AT+B"→X1T
ClrHome
Disp "X = A*T + B"
Disp A
Disp B
Disp "CORR: "
Pause E
LinReg(ax+b) L1,L3
a→C:b→D:r²→F
"CT+D"→Y1T
ClrHome
Disp "Y = C*T + D"
Disp C
Disp D
Disp "CORR: "
Pause F
min(L1)-5→Tmin
max(L1)+5→Tmax
FnOn 1
PlotsOn 1
GraphColor(1,BLUE)
Plot1(Scatter,L2,L3, [square] ,ORANGE)
ZoomStat

(Obviously use the colors and makers you like.   If you are working with a monochrome TI-83/TI-84, ignore the color commands.)

You can also download the program here:


Example 1

Fit the data to a parametric line:

T
X
Y
1
2.3
-3.0
2
2.8
-2.6
3
3.2
-2.3
4
3.7
-1.9
5
4.2
-1.6

Results:  
x = 0.47*t + 1.83 (r^2 ≈ 0.998)
y = 0.35*t – 3.33 (r^2 ≈ 0.997)




Example 2

Fit the data to a parametric line:

T
X
Y
1
-1.0
1.000
2
1.0
1.250
4
5.3
1.746
8
13.6
2.825
16
30.1
4.275

Results:
x = 2.075268817 * t – 3.066666667 (r^2 ≈ 0.99997)
y = 0.2196827957* t + 0.857166667 (r^2 ≈ 0.99145)



Eddie


This blog is property of Edward Shore, 2017.

Friday, August 25, 2017

HP Prime: Shewhart X-Bar Chart (Quality Chart)

HP Prime:  Shewhart X-Bar Chart (Quality Chart)

Introduction and Calculation

The program XCHART generates five variables that describe the parameters of a Shewhart X-bar chart for quality control purposes.  Two limits, upper and lower, are determined, set 3 deviations from the mean, set the boundaries in which a process can vary and still allow the process to be in control.

The samples are arranged in a matrix.  Each row is a sample, with each column is a data point of those samples.  For example, a 15 x 10 matrix represents 15 samples of with the sample size of 10.

The five parameters calculated are:

MM:  Grand Mean.  The mean of all the sample means. 

Sample mean = Σx / n

RM:  Range Mean.  The mean of all ranges of all samples. 

Range = max(sample) – min(sample)

MD:  Mean Deviation.  The mean of all the standard deviation of all samples.

Sample Deviation = √( (Σx^2 – (Σx)^2/n) / (n – 1)

L, U:  Lower and Upper limit of the x-bar chart.  How it is calculated is dependent on the sample size (number of columns).

If the size ≤ 25, then:

U = MM + a2 * RM
L = MM – a2 * RM

Where a2 is a constant.  The values of a2 for sample sizes 2 – 25 can be found here:  http://onlinelibrary.wiley.com/doi/10.1002/9781119975328.app2/pdf

Some values (2 – 11):
Sample Size
a2
Sample Size
a2
2
1.880
7
0.419
3
1.023
8
0.373
4
0.729
9
0.337
5
0.577
10
0.308
6
0.483
11
0.285

HP Prime Program XCHART

EXPORT XCHART(mat)
BEGIN
// 2017-08-25 EWS
// Quality control
// {grand mean, range mean,
// std.dev mean, LCL, UCL}

// Grand mean
LOCAL MM:=mean(mean(TRN(mat)));

// Average range
LOCAL RM,C,R,I,L,cl;
// sample size: columns
C:=colDim(mat);
// number of samples
R:=rowDim(mat);

FOR I FROM 1 TO R DO
cl:=row(mat,I);
RM:=RM+(MAX(cl)-MIN(cl));
END;
RM:=RM/R;

// Average deviation
LOCAL MD:=mean(stddev(TRN(mat)));


// Estimate LCL,UCL

LOCAL U,L;
IF C≤25 THEN
// a2 list for sample size 2-25
LOCAL a;
LOCAL a2:={1.88,1.023,.729,
.577,.483,.419,.373,.337,.308,
.285,.266,.249,.235,.223,
.212,.203,.194,.187,.18,.173,
.167,.162,.157,.153};
a:=a2(C-1);
L:=MM-a*RM;
U:=MM+a*RM;
ELSE
// c4 (C>25)
LOCAL c4:=√(2/(C-1))*((C/2-1)!/
((C-1)/2-1)!);
U:=MM+3*MD/(c4*√C);
L:=MM-3*MD/(c4*√C);
END;
// Results
RETURN {MM,RM,MD,L,U};
END;

Example:

Data Process 6 samples of 6 data points each:

9.48
10.07
10.98
8.9
11.53
11.05
10.04
8.78
10.8
9.45
11.34
8.9
10.75
10.48
10.08
9.36
10.61
9.92
10.05
8.99
10.00
8.33
9.3
9.77
9.65
9.41
10.08
8.91
11.43
9.08
9.74
9.08
11.17
11.21
9.94
8.89

Since the sample size is not greater than 25, the range is used, with a2 = 0.483 (for the size of 6).

Results:
MM = 9.93194444444
RM = 2.19
MD = 0.785268047476
L = 8.87417444444  (lower limit)
U = 10.9897144444  (upper limit)

According to the results, the process needs further investigation.

Sources:

Aczel, Amir D. and Sounderpandian, Jayavel.  Complete Business Statistics McGraw-Hill Irwin: Boston. 2006.  ISBN 13: 978-0-07-286882-1

“6.3.2.  What Are Variables Control Charts?”  Engineering Statistics Handbook.  http://www.itl.nist.gov/div898/handbook/pmc/section3/pmc32.htm
Retrieved August 24, 2017

Six Sigma Improvement with Minitab  “Appendix 2: Factors for control charts” Published on line June 22, 2011.   http://onlinelibrary.wiley.com/doi/10.1002/9781119975328.app2/pdf   Retrieved August 24, 2017

Eddie


This blog is property of Edward Shore, 2017.

Next Week... and Plans for October 2017

I'm so excited, can't want for next week's HHC 2017 calculator conference in Nashville!  It is my annual calculator conference ...