Thursday, December 29, 2016

PCalc 42 User Functions ( iOS )

PCalc 42 User Functions ( iOS )


Programs for the iOS App PCalc 42 from Previous Posts (during May 2014):








Time to revisit this app:

PCalc42 Decimal to Degrees-Minutes-Seconds (d.mmssss form): 
D > DMS

Switch to Decimal
Set R0 to X
Truncate X
Set R1 to R0
Subtract X from R1
Multiply R1 by 60
Set R2 to R1
Subtract X from R1
Multiply R1 by 60
Set R2 to R1
Truncate R1
Multiply R1 by 0.01
Add R1 to X
Set R3 to R2
Truncate R3
Subtract R3 from R2
Multiply R2 by 0.006
Add R2 to X

Example:   1.85 in DMS form is 1.51 (1° 51’)

PCalc42 Degrees-Minutes-Seconds (d.mmssss form) to Decimal
DMS > D

Switch to Decimal
Set R0 to X
Truncate X
Set R1 to R0
Subtract X from R1
Multiply R1 by 100
Set R2 to R1
Truncate R1
Subtract R1 from R2
Divide R2 by 60
Multiply R2 by 100
Add R1 to R2
Divide R2 by 60
Add R2 to X

Example:  1.3052 (1° 30’ 52”) in decimal form is 1.514444444


PCalc42 Snell’s Law of Refraction

Input: Y: n1, X: n,  n1 ≤ n2

Switch to Degrees
Invert X
Multiply Y by X
Inverse Sine X

Example:  n1 = 1.33, n2 = 1.50.   Output:  62.4573248455

PCalc42 Doppler Effect (RPN)  (SI Units)

Input:  Z:  emitted frequency (Hz), Y:  receiver velocity (m/s), X: source velocity (m/s)
Output:  observed frequency (Hz) on stack X

Negate X
Add Y to X
RPN Swap
RPN Roll Down
Divide X by 299752458
Add 1 to X
Multiply Y by X
RPN Roll Down

Example: 
Z:  Emitted Frequency:  525 Hz
Y:  Receiver Velocity:  214,000,000 ft/s
X:  Source Velocity:  208,000,000 ft/s

Output:  Observed Frequency:  535.5086711249 Hz

PCalc42 Sums (RPN) Σ m, Σ m^2, Σ m^3

The sum of Σ m^X from m = 1 to m = Y, where X is the power, Y is the power (up to 3).  If Y > 3, an error condition occurs. 

Formulas:
Σ m = (X^2 + X) / 2
Σ m^2 = (2*X^3 + 3*X^2 + X) / 6
Σ m^3 = (X * (X+1))^2 / 4

Set R0 to Y
Truncate X
Skip 3 if X = 1
Skip 7 if X = 2
Skip 16 if X = 3
Error
RPN Roll Down
X To Power of 2
Add R0 to X
Divide X by 2
Stop
RPN Roll Down
X To Power of 3
Multiply X by 2
Set R1 to R0
R1 To Power of 2
Multiply R1 by 3
Add R1 to X
Add R0 to X
Divide X by 6
Stop
RPN Roll Down
Add 1 to X
Multiply X by R0
X To Power of 2
Divide X by 4

Example:
Y = 6, X = 1:  Sum is 21
Y = 6, X = 2:  Sum is 91
Y = 6, X = 3:  Sum is 441

PCalc42 Present Value Factor of a Single Sum

PV:  (1 + Y/100)^-X

Y:  interest rate
X:  periods

Negate X
Divide Y by 100
Add 1 to Y
Y To Power of X
RPN Roll Down

Example:  Y = 7 (7%), X =  5 (n = 5)
Output:  0.7129861795

Happy New Year’s Everyone! See you in 2017!    

Eddie


This blog is property of Edward Shore, 2016.



Friday, December 23, 2016

Fun with HP 71B IV

Fun with HP 71B IV

For the previous entries:

