Opened 6 months ago

Last modified 3 weeks ago

#30772 new defect

induced volume for polytopes defined over algebraic fields

Reported by: gh-LaisRast Owned by:
Priority: major Milestone: sage-9.4
Component: geometry Keywords: polytope, volume, square root, sqrt
Cc: jipilab, gh-kliem, vdelecroix, tscrim, mkoeppe Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: #3889 Stopgaps:

Status badges

Description

I have a 3-polytoe in R4 where R is some special algebraic field (see below). When trying to compute the volume(measure='induced'), the following error appears:

sage: F2.volume(measure='induced')
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
...
AttributeError: 'sage.rings.number_field.number_field_morphisms.NumberFieldEmbedding' object has no attribute 'im_gens'

To reproduce the error:

sage: x = var('x')
....: R2.<sqrt2> = NumberField(x^2 - 2, embedding=AA(2).sqrt())
....: R3.<sqrt3> = NumberField(x^2 - 3, embedding=AA(3).sqrt())
....: R5.<sqrt5> = NumberField(x^2 - 5, embedding=AA(5).sqrt())
....: R = R2.composite_fields(R3)[0].composite_fields(R5)[0]
....: R.rename('special algebraic field')
....: R.random_element().sqrt()
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
...
AttributeError: 'sage.rings.number_field.number_field_morphisms.NumberFieldEmbedding' object has no attribute 'im_gens'

So it is not a bug in Polyhedron. However, to avoid this error in Polyhedron, I suggest the following changes in Polyhedron.volume(measure='induced')

            Adet = (A.matrix().transpose() * A.matrix()).det()
-           return self.affine_hull_projection(orthogonal=True).volume(measure='ambient', engine=engine, **kwds) / sqrt(Adet)
+           try:
+               return self.affine_hull_projection(orthogonal=True).volume(measure='ambient', engine=engine, **kwds) / sqrt(Adet)
+           except:
+               return self.affine_hull_projection(orthogonal=True).volume(measure='ambient', engine=engine, **kwds) / sqrt(AA(Adet))
        elif measure == 'induced_rational':

Change History (5)

comment:1 Changed 6 months ago by gh-kliem

I think the underlying problem should be fixed, if not impossible.

comment:2 Changed 6 months ago by gh-kliem

  • Cc vdelecroix tscrim mkoeppe added

comment:3 Changed 6 months ago by vdelecroix

The implementation of sqrt is bad anyway. Returning an element of the symbolic ring is the worse thing you can do.

sage: R2.gen().sqrt()                                                                                                                                                                                               
2^(1/4)
sage: parent(_)                                                                                                                                                                                                     
Symbolic Ring

And in the code there is the following attempt of justification # This is what integers, rationals do....

comment:4 Changed 6 months ago by vdelecroix

  • Dependencies set to #3889
  • Milestone changed from sage-9.2 to sage-9.3

The sqrt issue is solved in #3889

comment:5 Changed 3 weeks ago by mkoeppe

  • Milestone changed from sage-9.3 to sage-9.4

Sage development has entered the release candidate phase for 9.3. Setting a new milestone for this ticket based on a cursory review of ticket status, priority, and last modification date.

Note: See TracTickets for help on using tickets.