Showing posts with label integer division. Show all posts
Showing posts with label integer division. Show all posts

Friday, March 14, 2025

Casio fx-6500P Program Library 2025

Casio fx-6500P Program Library 2025


Last birthday, I reviewed the rare classic, the Casio fx-6500G:

https://edspi31415.blogspot.com/2024/03/spotlight-casio-fx-6500g.html



Casio fx-6500G




Parabola Area and Maximum Point: Program P1: Steps 114


Area Under a Parabola set up by the equation:


y = -((x – a)*(x – b)) = -x^2 + p*x – q

p = a + b

q = a * b


Cls

“-((X-A)×(X-B))”

“A”? →A

“B”? → B

A+B → P

AB → Q

-B^3 ÷ 3 + B² P ÷ 2 – Q B + A^3 ÷ 3 - A² P ÷ 2 + Q A → R

“AREA:”

R ◢

“MAX PT:”

P ÷ 2 →X ◢

-((X-A)×(X-B)) → Y



The caret symbol ^ stands for [x^y].


Example:

y = -((x + 4) * (x – 2)) = -x^2 – 2*x + 8

A = -4, B = 2

Area: 36

Maximum Point: (-1, 9)



Circular Sector: Arc Length and Sector Area: Program: P2: Steps: 59


“RADIUS”? →R

“ANG(°)”? → T

RTπ÷180 →L

RL÷2 →A

“ARC LENGTH:”

L ◢

“AREA:”

A


The degree character is generated by the [° ‘ “] key.


Example:


R = 10.5, T (angle) = 120°

Results: Arc length = 21.99114858, Area = 115.45353



Integer Division: Program: P3: Steps: 51


“INT÷”

“X>0”? →X

“M>0”? →M

Int(X÷M)→Q

X-M×Q→R

Q ◢

“REM”

R


Examples:


43 Int÷ 11 = 3 Rem 10


7263 Int÷ 1849 = 3 Rem 1716


Hint: To find out the number of steps in a single program? Simply scroll down the last character and hold down the [ MDisp ] key. Kind of neat because this works outside of programming mode. I think this key was available on most Casio graphing calculators well into the fx-7700G (single G) and fx-9700Gα (E,M,H) series in mid 1990’s.



95% Population Proportion: Program P4: Steps: 96


X successes out of population N


“95 PRCT PROP”

“X”? → X

“N”? → N

X ÷ N → P

√(P(1-P))→ M

1.959963984 M ÷ √N → H

P – H → L

L + 2H → H

“LOW:”

L ◢

“HIGH:”

H


Example:


X = 850, N = 1176

Interval:

LOW: 0.6972058859

HIGH: 0.7483723454


Interval:


Source: HP 21S Stat/Math Calculator: Owner’s Manual. Hewlett Packard. 3rd Edition. June 1990.



Power Generated by a Wind Turbine: Program P5: Steps: 82


“WIND PWR”

“RADIUS (M)”? →R

“SPEED (M÷S)”? → V

“DENSITY”? →P

π × R² × P × V^3 ÷ 2 → W

“POWER:”

W


Example:


R = 8.18 m, V = 4.48 m/s, P = 1.2 kg/m³

Result: 11340.74989 W


Source: Sharp Electronics Corporation Conquering The Sciences: Applications for the SHARP Scientific Calculator EL-506A Sharp Corporation. Osaka, Japan. 1986. pp.75-77



Round to Nearest Integer (display only): Program P6: Steps: 11


?→N

Fix 0

Rnd

Norm


Examples:

N = 19.273 → 19

N = 44.8273 → 45

N = -2.82 → -3


That’s it. I wish you all a wonderful day. Thank you,


Eddie


All original content copyright, © 2011-2025. 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, November 6, 2022

hp 9g: Sample Programs

hp 9g:  Sample Programs


Introduction


As I mentioned in yesterday's blog, today's blog will have some sample programs for the hp 9g.   


The hp 9g's programming language is a mix of C and Basic, and is unique from the rest of the Hewlett Packard calculators.    The hp 9g has 400 steps of programming memory to be allocated among 10 program files, P0 through P9.   


The 9g has 26 variables, but can be extended up to 53 variables at the cost of program steps.  The square brackets indicate indirect addressing.  The number in the square brackets is the number of steps away from the variable.   Any variable beyond Z (Z[0], A[25]) must be addressed in this fashion.  


Example: 

A[0] calls up A

A[1] calls up B

...

A[25] calls up Z. 


We can use any letter, but I recommend using either A or Z. 



hp 9g Program:  Integer Division


This program gives the quotient and remainder of N ÷ D.  The program here assumes you enter positive integers, and some code can be entered for checking inputs.  


INPUT N

INPUT D

Q=INT(N/D)

R=N-Q*D

PRINT Q," R",R

END


Examples:


N = 4379, D = 8;  Result:  547 R3


N = 5884, D = 29;  Result:  202 R26



Note:  The PRINT command converts variable values to strings automatically, without the need for a string or STR$ command.


hp 9g Program:  Arithmetic-Geometric Mean


This program determines the AGM given two numbers A and G.


INPUT A

INPUT B

PRINT "ACC. 10^-8"

Lbl 0:

X=.5(A+G)

Y=√(AG)

If (ABS(X-Y)<10^(-8))

Then {Goto 1}

A=X

G=Y

Goto 0

Lbl 1:

Print "ANS= ", X


Examples:


A = 1.3, G = 1.5,   Result:  ANS ≈ 1.39821143


A = 20, G = 45,  Result:  ANS ≈ 31.23749374



Notes:  


10^ is from [ 2nd ] (10^x) the antilog function.


The label command must have the colon character after the label number, or a syntax error occurs.  


If you run a program from the Main mode by the [ PROG ] key, you will be transferred to Program mode when the program finishes.


hp 9G Program: The Maximum Value of A through X



Y = maximum value

Z = counter variable


PRINT "MAX(A:X)"; ◢

FOR(Z=2;Z<23;Z++){

IF(A[Z]>Y)

THEN{Y=A[Z]}};

PRINT "MAX=",Y;

END


Example:  


Clear all variable in the MAIN mode by CL-VAR

Set up variables: 


A = 12, D = 24, E = 37, G = 40, S = 19, T = 16, U = 7

Result:  MAX= 40


Notes:   


++ is from the Instruction menu, it is a smaller-jointed double plus.


When the program encounters a run/stop instruction (◢), the last message is displayed.  Continue execution by pressing the equals key [ = ].  


hp 9g Program:  Plotting y = A * sin(B * x + C) + D


The programming mode does not offer a lot of support when it comes to graphs.  


PRINT "SINE"

SLEEP(.5)

INPUT A,B,C,D

RANGE(-2π,2π,π/4,-A,A,1)

Graph Y=A*sin(BX+C)+D

PRINT "PRESS G<>T"

END




A = 1, B = 1, C = 0, D = 0



Notes:


Prior to running the program, set the angle mode to Radians through the [DRG] key.  Also, press [ 2nd ] [ → ] (CLS) to clear the graph screen.  Unfortunately, neither of these commands can be programmed.  


Plots from programs cannot be traced.


When the program ends, you will need to switch to Main mode, press [G<>T] to show the graph.   Not a very efficient way of showing a graph.  



That is a sample of the programs for the hp 9g.  Good for number crunching, kind of a little bit to be desired for graphics.


Until next time,


Eddie 



All original content copyright, © 2011-2022.  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, November 22, 2021

Retro Review: Casio fx-55 Fraction Mate

 Retro Review: Casio fx-55 Fraction Mate









Quick Facts


Model: fx-55 Fraction Mate

Company: Casio

Years: probably the 1990s or early 2000s, predecessor to the fx-55 Plus* 

Memory Register:  1 independent memory

Battery:  Solar with battery back up (LR44)

Screen:  8 digits, 4 digit numerator, 4 digit denominator, function indicator (+, -, ×, ÷, ^), equals and parenthesis indicators 

Logic:  Algebraic

Comes with hard case and reference card  


In 2018, I reviewed the fx-55 Plus:  https://edspi31415.blogspot.com/2018/08/review-casio-fx-55-plus.html


Right now there are plenty of fx-55 (original keyboard) for sale on auction sites for eBay at really inexpensive prices, sometimes as low as about $2.00.


Target Audiences


*  Elementary and middle school students

*  Anyone who wants a few more functions than a regular four-function calculator, but not a scientific calculator

*  You want a calculator with an emphasis on fractions


Keyboard


The fx-55 Fraction Mate does not have a shift key.   Some of the keys are:


[ + ], [ - ], [ × ], [ ÷ ]:  Arithmetic keys

[ ( ], [ ) ]:  Parenthesis keys

[ x^y ]:  Power key with a caret indicator on the screen

[ 1/x ]:  Reciprocal

[ RAN# ]:  3 digit random number between 0 and 1

[ FIX ]:  Fix setting.  For float setting, press [ FIX ] [ . ]

[ RND ]:  Round number to fixed setting internally

[ 10^x ]:  Antilog function

[ X ←→ Y ]:  Switch operators

[ X ←→ M]:  Exchange number in the display with number in memory

[ % ]: Percent key, see below

[ > ]: Backspace key

[ a ], [ b/c ]:  Fraction entry keys

[ F ←→ D ]:  Fraction/decimal conversion

[ a b/c ←→ d/c ]:  Improper/proper fraction conversion

[ SIMP ]:  Fraction simplification key

[ ÷R ]:  Integer division, with quotient and remainder.  If both numbers are positive, then remainder acts as a modulo operator

[ √ ]: square root

[ x^2 ]: square function


Integer Division


Pressing [ ÷R ] will return both the quotient and remainder of a division calculation.  If both numbers are positive, then the remainder is the modulo.  


Example:  55 [ ÷R ] 12 returns 4 R 7.  Then 55 = 7 MOD 12.


Percent Key


To add % to n, press:

n [ × ] p [ % ] [ + ]


To subtract % from n, press:

n [ × ] p [ % ] [ - ]



Simplify Key


The [ SIMP ] key simplifies fractions when possible.   The factor used to simplify the fraction is briefly displayed.  All fractions on the fx-55 FRACTION MATE are simplified manually.


Example:   1450/2900 = 


1450 [ b/c ] 2900 [ = ]

Display:  = 1450/2900  Simp


The Simp indicator means the fraction can be simplified.


[ SIMP ]

2 brifely displays before 725/1450 Simp


Repeated presses of [ SIMP ]:

5,  145/290 Simp

5,  29/58  Simp

29,  1/2


Order of Operations


The fx-55 follows the order of operations.  This is great for students in algebra.  


Example: 


3 [ + ] 9 [ × ] 11 [ = ] returns 102     (multiplication/division first, then addition/subtraction) 


Verdict


I like the fx-55 Fraction Mate.  It has a lot of additional functions that beyond the traditional four-function calculator:  parenthesis, powers, reciprocal, fractions.  The display and the numbers are big.  I like how the arithmetic and power functions are displayed.   Worth the buy.


Casio Ledudu's page for fx-55, including the manual:  https://casio.ledudu.com/pockets.asp?type=1176&lg=eng


Eddie


All original content copyright, © 2011-2021.  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, September 4, 2016

HP 12C Platinum: Finding the Day of Easter

HP 12C Platinum:  Finding the Day of Easter

An Easter Algorithm

One can figure out when Easter is by the following algorithm:

“  c = y / 100

    n = y - 19 * ( y / 19 )

    k = ( c - 17 ) / 25

    i = c - c / 4 - ( c - k ) / 3 + 19 * n + 15

    i = i - 30 * ( i / 30 )

    i = i - ( i / 28 ) * ( 1 - ( i / 28 ) * ( 29 / ( i + 1 ) )

        * ( ( 21 - n ) / 11 ) )

    j = y + y / 4 + i + 2 - c + c / 4

    j = j - 7 * ( j / 7 )

    l = i - j

    m = 3 + ( l + 40 ) / 44

    d = l + 28 - 31 * ( m / 4 )
“  (see the Source below, http://aa.usno.navy.mil/faq/docs/easter.php )

The only input is y, the four digit year (1997, 2015, etc).   Each of the slashes “/” in the above text refers to integer division.  Hence in this case:  a/b refers to INTG(a ÷ b).

Other things I noticed while porting this algorithm to the HP 12C Platinum:

The line y - 19 * ( y / 19 ) can be expressed as y MOD 19 and 19 * fPart(y ÷ 19).   This happens in three other lines (2nd, 5th, and 8th).  See how to calculate the MOD function, when both arguments are positive on the HP 12C here:  http://edspi31415.blogspot.com/2016/07/hp-12c-programming-part-i-modulus-gcd.html

On the HP 12C Platinum, the LSTx function moved to [ g ] [ + ].  (Code 43, 40)

After the 5th line, the variable i will between 0 and 29.  If i ≤ 27, the 6th line can be skipped entirely since iPart(i/28) = 0.  Otherwise, iPart(i/28) = 1.  This cuts on down the number of steps needed.

I was also to combine some steps in the beginning by computing c and k while building i at the same time.

Storage arithmetic is allowed on R0 – R4 on both the HP 12C Platinum and the classic HP 12C.  By the way, the reason why I mention the HP 12C Platinum is that this program is 133 steps.  Only 99 steps are possible on the classic HP 12C.

Store registers:
R0: four digit year
R1:  c, m (result: month)
R2:  n, j, d (result: day)
R3: k, l
R4: i

Instructions:  Enter the four digit year.  Press [ R/S ].  The month will be displayed (stored in R1).  Press [ R/S ] to get the day (stored in R2).

HP12C Platinum Program:  Easter

STEP
CODE
KEY
Notes
001
44, 0 
STO 0
Store year (y)
002
1
1

003
25
%

004
43, 25
INTG

005
44, 1
STO 1
Store c
006
44, 4
STO 4
Start i
007
 36
ENTER
To fill the stack
008
36
ENTER

009
4
4

010
10
÷

011
43, 25
INTG

012
44, 30, 4
STO- 4

013
33
R↓

014
36
ENTER

015
36
ENTER

016
1
1

017
7
7

018
30
-

019
2
2

020
5
5

021
10
÷

022
43, 25
INTG

023
44, 3
STO 3
Store k
024
30
-

025
3
3

026
10
÷

027
43, 25
INTG

028
44, 30, 4
STO- 4

029
1
1

030
5
5

031
44, 40, 4
STO+ 4

032
45, 0
RCL 0

033
1
1

034
9
9

035
10
÷

036
43, 40
LSTx
LSTx is [ g ] [ + ] on the Platinum
037
34
X<>Y

038
43, 24
FRAC

039
20
*
 y MOD 19
040
44, 2
STO 2
 Store n
041
1
1

042
9
9

043
20
*

044
44, 40, 4
STO+ 4

045
45, 4
RCL 4

046
3
3

047
0
0

048
10
÷

049
43, 40
LSTx

050
34
X<>Y

051
43, 24
FRAC

052
20
*

053
44, 4
STO 4
i MOD 30
054
2 
2

055
7
7

056
45, 4
RCL 4

057
43, 44
x≤y
Is i≤27?
058
43, 33, 080
GTO 080
If so, go to step 080
059
2
2

060
9
9

061
45, 4
RCL 4

062
1
1

063
40
+

064
10
÷

065
43, 25
INTG

066
20
*

067
1
1

068
34
X<>Y

069
30
-

070
2
2

071
1
1

072
45, 2
RCL 2

073
30
-

074
1
1

075
1
1

076
10
÷

077
43, 25
INTG

078
20
*

079
44, 30, 4
STO- 4

080
45, 0 
RCL 0

081
45, 2
STO 2
Start j
082
4
4

083
10
÷

084
43, 25
INTG

085
 44, 40, 2
STO+ 2

086
45, 4
RCL 4

087
2
2

088
40
+

089
45, 1
RCL 1

090
30
-

091
44, 40, 2
STO+ 2

092
45, 1
RCL 1

093
4
4

094
10
÷

095
43, 25
INTG

096
44, 40, 2
STO+ 2

097
45, 2
RCL 2

098
7
7

099
10
÷

100
43, 40
LSTx

101
34
X<>Y

102
43, 24
FRAC

103
20
*

104
44, 2
STO 2
j MOD 7
105
 45, 4
RCL 4

106
34
X<>Y

107
30
-

108
44, 3
STO 3
Store l
109
4
4

110
0
0

111
40
+

112
4
4

113
4
4

114
10
÷

115
43, 25
INTG

116
3
3

117
40
+

118
44, 1
STO 1
Store month (m)
119
31
R/S
Displays m
120
4
4

121
10
÷

122
43, 25
INTG

123
3
3

124
1
 1

125
20
*

126
16
CHS

127
2
2

128
8
8

129
40
+

130
45, 3
RCL 3

131
40
+

132
44 , 2
STO 2
Store day (d)
133
43, 33, 000
GTO 000
Stop, display d


Examples and Test Data:

2016: 3, 27
Keystrokes:  2016 [R/S] [R/S]

1995: 4, 16
2124: 4, 2
1977: 4, 10
2017: 4, 16
1826: 3, 26

These results have been verified. 

Now we can determine when is Easter at any year.  Happy Easter in advance!

Eddie

Source:    The United States Naval Observatory  “The Date of Easter”  March 11, 2016.  http://aa.usno.navy.mil/faq/docs/easter.php  Retrieved September 2, 2016



This blog is property of Edward Shore, 2016.

Python: Drawing a Ring of Circles

Python: Drawing a Ring of Circles The goal: Draw a number of circles that revolve around the origin (0,0). The center of each circle i...