Hi,

> On May 26, 2015, at 10:36 PM, Damien Guillaume <dami...@msu.edu> wrote:
> 
>> This seems to work as expected for square matrices. However, the example
>> below accepts ([2,-2,-4],[-1,3,4]) as an answer, even though
>> &cas('maxima','rank(matrix'.$submission.'^^2-matrix'.$submission.')')
>> should generate an error in MAXIMA:
>> 
>> (%i1) A:matrix([2,-2,-4],[-1,3,4]);                               [  2
>>   - 2  - 4 ]
>> (%o1)                          [               ]
>>                                [ - 1   3    4  ]
>> (%i2) rank(A^^2 - A);
>> MULTIPLYMATRICES: attempt to multiply nonconformable matrices.
>>  -- an error. To debug this try: debugmode(true);
> 
> It looks like maximareply() in lonmaxima.pm does not recognize this error 
> message as an error message (it is only checking if there is "incorrect" in 
> the reply). I guess the best solution would be to fix that, but maybe there 
> is a way to tell if the result of the cas call makes sense or not (like 
> testing if it is an integer), as a workaround.

Argh! Yes, it’s really a problem that MAXIMA was designed throughout for 
interactive sessions. The replies are non-standardized.

I am not sure if &maximareply() gives us back the whole message, since it is 
two lines (another problem), so I think we only get back “MULTIPLYMATRICES: 
attempt …” It is impossible to anticipate all the possible messages that MAXIMA 
returns, since there is no standard - each package spits out whatever the 
author imagined. In this case, probably the only remedies are to interpret the 
presence of “attempt” also as an error

if ($determinant=~/(error|attempt)/i)  { return ‘BAD_FORMULA’; }

or to see if we only get back a number

unless ($determinant=~/^\s*\d+\s*$)  { return ‘BAD_FORMULA’; }

- probably cleaner to do the latter, if we know that all ranks should just be 
numbers.

- Gerd.

_______________________________________________
LON-CAPA-users mailing list
LON-CAPA-users@mail.lon-capa.org
http://mail.lon-capa.org/mailman/listinfo/lon-capa-users

Reply via email to