Post Reply 
Summation based benchmark for calculators
04-05-2023, 08:01 PM
Post: #238
RE: Summation based benchmark for calculators
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
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Summation based benchmark for calculators - Guenter Schink - 04-05-2023 08:01 PM



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