HP Forums
CASIO Graph 90+E - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: Not HP Calculators (/forum-7.html)
+--- Forum: Not remotely HP Calculators (/forum-9.html)
+--- Thread: CASIO Graph 90+E (/thread-10701.html)

Pages: 1 2 3 4


RE: CASIO Graph 90+E - toml_12953 - 08-23-2018 05:28 PM

(08-23-2018 08:47 AM)m@x Wrote:  
(08-11-2018 10:44 PM)StephenG1CMZ Wrote:  BTW, authors say "morning has broken" at daybreak - astronomers think "morrning just worked normally" Smile

Morning has broken like the first morning
Blackbird has spoken like the first bird
Praise for the singing
Praise for the morning
Praise for them springing fresh from the world

Originally, the last line was "...fresh from the Word" meaning the word of God.


RE: CASIO Graph 90+E - severedgarden - 08-30-2018 02:39 PM

The update for the Casio Graph 90 +e and its out-of-France equivalent, the fx CG50 is here!
We can use MicroPython!

https://edu.casio.com/download_service/en/download/index.html

A day before than expected! I will try it tonight Smile


RE: CASIO Graph 90+E - rprosperi - 08-30-2018 03:53 PM

(08-30-2018 02:39 PM)severedgarden Wrote:  The update for the Casio Graph 90 +e and its out-of-France equivalent, the fx CG50 is here!
We can use MicroPython!

https://edu.casio.com/download_service/en/download/index.html

A day before than expected! I will try it tonight Smile

FYI - In USA, this link redirects to: http://edu.casio.com/index.php

It seems Casio is trying hard to limit distribution to certain locales....


RE: CASIO Graph 90+E - Dave Britten - 08-30-2018 03:54 PM

Whoa, awesome! I was under the impression Python was only coming to the Graph 90+E model. Glad I was wrong!

