Friday, February 15, 2019

TI-86: Sequence Graphing


TI-86: Sequence Graphing

The program Sequen86 plots one recursive sequence with one initial condition. The function is stored in variable y1, with x presenting y1(n-1). The initial condition is assumed to be y1(1).

This program was originally posted on ticalc.org on April 28, 2001. Link: https://www.ticalc.org/archives/files/fileinfo/186/18667.html

18 years, wow, how time flies.

TI-86 Program Sequen86
(354 bytes)

Func
FnOff
PlOff
ClLCD
DelVar(L1)
DelVar(L2)
Outpt(6,1,”Let y1 = u”)
Outpt(7,1,”Let x = n-1”)
InpSt “y1 =”, Y
St>Eq(Y,y1)
Input “Initial Cond: “,I
Input “# of Steps: “,S
{I} → U
For(N, dimL U+1, S+1, 1)
y1(U(N-1)) → U(N)
End
seq(x,x,1,S+1) → L1
U → L2
0 → xMin
S+1 → xMax
min(U) – 1 → yMin
max(U) + 1 → yMax
Plot1(1,L1,L2)
FnOff 1
Disp “L1 = n”
Pause “L2 = u”
DispG


Example:

u(n) = u(n-1)/3 + 1/4
Initial condition, u(1) = 1/5
Number of Steps: 10

Set up for Sequen86:
y1 = x/3 + 1/4




The 2019 Version

Here is an alternate version, SEQGRAPH. Use U for U(n-1) and N for n. The program allows the initial condition for any value of N.

TI-86 Program SEQGRAPH
(277 bytes)

InpSt “U1(U,N) = “,S1
St>Eq(S1,U1)
Input “N Start = “,N
Input “U0 = “,U
Input “Steps: “,S
S + 1 → dimL xList
S + 1 → dimL yList
N → xList(1)
U → yList(1)
For(I, 2, S+1)
xList(I-1) + 1 → N
N → xList(I)
yList(I-1) → U
U1 → yList(I)
End
FnOff
PlOff
PlOn 1
Plot1(1,xList,yList)
ZData

Example:

u(n) = u(n-1)/3 + 1/4
Initial condition, u(1) = 1/5
Number of Steps: 10

Set up for SEQGRAPH:
U1 = U/3 + 1/4
N Start: 1
U0 = 1/5 (initial condition)



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, February 14, 2019

TI-86: Angle Between Vectors, Vandermonde Matrix, Least Squares Algorithm, Chebyshev Polynomials (1st Kind)


TI-86: Angle Between Vectors, Vandermonde Matrix, Least Squares Algorithm, Chebyshev Polynomials (1st Kind)

The TI-86 has one of the best interfaces for a graphing calculator I ever had the joy to work with. The TI-86 is an update of the TI-85. Here are some programs for the TI-86.

Angle Between Vectors

The program vangle calculates the angle between two angles. The angle is calculated in degrees.



TI-86 Program vangle
(75 bytes)

Prompt V1
Prompt V2
Disp cos⁻¹ (dot(V1,V2)/(norm V1*V2))

Example: [2, -3, 4] and [8, 1, -2]
Angle: 83.5823268926°

Vandermonde Matrix

The program vander creates a matrix based on a list of coefficients.

Example: {x, y, z} produces the matrix

[ [x^0, x^1, x^2], [y^0, y^1, y^2], [z^0, z^1, z^2] ]



TI-86 Program vander
(125 bytes)

Input “List: “, L1
dimL L1 → N
{N, N} → dimL MA
For(R, 1, N)
For(C, 1, N)
L1(R)^(C-1) → MA(R,C)
End
End
Disp “MA=”
Pause MA

Example: {2, 4, 7}
Result: [ [1, 2, 4], [1, 4, 16], [1, 7, 49] ]

Least Square Algorithm

The program LSQ taxes the matrices X and Y (Y is a one-column matrix), and calculates
(X^T X)^-1 (X^T Y).

LSQ is used to fit statistical fits with least squares.



TI-86 Program LSQ
(118 bytes)

Disp “Least Squares”
Input “Matrix X: “,MX
Input “Matrix Y: “,MY
(MX^T * MX)^-1 * (MX^T * MY) → ML
Disp “ML= “
Pause ML

Example:
MX = [ [1, 3, 2.0], [1, 4, 2.3], [1, 5, 2.6], [1, 8, 2.9] ]
MY = [ [1.6], [1.8], [2.1], [2.3] ]

