Linear Algebra support?

I’m interested in porting/adapting the exercises at https://library.tbil.org/2025/linear-algebra/exercises/ into Doenet. The way those problems are defined (using SageMath) depends a lot on knowing properties such as pivots, RREF, and generating random examples of matrices of certain forms.

This could all be done by cleverly using elementary matrices of course, but I wanted to make sure that there isn’t some more advanced tooling I could take advantage of, or else that no one hadn’t already made headway in this direction.

(I suppose the other, stupid(?) option I have is to use my existing SageMath code to pre-generate lots of random matrices of the forms I need, and then choose randomly from those…)

We don’t currently have a linear algebra tools to speak of on Doenet, save calculating eigenvalues and eigenvectors. If you’d like particular linear algebra features, you could request them here or on GitHub. To make significant progress on this in the near future, we’d most likely need to find someone interested in helping with their development.

Another option is to incorporate a simple way to import randomly generated parameter sets from outside sources, for example, like your CheckIt and SpaTeXt do. Then, it would be easy to use your existing SageMath code.

Without adding any DoenetML features, you could generate this type of code to have a matrix that is randomly select from some options:

<select name="A">
  <option>
    <matrix>
      <row>1 2</row>
      <row>3 4</row>
    </matrix>
  </option>
  <option>
    <matrix>
      <row>5 6</row>
      <row>7 8</row>
    </matrix>
  </option>
</select>

Or, if it is easier, you could define each matrix with a <math format="latex"> and include the latex for a matrix in each <math>.

Thanks Duane. Since I have the SageMath code generating all the random bits already, a first pass would probably be to generate lots of seeds as a big XML <setup/> as you suggest. I think then I could look into contributing to linear algebra components on the code side (once I feel safe that I have what I need to teach this fall…).

Now an authoring question – what’s the best way to set a lot of related variables at once? <select/> sets a single variable, but I want the same seed to set a bunch of related variables.

You can use a <select> to select a set of items. You just need to

  1. put multiple components in each <option>, and
  2. name the consistently across the <option>.

For example,

<select name="s">
  <option>
    <math name="m">x^2</math><function name="f">sin x</function>
  </option>
  <option>
    <math name="m">1/x</math><function name="f">e^x</function>
  </option>
</select>

<p>m is $s.m, f is $s.f</p>

@Xinli_Wang this conversation might be of relevance.

Thanks for alerting me Anurag! I’d love to see more linear algebra examples here in Doenet before I try to create my own.