Package sage :: Package quadratic_forms :: Module binary_qf :: Class BinaryQF
[hide private]
[frames] | no frames]

Class BinaryQF

source code

                      object --+    
                               |    
structure.sage_object.SageObject --+
                                   |
                                  BinaryQF


BinaryQF([a,b,c])

INPUT:
    v -- a list of 3 entries:  [a,b,c]

OUTPUT:
    the binary quadratic form a*x^2 + b*x*y + c*y^2.

EXAMPLES:
    sage: b = BinaryQF([1,2,3])
    sage: b.discriminant()
    -8        



Instance Methods [hide private]
 
__init__(a=..., b=..., c=...)
Creates the binary quadratic form $ax^2 + bxy + cy^2$ from the triple [a,b,c] over IntegerRing().
source code
 
__getitem__(self, n)
Return the n-th component of this quadratic form.
source code
 
__call__(self, *args)
Evaluate this quadratic form at a point.
source code
 
__cmp__(self, right)
Returns True if self and right are identical: the same coefficients.
source code
 
__add__(self, Q)
Returns the component-wise sum of two forms.
source code
 
__sub__(self, Q)
Returns the component-wise difference of two forms.
source code
 
_repr_(self)
Display the quadratic form.
source code
 
polynomial(self)
Returns the binary quadratic form as a homogeneous 2-variable polynomial.
source code
 
discriminant(self)
Returns the discriminant $b^2 - 4ac$ of the binary form $ax^2 + bxy + cy^2$.
source code
 
has_fundamental_discriminant(self)
Checks if the discriminant D of this form is a fundamantal discriminant (i.e.
source code
 
is_weakly_reduced(self)
Checks if the form $ax^2 + bxy + cy^2$ satisfies $|b| \leq a \leq c$, i.e., is weakly reduced.
source code
 
reduce(self)
EXAMPLES:...
source code
 
is_reduced(self)
Checks if the quadratic form is reduced, i.e., if the form $ax^2 + bxy + cy^2$ satisfies $|b|\leq a \leq c$, and that $b\geq 0$ if either $a = b$ or $a = c$.
source code
 
complex_point(self)
Returns the point in the complex upper half-plane associated to this (positive definite) quadratic form).
source code

Inherited from structure.sage_object.SageObject: __hash__, __new__, __repr__, _axiom_, _axiom_init_, _gap_, _gap_init_, _gp_, _gp_init_, _interface_, _interface_init_, _interface_is_cached_, _kash_, _kash_init_, _macaulay2_, _macaulay2_init_, _magma_, _magma_init_, _maple_, _maple_init_, _mathematica_, _mathematica_init_, _maxima_, _maxima_init_, _octave_, _octave_init_, _pari_, _pari_init_, _r_init_, _sage_, _singular_, _singular_init_, category, db, dump, dumps, plot, rename, reset_name, save, version

Inherited from object: __delattr__, __getattribute__, __reduce__, __reduce_ex__, __setattr__, __str__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(a=..., b=..., c=...)
(Constructor)

source code 

Creates the binary quadratic form $ax^2 + bxy + cy^2$ from the
triple [a,b,c] over IntegerRing().

EXAMPLES:
    sage: Q = BinaryQF([1,2,3])
    sage: Q
    x^2 + 2*x*y  + 3*y^2
    sage: Q = BinaryQF([1,2])
    Traceback (most recent call last):
    ...
    ValueError: Binary quadratic form must be given by a list of three coefficients

Overrides: object.__init__

__getitem__(self, n)
(Indexing operator)

source code 

Return the n-th component of this quadratic form.

If this form is $a x^2 + b x y + c y^2$, the 0-th component is $a$,
the 1-st component is $b$, and $2$-nd component is $c$.

Indexing is like lists -- negative indices and slices are allowed.

EXAMPLES:
    sage: Q = BinaryQF([2,3,4])
    sage: Q[0]
    2
    sage: Q[2]
    4
    sage: Q[:2]
    (2, 3)
    sage: tuple(Q)
    (2, 3, 4)
    sage: list(Q)
    [2, 3, 4]

__call__(self, *args)
(Call operator)

source code 

Evaluate this quadratic form at a point.

INPUT:
    args -- x and y values, often as a pair x, y or a list [x, y]

EXAMPLES:
    sage: Q = BinaryQF([2,3,4])
    sage: Q(1, 2)
    24

__cmp__(self, right)
(Comparison operator)

source code 

Returns True if self and right are identical: the same coefficients.

EXAMPLES:
    sage: P = BinaryQF([2,2,3])
    sage: Q = BinaryQF([2,2,3])
    sage: R = BinaryQF([1,2,3])
    sage: P == Q # indirect doctest
    True
    sage: P == R # indirect doctest
    False

TESTS:
    sage: P == P
    True
    sage: Q == P
    True
    sage: R == P
    False
    sage: P == 2
    False

__add__(self, Q)
(Addition operator)

source code 

Returns the component-wise sum of two forms.

That is, given $a_1 x^2 + b_1 x y + c_1 y^2$ and $a_2 x^2 + b_2 x y +
c_2 y^2$, returns the form
$$(a_1 + a_2) x^2 + (b_1 + b_2) x y + (c_1 + c_2) y^2 .$$

