1 | initial version |
Try this :
sage: A=matrix([[var("a_{}_{}".format(u,v)) for v in (1..2)] for u in (1..2)]);A
[a_1_1 a_1_2]
[a_2_1 a_2_2]
sage: X=vector([var("x_{}".format(u)) for u in (1..2)]);X
(x_1, x_2)
sage: Y=vector([var("y_{}".format(u)) for u in (1..2)]);Y
(y_1, y_2)
sage: Sol=solve(map(lambda u,v:u==v, A*X, Y),[u for u in X]);Sol
[[x_1 == -(a_2_2*y_1 - a_1_2*y_2)/(a_1_2*a_2_1 - a_1_1*a_2_2), x_2 == (a_2_1*y_1 - a_1_1*y_2)/(a_1_2*a_2_1 - a_1_1*a_2_2)]]
i. e. $$\left[\left[x_{1} = -\frac{a_{2_{2}} y_{1} - a_{1_{2}} y_{2}}{a_{1_{2}} a_{2_{1}} - a_{1_{1}} a_{2_{2}}}, x_{2} = \frac{a_{2_{1}} y_{1} - a_{1_{1}} y_{2}}{a_{1_{2}} a_{2_{1}} - a_{1_{1}} a_{2_{2}}}\right]\right]$$.
which looks entirely reasonable...
HTH,
2 | No.2 Revision |
Try this :
sage: A=matrix([[var("a_{}_{}".format(u,v)) A=matrix([[var("a_{}_{}".format(u,v), latex_name="a_{{{},{}}}".format(u,v)) for v in (1..2)] for u in (1..2)]);A
[a_1_1 a_1_2]
[a_2_1 a_2_2]
sage: X=vector([var("x_{}".format(u)) for u in (1..2)]);X
(x_1, x_2)
sage: Y=vector([var("y_{}".format(u)) for u in (1..2)]);Y
(y_1, y_2)
sage: Sol=solve(map(lambda u,v:u==v, A*X, Y),[u for u in X]);Sol
[[x_1 == -(a_2_2*y_1 - a_1_2*y_2)/(a_1_2*a_2_1 - a_1_1*a_2_2), x_2 == (a_2_1*y_1 - a_1_1*y_2)/(a_1_2*a_2_1 - a_1_1*a_2_2)]]
i. e. $$\left[\left[x_{1} = -\frac{a_{2_{2}} -\frac{{a_{2,2}} y_{1} - a_{1_{2}} y_{2}}{a_{1_{2}} a_{2_{1}} {a_{1,2}} y_{2}}{{a_{1,2}} {a_{2,1}} - a_{1_{1}} a_{2_{2}}}, {a_{1,1}} {a_{2,2}}}, x_{2} = \frac{a_{2_{1}} \frac{{a_{2,1}} y_{1} - a_{1_{1}} y_{2}}{a_{1_{2}} a_{2_{1}} {a_{1,1}} y_{2}}{{a_{1,2}} {a_{2,1}} - a_{1_{1}} a_{2_{2}}}\right]\right]$$.{a_{1,1}} {a_{2,2}}}\right]\right]$$.
which looks entirely reasonable...
HTH,