08-11-2017, 01:57 PM
I have been looking at my new Casio fx-CG500 (CG500 for short) and focusing on its programming. The manual for the CG500 contains a section that lists all of the programming commands and constructs. The text contains general syntax for the commands but is very light on examples. Casio has not included a short library of programs which would have really helped.
Programming the CG500 requires that you understand a few rules. If you program a function the interpreter expects that the function returns a simple expression--no loops or decision making constructs! The CG500 allows you to create programs that act as SUBroutines of FUNctions with parameters. The function-type programs use the Return statement followed by an expression. The SUB-type program can use the Return command all by itself to exit.
The first rule for programming numerical analysis code is that you MUST include the SetDecimal command at the start of your code. This command tells the CG500 interpreter that you wish to calculate numeric results AND NOT symbolic ones. Failing to do so (as I experienced first) will cause your programs to execute very slowly and virtually come to a halt. So, including the SetDecimal command is a must.
The second rule is to include the OPTIONAL Local statement. Unlike the HP Prime, the CG500 allows you to use variables as you go. If you do not declare them in the Local statement, the CG500 sets these variables as global and their values remain after the program ends execution. This may be handy for debugging (of course you can use Print commands to display the values of any variable or program parameters). You can use the delVar command to delete global variables. Using the Local statement is much more practical than a long list of delVar commands inserted before the program ends. There are some cases, such as error management, when global variables can be used to communicate between programs without using parameters.
After a frustrating experience, I was able to program Newton's algorithm and have it work properly.
I have also noticed that the CG500 lacks advanced math functions like Zeta, Hermite polynomial, Laguerre polynomials, and so on. So Cyril, Time, and the rest of the team can breath easy in this department.
This si as far as I have tested the CG500.
Namir
Programming the CG500 requires that you understand a few rules. If you program a function the interpreter expects that the function returns a simple expression--no loops or decision making constructs! The CG500 allows you to create programs that act as SUBroutines of FUNctions with parameters. The function-type programs use the Return statement followed by an expression. The SUB-type program can use the Return command all by itself to exit.
The first rule for programming numerical analysis code is that you MUST include the SetDecimal command at the start of your code. This command tells the CG500 interpreter that you wish to calculate numeric results AND NOT symbolic ones. Failing to do so (as I experienced first) will cause your programs to execute very slowly and virtually come to a halt. So, including the SetDecimal command is a must.
The second rule is to include the OPTIONAL Local statement. Unlike the HP Prime, the CG500 allows you to use variables as you go. If you do not declare them in the Local statement, the CG500 sets these variables as global and their values remain after the program ends execution. This may be handy for debugging (of course you can use Print commands to display the values of any variable or program parameters). You can use the delVar command to delete global variables. Using the Local statement is much more practical than a long list of delVar commands inserted before the program ends. There are some cases, such as error management, when global variables can be used to communicate between programs without using parameters.
After a frustrating experience, I was able to program Newton's algorithm and have it work properly.
I have also noticed that the CG500 lacks advanced math functions like Zeta, Hermite polynomial, Laguerre polynomials, and so on. So Cyril, Time, and the rest of the team can breath easy in this department.
This si as far as I have tested the CG500.
Namir