Post Reply 
Calculator benchmark
10-02-2021, 10:08 PM (This post was last modified: 10-23-2021 01:58 AM by robve.)
Post: #51
RE: Calculator benchmark
(09-25-2021 01:25 AM)robve Wrote:  Sharp EL-5100(S): 93 keystrokes

I'll buy the first person who finds this keystroke sequence a beer. If no one found it in 7 days, then I'll report the solution next week anyway.

Just 92 keystrokes is also possible. So I have to restate the challenge slightly: the first person who finds a keystroke sequence of 93 or less gets a beer.

Alas, no submitted solutions.

A solution with 91 keystrokes saves the value B/2 in M in the AER setup. Instead of typing B/2 in the execution, the RM key suffices to obtain B/2:

AER-switch                   1 AER mode
[2ndF][f()=]AB=              5 enter formula LHS
/2[=>M]                      3 save B/2 in M
A[x^2]+A-[LN]B,[LN]B[x^2]   11 enter formula RHS


Setup: 20 keystrokes.

Code:
COMP-switch     1 comp mode
COMP            1 activate AER formula
3.12[COMP]      5
2.56[COMP]      5 displays X
[COMP]          1 displays Y
[COMP]          1 A is unchanged
RM[COMP]        2 displays X
[COMP]          1 displays Y
[COMP]          1 A is unchanged
RM[COMP]        2 displays X
[COMP]          1 displays Y
2A[COMP]        3
[COMP]          1 B is unchanged displays X
[COMP]          1 displays Y
2A[COMP]        3
[COMP]          1 B unchanged displays X
[COMP]          1 displays Y
2A[COMP]        3
RM[COMP]        2 displays X
[COMP]          1 displays Y
[COMP]          1 A is unchanged
RM[COMP]        2 displays X
[COMP]          1 displays Y
[COMP]          1 A is unchanged
RM[COMP]        2 displays X
[COMP]          1 displays Y
18.59[COMP]     6
[COMP]          1 B is unchanged, displays X
[COMP]          1 displays Y
17.63[COMP]     6
[COMP]          1 B is unchanged, displays X
[COMP]          1 displays Y
[COMP]          1 A is unchanged
2B[COMP]        3 displays X
[COMP]          1 displays Y
[COMP]          1 A is unchanged
2B[COMP]        3 displays X
[COMP]          1 displays Y

Execution: 71 keystrokes.

Sharp EL-5100(S): 91 keystrokes

The EL-5100(S) was the first calculator to introduce algebraic notation. The expression syntax is internally still handled by the traditional operand and operator stacks combined with an X register to hold the last result. This means that /2[=>M] is legal, because /2 takes the last value stored in register X then divides it by 2. In this case X holds the last value entered. Because an internal register X is used to hold the last value and the syntax of infix and postfix operators allows omitting the first operand, a slew of tricks and hacks is possible to reduce the size of AER formulas and, consequently, reduce keystrokes.

There appears to be no requirement to use a comma in an AER formula to chain multiple expressions, despite what the SHARP manual says. The comma produces a value, which is not always desirable. Omitting the comma in a formula simply continues executing the next expression in the AER formula. This is what you would normally expect a simple calculator to do. Perhaps SHARP didn't want to reveal that the implementation of algebraic expression evaluation is simplistic in comparison to programming languages.

Below is a list of EL-5100(S) tricks and hacks. Most aren't documented by SHARP or posted elsewhere:
Code:
After STO ⇒M M+ the last value is still usable as an operand for the next
operator.  For example:
    1;A STO B +1 STO C                  saves A to B and B+1 to C

When using an infix or postfix operator (+ - × ÷ Yˣ ˣ√ ℙ ℂ STO →POL →REC ² ⁻¹ !
⇒M M+ M- →DEG →DMS) at the start of an expression, this operator uses the last
value calculated as its first operand.  For example:
    1;f(A)=+1 STO A ×2 STO B            takes A then saves A+1 to A and 2A to B

In fact, this method also works without a function, but a value must be
calculated first and displayed before pressing COMP.  For example:
    1;STO A