Results:
ML = [ [-0.14444444449], [-1.666666667E-2], [0.88888888889] ]

Chebyshev Polynomials (1st Kind)

The program tcheby calculates the numerical value of the Chebyshev polynomials of the 1st Kind given its point, X, and the order, N.

TI-86 Program tcheby
(127 bytes)

Prompt X,N
If X>1 : Goto A
If X<-1 :="" b="" goto="" span="">
cos(N * cos⁻¹ X) → A
Goto C
Lbl A
cosh(N * cosh⁻¹ X) → A
Goto C
Lbl B
(-1)^N * cosh(N * cosh⁻¹ X) → A
Lbl C
Disp A

Example:
X = -2.5, N = 4, Result: 263.5
X = 0.5, N = 4, Result: -0.5
X = 2.5, N = 4, Result: 263.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.

Saturday, February 9, 2019

App Spotlight: MyScript Calculator 2


App Spotlight: MyScript Calculator 2


App: MyScript 2
Platform: Android, iOS
Price:
Android: Free Until February 12, 2019, $2.99 Thereafter
iOS: $2.99

I received an email from MyScript about their newly released MyScript Calculator 2 for Android.

MyScript Calculator 2 is an update to the MyScript calculator. You can see my review for the original version here: http://edspi31415.blogspot.com/2013/01/review-myscript-calculator.html.

What is in the new version?

* You can display results in decimal (up to 6 decimal places) with one of two settings: truncated or rounded, or you can display answers in simplified fractions (improper or in mixed form)
* The ability to turn on automatic calculation or manual calculation
* You can solve some equations. Caveats: Limited to simple equations (not full quadratic or cubic equations, yet)
* We can drag numbers to copy them in different calculations. Dragging numbers to the blue bar on top of the screen will store them in memory. Stored numbers will be available even if the workspace is cleared. To pick a number for dragging, all you have to do is to press on a number, hold until the number is boxed. At that point, you can drag the box.

Here are some screen shots from Version 2.




Here is a video demonstration of MyScript Calculator 2 by the company: https://www.youtube.com/watch?v=EpU24ooMY-8&feature=youtu.be

I thank Giovanni Rodriguez of Marketing for introducing me to MyScript 2.

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, February 7, 2019

Casio fx-3650P: Chebyshev Polynomials, Roots of a Complex Number, Reversion Value, Mach Speed, Trapezoid Perimeter


Casio fx-3650P: Chebyshev Polynomials, Roots of a Complex Number, Reversion Value, Mach Speed, Trapezoid Perimeter

Chebyshev Polynomials of the First Kind

Values of the Chebyshev polynomials can calculated by the following:

T_n (x):

cos (n acos x) if |x| ≤ 1

cosh (n acosh x) if x ≥ 1

(-1)^n cosh (n acosh(-x)) if x ≤ 1

Inputs: x, y (n) order. The program assumes y is an integer.

Program (74 bytes):

? → X : ? → Y : X > 1 ⇒ Goto 1 :
-1 > X ⇒ Goto 2 : cos ( Y cos¹ X ) → A : Goto 3 :
Lbl 1 : cosh ( Y cosh¹ X ) → A : Goto 3
Lbl 2 : (-1)^Y * cosh ( Y cosh¹ X ) → A :
Lbl 3: A

Examples

T_Y(X)

X: -3, Y: 5, Result: -3363
X: 0.3, Y: 5, Result: 0.99888
X: 3, Y: 5, Result: 3363

Roots of a Complex Number

This program calculates the roots of a complex number (x + yi)^a, which is calculated as:

r^(1/n) * ( cos((θ + 2 π k)/n) + i*sin((θ + 2 π k)/n) )

where k = 0 to n-1
r =√(x^2 + y^2)
θ = angle(x + yi) = atan(y/x)

Program (66 bytes):

? → X : ? → Y : ? → A : 0 → M :
Rad : Pol(X,Y) : A x√ X → B :
Y → D : Lbl 1 : M ⊿ Rec(B, (D + 2 Ï€ M )/A) ⊿
Y ⊿ 1 M+ : M ≠ A ⇒ Goto 1 : M

The program stops when M = A.

Example:

(-2 + 4i)^(1/4)

X: -2, Y: 4, A: 4

(Fix 4 setting)
M: 0, X: 1.2701, Y: 0.7082
M: 1, X: -0.7082, Y: 1.2701
M: 2, X: -1.2701, Y: -0.7082
M: 3, X: 0.7082, Y: -1.2701
M: 4 (end)

