Skip to content

Add Unique Hess Jacobian model, and some cleanup to function fields code#41453

Merged
vbraun merged 67 commits intosagemath:developfrom
vincentmacri:function-field-jacobians
Feb 25, 2026
Merged

Add Unique Hess Jacobian model, and some cleanup to function fields code#41453
vbraun merged 67 commits intosagemath:developfrom
vincentmacri:function-field-jacobians

Conversation

@vincentmacri
Copy link
Copy Markdown
Member

@vincentmacri vincentmacri commented Jan 15, 2026

This PR adds an optimized polished implementation of the Unique Hess Jacobian model from my Master's thesis. This model is similar to the existing Hess model we have, but uses a different algorithm for reduction that gives unique representatives of divisor classes. The existing Hess model and Khuri-Makdisi models that are already in Sage do not give unique representatives, and so are not hashable and cannot be used in sets or dictionaries (we previously had an incorrect hash implementation for these models which I removed because they are inherently not hashable).

In order to minimize duplication with the existing Hess model I moved some the _normalize method to a new Cython file, which should also speed it up. I made a few other refactoring changes along the way to simplify the code, especially by moving generic code to the FunctionField class that was previously repeated in RationalFunctionField and FunctionField_polymod. I also added a lot of type annotation to the function fields code.

Despite all the refactoring, the only breaking changes are deprecations of unnecessary functions (and removal of the broken hash functions for the Hess and Khuri-Makdisi models). For example, Jacobian elements had a multiple method that does the same thing as self * n, so I deprecated that (after fixing some coercion issues that make n * self slower than it should have been).

For reviewers: pretty much all the "new" code is in src/sage/rings/function_field/jacobian_unique_hess.py and everything else is refactoring/optimization (and some changes to the jacobian method in src/sage/rings/function_field/function_field.py to add the ability to construct the new Jacobian model). I'm submitting it as one PR rather than two so that there is context for why I'm refactoring the code.

📝 Checklist

  • The title is concise and informative.
  • The description explains in detail what this PR is about.
  • I have linked a relevant issue or discussion.
  • I have created tests covering the changes.
  • I have updated the documentation and checked the documentation preview.

⌛ Dependencies

@vincentmacri vincentmacri changed the title Add Unique Hess Jacobian model, and some cleanup up function fields code Add Unique Hess Jacobian model, and some cleanup up to function fields code Jan 15, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Jan 15, 2026

Documentation preview for this PR (built with commit cac3ded; changes) is ready! 🎉
This preview will update shortly after each push to this PR.

@vincentmacri vincentmacri changed the title Add Unique Hess Jacobian model, and some cleanup up to function fields code Add Unique Hess Jacobian model, and some cleanup to function fields code Jan 19, 2026
@vincentmacri
Copy link
Copy Markdown
Member Author

@kwankyu Would you be able to review this?

Comment thread src/sage/rings/function_field/jacobian_khuri_makdisi.py
Comment thread src/sage/rings/function_field/divisor.py
@vincentmacri vincentmacri requested a review from kwankyu February 20, 2026 03:32
Copy link
Copy Markdown
Collaborator

@kwankyu kwankyu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I am happy that existing doctests not only pass but also often run faster than previously.

vbraun pushed a commit to vbraun/sage that referenced this pull request Feb 20, 2026
sagemathgh-41453: Add Unique Hess Jacobian model, and some cleanup to function fields code
    
<!-- ^ Please provide a concise and informative title. -->
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes sagemath#12345". -->

This PR adds an optimized polished implementation of the Unique Hess
Jacobian model from [my Master's thesis](https://ucalgary.scholaris.ca/i
tems/00115cc7-cf9d-49d9-9185-77d3eb2d58e7). This model is similar to the
existing Hess model we have, but uses a different algorithm for
reduction that gives unique representatives of divisor classes. The
existing Hess model and Khuri-Makdisi models that are already in Sage do
not give unique representatives, and so are not hashable and cannot be
used in sets or dictionaries (we previously had an incorrect hash
implementation for these models which I removed because they are
inherently not hashable).

In order to minimize duplication with the existing Hess model I moved
some the `_normalize` method to a new Cython file, which should also
speed it up. I made a few other refactoring changes along the way to
simplify the code, especially by moving generic code to the
`FunctionField` class that was previously repeated in
`RationalFunctionField` and `FunctionField_polymod`. I also added a lot
of type annotation to the function fields code.

Despite all the refactoring, the only breaking changes are deprecations
of unnecessary functions (and removal of the broken hash functions for
the Hess and Khuri-Makdisi models). For example, Jacobian elements had a
`multiple` method that does the same thing as `self * n`, so I
deprecated that (after fixing some coercion issues that make `n * self`
slower than it should have been).

For reviewers: pretty much all the "new" code is in
`src/sage/rings/function_field/jacobian_unique_hess.py` and everything
else is refactoring/optimization (and some changes to the `jacobian`
method in `src/sage/rings/function_field/function_field.py` to add the
ability to construct the new Jacobian model). I'm submitting it as one
PR rather than two so that there is context for why I'm refactoring the
code.

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [x] I have created tests covering the changes.
- [x] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#41453
Reported by: Vincent Macri
Reviewer(s): Kwankyu Lee, Vincent Macri
@vincentmacri
Copy link
Copy Markdown
Member Author

LGTM. I am happy that existing doctests not only pass but also often run faster than previously.

Thank you so much for the review!

@vbraun vbraun merged commit 3bf3d56 into sagemath:develop Feb 25, 2026
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants