WeBWorK Main Forum

Why aren't math objects hooked up to a CAS?

Why aren't math objects hooked up to a CAS?

by Nikola Kuzmanovski -
Number of replies: 4
I recently started writing general problems with partial credit that link multiple answer blanks and give messages based on student responses. I attached one of these problems here. This example is like a problem template where just changing the functions gives you a different problem with the messages and partial credit built in.

While designing problems I always feel restricted and want a computer algebra system in the background. I am aware that we can call sage from Webwork, but I want to use a CAS (computer algebra system) on student input which needs to be in a specific format in order to be interpreted by the CAS correctly. It would be so convenient to have something like a CAS string for every math object (or just for Formula objects would be amazing) and a way to create a math object from a CAS string. One can pick a CAS, like sage or maxima for example, and just build this functionality into the math objects library. It can also be decently modular, where switching from one CAS to another will mostly deal with updating the CAS string formatting function.

I am wondering if this was ever considered and if people just decided that it is not a good idea for Webwork. I can list out why I feel restricted without a CAS, but I think that this is a little bit irrelevant for this post, because I think that most people would agree that adding a CAS will allow more possibilities when you are trying to give partial credit by manipulating the student input.
In reply to Nikola Kuzmanovski

Re: Why aren't math objects hooked up to a CAS?

by samuel kim -

Did you try using STACK?

I wonder if it's possible there. 

In reply to samuel kim

Re: Why aren't math objects hooked up to a CAS?

by Nikola Kuzmanovski -

I looked up what STACK is, and it looks interesting. However, from the online videos it seems to be missing some features from Webwork like MathQuill for example. I am not sure what is possible in it and how flexible it is though. They seem to be using Maxima to give feedback to students, but I don't want the CAS to have so much power. I want to use the CAS to compute things and then give feedback to students based on my own computation. One main reason for this is that I think the CAS might be pretty stupid in a lot of scenarios to give any meaningful feedback.

They have these trees as a way to do step by step problems which you can do by making a nicely structured Webwork problem. In general, from my limited time looking at this, it seems like STACK tries to make problem creation easier by simplifying and also restricting the problem creation process. Which would make the stuff I am trying to do even harder, if not impossible. Webwork is extremely flexible compared to STACK in this view.

Webwork could think about integrating the CAS part of STACK though. It seems that they already have exactly what I am describing here in the background, but use it for different purposes and have a system that doesn't allow the freedom that Webwork does at the moment.

In reply to Nikola Kuzmanovski

Re: Why aren't math objects hooked up to a CAS?

by Danny Glin -
When WeBWorK first came about there were not a lot of good options for an open-source CAS with which to integrate, and at that point using a CAS to check if two expressions were equivalent was notoriously unreliable.

Things have changed a lot since then, and I see the value of having access to a CAS from within WeBWorK problems.  As you pointed out, there is some integration with Sage available, and there is also integration with R available.  I haven't really played with the Sage integration, but I know that you can access R from within an answer checker.

I think you've hit on the biggest challenge, which is getting the syntax to play nice between the two systems.  MathObjects generates both a normal string and a LaTeX string for any object.  For Formula objects the normal string is basically "calculator notation", so I would expect that this could be passed to a CAS as-is and be interpreted correctly, and as long as the CAS outputted similar notation, the output from the CAS could be passed to Compute().  If you have specific needs or ideas you can post them here or as a GitHub discussion.

Looking quickly at your sample problem, some of the things you are doing there could be useful as methods in PG.  For example checking that two functions are equivalent up to an additive constant is already available as an answer checker, but not as a standalone method within a custom checker.  Your checkMultAdd is virtually identical to a code snippet that I use in differential equations problems, so making this a MathObjects method could be useful as well.

With WeBWorK being open source, if you have improvements that you have made to the code, please submit a pull request on GitHub so that they can be considered for inclusion in the code base.
In reply to Danny Glin

Re: Why aren't math objects hooked up to a CAS?

by Nikola Kuzmanovski -
Thanks for the historical background!

The UNL math department will most likely contribute our own problems and methods in the near future to be considered for inclusion in the code base. Some people have started using some of my partial credit checkers in the department here, and it only makes sense to make them available instead of copying them from course to course.