Sunday, May 5, 2024

Circular Sector: Finding the Radius and Angle

 Circular Sector: Finding the Radius and Angle





Here is the problem:


We are given the area of the circular segment, A, and the arc length of the segment, s. What is the radius, r, and the angle, θ?


The arc length is calculated as: s = θ * r


The area is calculated as: A = ½ * θ * r^2


We have the system of equations:


A = ½ * θ * r^2

s = θ * r


Divide A by s:


A / s= (½ * θ * r^2) / (θ * r)

A / s = r / 2

2 * A / s = r


Then

s = r * θ

θ = s / r = s^2 / (2 * A)


In summary:

r = 2 * A / s

θ = s / r = s^2 / (2 * A)


Note that the angle is in radians.

Example


Example 1:

s = 4, A = 30


r = (2 * 30) / 4 = 15

θ = 4 / 15 ≈ 0.266666667


Example 2:

s = 10.5, A = 31.8


r = (2 * 30) / 4 = 212/35 ≈ 6.057142857

θ = 10.5 / (212/35) = 735/424 ≈ 1.733490566


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 4, 2024

Battle of the “Cheap” Calculators: Sharp EL-501W vs. Bazic 3003

Battle of the “Cheap” Calculators: Sharp EL-501W vs. Bazic 3003


Let’s Get Ready to Rumble!”


Today is an accuracy battle between the:


Sharp EL-501W





This is brand name calculator. In the 2010s, Sharp manufactured one with blue casing. However, their current EL-501W type (really named the EL-501XBWH) has black casing. Both the EL-501W and EL-501XBWH have the same keyboard and the same amount of functions. The average price runs from $9 to $16 (US).





This is the Bazic 3003, a clone of the Sharp EL-501W/EL-501XBWH. This model sells in discount stores for anywhere from $3 to $6 (US).


There is another clone, the Jot Scientific Calculator which is physically smaller than both models I mentioned, and is even cheaper, close it $1 to $3. (US) I won’t be using this model in today’s tests.


The features on all these models include:


* trigonometric, hyperbolic, logarithm, and power functions

* binary, decimal, octal, and hexadecimal base conversions

* two buttons, [ a ] and [ b ] which assists with complex number arithmetic and polar/rectangular conversions

* random numbers

* one-variable statistics with basic analysis



The Exchange Function: { ↕ }


