Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Warning

This section is a work in progress please excuse the sparse documentation. If you'd like to use this question type and don't find the sufficient information on this page please email us.

This section will cover how to use the HTML & JavaScript (JS) question type to create matrix questions. Because of this, the HTML & JS question type is also sometime called matrix editor.



Below are examples of how this question type could be used

Matrix Questions

Tabular Input



Creating Matrix Question Types

Matrix objects in JavaScript are supported through the usage of MathJs, a mathematical library for JavaScript. Specifically this page covers the usage and support of matrix objects. https://mathjs.org/docs/datatypes/matrices.html

Below is an example of a matrix question.



Example Code

Code Block
languagetext
titleBody
Compute the product $AB$ of the matrices

$$A = @matA, B = @matB$$
Code Block
languagetext
titleExplanation
By the row-column definition of the product of matrices

$$\eqalign{AB = &@matA @matB \cr
&@ans1}$$
Code Block
languagejs
firstline1
titleJavaScript
linenumberstrue
function js_answer() {
	/* global matrix matA u={} */
	/* global matrix matB u={} */
	/* global matrix ans1 u={} */
	
	matA = math.matrix([[-3, -1, -5],
						[-4, -5, 0],
						[-2, -4, 5]]);

	matB = math.matrix([[4, 4, 0],
						[-5, 5, 0],
						[2, 5, -3]]);

	ans1 = math.multiply(matA, matB);

}

Preview