Business: Reversion Value

Input:

A = n: number of payments
B = I%: periodic interest rate (in decimal)
C = monthly rent
D = asking price

Note: For monthly payments, divide the annual interest rate by 1200.

Program (55 bytes):

Fix 2 : ? → A : ? → B : ? → C : ? → D :
-C (1 + B) ( (1 + B)^A -1 ) ÷ B → X :
X + D (1 + B)^A → X : X

Example:
5 years of monthly payments, A = 60
Interest rate, B = 6/1200
Monthly Rate, C = 1895
Asking Price, D = 250000


Result: 204337.26

Source:
Roger F. Farish and Elbert B. Greynolds, Jr., Ph.D., CPA Calculator Analysis for Business and Finance Texas Instruments Incorporated 1978 ISBN 0-07-063757-1

Mach Speed

This program calculates the mach speed, a ratio of the speed of sound given:

A = the altitude of the object, such as a vehicle (in feet)
B = temperature (°F)
C = velocity of the vehicle (mph)

Equations used:

Mach Number = velocity of the vehicle / speed of sound

where Speed of Sound = 44100 / 1519 * √( 459.7 + B – 3.57 * A / 1000)

Program (52 bytes):

? → A : ? → B : ? → C :
44100 ÷ 1519 * √ ( 459.7 + B – 3.57 A ÷ 1000 ) → D :
C ÷ D → M

A lapse rate of -3.57° per 1000 ft altitude is assumed.

Example:

Input:
A: altitude = 2500 ft
B: temperature = 63 °F
C: velocity = 795 mph

Result:
mach speed: 1.208091501

Source:
“Mach Number and Airspeed vs Altitude” Granite Island Group (Technical Surveillance Counter Measures) http://www.tscm.com/mach-as.pdf Retrieved January 26, 2019

Perimeter of a Trapezoid



P + A + B + C * (1/sin X + 1/sin Y)

Program (38 bytes):

Deg : ? → A : ? → B : ? → C : ? → X : ? → Y :
A + B + C ( 1 ÷ sin X + 1 ÷ sin Y )

Example:
A = 227.6
B = 305.4
C = 10.5
X = 86°
Y = 5°

Result: 663.999629

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, February 3, 2019

Calculator Programming: Making FOR, WHILE, and REPEAT Loops with IS>, DS<, GOTO, IF, LBL

Calculator Programming:  Making FOR, WHILE, and 
REPEAT Loops with IS>, DS<, GOTO, IF, LBL

Introduction

Say your programming capabilities on your calculator, BASIC portable computer, or programming app does not have the FOR, WHILE, and REPEAT loop structures.  No worries, there are some workarounds we can use.

Today the programs will be demonstrated with the language of the TI-81 and TI-84 Plus CE, but this blog isn't limited to these two calculators.


Simulating FOR Loops with IS> and DS<

The TI-81 (and every Texas Instruments graphing calculator of that family inclusive to the TI-84 Plus CE) has the commands IS> and DS<.

IS>:  Increment and Skip

Syntax:  IS>(variable, target number)

IS> increases the value stored in a variable by 1 and performs a comparison test.  The next command is excited if the increased value is less than or equal to the target number.

IS>(var, target)
[do this command if var + 1 ≤ target]
[skip to this command if var + 1 > target]

Simulating the FOR Loop:

FOR var = begin TO end*
[commands]
NEXT
[commands after loop is over]


* Syntax varies.  For the TI-84 Plus CE:  For(var,begin, end) : [commands] : End

with:

begin → var
LBL [label]
[commands]
IS>(var, end)
GOTO [label]
[commands after loop is over]

The program PRGM1 demonstrates how to accomplish a FOR loop with IS>.  PRGM1 displays the numbers 1 to 10.  The TI-81 section can be programmed by on the TI-81 and TI-84 Plus CE, which the TI-84+ section is for calculators TI-82 and later.

"TI-81"
1→K
Lbl 1
Disp K
IS>(K,10)
Goto 1
Disp "END"
Wait 2
"TI-84+"
For(K,1,10)
Disp K
End
Disp "END"

DS<   

Decrement and Skip

Syntax:  DS<(variable, target number)

DS< decreases the value stored in a variable by 1 and performs a comparison test.  The next command is excited if the increased value is greater than or equal to the target number.  DS< is the opposite of IS>.

