# Creating A Random Quadratic Form¶

Create a random quadratic form in $$n$$ variables defined over the ring $$R$$.

The last (and optional) argument rand_arg_list is a list of at most 3 elements which is passed (as at most 3 separate variables) into the method R.random_element().

INPUT:

• $$R$$ – a ring.
• $$n$$ – an integer $$\ge 0$$
• rand_arg_list – a list of at most 3 arguments which can be taken by R.random_element().

OUTPUT:

A quadratic form over the ring $$R$$.

EXAMPLES:

sage: random_quadraticform(ZZ, 3, [1,5])    ## RANDOM
Quadratic form in 3 variables over Integer Ring with coefficients:
[ 3 2 3 ]
[ * 1 4 ]
[ * * 3 ]

sage: random_quadraticform(ZZ, 3, [-5,5])    ## RANDOM
Quadratic form in 3 variables over Integer Ring with coefficients:
[ 3 2 -5 ]
[ * 2 -2 ]
[ * * -5 ]

sage: random_quadraticform(ZZ, 3, [-50,50])    ## RANDOM
Quadratic form in 3 variables over Integer Ring with coefficients:
[ 1 8 -23 ]
[ * 0 0 ]
[ * * 6 ]


Create a random quadratic form in $$n$$ variables defined over the ring $$R$$ satisfying a list of boolean (i.e. True/False) conditions.

The conditions $$c$$ appearing in the list must be boolean functions which can be called either as Q.c() or c(Q), where Q is the random quadratic form.

The last (and optional) argument rand_arg_list is a list of at most 3 elements which is passed (as at most 3 separate variables) into the method R.random_element().

EXAMPLES:

sage: Q = random_quadraticform_with_conditions(ZZ, 3, [QuadraticForm.is_positive_definite], [-5, 5])
sage: Q    ## RANDOM
Quadratic form in 3 variables over Integer Ring with coefficients:
[ 3 -2 -5 ]
[ * 2 2 ]
[ * * 3 ]


Create a random ternary quadratic form.

The last (and optional) argument rand_arg_list is a list of at most 3 elements which is passed (as at most 3 separate variables) into the method R.random_element().

INPUT:

• rand_arg_list – a list of at most 3 arguments which can be taken by R.random_element().

OUTPUT:

EXAMPLES:

sage: random_ternaryqf()  ##RANDOM
Ternary quadratic form with integer coefficients:
[1 1 4]
[-1 1 -1]
sage: random_ternaryqf([-1, 2])  ##RANDOM
Ternary quadratic form with integer coefficients:
[1 0 1]
[-1 -1 -1]
sage: random_ternaryqf([-10, 10, "uniform"])  ##RANDOM
Ternary quadratic form with integer coefficients:
[7 -8 2]
[0 3 -6]


Create a random ternary quadratic form satisfying a list of boolean (i.e. True/False) conditions.

The conditions $$c$$ appearing in the list must be boolean functions which can be called either as Q.c() or c(Q), where Q is the random ternary quadratic form.

The last (and optional) argument rand_arg_list is a list of at most 3 elements which is passed (as at most 3 separate variables) into the method R.random_element().

EXAMPLES:

sage: Q = random_ternaryqf_with_conditions([TernaryQF.is_positive_definite], [-5, 5])
sage: Q    ## RANDOM
Ternary quadratic form with integer coefficients:
[3 4 2]
[2 -2 -1]


Some Extras

#### Next topic

Routines for computing special values of L-functions