| 1483 | def bilinear_map(self,v,w): |

| 1484 | """ |

| 1485 | Given a quadratic form `Q', this gives the image of two vectors in `Q` under the associated bilinear map. |

| 1486 | INPUT: |

| 1487 | |

| 1488 | -`v,w`-- vectors. |

| 1489 | -`Q`-- Quadratic Form |

| 1490 | |

| 1491 | OUTPUT: |

| 1492 | |

| 1493 | element of the base ring of `Q`. |

| 1494 | |

| 1495 | EXAMPLES:: |

| 1496 | |

| 1497 | sage: Q=QuadraticForm(ZZ,3,[1,4,0,1,4,1]) |

| 1498 | sage: v=vector((1,2,0));w=vector((0,1,1)) |

| 1499 | sage: Q.bilinear_map(v,w) |

| 1500 | 8 |

| 1501 | |

| 1502 | :: |

| 1503 | |

| 1504 | sage: Q=QuadraticForm(QQ,2,[1/2,2,1]) |

| 1505 | sage: v=vector(QQ,(1,1)) |

| 1506 | sage: w=vector(QQ,(1/2,2)) |

| 1507 | sage: Q.bilinear_map(v,w) |

| 1508 | 19/4 |

| 1509 | |

| 1510 | :: |

| 1511 | |

| 1512 | sage: Q=DiagonalQuadraticForm(ZZ,[1,7,7]) |

| 1513 | sage: v=vector((1,2)) |

| 1514 | sage: w=vector((1,1,1)) |

| 1515 | sage: Q.bilinear_map(v,w) |

| 1516 | (<type 'exceptions.TypeError'>, 'Bilinear form can only be evaluated on vectors with length 3.') |

| 1517 | |

| 1518 | """ |

| 1519 | if len(v)!=self.dim() or len(w)!=self.dim(): |

| 1520 | return TypeError, "Bilinear form can only be evaluated on vectors with length " + str(self.dim()) + "." |

| 1521 | else: |

| 1522 | return (self(v+w)-self(v)-self(w))/2 |

| 1523 | |

| 1524 | |