Preloading CAS in GeoGebra applets
Mixing dynamic geometry and computer algebra is not always easy. At GeoGebra, we have been working on solving some challenges with preloading the computer algebra system (CAS) before some heavy computations are initiated by the user.
For many users, those computations are not really required. Dynamic geometry usually just shows nice relationships between lines, circles and other objects, but you don't have to go into the very details, so you don't need CAS at all. But sometimes it is worth doing something more. In such cases the CAS should be loaded on time to ensure being ready to serve the output for the user.
Unfortunately, GeoGebra's internals do not completely support this idea yet. If you start a heavy computation like comparing two objects symbolically, in case the CAS is not yet loaded, you won't get any useful results. Just an "undefined" output which means that nothing really happened in the background yet. Then you may retry your request and hope for the best, if GeoGebra is already up-to-date to serve you. This affects only activities that are shown in a web browser (including Classic 6 as well), but not the ones that are running natively in your desktop version Classic 5.
Following Mike's idea today I finally introduced a hack on one of my recent applets. The trick is that you create an object in the CAS View that checks if a simple CAS computation is correct. In my file this check is to create the command Factor(x^2-1) first, and then verify if its result contains the expected expression. I use the command cl:=$1==(x-1)(x+1) to decide this properly. Then, the objects related to the heavy computations (in my example, segments p, q and r) are configured to be shown only when the variable cl is true.
With this technique the objects p, q and r (their lengths are to be checked with the Relation tool) are shown just after the CAS is properly loaded.
For many users, those computations are not really required. Dynamic geometry usually just shows nice relationships between lines, circles and other objects, but you don't have to go into the very details, so you don't need CAS at all. But sometimes it is worth doing something more. In such cases the CAS should be loaded on time to ensure being ready to serve the output for the user.
Unfortunately, GeoGebra's internals do not completely support this idea yet. If you start a heavy computation like comparing two objects symbolically, in case the CAS is not yet loaded, you won't get any useful results. Just an "undefined" output which means that nothing really happened in the background yet. Then you may retry your request and hope for the best, if GeoGebra is already up-to-date to serve you. This affects only activities that are shown in a web browser (including Classic 6 as well), but not the ones that are running natively in your desktop version Classic 5.
Following Mike's idea today I finally introduced a hack on one of my recent applets. The trick is that you create an object in the CAS View that checks if a simple CAS computation is correct. In my file this check is to create the command Factor(x^2-1) first, and then verify if its result contains the expected expression. I use the command cl:=$1==(x-1)(x+1) to decide this properly. Then, the objects related to the heavy computations (in my example, segments p, q and r) are configured to be shown only when the variable cl is true.
With this technique the objects p, q and r (their lengths are to be checked with the Relation tool) are shown just after the CAS is properly loaded.
Comments