Links to other HP 71B Programs:
Fun with the 71B:
http://edspi31415.blogspot.com/2012/06/fun-with-hp-71b.html
Fun with the 71B III:


Rake Wall

The program RAKEWALL calculates:

*  The positions and lengths of studs on a rake wall
*  Angle of the incline




Program RAKEWALL
192 Bytes, 12/22/2016

10 DESTROY B,R,L,N,A
15 DESTROY I,T,O
50 INPUT “BASE:”; B
52 INPUT “RISE:”; R
54 INPUT “RUN:”; L
56 INPUT “O.C. :”; S
74 N = INT(L/S)
76 DEGREES
78 T = ATAN(R/L)
80 DISP “ANGLE =”; T; “°”  @ PAUSE
90 FOR I=L TO 0 STEP –S
92 A = I*TAN(T)+B
94 DISP I; “, “; A  @ PAUSE
96 NEXT I
98 DISP 0; “, “; B

Notes:
Degree symbol (°):  [ g ], [RUN] (CTRL), [ A ]

Example: (amounts are in feet)
BASE:  4
RISE:  3
RUN:  6
O.C.:  16/12  (1 foot, 4 inches)

Output: 
ANGLE = 26.5650511771 °
(Position from where the incline meets the base, length of studs)
6, 7
4.66666666667, 6.33333333334
3.33333333334, 5.66666666667
2.00000000001, 5
0.66666666668, 4.33333333334
0,  4


Automotive Cylinders:  Calculating Displacement and Piston Speed

The program supplies default values which can be accepted or changed.



Program AUTOCYN
217 Bytes, 12/22/2016

10 DESTROY N,B,S,R,E,P
15 INPUT “# CYLINDERS:”,  “6”; N
20 INPUT “BORE (IN):”, “4”; B
25 INPUT “STROKE (IN):”, “4”; S
30 E = PI/4 * B^2 * S * N
35 INPUT “RPM:”; R
40 P = S * R / 6
45 DISP “ENGINE DISPLACEMENT =” @ WAIT 1
50 DISP E; “ IN^3” @ PAUSE
55 DISP “PISTON SPEED =” @ WAIT 1
60 DIPS P; “FPM”

Example 1:
N = 6 cylinders, B = 4 in, S = 4 in, RPM = 3500
Output:  E ≈ 301.59290 in^3, P ≈ 2333.33333 FPM

Example 2:
N = 6 cylinders, B = 4 in, S = 3 in, RPM = 4500
Output:  E ≈ 226.19467 in^3, P = 2250 FPM

Right Triangle Solver

The program RIGHTTRI is a solver for the sides A, B, and C.  To solve for the third side, the desired side needs to have a 0 value, while the other two sides have non-zero values.  Each time a solution is found, the values of A, B, and C are reset (set to 0).



Program RIGHTTRI
502 Bytes, 12/22/2016

10 DESTROY A,B,C,Z$
11 ! LOOP
12 DISP “A, B, C, Solve, Exit”
14 DELAY 0, 0
16 Z$ = KEY$
18 IF Z$ = “A” THEN 30
20 IF Z$ = “B” THEN 40
22 IF Z$ = “C” THEN 50
24 IF Z$ = “S” THEN 60
26 IF Z$ = “E” THEN 96
28 GOTO 12
30 INPUT “A = “; A
32 GOTO 12
40 INPUT “B = “; B
42 GOTO 12
50 INPUT “C = “; C
52 GOTO 12
60 IF A=0 AND B AND C THEN 62 ELSE 70
62 S=SQR(C^2-B^2) @ Z$ = “A”
64 GOTO 90
70 IF A AND B=0 AND C THEN 72 ELSE 80
72 S=SQR(C^2-A^2) @ Z$ = “B”
74 GOTO 90
80 IF A AND B AND C=0 THEN 82 ELSE 86
82 S=SQR(A^2+B^2) @ Z$ = “C”
84 GOTO 90
86 DISP “MUST HAVE ONE 0” @ BEEP @ WAIT .5
88 GOTO 10
90 DISP Z$; “ = “; S @ PAUSE
92 GOTO 10
94 DISP “DONE”

