symbolically solve for unknown matrix
How do you solve a matrix equation for an unknown symbolic matrix? I have read the documentation on symbolic matrix calcs, and the documentation of linear algebra / systems of linear equations, but can't work out how to do what I want.
For example given the matrix equation
y = Ax, where
x are column vectors with (say) 2 rows, and A is a 2x2 matrix, I can symbolically solve this equation as follows:
A = matrix(SR, 2, 2, [[var('a'),var('b')],[var('c'),var('d')]]) y = vector([var('y1'), var('y2')]) # Solve for x such thay Ax = y: x = A.solve_right(y)
Which will give me an expression for each of the elements of
x in terms of
[a, b, c, d] and the elements of
Question: how to I get an expression for the elements of
[a, b, c, d], for a given (symbolic)
y. Below is a concrete trivial example where the answer is obviously
[a=1, b=1, c=1, d=-1], but how could I solve for these elements in sagemath?
A = matrix(SR, 2, 2, [[var('a'), var('b')],[var('c'), var('d')]]) x = vector(SR, [var('x1'), var('x2')]) y = vector(SR, [x1 + x2, x1-x2]) #solve(A*x == y, A) # <= This doesn't work #solve(A*x == y, ['a', 'b', 'c', 'd']) # <= Nor does this
I think I could probably do it by looping through each row (equation) in the system of equations, and generating a list of equations and then solving those for the unknowns, but was wondering if there's a better way?