Opened 7 years ago

# Comparisons in real number field — at Version 3

Reported by: Owned by: vdelecroix vdelecroix major sage-5.10 number fields real number field, comparison Vincent Delecroix N/A

Provide the order from RR for number field embedded in RR as in

```sage: K.<sqrt2> = NumberField(x^2 - 2, 'sqrt2', embedding=1.4142)
sage: sqrt2 - 1 > 0
True
sage: sqrt2 < 2
True
```

There is a patch for quadratic field. Another one is comming for general number fields. Note that this patch is partly a duplicate because of #7160.

Timings with the patch

```sage: K.<sqrt2> = QuadraticField(2,'sqrt2',embedding=1.4142)
sage: b = (5*sqrt2 + 14)/5
sage: a = (3*sqrt2 + 18)/7
sage: %timeit a < b
625 loops, best of 3: 6.68 µs per loop
```

Timings without the patch

```sage: sage: K.<sqrt2> = QuadraticField(2,'sqrt2',embedding=1.4142)
sage: a = (3*sqrt2 + 18)/7
sage: b = (5*sqrt2 + 14)/5
sage: %timeit a < b
625 loops, best of 3: 478 ns per loop
```

### comment:1 Changed 7 years ago by aapitzsch

• Authors changed from vdelecroix to Vincent Delecroix

I had a short look at your patch. Could you use Python 3 compatible syntax to raise errors. E.g.

```raise ValueError("absolute value not implemented for complex embeddings")
```

### comment:2 Changed 7 years ago by vdelecroix

• Description modified (diff)

### comment:3 Changed 7 years ago by vdelecroix

• Description modified (diff)
Note: See TracTickets for help on using tickets.