README (not visible to students)

This question provides two matrices as both NumPy and MATLAB variables using the <pl-variable-output> element. The entries of the matrices are randomly generated. Students are asked to compute the product of these two matrices, and provide their answer using either NumPy or MATLAB format. The generated matrices are converted to JSON format with pl.to_json(...) for storage in data["params"] and data["correct_answers"].

Matrix input: random parameters and correct answer

Two matrices $A$ and $B$ are given as follows:

1
2
A = [-1.0 -0.7 0.7 0.4 1.0; -0.2 0.9 0.8 0.2 0.9; 0.3 -0.6 0.3 0.2 -0.7; 0.1 0.9 0.0 0.2 0.2];
B = [0.1 0.1 -0.2 -0.3; 0.8 -0.5 0.1 -0.3; 1.0 0.8 -0.1 -0.7; -1.0 -0.9 0.6 -0.1; -0.7 -0.9 -0.1 -0.8];
1
2
3
4
import numpy as np

A = np.array([[-1.0, -0.7, 0.7, 0.4, 1.0], [-0.2, 0.9, 0.8, 0.2, 0.9], [0.3, -0.6, 0.3, 0.2, -0.7], [0.1, 0.9, 0.0, 0.2, 0.2]])
B = np.array([[0.1, 0.1, -0.2, -0.3], [0.8, -0.5, 0.1, -0.3], [1.0, 0.8, -0.1, -0.7], [-1.0, -0.9, 0.6, -0.1], [-0.7, -0.9, -0.1, -0.8]])

Find the product of these two matrices:

Correct answer

Student view placeholder

In student views this area is used for assessment and score info.
Tools

Staff information

Question

Title:
Matrix input: random parameters and correct answer

Variant

Started at:
2026-08-05 01:00:01 (CDT)
Duration:
0s
Show/Hide answer
{
  "C": {
    "_type": "ndarray",
    "_dtype": "float64",
    "_value": [
      [
        -1.06,
        -0.4500000000000001,
        0.19999999999999998,
        -0.82
      ],
      [
        0.67,
        -0.8200000000000001,
        0.07999999999999997,
        -1.51
      ],
      [
        0.1399999999999999,
        1.02,
        0.04000000000000001,
        0.42
      ],
      [
        0.39,
        -0.8,
        0.17,
        -0.48000000000000004
      ]
    ]
  }
}
History
dec frac
rad deg