Post Reply 
Summation based benchmark for calculators
09-06-2018, 10:12 PM (This post was last modified: 09-06-2018 10:13 PM by Guenter Schink.)
Post: #138
RE: Summation based benchmark for calculators
(09-06-2018 09:46 PM)Dave Britten Wrote:  
(09-06-2018 09:30 PM)Guenter Schink Wrote:  a different result for NUMWORKS (Python script)

Someone posted that 100000 iterations would take 84sec. My script does it within 68sec. Perhaps I made a mistake? I'm not at all experienced with Python.

So here is the short script
Code:

from math import *
x=0
for i in range(1,100001):
 x=x+pow(exp(sin(atan(i))),1/3)
print(x)

Result is 139560.97614110521

Günter

As was pointed out to me over in this thread, you can significantly speed up Micro Python code by doing the work inside a function.

This version runs in about 57 seconds on my Casio fx-CG50, producing 139560.9761410521:

Code:
from math import *
def RunTest():
  x=0
  for i in range(1,100001):
    x=x+pow(exp(sin(atan(i))),1/3)
  print(x)

RunTest()

Thanks Dave,

I applied the changes as above, making it a function. The difference however is marginal, 65sec instead of 68. Seems to depend on the implementation of Python. But it's an improvement still.

Regards, Günter

edit: typo
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 - 09-06-2018 10:12 PM



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