Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The inner_product is the implemented method in this case, for instance:

sage: x=vector((1,2,3)); y=vector((2,3,11))
sage: x.inner_product(y)
41

(That 11 instead of the one in the postshould make the result bigger and avoid "coincidences".)

An explicit check:

sage: sum( [x[k]*y[k] for k in range(len(x)) ] )
41

(The range(len(x)) could have been simply (0,1,2) in this simple case.)

The inner_product is the implemented method in this case, the case of the $(1,1,1)$, for instance:

sage: x=vector((1,2,3)); y=vector((2,3,11))
sage: x.inner_product(y)
41

(That 11 instead of the one in the postshould make the result bigger and avoid "coincidences".)

An explicit check:

sage: sum( [x[k]*y[k] for k in range(len(x)) ] )
41

The line in the explicit check may be used also with slight changes. Or use simply the matrix giving the bilinear form, in the same spirit:

sage: PHI = diagonal_matrix( 3, [1,-1,1] )
sage: x * PHI * y.column()
(29)
sage: sum( [ (-1)^k*x[k]*y[k] for k in range(len(x)) ] )
29
sage: ( x*PHI ).inner_product(y) 
29

Above, y.column() is the column vector related to y.

sage: y.column()
[ 2]
[ 3]
[11]

(The range(len(x)) could have been simply (0,1,2) in this simple case.)

The inner_product is the implemented method in the case of the $(1,1,1)$, phi associated to the $(1,1,1)$ diagonal matrix, for instance:

sage: x=vector((1,2,3)); y=vector((2,3,11))
sage: x.inner_product(y)
41

(That 11 instead of the one in the postshould make the result bigger and avoid "coincidences".)

An explicit check:

sage: sum( [x[k]*y[k] for k in range(len(x)) ] )
41

The line in the explicit check may be used also with slight changes. Or use (The range(len(x)) could have been simply (0,1,2) in this simple case.)

In the more general case the matrix giving the bilinear form, form can be inserted, we have in the same spirit:

sage: PHI = diagonal_matrix( 3, [1,-1,1] )
sage: x * PHI * y.column()
(29)
sage: sum( [ (-1)^k*x[k]*y[k] for k in range(len(x)) ] )
29
sage: ( x*PHI ).inner_product(y) 
29

Above, y.column() is the column vector related to y.

sage: y.column()
[ 2]
[ 3]
[11]

(The range(len(x)) could have been simply (0,1,2) in this simple case.)