Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Assuming phi is bilinear, one possibility is

sage: Q3 = FiniteRankFreeModule(QQ, 3, 'Q^3', start_index=1)
sage: e = Q3.basis('e') # Q^3 canonical basis
sage: phi = Q3.tensor((0,2))
sage: phi[1,1], phi[2,2], phi[3,3] = 1, -1, 1
sage: phi
Type-(0,2) tensor on the 3-dimensional vector space Q^3 over the Rational Field
sage: phi.display()
e^1*e^1 - e^2*e^2 + e^3*e^3
sage: x = Q3((1,2,3)); x
Element of the 3-dimensional vector space Q^3 over the Rational Field
sage: y = Q3((2,3,1))
sage: phi(x,y)
-1

Assuming phi is bilinear, one possibility is

sage: Q3 = FiniteRankFreeModule(QQ, 3, 'Q^3', start_index=1)
sage: e = Q3.basis('e') # Q^3 canonical basis
sage: phi = Q3.tensor((0,2))
sage: phi[1,1], phi[2,2], phi[3,3] = 1, -1, 1
sage: phi
Type-(0,2) tensor on the 3-dimensional vector space Q^3 over the Rational Field
sage: phi.display()
e^1*e^1 - e^2*e^2 + e^3*e^3
sage: x = Q3((1,2,3)); x
Element of the 3-dimensional vector space Q^3 over the Rational Field
sage: y = Q3((2,3,1))
sage: phi(x,y)
-1
sage: phi(x,y) == x[1]*y[1] - x[2]*y[2] + x[3]*y[3]
True