Opened 10 years ago

Closed 9 years ago

abs floor ceil for quadratic number field

Reported by: Owned by: vdelecroix vdelecroix major sage-5.11 number fields absolute value, floor, ceiling, number field, quadratic mhansen, berocal sage-5.11.beta0 Vincent Delecroix Frédéric Chapoton N/A #13213

Implementation of absolute value (abs), floor (floor) and ceiling (ceil) function for elements in quadratic number field.

The implementation uses only manipulation of (mpz) integers.

The function abs depends on the function sign implemented in ticket #13213.

comment:1 Changed 10 years ago by vdelecroix

• Description modified (diff)
• Status changed from new to needs_review

comment:2 follow-up: ↓ 3 Changed 9 years ago by kcrisman

Does the removal of

```K.<a> = NumberField(x^2+1, embedding=CDF.gen())
```

as an example mean that one couldn't use this syntax at all any more? Would number fields from quadratics not automatically be quadratic fields (when mathematically appropriate, I'm excluding `x^2-1` and the like) and inherit these methods, or would that simply not work now?

comment:3 in reply to: ↑ 2 Changed 9 years ago by vdelecroix

Does the removal of

```K.<a> = NumberField(x^2+1, embedding=CDF.gen())
```

as an example mean that one couldn't use this syntax at all any more?

This syntax is still available. The patch only aims to implement methods abs, floor and ceil for quadratic elements. As an example

```sage: K.<sqrt2> = QuadraticField(2)
sage: sqrt2.floor()
1
```

It is yet possible (without the patch) to do

```sage: K.<sqrt2> = QuadraticField(2)
sage: floor(sqrt2)
1
```

But there is a simpler and faster way to do it compared to what floor does (using the real interval field with finer and finer approximations). Note that if the method .floor is present, the the function floor will use it!

Would number fields from quadratics not automatically be quadratic fields (when mathematically appropriate, I'm excluding `x^2-1` and the like) and inherit these methods, or would that simply not work now?

Yes, it is the way it is

```sage: type(NumberField(x^2 + 1, 'a'))
```

comment:4 Changed 9 years ago by vdelecroix

• Dependencies changed from #7160, #13213 to #13213
• Description modified (diff)

comment:5 Changed 9 years ago by vdelecroix

The patch now takes care of the new doctest framework (ie replace "..." by "....:" for multiline tests).

comment:6 Changed 9 years ago by chapoton

I have made a short review patch, with correct links to trac and raise statements.

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

• Reviewers set to Frédéric Chapoton
• Status changed from needs_review to positive_review

ok, looks good to me. Positive review.

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

ok, looks good to me. Positive review.

Cool. Thanks Frédéric.

comment:9 Changed 9 years ago by jdemeyer

• Milestone changed from sage-5.10 to sage-5.11

comment:10 Changed 9 years ago by jdemeyer

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