The exchange key switches the operands in arithmetic calculation. The key sequence is the same: [ 2ndF ] [ ( ] { ↕ }. If we complete an arithmetic calculation by pressing the equals button [ = ], the exchange function recalls the second operand for each operation. Well, almost.


Operation

Keystrokes

Result

Addition

A [ + ] B [ = ] [ 2ndF ] [ ( ] { ↕ }

B

Subtraction

A [ - ] B [ = ] [ 2ndF ] [ ( ] { ↕ }

B

Multiplication

A [ × ] B [ = ] [ 2ndF ] [ ( ] { ↕ }

A

Division

A [ ÷ ] B [ = ] [ 2ndF ] [ ( ] { ↕ }

B

Power

A [ y^x ] B [ = ] [ 2ndF ] [ ( ] { ↕ }

B

(A, B are two arbitrary numbers)



The Sharp EL-501W has plastic keys, a slide case, and takes two LR44 batteries, while the Bazic 3033 has rubber keys, a flip case, and takes two LR1130 batteries. As a personal preference, I prefer plastic keys to rubber keys.


Let’s compare.



A Comparison of Accuracy


The Trigonometric Forensics Evaluation


This test calculates:

arcsin( arccos( arctan( tan( cos( sin( 9° )))))) (six set of parenthesis)


However, we do not need parenthesis:

[ DRG ] (press until degrees mode is set)

9 [ SIN ] [ COS ] [ TAN ]

[ 2ndF ] [ TAN ] {TAN^-1} [ 2ndF ] [ COS ] {COS^-1} [ 2ndF ] [ SIN ] {SIN^-1}


Ideally, the answer returned should be exactly 9.





This test is presented on datamath.org web site (see source below), and this test was used to determine what chips were used in various Texas Instruments calculators.


Results:

Sharp EL-501W

8.9999 98637

Bazic 3003

8.9999 9986


Bazic gets the slight edge on this test.


The Cube of a Complex Number


The next test calculates (4.5 + 2.2i)^3.


The complex number mode only works for arithmetic functions (+, -, ×, ÷).


First, lets’ calculate the cube in complex mode.


Keystrokes:

[ 2ndF ] [ → ] {CPLX} (until CPLX indicator appears)

4.5 [ a ] 2.2 [ b ] [ × ] 4.5 [ a ] 2.2 [ b ] [ × ] 4.5 [ a ] 2.2 [ b ] [ = ]


Results:

Sharp EL-501W

25.785 + 123.002i (press [ b ] for the imaginary part)

Bazic 3003

25.785 + 123.002i (press [ b ] for the imaginary part)



Now in Real Mode using the polar/rectangular conversion functions.


Keystrokes:

[ 2ndF ] [ → ] {CPLX} (until CPLX indicator disappears)

4.5 [ a ] 2.2 [ b ] [ 2ndF ] [ a ] { →rθ }

[ b ] [ x→M/STO ] [ a ] [ y^x ] 3 [ = ] (manually record 125.6756071)

[ RM/RCL ] [ × ] 3 [ = ] [ b ] 125.6756071 [ a ] [ 2ndF ] [ b ] { →xy }


Results:

Sharp EL-501W

25.78499999 + 123.002i (press [ b ] for the yi part)

Bazic 3003

25.78499999 + 123.002i (press [ b ] for the yi part)



Test of the Logarithm Bug


This test to check to the accuracy of the approximation of e^x, where


e^x = lim n → ∞ (1 + x / n) ^n


If x = 1, then e = e^x = lim n → ∞ (1 + 1 / n) ^n


This test came about because there were several TI-30X and TI-36X calculators that were manufactured in the 1990s. See the Logarithm Bug in the Sources section for more details.


At various values of n:


(1 + 1 / N)^N

Sharp EL-501W

Bazic 3003

N = 10

2.59374246

2.59374246

N = 1,000

2.716923932

2.716923932

N = 100,000

2.718268237

2.718268237

N = 10,000,000 = 1E7

2.718281693

2.718281693


Both calculators give the same results. More importantly, there is no “logarithm bug” present from these results. Yay!



Statistics of Large Numbers


Sometimes when doing statistics of large numbers, which the numbers themselves differ by little, accuracy can suffer.


The data points for this sample:

100 008

100 014

100 007

100 016

100 009

100 006

100 010

100 015

100 012

100 018


Both calculators give these results:


Mean: 100011.5

Sum: 1000115

Sum^2: 1.0002E+11 (1.000230015E+11)

σx = 3.905124838

sx = 4.116363012

n = 10



Overall, the two calculators return the same result. Based off these results, it’s down to how much money you want to spend and what type of keys do you prefer.



Sources


Woerner, Joerg. “Calculator Integrated Circuits Forensics” Datamath.org. Last updated December 12, 2001

http://www.datamath.org/Forensics.htm. Retrieved March 16, 2024.



Senzer, Bob, Mike Sebastian, and Joerg Woerner. “Logarithm Bug” Datamath.org. Last updated October 11, 2005. http://www.datamath.org/Story/LogarithmBug.htm Retrieved March 16, 2024.


For the Star Wars fans, may the Fourth and Force be with you,


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.


Sunday, April 28, 2024

TI 30Xa Algorithms: Fundamental Horizontal Circle Calculations

 TI 30Xa Algorithms: Fundamental Horizontal Circle Calculations



Introduction and Formulas





Given the following:


r = radius of the curve

Δ = central angle, or the angular sweep of the curve. The angle is usually given in whole degrees or in surveying, degrees-minutes-seconds.


We can calculate the following:


The length of the tangent line to the central meeting point:

t = r × tan( Δ / 2 )


The linear distance from where the curve begins to the point the curve ends, known as the chord distance:

c = 2 × r × sin( Δ / 2 )


The distance of the curve from the end points, known as the arc length:

s = (Δ° / 180°) × π × r


Note the formula for arc length assumes that the angle is in degrees. If the angle is in radians, the formula for arc length reduces to s = Δ rad × r.



Procedure


The procedure is made for the TI-30Xa, where we can take advantage of the three memory registers it has. You can use another calculator, except most basic scientific calculators only have one memory register; you will just have type in one of the extra variables.


1. Check the angle mode. We should be in degrees mode, which is indicated by the DEG indicator. If not, press the [ DRG ] key until degrees mode is selected.


2. Enter the central degree (Δ).


If the degree is in whole degrees, just enter the angle and store into memory register 1. ( [ STO ] [ 1 ] ).


If the degree is in degrees-minutes-seconds format (known as DMS or sometimes as HMS), enter the angle in DD.MMSSS format. Then press [ 2nd ] [ + ] {DMS>DD} to convert the angle into whole degrees. Then store the result into memory register 1.


3. Enter the radius length and store in memory register 2. ( [ STO ] [ 2 ] ).


Memory registers:

M1 = Δ; M2 = r


4. Calculate the tangent length, t:


[ ( ] [ RCL ] 1 [ ÷ ] 2 [ ) ] [ TAN ] [ × ] [ RCL ] 2 [ = ]


5. Calculate the chord distance, c:


2 [ × ] [ RCL ] 2 [ × ] [ ( ] [ RCL ] 1 [ ÷ ] 2 [ ) ] [ SIN ] [ = ]


6. Calculate the arc length, s:


[ RCL ] 1 [ × ] [ π ] [ × ] [ RCL ] 2 [ ÷ ] 180 [ = ]


Examples


Let’s assume for the following examples Degrees mode is set (DEG).


Example 1:

r = 150 ft (it can be any length unit as long as you keep it consistent)

Δ = 60° (whole degrees)


60 [ STO ] 1

150 [ STO ] 2


t: [ ( ] [ RCL ] 1 [ ÷ ] 2 [ ) ] [ TAN ] [ × ] [ RCL ] 2 [ = ]

t = 86.60254038 ft


c: 2 [ × ] [ RCL ] 2 [ × ] [ ( ] [ RCL ] 1 [ ÷ ] 2 [ ) ] [ SIN ] [ = ]

c = 150 ft

(In this case, the chord length is the same as the radius. Why? There is a geometric reason.)


s: [ RCL ] 1 [ × ] [ π ] [ × ] [ RCL ] 2 [ ÷ ] 180 [ = ]

s = 157.0796327 ft



Example 2:

r = 324 ft

Δ = 92°22’18” (92 degrees, 22 minutes, 18 seconds)


92.2218 [ 2nd ] [ + ] {DMS>DD} [ STO ] 1

324 [ STO ] 2


t: [ ( ] [ RCL ] 1 [ ÷ ] 2 [ ) ] [ TAN ] [ × ] [ RCL ] 2 [ = ]

t = 337.6968953 ft


c: 2 [ × ] [ RCL ] 2 [ × ] [ ( ] [ RCL ] 1 [ ÷ ] 2 [ ) ] [ SIN ] [ = ]

c = 467.5897175 ft


s: [ RCL ] 1 [ × ] [ π ] [ × ] [ RCL ] 2 [ ÷ ] 180 [ = ]

s = 522.3494689 ft



Source

Hewlett-Packard Company. HP-46 sample applications. Loveland, CO. February 1,1975. Part No. 00046-90018. pg. 104-105



Happy Birthday, Smokey!


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, April 27, 2024

Casio fx-CG 50: Points on a Circle

 Casio fx-CG 50: Points on a Circle


Introduction and Derivation





Given the initial point on a circle (x, y). If the point travels on a circle a distance of arc length s, where is the new point on the circle? Assumption: The center of the circle lies on the point (0, 0).


In fact, we can have two points depending on the direction traveled: counter-clockwise or clockwise. The programs presented today will determine both points.


Points that lie on the circle have the same radius. Determine the required radius:

r = √(x^2 + y^2)


And since the circle is centered at (0, 0), we can determine the angle by:

θ = arctan(y/x) = arg(x + yi)


We will assume all angles are in radians.


The arc length can be used to determine the angle traveled. Let’s call this angle z:

s = r × z

z = s / r


The new points can be determined by:


x’ = r × cos(θ + z), y’ = r × sin(θ + z)


x’’ = r × cos(θ - z), y’’ = r × sin(θ - z)


Casio fx-CG 50 Basic: PTSONCIRC


Code:


ClrText

Blue “POINTS ON”

Blue “THE CIRCLE”

Blue “CENTER (0,0)”

Red “RADIANS”

Rad

“INITIAL X”? → X

“INITIAL Y”? → Y

“ARC LENGTH”? → S

Abs (X+Yi) → R

Arg (X+Yi) → θ

S ÷ R → Z

R × cos(θ + Z) → A

R × sin(θ + Z) → B

R × cos(θ - Z) → C

R × cos(θ - Z) → D

ClrText

Green Locate 1,3,”POINT 1”

Black Locate 1,4,A

Blue Locate 11,4,”,”

Black Locate 12,4,B

Green Locate 1,5,”POINT 2”

Black Locate 1,6,C

Blue Locate 11,6,”,”

Black Locate 12,6,D


For monochrome models, leave out the color commands (Blue, Red, Black, Green)


Casio fx-CG 50 Python: ptsoncirc.py


Code:


from math import *

print(“Points on\nthe circle.”)

print(“Center is at (0,0)”)

x=float(input(“initial x? “))

y=float(input(“initial y? “))

s=float(input(“arc length? “))

r=sqrt(x**2+y**2)

t=atan(x,y)

z=s/r

b,a=r*cos(t+z),r*sin(t+z)

d,c=r*cos(t-z),r*sin(t-z)

print(“Point 1”)

print(str(a),”,\n”,str(b))

print(“Point 2”)

print(str(c),”,\n”,str(d))


Examples


X: 5, Y: 6, S: 1.5

Point 1: (3.76280901, 6.84406811)

Point 2: (6.05333094, 4.93529983)


X: 4: Y: 5, S: 1

Point 1: (3.173620164, 5.561306956)

Point 2: (4.729016994, 4.316989492)



Python Pointers


Storing to Multiple Variables in One Line


We can store a value to multiple variables in one line. For example,


a = b = 7

Stores the value 7 to both the variables a and b.


We can store multiple values to multiple values to multiple variables in one line. For example:


a, b = 7, 8

Stores 8 to the variable b and 7 to the variable a. The expression works from the inside-out.


We could also have both uppercase and lowercase letters as different variables, such as A and a. I choose not to because I want to avoid confusion.



New Line Escape Character: \n


In a string, we can add \n (backslash, n) to create a new line.



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.


Sunday, April 21, 2024

Casio fx-CG50 and Swiss Micros DM32: HP 16C’s Bit Summation

 Casio fx-CG50 and Swiss Micros DM32: HP 16C’s Bit Summation



The HP 16C’s #B Function


The #B function is the HP 16C’s number of bits function and sums the bits that are “turned on”. To find #B, if needed, convert the number to its binary form (base 2). #B are the number of ones. Here, I am assuming the binary integers are unsigned.


For example: Calculate #B(49). Assuming 49 is in decimal base.


49_10 = 110001_2


Then #B(49) = 3



Casio fx-CG 50 Program: BITS


I thought the fx-CG 50 had functions to convert integers and logical functions, but I did not have find them. If anyone knows whether the fx-CG 50 has base conversions, please let me know. I know that earlier Casio graphing calculators had base conversions.


The binary integer form is stored in B, as long as the decimal integer is less than 2048. (2^11).


Size: 168 bytes


“DEC→BIN”

“D”? → N

N → M

0 → C

0 → B

Int (log N ÷ log 2) → L

For L → J To 0 Step -1

If M ≥ 2^J

Then

C + 1 → C

M – 2^J → M

B × 10 + 1 → B

Else

B × 10 → B

IfEnd

Next

ClrText

If N < 2049

Then

“BIN=”

B ◢

IfEnd

“#B=”

C


The hashtag character (#) is called from the CHAR menu.



Swiss Micros DM32 Program: BITS


Two labels are used:

LBL B: 68 bytes

LBL T: 92 bytes


The main program is LBL B. This should fit on the classic HP 32S/32SII calculators.


B01 LBL B

B02 CF 0

B03 SF 10

B04 “DEC NUMB”

B05 PSE

B06 INPUT N

B07 STO M

B08 Clx

B09 STO C

B10 RCL N

B11 LOG

B12 2

B13 LOG

B14 ÷

B15 IP

B16 1

B17 +

B18 STO L


T01 LBL T

T02 RCL M

T03 2

T04 RCL L

T05 1

T06 -

T07 y^x

T08 -

T09 x≥0?

T10 SF 0

T11 FS? 0

T12 LASTx

T13 FS? 0

T14 STO- M

T15 FS? 0

T16 1

T17 FS? 0

T18 STO+ C

T19 CF 0

T20 DSE L

T21 GTO T

T22 RCL N

T23 BIN

T24 STOP

T25 “BITS=”

T26 PSE

T27 CF 10

T28 DEC

T29 VIEW C

T30 GTO B


Examples


Decimal: 35, Binary: 100011, #B(35) = 3

Decimal: 36, Binary: 100100, #B(36) = 2

Decimal: 37, Binary: 100101, #B(37) = 3


Decimal: 50, Binary: 110010, #B(50) = 3

Decimal: 51, Binary: 110011, #B(51) = 4

Decimal: 52, Binary: 110100, #B(52) = 3



Sources


Hewlett-Packard. HP-16C Computer Scientists Owner’s Handbook. Hewlett-Packard Company. 1982. pg. 52



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.

Circular Sector: Finding the Radius and Angle

  Circular Sector: Finding the Radius and Angle Here is the problem: We are given the area of the circular segment, A, and th...