Notes:

The line of IF A=0 AND B AND C… tests whether A is zero, B and C are non-zero.  You can test whether a variable is non-zero by just typing the variable in an IF condition.

The function SQR is the square root function of the HP 71B.

Anything following an exclamation point (!) is a comment.


Basic Bridged-T Notch Filter

The program NOTCH calculates the required capacitor and resistor to null out an undesired frequency.

Inputs:  inductance (H), frequency to nullified (Hz), resistance of the required coil (Ω)



Source:  Rosenstein, Morton.  Computing With the Scientific Calculator Casio: Tokyo, Japan.  1986.  ISBN-10: 1124161430

Program NOTCH
244 Bytes, 12/22/2016

10 DESTROY L,F,I,C,R
20 DISP “INDUCTANCE” @ WAIT 1
22 INPUT “in H: “; L
24 DISP “FREQUENCY” @ WAIT 1
26 INPUT “in Hz: “; F
28 DISP “COIL’S RESISTENCE” @ WAIT 1
30 INPUT “in Ω: “; I
40 C = 1/(2 * PI^2 * F^2 * L)
42 R = (PI * F * L)^2 / I
44 DISP “NOTCH CAPACITOR” @ WAIT 1
46 DISP C; “ F” @ PAUSE
48 DISP “NOTCH RESISTENCE” @ WAIT 1
50 DISP R; “ Ω”

Notes:
Capital Omega Character (Ω):  [ g ], [RUN] (CTRL), [ Q ]

Example:   L = 0.12 H, F = 1170 Hz, Coil Resistance = 30 Ω
Output: 
NOTCH CAPACITOR ≈ 3.08402 * 10^-7 F
NOTCH RESISTENCE ≈ 6485.04070 Ω


Differential Equations and Half-Increment Solution, Numerical Methods

The program HALFDIFF solves the numerical differential equation

d^2y/dt^2 = f(dy/dt, y, t)  given the initial conditions y(t0) = y0 and dy/dt (t0) = dy0

In this notation, y is the independent variable and t is the dependent variable.

The Method

Let C = f(dy/dt, y, t).  Give the change of t as Δt.

First Step:

With t = t0:
h_1/2 = dy0 + C * Δt/2
y1 = y0 + dy0 * Δt

Loop:

t = t0 + Δt
h_I+1/2 = h_I-1/2 + C * Δt
y_I+1 = y_I +h_I+1/2 * Δt

Repeat as many steps as desired.


Source:  Eiseberg, Robert M.  Applied Mathematical Physics with Programmable Pocket Calculators  McGraw-Hill, Inc:  New York.  1976.  ISBN 0-07-019109-3

Program HALFDIFF
250+ bytes, 12/22/2016

Edit f(A,Y,T) at line 5 where
A = y’(t), Y = y(t),  T = t

5 DEF FNF(A,Y,T) = insert function y’(t), y(t), and t here
10 DESTROY A,Y,D,N,H,T
12 RADIANS
20 INPUT “dY/dX (0) = “, “0”; A
22 INPUT “Y(0) = “, “0”; Y
24 INPUT “DELTA T = “,”1”; D
26 INPUT “TMAX = “,”5”; N
28 T = D
44 H = A + FNF(A,Y,T) * D/2
48 Y = Y + H * D
50 DISP D; “, “;  Y @ PAUSE
70 FOR I = 2 * D TO N STEP D
72 T = I @ A = H
76 H = H + FNF(A,Y,T) * D
78 Y = Y + H * D
80 DISP I; “, “; Y @ PAUSE
82 NEXT I

Example:  y’’(t) = y’(t) + 2 *  t with y’(0) = 0, y(0) = 1, Delta t = 1, Max t = 6
FNF(A,Y,T) = A + 2 * T

Results:

T
Y
1
2
2
8
3
26
4
70
5
168
6
376


  
This blog is property of Edward Shore, 2016.





