I have a matrix in PGML using the matrix context. For the following code, I'd like a vertical line between columns 2 and 3 to separate the variables from the constants. Does anybody know how to do this?

## DESCRIPTION

## College Algebra

## ENDDESCRIPTION

## DBsubject(Algebra)

## DBchapter()

## DBsection()

## Date(07/03/2017)

## Institution(Red Rocks Community College, Colorado Community College System)

## Author(Craig Faulhaber)

## MO(1)

## KEYWORDS('college algebra')

##################

# Initialization

DOCUMENT();

loadMacros(

"PGstandard.pl",

"MathObjects.pl",

"AnswerFormatHelp.pl",

"PGML.pl",

"PGcourse.pl",

);

TEXT(beginproblem());

$showPartialCorrectAnswers = 1;

##################

# Setup

$a=non_zero_random(-1,1);

$b=non_zero_random(-9,9);

$c=non_zero_random(-9,9);

$d=non_zero_random(-9,9);

$e=non_zero_random(-9,9);

$f=non_zero_random(-9,9);

Context("Full");

Context()->noreduce("(-x)-y","(-x)+y");

$eqn1 = Compute("$a*x+$b*y")->reduce;

$eqn2 = Compute("$d*x+$e*y")->reduce;

Context("Matrix");

$A = Matrix(

[$a,$b,$c],

[$d,$e,$f],

);

$B=Matrix(

[$c],

[$f],

);

$answer = $A;

$right=$B;

##################

# Main text

BEGIN_PGML

Find the augmented matrix for this system.

>>[` [$eqn1]=[$c] `]<<

>>[` [$eqn2] = [$f] `]<<

Augmented matrix: [_____]*{$answer} |[_____]*{$right}[@ AnswerFormatHelp("matrices") @]*

END_PGML

########################

# Solution

#BEGIN_PGML_SOLUTION

#Solution explanation goes here.

#END_PGML_SOLUTION

COMMENT('Uses PGML.');

ENDDOCUMENT();

*Rochester/setLinearAlgebra1Systems/ur_la_1_8.pg*

So right now to get what you would like, you would have to make something that placed each answer individually, and put it in a table like Mike suggests. I'm not sure you could get the left and right brackets though, without some hacks that would negatively impact accessibility. Would you settle for three vertical rules without the "lips" on the outer brackets?

Using parserMultiAnswer.pl (http://webwork.maa.org/pod/pg_TRUNK/macros/parserMultiAnswer.pl.html), you could make it so that even with 9 answer blanks there would only be a single correct/incorrect response.

For presenting the system, you might like:

>>[``\left\{ \begin{aligned}

[$eqn1] &= [$c]\\

[$eqn2] &= [$f]

\end{aligned} \right.``]<<

They will still appear as two matrices in the results table, however, so if you want them to look like augmented matrices there as well, then you will need to use a MultiAnswer object to combine them. Here is an example that shows how to do this.

loadMacros( "PGML.pl", "parserMultiAnswer.pl", ); Context("Matrix"); $A = Matrix([[1,2,3],[4,5,6]])->with(close => '|'); $B = Matrix([[7],[8]])->with(open => '.'); $ma = MultiAnswer($A,$B)->with( checker => sub { my ($correct,$student,$self,$ans) = @_; my ($sA,$sB) = @$student; $self->{ans}[0]{preview_latex_string} =~ s/~~]/|/; $self->{ans}[1]{preview_latex_string} =~ s/~~[/./; return $A == $sA && $B == $sB; }, singleResult => 1, separator => '', tex_separator => '', ); BEGIN_PGML Augmented matrix: [___]*{$ma}[___]*{$ma} END_PGMLthis uses

`singleResult => 1`

to get both matrices on one line of the results table, and sets the separators to be empty so the two matrices are flush with each other. Finally, the `checker`

simply checks if the student answers equal the correct ones, and touches up the preview latex strings to use the correct delimiters. (There may be a better way to do the latter, but this works.)
Finally, note that if the student uses tabs to move from entry to entry, they will cycle through the left-hand matrix first, then the right-hand side. It would be difficult to change that.

See if that does what you need.

*May I ask where this is documented?*
Well, the open/close delimiters are documented on the WeBWorK wiki page for Matrix Objects. The MultiAnswer object has documentation within the macro file itself. The `preview_latex_string`

is part of the AnswerHash object, but I consider modifying that a hack, and there should be a better way to handle it. I just didn't spend more time trying to work it out.

I'll answer the tolerance question separately.

*how do you set a tolerance for the matrix entries?*You were right to set the flags in the context, but it has to be the Matrix context, not the Numeric one (it has to be the context in which the MathObject is created). So something like

loadMacros( "PGML.pl", "parserMultiAnswer.pl", ); Context("Matrix"); Context()->flags->set(tolerance => .1, tolType=>"absolute"); $A = Matrix([[pi,sqrt(2),e],[4,5,6]])->with(close => '|'); $B = Matrix([[7],[8]])->with(open => '.'); $ma = MultiAnswer($A,$B)->with( checker => sub { my ($correct,$student,$self,$ans) = @_; my ($sA,$sB) = @$student; $self->{ans}[0]{preview_latex_string} =~ s/~~]/|/; $self->{ans}[1]{preview_latex_string} =~ s/~~[/./; return $A == $sA && $B == $sB; }, singleResult => 1, separator => '', tex_separator => '', ); BEGIN_PGML Augmented matrix: [___]*{$ma}[___]*{$ma} END_PGMLshould work.