Currently, the problems that ask for a basis for the row space of a matrix A require students to enter the basis as column vectors. What I want to do is to to change this to entry via row vectors. I have the formatting and entry taken care of, but the problem seems to be that basis_cmp can't work with row vectors. Is there some clever hack which will enable it to work?
Here is the code that I have (once the matrix A has been created):
BEGIN_TEXT
Here, x = $x.
$BR
Find a basis of the row space of the matrix
$BR
\{ mbox( '\(A=\)', display_matrix($A), '.' ) \}
$BR
If there are extra vectors which you do not need, fill in their entries with x's.
$BR
\{ mbox( ans_array(1,5,10), ', ') \}
\{ mbox( ans_array_extension(1,5,10), ', ') \}
\{ mbox( ans_array_extension(1,5,10), ', ') \}
\{ mbox( ans_array(1,5,10), '. ') \}
END_TEXT
if ($x == 3) {
ANS(basis_cmp([[1,0,0,($a[1][4]*$a[2][2]-$a[1][2]*$a[2][4])/($a[2][2]*$a[1][1]),
($a[1][5]*$a[2][2]-$a[1][2]*$a[2][5])/($a[2][2]*$a[1][1])],
[0,1,0,$a[2][4]/$a[2][2],$a[2][5]/$a[2][2]], [0,0,1,0,0]])); # $x = 3
} else { if ($x == 4) {
ANS(basis_cmp([[1,0,($a[1][3]*$a[2][2]-$a[1][2]*$a[2][3])/($a[2][2]*$a[1][1]),0,
($a[1][5]*$a[2][2]-$a[1][2]*$a[2][5])/($a[2][2]*$a[1][1])],
[0,1,$a[2][3]/$a[2][2],0,$a[2][5]/$a[2][2]], [0,0,0,1,0]])); # $x = 4
} else { if ($x == 5) {
ANS(basis_cmp([[1,0,($a[1][3]*$a[2][2]-$a[1][2]*$a[2][3])/($a[2][2]*$a[1][1]),
($a[1][4]*$a[2][2]-$a[1][2]*$a[2][4])/($a[2][2]*$a[1][1]),0],
[0,1,$a[2][3]/$a[2][2],$a[2][4]/$a[2][2],0], [0,0,0,0,1]])); # $x = 5
} } }
ANS(str_cmp("x")); ANS(str_cmp("x")); ANS(str_cmp("x")); ANS(str_cmp("x"));
ENDDOCUMENT();
(I am currently trying this with a seed which makes $x = 5. The formula for that answer is correct; I checked it with Maple.)Here, x = $x.
$BR
Find a basis of the row space of the matrix
$BR
\{ mbox( '\(A=\)', display_matrix($A), '.' ) \}
$BR
If there are extra vectors which you do not need, fill in their entries with x's.
$BR
\{ mbox( ans_array(1,5,10), ', ') \}
\{ mbox( ans_array_extension(1,5,10), ', ') \}
\{ mbox( ans_array_extension(1,5,10), ', ') \}
\{ mbox( ans_array(1,5,10), '. ') \}
END_TEXT
if ($x == 3) {
ANS(basis_cmp([[1,0,0,($a[1][4]*$a[2][2]-$a[1][2]*$a[2][4])/($a[2][2]*$a[1][1]),
($a[1][5]*$a[2][2]-$a[1][2]*$a[2][5])/($a[2][2]*$a[1][1])],
[0,1,0,$a[2][4]/$a[2][2],$a[2][5]/$a[2][2]], [0,0,1,0,0]])); # $x = 3
} else { if ($x == 4) {
ANS(basis_cmp([[1,0,($a[1][3]*$a[2][2]-$a[1][2]*$a[2][3])/($a[2][2]*$a[1][1]),0,
($a[1][5]*$a[2][2]-$a[1][2]*$a[2][5])/($a[2][2]*$a[1][1])],
[0,1,$a[2][3]/$a[2][2],0,$a[2][5]/$a[2][2]], [0,0,0,1,0]])); # $x = 4
} else { if ($x == 5) {
ANS(basis_cmp([[1,0,($a[1][3]*$a[2][2]-$a[1][2]*$a[2][3])/($a[2][2]*$a[1][1]),
($a[1][4]*$a[2][2]-$a[1][2]*$a[2][4])/($a[2][2]*$a[1][1]),0],
[0,1,$a[2][3]/$a[2][2],$a[2][4]/$a[2][2],0], [0,0,0,0,1]])); # $x = 5
} } }
ANS(str_cmp("x")); ANS(str_cmp("x")); ANS(str_cmp("x")); ANS(str_cmp("x"));
ENDDOCUMENT();
--- Christopher Heckman
P.S. The extra ans_array and ANS's are intentional; I also wanted to "hide" what the dimensions of these spaces are. Furthermore, I'm changing a few formulas so that the "correct answers" that WeBWorK gives are the ones you get by doing the procedures described in the book; not all the problems have been written with this in mind.