Monday, December 19, 2016

Happy Holidays

To everyone, Happy Holidays and Merry Christmas! Thank you everyone for all the support and comments on this blog.  

Coming up is another series on the HP 71B.  I have some things planned for 2017; let's see where it goes.  

See you after the 25th! - Eddie

Sunday, December 11, 2016

TI-84 Plus CE: Updated TI-84 RPN Program

TI-84 Plus CE:  Updated TI-84 RPN Program

For the original TI84RPN program, click here:

Introduction to TI84RPNS

The program TI84RPNS puts the TI-84 Plus CE into RPN (reverse polish notation) mode with arithmetic functions, power, square root, reciprocal, and π.  The program contains room for one independent memory and a four level stack that works like the classic Hewlett Packard RPN calculators. 

The program uses list 6 (L6) as the stack, with six elements:
L6(1): X stack (displayed – bottom number)
L6(2): Y stack (displayed – top number)
L6(3): Z stack
L6(4): T stack
L6(5): Independent memory stack
L6(6): (temporary memory)

What’s New:  TI84PRNS adds trigonometric, logarithmic, and additional numeric functions have been added.  Also, the [ XTθN ]/(link) key is used to switch angle modes between Degrees and Radians.  

If you need an idea how RPN works, please check this out:  http://edspi31415.blogspot.com/2011/09/rpn-basics.html


To enter numbers, this program requires you to press the [enter] key prior to entering a number on the stack.  

The following keys with the associated functions are available:

Primary Keys



[ enter ]  Enter number
[ + ] Add: Y + X
[ - ] Subtract: Y - X
[ × ] Multiplication: Y * X 
[ ÷ ] Divide: Y/X
[ ^ ]  Exponent: Y^X
[ x2 ] Square:  x^2
[ x-1 ]  Reciprocal:  1/x
[ (-) ] Switch the sign of X (multiply X by -1)
[ sto> ] Store X in independent memory
[ alpha ] Recall memory 
[ clear ] Clear X stack to 0

[ sin ]  Sine of X
[ cos ] Cosine of X
[ tan ] Tangent of X
[ log ]  Common Logarithm (base 10) of X
[ ln ] Natural Logarithm (base e) of X

Function Keys:
[ Y= ] (F1):  CIRC:  Area of the Circle, radius is on stack X
[ window ] (F2):  DIAG:  Diagonal/Polar Radius, √(X^2 + Y^2)
[ zoom ] (F3): PRCH:  Percent Change from Y to X
[ trace ] (F4): ANGL:  Angle Function, angle(Yi+X)
[ graph ] (F5): REAL:  Real portion of the complex number in X


Stack operations:
[ ( ] Swap with X and Y
[ ) ] Roll stack down, result { Y, T, Z, X }

Mode operations:
[ XTθN ] Switch to Degrees Mode

Exit TI84PRNS:
Press [ mode ]

Secondary Keys: Keys pressed after [ 2nd ] is pressed



[ 2nd ]  Cancels 2nd

[ ^ ] ( π )   Enters π to the Stack
[ x2 ] ( √ ) Square Root of X
[ sin ] (sin-1)   Arcsine of X
[ cos ] (cos-1)  Arccosine of X
[ tan ]  (tan-1)  Arctangent of X
[ log ] (10x)  Common antilog (base 10) of X
[ ln ] (ex) Exponential function (base e) of X

Function Keys:
[ Y= ] (F1):  ABS:  Absolute Value of X
[ window ] (F2):  INT:  Integer Part of X
[ zoom ] (F3): FRC:  Fractional Part of X
[ trace ] (F4): SIGN:  Sign of X
[ graph ] (F5): IMAG:  Imaginary portion of the complex number in X

Mode operations:
[ 2nd ], [ XTθN ] Switch to Radians Mode




Example:   2 + 3 + 9 = 14
Keys:
[ enter ], 2, [ enter ]
[ enter ], 3, [ enter ], [ + ], 
[ enter ], 9,  [ enter ], [ + ]

