Ask Your Question

# Convert a matrix to a list of equations

Hi there, I have a matrix A with entries depending linearly on a number of parameters a1,...,an, and would like to solve the equation A=0. It seems I need to convert A to a list of equations of the form "entry=0" and then use solve(eqns, a1,...,an); but how do I convert A to such a list?

Any help appreciated!

edit retag close merge delete

## 1 Answer

Sort by ยป oldest newest most voted

Given a matrix M, say:

sage: M = matrix(ZZ, [[4, 27, -3], [-3, 2, -1], [-177, 45, 5]])
sage: M
[   4   27   -3]
[  -3    2   -1]
[-177   45    5]


You can get its entries by doing:

sage: M.coefficients()
[4, 27, -3, -3, 2, -1, -177, 45, 5]

more

## Comments

Thanks tmonteil, that's good to know! Is there also a way to convert the list of coefficients to a list of equations, setting each coefficient == 0?

( 2018-08-29 23:33:47 +0200 )edit

yes, like this:

[c == 0 for c in M.coefficients()]

( 2018-08-30 13:29:33 +0200 )edit

## Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

## Stats

Asked: 2018-08-29 21:24:30 +0200

Seen: 1,043 times

Last updated: Aug 29 '18