I have to find a vector and a matrix that transform some input vectors into others. The input vectors are: (−3, 4), (0, 8) i (6, 6) and the output for each vector is (1, −4), (6, −4) i (8, 2).
That's what i've tried: `
var('a b c d e f')
p = matrix([[-3,4],[0,8],[6,6]]).T
p2 = matrix([[1,-4],[6,-4],[8,2]]).T
q = vector([a,b])
t = matrix([[c,d],[e,f]])
eqs = [p2[i,j] == q[i] + t[i,:]*p[:,j] for i in range(2) for j in range(2)]
show(eqs)
solve(eqs,[a,b,c,d,e,f])
But when i say show(eqs) the output is [False,False,False,False] instead of the actual equations. Why?
I've tried the code above. I expect some feedback that can make me understand the error in the code.
The problem is that you're adding scalars and matrices:
p2[i,j]is a scalar, as isq[i], butt[i,:]*p[:,j]is a1x1matrix:type(p2[1,1])will return<class 'sage.rings.integer.Integer'>andtype(q[0])will return<class 'sage.symbolic.expression.Expression'>, buttype(t[i,:]*p[:,j])will return<class 'sage.matrix.matrix_symbolic_dense.Matrix_symbolic_dense'>. Try using the only entry in that matrix instead, either by explicitly pulling out the[0,0]entry or by converting the row oftand the column ofp2to vectors and using a dot product: useor