See more examples below. 




TI-84 Plus Program TI84RPNS:

Disp "TI-84+ BASIC RPNS"
Disp "DEC. 2016"
Full
a+bi
{0,0,0,0,0,0}→L6
ClrHome


Lbl 1
While 1
getKey→K
While K=0
getKey→K
Output(2,1,L6(2))
Output(3,1,L6(1))
Output(4,1,"(: SWAP, ): ROLL")
Output(5,1,"MODE: EXIT, ALPHA: RCL")
Output(6,1,"XTθN: DEG/RAD")
Output(7,1,"ENTER: ENTER NUMBER")
Output(8,1,"CIRC/DIAG/PCHG/ANGL/REAL")
End

If K=22:Then:ClrHome:Stop:End

If K=21:Then:Goto 20:End

If K=45:Then:0→L6(1):ClrHome:End
If K=55:Then:L6(2)^L6(1)→L6(6)
Goto 2:End
If K=65:Then:L6(2)/L6(1)→L6(6)
Goto 2:End
If K=75:Then:L6(2)*L6(1)→L6(6)
Goto 2:End
If K=85:Then:L6(2)-L6(1)→L6(6)
Goto 2:End
If K=95:Then:L6(2)+L6(1)→L6(6)
Goto 2:End
If K=105:Then:Goto 4:End

If K=51:Then:1/L6(1)→L6(1):ClrHome:Goto 1:End
If K=61:Then:L6(1)²→L6(1):ClrHome:Goto 1:End
If K=52:Then:sin(L6(1))→L6(1):ClrHome:Goto 1:End
If K=53:Then:cos(L6(1))→L6(1):ClrHome:Goto 1:End
If K=54:Then:tan(L6(1))→L6(1):ClrHome:Goto 1:End
If K=71:Then:log(L6(1))→L6(1):ClrHome:Goto 1:End
If K=81:Then:ln(L6(1))→L6(1):ClrHome:Goto 1:End
If K=104:Then:­L6(1)→L6(1):ClrHome:Goto 1:End

"CIRC"
If K=11:Then:L6(1)²*π→L6(1):ClrHome:Goto 1:End
"DIAG"
If K=12:Then:√(L6(1)²+L6(2)²)→L6(6)
L6(6)→L6(1):L6(3)→L6(2):L6(4)→L6(3)
ClrHome
Goto 1:End
"PCHG"
If K=13:Then:100*(L6(1)-L6(2))/L6(2)→L6(6)
L6(6)→L6(1):L6(3)→L6(2):L6(4)→L6(3)
ClrHome
Goto 1:End
"ANGL"
If K=14
Then:angle(L6(1)+L6(2)*i)→L6(6)
L6(6)→L6(1):L6(3)→L6(2):L6(4)→L6(3)
ClrHome
Goto 1:End
"REAL"
If K=15:Then:real(L6(1))→L6(1):ClrHome:Goto 1:End



If K=63:Then:Goto 5:End
If K=64:Then:Goto 6:End
If K=91:Then:L6(1)→L6(5):Goto 1:End
If K=31:Then:L6(5)→L6(6):Goto 3:End
If K=32:Then:Degree:Goto 1:End


If K=22:Then:ClrHome:Stop:End
Goto 1
Lbl 2
"TWO OPERATION"
L6(6)→L6(1):L6(3)→L6(2):L6(4)→L6(3)
ClrHome
Goto 1
Lbl 3
"RCL/INPUT"
L6(3)→L6(4):L6(2)→L6(3):L6(1)→L6(2)
L6(6)→L6(1):ClrHome
Goto 1
Lbl 4
"INPUT NUMBER"
ClrHome
Input "NUMBER:",N
N→L6(6)
Goto 3
Lbl 5
"SWAP"
L6(1)→L6(6):L6(2)→L6(1):L6(6)→L6(2)
ClrHome
Goto 1
Lbl 6
"ROLL"
L6(1)→L6(6)
L6(2)→L6(1):L6(3)→L6(2):L6(4)→L6(3)
L6(6)→L6(4)
ClrHome
Goto 1