EDIT: It can run the standard 8x8 n-queens benchmark (http://www.hpmuseum.org/cgi-sys/cgiwrap/hpmuseum/articles.cgi?read=700) in a bit under one second. (I just did a quick port of the generic Pascal version on that page.)


RE: CASIO Graph 90+E - klesl - 08-30-2018 06:15 PM

I downloaded the update from site mentioned above
http://edu.casio.com/download/index.php
After downloading I updated my fx-CG50 bought in Germany and the item "Python" is included in the calc. I tried the simple program named octa from the UG and it is functional.


RE: CASIO Graph 90+E - StephenG1CMZ - 08-30-2018 09:51 PM

Can the Casio screen pixels be addressed from microPython (e.g. to draw Mandelbrot)?


RE: CASIO Graph 90+E - Dave Britten - 08-30-2018 09:57 PM

Not that I could find in the manual, unfortunately. It only has print and input for I/O. (Maybe file I/O too; I didn't look for that.)


RE: CASIO Graph 90+E - xerxes - 09-01-2018 10:40 AM

(08-30-2018 03:54 PM)Dave Britten Wrote:  EDIT: It can run the standard 8x8 n-queens benchmark (http://www.hpmuseum.org/cgi-sys/cgiwrap/hpmuseum/articles.cgi?read=700) in a bit under one second. (I just did a quick port of the generic Pascal version on that page.)

Would be nice to have your test result and the code in the list, if you are also interested.
If yes, can you please check the execution time with an outer loop of 100 iterations for a
more accurate result?

The CG20 needs 39.7 seconds with BASIC. Strangely using MAT is a bit faster than using a list.

Code:
 0->A~Z
 8->R
 {R,1}->Dim Mat A
 0
 Do
 Isz X
 R->Mat A[X,1]
 Do
 Isz S
 X->Y
 While Y>1
 Dsz Y
 Mat A[X,1]-Mat A[Y,1]->T
 If T=0 Or X-Y=Abs T
 Then 0->Y
 Mat A[X,1]-1->Mat A[X,1]
 While Mat A[X,1]=0
 Dsz X
 Mat A[X,1]-1->Mat A[X,1]
 WhileEnd
 IfEnd
 WhileEnd
 LpWhile Y<>1
 LpWhile X<>R
 S

I guess the CG50 should do it in around 20 seconds.


RE: CASIO Graph 90+E - Dave Britten - 09-03-2018 02:06 PM

(09-01-2018 10:40 AM)xerxes Wrote:  
(08-30-2018 03:54 PM)Dave Britten Wrote:  EDIT: It can run the standard 8x8 n-queens benchmark (http://www.hpmuseum.org/cgi-sys/cgiwrap/hpmuseum/articles.cgi?read=700) in a bit under one second. (I just did a quick port of the generic Pascal version on that page.)

Would be nice to have your test result and the code in the list, if you are also interested.
If yes, can you please check the execution time with an outer loop of 100 iterations for a
more accurate result?

100 runs took a total of about 29 seconds. The code is listed below; should work for just about anything that runs Python.

Code:
for i in range(100):
  a = [0] * 9
  r = 8
  s = 0
  x = 0
  y = 0
  t = 0
  while True:
    x += 1
    a[x] = r
    while True:
      s += 1
      y = x
      while y>1:
        y -= 1
        t = a[x]-a[y]
        if t==0 or x-y==abs(t):
          y=0
          a[x] -= 1
          while a[x]==0:
            x -= 1
            a[x] -= 1
      if y==1:
        break;
    if x==r:
      break;
  print(s)



RE: CASIO Graph 90+E - gomefun2 - 09-03-2018 05:52 PM

Your code works but could be made faster.

I also ran your code and got about 29 seconds, then I watched this video:

https://www.youtube.com/watch?v=hHec4qL00x0

I only followed his first point of advice by making your code a function by adding one single line of code I sped up your code from 29 seconds down to 13 seconds!

I didn't really watch the rest of the video yet to see if there are even more things that could be done. I'm not a computer scientist though, more of an engineer, and I don't really use python too much.

def XXX(n):
for i in range(n):
a = [0] * 9
r = 8
s = 0
x = 0
y = 0
t = 0
while True:
x += 1
a[x] = r
while True:
s += 1
y = x
while y>1:
y -= 1
t = a[x]-a[y]
if t==0 or x-y==abs(t):
y=0
a[x] -= 1
while a[x]==0:
x -= 1
a[x] -= 1
if y==1:
break;
if x==r:
break;
print(s)


RE: CASIO Graph 90+E - Dave Britten - 09-03-2018 06:43 PM

Now that's a pretty surprising difference. I just confirmed the same on mine (12-13 seconds or so). My educated guess is that pushing the variables down to a function-local scope lets Python do less housekeeping of globals.


RE: CASIO Graph 90+E - Thomas Klemm - 09-03-2018 08:14 PM

Based on the video: global variables need a look-up in a hash-map while local variables can be accessed directly on the stack.
Conclusion: Avoid global variables.

Cheers
Thomas


RE: CASIO Graph 90+E - xerxes - 09-04-2018 11:08 AM

Thanks to Dave and gomefun2 for testing. What a significant difference between global and local variables in this case.
Unfortunately there seems to be no graphics support, what is very strange for a graphing calculator.


RE: CASIO Graph 90+E - xerxes - 09-04-2018 11:50 AM

After watching the mentiond video, I noticed that normally MicroPython compiles to bytecode, but there seems to be also a native code mode,
if @micropython.native is used at the beginning of the function. Maybe we can go much faster, if @micropython.native does work on the CG50.
I guess we need 1000 or 10000 iterations in this caae, to have an accurate result.


RE: CASIO Graph 90+E - Dave Britten - 09-04-2018 12:52 PM

(09-04-2018 11:50 AM)xerxes Wrote:  After watching the mentiond video, I noticed that normally MicroPython compiles to bytecode, but there seems to be also a native code mode,
if @micropython.native is used at the beginning of the function. Maybe we can go much faster, if @micropython.native does work on the CG50.
I guess we need 1000 or 10000 iterations in this caae, to have an accurate result.

Doesn't appear to be supported (or I'm doing something wrong). I get "invalid micropython decorator".


RE: CASIO Graph 90+E - xerxes - 09-04-2018 01:00 PM

What a pity, but good to know.


RE: CASIO Graph 90+E - gomefun2 - 09-04-2018 01:59 PM

I'm not too familiar with how python libraries work. But I think the calculator can probably use custom made libraries.

I think to create a custom library, you would just create a .py file on a computer then put it in the same folder as your project on the calculator. Then you could call the file by using import.

I'm not sure if you could do graphics this way, but I'm reasonably sure that other custom libraries could be created doing this.

Anyway, because documentation is lacking (as far as I can tell), and because some people have inquired, here is a list of the libraries included on the calculator:

Built-in (standard library):
abs(), and, as, bin(), break, class, complex(,), continue, def, def:, def:return, del, divmod(,), elif, else, except, False, finally, float(), for, for:, for:range(), for:range(,), for:range(,,), from, global, hex(), if, if:, if:else, if:elif, if.and:else, if.or:else, import, in, input(), int(), is, lambda, len(), max(), min(), None, nonlocal, not, oct(), or, pass, pow(,), print, raise, range(), return, round(), sorted(), str(), sum(), True, try, type(), while, while:, with, yield, ().imag, ().real

Math Library:
acos(), asin(), atan(), atan2(,), ceil(), cos(), cosh(), exp(), fabs(), floor(), fmod(,), frexp(), from math import*, import math, ldexp(,), log(), log10(), math., math.e, math.pi, modf(), pow(,), sin(), sinh(), sqrt(), tan(), tanh()

Random Library:
choice(), from random import*, getrandbits(), import random, randint(,), random(), random., randrange(), seed(), uniform(,)

Symbols:
e, +, -,*,**,/,%,&,|,^,~,<,>,<=,>=,==,!,(,),[,],{,},,,:,.,;,=,',",#,\,!,_


RE: CASIO Graph 90+E - Dave Britten - 09-05-2018 11:32 AM

(09-04-2018 01:59 PM)gomefun2 Wrote:  I'm not too familiar with how python libraries work. But I think the calculator can probably use custom made libraries.

I think to create a custom library, you would just create a .py file on a computer then put it in the same folder as your project on the calculator. Then you could call the file by using import.

I'm not sure if you could do graphics this way, but I'm reasonably sure that other custom libraries could be created doing this.

Yes, you can create modules this way, but they have to be pure Python code, i.e. you don't get any capabilities that aren't there already. It's more of an encapsulation and code sharing feature.


RE: CASIO Graph 90+E - brickviking - 09-06-2018 10:35 AM

(09-01-2018 10:40 AM)xerxes Wrote:  The CG20 needs 39.7 seconds with BASIC. Strangely using MAT is a bit faster than using a list.

Code:
 0->A~Z
 8->R
 {R,1}->Dim Mat A
 0
 Do
 Isz X
 R->Mat A[X,1]
 Do
 Isz S
 X->Y
 While Y>1
 Dsz Y
 Mat A[X,1]-Mat A[Y,1]->T
 If T=0 Or X-Y=Abs T
 Then 0->Y
 Mat A[X,1]-1->Mat A[X,1]
 While Mat A[X,1]=0
 Dsz X
 Mat A[X,1]-1->Mat A[X,1]
 WhileEnd
 IfEnd
 WhileEnd
 LpWhile Y<>1
 LpWhile X<>R
 S

I've tried this on the older 9750GII (upgraded OS) and a 9750G+. I got 876 in about 45 seconds on the GII, but got a Syn Error at the IfEnd for the G+, and I don't know why yet, as it's the same code on both. Any clues?

EDIT: Ah, I forgot to follow the initial hpmuseum link, I've found the G+ code differs from the GII code. However, I'd still like to know why the newer code doesn't work. I entered the code from the link for the G+, and it errors out on List 1[X]-List1[Y]->T (with Arg Error).

(Post 275)


RE: CASIO Graph 90+E - xerxes - 09-06-2018 11:53 AM

There are different test codes for the Casio graphing calculators, because I noticed that the 8 bit devices are faster with unstructured code
using a list, while the 32 bit ones are faster with structured code using a matrix. I remember testing the structured code on the older devices,
caused an abnormal behaviour. Deeper investigation of the problem showed, that the reason is a bug of the interpreter, but I don't remember
the details exactly.

Thanks for testing the FX-9750GII-2 (SH4a).