Opened 5 years ago

Closed 5 years ago

## #25023 closed enhancement (fixed)

Reported by: Owned by: annahaensch major sage-8.2 number fields Anna Haensch Simon Brandhorst N/A 56283fe 56283fe849868db720531ad45364aa247050247a

### Description

Computes the quadratic defect (see O'Meara Section 63A) of a number field element locally at a prime p. This is an implementation of Algorithm 3.1.3 from Kirschmer's "Definite quadratic and hermitian forms with small class number."

The function returns the valuation of the quadratic defect (rather than the fractional ideal itself) since this is the more relevant (and computationally useful) piece of information.

### comment:2 Changed 5 years ago by annahaensch

Commit: → a140e55ed69a77b79bacdc0a1f68a316868f561d new → needs_review

New commits:

 ​2e4fc4f `adds imports to number_field.py` ​a140e55 `adds quadratic_defect`

### comment:3 Changed 5 years ago by sbrandhorst

Status: needs_review → needs_work

over `QQ`: do not use quadratic_residues as that forms a list of size (p-1)/2 this is not necessary. You can use legendre_symbol or reduce mod p and then use is_square (like over numberfields)

Your method quadratic_defect sits in the wrong class. (NumberField_quadratic) so it is not accessible in general. For example we can move it to NumberField_generic.

```+                    if w < u and w % 2 ==1:
+                        d = v+w
+                    if w == u and (f+F((a-1)/4)).is_irreducible():
+                        d = v+w
```

You sure this is correct ?(I did not fully check).

• the reference to kirschmers work should be a proper citation in src/doc/en/reference/references

Could you explain why you consider the valuation more useful than the quadratic_defect itself?

### comment:4 Changed 5 years ago by sbrandhorst

Reviewers: → Simon Brandhorst

### comment:5 Changed 5 years ago by git

Commit: a140e55ed69a77b79bacdc0a1f68a316868f561d → e419b36841853392158db03d38ba6e006ea5d4d7

Branch pushed to git repo; I updated commit sha1. New commits:

 ​e419b36 `Changes to quadrati_defect()`

### comment:6 Changed 5 years ago by annahaensch

• Updated the function in rational_field to use legendre_symbol() instead of quadratic_residue().
• I added Kirschmer's item to the reference list, and added a reference line to the documentation. I've never done this before, perhaps up can see if I did it correctly?
• I moved the number field version of the function to be in the class number_field_generic...I think. Is this accomplished by just moving the function to where that class is defined? Maybe you can check to see if I did that correctly.
• The item you point out should be correct, this should be 63:3 and 63:5 from O'meara's book on quadratic forms.

I am choosing to return a valuation since this is an easier object to deal with. Moreover, this is also what is returned by the analogous function "QuadraticDefect?" in magma (which I believe was implimented by Kirschmer).

New commits:

 ​e419b36 `Changes to quadrati_defect()`

### comment:7 Changed 5 years ago by annahaensch

Status: needs_work → needs_review

### comment:9 Changed 5 years ago by sbrandhorst

I did some cosmetic changes. Positive review if you are happy with what I have done.

### comment:10 Changed 5 years ago by git

Commit: e419b36841853392158db03d38ba6e006ea5d4d7 → 086cde098120cf2313030c28ac33e2d80cc4a579

Branch pushed to git repo; I updated commit sha1. New commits:

 ​086cde0 `Add reference to rational_field`

### comment:11 Changed 5 years ago by annahaensch

I just added the official reference to the rational_field version of the function. Now I am happy with it, and would be most pleased with a positive review. Thanks!

### comment:12 Changed 5 years ago by sbrandhorst

Status: needs_review → positive_review

### comment:14 Changed 5 years ago by sbrandhorst

 ​e5f4670 `Allowed prime ideals as input for quadratic_defect.` ​b5fd719 `Merge branch 'u/annahaensch/adds_function_to_compute_quadratic_defect' of git://trac.sagemath.org/sage into t/25023/adds_function_to_compute_quadratic_defect` ​56283fe `Doc syntax`