WeBWorK Problems

Matrix Custom Answer Checking

Re: Matrix Custom Answer Checking

by Davide Cervone -
Number of replies: 0
A couple of issues, here.

First, my understanding is that LR decomposition is only value for square matrices, which yours isn't. Perhaps you want to keep A separate from the augmented form of A and work with that?

If you want to have the students enter the augmented matrix, you will need to use $A->ans_array as you have done, but then you will need to use $A->cmp with a custom checker, not $LA->cmp. The custom checker can use $LA internally (and ignore $correct) if you want, or you could wait to compute $LA within the answer checker (from the correct answer). Whatever you prefer.

I think you will need to remove the last column of the correct and student answer. There is no really convenient way to do that, however. Here is one possibility for deleting the fifth column from a matrix $M.

    $Mt = $M->transpose;
    $MM = Matrix(
            $Mt->extract(1),
            $Mt->extract(2),
            $Mt->extract(3),
            $Mt->extract(4),
          )->transpose;
So you could use that to get the square matrix whose LR decomposition you would need to compute.

There are a couple of other minor issues as well: I would recommend using \rm in your chemical equations to get the right font for the chemicals:

    $chem[0] ="\rm Sn O_2 + H_2 \rightarrow Sn + H_2 O";
    $chemxs[0] ="x_1{\rm Sn O_2} + x_2{\rm H_2} \rightarrow x_3{\rm Sn} + x_4{\rm H_2 O}";
Also, creating $A dynamically from your row arrays is easy:
    $A = Matrix([@ar1],[@ar2],[@ar3]);

See if any of that helps.

Davide