# HP Calculator Wiki

### Site Tools

benchmarks:four_op_and_accuracy

# Calc bench: Four operators (FO)

The idea
There are a lot of benchmarks for calculators and computers, but so far the popular ones are:

Nquees tests mainly memory and addition-subtraction operators. The savage one is more complex and math related, but the results are scattered everywhere (Feel free to gather them and do a wiki page about it! Oh, we have already done that) plus it accounts “only” the accuracy 2) so we don't have execution times. The summation test is really simple as well the find primes, even if the latter involves more operators. Moreover a test should be simple, else the userbase won't do it. (See the poor middle square method test )

So, why do we not do a simple benchmark involving the four operations (plus one, the square root) to check both the speed on simple operations and the accuracy? About accuracy, read below.

The pseudocode

input: given an n
----
sum = 0;
b = 0; c = 0;
for a:=1 to n do {
//to avoid optimizations by smarter compilers
//trick them with new variables
b:= a;
c:= a;
sum:= sum + squareRoot(b*c)/a; //it's a sum+1 from the simbolic point of view.
}
print sum

What do we check?
Both times of execution, for a given n, and accuracy (the result should be: n itself) in terms of relative error |result-n|/n. Some arguments on the Savage benchmark has shown that the accuracy measure is not so reliable, so we don't check that (anyway, just report the result).

How to report the results

A result is composed by the following list
- the device used plus the language used, eventual overclock, eventual custom firmware and so on.
- time elapsed for a given n in seconds (see below)
- the result printed
- the code used.

N options:
100
1000
10'000
for fast implementations
100'000
1'000'000

if the calculator is too slow, or limited, to compute a given n, then report "for n the computation
takes too much time". Conversely, if the calculator is too fast to compute a given n, then report
"for n the computation takes too little time, i skipped it"

## Speed section

### Physical calculators

#### n is 100

1. HP 50g userRPL
• 1.06 @75mhz
• Res: 5050
• code: 3)

#### n is 1'000

1. HP 50g userRPL
• 10.01 @75mhz
• Res: 500500
• same of entry with n=100

#### n is 10'000

1. HP 50g userRPL
• 102.093 @75mhz
• Res: 50005000
• same of entry with n=100

### Emulators on mobile/handheld devices smaller than 7'' (7'' included)

#### n is 100'000

2)
As if it is not important! Is a main topic on computation!
3)
<code> «
@n
0 @sum
\->
n
sum
<<
PUSH
-105 SF
  1 n
FOR a
a DUP * @a^2
\v/ @sqrt(a^2)
'sum' STO+
NEXT
sum
  POP
>>
» <code> 