jonathf / numpoly

Numpy compatible polynomial representation
https://numpoly.readthedocs.io
BSD 2-Clause "Simplified" License
12 stars 6 forks source link

Diagonalize parametric matrix #77

Closed matteoettam09 closed 4 days ago

matteoettam09 commented 3 years ago

Hello,

is it possible to get a parametric eigendecomposition of a matrix whose elements are a mix of known numerical values and parametric variables, expressed as ndpoly entries?

Thank you.

jonathf commented 3 years ago

Currently no. I am not even sure if I understand how that would work. In the governing equation A x = lambda x do we assume all terms are polynomial scalar/vectors/matrices?

If you know how to approach such a problem and know of reading matterial I can look at, I can let you know if it would be feasable to implement or not.

matteoettam09 commented 3 years ago

I think both the eigenvalue matrix and the eigenvector matrix (and its inverse) are in general a function of polynomial scalars appearing inside the given matrix, so yes, if I understand your question correctly.

Unfortunately, I have no idea about how to deal with the problem, it's just something that came out of my research.

jonathf commented 3 years ago

I figured a way to solve this, but it requires a few new functions that are not currently implemented. Stay tuned and I'll get back to this thread when all needed compoents are in place.

matteoettam09 commented 3 years ago

Great! Thank you.

jonathf commented 3 years ago

So here is working example that should work in version 1.1.3:

import numpy as np
import numpoly as nu

# q1, q2 are parameters, q0 reserved for calculations as lambda
q0, q1, q2 = nu.variable(3)

# parametric matrix to find eigen vectors/values from
mat = nu.polynomial([[1, q1], [q2, 1]])

# characteristic eq == 0
char_expr = nu.det(mat-np.eye(len(mat))*q0)

# evaluate parameters and extract eigen values
eig_vals = nu.roots(nu.polynomial(char_expr(q1=3, q2=1)))

Temporary caveates:

Let me know if this is what you were looking for.

matteoettam09 commented 3 years ago

Yes, thank you, this is exactly was I was looking for! I will start working on it.