Fellows,
At first, sorry for my bad English - I'm Brazilian, so a Portuguese native speaker.
I have a few calculators and sometimes I like to make some benchmark tests with them. Maybe the "Calculator Olympic Games", if you wish.
I use to figure tests that everyone can play.
But, this time, I tried something different and excluded the non-programable calculators.
My intentions were to analyze the native programming language and also a similar algorithm to them, in order to compare their performance (maybe it is interesting to post the results and the codes in another post).
Well, we all know that the Classpad does not have a native good programming environment when you have performance in mind (even more when you are dealing with numerical analys with a lot of loops). In this way, myself and all the other calculators agreed that we will allow CP330 to use CPLua in substitution of natural Casio Basic.
The benchmark used is to perform Simpson Rule as presented in this link for the Ti-81 (https://www.ticalc.o...math/simpson.81) PS: on line 5, the correct code is a capital i instead of one. The corrected instruction is :(B - A) / N -> I
The code was minor adjusted according the possible commands on each calculator.
So, they all have to perform the following definite integral:
e^(x^3), from 0 to 6, with n=1000
It was based on the test presented here: https://www.youtube....h?v=DHRsvSTGiBc
The CPLua code used is:
--start
function y(x)
return math.exp(x^3)
end
n = 1000
a = 0 + 0.
b = 6 + 0.
i = (b-a)/n
x = a + 0.
s = 0.0
while ( x < b ) do
s = s+y(x)
x = x+i
s = 4*y(x)+s
x = x+i
s = s+y(x)
end
s = s*i/3
print(s)
Ok. All the calculators performed well and provided the same answer (obviously, with their respective performance time).
But CPLua in Classpad did not.
CPLua ignores when x = 6, when it should stop. It iterates one more time, as if the instruction were ( x <= b ).
I tried everything that I figured that it could be and did not find anything. I tried CPLua 0.8 and 0.10a.
So, I changed the code, reduced the d to 10 and requested an x print before the while end. Just to investigate, the code became:
n = 10
a = 0 + 0.
b = 6 + 0.
i = (b-a)/n
x = a + 0.
s = 0.0
while ( x < b ) do
s = s+y(x)
x = x+i
s = 4*y(x)+s
x = x+i
s = s+y(x)
print(x)
end
s = s*i/3
print(s)
The output is:
1.2
2.4
3.6
4.8
6
7.2
2.51522462964201e+161
Done.
The 7.2 there is totaly wrong. It is not suposed to be there.
If I change b=5, so it works. If I change b to 6.000001 it works
But if I change b=6.00001 it does not work!!!!
Does anybody has a clue about what is going on?
Thanks a lot!!!!
Edited by MrMagoo, 15 April 2021 - 10:29 PM.