Skip to content
Classroom

Matrices Question Type

Students enter a 2D matrix of values.

Basic Syntax

[matrix]
answer = [[1, 2], [3, 4]];

Options

answer (required)

The correct matrix in 2D array format.

[matrix]
answer = [[1, 0, 0], [0, 1, 0], [0, 0, 1]];  // Identity matrix

rows, cols

Expected matrix dimensions.

[matrix]
answer = [[1, 2, 3], [4, 5, 6]];
rows = 2;
cols = 3;

tolerance

Acceptable error for each element.

[matrix]
answer = [[1.5, 2.7], [3.1, 4.2]];
tolerance = 0.01;

Examples

Matrix Multiplication

$A = "[[1, 2], [3, 4]]";
$B = "[[5, 6], [7, 8]]";

Multiply the matrices:
`A = $A` and `B = $B`

[matrix]
answer = [[19, 22], [43, 50]];
rows = 2;
cols = 2;
tolerance = 0.01;

Augmented Matrix from System

Write the augmented matrix for the system:
`2x + 3y = 5`
`x - y = 2`

[matrix]
answer = [[2, 3, 5], [1, -1, 2]];
rows = 2;
cols = 3;

Identity Matrix

What is the 3×3 identity matrix?

[matrix]
answer = [[1, 0, 0], [0, 1, 0], [0, 0, 1]];
rows = 3;
cols = 3;

Row-Reduced Echelon Form

Use row reduction to solve the system, then write the result in RREF.

Original: `[[1, 2, 3], [2, 1, 4]]`

[matrix]
answer = [[1, 0, 1.4], [0, 1, 0.8]];
rows = 2;
cols = 3;
tolerance = 0.01;

Grading

The system: 1. Parses the student's matrix input 2. Checks dimensions match (if specified) 3. Compares each element within tolerance 4. Returns Correct if all elements match, Incorrect otherwise

Display Format

Students enter matrices in row-by-row format, typically with a visual input grid:

[1.5] [2.3] [3.1]
[4.2] [5.6] [6.7]

Tips

  • Specify dimensions: Helps students understand expected output size
  • Set reasonable tolerance: Rounding errors accumulate in complex calculations
  • Provide context: Explain what the matrix represents (transformation, system, etc.)
  • Start with small matrices: 2×2 or 2×3 before larger systems

See Also