DS<(var, target)
[do this command if var - 1 ≥ target]
[skip to this command if var - 1 < target]

Simulating the FOR Loop:

FOR var = begin TO end STEP -1*
[commands]
NEXT
[commands after loop is over]


* Syntax varies.  For the TI-82 to the TI-84 Plus CE, including TI-80 and TI-73:
For(var,begin, end, -1) [commands] End

with:

begin → var
LBL [label]
[commands]
DS<(var, end)
GOTO [label]
[commands after loop is over]

PRGM2 demonstrates the use of DS< and the associated For loop.


"TI-81"
10→K
Lbl 1
Disp K
DS<(K,1)
Goto 1
Disp "END"
Wait 2
"TI-84+"
For(K,10,1,­1)
Disp K
End
Disp "END"

Simulating WHILE and REPEAT Loops

With the proper use of the IF, LBL, and GOTO we can simulate WHILE and REPEAT loops.

Simulated WHILE Loops

WHILE [condition is true]
[commands]
END

* While is available for TI-82 to the TI-84 Plus CE, including TI-73.

can be simulated by:

LBL [label]
[commands]
IF [while condition] 
GOTO [label]

Simulated REPEAT Loops

REPEAT
[commands]
UNTIL [condition]

* The syntax for the TI-82 to the TI-84 Plus CE, including TI-73 is:
Repeat [condition] : [commands] : End

LBL [label]
[commands]
IF [inverse of the repeat condition] 
GOTO [label]

Example:  If the repeat condition is T>5, then the inverse is T≤5.

PRGM3 is a demonstration program on how all three techniques are used to accomplish this:

Start with 1000.  Take the square root.  Keep going until the calculator gets to 1 (by the precision of the calculator).

"TI-81"
1000→K
Lbl 1
√(K)→K
Disp K
If K≠1
Goto 1
Disp "END"
Wait 2
"84+ WHILE"
1000→K
While K≠1
√(K)→K
Disp K
End
Disp "END WHILE"
Wait 2
"84+ REPEAT"
1000→K
Repeat K=1
√(K)→K
Disp K
End
Disp "END REPEAT"

I hope you find these tips useful and helpful.

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.

Wednesday, January 30, 2019

HP 71B: Product of f(x), Nested Radicals, How Much Can I Afford?, Cardiac Analysis

HP 71B:  Product of f(x), Nested Radicals, How Much Can I Afford?, Cardiac Analysis

Product of a Function

∏ f(x)

Edit f(x) at line 10

PROGRAM PRODFX
At least 90 bytes, 1/23/2019

10 DEF FNF(X)=[ insert f(X) here ]
20 INPUT "Lower=";L
30 INPUT "Upper=";U
40 P=1
50 FOR X=L TO U @ P=P*FNF(X) @ NEXT X
60 DISP 'P=';P

Example:  f(X) = FNF(X) = 1/X
Lower:  1
Upper:  5
Result:  6.61375661376E-6

Trigonometric Simplification

Original blog entry (11/15/2018):  http://edspi31415.blogspot.com/2018/11/ti-84-and-casio-fx-cg-50-micropython.html

Source: Dugopolski, Mark  Trigonometry Addison Wesley: Boston 2003 pp 211-212  ISBN 0-201-70338-6

Simply the expression:

a sin x + b cos x = r * sin( θ + x )
where r = √(a^2 + b^2), θ = angle(a,b) = arg(a+bi)

PROGRAM SCTOSIN
114 bytes, 1/23/2019

10 DESTROY A,B,R,T
20 RADIANS
30 DISP "A*SIN(X)+B*COS(X)" @ PAUSE
40 INPUT "A=";A
50 INPUT "B=";B
60 R=SQR(A^2+B^2) @ T=ANGLE(A,B)
70 DISP R;"*SIN(";T;"+X)"

Line 70 can use PRINT
SQR is √

Example: 
A = 2.25,  B = 1.76
Result:
R = 2.85658887486  (scroll left)
θ = .663806440909
Output:
2.85658887486  *SIN( .663806440909 +X)

How Much Car Can You Afford?

Original blog entry (3/13/2018):  https://edspi31415.blogspot.com/2018/03/hp-prime-car-payment-and-affordability.html

Calculate how much the buyer can afford, considering sales tax, discounts, and down payment.  All amounts are entered as positive.

PROGRAM AFFORD
221 bytes, 1/24/2019

