Sunday, April 26, 2020

Casio fx-CG 50: Shortcuts Study

Casio fx-CG 50: Shortcuts Study

Introduction

When programming in calculators, sometimes it is useful to use alternate ways of accomplishing the task.  The alternate way could save keystrokes and memory, which can become important with older programming calculators and calculators where the number of steps available is about 150 or lower. 

Complex Number Functions

Some of the shortcut methods involves complex numbers and complex number operations, particular involving polar-rectangular conversions.

Below are the four common conversion calculations needed and alternate ways to accomplish them: 

√(x^2 + y^2) = abs(x + y ⅈ) = R>Pr(x,y) 

atan( y / x ) = arg(x + y ⅈ) = R>Pθ(x,y)**

r cos θ = real( r ∠ θ) = P>Rx(r,θ)

r sin θ = imag(r ∠ θ) = P>Ry(r,θ)

** The domain in the atan function is (-90°, 90°) while the arg (sometimes named atan2 and angle) and R>Pθ functions takes the (x,y) coordinates to account and the domain is (-180°, 180°).

Casio fx-CG50 Program: SHORTCUT

The program SHORTCUT illustrates six shortcut techniques regarding:

1.  Law of Cosines - Calculating the Third Side of a triangle

c = √(a^2 + b^2 - 2ab cos θ)
Complex Number Alternate: c = abs( real(a∠θ) - b + imag(a∠θ)*ⅈ )

2.  Rounding to the Nearest Integer

