Opened 5 months ago
Closed 4 months ago
#31883 closed defect (fixed)
Refine category of ScalarField
Reported by:  mkoeppe  Owned by:  

Priority:  major  Milestone:  sage9.4 
Component:  manifolds  Keywords:  
Cc:  egourgoulhon, tscrim, ghmjungmath  Merged in:  
Authors:  Matthias Koeppe  Reviewers:  Travis Scrimshaw 
Report Upstream:  N/A  Work issues:  
Branch:  cd3ca79 (Commits, GitHub, GitLab)  Commit:  cd3ca79ab94f48321cc9aa3f0b34c1b3db4e405e 
Dependencies:  Stopgaps: 
Description
A ScalarField
on a topological manifold is supposed to be a continuous map  but this is not reflected by the category of its parent.
sage: M = Manifold(2, 'R^2', structure='topological') sage: c_cart.<x,y> = M.chart() sage: r_squared = M.scalar_field(x^2+y^2) sage: r_squared.parent().category() Category of commutative algebras over Symbolic Ring sage: r_squared.codomain() AttributeError: 'ScalarFieldAlgebra_with_category.element_class' object has no attribute 'codomain'
Change History (12)
comment:1 Changed 5 months ago by
comment:2 Changed 5 months ago by
 Branch set to u/mkoeppe/refine_category_of_scalarfield
comment:3 Changed 5 months ago by
 Commit set to 1942c714237d5f2996587bfeda80404b57720696
 Status changed from new to needs_review
Anyway, here is a simple solution
New commits:
1942c71  ScalarField.codomain: New, put scalar fields in category of continuous maps

comment:5 Changed 5 months ago by
sage t long randomseed=0 src/sage/graphs/graph.py # 1 doctest failed sage t long randomseed=0 src/sage/manifolds/differentiable/scalarfield_algebra.py # 2 doctests failed sage t long randomseed=0 src/doc/en/thematic_tutorials/vector_calculus/vector_calc_advanced.rst # 1 doctest failed sage t long randomseed=0 src/doc/en/thematic_tutorials/vector_calculus/vector_calc_plane.rst # 1 doctest failed
The one in graph.py
doesn't seem like an error related to this ticket, but the others are trivial. Please make the changes and check that graph.py
is indeed unrelated. Once done, you can set a positive review.
comment:6 Changed 5 months ago by
 Commit changed from 1942c714237d5f2996587bfeda80404b57720696 to cd3ca79ab94f48321cc9aa3f0b34c1b3db4e405e
Branch pushed to git repo; I updated commit sha1. New commits:
cd3ca79  Update doctests for refined category of ScalarField

comment:7 Changed 5 months ago by
The failing doctest in graph.py
is unrelated and is fixed by #31848
comment:9 Changed 5 months ago by
Thank you!
comment:10 Changed 5 months ago by
I agree with the code added in this ticket, but let me seize the opportunity to point out some current inconsistency in the manifold set up, which is due to the lack of a proper real field in Sage (cf. #24456):
 the base field of a real manifold is
RR
 the base ring of the algebra of scalar fields on a manifold is
SR
Of course, from a pure mathematical side, 1 and 2 should be identical.
The basic reason for 1 is RR
being the simplest proxy for the genuine real field, albeit all (symbolic) computations on manifolds have nothing to do with 53 bits of precision...
The basic reason for 2 is to naturally allow for algebra operations like a*f
, where a
is a symbolic variable and f
a scalar field.
If #24456 converges some day, both 1 and 2 should be set to the real field object that will emerge from it. Meanwhile, we have
sage: M = Manifold(2, 'M') sage: CM = M.scalar_field_algebra() sage: M.base_field() Real Field with 53 bits of precision sage: CM.base_ring() Symbolic Ring
With the codomain()
method introduced in this ticket, we have in addition
sage: X.<x,y> = M.chart() sage: f = M.scalar_field(x^2) sage: f.codomain() is f.domain().base_field() True
which is nice, but
sage: f.codomain() is f.parent().base_ring() False
Moreover, for images of scalar fields, we have
sage: p = M((pi, 0)) sage: f(p) pi^2 sage: f(p) in f.codomain() True
but this holds only because pi^2
can be converted to an element of RR
. Otherwise, the test fails:
sage: a = var('a', domain='real') sage: p = M((a, 0)) sage: f(p) in f.codomain() False
f(p)
not lying in f.codomain()
is certainly something we do not want, but this is currently a consequence of the inconsistency 1 <> 2 mentioned above. The latter could be removed by making SR
the base field of manifolds. But then a real manifold and a complex one would appear as having the same base field (according to base_field()
).
Finally, it's worth to stress that in practice, the inconsistency 1 <> 2 is a rather mild one: to my knowledge, it has never triggered any error nor yield any false result in actual computations on manifolds (apart from the trivial CM.base_ring() is M.base_field()
being false).
comment:11 Changed 5 months ago by
Thanks a lot for sharing these insights!
comment:12 Changed 4 months ago by
 Branch changed from u/mkoeppe/refine_category_of_scalarfield to cd3ca79ab94f48321cc9aa3f0b34c1b3db4e405e
 Resolution set to fixed
 Status changed from positive_review to closed
Unfortunately, trying to make
ScalarField
a subclass ofMap
leads to: