HP Forums

Full Version: Summation based benchmark for calculators
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13
I think we have new champion -- by quite a margin

Prime G2 Beta 2.1.14549 using Python
Code:
#PYTHON name
from math import *
import sys
import hpprime
t=hpprime.eval("time")
c=int(sys.argv[0])
print()
print("Exponent = ",c)
print("Iterations = ", 10**c)
a=0
for i in range(1, 10**c+1):
    a=a+pow((e**(sin(atan(i)))),1/3) 
print("Time (sec) = ",round(hpprime.eval("time")-t,4))
print("Sum = ",a)
#end
Export sums(c)
Begin
  PYTHON(name, c);
End;

From the Home screen invoke this Python program with sums(?)

where "?" question mark has to be replaced by the exponent which denotes the magnitude
  • 3 for 1000
  • 4 for 10 000
  • 5 for 100 000
  • 6 for 1 000 000

Output will be the exponent, the resulting number, the time and the sum. E.g.
3
1000
0.036 sec
1395.3462877433426


Code:
Results:
3       1 000  0.036 sec     1395.3462877433426
4      10 000  0.159 sec    13955.857904429155
5     100 000  1.425 sec   139560.9761410521
6   1 000 000 14.046 sec  1395612.158725383

I think that's quite impressive specifically when compared with the values for native PPL.

Günter

Edit: put the timing into the Python code rather than using TEVAL
Something new to me, maybe a lack of Prime knowledge.
My Prime is configured in RPN (for stack Home computations).

I tried the sum "benchmark" proposed here, then Pick (copy) the first formula to modify it in the command line, I want to run a bigger one, from a 1000 to 10000 sum.
I only added a zero behind "1000", the Editor refuses to validate the formula. Why ?

[Image: wgZJbrL] https://ibb.co/wgZJbrL
[Image: VD2Wzp6] https://ibb.co/VD2Wzp6
[Image: WfpDSGv] https://ibb.co/WfpDSGv
Finally updated up to post #221 (yay after years! Well priorities...)

It took more than 2 hours, so it wasn't that trivial.

Updated also here: http://www.wiki4hp.com/doku.php?id=bench...g_exp_root
and here: https://osdn.net/users/pier4r/pf/various...chmark.txt

I am not so sure about some results regarding 500k with the prime G2. Now you all need to add more entries so that I have to catch up again Big Grin
(08-05-2021 04:06 PM)pier4r Wrote: [ -> ]Finally updated up to post #221 (yay after years! Well priorities...)

It took more than 2 hours, so it wasn't that trivial.

Updated also here: http://www.wiki4hp.com/doku.php?id=bench...g_exp_root
and here: https://osdn.net/users/pier4r/pf/various...chmark.txt

I am not so sure about some results regarding 500k with the prime G2. Now you all need to add more entries so that I have to catch up again Big Grin

The HP Expander (not XP Expander) is a calculator from HP, not a mobile device. It never saw the light of the markets. I've got a prototype at one of the HHCCs.

Günter
(08-08-2021 10:59 AM)Guenter Schink Wrote: [ -> ]The HP Expander (not XP Expander) is a calculator from HP, not a mobile device. But I think it never saw the light of the markets. I've got a prototype at one of the HHCCs.

It actually was "HP Xpander".
Have a couple, from different development stages.
(08-08-2021 11:03 AM)Massimo Gnerucci Wrote: [ -> ]
(08-08-2021 10:59 AM)Guenter Schink Wrote: [ -> ]The HP Expander (not XP Expander) is a calculator from HP, not a mobile device. But I think it never saw the light of the markets. I've got a prototype at one of the HHCCs.

It actually was "HP Xpander".
Have a couple, from different development stages.

Thanks for the correction. I could have had a closer look either to the device or the Wiki article Smile

Günter
ThetaCalc, an RPN calculator app running on iOS which can be programmed in JavaScript, produced the following result for n = 1000000 on an iPhone 12:

HP museum benchmark (n = 1000000)
Sum = 1395612.1587253837
Time = 0.189 seconds

I don't know, however, whether the app fits into one of the given categories.

Here is the program:

Code:
function benchmark(n) {
  let s = 0;
  for (let i = 1; i <= n; i++) {
    s += Math.pow(
      Math.exp(
        Math.sin(
          Math.atan(i))), 1/3);
  }
  return s;
}

