Declarations - how to compare two equations?



Hi,

Thanks for the very quick replies!

On Jan 22, 2012, at 10:59 AM, Henry Baker wrote:

> 
> I still think that this is a worthwhile goal, but it would require a substantial amount of work to produce what Gerd wants.
> 
> At 07:22 AM 1/22/2012, Richard Fateman wrote:
>> Solve generally ignores declarations, except insofar as it might call some other program like simplification, that uses them.
>> 
>> You will have to filter out the real solutions some other way.

Please excuse my ignorance of advanced MAXIMA syntax. Here's what I really need to achieve: see if an equation that a student inputs is equivalent to an equation given by the instructor.

Here's a snippet of internal LON-CAPA code; LON-CAPA is mostly written in Perl, the &cas()-subroutine passes expressions to MAXIMA for evaluation.

sub compareequations {
   my ($var,$value,$equation)=@_;
# var is the variable given
# value is the expected value of $var, $var=$value
# equation is the equation to be tested
   $expressiona='trigsimp(trigreduce(['.$var.'='.$value.']))';
   $expressionb='trigsimp(trigreduce(solve('.$equation.','.$var.')))';
   $reply=&cas('maxima','is(equal('.$expressiona.','.$expressionb.'))');
   if ($reply=~/^Error\:/) { return $reply; }
   if ($reply=~/true/) { return 'true'; }
   return 'false';
}

So, my current algorithm is:

* instructor gives a single variable on the lefthand side and the expected righthand side (e.g., "x"  and "2*y+b" for "x=2*y+b")
* the student answer (e.g., "y=(x-b)/2") is solved for that variable (in this example, "x"), simplified, and compared to the simplified instructor answer

The above problem occurs in a (minimal) example when the instructor answer is x=5, and the student inputs x^3=125 - in the real realm, that would be awkward but correct.

Is there any better way to compare two equations (that LON-CAPA does not "know" the first thing about) inside MAXIMA, and if not, how could I begin to address the issue?

Thanks!

- Gerd.