10 DESTROY N,I,S,X,W,D,P
20 INPUT "# MONTHS:";N
30 INPUT "RATE %:";I @ I=I/1200
40 INPUT "PAYMENT $";X
50 INPUT "SALES TAX %:";S
60 INPUT "DISCOUNT %:";D
70 INPUT "DOWN PMT $";W
80 P=1/I*(1-(1+I)^(-N))
85 P=P*X
90 P=(P+W)/((1+.01*S)*(1-.01*D))
95 PRINT USING "'AMT: $'7D.DD";P

Example:
Term: N = 60 months
Interest Rate:  I = 4.8%
Desired Payment: X = $295
Sales Tax: S = 9.5%
Discount: D = 10%
Down Payment: W=$1500

Result:
AMT: $17657.09

HP 71B: Cardiac Programs

Source:  Hewlett Packard.  "HP-65 Medical Pac 1" 1974.

Valve Area

Variables:

Input:
P = pressure gradient data (mmHg), enter an average or data points
C = cardiac output (CO) (l/min)
R = R-R interval (seconds)
T = the time the valve is open (seconds)

The program offers a choice between calculating an  area of a regular valve or a mitral valve.

Program VALVE
433 bytes, 1/28/2019

10 DESTROY K,P,N,D,P1,C,R,T,F,V
20 P1=0 @ N=0 @ P=0
30 PRINT "PRESSURE (mmHg)" @ WAIT .5
35 INPUT "P: 1=AVG 2=DATA ";K
38 IF K=1 THEN 50 ELSE 40 
40 INPUT "P DATA: ";D
42 P=P+D @ N=N+1 @ P1=P/N
44 INPUT "DONE? 1=YES 2=NO ";K
46 IF K=2 THEN 40 ELSE 60
50 INPUT "P AVG. :";P1
60 INPUT "CO (l/min): ";C
62 INPUT "R-R (sec): ";R
64 INPUT "OPEN TIME (sec/min):";T
66 F=C*R/(60*T) @ V=F/(.0445*SQR(P1))
68 INPUT "MITRAL 1=YES 2=NO ";K
70 IF K=1 THEN LET V=V/.7
72 PRINT "MEAN FLOW (l/sec) :";F @ PAUSE
74 PRINT "AREA (cm^2) :";V

Anatomic Shunts

The program SHUNTS calculates the bi-directional shunts as a percentage.  The shunts are R-L (right-left) shunt and the L-R (left-right) shunts.

Variables:

Input:
R1:  right pulmonary artery
R2:  right atrium
L1:  left pulmonary artery
L2:  left ventricle

Program SHUNT
230 bytes, 1/27/2019

10 DESTROY L1,L2,R1,R2,L3,R3
20 INPUT "R-PULMONARY%:";R1
30 INPUT "R.ATRIUM%:";R2
40 INPUT "L-PULMONARY%:";L1
50 INPUT "L.ATRIUM%";L2
60 R3=(L1-L2)/(L1-R2)*100
65 L3=(R1-R2)/(L1-R2)*100
70 PRINT USING ' "R-L SHUNT:"4D.DD"%" ';R3 @ PAUSE
75 PRINT USING ' "L-R SHUNT:"4D.DD"%" ';L3 
90 END

Stroke Work

The program STRKWORK calculates stroke work and stroke work index based on pressure, cardiac output (CO), R-R interval (seconds), and body surface area (BSA).  The BSA is optional but is needed to calculate stroke work index. 

Program STRKWORK
404 bytes, 1/28/2019

10 DESTROY S,S1,P,P1,R,C,N,K,D,B
14 DISP "P=PRESSURE mmHg" @ WAIT .5
20 N=0 @ P=0
25 INPUT "P 1:AVG 2:DATA ";K
30 IF K=1 THEN 50
40 INPUT "P. DATA PT: ";D
42 P=P+D @ N=N+1 @ P1=P/N
44 INPUT "DONE? 1=YES 2=NO ";K
46 IF K=2 THEN 40 ELSE 60
50 INPUT "AVG P: ";P1 
60 INPUT "R-R INTERVAL (sec):";R
62 INPUT "CO (L/MIN): ";C
70 S=13.6*P1*C*R/60
72 PRINT "SW =";S;"(gm m)" @ PAUSE
80 INPUT "BSA? (m^2) (0=NONE): ";B
82 IF B=0 THEN 90
84 S1=S/B
86 PRINT "SWI: ";S1;"gm m/m^2"
90 END

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, January 28, 2019

HP 71B: Linear Regression, Open Channel, Sunrise/Sunset, Musical Mini-Piano