const n = 1000000;
startTimer();
let s = benchmark(n);
stopTimer();
println(`HP museum benchmark (n = ${n})`);
println(`Sum = ${s}`);
printlnElapsed();
I recently received a Sharp PC-1201 and was currious how this nice little machine would perform, here are the results :

N=10 ~25s result 13,318529402
N=100 ~285s result 138,90159786
N=1000 ~2844s result 1394,95067416
(04-22-2021 06:33 PM)Guenter Schink Wrote: [ -> ]I think we have new champion -- by quite a margin

Prime G2 Beta 2.1.14549 using Python

When I copy and paste that code into the emulator, I get

Code:
Traceback (most recent call last):  File "<stdin>", line 5, in <module>
ValueError: invalid syntax for integer with base 10: '10\xef\xb9\x90000'
Traceback (most recent call last):
  File "<stdin>", line 5, in <module>
ValueError: invalid syntax for integer with base 
10: '1\xef\xb9\x90000'
Traceback (most recent call last):
  File "<stdin>", line 5, in <module>
ValueError: invalid syntax for integer with base 
10: '1\xef\xb9\x90000'
Traceback (most recent call last):
  File "<stdin>", line 5, in <module>
ValueError: invalid syntax for integer with base 
10: '1\xef\xb9\x90000'
(08-17-2021 11:23 PM)toml_12953 Wrote: [ -> ]
(04-22-2021 06:33 PM)Guenter Schink Wrote: [ -> ]I think we have new champion -- by quite a margin

Prime G2 Beta 2.1.14549 using Python

When I copy and paste that code into the emulator, I get

Code:
Traceback (most recent call last):  File "<stdin>", line 5, in <module>
ValueError: invalid syntax for integer with base 10: '10\xef\xb9\x90000'
Traceback (most recent call last):
  File "<stdin>", line 5, in <module>
ValueError: invalid syntax for integer with base 
10: '1\xef\xb9\x90000'
Traceback (most recent call last):
  File "<stdin>", line 5, in <module>
ValueError: invalid syntax for integer with base 
10: '1\xef\xb9\x90000'
Traceback (most recent call last):
  File "<stdin>", line 5, in <module>
ValueError: invalid syntax for integer with base 
10: '1\xef\xb9\x90000'

I just also copied it to the virtual Prime. works flawlessly. (?)

The error actually points to line 6 "c=int(sys.argv[0])" Can't assume what's going wrong.

Günter
(08-18-2021 03:09 PM)Guenter Schink Wrote: [ -> ]
(08-17-2021 11:23 PM)toml_12953 Wrote: [ -> ]When I copy and paste that code into the emulator, I get

Code:
Traceback (most recent call last):  File "<stdin>", line 5, in <module>
ValueError: invalid syntax for integer with base 10: '10\xef\xb9\x90000'
Traceback (most recent call last):
  File "<stdin>", line 5, in <module>
ValueError: invalid syntax for integer with base 
10: '1\xef\xb9\x90000'
Traceback (most recent call last):
  File "<stdin>", line 5, in <module>
ValueError: invalid syntax for integer with base 
10: '1\xef\xb9\x90000'
Traceback (most recent call last):
  File "<stdin>", line 5, in <module>
ValueError: invalid syntax for integer with base 
10: '1\xef\xb9\x90000'

I just also copied it to the virtual Prime. works flawlessly. (?)

The error actually points to line 6 "c=int(sys.argv[0])" Can't assume what's going wrong.

Günter

I had digit grouping set to 123,456.789. When I change it to 123456.789, I don't get an error but I get a lot of zeroes on the screen and what may be an infinite loop.
(08-18-2021 04:01 PM)toml_12953 Wrote: [ -> ]I had digit grouping set to 123,456.789. When I change it to 123456.789, I don't get an error but I get a lot of zeroes on the screen and what may be an infinite loop.

o.K. I think I found the problem. It wasn't clearly explained. You have to enter the exponent rather then the number. E.g. enter 3 to get 1000 iterations. Have a look at the code and now it should become obvious.

I chose this because "sys.argv[0]" doesn't seem to work reliably with numbers greater 999. Consequently if it works somehow, the first output is a digit with as many zeros as requested, and that output takes a while.

Günter

edit: I just realized that I can't run the program from the command line I had to go to the program catalog <SHIFT> <1> and run it fro there
(08-18-2021 06:56 PM)Guenter Schink Wrote: [ -> ]
(08-18-2021 04:01 PM)toml_12953 Wrote: [ -> ]I had digit grouping set to 123,456.789. When I change it to 123456.789, I don't get an error but I get a lot of zeroes on the screen and what may be an infinite loop.

o.K. I think I found the problem. It wasn't clearly explained. You have to enter the exponent rather then the number. E.g. enter 3 to get 1000 iterations. Have a look at the code and now it should become obvious.

I chose this because "sys.argv[0]" doesn't seem to work reliably with numbers greater 999. Consequently if it works somehow, the first output is a digit with as many zeros as requested, and that output takes a while.

Günter

edit: I just realized that I can't run the program from the command line I had to go to the program catalog <SHIFT> <1> and run it fro there

Oof! Es tuit mir leid! Yes, an exponent of 1000 would take a long time! Thank you for replying.
Updated up to post #233
Also the HP Xpander name and category fixed. Hopefully I didn't miss anything.
I have bought newer casio model, fx-570CW several months ago and reminded this thread. Test results below:

max = 10000
~ 581s - casio fx-570CW, 13955.8579 (sum function)
max = 1000
~ 59s - casio fx-570CW, 1395.346288 (sum function)
max = 100
~ 7s - casio fx-570CW, 139.297187 (sum function)
max = 10
~ 1s - casio fx-570CW, 13.71183502 (sum function)

fx-570CW is significantly faster than fx-570EX. Let's compare them.

1s / 2s (max = 10)
7s / 12s (max = 100)
59s / 109s (max = 1000)
581s / 1073s (max = 10000)
Tested with HP-200LX too.

max = 10000
~ 257s - HP-200LX turbo c 2.01, 13955.857904
max = 1000
~ 27s - HP-200LX turbo c 2.01, 1395.346288
max = 100
~ 4s - HP-200LX turbo c 2.01, 139.297187
max = 10
~ 2s - HP-200LX turbo c 2.01, 13.711835

Code:
#include <math.h>
main()
{
double i,sum;
i=1;
sum=0;
for(i=1;i<=10000;i++)
{
sum+=pow(exp(sin(atan(i))),1/3.);
}
printf("%lf\n",sum);
}
Σ( ³√[e^(sin(tan^-1(x)))], x=1 to 1000)

Casio fx-991CW:
Result: 1395.346288
Time: approx. 57 seconds

TI-30X Pro MathPrint (Europe):
Result: 1395.346288
Time: approx. 1 minute, 44 seconds
Once again Python on PRIME

This time using "Generator"
Code:
from math import *
from hpprime import *
Number=input("Enter number:")
Number=int(Number)
print(" {:,d}".format(Number))
t=eval('time')
Sum = sum(pow(e**(sin(atan(i))),1/3) for i in range(1,Number+1)) 
t=eval('time')-t
print("Sum = {:}".format(Sum),"\nTime = {:}".format(round(t,8)))

significantly faster than the previous published Python code (Top of this page). The calculation is done in this one-liner:
>>Sum = sum(pow(e**(sin(atan(i))),1/3) for i in range(1,Number+1)) <<

Code:
10,000      ->   0.101 sec     13955.8579042916
100,000     ->   1.038 sec    139560.9761411052
1,000,000   ->  10.381 sec   1395612.15872538
10,000,000  -> 103.724 sec  13956123.9815476

Günter
HP Prime G2 V.14603 Python
==========================
100.000 -> 0.84s
1.000.000 -> 8.4s
10.000.000 -> 84.1s

optimized post #238:

x=1/3
Sum = sum(exp(sin(atan(i)))**x for i in range(1,Number+1))
(01-28-2023 09:22 AM)BINUBALL Wrote: [ -> ]Tested with HP-200LX too.

Couldn't resist trying this on a modern PC...

Code:

#include <math.h>
#include <stdio.h>

void main()
{
  double i,sum;
  i=1;
  sum=0;
  for(i=1;i<=10000;i++)
  {
  sum+=pow(exp(sin(atan(i))),1/3.);
  }
  printf("%lf\n",sum);
}

$ gcc sum.c -o sum -lm
$ time ./sum 
13955.857904

real    0m0.005s
user    0m0.005s
sys    0m0.001s
$
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13
Reference URL's