Skip to content
Classroom

Matrices

Answer type: matrix

By default the student types the whole matrix into one box, like [(1,2),(3,4)]. Set $answersize = "rows,cols" (for example "2,2") to give the student a grid with one box per entry instead.

The minimum

Common Control:

$answer = "[(1,2),(3,4)]"

Options

Variable Effect
$answer the correct matrix — required
$answersize the grid dimensions offered to the student
$abstolerance / $reltolerance tolerance per entry
$reqdecimals accuracy of each entry: unless $abstolerance or $reltolerance is set, it sets an absolute tolerance of 0.5×10⁻ⁿ; the number of decimals typed is not checked
$scoremethod "byelement" gives credit per correct entry; "allornothing" does not
$answerformat accepted-format flags
$ansprompt, $answerboxsize input box

$scoremethod

For anything larger than 2×2, "byelement" is usually the fairer choice — a single arithmetic slip otherwise costs the whole question.

Type Entries are
matrix numbers
calcmatrix expressions to evaluate
algmatrix compared algebraically
complexmatrix, calccomplexmatrix complex

calcmatrix also reads $hidepreview.

Example

Common Control — setup:

$a = nonzerorand(-5, 5)
$b = nonzerorand(-5, 5)
$c = nonzerorand(-5, 5) where ($c != $b)
$d = nonzerorand(-5, 5)
$det = $a*$d - $b*$c

Question Text:

<p>Give the transpose of `[[$a,$b],[$c,$d]]`.</p>

Common Control, continued — answer and options:

$answer = "[($a,$c),($b,$d)]"
$scoremethod = "byelement"

See Also

  • N-Tuple — a single ordered tuple
  • Number — a scalar such as a determinant
  • Array Macros — building matrix data in control