Open baggepinnen opened 3 years ago
Basically, dup of #220
That's not how GenericLinearAlgebra works BTW...
That's not how GenericLinearAlgebra works BTW...
Not sure what you mean by that, GenericLinearAlgebra does a have a method of eigvals
which is generic wrt the matrix element type, so it felt natural to try that, granted that it's most likely targeted at numerical computing only.
The generic algorithm isn't going to work. What makes this special is that eigenvalues are solutions to the characteristic polynomials, and so you know by Abel's theorem that you definitely cannot do this for NxN with N>=5 as if you could, then you'd have an algorithm for solving higher order polynomials effectively. Something could be specialized to small matrices, but you'd probably what to do it via the polynomial form.
https://en.wikipedia.org/wiki/Eigenvalue_algorithm#Algorithms
Numerical eigenvalue solvers use an algorithm that iterates to tolerance, but you just can't do that if you have symbolic variables because symbolic control flow cannot be evaluated without values. The error:
ERROR: TypeError: non-boolean (Num) used in boolean context
shows up when you're doing something like if x < tol
. If x
is a number, then this is true or false. If x
is symbol, then it's x < tol
, so Julia just cannot know how many iterations to do and throws an error.
Hopefully that makes the error, the reason for the error, the reason why it has to be there in general, and exactly what the workaround would look like (i.e. hardcoding polynomial solves for up to the quartic and using that). But the moral of the story is, if you see that error, you're likely doing a non-quasi-static algorithm, i.e. some algorithm which requires knowing the numerical values to know the number of steps, and those algorithms are by their very nature not compatible with symbolic computing.
SymPy handles eigenvalues of symbolic matrices, provided that they are not too large. Loading GenericLinearAlgebra and trying the same with Symbolics results in
┆Issue is synchronized with this Trello card by Unito