Alternate to the round function:  int( frac x + x 0

3.  √(1 - x^2),  |x| < 1

Trigonometric Alternate:  sin(acos x )

4.  x / √(1 + x^2),  any x

Trigonometric Alternate:  sin(atan x)

5.  √(a^2 + b^2 + c^2)

Complex Number Alternate:  abs(c + abs(a + b*ⅈ) * ⅈ)

6.  √(a^2 + 2*b^2)

Two Step Alternate (this is just one of many ways):
abs(a + b*ⅈ)
abs(b + ans*ⅈ)

Program:

Anything that follows // is a comment.  Don't type the comment in. 

a+bⅈ       // turn complex mode on
"BETTER PROG HP67/97"    // credit to source, slash character from CHAR menu
"EWS 2020-03-09"
Menu "SHORTCUTS","LAW OF COSINES",1,"ROUND TO INTEGER",2,
"√(1-X^2)",3," X÷√(1+X^2)",4,"√(A^2+B^2+C^2)",5,"√(A^2+2*B^2)",6

Lbl 1
"θ"?→θ
"A"?→A
"B"?→B
"√(A^2+B^2-2AB cos θ)"→Str 1
Exp(Str 1)→R            
"Abs(Rep(A∠θ)-B+Imp(A∠θ)ⅈ"→Str 2
Exp(Str 2)→S
Goto R

// Exp numerically evaluates a string 

Lbl 2
"NUMBER"?→X
"RndFix(X,0)"→Str 1
RndFix(X,0)→R      
// Exp(RndFix(a,b)) leads to an error message
"Int (Frac X+X)"→Str 2
Exp(Str 2)→S
Goto R

Lbl 3
"-1
"√(1-X^2) "→Str 1
Exp(Str 1)→R
"sin cos^-1 X"→Str 2
Exp(Str 2)→S
Goto R

Lbl 4
"X"?→X
"X÷√(1+X^2)"→Str 1
Exp(Str 1)→R
"sin tan^-1 X"→Str 2
Exp(Str 2)→S
Goto R

Lbl 5
"A"?→A
"B"?→B
"C"?→C
"√(A^2+B^2+C^2)"→Str 1
Exp(Str 1)→R
"Abs (C+Abs (B+A×ⅈ)×ⅈ)"→Str 2
Exp(Str 2)→S
Goto R

Lbl 6
"A"?→A
"B"?→B
"√(A^2+2B^2)"→Str 1
Exp(Str 1)→R
"Abs (A+Bⅈ):Abs (Ans+Bⅈ)"→Str 2
Exp(Str 2)→S
Goto R

Lbl R
ClrText
Black Locate(1,1,Str 1)
Black Locate(1,2,R)
Blue Locate(1,4,Str 2)
Blue Locate(1,5,S)

//  If you are using a monochrome screen such as the Casio fx-9750gII or fx-9860gII, leave out the Black and Blue commands.


You can download the program file here (fx-CG 50, 696 bytes):
https://drive.google.com/open?id=1b4PzPWEdQ0bV_l3l7vIcThVGxjOR94pb 

Source:
William Kob, John Kennedy, Richard Nelson.  Better Programming On The HP-67/97 PPC 1978

Eddie

All original content copyright, © 2011-2020.  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, April 25, 2020

HP 42S/DM42/Free 42: Advanced Boolean Functions

HP 42S/DM42/Free 42: Advanced Boolean Functions

Introduction

The programs NOTBIT, NAND, NOR, and IMPL are four advanced Boolean functions that work on Binary Numbers.  You designate a bit size, up to 35, on each of these functions.   There is no signed bit in these programs.  Results are stored in the Alpha Register while the decimal equivalent is stored in the X register. 

HP 42S/DM42/Free 42 Program:  NOTBIT

00 { 57-Byte Prgm }
01▸LBL "NOTBIT"
02 "BIT SIZE?"
03 PROMPT
04 STO 00
05 BINM
06 "BIN?"
07 PROMPT
08 STO 01
09 DECM
10 2
11 RCL 00
12 Y↑X
13 X<>Y
14 BASE-
15 1
16 BASE-
17 BINM
18 "NOT: "
19 ARCL ST X
20 AVIEW
21 EXITALL
22 .END.

Example:

NOT 11011, bit size:  8

Result: 
NOT:  11100100

HP 42S/DM42/Free 42 Program:  NAND

a NAND b = NOT ( a AND b )

00 { 67-Byte Prgm }
01▸LBL "NAND"
02 "BIT SIZE?"
03 PROMPT
04 STO 00
05 BINM
06 "BIN1?"
07 PROMPT
08 STO 01
09 "BIN2?"
10 PROMPT
11 STO 02
12 AND
13 DECM
14 2
15 RCL 00
16 Y↑X
17 X<>Y
18 BASE-
19 1
20 BASE-
21 BINM
22 "NAND: "
23 ARCL ST X
24 AVIEW
25 EXITALL
26 .END.

Example:

110011 NAND 111100, bit size: 8

Result:
NAND:  11001111

HP 42S/DM42/Free 42 Program:  NOR

a NOR b = NOT ( a OR b )

00 { 64-Byte Prgm }
01▸LBL "NOR"
02 "BIT SIZE"
03 PROMPT
04 STO 00
05 BINM
06 "BIN1?"
07 PROMPT
08 STO 01
09 "BIN2?"
10 PROMPT
11 STO 02
12 OR
13 DECM
14 2
15 RCL 00
16 Y↑X
17 X<>Y
18 BASE-
19 1
20 BASE-
21 BINM
22 "NOR: "
23 ARCL ST X
24 AVIEW
25 EXITALL
26 .END.

Example:

110011 NOR 111100, bit size: 8

Result:
NOR:  11000000

HP 42S/DM42/Free 42 Program:  IMPL

IMPL (Implication):  a → b = (NOT a) OR b

00 { 66-Byte Prgm }
01▸LBL "IMPL"
02 "BIT SIZE?"
03 PROMPT
04 STO 00
05 BINM
06 "BIN1?"
07 PROMPT
08 STO 01
09 DECM
10 2
11 RCL 00
12 Y↑X
13 X<>Y
14 BASE-
15 1
16 BASE-
17 BINM
18 "BIN2?"
19 PROMPT
20 STO 02
21 OR
22 "A→B: "
23 ARCL ST X
24 AVIEW
25 EXITALL
26 .END.

Example:

110011 IMPL 111100, bit size: 8

Result:
IMPL:  11111100

You can download the raw files here: 
https://drive.google.com/open?id=19u8tPcX4_-o0lwvjUc0KO4-WSmhnxpwe

Source:

John W. Harris and Horst Stocker  Handbook of Mathematics and Computation Science  Springer:  New York, NY.  2006.  ISBN 978-0-387-94746-4

Eddie

All original content copyright, © 2011-2020.  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, April 24, 2020

Construction Master 5: Right Triangles

Construction Master 5:   Right Triangles

Introduction



The Calculated Industries Construction Master 5 does not have trigonometric keys, but it has four keys to dedicated to solving problems with right triangles, which appear a lot in construction.  Those four keys are:

[ Pitch ]:  there are several ways to enter the pitch:

If the amount is in inches, then the measurement is put as a pitch (x inches per 12 inches).  Example:  3 [ Inch ] [ Pitch]  inputs the angle as a 3 inch pitch (approximately 14.04°)

If the amount is in percent, the angle is entered as a percent grade.   Example: To enter 2% grade, press 2 [ % ] [ Pitch ] (approximately 1.15°)

If the amount is not attached to a unit, the amount is entered as degrees.  Example: To enter 30°, press 30 [ Pitch ].

[ Rise ]:  rise - opposite side.  Amounts can be entered with or without units.   

[ Run ]:  run - adjacent side.  Amounts can be entered with or without units.

[ Diag ]:  diagonal - hypotenuse.  Amounts can be entered with or without units.  Solving for the diagonal is known as a squaring-up calculation. 

To solve for a variable, just press the key without entering an amount. 

After all the variables have been calculated, you can calculate perimeter and area by:

Perimeter:  [ Rcl ] [ Rise ] [ + ] [ Rcl ] [ Run ] [ + ] [ Rcl ] [ Diag ]

Area:  [ Rcl ] [ Rise ] [ × ] [ Rcl ] [ Run ] [ ÷ ] 2

Examples 

Example 1:

Given:  Diagonal:  17.4 feet, Pitch:  20°

Results:
Rise:  5.95115 feet;  Run:  16.35065
Perimeter:  39.7018 feet;  Area:  48.65259 square feet

Example 2:

Given: Rise:  50 feet, Run:  40 feet

Results:
Diagonal:  64 feet 3/8 inch;  Pitch:  51.34°
Perimeter:  154 feet 3/8 inch feet;  Area:  1000 square feet

Example 3:

Given:  Grade: 3%, Feet: 17.5 Feet

Note, to enter the grade:  3 [ % ] [ Pitch ]

Results:
Run:  583.3333 ft, Diag:  583.5958 ft
Angle:  1.72°
Perimeter:  1184.429; Area: 5104.167 square feet

Eddie

All original content copyright, © 2011-2020.  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, April 18, 2020

Word Search Maker and Retro Review: Texas Instruments TI-18 SLR

Word Search Maker and Retro Review:  Texas Instruments TI-18 SLR

Word Search Maker

I was recently contacted by Phoebe and her website:  Word Search Maker.  Word Search Maker allows you to create word searches in one of four shapes:  diamond, circle, square, or spiral.  Word search maker automatically places the words in the search and also gives an answer.

Here is one I created, theme is math and calculators:  https://wordsearchwizard.com/puzzles/?id=1472

Here is a Milky Way themed word puzzle:
https://wordsearchwizard.com/puzzles/?id=1473

Create your own word searches here:  https://wordsearchwizard.com/maker/

General site:  https://wordsearchwizard.com

Setting up accounts are free.  Special thank you to Phoebe for sharing this wonderful website!


Retro Review:  Texas Instruments TI-18 SLR




Quick Facts:

Model:  TI-18 SLR
Company:  Texas Instruments
Type:  Scientific
Years:  1985-at least 1987
Display:  8 digits
Batteries:  Solar (calculator will work properly only in full light)
Original Retail Price:  Roughly $15 - $20
Logic:  Chain

Hybrid Between Four-Function and Scientific

The TI-18 SLR is a hybrid of a four-function calculator and a scientific calculator.

Four-Function Calculator:

*  Arithmetic (+, -, *, ÷)
*  Percent functions return the answer as soon as the percent key is pressed.
*  Operations are calculated in chain mode.  Order of operations are not followed.
*  Memory is one register:  1.   Keys regarding memory:

* M+:  calculate and add the result to memory
* M-:   calculate and subtract the result from memory
* MR:  memory recall
* MC:  memory clear

*  Square root function.  (takes the square root of the displayed number)

Scientific Calculator:

*  Square function (squares the displayed number)
*  Pi button
*  Reciprocal function (takes the reciprocal of the displayed number)
*  Parenthesis, see the next section

Parenthesis

The parenthesis key [ ( ) ] opens and closes one set of parenthesis.  There are no nested parenthesis, nor there is any indicator on the display when parenthesis are in effect.  Still, this key can aid in calculations.

Example:

Example 1:

(5^2 + 12^2) / ( 4 + 5 )

Key stroke:
 [ ( ) ] 5 [ x^2] [ + ] 12 [ x^2 ] [ ( ) ]
[ ÷ ] [ ( ) ] 4 [ + ] 5 [ ( ) ]
[ = ]

Result:  18.777777

Example 2:

π * ( 18^2 - 7^2 ) + ( π * 11^2 )

Key strokes:
[ π ] [ × ] [ ( ) ] 18 [ x^2 ] [ - ] 7 [ x^2 ] [ ( ) ]
[ + ] [ ( ) ] [ π ] [ × ] 11 [ x^2 ] [ ( ) ] [ = ]

Result: 1244.0706

Note results are truncated at the last digit, not rounded.

Display

The display is one line and it's small.  Still the display is serviceable.  The left slot has three vertical indicators:  M (memory indicator) on top, - (for negative numbers) in the middle, and E (error indicator) on the bottom.

Keyboard

The keys are responsive, but I wouldn't try to speed type on the TI-18SLR.

Routine Goodies

Absolute Value:  | n |
n  [ x^2 ] [ √x ]

Sign:  sgn(n) = -1 for negative, 1 for positive (does not work for n = 0)
[MC] n [ M+ ] [ x^2 ] [ √x ] [ ÷ ] [ MR ] [ = ]

Modulus:  n mod m  with n > m, n > 0, m > 0.
[ MC ] n [ M+ ] [ 1/x ] [ × ] m [ - ] (integer part of the result) [ × ] [ MR ] [ = ]

Example:
99 mod 16 = 3
[ MC ] 16 [ M+ ] [ 1/x ] [ × ] 99   (Display: 6.1875   integer(6.1875) = 6)
[ - ] 6  [ × ] [ MR ] [ = ]

Result:  3

Verdict

A collector's item.  I wish more basic calculators included x^2, π, and 1/x, which are very useful in many calculations.


Note: This post was scheduled for Sunday, 4/19/2020, but I decided to move it up to post this 12 hours early. 

Eddie

All original content copyright, © 2011-2020.  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 12C: Sums of x

HP 12C:  Sums of x

Introduction

The following are four programs to calculate:

*  ∑ x
*  ∑ x^2
*  ∑ x^3
*  ∑ ax + b

with limits x = 0 to n.

Each program uses a closed sum formula.  The second and fourth program uses Horner's Method. 

Note:  You can use the first three if your limits are x = 1 to n (because at x = 0, 0 is added to the sum).  However if you use the fourth program, to get the sum from 1 to n, subtract b. 

HP 12C Program:  ∑x (x=0 to n)

n
∑ x =  n * (n + 1) / 2
x=0

Enter n, execute program

STEP:  KEY CODE  KEY
01:  36  ENTER
02:  36  ENTER
03:  1  1
04:  40  +
05:  20  *
06:  2   2
07  10  ÷
08:  43,33,00  GTO 00

Keys Only:
ENTER
ENTER
1
+
2
*
÷
GTO 00

Example:  (n = 48)

48
∑ x  = 1176
x=0

HP 12C Program:  ∑x^2 (x=0 to n)

n
∑ x^2 =  n * ( ( n / 3 + 1 / 2 ) * n + 1 / 6 )
x=0

Enter n, execute program

STEP:  KEY CODE KEY
01:  36  ENTER
02:  36  ENTER
03:  36  ENTER
04:  3  3
05:  10  ÷
06:  2  2
07:  22  1/x
08:  40  +
09:  20  *
10:  6  6
11:  22  1/x
12:  40  +
13:  20  *
14:  43,33,00  GTO 00

Keys Only:
ENTER
ENTER
ENTER
3
÷
2
1/x
+
*
6
1/x
+
*
GTO 00

Example:  (n = 48)

48
∑ x^2  = 38,024
x=0

HP 12C Program:  ∑x^3 (x=0 to n)

n
∑ x^3 =  1 / 4 * (n^2 + n)^2
x=0

Enter n, execute the program

STEP:  KEY CODE  KEY
01:  36  ENTER
02:  36  ENTER
03:  2  2
04:  21  y^x
05:  40  +
06:  2:  2
07:  21  y^x
08:  4  4
09:  10  ÷
10:  43,33,00  GTO 00

Keys Only:
ENTER
ENTER
2
y^x
+
2
y^x
4
÷
GTO 00

Example:  (n = 32)

32
∑ x^3  = 278,784
x=0

HP 12C Program:  ∑(a*x + b)  (x=0 to n)

n
∑ (a*x + b) =  n * (a * n / 2 + (a / 2 + b) ) + b
x=0

Store a in R1, store b in R2, enter n on the x-stack, execute the program

STEP:  KEY CODE   KEY
01:  36   ENTER
02:  36   ENTER
03:  36   ENTER
04:  45, 1  RCL 1
05:  20   *
06:  2    2
07:  10   ÷
08:  45, 1  RCL 1
09:  2   2
10:  10   ÷
11:  45, 2   RCL 2
12:  40   +
13:  40   +
14:  20   *
15:  45, 2  RCL 2
16:  40  ÷
17:  43, 33, 00   GTO 00

Keys Only:
ENTER
ENTER
ENTER
RCL 1
*

÷
RCL 1
2
÷
RCL 2
+
+
*
RCL 2
÷
GTO 00

Example:  (a = R1 = 3,  b = R2 = 4, n = 32)

3 STO 1,  4 STO 2,  32, R/S

32
∑ (3x + 4) = 1,716
x=0


I tried something new with my RPN keystroke programs, the second versions of each I just listed what keys to press without the step number or code.  I think this would be easier to read, but does leave out the key and key code.  Any comments on which style is preferred is appreciated. 


Eddie

All original content copyright, © 2011-2020.  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, April 17, 2020

Fun with Radio Shack EC-4019 and Casio fx-3800P

Fun with Radio Shack EC-4019 and Casio fx-3800P

First blog entry of the 10th year of this blog (4/11/2020 - 4/11/2021).  I can't expression enough gratitude for your support and comments - Eddie

Sums

n
∑ x  = (n^2 + n) / 2
x = 1

Program (9 steps):

ENT
Kin 1
x^2 
+
Kout 1
=
÷ 



Execution:  [ # ] n [ RUN ]

where [ # ] represents program keys [ I ], [ II ], [ III ], and [ IV ] in RUN mode ( [ MODE ] [ . ] )

Example:  n = 48, Result:  1176

n
∑ x^2 = n * ((n/3 + 1/2) * n + 1/6 )
x=1

Program (16 steps):

ENT
Kin 1
*
(
Kout 1
x^2
÷ 
3
+
Kout 1
÷

+
6
1/x
=

Execution:  [ # ] n [ RUN ]

Example:  n = 48, Result:  38024

Horner's Rule:  Cubic Polynomials

Calculate p(x) by Horner's Rule where:

p(x) = a*x^3 + b*x^2 + c*x + d = x * ( x * ( a*x + b ) + c ) + d

Program (16 steps):

Kout 5
+
Kout 1
*
(
Kout 4

Kout 1

(
Kout 2
*
Kout 1

Kout 3
=

Execution:  x [ Kin ] 1, a [ Kin ] 2, b [ Kin ] 3, c [ Kin ] 4, d [ Kin ] 5.   Press [ # ]

Example:  x = K1 = 50, a = K2 = 1, b = K3 = 4, c = K4 = 5, d = K5 = -200
Result:  135,050

Head Winds And Cross Winds

Head Winds:
HW = K * cos(D - HDG - V)

Cross Winds:
RCW = K * sin(D - HDG - V)

where:
K = wind velocity (mi/hr)  (K1)
D = wind direction with 0° due North, clockwise (degrees)  (K2)
HDG = airplane direction with 0° due North, clockwise (degrees)  (K3)
V = compass adjustment   (K4)

Mode 4: Degrees

Program (13 steps):

Mode
4        //  Degree mode
Kout 1
P → R 
(
Kout 2 
-
Kout 3
-
Kout 4

HLT   // HW
X ←→ Y  // RCW

Execution:
K [ Kin ] 1,  D [ Kin ] 2,  HDG [ Kin ] 3,  V [ Kin ] 4.  Press [ # ].

Example:
K = 25 mi/hr = K1
D = 240° = K2
HDG = 280°  = K3
V = 0  = K4

Results:
HW:  19.15111108 mi/hr
RCW:  -16.09699024 mi/hr

Source:  HP 65 Aviation Pac-1 Hewlett Packard.  1974

Rate of Climb

Rate of Climb (ft/min):
ROC = TAS * ALT ÷ √( DIST^2 + ALT^2 )

where:
TAS = true airplane speed (ft/min)   (K1)
ALT = vertical distance (ft)   (K2)
DIST = horizontal distance (ft)   (K3)

Conversion factors:
1 knot = 101.269 ft/min
1 nautical mile = 6072.12 ft

Program (13 steps):

Kout 1
*
Kout 2
÷
(
Kout 2
x^2

Kout 3
x^2
)

=

Execution:
TAS [ Kin ] 1,  ALT [ Kin ] 2,  DIST [ Kin ] 3.  Press [ # ].

Example:
TAS = 4,300 ft/min = K1
ALT = 3,000 ft = K2
DIST = 81,425 ft = K3

Result:  ROC: 158.3205808 ft/min

Source:  HP 65 Aviation Pac-1 Hewlett Packard.  1974

Modulus

For positive integers N, M:
N mod M = ( N / M - int(N / M) ) * M

Results lie in the interval [ -int( M / 2 ), int( M / 2 ) ]

Program (16 steps):

MODE
7
0     // Fix 0 mode 
Kout 2
1/x
*
Kout 1

Kin 3

Kout 3
RND   // round displayed number to settings
=
*
Kout 2
=

Execution:
N [ Kin ] 1,  M  [ Kin ] 2.  Press [ # ].

Examples:

48 mod 17 = -3  (equivalent to 48 mod 17 = 14)

721 mod 21 = 7


Eddie

All original content copyright, © 2011-2020.  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, April 12, 2020

TI-80 and TI-84 Plus CE: Drawing a Bag of Two Kinds of Items

TI-80 and TI-84 Plus CE:  Drawing a Bag of Two Kinds of Items

Introduction




The program BINDRAW has a participant draw from a population made of two type of objects, A and B.  Think of a bag with green marbles (A) and red marbles (B).  You are given the number of draws and you need to calculate the chance you draw a certain combination, such as 3-draws of order A, A, B or A, B, A.

POP A:  number of A balls in the bag

POP B:  number of B balls in the bag

The ^-1 is the inverse function [ x^-1 ]

TI-80 Program  BINDRAW (161 bytes)

The TI-80 Program of BINDRAW is a simple version, which calculates a single probability.

INPUT "POP A?",A
INPUT "POP B?",B
A + B → T
DISP "TOTAL:",T
INPUT "NO OF DRAWS?",D
(T nPr D)^-1 → P
FOR(I,1,D)
CLRHOME
DISP "DRAW ",I,"1. A 2. B"
INPUT J
IF J = 1
THEN
P * A → P
A - 1 → A
ELSE
P * B → B
B - 1 → B
END
END
DISP "PROB:",P

TI-84 Plus CE Program BINDRAW (374 bytes)

The TI-84 Plus CE version of BINDRAW expands on the simple version.  After calculating a single probability: you get a menu of the following options.

ADD TO MEM:  Add the probability to memory.  The memory register is the cumulative probability.  The cumulative probability is displayed.

CLEAR MEM:  Reset the cumulative probability to zero.

NEW DRAW:  Start a new draw.  The cumulative probability remains intact.

NEW PROB:   Starts a new problem.  The cumulative probability resets to zero.

QUIT:  End the program.

"2020-02-29 EWS"
Lbl 0
Input "POP A?",N
Input "POP B?",M
N + M → T
Disp "TOTAL",T
0 → S
Input "NO OF DRAWS?",D
Lbl 1
N → A 
M → B
(T nPr D)^-1 → P 
" " → Str0
For(I, 1, D)
Disp "DRAW " + toString(I), "HIST " + Str0, "1. A 2. B"
Input J
If J = 1
Then
P * A → P
A - 1 → A
Str0 + "A" → Str0
Else
P * B → P
B - 1 → B
Str0 + "B" → Str0
End
End
Disp "PROB"
Pause P
Lbl 2
Menu("MENU", "ADD TO MEM", 3, "CLEAR MEM", 4, "NEW DRAW", 1, 
"NEW PROB", 0, "QUIT", 5)
Lbl 3
P + S → S
Disp "MEM"
Pause S
Goto 2
Lbl 4
0 → S
Disp "MEM CLEARED"
Pause
Goto 2
Lbl 5

You can download the TI-84 Plus CE program here:
https://drive.google.com/open?id=1HBpv5rNN6kA-__MTKoc3RJtMAgqyF1w4

Example

The bag has 5 balls labeled "A" and 3 balls labeled "B".  What is the probability of either drawing 3 "A" balls in a row or drawing 3 "B" balls out of the bag?

Prompts:
POP A?  5
POP B?  3
(Total = 8)
DRAWS? 3

Three "A": choose option 1 three times in a row
Probability:  0.1785714286

Three "B": choose option 2 three times in a row
Probability:  0.0178571429

Cumulative Probability:  0.1964285715

Blog turns 9 on the 16th 

This is the last blog entry of the 9th year of my calculator and math blog as this blog turns 9 on April 16, 2020.  Thank you to everyone and all your support!  See year when we start Year 10 (!) on the 17th. 


Eddie

All original content copyright, © 2011-2020.  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, April 11, 2020

Casio fx-CG 50 Update and Mental Math: Squaring a Number Ending in 5

Casio fx-CG 50 Update and Mental Math:   Squaring a Number Ending in 5

Casio fx-CG 50 Update

Casio released an update to the operating software for the fx-CG 50, version 3.40.   This update, among other things, expands the number of commands in Casio's Micropython.

There is a new module casioplot module has commands to draw pixels in any color and strings. 

The link to get the updated software is here:  https://edu.casio.com/download/index.php

Click on Graphing Models.

I have not had a chance to try the new drawing commands yet, it's on my list of things to do. 

Mental Math:   Squaring a Number Ending in 5

Squaring a positive integer whose last digit is 5 will result in the answer whose last digits are 25.

Why is this true?

Let n be a positive integer whose last digit is 5.   (n = 15, 25, 35, etc.). 

Let m = n - 5, then n = m + 5.   Note that m is a multiple of 10.

Then:

n^2 = (m + 5)^2
= m^2 + 2 * m * 5 + 25
= m^2 + 10 * m + 25
= (m^2 + 10 * m) + 25
= m * (m + 10) + 25

Since m is a multiple of 10, m^2 and 10 *  m are multiples of 100.  Because of this fact, squaring integers ending in 5 is used in mental math.

Examples

Example 1:  Calculate 45^2.

n = 45 = 40 + 5    (m = 40)
= (40 + 5)^2
= 40 * (40 + 10) + 5^2
= 40 * 50 + 25
= 2000 + 25
= 2025

45^2 = 2025

Example 2:  Calculate 165^2

n = 165 = 160 + 5    (m = 160)
= (160 + 5)^2
= 160 * (160 + 10) + 25
= 160 * 170 + 25
=  27200 + 25
=  27225

Eddie

All original content copyright, © 2011-2020.  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, April 10, 2020

HP Prime: Drawing Cards and Video Poker

HP Prime:  Drawing Cards and Video Poker

The Function drawcardfx

The function drawcardfx draws a set number of cards from a deck of 52 standard playing cards.

To achieve this effect, I made four lists:

List 1:  A list of all integers 0 to 51.

List 2:  The suits.  I took each of the elements of List 1 MOD 4, giving the answers of 0, 1, 2, 3, respectively.  Each of the modulo are assigned to a suit:

0:  Clubs.  This is character 9827 for the HP Prime.  ♣
1:  Diamonds.  This is character 9826.  (9827 - 1)  ♢
2:  Hearts.  This is character 9825.  (9827 - 2)  ♡
3:  Spades.  This is character 9824.  (9827 - 3) ♠

List 3:  The ranks.  I divided each element of List 1 by 4, take the integer part, then add 1.  For example:  for card number 17:  IP(17/4) + 1 = IP(4.25) + 1 = 4 + 1 = 5.   This is why I let List 1 range for 0 to 51 instead of 1 to 52, since IP(52/4) + 1 = 14 while IP(0/4) + 1 = 1, and I want four 1s, four 2s, four 3s, up to four 13s.  There are 13 ranks in a standard deck of cards.

List 4:  This list starts empty and will hold all the cards drawn in the hand.  Empty lists are allowed in the HP Prime.

I then turned List 2 and List 3 into appropriate strings.  For List 3, I turned each 1 into an Ace (A), 11 into a Jack (J), 12 into a Queen (Q), and 13 into a King (K).

The While loop allows me to pull to generate a sample with no repeats.  If there is an easier way for me to do this on the HP Prime, please let us in the comments.

The function returns a list of strings in the format "(rank) (suit)".

Example:  drawcardfx(5) might return
{"K ♠", "9 ♡", "A ♠", "4 ♢", "K ♣"}
(not bad, pair of Kings)

HP Prime Program: drawcardfx

EXPORT drawcardfx(n)
BEGIN
// 2020-04-01 EWS
// Draws n cards
// single draw
// no print out

LOCAL x,k,t,s;
LOCAL L1,L2,L3,L4;

RANDSEED();

// list of cards
L1:=MAKELIST(x,x,0,51);

L2:=9827-(L1 MOD 4);
L3:=IP(L1/4)+1;

FOR k FROM 1 TO 52 DO
L2(k):=CHAR(L2(k));
L3(k):=STRING(L3(k));
IF L3(k)=="1" THEN L3(k):="A"; END;
IF L3(k)=="11" THEN L3(k):="J"; END;
IF L3(k)=="12" THEN L3(k):="Q"; END;
IF L3(k)=="13" THEN L3(k):="K"; END;
END;

L4:={};

k:=1;

WHILE k≤n DO
t:=RANDINT(1,52);
// if statement
IF L1(t)≠0 THEN
s:=L3(t)+" "+L2(t);
L1(t):=0;
L4:=CONCAT(L4,{s});
k:=k+1;
END;
END;

// end the program
RETURN L4;
END;

A Simple Video Poker Program

The program VIDEOPOKER is simple video poker program.  You are dealt a hand of 5 cards from a standard 52 card deck.  You are then asked to hold every card that you want to keep.  Once you decide which cards to keep, that card is held.  Executing the DRAW option redraws the cards and you are shown your final hand.

This is a very simple program because there is no better or ranking of hands.  This just has the play of the cards.

The game is achieved by having the game draw 10 cards in advance, separating them into groups of 5.

This program will require the function drawcardfx above.

Example Game:
Run VIDEOPOKER - no arguments needed.

Your first hand:
6 ♢
5 ♢
10 ♠
Q ♠
6 ♡

A choose box appears after I press [ Enter ].  Let's say I want to hold the pair of sixes.  So I highlight each of the sixes and press [ Enter ].  After doing this the choose box now reads:

HOLD?
HELD
5 ♢
10 ♠
Q ♠
HELD
DRAW

I now choose draw and I get:
------------------
Final hand:
6 ♢
A ♠
4 ♢
6 ♣
6 ♡

I improved my hand to a set of sixes (three sixes).

HP Prime Program VIDEOPOKER

EXPORT VIDEOPOKER()
BEGIN
// just for fun
// 2020-04-01 EWS
// drawcardfx required
LOCAL c,k,s,t;
LOCAL cardz,L01,L02,Lhand,Lrep,L03;

cardz:=drawcardfx(10);
L01:=SUB(cardz,1,5);
L02:=SUB(cardz,6,10);
Lhand:=L01;
Lrep:={1,2,3,4,5,6};

PRINT();
PRINT("Your first hand:");

FOR k FROM 1 TO 5 DO
PRINT(Lhand(k));
END;
WAIT(0);

L03:=CONCAT(Lhand,{"DRAW"});

WHILE c≠6 DO
CHOOSE(c,"HOLD?",L03);
Lrep(c):=0;
L03(c):="HELD";
END;

FOR k FROM 1 TO 5 DO
IF Lrep(k)≠0 THEN
Lhand(k):=L02(k);
END;
END;


PRINT("-----------");
PRINT("Final hand:");
FOR k FROM 1 TO 5 DO
PRINT(Lhand(k));
END;

END;

Have fun!  If you do modify the program above to involve gambling, please virtual gamble responsibly.

Eddie

All original content copyright, © 2011-2020.  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, April 5, 2020

The Sum of a Constant

The Sum of a Constant

Introduction

What is the sum of the series:

∑ a from x= 0 to n   (a is a real or complex constant, n is a positive integer)

I may not be what you think.   Take a close look at the limits:  lower limit of 0, upper limit of n.   Assume the increment of x is 1. 

The sum of the series is (n + 1) * a.

Proof

Base case.   Let n = 1.  Then:

∑ a from x = 0 to 1

=  a + a   

= 2 * a

= (1 + 1) * a

The value a is added for the x=0 term.   The value a is added for the x=1 term.

Induction.   Assume for a positive integer k,  the series holds.  Then for the sum from x = 0 to x = k + 1:

∑ a from x = 0 to k+1

= ( ∑ a from x = 0 to k ) + ( ∑ a from x = k+1 to k+1 )

= (k + 1) * a + a

= k * a + a + a

= k * a + 2 * a

= (k + 2) * a    QED

Examples


Example 1:

∑ a from x = 0 to 2

= a + a + a

= 3 * a


Example 2:

∑ 6 from x = 0 to 11

= (11 + 1) * 6

= 12 * 6

= 72


Eddie

All original content copyright, © 2011-2020.  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, April 4, 2020

Retro Review: Canon Palm Printer P1-DH V

Retro Review:  Canon Palm Printer P1-DH V



Quick Facts:

Model:  Palm Printer P1-DH DV
Company:  Canon
Type:  Printing
Years:   I think this model is around 2016, not sure, I got this from a search on Amazon.  The current version is P1-DH V3
Display:  12 digits
Batteries:  4 AAA Battery and/or AC Adapter AD-380
Original Retail Price:  about $30.00 to $35.00
Logic:  Chain

This review is on an older model P1-DH DV.  I think the current version at the time of this post is the P1-DH DV3. 

I will focus my review on the keyboard and features only, not on the printing features. 

The calculator will operate on AC power alone, without batteries, which I like. 

Unlike most printing calculators, the P1-DH V operates as a four-function Chain calculator instead of an adding machine.  For example:  to add 2, 7, and 11, type:

2 [ + ] 7 [ + ] 11 [ = ]

Result: 20

Features

This is a standard printing calculator that has the following features:

*  Decimal Point Selectors:  F (float, no indicator), 0, 2, 3, 4, A (add mode).  The mode is changed by the key [DEC].   Float is the default mode. 

*  Rounding/Truncate Toggle:  toggle between rounding and truncate with the [5/4] key.  When the 5/4 is on, the calculator is on rounding mode.  Note that this setting has no affect on results on when the decimal point selector is set to Float.

Example:

Float Mode:
1 [ ÷ ] 6 [ = ] returns 0.16 666 666 666

2 Decimal Place Mode:  (2 indicator)
5/4 on (Rounding mode):  1 [ ÷ ] 6 [ = ] returns 0.17
5/4 off (Truncate mode):  1 [ ÷ ] 6 [ = ] returns 0.16

*  One memory register is available, with sum and difference.   When [ M+ = ] is pressed, the calculation is completed and is added to the memory register.   When [ M- = ] is pressed, the calculation is completed and is subtracted from the memory register.

Example:

1000 * 298 + 928 * 172 - 442 * 180

[ RM/CM ] until memory is cleared
1000 [ × ] 298 [ M+ = ]
928 [ × ] 172 [ M+ = ]
442 [ × ] 180 [ M- = ]
[ RM/CM ]
Result:  378,056

*  Time Calculations:  You can enter hours-minutes for calculations in either AM/PM or 2400 hour format by using the [TIME CAL] key.  You know the calculator is ready to accept hours-minutes when the screen shows 00:00.  In AM/PM mode, switch between AM/PM by use the [TIME CAL AM/PM] button.  To calculate the difference between times, the required key is the key with the tilde mark on it.  ( [ ~ ] )

Example:  What time has passed between 23:17 and 11:16?  (2400 hours)

[TIME CAL] [TIME CAL] (00:00 without an AM/PM indicator means 2400 hours):
2 3 1 7 [ ~ ]
1 1 1 6 [ = ]

11:59 (11 hours, 59 minutes)

* Cost/Sell/Margin and Sales Tax Calculation.  See the next section.

The [ B ← → T ] Key

The [ B ←→ T ] rules what functions the blue keys execute on the P1-DH V. 

Indicator T:  Tax Mode (Default mode)

[ TAX+ ]:  Add tax using the rate stored
[ TAX- ]:  Subtract tax using the rate stored
[ RATE ]:  Press this key to enter the tax rate (RATE will be blinking), press [ RATE ] again to finish

Indicator B:  Business Mode

[ COST ]:  Cost
[ SELL ]:  Sell
[ MARGIN ]:  Margin

Enter any of the two values, the third is automatically calculated.

Example: 
Sell = $29.95,  Margin = 8%

[ B ←→ T ] until B appears
29.95 [ SELL ] (SELL flashes)
8 [ MARGIN ]

Result:  27.55 (COST indicator)

Keyboard

The keyboard is nice and light.  The keys are rubber and very responsive.  The key response and register is great.  My hands are a little too big but it is possible to speed calculate on the Palm Printer. 

I like the screen but I wish the indicators were bigger, as they are too tiny for my preference.  Just make sure you triple check which mode you are in.  This model I purchased in December 2019 at a Revivals Store in Palm Springs. 

Eddie

All original content copyright, © 2011-2020.  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, April 3, 2020

HP Prime: Solving Integral Equations

HP Prime:  Solving Integral Equations

Introduction

The program INTEGRALSOLVE solves the following integral equation for x:

x
∫ f(X) dX  - a = 0
0

using Newton's method.

Big X represents the variable of f(X) to be integrated while small x is the x that needs to be solved for.

Taking the derivative of the above integral using the Second Fundamental Theorem of Calculus:

d/dx [ ∫( f(X) dX from X=0 to X=x ) - a ]
= d/dx [  F(x) - F(0) - a ]
= d/dx [ F(x) ] - d/dx [ F(0) ] - d/dx [ a ]
= d/dx [ F(x) ]
= f(x)

F(X) is the anti-derivative of f(X).  F(0) and a are numerical constants, hence the derivative of each evaluates to 0.

Newton's Method to solve for any function g(x) is:

x_n+1 = x_n - g(x_n) / g'(x_n)

Applying this to the equation, Newton's Method gives:

x_n+1 = x_n - [ ∫( f(X) dX from X=0 to X=x_n ) - a ] / f(x_n)

HP Prime Program INTEGRALSOLVE

Note:  Enter f(X) as a string and use capital X.  This program is designed to be use in Home mode.

EXPORT INTEGRALSOLVE(f,a,x)
BEGIN
// f(X) as a string, area, guess
// ∫(f(X) dX,0,x) = a
// EWS 2019-07-26
// uses Function app
LOCAL x1,x2,s,i,w;
F0:=f;
s:=0;
x1:=x;
WHILE s==0 DO
i:=AREA(F0,0,x1)-a;
w:=F0(x1);
x2:=x1-i/w;
IF ABS(x1-x2)<1 font="" then="">
s:=1;
ELSE
x1:=x2;
END;
END;

RETURN approx(x2);
END;

Examples



Radians angle mode is set.

Example 1:

Solve for x:

x
∫ sin(X) dX = 0.75
0

Initial guess:  1

Result:  x ≈ 1.31811607165

Example 2:

Solve for x:

x
∫ e^(X^2) dX = 0.95
0

Initial guess:  2

Result:  x ≈ 0.768032819934

Pretty powerful.

April 2020:  New Posts Every Friday, Saturday, and Sunday! 

Eddie

All original content copyright, © 2011-2020.  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/DM42: Height of a Fire, Time to Clear a Corridor

 HP 42S/DM42:  Height of a Fire, Time to Clear a Corridor HP 42S/DM42/Free42 Program:  FIREHGT The program FHGT approximates the height of a...