Saturday, March 15, 2025

Casio Python with fx-CG 50: Drawing Shapes with Casioplot (draws.py)

Casio Python with fx-CG 50: Drawing Shapes with Casioplot (draws.py)


The Casio file draws.py is a file that use both the casioplot and math modules and contains four drawing functions.


The plot functions uses the pixel system.


Upper left hand corner: (0, 0)

Upper right hand corner: (383, 0)

Lower left hand corner: (0, 191)

Lower right hand corner: (383, 191)


The x axis increases going right and the y axis increases going down. This orientation is common for a pixel-orientated coordinate system.


Note that the pixels must be integers. A non-integer value for a pixel will cause an error.



Importing the draws module


After copying the file draws.py to your calculator, type: from draws import *


The casioplot and math modules will also be imported because the draws module is imported. This is the case of the fx-CG 50, and I’m pretty sure it will work with the other Casio calculators with Python (fx-9750GIII, fx-9860GIII, fx-CG 100, Graph Math+).


To clear the drawing screen, use the casioplot’s command clear_screen().


To show the picture, use the casioplot’s command show_screen().


The functions from the draws must be manually typed, as they will not appear in the catalog or VARS menu.



sline(x,sx,y,sy,l,c)


Draws a line from (x,y) of length l and color c. The color is a three-element tuple in the RGB format ((red, green, blue)).


The arguments sx and sy are direction/slope arguments which dictate the direction of the line.


To draw a line going left (←)

Set sx = -1 and sy = 0

To draw a line going right (→)

Set sx = 1 and sy = 0

To draw a line going up (↑)

Set sx = 0 and sy = -1

To draw a line going down (↓)

Set sx = 0 and sy = 1

To draw a line going right and up (↗)

Set sx = 1 and sy = -1

To draw a line going left and up (↖)

Set sx = -1 and sy = -1

To draw a line going right and down (↘)

Set sx = 1 and sy = 1

To draw a line going left and down (↙)

Set sx = -1 and sy = 1


Examples:

sline(1,1,1,0,140,(255,0,0)) draws a red line starting from (1,1) going right with length of 140 pixels


sline(180,0,100,-1,50,(0,255,0)) draws a green line starting from (180,100) going up with length of 50 pixels





The sample file draw1.py is a demonstration of the sline command.






box(x,xl,y,yl,c)


The box function draws a box with the upper left hand corner (x,y) with color c, horizontal length (width) xl, and vertical length (height) yl. The box draws to the right and down. The box is filled with the specified color. If xl = yl, the function will draw a square.


Example:

box(20,100,40,150,(128,128,128)) draws a gray rectangle with upper-left corner at (20,40) with horizontal length of100 and vertical length of 150.


box(300,60,0,60,(0,0,0)) draws a black square with upper-left corner at (300, 0) with the side length of 60.





The sample file draw2.py uses the box function to generate a random game map of land (green) and water (blue).






tri(x,xd,y,yd,l,c)


The tri function draws a 45-45-90 right triangle. The point (x,y) is the corner point that contains the right angle of 90°. The arguments xd and yd dictate the direction of the triangle (see table below).





The triangle is filled with color c. The sides of the triangle will be drawn with length l.


Example:


tri(80,1,80,-1,75,(0,128,128)) draws a teal 45-45-90 right triangle with the right angle located at (80, 80). The length is 75 pixels.





The sample file draw3.py uses the tri function to draw four triangles, one with each proper orientation.






circ(x,y,r,c)


The circ function draws a circle centered at (x, y) with radius r and color c. The circle is drawn as outline and not filled. To make the circle appear as smooth as possible, 720 points are plotted.


Example:

circ(190,100,85,(255,128,0)) draws an orange circle with radius 85, centered at (190, 100).





The file draw4.py demonstrates the circ function.






Casio fx-CG 50 Python: draws.py code


# drawing utilities

# 12-04-2024


from casioplot import *

from math import *


def sline(x,sx,y,sy,l,c):

  for i in range(l+1):

    set_pixel(x+sx*i,y+sy*i,c)


# upper left corner

def box(x,xl,y,yl,c):

  for i in range(xl+1):

    for j in range(yl+1):

      set_pixel(x+i,y+j,c)


# right triangle

# (x,y) point with right angle

# l=length

# xd=1 right, xd=-1 left

# yd=1 down, yd=-1 up

def tri(x,xd,y,yd,l,c):

  for i in range(l+1):

    k=l-i

    for j in range(k+1):

      set_pixel(x+xd*i,y+yd*j,c)


# hallow circle

def circ(x,y,r,c):

for i in range(721):

  t=2*pi*i/720

  xr=int(x+r*cos(t))

  yr=int(y+r*sin(t))

  set_pixel(xr,yr,c)



You can download the draws.py and the example Python files here:

https://drive.google.com/file/d/1rGQHa60V7ZCE9Vs0kYy0cfIe0pOXqVaZ/view?usp=sharing


I hope you enjoy this program as much as I have making it,



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.

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, March 9, 2025

Spotlight: Calculated Industries QR Calc

Spotlight: Calculated Industries QR Calc <Title>


Quick Facts



Model: 3375

Name: QR Calc

Company: Calculated Industries

Timeline: 1993

Type: Quality Control, Statistics

Operating System: Algebraic

Digits: 7

Memory: 1 general purpose memory register plus specific variable registers 

Power: 1 CR-2032 battery





When I purchased the QR Calc, there was no manual with it. Normally, it wouldn’t present any issues because I can often find manuals online. That is not the case with the QR Calc. If there is any manual online, please email me. I’ll have to be more careful next time.



I apologize that I will not be able to describe all the functions but hopefully I describe enough features to give the reader a general idea. Please check out the sources below.



Features



Let’s start with the mathematical functions included: powers and roots (y^x, x². √), natural logarithm (ln), exponential function (e^x), reciprocal (1/x), arithmetic (+, -, ×, ÷), and the standard percent key which operates they people expect it to (%). The order of operations is enforced. Like a lot of calculators, the change sign (+/-) key is a shifted function.



The operating range of the calculator is 7 digits: -9,999,999 to 9,999,999. Any calculator that has a result outside of this range causes the QR calculator to display an error message.



The store key for the QR Calc is labeled [ Set ].



The function →PPM changes any number into n parts per million.

Example: 0.0014 →PPM displays 1,400 PPM.



Here are some functions I was able to find out and figure out:



Normal Distribution



The normal distribution functions calculate areas of the standard normal distribution, assuming that μ = 0 and σ = 1.



n [ nZ ]: lower tail probability (from -∞ to x = n)

n [ 2nd ] (ModZ): probability from x = 0 to x = n



One Variable Statistics



The QR handles a single set of statistics with the following key and key sequences:



[ Add ]: Add a data point (Σ+)

[ 2nd ] [ Add ] (Subtract): Subtract a data point (Σ-)

[ 2nd ] [ + ] (S←→P): Toggle between standard deviation and population deviation (σn indicator)



[ x-bar ]: Calculate the arithmetic mean.

[ R ]: Calculate the range of the data.

[ 2nd ] [ x-bar ] (N): Calculate the number of data points.

[ 2nd ] [ R ] (σ): Calculate the deviation, depending on the deviation mode set.

[ Low ]: Returns the minimum value of the data set entered.

[ 2nd ] [ Low ] (High): Returns the maximum value of the date set entered.



[ Skew ]: Skew. I’m not sure what formula the QR Calc uses because I have not been able to match results with any formula I found yet.

[ 2nd ] [ Skew ] (Kurt): Excess Kurtosis. Kurtosis measures how concentrated the data is with respect to the mean.



The formula used for Excess Kurtosis:

μ4 = 1/n * Σ((xi – mean)^4)

kurtosis = μ4/s^4 – 3



Process Capability Indices



If a process is mature, that is a process that is regular and has been executed for a period of time, we can measure the capability index.



There are two capability indices:



Cp: for a centered analysis

Cpk: for a non-centered analysis. This metric is used for potential future performance.

Generally, we want these indices to be at least 1. Capable processes have an Cp index of 1.33 or higher.



Key strokes:

Enter the mean: [ Set ] [ x-bar ]

Enter the deviation: [ Set ] [ 2nd ] [ R ] ( σ )

Enter the lower specification limit (based on the normal distribution): [ Set ] [ LSL ]

Enter the upper specification limit: [ Set ] [ 2nd ] [ LSL ] (USL)

Each variable entered will have an indicator.



Calculate Cp: [ 2nd ] [ Cpk ] (Cp)

Calculate Cpk: [ Cpk ]



Example:

LSL = - 1, USL = 1, mean = 0.05, deviation = 0.27

[ 2nd ] [ × ] (AC) to clear out the registers if needed

0.5 [ Set ] [ x-bar ] (x-bar indicator is on)

0.27 [ Set ] [ 2nd ] [ R ] ( σ ) (σ indicator is on)

1 [ 2nd ] [ - ] (+/-) [ Set ] [ LSL ] (L indicator is on)

1 [ Set ] [ 2nd ] [ LSL ] (USL) (U indicator is on)



Results:

Cp: 1.234568

Cpk: 1.17284

That is a pretty good process.



Formulas Used:

Cp = (USL -LSL) / (6 * σ)

Cpx = min((x-bar – LSL) / (3 * σ), (USL – x-bar) / (3 * σ))





Control Charts



We get to the main feature of the QR Calc: Control Charts and Capability Limits. On the back of the calculator, the QR Calc has a list of handy formulas.







The heart of the QR Calc is the table of constants that are used in control charts and limit charts. Often the chart limits are built on many samples of n data points each, where x-bar is the average of the sample averages, and R is the average of the range samples. We can also build chart limits with one sample. The QR Calc can only handle sample sizes from 3 to 25 data points.



Mean Control Chart Limits:

Lower: LCL-mean = x-bar – n * A2 * R

Upper: UCL-mean = x-bar + n * A2 * R



R Control Chart Limits:

Lower: LCL-R = n * D3 * R

Upper: UCL-R = n * D4 * R



A2, D3, and D4 are constants used in calculating control chart limits. Accessing these constants takes one argument, which is the sample size.



The A2 constant for a sample size of 3: 3 [ nA2 ] returns 1.023.



Below is a short table of constants, as determined by the QR Calc.



Sample Size n

Constant A2

Constant D3

Constant D4

5

0.577

0

2.114

10

0.308

0.223

1.777

15

0.223

0.347

1.653

20

0.18

0.415

1.585

25

0.153

0.459

1.541



Standard deviation can be estimated by using the average range ( R ) and another constant d2:

σ ≈ R / d2

Sample Size n

Constant d2

5

2.326

10

3.078

15

3.472

20

3.735

25

3.931


A table of constants from n = 2 to 25 can be found here:

https://sixsigmastudyguide.com/x-bar-r-control-charts/



Example:

Construct mean and range charts from a sample (n = 5):

3.995

4.26

4.37

4.44

4.58



Keystrokes:

(after clearing data)

3.995 [ Add ] 4.26 [ Add ] 4.37 [ Add ] 4.44 [ Add ] 4.58 [ Add ]



X-bar chart:

LCL: [ x-bar ] - 5 [ nA2 ] [ × ] [ R ] [ = ] Result: 3.991455

UCL: [ x-bar ] + 5 [ nA2 ] [ × ] [ R ] [ = ] Result: 4.666545



R chart:

LCL: 5 [ 2nd ] [ nD4 ] (nD3) [ × ] [ R ] [ = ] Result: 0

UCL: 5 [ nD4 ] [ × ] [ R ] [ = ] Result: 12.36669

The QC calc has contains the E2 constant.



Final Thoughts



The functions that I still do not know about or have figured out are: TRGa, TRGb, RS a, RS b, %Low, and %High.



This review is incomplete. I will keep searching for a manual, I may have to buy another QR Calc.



This calculator is a rarity, and one worth checking out.






Sources


Hessing, Ted. “Process Capability (Cp & Cpk)” 6σSTUDYGUIDE.COM (no specific date give, first comment on November 19, 2014) https://sixsigmastudyguide.com/process-capability-cp-cpk/. Accessed January 2025.



Hessing, Ted. “X Bar R Control Charts” 6σSTUDYGUIDE.COM (no specific date give, first comment on April 17, 2018) https://sixsigmastudyguide.com/x-bar-r-control-charts/. Accessed January 2025.


Hewlett Packard. HP-65 Stat Pac 2 Cupertino, CA. https://literature.hpcalc.org/items/975 1975




Next time, I’m going to see if a manual comes with it. Not everything has a manual online.




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.

Casio Python with fx-CG 50: Drawing Shapes with Casioplot (draws.py)

Casio Python with fx-CG 50: Drawing Shapes with Casioplot (draws.py) The Casio file draws.py is a file that use both the casioplot and...