HP 71B:  Linear Regression, Open Channel, Sunrise/Sunset, Musical Mini-Piano

Feel free to use this pic whenever it's Friday.  Even if it's Monday.  :) 


Linear Regression with a User Keyboard

This program creates a user keyboard with the following keys defined:

[ I ]  Clears the statistics array and variables
[ A ]  Add a data point X,Y: the sample size is shown
[ D ]  Delete a data point X,Y:  the sample size is shown
[ M ] Sample Mean for X and Y data.  Press CONT for mean of Y values.
[ S ] Sums for X and Y data.  Press CONT for sum of Y values.
[ E ]  Standard Deviation for X and Y data.  Press CONT for standard dev. of Y values.
[ R ]  Execute Linear Regression.  A = intercept, B = slope, correlation is calculated, fit to the line Y = A + B*X
[ H ]  Help:  cycles what all the keys do
[ X ] Clears all the user keys, prepares you to go to the next program

PROGRAM STATLIN
689 bytes, 1/26/2019

10 DEF KEY "I", 'RUN 110'
20 DEF KEY "A", 'RUN 200'
30 DEF KEY "D", 'RUN 300'
40 DEF KEY "M", 'RUN 400'
45 DEF KEY "S", 'RUN 440'
50 DEF KEY "E", 'RUN 500'
60 DEF KEY "R", 'RUN 600'
70 DEF KEY "X", 'RUN 700'
75 DEF KEY "H", 'RUN 750'
80 USER ON
90 END

110 DESTROY S,A,B,X,Y,H$,I
120 STAT S(2) @ PRINT "ALL CLEAR"
130 END

200 INPUT "+ X,Y:";X,Y
210 ADD X,Y & DISP "N=";TOTAL(0)
220 END

300 INPUT "- X,Y:";X,Y
310 DROP X,Y & DISP "N=";TOTAL(0)
320 END

400 PRINT "X-BAR=";MEAN(1) @ PAUSE
420 PRINT "Y-BAR=";MEAN(2)
430 END

440 PRINT CHR$(28);"X=";TOTAL(1) @PAUSE
450 PRINT CHR$(28);"Y=";TOTAL(2)
460 END

500 PRINT "sX:";SDEV(1) @ PAUSE
510 PRINT "sY:";SDEV(2)
520 END

600 LR 2,1,A,B
610 PRINT "INT=";A @ PAUSE
620 PRINT "SLP=";B @ PAUSE
630 PRINT "r=";CORR(2,1) @ PAUSE
640 PRINT "Y=";A;"+";B;"X"
650 END

700 PURGE KEYS @ USER OFF
710 PRINT "EXIT COMPLETE"

750 FOR I=1 TO 8
760 READ H$ @ PRINT H$ @ WAIT 1
770 DATA "I: CLEAR","A: ADD","D: DEL","M: MEAN","S: SUMS","E: SDEV","R: A+BX","X: EXIT"
780 NEXT I
790 PRINT "READY." @ END

Example to try:

Data:  X,Y
-5.56, 0.79
-4.30, 0.84
1.86, 1.93
2.24, 2.01
3.95, 2.26

To add data:  (in USER mode) [ A ] -5.56, 0.79 [END LINE] (repeat for all data points)

Results:  n = 5

Mean:
[ M ]  "X-BAR=" -0.362  [ f ] [ + ] (CONT) "Y-BAR=" 1.566

Sums:
[ S ]  "∑X=" -1.81 [ f ] [ + ] (CONT) "∑Y=" 7.83

Standard Deviations:
[ E ] "sX=" 4.26696847891 [ f ] [ + ] (CONT) "sY=" 0.696512742166

Linear Regression:
[ R ] "INT=" 1.62489805306  [ f ] [ + ] (CONT)
"SLP=" 0.162701804029 [ f ] [ + ] (CONT)
"r=" 0.996741950615 [ f ] [ + ] (CONT)
"Y=1.6248905306 + 0.162701804029 X"

Open Channel Parameters

Source: 

Michael R. Lindberg, PE  Civil Engineering Reference Manual for the PE Exam 11th Edition  Professional Publications Inc., Belmont, CA  2008  ISBN-13:  978-1-59126-129-2

The program OPENFLOW calculates the following:

Area
Wetted Perimeter
Hydraulic Radius
Hydraulic Depth
Uniform Section Factor

of conductors of four shapes: rectangle, trapezoid, triangle, and circle.



