Your version doesn't work with PreTeXt. I'll do some playing around to see if I can fix that.
If not, I think my version (after incorporating some of your suggestions) will do: I'm putting this problem in a book where students will be regularly using the [[a,b],[c,d]] syntax, because it's the same syntax used to enter a matrix in Python.