End

Lbl 20
ClrHome
While 1
getKey→K
While K=0
getKey→K
Output(2,1,L6(2))
Output(3,1,L6(1))
Output(4,1,"2ND")
Output(8,1,"ABS /INT /FRC /SIGN/IMAG")
End

If K=21:Goto 1
"PI"
If K=55:Then:
π→L6(6)
L6(3)→L6(4):L6(2)→L6(3):L6(1)→L6(2)
L6(6)→L6(1):ClrHome
Goto 1
End

"OTHERS"
If K=32:Then:Radian:Goto 1:End
If K=61:Then:√(L6(1))→L6(1):ClrHome:Goto 1:End
If K=52:Then:sin-1(L6(1))→L6(1):ClrHome:Goto 1:End
If K=53:Then:cos-1(L6(1))→L6(1):ClrHome:Goto 1:End
If K=54:Then:tan-1(L6(1))→L6(1):ClrHome:Goto 1:End
If K=71:Then:10^(L6(1))→L6(1):ClrHome:Goto 1:End
If K=81:Then:e^(L6(1))→L6(1):ClrHome:Goto 1:End

"ABS "
If K=11:Then:abs(L6(1))→L6(1):ClrHome:Goto 1:End
"INT "
If K=12:Then:iPart(L6(1))→L6(1):ClrHome:Goto 1:End
"FRC "
If K=13:Then:fPart(L6(1))→L6(1):ClrHome:Goto 1:End
"SIGN"
If K=14:Then:abs(L6(1))/L6(1)→L6(1):ClrHome:Goto 1:End
"IMAG"
If K=15:Then:imag(L6(1))→L6(1):ClrHome:Goto 1:End

End



Remember to keep the Order of Operations in mind when running this program.

Example 1:   1/(10 – 1.5^2.5) = 0.1380391041

[ enter ], 10, [ enter ]
[ enter ], 1.5, [ enter ]
[ enter ], 2.5, [ enter ]
[ ^ ], [ - ], [ x-1 ]


Example 2:   √(6^2 + 7^2) = 9.219544457

[ enter ], 6, [ enter ], [ x2 ]
[ enter ], 7, [ enter ], [ x2 ]
[ + ], [ , ]


Example 3:  Store 1.758 in memory. (Let M = 1.758)
Calculate 10 – 1.1^M + 2M = 12.33358933

[ enter ], 1.758, [ enter ], [ sto> ]
[ enter ], 10, [ enter ]
[ enter ], 1.1, [ enter ]
[ alpha ], [ ^ ], [ - ]
[ enter ], 2, [ enter ]
[ alpha ], [ × ], [ + ]

Example 4:  (10 + (8 – 5%)) + 9% = (10 + (8 * .95)) * 1.09 = 19.184

[ enter ], 8, [ enter ]
[ enter ], .95, [ enter ], [ × ]
[ enter ], 10, [ enter ], [ + ]
[ enter ], 1.09, [ enter ], [ × ]


Example 5:  e^(1.5) = 4.48168907

[ enter ], 1.5, [ enter ]
[ 2nd ], [ ln ] (ex)

Example 6:  sin((10/√(2^2 + 2.5^2))°) = 0.0544879291

Use the DIAG function for √(2^2 + 2.5^2)

[ XTθN ] (set Degrees mode)
[ enter ], 2, [ enter ]
[ enter ], 2.5, [ enter ]
[ window ] (F2)
[ x-1 ], [ enter ], 10, [ enter ]
[ * ], [ sin ]


Example 7:  What is the percent change from 10.99 to 20.99?  90.99181074 (%)

[ enter ], 10.99, [ enter ]
[ enter ], 20.99, [ enter ]
[ zoom ] (F3)

This blog is property of Edward Shore, 2016




Expanding Linear Regression

Expanding Linear Regression Introduction – Linear Regression All scientific calculators that have two-variable dimensions has cu...