Opened 10 years ago

Closed 10 years ago

# Fix negation of Jacobian morphisms

Reported by: Owned by: SimonKing AlexGhitza major sage-5.9 algebra Jacobian morphism sage-5.9.beta4 Simon King Travis Scrimshaw N/A

The following fails with a coercion error:

```            sage: P.<x> = QQ[]
sage: f = x^5 - x + 1; h = x
sage: C = HyperellipticCurve(f,h,'u,v')
sage: J = C.jacobian()
sage: K.<t> = NumberField(x^2-2)
sage: R.<x> = K[]
sage: Q = J(K)([x^2-t,R(1)])
sage: Q
(u^2 - t, v - 1)
sage: -Q
(u^2 - t, v + u + 1)
```

The reason is that in the `__neg__` method, the remainder of a polynomial h over the rationals is computed modulo a non-constant polynomial over a number field. The involved `__mod__` method of FLINT polynomials would try to coerce the modulus into the parent of h, which fails here for obvious reasons.

I see two possible solutions:

1. Make sure in `JacobianMorphism_divisor_class_field.__neg__` that h and the modulus live in the same ring, e.g., by adding the modulus to h before computing the remainder (which won't change the result).
2. In the `__mod__` method of FLINT polynomials, invoke coercion_model.canonical_coercion on h and the modulus, rather than trying to coerce the modulus into the parent of h.

With the second approach, the output of `__mod__` would potentially live in a different ring (which should not be the case!) and it would imply a general slowdown of the `__mod__` method. Therefore I prefer the first approach.

### comment:1 Changed 10 years ago by SimonKing

Authors: → Simon King new → needs_review

### comment:2 Changed 10 years ago by SimonKing

Description: modified (diff)

I think the old formulation at the end of the ticket description was misleading.

### comment:3 Changed 10 years ago by SimonKing

Description: modified (diff)

### comment:4 Changed 10 years ago by tscrim

Reviewers: → Travis Scrimshaw needs_review → positive_review

Looks good to me.

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

Merged in: → sage-5.9.beta4 → fixed positive_review → closed
Note: See TracTickets for help on using tickets.