Opened 22 months ago
Last modified 4 months ago
#30772 new defect
induced volume for polytopes defined over algebraic fields
Reported by: | gh-LaisRast | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | sage-9.7 |
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: |
Description
I have a 3-polytoe in R^{4} 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 (8)
comment:1 Changed 22 months ago by
comment:2 Changed 22 months ago by
- Cc vdelecroix tscrim mkoeppe added
comment:3 Changed 22 months ago by
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 22 months ago by
- Dependencies set to #3889
- Milestone changed from sage-9.2 to sage-9.3
The sqrt issue is solved in #3889
comment:5 Changed 17 months ago by
- 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.
comment:6 Changed 13 months ago by
- Milestone changed from sage-9.4 to sage-9.5
comment:7 Changed 8 months ago by
- Milestone changed from sage-9.5 to sage-9.6
comment:8 Changed 4 months ago by
- Milestone changed from sage-9.6 to sage-9.7
I think the underlying problem should be fixed, if not impossible.