LMSouq
moodle-core Open

Random matrix with determinant not zero in Maxima

HI
Hirshy
1 month ago
3 views
Problem Description
I want to generate a matrix with random entries such that the determinant of that matrix is not zero using Maxima and further down the line implement this in STACK for Moodle. I am completely new to working with Maxima (or any CAS for that matter), so I have been going through various examples I found online and have so far managed to get this: Generating a 2x2 random matrix with 0 or 1 (for simplicity reasons) and calculating its determinant: g[i,j]:=1-random(2); M1:genmatrix(g,2,2); dM1:determinant(M1); For the next step I wanted to define a matrix M2 as follows: M2:(if dM1#0 then M1 else ***) If the determinant of the matrix M1 is already not zero, fine, I'll go with that, but I am struggling with the else-part. I was thinking of creating a loop that generates new random numbers `g[i,j]` for `M1` until I get a matrix with determinant not zero, but am unsure on how to do that or if there are other options. In addition: as I mentioned this is ultimately something I want to implement in STACK for moodle (question will be to solve a system of linear equations with the generated matrix being the matrix of this system), so I don't know if there are any limitations on using if and while loops in STACK, so if somebody is aware of known problems I would appreciate any input.

AI-Generated Solution

Powered by LMSouq AI · GPT-4.1-mini

✓ Solution Ready
Analyzing problem and generating solution…
Was this solution helpful?
Back to Knowledge Base