PROGRAM OPENFLOW
781 bytes, 1/25/2019

10 DESTROY K,D,B,P,R,T,H,W
20 DEGREES
30 DISP "1. RECTANGLE" @ WAIT 1
40 DISP "2. TRAPEZOID" @ WAIT 1
50 DISP "3. TRIANGLE" @ WAIT 1
60 DISP "4. CIRCLE" @ WAIT 1
70 DISP "ELSE. REPEAT" @ WAIT .5
80 INPUT "CHOICE (1-4,E):"; K
90 IF K=1 THEN 1010
100 IF K=2 THEN 2010
110 IF K=3 THEN 3010
120 IF K=4 THEN 4010
130 GOTO 30

1010 INPUT "WIDTH,DEPTH:";W,D
1020 A=D*W @ P=2*D+W @ R=A/P
1030 H=A/W @ S=A*R^(2/3)
1040 GOTO 5010

2010 INPUT "DEPTH:";D
2012 INPUT "WIDTH-LONG:";W
2014 INPUT "WIDTH-SHORT:";B
2016 INPUT "ANGLE:";T
2020 A=D*(B+D/TAN(T)) @ P=B+2*(D/SIN(T)) @ R=A/P
2030 H=A/W @ S=A*R^(2/3)
2040 GOTO 5010

3010 INPUT "WIDTH:";W
3012 INPUT "DEPTH:";D
3014 INPUT "ANGLE:";T
3020 A=D^2/TAN(T) @ P=2*D/SIN(T) @ R=A/P
3030 H=A/W @ S=A*R^(2/3)
3040 GOTO 5010

4010 INPUT "RADIUS:";R
4012 INPUT "ANGLE:";T @ T=PI*T/180
4014 RADIANS
4020 A=1/8*(T-SIN(T))*D^2 @ P=T*D/2 @ R=A/P
4030 H=A/D @ S=A*SQR(D)
4040 GOTO 5010

5010 PRINT "AREA=";A @ PAUSE
5020 PRINT "WET PERIM.=";P @ PAUSE
5030 PRINT "HYD. RADIUS=";R @ PAUSE
5040 PRINT "HYD. DEPTH=";H @ PAUSE
5050 PRINT "SECTION FACTOR=";S
5060 END


Approximate Time of Sunrise and Sunset

Source:

Hewlett Packard "HP-65 Aviation Pac" 1974

The program SUNTIME approximates the time of sunset and sunrise based on a date in a general 365-day calendar, the person's location (longitude (east is negative, west is positive) and latitude (north is positive, south is negative)), and the time zone.

Time Zone Table (United States/Mexico/Canada) 
Hours from GMT:
Hawaii:   Standard and Daylight: -10
Alaska:  Standard: -9, Daylight: -8
Pacific:  Standard: -8, Daylight: -7
Mountain: Standard: -7, Daylight: -6
Central: Standard: -6, Daylight: -5
Eastern: Standard: -5, Daylight: -4

Program SUNTIME
494 bytes, 1/24/2019

10 DESTROY T,E,D,A,Z,G,C
11 DESTROY S,S1,S2,S3
12 DESTROY O1,O2,O3,O,U1,U2,U3,U
14 DEGREES
16 INPUT "MONTH: ";M
20 INPUT "DAY: ";D
26 INPUT "LONG (E/W):D,M,S:";O1,O2,O3
27 O=O1+O2/60+O3/3600
30 INPUT "LAT (S/N):D,M,S:";U1,U2,U3
32 U=U1+U2/60+U3/3600
35 INPUT "TIME ZONE:";Z
40 T=.988*(D-1+30.3*(M-1))
45 E=.123*COS(T+87)-1/6*SIN(2*T+20)
50 C=-23.439*COS(T+10)
55 S=(O-ACOS(-TAN(C)*TAN(U)))/15-E+12+Z
57 S1=IP(S)
59 S2=IP(FP(S)*60)
61 S3=FP(FP(S)*60)*60
65 DISP "Sunrise: ";S1;":";S2;":";S3 @ PAUSE
75 N=(O+ACOS(-TAN(C)*TAN(U)))/15-E+12+Z
77 N1=IP(N)
79 N2=IP(FP(N)*60)
81 N3=FP(FP(N)*60)*60
85 DISP "Sunset: ";N1;":";N2;":";N3

Example:
Time:  January 26  (Month = 1, Day = 26)
Place:  Farifield, CA:   38°15′28″N 122°3′15″W
Time Zone: -8 (Standard)