Open parenthesis '(' can be omitted when using ')' or '=' in an expression.  A
'=' closes all parentheses of an expression.  For example:
    1;f(A)=2A-1)²                       computes (2A-1)²
    1;f(A)=1+(2×(A-3=²                  computes (1+(2×(A-3)))²

All parentheses before STO ⇒M M+ , ◣ are automatically closed.  For example:
    1;f(A)=2×(A-1 STO B                 takes A then saves 2×(A-1) to B

A comma ',' can be omitted (display value) when the next expression starts with
an operand.  For example:
    1;A+1 STO A 2B STO B                saves A+1 to A and 2B to B

A f()= function can be defined within an AER entry to start of the next
expression.  For example:
    1;f(A)=²,f(A)=√A                    takes A, displays A², then takes A
                                        again, displays √A

A f()= function does not require the closing ')', a '=' suffices.  For example:
    1;f(AB=√(A²+B²                      computes hypotenuse of A,B

A value specified with COMP for f(A)= can also use some of the same tricks.
For example:
    1;2 STO B f(A)=
    COMP
    1;A=?
    enter ×2
    1;ANS 1= 4.

Implied multiplication when applied to parentheses like A(1+2) is not possible,
except when applying after the closing ')' for memory or π: For example:
    1;1+B)A                             computes A×(1+B)

Always use (-) for unary minus, otherwise - (minus) takes X as an operand.

Powers Yˣ do not accept negative Y, use ² and repeated multiplications or use
√A²YˣB to compute |A|YˣB.

To compute the absolute value |A|, use √A².

To compute trunc(A) integer part of A, use A+ᴱ10-ᴱ10

To compute round(A) for positive A, use A+.5+ᴱ10-ᴱ10

To compute frac(A), use A-(A+ᴱ10-ᴱ10)

In COMP mode, when the COMP key is mixed with other key presses (except memory
operations), COMP always reverts to 1;. Therefore, put repetitive calculations
preferably in 1;.

Some examples to demonstrate these hacks.

Simpson's rule of integration:
Code:
1;f(ABC)=0 STO I 1 STO J 2 STO H A STO E B-A)÷C STO D◣
2;EEE+2E²-E+2 STO F ×J+I STO I E+D STO E 6-H STO H STO J C-1 STO C◣
3;I-F)D÷3

where:

1; specifies integration range A to B in C parts, where C must be even
2; evaluates one step of the function
3; computes the final result

The function is specified in 2; up to STO F, with E as x.

Press 1; or COMP to specify A, B and C, then press 2; and repeat COMP until the
counter C value displayed is -1. Press 3; to obtain the integral value. To
restart, press 1;. The values of A and B are retained, but C must be specified.

Example:
Press 1; then enter the value 1 for A, 5 for B and 8 for C:
1;A=1 COMP
1;B=5 COMP
1;C=8 COMP
1;ANS 1= 0.5
Press 2; then press COMP until -1 is displayed:
2;ANS 1= 7.
COMP
...
2;ANS 1=-1.
Press 3;
3;ANS 1= 234.6666667

erf() approximation with maximum relative error 0.00013 (note that (-) means unary minus):
Code:
1;f(A)=² STO B √B÷A×√(1-e((-)B×(4÷π+.147B)÷(1+.147B

Note: erf(0)=0 but AER produces an error because √B÷A is used to determine the
sign of A.

GCD(A,B):
Code:
1;A-(A÷B+ᴱ10-ᴱ10)B STO C B STO A C STO B

Press COMP until zero is displayed (or when an error occurred), then A holds
the GCD result. Negative A or B may produce a negative GCD in A. In that case
ignore the sign of A or correct it with √A².

Example:
5040 STO A
411 STO B
COMP
1;ANS 1= 108.
COMP
1;ANS 1= 87.
COMP
1;ANS 1= 21.
COMP
1;ANS 1= 3.
COMP
1;ANS 1= 0.
RCL A
3.

Rational approximation by continued fractions:
Code:
1;E+ᴱ10-ᴱ10 STO D E-D STO E BD+J STO F B STO J F STO B CD+I STO F C STO I F STO C B÷C STO D E⁻¹ STO E A-D◣
2;f(A)=1 STO B STO I 0 STO C STO J A STO E

Press 2; to enter a value
Press 1; to compute the first approximation D=B/C~A, displays the difference A-D
Press COMP to compute the next approximation D=B/C~A, displays the difference A-D
Repeat COMP until the difference (error) is sufficiently small or zero

Result: B is the numerator, C the denominator and D=B/C~A

Example:
Press 2; then enter π
2;A=π
COMP
Press 1;
1;ANS 1= 0.141592654
COMP
1;ANS 1=-0.001264489
RCL B
22.
RCL C
7.
COMP
1;ANS 1= 0.00008322
RCL B
333.
RCL C
106.
COMP
1;ANS 1= 0.00000267
RCL B
355.
RCL C
113.

This gives 355/133 as an approximation of π with 5 digits precision.

Complex arithmetic:
Code:
1;f(BJ)=A+B STO A,I+J STO I◣
2;f(BJ)=A STO HAB-IJ STO A,BI+HJ STO I◣
3;f(BJ)=²+B² STO GA STO HAB+IJ)/G STO A,BI-HJ)/G STO I

where

1; adds B+Ji to A+Ii
2; multiplies A+Ii by B+Ji
3; divides A+Ii by B+Ji

Example:
12.5 STO A              re of first argument
(-)7 STO I              im of first argument
2ndF-G
2;B=3                   re of second argument
2;J=2                   im of second argument
2;ANS 1= 51.5           re of the product
2;ANS 2= 4.             im of the product

t-test:
Code:
1;f(A)=F÷E-A)÷√((G-E×(F÷E)²)÷(E²-E

STAT mode to enter the data.

COMP mode then COMP to compute the t test given A.

Example:
STAT mode
72 DATA
67 DATA
69 DATA
85 DATA
91 DATA
68 DATA
77 DATA
74 DATA
70 DATA
82 DATA
COMP mode
COMP
1;ANS 1= 2.147

Sterling's Gamma approximation:
Code:
1;f(A)=√2π×AYˣ(A-.5)×e(1÷12A-A

These fun concoctions are mine, except the last one, which is based on the Gamma function shown in http://rskey.org/el5100

Edit: after posting I noticed that the HP forum "machinery" replaced the E exponent symbol U+1D53C with a question mark. Is this a bug? I replaced the double stroke E with the ᴱ symbol. Ugly, but close enough. Also clarified the floor/round tricks, added the f(A= hack and added a complex arithmetic example.

Edit 2: further reduced to 91 keystrokes by replacing )= requiring two keystrokes [2ndF][f()=] with just one keystroke = as a shortcut.

- Rob

"I can count on my friends" -- HP 71B,Prime|Ti VOY200,Nspire CXII CAS|Casio fx-CG50...|Sharp PC-G850,E500,2500,1500,14xx,13xx,12xx...
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Calculator benchmark - jhallen - 08-08-2021, 05:42 AM
RE: Calculator benchmark HP-28S - C.Ret - 08-08-2021, 04:46 PM
RE: Calculator benchmark - C.Ret - 08-08-2021, 07:26 PM
RE: Calculator benchmark - jhallen - 08-08-2021, 08:05 PM
RE: Calculator benchmark - OlidaBel - 08-11-2021, 12:40 PM
RE: Calculator benchmark - C.Ret - 08-08-2021, 08:25 PM
RE: Calculator benchmark - robve - 08-11-2021, 08:15 PM
RE: Calculator benchmark - jhallen - 08-08-2021, 09:57 PM
RE: Calculator benchmark - C.Ret - 08-12-2021, 04:24 PM
RE: Calculator benchmark - robve - 08-12-2021, 09:13 PM
RE: Calculator benchmark - robve - 08-12-2021, 11:37 PM
RE: Calculator benchmark - Claudio L. - 08-09-2021, 08:14 PM
RE: Calculator benchmark - jhallen - 08-11-2021, 04:33 AM
RE: Calculator benchmark - Claudio L. - 08-11-2021, 05:14 PM
RE: Calculator benchmark - OlidaBel - 08-11-2021, 09:00 AM
RE: Calculator benchmark - jhallen - 08-11-2021, 01:16 PM
RE: Calculator benchmark - OlidaBel - 08-11-2021, 01:33 PM
RE: Calculator benchmark - Werner - 08-11-2021, 11:49 AM
RE: Calculator benchmark - jhallen - 08-11-2021, 01:11 PM
RE: Calculator benchmark - DavidM - 08-12-2021, 01:42 AM
RE: Calculator benchmark - robve - 08-13-2021, 02:16 PM
RE: Calculator benchmark - jhallen - 08-20-2021, 03:34 AM
RE: Calculator benchmark - robve - 08-20-2021, 02:49 PM
RE: Calculator benchmark - robve - 08-20-2021, 06:12 PM
RE: Calculator benchmark - jhallen - 08-20-2021, 08:26 PM
RE: Calculator benchmark - robve - 08-13-2021, 09:10 PM
RE: Calculator benchmark - C.Ret - 08-15-2021, 01:13 PM
RE: Calculator benchmark - robve - 08-15-2021, 02:31 PM
RE: Calculator benchmark - robve - 08-15-2021, 04:43 PM
RE: Calculator benchmark - robve - 08-15-2021, 06:30 PM
RE: Calculator benchmark - robve - 08-16-2021, 01:01 AM
RE: Calculator benchmark - EdS2 - 08-16-2021, 06:22 AM
RE: Calculator benchmark - C.Ret - 08-19-2021, 04:37 AM
RE: Calculator benchmark - C.Ret - 08-19-2021, 05:21 PM
RE: Calculator benchmark - Werner - 08-20-2021, 02:58 PM
RE: Calculator benchmark - C.Ret - 08-22-2021, 10:29 AM
RE: Calculator benchmark - jhallen - 08-17-2021, 03:56 AM
RE: Calculator benchmark - C.Ret - 08-18-2021, 08:20 PM
RE: Calculator benchmark - jhallen - 08-19-2021, 12:23 AM
RE: Calculator benchmark - jhallen - 08-22-2021, 06:42 PM
RE: Calculator benchmark - robve - 08-23-2021, 10:51 PM
RE: Calculator benchmark - robve - 09-22-2021, 06:14 PM
RE: Calculator benchmark - robve - 09-25-2021, 01:25 AM
RE: Calculator benchmark - robve - 10-02-2021 10:08 PM



User(s) browsing this thread: 1 Guest(s)