Skip to content

Improve performance of field_pretty for multiquadratic fields#7013

Open
rvisser7 wants to merge 4 commits into
LMFDB:mainfrom
rvisser7:fast_multiquad
Open

Improve performance of field_pretty for multiquadratic fields#7013
rvisser7 wants to merge 4 commits into
LMFDB:mainfrom
rvisser7:fast_multiquad

Conversation

@rvisser7
Copy link
Copy Markdown
Member

@rvisser7 rvisser7 commented May 16, 2026

This PR makes some improvements to the field_pretty function in web_number_field.py, which computes latex names for certain number fields. In particular, it makes computing the latex names for biquadratic and more general multi-quadratic fields slightly more efficient.

For quadratic fields, the computation of the $D$ in $Q(\sqrt{D})$ is now taken directly from the label (instead of calling WebNumberField), and the linear algebra for the multi-quadratic case is now done directly using bitwise XOR on integers (where we store a vector over F_2 just as a integer, where the bits are the entries of the vector), instead of calling Sage's general linear algebra methods.

The main motivation for this is to speed up the rendering time of the homepage for the degree 32 multi-quadratic field $Q(i, \sqrt{2}, \sqrt{3}, \sqrt{5}, \sqrt{7})$:

https://www.lmfdb.org/NumberField/32.0.4026692887688564776141139207792885760000000000000000.1 (prod)
https://beta.lmfdb.org/NumberField/32.0.4026692887688564776141139207792885760000000000000000.1 (beta)
http://localhost:37777/NumberField/32.0.4026692887688564776141139207792885760000000000000000.1 (new)

which requires computing not just the latex name for this field, but the latex name for all 372 subfields!

At the moment, this takes ~12 seconds to load on production, and ~8 seconds to load on beta, assuming the latex names haven't been cached yet. From my testing, this PR now takes ~4 seconds to load, before caching. But hopefully this will load even faster on beta. Still not ideal, but at least an improvement from the current implementation. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant