Showing posts with label algorithms. Show all posts
Showing posts with label algorithms. Show all posts

Saturday, August 23, 2025

Casio fx-92 Collège: Plotting Lines, Regular Polygons, and Functions

Casio fx-92 Collège: Plotting Lines, Regular Polygons, and Functions


Introduction


The Casio fx-92 Collège has an algorithm application which is similar to Scratch. For more details, please refer to the Alogirthmique Mode section of my spotlight review:


https://edspi31415.blogspot.com/2025/02/spotlight-casio-fx-92-college.html


A limitation of the fx-92 Collège is that programs are not retained once we leave the Algorithmique Mode or turn the calculator off.


Remember that the commands, the mathematical functions, and keys on the calculator fx-92 Collège are in French. The left column is what will see on the calculator screen** (in French) and the right column is a “rough” translation to English. Please note that I am currently not fluent in French.


** Demander valuer is just shown as ? → var. (Prompt for a value)

** Metire var á is shown as expression → var. (Store an expression to a variable)


Draw a line y = Ax + B.


French: fx-92 Collegè

English Translation

(Demander valeur) ? → A

? → A

(Demander valeur) ? → B

? → B

(Metire var á) (-24 – B) ÷ A →C

(-24 – B) ÷ A →C

(Metire var á) (24 – B) ÷ A →D

(24 – B) ÷ A →D

Si C ≥ D Alors

If C ≥ D Then

(Metire var á) C →E

C →E

(Metire var á) D →C

D →C

(Metire var á) E →D

E →D

Fin

End

Stylo relevè

Pen is raised

Aller à x = C ; y = A×C + B

Go to C, A × C + B

S’ orienter à tan^-1(A) degrès

Set orientation to arctan(A) degrees

Stylo écrit

Pen is down

Avancer de √((D-C)^2 + 48^2) pixels

Move forward √((D-C)^2 + 48^2) pixels

The algorithm draws a line when -24 ≤ y ≤ 24. If x is in the range -96 ≤ x ≤ 95, the line will be plotted on the screen.


The algorithm solves the following equations:


A x + B = -24

A x + B = 24


where the minimum of the two results are stored in C and the maximum of the two results are stored in D.


The equation is given in standard form where A is the slope and B is the y-intercept. If we go to the left side of the line (Xmin) and head to the right, we can draw the line in the direction of the slope, which is calculated by arctan(A). The arc-tangent function typical has a range between -180° to 180° (-π radians to π radians).



Draw a Regular Polygon


Draw a regular polygon of B sides. The radius is fixed at 20 pixels. The polygon is drawn in the middle of the screen.


French: fx-92 Collegè

English Translation

(Demander valeur) ? → B

? → B

(Metire var á) 40 × sin(180° ÷ B) → C

40 × sin(180° ÷ B) → C

Stylo relevè

Pen raised

Aller à x = -C ÷ 2; y = -20

Go to -C ÷ 2, -20

(Metire var á) 1 → A

1 → A

Stylo écrit

Pen is down

Répéter jusqú a A>B

Repeat until A > B

Avancer de C pixels

Move forward C pixels

Tourner de ⟲ 360° ÷ B degrès

Turn (360° ÷ B) degrees

(Metire var á) 1 + A → A

1 + A → A

End repeat loop



The program begins by determining the required side length and positioning the cursor to the point (-C/2, -20). This allows the polygon to drawn in the middle of the screen.



The relationship between the radius of regular polygon (r) and the side length (s) is:


s = 2 * r * sin(180° / n) = 2 * r * sin(π radians/n)


With r = 20, s = 40 * sin(180° / n)


The degree symbol is found in the Catalog → Angl/Coord/Sexag → Degrés.


The variable B is used for the number of sides.




Draw the Function C = f(z).


A = z minimum (Xmin), B = z maximum (Xmax)


Be aware that the plotting screen is limited and there is no ability to zoom. (-96 ≤ z ≤ 95)


The fx-92 errors if C < -999 or C > 999.


French: fx-92 Collegè

English Translation

(Demander valeur) ? → A

? → A

(Demander valeur) ? → B

? → B

(Metire var á) A→ z

A → z

Répéter jusqú a z >B

Repeat until z > B

(Metire var á) f(z)→ C (**)

f(z)→ C (**)

Si z = A Alors

If z = A Then (we are at the xmin at the graph)

Stylo relevè

Pen Raised

Sinon

Then

Stylo écrit

Pen is Down

Fin

End (If)

Aller à x = z ; y = C

Go to z ; C

(Metire var á) z + 0,5→ z

z + 0.5→ z

End repeat loop


Here is where you enter you function. Examples may include:


15 × cos((z ÷ 10)^r ) (^r: Catalog → Angl/Coord/Sexag → Radians)


√z


Abs(z – 3) (Catalog → Cacul Numèrique → Value Absolue)


-2 × z + 1.1


e^(-z) (Catalog → Autre → select e)



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.

The author does not use AI engines and never will.


Sunday, March 31, 2024

TI-30Xa Algorithms: Linear Regression

 TI-30Xa Algorithms: Linear Regression


Welcome to the March 2024 installment of TI-30Xa Algorithms.



Linear Regression with a TI-30Xa?


Today’s task is to fit bi-variate data to the line:


y = m * x + b


with the TI-30Xa. What? This calculator does not have a linear regression mode. Yes, with it is possible. We are going to use the technique shown in by the TI-36 Solar Guidebook from 1985 (see Source below). The TI-36 Solar was part of Texas Instruments’ line in the late 1980s and the early 1990s.


You can read my review on the TI-36 Solar from September 26, 2020 here:

https://edspi31415.blogspot.com/2020/09/retro-review-ti-36-solar.html


Where the TI-36 Solar only had one memory register, the TI-30Xa has three memory registers, and they are going to come in handy here.



Procedure


Caution: Be sure the calculator is on the entire time. Turning off the calculator will clear out statistics mode.


1. Enter the y data. Store the mean (y-bar) into memory register 2. Store the population deviation (σy) into memory register 3.


Keystrokes:

Mean of y-data: [ 2nd ] [ x^2 ] {x-bar} [ STO ] [ 2 ]

Population of y-data: [ 2nd ] [ ÷ ] { σxn } [ STO ] [ 3 ]


2. Clear the stat registers and enter the x data. As we are entering the x data, use memory register 1 to calculate Σxy.


Keystrokes:


Clear Stat Registers: [ 2nd ] [ 7 ] {CSR}


1st Point:

x1 [ × ] y1 [ = ] [ STO ] [ 1 ]

x1 [ Σ+ ]


Every point there after:

x_i [ × ] y_i [ = ] [ 2nd ] [ RCL ] {SUM} [ 1 ]

x_i [ Σ+ ]



3. Calculate the slope, and replace Σxy with the slope.


m = ( y-bar * Σx – Σxy) / ( x-bar * Σx - Σx^2)


Keystrokes:

[ ( ] [ RCL ] [ 2 ] [ × ] [ 2nd ] [ ( ] [ - ] [ RCL ] [ 1 ] [ ) ]

[ ÷ ] [ ( ] [ 2nd ] [ x^2 ] [ × ] [ 2nd ] [ ( ] [ - ] [ 2nd ] [ ) ] [ = ] [ STO ] [ 1 ]


4. Calculate the y-intercept, replace y-bar with the y-intercept.


b = -m * x-bar + y-bar


Keystrokes:

[ RCL ] [ 1 ] [ +/- ] [ × ] [ 2nd ] [ x^2 ] [ + ] [ RCL ] [ 2 ] [ = ] [ STO ] [ 2 ]


5. Calculate the correlation. If the correlation is close to -1 or +1, the linear fit will be excellent.


r = m * σx / σy


Keystrokes:

[ RCL ] [ 1 ] [ × ] [ 2nd ] [ ÷ ] [ ÷ ] [ RCL ] [ 3 ] [ = ]


6. Use slope (m) and intercept (b) to predict x and y values:


y’ = m * x0 + b

Keystrokes: [ RCL ] [ 1 ] [ × ] x0 [ + ] [ RCL ] [ 2 ] [ = ]


x’ = (y0 – b) / m

Keystrokes: [ ( ] y0 [ - ] [ RCL ] [ 2 ] [ ) ] [ ÷ ] [ RCL ] [ 1 ] [ = ]


Key Map


[ RCL ] [ 1 ]: first Σxy, then m

[ RCL ] [ 2 ]: first y-bar, then b

[ RCL ] [ 3 ]: σy

[ 2nd ] [ x^2 ]: x-bar

[ 2nd ] [ ÷ ]: σxn



Example


Fit a line to the data:


X

Y

12

100

13

98.7

14

97.1

16

94.9

18

92.6

20

90



1. Enter the y data. Store the mean (y-bar) into memory register 2. Store the population deviation (σy) into memory register 3.


100 [ Σ+ ]

98.7 [ Σ+ ]

97.1 [ Σ+ ]

94.9 [ Σ+ ]

92.6 [ Σ+ ]

90 [ Σ+ ] (display n = 6)



Mean of y-data: [ 2nd ] [ x^2 ] [ STO ] [ 2 ] (y-bar = 95.55)


Population of y-data: [ 2nd ] [ ÷ ] [ STO ] [ 3 ] (σy = 3.465424457)



2. Clear the stat registers and enter the x data. As we are entering the x data, use memory register 1 to calculate Σxy.


Keystrokes:


Clear Stat Registers: [ 2nd ] [ 7 ] {CSR}


12 [ × ] 100 [ = ] [ STO ] [ 1 ]

12 [ Σ+ ]


13 [ × ] 98.7 [ = ] [ 2nd ] [ RCL ] [ 1 ] (SUM 1)

13 [ Σ+ ]


14 [ × ] 97.1 [ = ] [ 2nd ] [ RCL ] [ 1 ] (SUM 1)

14 [ Σ+ ]


16 [ × ] 94.9 [ = ] [ 2nd ] [ RCL ] [ 1 ] (SUM 1)

16 [ Σ+ ]


18 [ × ] 92.6 [ = ] [ 2nd ] [ RCL ] [ 1 ] (SUM 1)

18 [ Σ+ ]


20 [ × ] 90 [ = ] [ 2nd ] [ RCL ] [ 1 ] (SUM 1)

20 [ Σ+ ]


RCL 1: Σxy = 8827.7

[ 2nd ] [ x^2 ]: x-bar = 15.5



3. Calculate the slope, and replace Σxy with the slope.


[ ( ] [ RCL ] [ 2 ] [ × ] [ 2nd ] [ ( ] [ - ] [ RCL ] [ 1 ] [ ) ]

[ ÷ ] [ ( ] [ 2nd ] [ x^2 ] [ × ] [ 2nd ] [ ( ] [ - ] [ 2nd ] [ ) ] [ = ] [ STO ] [ 1 ]


Slope: m = -1.230526316


4. Calculate the y-intercept, replace y-bar with the y-intercept.


[ RCL ] [ 1 ] [ +/- ] [ × ] [ 2nd ] [ x^2 ] [ + ] [ RCL ] [ 2 ] [ = ] [ STO ] [ 2 ]


Intercept: b = 114.6231579


5. Calculate the correlation.


[ RCL ] [ 1 ] [ × ] [ 2nd ] [ ÷ ] [ ÷ ] [ RCL ] [ 3 ] [ = ]


Correlation: r = -0.999092386


The line is:


y = -1.230526316 * x + 114.6231579



6. Predict values.


If x = 15, predict the y value (y’):


[ RCL ] [ 1 ] [ × ] x0 [ + ] [ RCL ] [ 2 ] [ = ]

y’ = 96.16526316


If y = 95, predict the x value (x’):


[ ( ] y0 [ - ] [ RCL ] [ 2 ] [ ) ] [ ÷ ] [ RCL ] [ 1 ] [ = ]

x’ = 15.94696322



Source


Alley, Chris M., Brenda M. Cornitius, et al. TI-36 Solar Guidebook Texas Instruments Incorporated. Dallas, TX. 1985, 1986, 1987. pp. 4.6 – 4.13



Eddie


All original content copyright, © 2011-2024. 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, May 27, 2023

TI-Nspire CX II (CAS): How Many Terms Are Needed to Calculate π?

TI-Nspire CX II (CAS): How Many Terms Are Needed to Calculate π?



Every One Wants a Slice of π


There are many ways of calculating the π, usually apply a formula or a sequence many, many, many times to get as many digits as possible.  The file pitests.tns tests (see below) five algorithms:



Test 1:  Zeta Formula


π^2 / 6 = Σ( 1 / n^2, n=1 to ∞ )


Test 2:  Pi Squared Over Eight Sum


π^2 / 8 = Σ( (2 * n + 1)^(-2), n = 0 to ∞)


Test 3:  Half of Pi Product


π / 2 = Π( (2 * k)^2 / ((2 * k - 1) * (2 * k + 1)), k = 1 to ∞)


Test 4:  Fibonacci Number Sum


π / 2 = Σ( arctan((F_[2*k+1])^(-1)), k = 0 to ∞ )


The angle is radians.  F_[2*k+1] is the [2*k+1]th Fibonacci number.


Test 5:  Limit Sequence


π = lim (n → ∞) [ a^2 / n ]


where 

a0 = 1

a_[n+1] = a_[n] * (1 + (2 * n + 1)^(-1))


The goal is to determine how many terms are needed to obtain a certain amount of digits.  






Certain algorithms take longer than others.     Here are some results:


2 places:  3.14

3 places:  3.141



Test 1:  

2 decimal places:  600 terms

3 decimal places:  1611 terms 


The zeta function converges super slowly for small arguments.


Test 2:

2 decimal places:  199 terms

3 decimal places:  537 terms


Test 3:

2 decimal places:  493 terms

3 decimal places:  1325 terms


Test 4:

2 decimal places:  9 terms

3 decimal places: 10 terms


The Fibonacci method is the fastest and probably is the quickest way to build the expansion of π.


Test 5:

2 decimal places:  94 places

3 decimal places:  1929 places



Download the file pitests.tns here:  https://drive.google.com/file/d/1XqHtPnoKvqfmFLNWHQ-IayFz_lM5zZyT/view?usp=share_link



Source


"List of formulae involving π"  Wikipedia.   Edited on February 11, 2023.   Accessed on March 12, 2023.  https://en.wikipedia.org/wiki/List_of_formulae_involving_%CF%80



Note:   On June and July 2023, regular posts will be on Saturdays only, which will include the next Carnival of Math.


Eddie



All original content copyright, © 2011-2023.  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, August 15, 2021

Construction Pro 5: Geometry Algorithms

Construction Pro 5:  Geometry Algorithms


Before We Begin


Before we begin, some things to note:


1.  The [ Circ ] [ Circ ] sequence gives the area of a circle given by the denominator.  Area = (π * diameter^2) / 4 


2.  The [ Conv ] [ Rcl ] will clear the Construction Master 5's memory register.  So will [ Rcl ] [ Rcl ], the only difference is that the former sequence will not recall the memory's contents.


3.  The [ Rcl ] [ M+ ] sequence will recall the memory register's contents.


4.  The Construction Master 5 operates in Chain mode, like standard four-function calculators.  


5.  The algorithms presented today is one way to approach these calculation, most of them demonstrate the [ Circ ] [ Circ ] and memory features.   


Area:  Donut Driveway




Area = ((2D + I)^2 - I^2) * π/4


Key Sequence:


[ Conv ] [ Rcl ]

2 [ x ] D [ + ] I [ = ] [ Circ ] [ Circ ] [ M+ ]

I [ Circ ] [ Circ ] [ Conv ] ( M- )

[ Rcl ] [ M+ ]


Example:

D = 50 feet, I = 10 feet


[ Conv ] [ Rcl ]

2 [ x ] 50 [ Feet ] [ + ] 10 [ Feet ] [ = ] [ Circ ] [ Circ ] [ M+ ]

10 [ Feet ] [ Circ ] [ Circ ] [ Conv ] ( M- )

[ Rcl ] [ M+ ]


Result:  9,424.778 ft^2


Volume:  One-Hole Concrete Block




Note:  The border length (d) is equal around the entire block.


V = ( ( W + L ) * 2 * d - 4 * d^2 ) * t


Key Sequence:


[ Conv ] [ Rcl ]

W [ + ] L [ x ] 2 [ x ] d [ M+ ]

d [ Conv ] ( x^2 ) [ x ] 4 [ M- ]

[ Rcl ] [ M+ ] [ x ] t [ = ]


Example:

L = 12 in, W = 8 in, d = 1 in, t  10 in


[ Conv ] [ Rcl ]

8 [ Inch ] [ + ] 12 [ Inch ] [ x ] 2 [ x ] 1 [ Inch ] [ M+ ]

1 [ Inch ] [ Conv ] ( x^2 ) [ x ] 4 [ M- ]

[ Rcl ] [ M+ ] [ x ] 10 [ Inch ] [ = ]


Result:  360 in^3


Volume: Right Triangular Prism




V = D * H * B / 2 


Key Sequence:


D [ x ] H [ x ] B [ ÷ ] 2 [ = ]


Example:

D = 325 ft, H = 77 ft, B = 148 ft


325 [ Feet ] [ x ] 77 [ Feet ] [ x ] 148 [ Feet ] [ ÷ ] 2 [ = ]


Result:  1,851,850 ft^3 ≈ 68,587.04 yd^3


Volume:  Sphere Using the Circ Function





V = 4/3 * π * r^3 = π * d^3 / 6 = area_circle * d / 1.5

where area_circle = π * d^2 / 4


Key Sequence:


[ Conv ] [ Rcl ]

D [ M+ ] [ = ] [ Circ ] [ Circ ] [ x ] [ Rcl ] [ M+ ] [ ÷ ] 1.5 [ = ]


Note:  The first equals key "locks" in the value of D on to the register and allows it to be picked up with the Circ function without having to re-type it.  


Example:

D = 5 ft


[ Conv ] [ Rcl ]

5 [ Feet ] [ = ] [ M+ ] [ Circ ] [ Circ ] [ x ] [ Rcl ] [ M+ ] [ ÷ ] 1.5 [ = ]


Result: 65.44985 ft^3


Volume:  Column Using the Circ Function



V = π * D^2 * H / 4 = area_circle * H

where area_circle = π * d^2 / 4


Key Sequence:


D [ Circ ] [ Circ ] [ x ] H [ = ]


Example:

D = 2 ft 2 in, H = 1 ft 8 in


2 [ Feet ] 2 [ Inch ] [ Circ ] [ Circ ] [ x ] 1 [ Feet ] 8 [ Inch ] [ = ]


Result:  6.145013 ft^3


Commas added for readability.  


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. 


Earth's Radius by Latitude

Earth's Radius by Latitude Introduction: Calculating the Earth’s Radius In quick, general calculations, we assume that the...