xxxxxxxxxx
37
const a = [
[-2, 3],
[2, 1],
];
const b = [11, 9];
const x = math.usolve(a, b); // [[8], [9]]
const equation = `
\\begin{bmatrix}
${a[0][0]} & ${a[0][1]}\\\\
${a[1][0]} & ${a[1][1]}
\\end{bmatrix}
\\begin{bmatrix}
${x[0]}\\\\
${x[1]}
\\end{bmatrix}
=
\\begin{bmatrix}
${b[0]}\\\\
${b[1]}
\\end{bmatrix}
`;
function setup() {
createCanvas(400, 400);
background(220);
const tex = createTeX(equation);
tex.style("font-size", "20px");
tex.position(90, 170);
}
function createTeX(expression) {
const tex = createP();
katex.render(expression, tex.elt);
return tex;
}