## WeBWorK Problems

### Solve LR ### Solve LR

by Olivia Henders -
Number of replies: 4

We are trying to use Solve LR to find the solution to this question (see image) However, instead of getting the expected answer (the matrix [,[-1]]) we’re getting a 2x2 zero matrix.

Applicable lines of code are listed below.

What are we doing incorrectly?

$v2D = ColumnVector(4,1); $D = Matrix([[3,5],[1,2]]);
# Must be called by a Matrix MathObject.
$answerBi =$D->solve_LR(Matrix($v2D)->transpose); BEGIN_PGML bi. Solve LR What is the solution to the system [Dx = \vec{v}]? [@ ans_box(4,30) @]* [@ AnswerFormatHelp("matrix") @]*   *Correct Answer(s):* [$answerBi]

 *Displayed Answer (after the due date):* [[$answerBi]] END_PGML ANS($answerBi->cmp()) ### Re: Solve LR

by Olivia Henders -
Sorry, the image failed to render for some reason. Please see http://imgur.com/tuVBLBt for the referenced image. ### Re: Solve LR

by Davide Cervone -
The problem is that solve_LR doesn't return what you think it does. The method uses the corresponding one from the MatrixReal package, and that returns three things: the dimension, the resultant vector, and the base matrix. These are explained in the linked page (search for solve_LR). So you could do either
($d,$answerBi,$X) =$D->solve_LR(Matrix($v2D)->transpose);  or $answerBi = ($D->solve_LR(Matrix($v2D)->transpose));

to get the result that you are looking for. It turns out that if you assign the array of three to the scalar \$answerBi, it gets assigned to the last element in the array (the base matrix), which is the 2x2 zero matrix you are seeing.  