```
from sympy import *
import random
lambda1 = Symbol('lambda_i')
kw3 = {"I","*I","I/2","*I/2","*I:","I:","sqrt"}
merror = bool
merror == True
n = random.randrange(2, 3, 1)
def mgenerator():
A = randMatrix(n,n,percent=100,min=0, max=3,symmetric=False)
B = randMatrix(n,n,percent=100,min=0, max=3,symmetric=False)
return (A,B)
mA, mB = mgenerator()
def matrices():
MC = mA*mB
eq55 = Eq(lambda1,(MC).eigenvals())
P, D = MC.diagonalize()
return (MC, eq55, P, D)
def mtest():
mC, mE, mP, mD = matrices()
if mC.is_diagonalizable() and not any(kw in str(mE) for kw in kw3):
merror == False
return merror
else:
mA, mB = mgenerator()
mC, mE, mP, mD = matrices()
return (mA, mB, mC, mE, mP, mD)
while merror == True:
mtest()
if merror == False:
#do stuff
```

For some reason I am not able to test my code and run the rest of it. I do not want to generate eigenvectors that include any square roots or complex numbers. Right now, one version of the code works but requires me to execute it a few time to generate the whole problem set.

I am getting a headache from trying to understand the difference between static and dynamic generated variables in matrix forms. Passing these variables through defined functions is also mind-boggling.

I am trying to generate static matrices and test them for conditionals. If they fail the test I want to generate new matrices and test them continuously until they pass the test and I can run the rest of my code.

I accomplished working testing functinos for a similar project integrated in the full code which is the calculus problem generator above the linear algebra problem generator.

Working Code

Updating Working Code That Is Currently Broken

As you can see between the two, the lower half is getting revised and condensed with nicer testing but I am struggling to get the outputs I want that don’t include complex numbers or square roots.

Twitter @Noeo1234)