Opened 8 years ago

Closed 8 years ago

# polynomial .reduce returns type int over p-adic field

Reported by: Owned by: bhutz AlexGhitza minor sage-5.6 algebra polynomial reduce sage-5.6.beta3 John Perry Karl-Dieter Crisman N/A

### Description (last modified by kcrisman)

The .reduce() function for a polynomial ring can return an 'int' type when the base field is a p-adic field.

```R.<y1,y2>=PolynomialRing(Qp(5),2, order='lex')
G=[y1^2 + y2^2, y1*y2 + y2^2, y2^3]
type((y2^3).reduce(G))
```

It should be returning an element of the polynomial ring.

This was noticed since it causes .variety() to fail.

```R.<y1,y2>=PolynomialRing(Qp(5),2, order='lex')
G=[y1^2 + y2^2, y1*y2 + y2^2, y2^3]
I=ideal(G)
I.variety()
```

Apply:

### comment:1 Changed 8 years ago by john_perry

• Description modified (diff)

I fixed some formatting issues with the ticket description.

### comment:2 Changed 8 years ago by john_perry

• Description modified (diff)

And promptly broke them, as well. (It looked good before I hit submit, honest!) Okay, I'll try again...

I can work on this, if no one else has their heart set on it.

### comment:3 follow-up: ↓ 4 Changed 8 years ago by kcrisman

• Authors Ben Hutz deleted

Please do! If it's a simple fix of type, maybe I can review it for you.

### comment:4 in reply to: ↑ 3 Changed 8 years ago by john_perry

Replying to kcrisman:

Please do! If it's a simple fix of type, maybe I can review it for you.

It would be very easy if I could figure out how I pooched my development environment. I have a working fix, but mercurial doesn't seem to notice the changes. I hate it when this happens.

### Changed 8 years ago by john_perry

simple patch + doctest

### comment:5 Changed 8 years ago by john_perry

• Status changed from new to needs_review

I said it was an easy fix. This bug has burned me in other contexts, so it wasn't hard to find and fix.

### comment:6 Changed 8 years ago by john_perry

• Description modified (diff)

### comment:7 follow-up: ↓ 9 Changed 8 years ago by kcrisman

I still get

```sage: I=ideal(G)
sage: I.variety()
verbose 0 (3482: multi_polynomial_ideal.py, groebner_basis) Warning: falling back to very slow toy implementation.
verbose 0 (1359: multi_polynomial_ideal.py, dimension) Warning: falling back to very slow toy implementation.
verbose 0 (2365: multi_polynomial_ideal.py, variety) Warning: falling back to very slow toy implementation.
verbose 0 (3482: multi_polynomial_ideal.py, groebner_basis) Warning: falling back to very slow toy implementation.
[{y1: O(5^20), y2: O(5^20)}]
```

but presumably that's okay. I'm uploading a slight refresh of your patch to use our new(ish) `:trac:` markup, and fixed the other non-occurrence of that in the file (there were several with the new markup already).

Apply only this

### comment:8 Changed 8 years ago by kcrisman

• Authors set to John Perry
• Description modified (diff)
• Reviewers set to Karl-Dieter Crisman
• Status changed from needs_review to positive_review

Patchbot, apply trac_13903-reviewed.patch

### comment:9 in reply to: ↑ 7 Changed 8 years ago by john_perry

Replying to kcrisman:

I still get

```sage: I=ideal(G)
sage: I.variety()
verbose 0 (3482: multi_polynomial_ideal.py, groebner_basis) Warning: falling back to very slow toy implementation.
verbose 0 (1359: multi_polynomial_ideal.py, dimension) Warning: falling back to very slow toy implementation.
verbose 0 (2365: multi_polynomial_ideal.py, variety) Warning: falling back to very slow toy implementation.
verbose 0 (3482: multi_polynomial_ideal.py, groebner_basis) Warning: falling back to very slow toy implementation.
[{y1: O(5^20), y2: O(5^20)}]
```

but presumably that's okay.

If you mean that the warnings are bothering you, then yes, that's okay. Unless I misread the Singular manual, it doesn't deal with Qp, though I could be wrong (I know next to nothing about p-adics, and Singular does deal with Zp). If Singular DOES implement Qp, then we haven't yet implemented that interface. That should be another ticket, though, because this bug would likely pop up even if we weren't in Qp.

I'm uploading a slight refresh of your patch to use our new(ish) :trac: markup...

Hunh. I didn't know about that. I wonder if I can remember it for the future... `;-)`

### comment:10 Changed 8 years ago by bhutz

Thanks. This looked good on my tests as well.

Yes, that result from .variety() is the correct final answer, well really the result is the point (1:0:0) in projective space Qp, but up to precision that is what is returned. The warnings I ignored ;)

### comment:11 Changed 8 years ago by jdemeyer

• Merged in set to sage-5.6.beta3
• Resolution set to fixed
• Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.