Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Solver returns empty solution for linear system (but it has a solution)

I have three n by n matrices : m_want , m_l andm_r

In the below examples, clearly m_want = m_l * m_r, however if I replace any of the value of either matrix by a variable and try to solve for this variable :

 solution = solve([system[i][j]==want[i][j] for j in range(n) for i in range(n)], variables)

then the solution is empty. Does anyone knows why it behaves like this?

m_l = Matrix([[1, 1, 0, 0, 0, 0, 0, 0],
[0.7071067811865475, -0.7071067811865475, 0, 0, 0, 0, 0, 0],
[0, 0, 1, 1, 0, 0, 0, 0],
[0, 0, 0.4142135623730962, -2.4142135623730976, 0, 0, 0, 0],
[0, 0, 0, 0, 1.0, 1.0, 0, -0.7071067811865483],
[0, 0, 0, 0, 1.414213562373096, -0.7071067811865457, -1, 0],
[0, 0, 0, 0, 0, -0.7071067811865472, 1.0, 1.0],
[0, 0, 0, 0, -1, 0, 1.4142135623730945, -0.7071067811865468]]
)

m_r = matrix([
[1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0],
[0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0],
[0.9238795325112865, 0.0, -0.9238795325112865, 0.0, 0.9238795325112865, 0.0, -0.9238795325112865, 0.0],
[0.0, -0.38268343236509034, 0.0, 0.38268343236509034, 0.0, -0.38268343236509034, 0.0, 0.38268343236509034],
[0.9807852804032295, 0, 0.19509032201612828, 0, -0.9807852804032295, 0, -0.19509032201612828, 0],
[0, -0.27589937928294467, 0, 1.38703984532215, 0, 0.27589937928294467, 0, -1.38703984532215],
[0.8314696123025446, 0, -0.5555702330196017, 0, -0.8314696123025446, 0, 0.5555702330196017, 0],
[0, -1.175875602419359, 0, 0.7856949583871042, 0, 1.175875602419359, 0, -0.7856949583871042]]
)

want =  matrix([
[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0],
[0.7071067811865475, -0.7071067811865475, 0.7071067811865475, -0.7071067811865475, 0.7071067811865475, -0.7071067811865475, 0.7071067811865475, -0.7071067811865475],
[0.9238795325112865, -0.38268343236509034, -0.9238795325112865, 0.38268343236509034, 0.9238795325112865, -0.38268343236509034, -0.9238795325112865, 0.38268343236509034],
[0.38268343236508906, 0.9238795325112872, -0.38268343236508906, -0.9238795325112872, 0.38268343236508906, 0.9238795325112872, -0.38268343236508906, -0.9238795325112872],
[0.9807852804032303, 0.5555702330196018, 0.1950903220161283, 0.8314696123025453, -0.9807852804032303, -0.5555702330196018, -0.1950903220161283, -0.8314696123025453],
[0.5555702330196017, 0.19509032201612886, 0.8314696123025453, -0.9807852804032305, -0.5555702330196017, -0.19509032201612886, -0.8314696123025453, 0.9807852804032305],
[0.8314696123025446, -0.9807852804032307, -0.5555702330196028, -0.19509032201612753, -0.8314696123025446, 0.9807852804032307, 0.5555702330196028, 0.19509032201612753],
[0.19509032201612703, 0.8314696123025446, -0.9807852804032307, -0.5555702330196031, -0.19509032201612703, -0.8314696123025446, 0.9807852804032307, 0.5555702330196031]])