EXAMPLES:
    sage: P = BinaryQF([2,2,3]); P
    2*x^2 + 2*x*y + 3*y^2
    sage: Q = BinaryQF([-1,2,2]); Q
    -x^2 + 2*x*y + 2*y^2
    sage: P + Q
    x^2 + 4*x*y + 5*y^2
    sage: P + Q == BinaryQF([1,4,5]) # indirect doctest
    True

TESTS:
    sage: Q + P == BinaryQF([1,4,5]) # indirect doctest
    True

__sub__(self, Q)
(Subtraction operator)

source code 

Returns the component-wise difference of two forms.

That is, given $a_1 x^2 + b_1 x y + c_1 y^2$ and $a_2 x^2 + b_2 x y +
c_2 y^2$, returns the form
$$(a_1 - a_2) x^2 + (b_1 - b_2) x y + (c_1 - c_2) y^2 .$$

EXAMPLES:
    sage: P = BinaryQF([2,2,3]); P
    2*x^2 + 2*x*y + 3*y^2
    sage: Q = BinaryQF([-1,2,2]); Q
    -x^2 + 2*x*y + 2*y^2
    sage: P - Q
    3*x^2 + y^2
    sage: P - Q == BinaryQF([3,0,1]) # indirect doctest
    True

TESTS:
    sage: Q - P == BinaryQF([3,0,1]) # indirect doctest
    False
    sage: Q - P != BinaryQF([3,0,1]) # indirect doctest
    True

_repr_(self)

source code 

Display the quadratic form.

EXAMPLES:
    sage: Q = BinaryQF([1,2,3]); Q # indirect doctest
    x^2 + 2*x*y + 3*y^2

    sage: Q = BinaryQF([-1,2,3]); Q
    -x^2 + 2*x*y + 3*y^2

    sage: Q = BinaryQF([0,0,0]); Q
    0

polynomial(self)

source code 

Returns the binary quadratic form as a homogeneous 2-variable
polynomial.

EXAMPLES:
    sage: Q = BinaryQF([1,2,3])
    sage: Q.polynomial()
    x^2 + 2*x*y + 3*y^2

    sage: Q = BinaryQF([-1,-2,3])
    sage: Q.polynomial()
    -x^2 - 2*x*y + 3*y^2

    sage: Q = BinaryQF([0,0,0])
    sage: Q.polynomial()
    0

discriminant(self)

source code 

Returns the discriminant $b^2 - 4ac$ of the binary
form $ax^2 + bxy + cy^2$.

EXAMPLES:
    sage: Q = BinaryQF([1,2,3])
    sage: Q.discriminant()
    -8

has_fundamental_discriminant(self)

source code 

Checks if the discriminant D of this form is a fundamantal
discriminant (i.e. D is the smallest element of its
squareclass with D = 0 or 1 mod 4).

EXAMPLES:
    sage: Q = BinaryQF([1,0,1])
    sage: Q.discriminant()
    -4
    sage: Q.has_fundamental_discriminant()
    True

    sage: Q = BinaryQF([2,0,2])
    sage: Q.discriminant()
    -16
    sage: Q.has_fundamental_discriminant()
    False

is_weakly_reduced(self)

source code 

Checks if the form $ax^2 + bxy + cy^2$  satisfies
$|b| \leq a \leq c$, i.e., is weakly reduced. 

EXAMPLES:
    sage: Q = BinaryQF([1,2,3])
    sage: Q.is_weakly_reduced()
    False

    sage: Q = BinaryQF([2,1,3])
    sage: Q.is_weakly_reduced()
    True

    sage: Q = BinaryQF([1,-1,1])
    sage: Q.is_weakly_reduced()
    True

reduce(self)

source code 

EXAMPLES:
    sage: a = BinaryQF([37,17,2])
    sage: a.is_reduced()
    False
    sage: b = a.reduce(); b
    x^2 + x*y + 2*y^2
    sage: b.is_reduced()
    True

is_reduced(self)

source code 

Checks if the quadratic form is reduced, i.e., if the form
$ax^2 + bxy + cy^2$ satisfies $|b|\leq a \leq c$, and
that $b\geq 0$ if either $a = b$ or $a = c$.

EXAMPLES:
    sage: Q = BinaryQF([1,2,3])
    sage: Q.is_reduced()
    False

    sage: Q = BinaryQF([2,1,3])
    sage: Q.is_reduced()
    True

    sage: Q = BinaryQF([1,-1,1])
    sage: Q.is_reduced()
    False

    sage: Q = BinaryQF([1,1,1])
    sage: Q.is_reduced()
    True

complex_point(self)

source code 

Returns the point in the complex upper half-plane associated
to this (positive definite) quadratic form).

For positive definite forms with negative discriminants, this is a
root $  au$ of $a x^2 + b x + c$ with the imaginary part of $   au$
greater than 0.

EXAMPLES:
    sage: Q = BinaryQF([1,0,1])
    sage: Q.complex_point()
    1.00000000000000*I