Inputs:
MONTH: 1
DAY: 26
LONG: 122,3,15
LAT: 38,15,28
TIME ZONE: -8

Results:
Sunrise: 7 : 24 : 19.09497708
Sunset: 17 : 16 : 17.62419468

Musical Mini-Piano

Key map:

[ A ]:  A
[ W ]:  A#
[ S ]: B
[ D ]: C
[ R ]: C#
[ F ]: D
[ T ]: D#
[ G ]: E
[ H ] : F
[ U ]: F#
[ J ]: G
[ I ]: G#
[ K ]: A (higher octave)

[ O ]: One octave higher
[ L ]:  One octave lower

[ P ]: Double the length of the note
[ = ]: Halve the length of the note

[ X ]:  Exit, clears all the user keys

Default octave:  A4 (220 HZ) to A5 (440 Hz)
Default note length:  1/4 second

Program PIANO
743 bytes, 1/27/2019

100 DESTROY A,N,P
110 A=2^(1/12) @ N=0 @ P=0
112 DEF KEY "A", 'BEEP 220.0*2^N,.25*2^P': ! A
114 DEF KEY "W", 'BEEP 233.1*2^N,.25*2^P': ! A#
116 DEF KEY "S'", 'BEEP 246.9*2^N,.25*2^P': ! B
118 DEF KEY "D", 'BEEP 261.6*2^N,.25*2^P': ! C
120 DEF KEY "R", 'BEEP 277.2*2^N,.25*2^P': ! C#
122 DEF KEY "F", 'BEEP 293.7*2^N,.25*2^P': ! D
124 DEF KEY "T", 'BEEP 311.0*2^N,.25*2^P': ! D#
126 DEF KEY "G", 'BEEP 329.6*2^N,.25*2^P': ! E
128 DEF KEY "H", 'BEEP 349.2*2^N,.25*2^P': ! F
129 DEF KEY "J", 'BEEP 392.0*2^N,.25*2^P': ! G
130 DEF KEY "U", 'BEEP 370.0*2^N,.25*2^P': ! G#
132 DEF KEY "I", 'BEEP 415.3*2^N,.25*2^P': ! F
134 DEF KEY "K", 'BEEP 440.0*2^N,.25*2^P': ! A
136 DEF KEY "O", 'N=N+1@ PRINT "OCTAVE UP" ':
138 DEF KEY "L", 'N=N-1 @ PRINT "OCTAVE DOWN" ':
140 DEF KEY "P", 'P=P+1 @ PRINT "NOTE x2" ':
142 DEF KEY "=", 'P=P-1 @ PRINT "NOTE /2" ': 
144 DEF KEY "X", 'RUN 400':
146 USER ON
148 END
400 DESTROY A,N,P
410 PURGE KEYS
420 USER OFF
430 PRINT "EXIT COMPLETE"
440 END

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, January 21, 2019

HP Prime: Renaming Headers in Statistic Editors

HP Prime:  Renaming Headers in Statistic Editors

I recently received an email asking for help of how to rename columns of the Statistics Editor screen.  I was not able to figure it out myself, I then asked if anyone at the Museum of HP Calculators knew. 

Link to the HPMoC thread:  http://www.hpmuseum.org/forum/thread-12231.html

Tim Wesseman replied that you can change the header name in the statistic editor by using:

D1(-1) = " [ header name in a string ] "

This applies to D2 - D9, D0, C1 - C9, and C0.  The HP Prime uses D# in anaylzing 1 Variable Statistics and C# in analyzing 2 Variable Statistics.



In the illustration listed above, I renamed the headers for both C1 and C2 as "X DATA" and "Y DATA". 

C1(-1):="X DATA"
C2(-1):="Y DATA"

Note this only changes the header in the Numeric View of the Statistics apps (Statistics 1Var, Statistics 2Var).

Caution:  This only works for Statistics columns, not for list columns for the list editor, or the matrix columns and rows for the matrix editor.

Tyann states to clear the header, simply store an empty string.  In this example,

C1(-1):=""
C2(-1):=""

Thanks to Tim Wessman, Tyann, and Roger Céspedes Esteban to sending me the email (the best for your Descriptive Statistics app, Roger).

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-50F/Radio Shack EC-4024 Program Collection: October 2026

Casio fx-50F/Radio Shack EC-4024 Program Collection: October 2026 Notes: * The fx-50F/EC-4024 has a 29 step program space betwe...