Showing posts with label Casio fx-9750 GIII. Show all posts
Showing posts with label Casio fx-9750 GIII. Show all posts

Saturday, February 4, 2023

Casio fx-9750GIII: Effects of Rounding

 Casio fx-9750GIII:  Effects of Rounding



How Accurate?


The program ROUNDS compare true results against the true results in one of five calculations:


1.  A × B × C

2.  A × B ÷ C

3.  √(A^2 + B^2 - C^2)

4.  A ÷ B ÷ C

5.  (A + 1 ÷ B)^C


The rounded result is calculated after rounding after each step.


For example:  A × B × C


True result:  

T = A × B × C


Rounded Result:

R = round(A × B)

R = round(R × C)


The absolute error percentage is calculated.   



Casio fx-9750GIII Program:  ROUNDS


"2022-11-23 EWS"

"EFFECTS OF ROUNDING"

"# OF PLACES"?→N

"A"?→A

"B"?→B

"C"?→C

Menu "SELECT OPERATION",

"A×B×C",A

"A×B÷C",B

"√(A^2 + B^2 - C^2)",C

"A÷B÷C",D

"(A+1÷B)^C",E

Lbl A

RndFix(A×B,N)→R

RndFix(R×C,N)→R

A×B×C→T

Goto 1

Lbl B

RndFix(A×B,N)→R

RndFix(R÷C,N)→R

A×B÷C→T

Goto 1

Lbl C

RndFix(A²+B²,N)→R

RndFix(√(R-C²),N)→R

√(A²+B²- C²)→T

Goto 1

Lbl D

RndFix(A÷B,N)→R

RndFix(R÷C,N)→R

A÷B÷C→T

Goto 1

Lbl E

RndFix(A+1÷B,N)→R

RndFix(R^C,N)→R

(A+1÷B)^C→T

Goto 1

Lbl 1

RndFix(100×Abs (R-T)÷T,5)→E

ClrText

Locate 1,3,"ROUNDED:"

Locate 9,3,R

Locate 1,4,"ACTUAL:"

Locate 9,4,T

Locate 1,5,"ERROR%:"

Locate 9,5



Example:


Let A = 13.946, B = 11.9765, C = π^3/4

Round to 2 decimal places (N = 2)


1.  A × B × C

Rounded:  1294.67

Actual:  1294.700174

Error:  2.33*10^-3 %


2.  A × B ÷ C

Rounded: 21.55

Actual:  21.54715585

Error:  0.0132%


3.  √(A^2 + B^2 - C^2)

Rounded: 16.67

Actual:  16.66855254

Error:  8.68*10^-3 %


4.  A ÷ B ÷ C

Rounded: 0.15

Actual: 0.1502208155

Error: 0.14699%


5.  (A + 1 ÷ B)^C

Rounded: 778927217

Actual:  778710708.2

Error:  0.0278%



Enjoy,  


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, October 10, 2021

n = a^m + b

 n = a^m + b



Calculators:  Swiss Micros DM41X, HP-32S/32SII, Casio fx-9750 GIII


n = a^2 + b


The following program breaks down a positive integer n into n = a^2 + b, where a is √n rounded to the nearest integer in attempt to minimize abs(b).    


Examples:

  

800 = 28^2 + 16

662 = 26^2 - 14

525 = 23^2 - 4


This technique is useful, especially with the HP 32S and HP 32SII.  Normally, real numbers take up 9.5 bytes of memory on the HP 32S series.  Integers 0 - 100 only consume 1.5 bytes of memory for the original HP 32S and the range is extended to 0 - 254 for the HP 32SII.  


When the program terminates, b is on the X stack while a is on the Y stack.  


HP 41C/Swiss Micros DM41X Program:  SQPLUS


01 LBL^T SQPLUS

02 FIX 0

03 ENTER 

04 SQRT

05 RND

06 X^2

07 -

08 LASTX

09 SQRT

10 X<>Y

11 FIX 4

12 RTN


HP 32S and HP 32SII Program: SQPLUS


S01 LBL S

S02 FIX 0

S03 ENTER

S04 SQRT

S05 RND

S06 x^2

S07 -

S08 LASTx

S09 SQRT

S10 x<>y

S11 ALL

S12 RTN


Example:  684


Result:

Y:  26

X:  8 

(26^2 + 8 = 684)


Additional Powers


Now let's extend the problem to include higher powers.  


n = a^m + b


We can estimate a by:


n ≈ a^m

ln n ≈ ln(a^m)

ln n ≈ m * ln a

ln n / m ≈ ln a


a ≈ e^(ln n / m)


Round a to the nearest integer.  Use this a to find b.


n = a^m + b


b = n - a^m


The script brkpower.py (225 bytes) calculates a and b for powers m = 2 to 6.  This script was created on the Casio fx-9750GIII.


Casio fx-9750GIII Micro python Script:  brkpower.py


# 2021-07-17 ews

from math import *

print("n = a**m + b")

n=float(input("n? "))

m=2.0

while m<7:

  a=int(exp(log(n)/m)+.5)

  b=n-a**m

  s="{:.0f} = {:.0f}**{:.0f} + {:.of}".format(n,a,m,b)

  print(s)

  m+=1


Example:  n = 860


Results:

860 = 29**2 + 19         (860 = 29^2 + 19) 

860 = 10**3 + -140     (860 = 10^3 - 140, and so on)

860 = 5**4 + 235

860 = 4**5 + -164

860 = 3**6 + 131


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. 


Sharp EL-5200/EL-9000 AER II Program Collection – September 2026

Sharp EL-5200/EL-9000 AER II Program Collection – September 2026 For my review on the Sharp EL-5200 (also known as the Sharp EL-9000)...