passagemath-symbolics 10.6.43__cp314-cp314t-musllinux_1_2_x86_64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of passagemath-symbolics might be problematic. Click here for more details.
- passagemath_symbolics/__init__.py +3 -0
- passagemath_symbolics-10.6.43.dist-info/METADATA +187 -0
- passagemath_symbolics-10.6.43.dist-info/RECORD +171 -0
- passagemath_symbolics-10.6.43.dist-info/WHEEL +5 -0
- passagemath_symbolics-10.6.43.dist-info/top_level.txt +3 -0
- sage/all__sagemath_symbolics.py +17 -0
- sage/calculus/all.py +14 -0
- sage/calculus/calculus.py +2826 -0
- sage/calculus/desolvers.py +1866 -0
- sage/calculus/predefined.py +51 -0
- sage/calculus/tests.py +225 -0
- sage/calculus/var.cpython-314t-x86_64-linux-musl.so +0 -0
- sage/calculus/var.pyx +401 -0
- sage/dynamics/all__sagemath_symbolics.py +6 -0
- sage/dynamics/complex_dynamics/all.py +5 -0
- sage/dynamics/complex_dynamics/mandel_julia.py +765 -0
- sage/dynamics/complex_dynamics/mandel_julia_helper.cpython-314t-x86_64-linux-musl.so +0 -0
- sage/dynamics/complex_dynamics/mandel_julia_helper.pyx +1035 -0
- sage/ext/all__sagemath_symbolics.py +1 -0
- sage/ext_data/kenzo/CP2.txt +45 -0
- sage/ext_data/kenzo/CP3.txt +349 -0
- sage/ext_data/kenzo/CP4.txt +4774 -0
- sage/ext_data/kenzo/README.txt +49 -0
- sage/ext_data/kenzo/S4.txt +20 -0
- sage/ext_data/magma/latex/latex.m +1021 -0
- sage/ext_data/magma/latex/latex.spec +1 -0
- sage/ext_data/magma/sage/basic.m +356 -0
- sage/ext_data/magma/sage/sage.spec +1 -0
- sage/ext_data/magma/spec +9 -0
- sage/geometry/all__sagemath_symbolics.py +8 -0
- sage/geometry/hyperbolic_space/all.py +5 -0
- sage/geometry/hyperbolic_space/hyperbolic_coercion.py +743 -0
- sage/geometry/hyperbolic_space/hyperbolic_constants.py +5 -0
- sage/geometry/hyperbolic_space/hyperbolic_geodesic.py +2409 -0
- sage/geometry/hyperbolic_space/hyperbolic_interface.py +206 -0
- sage/geometry/hyperbolic_space/hyperbolic_isometry.py +1082 -0
- sage/geometry/hyperbolic_space/hyperbolic_model.py +1502 -0
- sage/geometry/hyperbolic_space/hyperbolic_point.py +621 -0
- sage/geometry/riemannian_manifolds/all.py +7 -0
- sage/geometry/riemannian_manifolds/parametrized_surface3d.py +1632 -0
- sage/geometry/riemannian_manifolds/surface3d_generators.py +461 -0
- sage/interfaces/all__sagemath_symbolics.py +1 -0
- sage/interfaces/magma.py +3017 -0
- sage/interfaces/magma_free.py +92 -0
- sage/interfaces/maple.py +1397 -0
- sage/interfaces/mathematica.py +1345 -0
- sage/interfaces/mathics.py +1312 -0
- sage/interfaces/sympy.py +1398 -0
- sage/interfaces/sympy_wrapper.py +197 -0
- sage/interfaces/tides.py +938 -0
- sage/libs/all__sagemath_symbolics.py +6 -0
- sage/manifolds/all.py +7 -0
- sage/manifolds/calculus_method.py +555 -0
- sage/manifolds/catalog.py +437 -0
- sage/manifolds/chart.py +4019 -0
- sage/manifolds/chart_func.py +3419 -0
- sage/manifolds/continuous_map.py +2183 -0
- sage/manifolds/continuous_map_image.py +155 -0
- sage/manifolds/differentiable/affine_connection.py +2475 -0
- sage/manifolds/differentiable/all.py +1 -0
- sage/manifolds/differentiable/automorphismfield.py +1383 -0
- sage/manifolds/differentiable/automorphismfield_group.py +604 -0
- sage/manifolds/differentiable/bundle_connection.py +1445 -0
- sage/manifolds/differentiable/characteristic_cohomology_class.py +1840 -0
- sage/manifolds/differentiable/chart.py +1241 -0
- sage/manifolds/differentiable/curve.py +1028 -0
- sage/manifolds/differentiable/de_rham_cohomology.py +541 -0
- sage/manifolds/differentiable/degenerate.py +559 -0
- sage/manifolds/differentiable/degenerate_submanifold.py +1671 -0
- sage/manifolds/differentiable/diff_form.py +1658 -0
- sage/manifolds/differentiable/diff_form_module.py +1062 -0
- sage/manifolds/differentiable/diff_map.py +1315 -0
- sage/manifolds/differentiable/differentiable_submanifold.py +291 -0
- sage/manifolds/differentiable/examples/all.py +1 -0
- sage/manifolds/differentiable/examples/euclidean.py +2517 -0
- sage/manifolds/differentiable/examples/real_line.py +897 -0
- sage/manifolds/differentiable/examples/sphere.py +1186 -0
- sage/manifolds/differentiable/examples/symplectic_space.py +187 -0
- sage/manifolds/differentiable/examples/symplectic_space_test.py +40 -0
- sage/manifolds/differentiable/integrated_curve.py +4035 -0
- sage/manifolds/differentiable/levi_civita_connection.py +841 -0
- sage/manifolds/differentiable/manifold.py +4254 -0
- sage/manifolds/differentiable/manifold_homset.py +1826 -0
- sage/manifolds/differentiable/metric.py +3032 -0
- sage/manifolds/differentiable/mixed_form.py +1507 -0
- sage/manifolds/differentiable/mixed_form_algebra.py +559 -0
- sage/manifolds/differentiable/multivector_module.py +800 -0
- sage/manifolds/differentiable/multivectorfield.py +1520 -0
- sage/manifolds/differentiable/poisson_tensor.py +268 -0
- sage/manifolds/differentiable/pseudo_riemannian.py +755 -0
- sage/manifolds/differentiable/pseudo_riemannian_submanifold.py +1839 -0
- sage/manifolds/differentiable/scalarfield.py +1343 -0
- sage/manifolds/differentiable/scalarfield_algebra.py +472 -0
- sage/manifolds/differentiable/symplectic_form.py +910 -0
- sage/manifolds/differentiable/symplectic_form_test.py +220 -0
- sage/manifolds/differentiable/tangent_space.py +412 -0
- sage/manifolds/differentiable/tangent_vector.py +616 -0
- sage/manifolds/differentiable/tensorfield.py +4665 -0
- sage/manifolds/differentiable/tensorfield_module.py +963 -0
- sage/manifolds/differentiable/tensorfield_paral.py +2450 -0
- sage/manifolds/differentiable/tensorfield_paral_test.py +16 -0
- sage/manifolds/differentiable/vector_bundle.py +1728 -0
- sage/manifolds/differentiable/vectorfield.py +1717 -0
- sage/manifolds/differentiable/vectorfield_module.py +2445 -0
- sage/manifolds/differentiable/vectorframe.py +1832 -0
- sage/manifolds/family.py +270 -0
- sage/manifolds/local_frame.py +1490 -0
- sage/manifolds/manifold.py +3090 -0
- sage/manifolds/manifold_homset.py +452 -0
- sage/manifolds/operators.py +359 -0
- sage/manifolds/point.py +994 -0
- sage/manifolds/scalarfield.py +3718 -0
- sage/manifolds/scalarfield_algebra.py +629 -0
- sage/manifolds/section.py +3111 -0
- sage/manifolds/section_module.py +831 -0
- sage/manifolds/structure.py +229 -0
- sage/manifolds/subset.py +2764 -0
- sage/manifolds/subsets/all.py +1 -0
- sage/manifolds/subsets/closure.py +131 -0
- sage/manifolds/subsets/pullback.py +885 -0
- sage/manifolds/topological_submanifold.py +891 -0
- sage/manifolds/trivialization.py +733 -0
- sage/manifolds/utilities.py +1348 -0
- sage/manifolds/vector_bundle.py +1342 -0
- sage/manifolds/vector_bundle_fiber.py +332 -0
- sage/manifolds/vector_bundle_fiber_element.py +111 -0
- sage/matrix/all__sagemath_symbolics.py +1 -0
- sage/matrix/matrix_symbolic_dense.cpython-314t-x86_64-linux-musl.so +0 -0
- sage/matrix/matrix_symbolic_dense.pxd +6 -0
- sage/matrix/matrix_symbolic_dense.pyx +1022 -0
- sage/matrix/matrix_symbolic_sparse.cpython-314t-x86_64-linux-musl.so +0 -0
- sage/matrix/matrix_symbolic_sparse.pxd +6 -0
- sage/matrix/matrix_symbolic_sparse.pyx +1029 -0
- sage/modules/all__sagemath_symbolics.py +1 -0
- sage/modules/vector_callable_symbolic_dense.py +105 -0
- sage/modules/vector_symbolic_dense.py +116 -0
- sage/modules/vector_symbolic_sparse.py +118 -0
- sage/rings/all__sagemath_symbolics.py +4 -0
- sage/rings/asymptotic/all.py +6 -0
- sage/rings/asymptotic/asymptotic_expansion_generators.py +1485 -0
- sage/rings/asymptotic/asymptotic_ring.py +4858 -0
- sage/rings/asymptotic/asymptotics_multivariate_generating_functions.py +4153 -0
- sage/rings/asymptotic/growth_group.py +5373 -0
- sage/rings/asymptotic/growth_group_cartesian.py +1400 -0
- sage/rings/asymptotic/term_monoid.py +5237 -0
- sage/rings/function_field/all__sagemath_symbolics.py +2 -0
- sage/rings/polynomial/all__sagemath_symbolics.py +1 -0
- sage/symbolic/all.py +15 -0
- sage/symbolic/assumptions.py +985 -0
- sage/symbolic/benchmark.py +93 -0
- sage/symbolic/callable.py +459 -0
- sage/symbolic/complexity_measures.py +35 -0
- sage/symbolic/constants.py +1287 -0
- sage/symbolic/expression_conversion_algebraic.py +310 -0
- sage/symbolic/expression_conversion_sympy.py +317 -0
- sage/symbolic/expression_conversions.py +1713 -0
- sage/symbolic/function_factory.py +355 -0
- sage/symbolic/integration/all.py +1 -0
- sage/symbolic/integration/external.py +270 -0
- sage/symbolic/integration/integral.py +1115 -0
- sage/symbolic/maxima_wrapper.py +162 -0
- sage/symbolic/operators.py +267 -0
- sage/symbolic/random_tests.py +462 -0
- sage/symbolic/relation.py +1907 -0
- sage/symbolic/ring.cpython-314t-x86_64-linux-musl.so +0 -0
- sage/symbolic/ring.pxd +5 -0
- sage/symbolic/ring.pyx +1396 -0
- sage/symbolic/subring.py +1025 -0
- sage/symbolic/symengine.py +19 -0
- sage/symbolic/tests.py +40 -0
- sage/symbolic/units.py +1470 -0
|
@@ -0,0 +1,2183 @@
|
|
|
1
|
+
# sage_setup: distribution = sagemath-symbolics
|
|
2
|
+
r"""
|
|
3
|
+
Continuous Maps Between Topological Manifolds
|
|
4
|
+
|
|
5
|
+
:class:`ContinuousMap` implements continuous maps from a topological
|
|
6
|
+
manifold `M` to some topological manifold `N` over the same topological
|
|
7
|
+
field `K` as `M`.
|
|
8
|
+
|
|
9
|
+
AUTHORS:
|
|
10
|
+
|
|
11
|
+
- Eric Gourgoulhon, Michal Bejger (2013-2015): initial version
|
|
12
|
+
- Travis Scrimshaw (2016): review tweaks
|
|
13
|
+
|
|
14
|
+
REFERENCES:
|
|
15
|
+
|
|
16
|
+
- Chap. 1 of [KN1963]_
|
|
17
|
+
- [Lee2011]_
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
# ****************************************************************************
|
|
21
|
+
# Copyright (C) 2015-2019 Eric Gourgoulhon <eric.gourgoulhon@obspm.fr>
|
|
22
|
+
# Copyright (C) 2015 Michal Bejger <bejger@camk.edu.pl>
|
|
23
|
+
# Copyright (C) 2016 Travis Scrimshaw <tscrimsh@umn.edu>
|
|
24
|
+
# Copyright (C) 2018 Florentin Jaffredo <florentin.jaffredo@polytechnique.edu>
|
|
25
|
+
# Copyright (C) 2020 Michael Jung <micjung@uni-potsdam.de>
|
|
26
|
+
# Copyright (C) 2021 Matthias Koeppe <mkoeppe@math.ucdavis.edu>
|
|
27
|
+
#
|
|
28
|
+
# This program is free software: you can redistribute it and/or modify
|
|
29
|
+
# it under the terms of the GNU General Public License as published by
|
|
30
|
+
# the Free Software Foundation, either version 2 of the License, or
|
|
31
|
+
# (at your option) any later version.
|
|
32
|
+
# https://www.gnu.org/licenses/
|
|
33
|
+
# ****************************************************************************
|
|
34
|
+
|
|
35
|
+
from sage.categories.homset import Hom
|
|
36
|
+
from sage.categories.morphism import Morphism
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class ContinuousMap(Morphism):
|
|
40
|
+
r"""
|
|
41
|
+
Continuous map between two topological manifolds.
|
|
42
|
+
|
|
43
|
+
This class implements continuous maps of the type
|
|
44
|
+
|
|
45
|
+
.. MATH::
|
|
46
|
+
|
|
47
|
+
\Phi: M \longrightarrow N,
|
|
48
|
+
|
|
49
|
+
where `M` and `N` are topological manifolds over the same
|
|
50
|
+
topological field `K`.
|
|
51
|
+
|
|
52
|
+
Continuous maps are the morphisms of the category of topological
|
|
53
|
+
manifolds. The set of all continuous maps from `M` to `N` is
|
|
54
|
+
therefore the homset between `M` and `N`, which is denoted
|
|
55
|
+
by `\mathrm{Hom}(M,N)`.
|
|
56
|
+
|
|
57
|
+
The class :class:`ContinuousMap` is a Sage *element* class,
|
|
58
|
+
whose *parent* class is
|
|
59
|
+
:class:`~sage.manifolds.manifold_homset.TopologicalManifoldHomset`.
|
|
60
|
+
|
|
61
|
+
INPUT:
|
|
62
|
+
|
|
63
|
+
- ``parent`` -- homset `\mathrm{Hom}(M,N)` to which the continuous
|
|
64
|
+
map belongs
|
|
65
|
+
- ``coord_functions`` -- dictionary of the coordinate expressions
|
|
66
|
+
(as lists or tuples of the coordinates of the image expressed in
|
|
67
|
+
terms of the coordinates of the considered point) with the pairs
|
|
68
|
+
of charts ``(chart1, chart2)`` as keys (``chart1`` being a chart
|
|
69
|
+
on `M` and ``chart2`` a chart on `N`)
|
|
70
|
+
- ``name`` -- (default: ``None``) name given to ``self``
|
|
71
|
+
- ``latex_name`` -- (default: ``None``) LaTeX symbol to denote the
|
|
72
|
+
continuous map; if ``None``, the LaTeX symbol is set to
|
|
73
|
+
``name``
|
|
74
|
+
- ``is_isomorphism`` -- boolean (default: ``False``); determines whether the
|
|
75
|
+
constructed object is a isomorphism (i.e. a homeomorphism). If set to
|
|
76
|
+
``True``, then the manifolds `M` and `N` must have the same dimension.
|
|
77
|
+
- ``is_identity`` -- boolean (default: ``False``); determines whether the
|
|
78
|
+
constructed object is the identity map. If set to ``True``,
|
|
79
|
+
then `N` must be `M` and the entry ``coord_functions`` is not used.
|
|
80
|
+
|
|
81
|
+
.. NOTE::
|
|
82
|
+
|
|
83
|
+
If the information passed by means of the argument
|
|
84
|
+
``coord_functions`` is not sufficient to fully specify the
|
|
85
|
+
continuous map, further coordinate expressions, in other charts,
|
|
86
|
+
can be subsequently added by means of the method :meth:`add_expr`.
|
|
87
|
+
|
|
88
|
+
EXAMPLES:
|
|
89
|
+
|
|
90
|
+
The standard embedding of the sphere `S^2` into `\RR^3`::
|
|
91
|
+
|
|
92
|
+
sage: M = Manifold(2, 'S^2', structure='topological') # the 2-dimensional sphere S^2
|
|
93
|
+
sage: U = M.open_subset('U') # complement of the North pole
|
|
94
|
+
sage: c_xy.<x,y> = U.chart() # stereographic coordinates from the North pole
|
|
95
|
+
sage: V = M.open_subset('V') # complement of the South pole
|
|
96
|
+
sage: c_uv.<u,v> = V.chart() # stereographic coordinates from the South pole
|
|
97
|
+
sage: M.declare_union(U,V) # S^2 is the union of U and V
|
|
98
|
+
sage: xy_to_uv = c_xy.transition_map(c_uv, (x/(x^2+y^2), y/(x^2+y^2)),
|
|
99
|
+
....: intersection_name='W',
|
|
100
|
+
....: restrictions1=x^2+y^2!=0,
|
|
101
|
+
....: restrictions2=u^2+v^2!=0)
|
|
102
|
+
sage: uv_to_xy = xy_to_uv.inverse()
|
|
103
|
+
sage: N = Manifold(3, 'R^3', latex_name=r'\RR^3', structure='topological') # R^3
|
|
104
|
+
sage: c_cart.<X,Y,Z> = N.chart() # Cartesian coordinates on R^3
|
|
105
|
+
sage: Phi = M.continuous_map(N,
|
|
106
|
+
....: {(c_xy, c_cart): [2*x/(1+x^2+y^2), 2*y/(1+x^2+y^2), (x^2+y^2-1)/(1+x^2+y^2)],
|
|
107
|
+
....: (c_uv, c_cart): [2*u/(1+u^2+v^2), 2*v/(1+u^2+v^2), (1-u^2-v^2)/(1+u^2+v^2)]},
|
|
108
|
+
....: name='Phi', latex_name=r'\Phi')
|
|
109
|
+
sage: Phi
|
|
110
|
+
Continuous map Phi from the 2-dimensional topological manifold S^2
|
|
111
|
+
to the 3-dimensional topological manifold R^3
|
|
112
|
+
sage: Phi.parent()
|
|
113
|
+
Set of Morphisms from 2-dimensional topological manifold S^2
|
|
114
|
+
to 3-dimensional topological manifold R^3
|
|
115
|
+
in Category of manifolds over Real Field with 53 bits of precision
|
|
116
|
+
sage: Phi.parent() is Hom(M, N)
|
|
117
|
+
True
|
|
118
|
+
sage: type(Phi)
|
|
119
|
+
<class 'sage.manifolds.manifold_homset.TopologicalManifoldHomset_with_category.element_class'>
|
|
120
|
+
sage: Phi.display()
|
|
121
|
+
Phi: S^2 → R^3
|
|
122
|
+
on U: (x, y) ↦ (X, Y, Z) = (2*x/(x^2 + y^2 + 1), 2*y/(x^2 + y^2 + 1), (x^2 + y^2 - 1)/(x^2 + y^2 + 1))
|
|
123
|
+
on V: (u, v) ↦ (X, Y, Z) = (2*u/(u^2 + v^2 + 1), 2*v/(u^2 + v^2 + 1), -(u^2 + v^2 - 1)/(u^2 + v^2 + 1))
|
|
124
|
+
|
|
125
|
+
It is possible to create the map using
|
|
126
|
+
:meth:`~sage.manifolds.manifold.TopologicalManifold.continuous_map`
|
|
127
|
+
with only in a single pair of charts. The argument ``coord_functions``
|
|
128
|
+
is then a mere list of coordinate expressions (and not a dictionary)
|
|
129
|
+
and the arguments ``chart1`` and ``chart2`` have to be provided if
|
|
130
|
+
the charts differ from the default ones on the domain and/or codomain::
|
|
131
|
+
|
|
132
|
+
sage: Phi1 = M.continuous_map(N, [2*x/(1+x^2+y^2), 2*y/(1+x^2+y^2), (x^2+y^2-1)/(1+x^2+y^2)],
|
|
133
|
+
....: chart1=c_xy, chart2=c_cart,
|
|
134
|
+
....: name='Phi', latex_name=r'\Phi')
|
|
135
|
+
|
|
136
|
+
Since ``c_xy`` and ``c_cart`` are the default charts on respectively
|
|
137
|
+
``M`` and ``N``, they can be omitted, so that the above declaration
|
|
138
|
+
is equivalent to::
|
|
139
|
+
|
|
140
|
+
sage: Phi1 = M.continuous_map(N, [2*x/(1+x^2+y^2), 2*y/(1+x^2+y^2), (x^2+y^2-1)/(1+x^2+y^2)],
|
|
141
|
+
....: name='Phi', latex_name=r'\Phi')
|
|
142
|
+
|
|
143
|
+
With such a declaration, the continuous map ``Phi1`` is only partially
|
|
144
|
+
defined on the manifold `S^2` as it is known in only one chart::
|
|
145
|
+
|
|
146
|
+
sage: Phi1.display()
|
|
147
|
+
Phi: S^2 → R^3
|
|
148
|
+
on U: (x, y) ↦ (X, Y, Z) = (2*x/(x^2 + y^2 + 1), 2*y/(x^2 + y^2 + 1), (x^2 + y^2 - 1)/(x^2 + y^2 + 1))
|
|
149
|
+
|
|
150
|
+
The definition can be completed by using :meth:`add_expr`::
|
|
151
|
+
|
|
152
|
+
sage: Phi1.add_expr(c_uv, c_cart, [2*u/(1+u^2+v^2), 2*v/(1+u^2+v^2), (1-u^2-v^2)/(1+u^2+v^2)])
|
|
153
|
+
sage: Phi1.display()
|
|
154
|
+
Phi: S^2 → R^3
|
|
155
|
+
on U: (x, y) ↦ (X, Y, Z) = (2*x/(x^2 + y^2 + 1), 2*y/(x^2 + y^2 + 1), (x^2 + y^2 - 1)/(x^2 + y^2 + 1))
|
|
156
|
+
on V: (u, v) ↦ (X, Y, Z) = (2*u/(u^2 + v^2 + 1), 2*v/(u^2 + v^2 + 1), -(u^2 + v^2 - 1)/(u^2 + v^2 + 1))
|
|
157
|
+
|
|
158
|
+
At this stage, ``Phi1`` and ``Phi`` are fully equivalent::
|
|
159
|
+
|
|
160
|
+
sage: Phi1 == Phi
|
|
161
|
+
True
|
|
162
|
+
|
|
163
|
+
The map acts on points::
|
|
164
|
+
|
|
165
|
+
sage: np = M.point((0,0), chart=c_uv) # the North pole
|
|
166
|
+
sage: Phi(np)
|
|
167
|
+
Point on the 3-dimensional topological manifold R^3
|
|
168
|
+
sage: Phi(np).coord() # Cartesian coordinates
|
|
169
|
+
(0, 0, 1)
|
|
170
|
+
sage: sp = M.point((0,0), chart=c_xy) # the South pole
|
|
171
|
+
sage: Phi(sp).coord() # Cartesian coordinates
|
|
172
|
+
(0, 0, -1)
|
|
173
|
+
|
|
174
|
+
The test suite is passed::
|
|
175
|
+
|
|
176
|
+
sage: TestSuite(Phi).run()
|
|
177
|
+
sage: TestSuite(Phi1).run()
|
|
178
|
+
|
|
179
|
+
Continuous maps can be composed by means of the operator ``*``.
|
|
180
|
+
Let us introduce the map `\RR^3 \to \RR^2` corresponding to
|
|
181
|
+
the projection from the point `(X, Y, Z) = (0, 0, 1)` onto the
|
|
182
|
+
equatorial plane `Z = 0`::
|
|
183
|
+
|
|
184
|
+
sage: P = Manifold(2, 'R^2', latex_name=r'\RR^2', structure='topological') # R^2 (equatorial plane)
|
|
185
|
+
sage: cP.<xP, yP> = P.chart()
|
|
186
|
+
sage: Psi = N.continuous_map(P, (X/(1-Z), Y/(1-Z)), name='Psi',
|
|
187
|
+
....: latex_name=r'\Psi')
|
|
188
|
+
sage: Psi
|
|
189
|
+
Continuous map Psi from the 3-dimensional topological manifold R^3
|
|
190
|
+
to the 2-dimensional topological manifold R^2
|
|
191
|
+
sage: Psi.display()
|
|
192
|
+
Psi: R^3 → R^2
|
|
193
|
+
(X, Y, Z) ↦ (xP, yP) = (-X/(Z - 1), -Y/(Z - 1))
|
|
194
|
+
|
|
195
|
+
Then we compose ``Psi`` with ``Phi``, thereby getting a map
|
|
196
|
+
`S^2 \to \RR^2`::
|
|
197
|
+
|
|
198
|
+
sage: ster = Psi * Phi ; ster
|
|
199
|
+
Continuous map from the 2-dimensional topological manifold S^2
|
|
200
|
+
to the 2-dimensional topological manifold R^2
|
|
201
|
+
|
|
202
|
+
Let us test on the South pole (``sp``) that ``ster`` is indeed the
|
|
203
|
+
composite of ``Psi`` and ``Phi``::
|
|
204
|
+
|
|
205
|
+
sage: ster(sp) == Psi(Phi(sp))
|
|
206
|
+
True
|
|
207
|
+
|
|
208
|
+
Actually ``ster`` is the stereographic projection from the North pole,
|
|
209
|
+
as its coordinate expression reveals::
|
|
210
|
+
|
|
211
|
+
sage: ster.display()
|
|
212
|
+
S^2 → R^2
|
|
213
|
+
on U: (x, y) ↦ (xP, yP) = (x, y)
|
|
214
|
+
on V: (u, v) ↦ (xP, yP) = (u/(u^2 + v^2), v/(u^2 + v^2))
|
|
215
|
+
|
|
216
|
+
If the codomain of a continuous map is 1-dimensional, the map can
|
|
217
|
+
be defined by a single symbolic expression for each pair of charts
|
|
218
|
+
and not by a list/tuple with a single element::
|
|
219
|
+
|
|
220
|
+
sage: N = Manifold(1, 'N', structure='topological')
|
|
221
|
+
sage: c_N = N.chart('X')
|
|
222
|
+
sage: Phi = M.continuous_map(N, {(c_xy, c_N): x^2+y^2,
|
|
223
|
+
....: (c_uv, c_N): 1/(u^2+v^2)})
|
|
224
|
+
|
|
225
|
+
sage: Psi = M.continuous_map(N, {(c_xy, c_N): [x^2+y^2],
|
|
226
|
+
....: (c_uv, c_N): [1/(u^2+v^2)]})
|
|
227
|
+
sage: Phi == Psi
|
|
228
|
+
True
|
|
229
|
+
|
|
230
|
+
Next we construct an example of continuous map `\RR \to \RR^2`::
|
|
231
|
+
|
|
232
|
+
sage: R = Manifold(1, 'R', structure='topological') # field R
|
|
233
|
+
sage: T.<t> = R.chart() # canonical chart on R
|
|
234
|
+
sage: R2 = Manifold(2, 'R^2', structure='topological') # R^2
|
|
235
|
+
sage: c_xy.<x,y> = R2.chart() # Cartesian coordinates on R^2
|
|
236
|
+
sage: Phi = R.continuous_map(R2, [cos(t), sin(t)], name='Phi'); Phi
|
|
237
|
+
Continuous map Phi from the 1-dimensional topological manifold R
|
|
238
|
+
to the 2-dimensional topological manifold R^2
|
|
239
|
+
sage: Phi.parent()
|
|
240
|
+
Set of Morphisms from 1-dimensional topological manifold R
|
|
241
|
+
to 2-dimensional topological manifold R^2
|
|
242
|
+
in Category of manifolds over Real Field with 53 bits of precision
|
|
243
|
+
sage: Phi.parent() is Hom(R, R2)
|
|
244
|
+
True
|
|
245
|
+
sage: Phi.display()
|
|
246
|
+
Phi: R → R^2
|
|
247
|
+
t ↦ (x, y) = (cos(t), sin(t))
|
|
248
|
+
|
|
249
|
+
An example of homeomorphism between the unit open disk and the
|
|
250
|
+
Euclidean plane `\RR^2`::
|
|
251
|
+
|
|
252
|
+
sage: D = R2.open_subset('D', coord_def={c_xy: x^2+y^2<1}) # the open unit disk
|
|
253
|
+
sage: Phi = D.homeomorphism(R2, [x/sqrt(1-x^2-y^2), y/sqrt(1-x^2-y^2)],
|
|
254
|
+
....: name='Phi', latex_name=r'\Phi')
|
|
255
|
+
sage: Phi
|
|
256
|
+
Homeomorphism Phi from the Open subset D of the 2-dimensional
|
|
257
|
+
topological manifold R^2 to the 2-dimensional topological manifold R^2
|
|
258
|
+
sage: Phi.parent()
|
|
259
|
+
Set of Morphisms from Open subset D of the 2-dimensional topological
|
|
260
|
+
manifold R^2 to 2-dimensional topological manifold R^2 in Category of
|
|
261
|
+
manifolds over Real Field with 53 bits of precision
|
|
262
|
+
sage: Phi.parent() is Hom(D, R2)
|
|
263
|
+
True
|
|
264
|
+
sage: Phi.display()
|
|
265
|
+
Phi: D → R^2
|
|
266
|
+
(x, y) ↦ (x, y) = (x/sqrt(-x^2 - y^2 + 1), y/sqrt(-x^2 - y^2 + 1))
|
|
267
|
+
|
|
268
|
+
The image of a point::
|
|
269
|
+
|
|
270
|
+
sage: p = D.point((1/2,0))
|
|
271
|
+
sage: q = Phi(p) ; q
|
|
272
|
+
Point on the 2-dimensional topological manifold R^2
|
|
273
|
+
sage: q.coord()
|
|
274
|
+
(1/3*sqrt(3), 0)
|
|
275
|
+
|
|
276
|
+
The inverse homeomorphism is computed by :meth:`inverse`::
|
|
277
|
+
|
|
278
|
+
sage: Phi.inverse()
|
|
279
|
+
Homeomorphism Phi^(-1) from the 2-dimensional topological manifold R^2
|
|
280
|
+
to the Open subset D of the 2-dimensional topological manifold R^2
|
|
281
|
+
sage: Phi.inverse().display()
|
|
282
|
+
Phi^(-1): R^2 → D
|
|
283
|
+
(x, y) ↦ (x, y) = (x/sqrt(x^2 + y^2 + 1), y/sqrt(x^2 + y^2 + 1))
|
|
284
|
+
|
|
285
|
+
Equivalently, one may use the notations ``^(-1)`` or ``~`` to
|
|
286
|
+
get the inverse::
|
|
287
|
+
|
|
288
|
+
sage: Phi^(-1) is Phi.inverse()
|
|
289
|
+
True
|
|
290
|
+
sage: ~Phi is Phi.inverse()
|
|
291
|
+
True
|
|
292
|
+
|
|
293
|
+
Check that ``~Phi`` is indeed the inverse of ``Phi``::
|
|
294
|
+
|
|
295
|
+
sage: (~Phi)(q) == p
|
|
296
|
+
True
|
|
297
|
+
sage: Phi * ~Phi == R2.identity_map()
|
|
298
|
+
True
|
|
299
|
+
sage: ~Phi * Phi == D.identity_map()
|
|
300
|
+
True
|
|
301
|
+
|
|
302
|
+
The coordinate expression of the inverse homeomorphism::
|
|
303
|
+
|
|
304
|
+
sage: (~Phi).display()
|
|
305
|
+
Phi^(-1): R^2 → D
|
|
306
|
+
(x, y) ↦ (x, y) = (x/sqrt(x^2 + y^2 + 1), y/sqrt(x^2 + y^2 + 1))
|
|
307
|
+
|
|
308
|
+
A special case of homeomorphism: the identity map of the open unit disk::
|
|
309
|
+
|
|
310
|
+
sage: id = D.identity_map() ; id
|
|
311
|
+
Identity map Id_D of the Open subset D of the 2-dimensional topological
|
|
312
|
+
manifold R^2
|
|
313
|
+
sage: latex(id)
|
|
314
|
+
\mathrm{Id}_{D}
|
|
315
|
+
sage: id.parent()
|
|
316
|
+
Set of Morphisms from Open subset D of the 2-dimensional topological
|
|
317
|
+
manifold R^2 to Open subset D of the 2-dimensional topological
|
|
318
|
+
manifold R^2 in Join of Category of subobjects of sets and Category of
|
|
319
|
+
manifolds over Real Field with 53 bits of precision
|
|
320
|
+
sage: id.parent() is Hom(D, D)
|
|
321
|
+
True
|
|
322
|
+
sage: id is Hom(D,D).one() # the identity element of the monoid Hom(D,D)
|
|
323
|
+
True
|
|
324
|
+
|
|
325
|
+
The identity map acting on a point::
|
|
326
|
+
|
|
327
|
+
sage: id(p)
|
|
328
|
+
Point on the 2-dimensional topological manifold R^2
|
|
329
|
+
sage: id(p) == p
|
|
330
|
+
True
|
|
331
|
+
sage: id(p) is p
|
|
332
|
+
True
|
|
333
|
+
|
|
334
|
+
The coordinate expression of the identity map::
|
|
335
|
+
|
|
336
|
+
sage: id.display()
|
|
337
|
+
Id_D: D → D
|
|
338
|
+
(x, y) ↦ (x, y)
|
|
339
|
+
|
|
340
|
+
The identity map is its own inverse::
|
|
341
|
+
|
|
342
|
+
sage: id^(-1) is id
|
|
343
|
+
True
|
|
344
|
+
sage: ~id is id
|
|
345
|
+
True
|
|
346
|
+
"""
|
|
347
|
+
|
|
348
|
+
def __init__(
|
|
349
|
+
self,
|
|
350
|
+
parent,
|
|
351
|
+
coord_functions=None,
|
|
352
|
+
name=None,
|
|
353
|
+
latex_name=None,
|
|
354
|
+
is_isomorphism=False,
|
|
355
|
+
is_identity=False,
|
|
356
|
+
):
|
|
357
|
+
r"""
|
|
358
|
+
Initialize ``self``.
|
|
359
|
+
|
|
360
|
+
TESTS::
|
|
361
|
+
|
|
362
|
+
sage: M = Manifold(2, 'M', structure='topological')
|
|
363
|
+
sage: X.<x,y> = M.chart()
|
|
364
|
+
sage: N = Manifold(3, 'N', structure='topological')
|
|
365
|
+
sage: Y.<u,v,w> = N.chart()
|
|
366
|
+
sage: f = Hom(M,N)({(X,Y): (x+y, x*y, x-y)}, name='f') ; f
|
|
367
|
+
Continuous map f from the 2-dimensional topological manifold M
|
|
368
|
+
to the 3-dimensional topological manifold N
|
|
369
|
+
sage: f.display()
|
|
370
|
+
f: M → N
|
|
371
|
+
(x, y) ↦ (u, v, w) = (x + y, x*y, x - y)
|
|
372
|
+
sage: TestSuite(f).run()
|
|
373
|
+
|
|
374
|
+
The identity map::
|
|
375
|
+
|
|
376
|
+
sage: f = Hom(M,M)({}, is_identity=True) ; f
|
|
377
|
+
Identity map Id_M of the 2-dimensional topological manifold M
|
|
378
|
+
sage: f.display()
|
|
379
|
+
Id_M: M → M
|
|
380
|
+
(x, y) ↦ (x, y)
|
|
381
|
+
sage: TestSuite(f).run()
|
|
382
|
+
"""
|
|
383
|
+
Morphism.__init__(self, parent)
|
|
384
|
+
domain = parent.domain()
|
|
385
|
+
codomain = parent.codomain()
|
|
386
|
+
self._domain = domain
|
|
387
|
+
self._codomain = codomain
|
|
388
|
+
# dict. of coordinate expressions of the
|
|
389
|
+
# map:
|
|
390
|
+
# - key: pair of charts
|
|
391
|
+
# - value: instance of MultiCoordFunction
|
|
392
|
+
self._coord_expression = {}
|
|
393
|
+
self._is_isomorphism = False # default value; may be redefined below
|
|
394
|
+
self._is_identity = False # default value; may be redefined below
|
|
395
|
+
if is_identity:
|
|
396
|
+
# Construction of the identity map
|
|
397
|
+
self._is_identity = True
|
|
398
|
+
self._is_isomorphism = True
|
|
399
|
+
if domain != codomain:
|
|
400
|
+
raise ValueError(
|
|
401
|
+
"the domain and codomain must coincide for the identity map"
|
|
402
|
+
)
|
|
403
|
+
if name is None:
|
|
404
|
+
name = 'Id_' + domain._name
|
|
405
|
+
if latex_name is None:
|
|
406
|
+
latex_name = r'\mathrm{Id}_{' + domain._latex_name + r'}'
|
|
407
|
+
self._name = name
|
|
408
|
+
self._latex_name = latex_name
|
|
409
|
+
for chart in domain.atlas():
|
|
410
|
+
coord_funct = chart[:]
|
|
411
|
+
self._coord_expression[(chart, chart)] = chart.multifunction(
|
|
412
|
+
*coord_funct
|
|
413
|
+
)
|
|
414
|
+
else:
|
|
415
|
+
# Construction of a generic continuous map
|
|
416
|
+
if is_isomorphism:
|
|
417
|
+
self._is_isomorphism = True
|
|
418
|
+
if domain.dim() != codomain.dim():
|
|
419
|
+
raise ValueError(
|
|
420
|
+
"for an isomorphism, the source"
|
|
421
|
+
" manifold and target manifold must"
|
|
422
|
+
" have the same dimension"
|
|
423
|
+
)
|
|
424
|
+
if coord_functions is not None:
|
|
425
|
+
n2 = self._codomain.dim()
|
|
426
|
+
for chart_pair, expression in coord_functions.items():
|
|
427
|
+
if chart_pair[0] not in self._domain.atlas():
|
|
428
|
+
raise ValueError(
|
|
429
|
+
"{} is not a chart ".format(chart_pair[0])
|
|
430
|
+
+ "defined on the {}".format(self._domain)
|
|
431
|
+
)
|
|
432
|
+
if chart_pair[1] not in self._codomain.atlas():
|
|
433
|
+
raise ValueError(
|
|
434
|
+
"{} is not a chart ".format(chart_pair[1])
|
|
435
|
+
+ "defined on the {}".format(self._codomain)
|
|
436
|
+
)
|
|
437
|
+
if n2 == 1:
|
|
438
|
+
# a single expression entry is allowed
|
|
439
|
+
if not isinstance(expression, (tuple, list)):
|
|
440
|
+
expression = (expression,)
|
|
441
|
+
if len(expression) != n2:
|
|
442
|
+
raise ValueError(
|
|
443
|
+
"{} coordinate ".format(n2) + "functions must be provided"
|
|
444
|
+
)
|
|
445
|
+
self._coord_expression[chart_pair] = chart_pair[0].multifunction(
|
|
446
|
+
*expression
|
|
447
|
+
)
|
|
448
|
+
self._name = name
|
|
449
|
+
if latex_name is None:
|
|
450
|
+
self._latex_name = self._name
|
|
451
|
+
else:
|
|
452
|
+
self._latex_name = latex_name
|
|
453
|
+
self._init_derived() # initialization of derived quantities
|
|
454
|
+
|
|
455
|
+
#
|
|
456
|
+
# SageObject methods
|
|
457
|
+
#
|
|
458
|
+
|
|
459
|
+
def _repr_(self):
|
|
460
|
+
r"""
|
|
461
|
+
Return a string representation of ``self``.
|
|
462
|
+
|
|
463
|
+
TESTS::
|
|
464
|
+
|
|
465
|
+
sage: M = Manifold(2, 'M', structure='topological')
|
|
466
|
+
sage: X.<x,y> = M.chart()
|
|
467
|
+
sage: N = Manifold(2, 'N', structure='topological')
|
|
468
|
+
sage: Y.<u,v> = N.chart()
|
|
469
|
+
sage: f = Hom(M,N)({(X,Y): (x+y,x*y)})
|
|
470
|
+
sage: f
|
|
471
|
+
Continuous map from the 2-dimensional topological manifold M
|
|
472
|
+
to the 2-dimensional topological manifold N
|
|
473
|
+
sage: f = Hom(M,N)({(X,Y): (x+y,x*y)}, name='f')
|
|
474
|
+
sage: f
|
|
475
|
+
Continuous map f from the 2-dimensional topological manifold M
|
|
476
|
+
to the 2-dimensional topological manifold N
|
|
477
|
+
sage: f = Hom(M,N)({(X,Y): (x+y,x-y)}, name='f', is_isomorphism=True)
|
|
478
|
+
sage: f
|
|
479
|
+
Homeomorphism f from the 2-dimensional topological manifold M
|
|
480
|
+
to the 2-dimensional topological manifold N
|
|
481
|
+
sage: f = Hom(M,M)({(X,X): (x+y,x-y)}, name='f', is_isomorphism=True)
|
|
482
|
+
sage: f
|
|
483
|
+
Homeomorphism f of the 2-dimensional topological manifold M
|
|
484
|
+
sage: f = Hom(M,M)({}, name='f', is_identity=True)
|
|
485
|
+
sage: f
|
|
486
|
+
Identity map f of the 2-dimensional topological manifold M
|
|
487
|
+
"""
|
|
488
|
+
if self._is_identity:
|
|
489
|
+
return "Identity map {} of the {}".format(self._name, self._domain)
|
|
490
|
+
if self._is_isomorphism:
|
|
491
|
+
description = "Homeomorphism"
|
|
492
|
+
else:
|
|
493
|
+
description = "Continuous map"
|
|
494
|
+
if self._name is not None:
|
|
495
|
+
description += " " + self._name
|
|
496
|
+
if self._domain == self._codomain:
|
|
497
|
+
if self._is_isomorphism:
|
|
498
|
+
description += " of the {}".format(self._domain)
|
|
499
|
+
else:
|
|
500
|
+
description += " from the {} to itself".format(self._domain)
|
|
501
|
+
else:
|
|
502
|
+
description += " from the {} to the {}".format(self._domain, self._codomain)
|
|
503
|
+
return description
|
|
504
|
+
|
|
505
|
+
def _latex_(self):
|
|
506
|
+
r"""
|
|
507
|
+
LaTeX representation of ``self``.
|
|
508
|
+
|
|
509
|
+
TESTS::
|
|
510
|
+
|
|
511
|
+
sage: M = Manifold(2, 'M', structure='topological')
|
|
512
|
+
sage: X.<x,y> = M.chart()
|
|
513
|
+
sage: f = Hom(M,M)({(X,X): (x+y,x*y)}, name='f')
|
|
514
|
+
sage: latex(f)
|
|
515
|
+
f
|
|
516
|
+
sage: f = Hom(M,M)({(X,X): (x+y,x*y)}, name='f', latex_name=r'\Phi')
|
|
517
|
+
sage: latex(f)
|
|
518
|
+
\Phi
|
|
519
|
+
"""
|
|
520
|
+
if self._latex_name is None:
|
|
521
|
+
return r'\text{' + str(self) + r'}'
|
|
522
|
+
else:
|
|
523
|
+
return self._latex_name
|
|
524
|
+
|
|
525
|
+
#
|
|
526
|
+
# Hash and equality
|
|
527
|
+
#
|
|
528
|
+
|
|
529
|
+
def __hash__(self):
|
|
530
|
+
"""
|
|
531
|
+
Hash function.
|
|
532
|
+
|
|
533
|
+
TESTS::
|
|
534
|
+
|
|
535
|
+
sage: M = Manifold(2, 'M', structure='topological')
|
|
536
|
+
sage: X.<x,y> = M.chart()
|
|
537
|
+
sage: N = Manifold(2, 'N', structure='topological')
|
|
538
|
+
sage: Y.<u,v> = N.chart()
|
|
539
|
+
sage: f = M.continuous_map(N, {(X,Y): (x+y,x*y)})
|
|
540
|
+
sage: hash(f) == f.__hash__()
|
|
541
|
+
True
|
|
542
|
+
|
|
543
|
+
Let us check that ``f`` can be used as a dictionary key::
|
|
544
|
+
|
|
545
|
+
sage: {f: 1}[f]
|
|
546
|
+
1
|
|
547
|
+
"""
|
|
548
|
+
return hash((self._domain, self._codomain))
|
|
549
|
+
|
|
550
|
+
def __eq__(self, other):
|
|
551
|
+
r"""
|
|
552
|
+
Comparison (equality) operator.
|
|
553
|
+
|
|
554
|
+
INPUT:
|
|
555
|
+
|
|
556
|
+
- ``other`` -- a :class:`ContinuousMap`
|
|
557
|
+
|
|
558
|
+
OUTPUT: ``True`` if ``self`` is equal to ``other`` and ``False`` otherwise
|
|
559
|
+
|
|
560
|
+
TESTS::
|
|
561
|
+
|
|
562
|
+
sage: M = Manifold(3, 'M', structure='topological')
|
|
563
|
+
sage: X.<x,y,z> = M.chart()
|
|
564
|
+
sage: N = Manifold(2, 'N', structure='topological')
|
|
565
|
+
sage: Y.<u,v> = N.chart()
|
|
566
|
+
sage: f = M.continuous_map(N, {(X,Y): [x+y+z, 2*x*y*z]}, name='f')
|
|
567
|
+
sage: g = M.continuous_map(N, {(X,Y): [x+y+z, 2*x*y*z]}, name='g')
|
|
568
|
+
sage: f == g
|
|
569
|
+
True
|
|
570
|
+
sage: g = M.continuous_map(N, {(X,Y): [x+y+z, 1]}, name='g')
|
|
571
|
+
sage: f == g
|
|
572
|
+
False
|
|
573
|
+
"""
|
|
574
|
+
if other is self:
|
|
575
|
+
return True
|
|
576
|
+
if not isinstance(other, type(self)):
|
|
577
|
+
return False
|
|
578
|
+
if self.parent() != other.parent():
|
|
579
|
+
return False
|
|
580
|
+
if self._is_identity:
|
|
581
|
+
return other.is_identity()
|
|
582
|
+
if other._is_identity:
|
|
583
|
+
return self.is_identity()
|
|
584
|
+
for charts, coord_functions in self._coord_expression.items():
|
|
585
|
+
try:
|
|
586
|
+
if coord_functions.expr() != other.expr(*charts):
|
|
587
|
+
return False
|
|
588
|
+
except ValueError:
|
|
589
|
+
return False
|
|
590
|
+
return True
|
|
591
|
+
|
|
592
|
+
def __ne__(self, other):
|
|
593
|
+
r"""
|
|
594
|
+
Inequality operator.
|
|
595
|
+
|
|
596
|
+
INPUT:
|
|
597
|
+
|
|
598
|
+
- ``other`` -- a :class:`ContinuousMap`
|
|
599
|
+
|
|
600
|
+
OUTPUT:
|
|
601
|
+
|
|
602
|
+
- ``True`` if ``self`` is different from ``other`` and
|
|
603
|
+
``False`` otherwise
|
|
604
|
+
|
|
605
|
+
TESTS::
|
|
606
|
+
|
|
607
|
+
sage: M = Manifold(3, 'M', structure='topological')
|
|
608
|
+
sage: X.<x,y,z> = M.chart()
|
|
609
|
+
sage: N = Manifold(2, 'N', structure='topological')
|
|
610
|
+
sage: Y.<u,v> = N.chart()
|
|
611
|
+
sage: f = M.continuous_map(N, {(X,Y): [x+y+z, 2*x*y*z]}, name='f')
|
|
612
|
+
sage: g = M.continuous_map(N, {(X,Y): [x+y+z, 2*x*y*z]}, name='g')
|
|
613
|
+
sage: f != g
|
|
614
|
+
False
|
|
615
|
+
sage: g = M.continuous_map(N, {(X,Y): [x+y+z, 1]}, name='g')
|
|
616
|
+
sage: f != g
|
|
617
|
+
True
|
|
618
|
+
"""
|
|
619
|
+
return not (self == other)
|
|
620
|
+
|
|
621
|
+
#
|
|
622
|
+
# Map methods
|
|
623
|
+
#
|
|
624
|
+
|
|
625
|
+
def _call_(self, point):
|
|
626
|
+
r"""
|
|
627
|
+
Compute the image of a point by ``self``.
|
|
628
|
+
|
|
629
|
+
INPUT:
|
|
630
|
+
|
|
631
|
+
- ``point`` -- :class:`~sage.manifolds.point.TopologicalManifoldPoint`;
|
|
632
|
+
point in the domain of ``self``
|
|
633
|
+
|
|
634
|
+
OUTPUT: image of the point by ``self``
|
|
635
|
+
|
|
636
|
+
EXAMPLES:
|
|
637
|
+
|
|
638
|
+
Planar rotation acting on a point::
|
|
639
|
+
|
|
640
|
+
sage: M = Manifold(2, 'R^2', latex_name=r'\RR^2', structure='topological') # Euclidean plane
|
|
641
|
+
sage: c_cart.<x,y> = M.chart() # Cartesian coordinates
|
|
642
|
+
|
|
643
|
+
A pi/3 rotation around the origin defined in Cartesian coordinates::
|
|
644
|
+
|
|
645
|
+
sage: rot = M.continuous_map(M, ((x - sqrt(3)*y)/2, (sqrt(3)*x + y)/2),
|
|
646
|
+
....: name='R')
|
|
647
|
+
sage: p = M.point((1,2), name='p')
|
|
648
|
+
sage: q = rot(p) ; q
|
|
649
|
+
Point R(p) on the 2-dimensional topological manifold R^2
|
|
650
|
+
sage: q.coord()
|
|
651
|
+
(-sqrt(3) + 1/2, 1/2*sqrt(3) + 1)
|
|
652
|
+
|
|
653
|
+
Image computed after some change of coordinates::
|
|
654
|
+
|
|
655
|
+
sage: c_spher.<r,ph> = M.chart(r'r:(0,+oo) ph:(0,2*pi):\phi') # spherical coord. on the plane
|
|
656
|
+
sage: ch = c_spher.transition_map(c_cart, [r*cos(ph), r*sin(ph)])
|
|
657
|
+
sage: p1 = M.point((sqrt(5), arctan(2)), chart=c_spher) # p1 is defined only in terms of c_spher
|
|
658
|
+
sage: q1 = rot(p1) # but the computation of the action of rot is still possible
|
|
659
|
+
sage: q1 == q
|
|
660
|
+
True
|
|
661
|
+
|
|
662
|
+
Image computed by means of spherical coordinates::
|
|
663
|
+
|
|
664
|
+
sage: rot.add_expr(c_spher, c_spher, (r, ph+pi/3)) # now rot is known in terms of c_spher
|
|
665
|
+
sage: p2 = M.point((sqrt(5), arctan(2)), chart=c_spher)
|
|
666
|
+
sage: q2 = rot(p2) # computation on c_spher
|
|
667
|
+
sage: q2 == q
|
|
668
|
+
True
|
|
669
|
+
"""
|
|
670
|
+
# NB: checking that ``point`` belongs to the map's domain has been
|
|
671
|
+
# already performed by Map.__call__(); this check is therefore not
|
|
672
|
+
# repeated here.
|
|
673
|
+
if self._is_identity:
|
|
674
|
+
return point
|
|
675
|
+
chart1, chart2 = None, None
|
|
676
|
+
for chart in point._coordinates:
|
|
677
|
+
for chart_pair in self._coord_expression:
|
|
678
|
+
if chart_pair[0] is chart:
|
|
679
|
+
chart1 = chart
|
|
680
|
+
chart2 = chart_pair[1]
|
|
681
|
+
break
|
|
682
|
+
if chart1 is not None:
|
|
683
|
+
break
|
|
684
|
+
else:
|
|
685
|
+
# attempt to perform a change of coordinate on the point
|
|
686
|
+
for chart_pair in self._coord_expression:
|
|
687
|
+
try:
|
|
688
|
+
point.coord(chart_pair[0])
|
|
689
|
+
chart1, chart2 = chart_pair
|
|
690
|
+
except ValueError:
|
|
691
|
+
pass
|
|
692
|
+
if chart1 is not None:
|
|
693
|
+
break
|
|
694
|
+
else:
|
|
695
|
+
raise ValueError(
|
|
696
|
+
"no pair of charts has been found to "
|
|
697
|
+
+ "compute the action of the {} on the {}".format(self, point)
|
|
698
|
+
)
|
|
699
|
+
coord_map = self._coord_expression[(chart1, chart2)]
|
|
700
|
+
y = coord_map(*(point._coordinates[chart1]))
|
|
701
|
+
if point._name is None or self._name is None:
|
|
702
|
+
res_name = None
|
|
703
|
+
else:
|
|
704
|
+
res_name = self._name + '(' + point._name + ')'
|
|
705
|
+
if point._latex_name is None or self._latex_name is None:
|
|
706
|
+
res_latex_name = None
|
|
707
|
+
else:
|
|
708
|
+
res_latex_name = (
|
|
709
|
+
self._latex_name + r'\left(' + point._latex_name + r'\right)'
|
|
710
|
+
)
|
|
711
|
+
# The image point is created as an element of the domain of chart2:
|
|
712
|
+
dom2 = chart2.domain()
|
|
713
|
+
return dom2.element_class(
|
|
714
|
+
dom2,
|
|
715
|
+
coords=y,
|
|
716
|
+
chart=chart2,
|
|
717
|
+
name=res_name,
|
|
718
|
+
latex_name=res_latex_name,
|
|
719
|
+
check_coords=False,
|
|
720
|
+
)
|
|
721
|
+
|
|
722
|
+
#
|
|
723
|
+
# Morphism methods
|
|
724
|
+
#
|
|
725
|
+
|
|
726
|
+
def is_identity(self):
|
|
727
|
+
r"""
|
|
728
|
+
Check whether ``self`` is an identity map.
|
|
729
|
+
|
|
730
|
+
EXAMPLES:
|
|
731
|
+
|
|
732
|
+
Tests on continuous maps of a 2-dimensional manifold::
|
|
733
|
+
|
|
734
|
+
sage: M = Manifold(2, 'M', structure='topological')
|
|
735
|
+
sage: X.<x,y> = M.chart()
|
|
736
|
+
sage: M.identity_map().is_identity() # obviously...
|
|
737
|
+
True
|
|
738
|
+
sage: Hom(M, M).one().is_identity() # a variant of the obvious
|
|
739
|
+
True
|
|
740
|
+
sage: a = M.continuous_map(M, coord_functions={(X,X): (x, y)})
|
|
741
|
+
sage: a.is_identity()
|
|
742
|
+
True
|
|
743
|
+
sage: a = M.continuous_map(M, coord_functions={(X,X): (x, y+1)})
|
|
744
|
+
sage: a.is_identity()
|
|
745
|
+
False
|
|
746
|
+
|
|
747
|
+
Of course, if the codomain of the map does not coincide with its
|
|
748
|
+
domain, the outcome is ``False``::
|
|
749
|
+
|
|
750
|
+
sage: N = Manifold(2, 'N', structure='topological')
|
|
751
|
+
sage: Y.<u,v> = N.chart()
|
|
752
|
+
sage: a = M.continuous_map(N, {(X,Y): (x, y)})
|
|
753
|
+
sage: a.display()
|
|
754
|
+
M → N
|
|
755
|
+
(x, y) ↦ (u, v) = (x, y)
|
|
756
|
+
sage: a.is_identity()
|
|
757
|
+
False
|
|
758
|
+
"""
|
|
759
|
+
if self._is_identity:
|
|
760
|
+
return True
|
|
761
|
+
if self._codomain != self._domain:
|
|
762
|
+
return False
|
|
763
|
+
for chart in self._domain._top_charts:
|
|
764
|
+
try:
|
|
765
|
+
if chart[:] != self.expr(chart, chart):
|
|
766
|
+
return False
|
|
767
|
+
except ValueError:
|
|
768
|
+
return False
|
|
769
|
+
# If this point is reached, ``self`` must be the identity:
|
|
770
|
+
self._is_identity = True
|
|
771
|
+
return True
|
|
772
|
+
|
|
773
|
+
def _composition_(self, other, homset):
|
|
774
|
+
r"""
|
|
775
|
+
Composition of ``self`` with another morphism.
|
|
776
|
+
|
|
777
|
+
The composition is performed on the right, i.e. the returned
|
|
778
|
+
morphism is ``self * other``.
|
|
779
|
+
|
|
780
|
+
INPUT:
|
|
781
|
+
|
|
782
|
+
- ``other`` -- a continuous map whose codomain is the domain
|
|
783
|
+
of ``self``
|
|
784
|
+
- ``homset`` -- the homset of the continuous map ``self*other``;
|
|
785
|
+
this argument is required to follow the prototype of
|
|
786
|
+
:meth:`~sage.categories.map.Map._composition_` and is determined by
|
|
787
|
+
:meth:`~sage.categories.map.Map._composition` (single underscore),
|
|
788
|
+
that is supposed to call the current method
|
|
789
|
+
|
|
790
|
+
OUTPUT:
|
|
791
|
+
|
|
792
|
+
- :class:`~sage.manifolds.continuous_map.ContinuousMap` that is
|
|
793
|
+
the composite map ``self * other``
|
|
794
|
+
|
|
795
|
+
TESTS::
|
|
796
|
+
|
|
797
|
+
sage: M = Manifold(3, 'M', structure='topological')
|
|
798
|
+
sage: X.<x,y,z> = M.chart()
|
|
799
|
+
sage: N = Manifold(2, 'N', structure='topological')
|
|
800
|
+
sage: Y.<u,v> = N.chart()
|
|
801
|
+
sage: Q = Manifold(4, 'Q', structure='topological')
|
|
802
|
+
sage: Z.<a,b,c,d> = Q.chart()
|
|
803
|
+
sage: f = N.continuous_map(Q, [u+v, u*v, 1+u, 2-v])
|
|
804
|
+
sage: g = M.continuous_map(N, [x+y+z, x*y*z])
|
|
805
|
+
sage: s = f._composition_(g, Hom(M,Q)); s
|
|
806
|
+
Continuous map from the 3-dimensional topological manifold M
|
|
807
|
+
to the 4-dimensional topological manifold Q
|
|
808
|
+
sage: s.display()
|
|
809
|
+
M → Q
|
|
810
|
+
(x, y, z) ↦ (a, b, c, d) = ((x*y + 1)*z + x + y, x*y*z^2 + (x^2*y + x*y^2)*z, x + y + z + 1, -x*y*z + 2)
|
|
811
|
+
sage: s == f*g
|
|
812
|
+
True
|
|
813
|
+
"""
|
|
814
|
+
# This method is invoked by Map._composition (single underscore),
|
|
815
|
+
# which is itself invoked by Map.__mul__ . The latter performs the
|
|
816
|
+
# check other._codomain == self._domain. There is therefore no need
|
|
817
|
+
# to perform it here.
|
|
818
|
+
if self._is_identity:
|
|
819
|
+
return other
|
|
820
|
+
if other._is_identity:
|
|
821
|
+
return self
|
|
822
|
+
resu_funct = {}
|
|
823
|
+
for chart1 in other._domain._top_charts:
|
|
824
|
+
for chart2 in self._domain._top_charts:
|
|
825
|
+
for chart3 in self._codomain._top_charts:
|
|
826
|
+
try:
|
|
827
|
+
self23 = self.coord_functions(chart2, chart3)
|
|
828
|
+
resu_funct[(chart1, chart3)] = self23(
|
|
829
|
+
*other.expr(chart1, chart2), simplify=True
|
|
830
|
+
)
|
|
831
|
+
except ValueError:
|
|
832
|
+
pass
|
|
833
|
+
return homset(resu_funct)
|
|
834
|
+
|
|
835
|
+
def image(self, subset=None, inverse=None):
|
|
836
|
+
r"""
|
|
837
|
+
Return the image of ``self`` or the image of ``subset`` under ``self``.
|
|
838
|
+
|
|
839
|
+
INPUT:
|
|
840
|
+
|
|
841
|
+
- ``inverse`` -- (default: ``None``) continuous map from
|
|
842
|
+
``map.codomain()`` to ``map.domain()``, which once restricted to the image
|
|
843
|
+
of `\Phi` is the inverse of `\Phi` onto its image if the latter
|
|
844
|
+
exists (NB: no check of this is performed)
|
|
845
|
+
- ``subset`` -- (default: the domain of ``map``) a subset of the domain of
|
|
846
|
+
``self``
|
|
847
|
+
|
|
848
|
+
EXAMPLES::
|
|
849
|
+
|
|
850
|
+
sage: M = Manifold(2, 'M', structure='topological')
|
|
851
|
+
sage: N = Manifold(1, 'N', ambient=M, structure='topological')
|
|
852
|
+
sage: CM.<x,y> = M.chart()
|
|
853
|
+
sage: CN.<u> = N.chart(coord_restrictions=lambda u: [u > -1, u < 1])
|
|
854
|
+
sage: Phi = N.continuous_map(M, {(CN,CM): [u, u^2]}, name='Phi')
|
|
855
|
+
sage: Phi.image()
|
|
856
|
+
Image of the Continuous map Phi
|
|
857
|
+
from the 1-dimensional topological submanifold N
|
|
858
|
+
immersed in the 2-dimensional topological manifold M
|
|
859
|
+
to the 2-dimensional topological manifold M
|
|
860
|
+
|
|
861
|
+
sage: S = N.subset('S')
|
|
862
|
+
sage: Phi_S = Phi.image(S); Phi_S
|
|
863
|
+
Image of the Subset S of the
|
|
864
|
+
1-dimensional topological submanifold N
|
|
865
|
+
immersed in the 2-dimensional topological manifold M
|
|
866
|
+
under the Continuous map Phi
|
|
867
|
+
from the 1-dimensional topological submanifold N
|
|
868
|
+
immersed in the 2-dimensional topological manifold M
|
|
869
|
+
to the 2-dimensional topological manifold M
|
|
870
|
+
sage: Phi_S.is_subset(M)
|
|
871
|
+
True
|
|
872
|
+
"""
|
|
873
|
+
from sage.manifolds.continuous_map_image import ImageManifoldSubset
|
|
874
|
+
|
|
875
|
+
if self._is_identity:
|
|
876
|
+
if subset is None:
|
|
877
|
+
return self.domain()
|
|
878
|
+
else:
|
|
879
|
+
return subset
|
|
880
|
+
return ImageManifoldSubset(self, inverse=inverse, domain_subset=subset)
|
|
881
|
+
|
|
882
|
+
def preimage(self, codomain_subset, name=None, latex_name=None):
|
|
883
|
+
r"""
|
|
884
|
+
Return the preimage of ``codomain_subset`` under ``self``.
|
|
885
|
+
|
|
886
|
+
An alias is :meth:`pullback`.
|
|
887
|
+
|
|
888
|
+
INPUT:
|
|
889
|
+
|
|
890
|
+
- ``codomain_subset`` -- an instance of
|
|
891
|
+
:class:`~sage.manifolds.subset.ManifoldSubset`
|
|
892
|
+
- ``name`` -- string; name (symbol) given to the subset
|
|
893
|
+
- ``latex_name`` -- string (default: ``None``); LaTeX symbol to
|
|
894
|
+
denote the subset; if none are provided, it is set to ``name``
|
|
895
|
+
|
|
896
|
+
OUTPUT:
|
|
897
|
+
|
|
898
|
+
- either a :class:`~sage.manifolds.manifold.TopologicalManifold` or
|
|
899
|
+
a :class:`~sage.manifolds.subsets.pullback.ManifoldSubsetPullback`
|
|
900
|
+
|
|
901
|
+
EXAMPLES::
|
|
902
|
+
|
|
903
|
+
sage: R = Manifold(1, 'R', structure='topological') # field R
|
|
904
|
+
sage: T.<t> = R.chart() # canonical chart on R
|
|
905
|
+
sage: R2 = Manifold(2, 'R^2', structure='topological') # R^2
|
|
906
|
+
sage: c_xy.<x,y> = R2.chart() # Cartesian coordinates on R^2
|
|
907
|
+
sage: Phi = R.continuous_map(R2, [cos(t), sin(t)], name='Phi'); Phi
|
|
908
|
+
Continuous map Phi
|
|
909
|
+
from the 1-dimensional topological manifold R
|
|
910
|
+
to the 2-dimensional topological manifold R^2
|
|
911
|
+
sage: Q1 = R2.open_subset('Q1', coord_def={c_xy: [x>0, y>0]}); Q1
|
|
912
|
+
Open subset Q1 of the 2-dimensional topological manifold R^2
|
|
913
|
+
sage: Phi_inv_Q1 = Phi.preimage(Q1); Phi_inv_Q1
|
|
914
|
+
Subset Phi_inv_Q1 of the 1-dimensional topological manifold R
|
|
915
|
+
sage: R.point([pi/4]) in Phi_inv_Q1
|
|
916
|
+
True
|
|
917
|
+
sage: R.point([0]) in Phi_inv_Q1
|
|
918
|
+
False
|
|
919
|
+
sage: R.point([3*pi/4]) in Phi_inv_Q1
|
|
920
|
+
False
|
|
921
|
+
|
|
922
|
+
The identity map is handled specially::
|
|
923
|
+
|
|
924
|
+
sage: M = Manifold(2, 'M', structure='topological')
|
|
925
|
+
sage: X.<x,y> = M.chart()
|
|
926
|
+
sage: M.identity_map().preimage(M)
|
|
927
|
+
2-dimensional topological manifold M
|
|
928
|
+
sage: M.identity_map().preimage(M) is M
|
|
929
|
+
True
|
|
930
|
+
|
|
931
|
+
Another trivial case::
|
|
932
|
+
|
|
933
|
+
sage: M = Manifold(2, 'M', structure='topological')
|
|
934
|
+
sage: X.<x,y> = M.chart()
|
|
935
|
+
sage: D1 = M.open_subset('D1', coord_def={X: x^2+y^2<1}) # the open unit disk
|
|
936
|
+
sage: D2 = M.open_subset('D2', coord_def={X: x^2+y^2<4})
|
|
937
|
+
sage: f = Hom(D1,D2)({(X.restrict(D1), X.restrict(D2)): (2*x, 2*y)}, name='f')
|
|
938
|
+
sage: f.preimage(D2)
|
|
939
|
+
Open subset D1 of the 2-dimensional topological manifold M
|
|
940
|
+
sage: f.preimage(M)
|
|
941
|
+
Open subset D1 of the 2-dimensional topological manifold M
|
|
942
|
+
"""
|
|
943
|
+
if self._is_identity:
|
|
944
|
+
return codomain_subset
|
|
945
|
+
if self._codomain.is_subset(codomain_subset):
|
|
946
|
+
return self._domain
|
|
947
|
+
from sage.manifolds.subsets.pullback import ManifoldSubsetPullback
|
|
948
|
+
|
|
949
|
+
return ManifoldSubsetPullback(
|
|
950
|
+
self, codomain_subset, name=name, latex_name=latex_name
|
|
951
|
+
)
|
|
952
|
+
|
|
953
|
+
pullback = preimage
|
|
954
|
+
|
|
955
|
+
#
|
|
956
|
+
# Monoid methods
|
|
957
|
+
#
|
|
958
|
+
|
|
959
|
+
def _mul_(self, other):
|
|
960
|
+
r"""
|
|
961
|
+
Composition of ``self`` with another morphism (endomorphism case).
|
|
962
|
+
|
|
963
|
+
This applies only when the parent of ``self`` is a monoid, i.e. when
|
|
964
|
+
``self`` is an endomorphism of the category of topological manifolds,
|
|
965
|
+
i.e. a continuous map `M \to M`, where `M` is a topological manifold.
|
|
966
|
+
|
|
967
|
+
INPUT:
|
|
968
|
+
|
|
969
|
+
- ``other`` -- a continuous map whose codomain is the domain
|
|
970
|
+
of ``self``
|
|
971
|
+
|
|
972
|
+
OUTPUT:
|
|
973
|
+
|
|
974
|
+
- :class:`~sage.manifolds.continuous_map.ContinuousMap` that
|
|
975
|
+
is the composite map ``self * other``
|
|
976
|
+
|
|
977
|
+
TESTS::
|
|
978
|
+
|
|
979
|
+
sage: M = Manifold(2, 'M', structure='topological')
|
|
980
|
+
sage: X.<x,y> = M.chart()
|
|
981
|
+
sage: f = M.continuous_map(M, [x+y, x*y], name='f')
|
|
982
|
+
sage: g = M.continuous_map(M, [1-y, 2+x], name='g')
|
|
983
|
+
sage: s = f._mul_(g); s
|
|
984
|
+
Continuous map from the 2-dimensional topological manifold M
|
|
985
|
+
to itself
|
|
986
|
+
sage: s.display()
|
|
987
|
+
M → M
|
|
988
|
+
(x, y) ↦ (x - y + 3, -(x + 2)*y + x + 2)
|
|
989
|
+
sage: s == f*g
|
|
990
|
+
True
|
|
991
|
+
sage: f._mul_(M.identity_map()) == f
|
|
992
|
+
True
|
|
993
|
+
sage: M.identity_map()._mul_(f) == f
|
|
994
|
+
True
|
|
995
|
+
"""
|
|
996
|
+
dom = self._domain
|
|
997
|
+
return self._composition_(other, Hom(dom, dom))
|
|
998
|
+
|
|
999
|
+
#
|
|
1000
|
+
# Other methods
|
|
1001
|
+
#
|
|
1002
|
+
|
|
1003
|
+
def _init_derived(self):
|
|
1004
|
+
r"""
|
|
1005
|
+
Initialize the derived quantities of ``self``.
|
|
1006
|
+
|
|
1007
|
+
TESTS::
|
|
1008
|
+
|
|
1009
|
+
sage: M = Manifold(2, 'M', structure='topological')
|
|
1010
|
+
sage: X.<x,y> = M.chart()
|
|
1011
|
+
sage: f = M.homeomorphism(M, [x+y, x-y])
|
|
1012
|
+
sage: f._init_derived()
|
|
1013
|
+
sage: f._restrictions
|
|
1014
|
+
{}
|
|
1015
|
+
sage: f._inverse
|
|
1016
|
+
|
|
1017
|
+
``_extensions_graph`` and ``_restrictions_graph`` were not originally
|
|
1018
|
+
derived quantities, but this induced a bug when dealing with other
|
|
1019
|
+
derived quantities (see :issue:`26012`)::
|
|
1020
|
+
|
|
1021
|
+
sage: M = Manifold(2, 'M')
|
|
1022
|
+
sage: C.<x, y> = M.chart()
|
|
1023
|
+
sage: U = M.open_subset('U', coord_def={C:x>0})
|
|
1024
|
+
sage: g = M.metric('g')
|
|
1025
|
+
sage: g[:] = [[1, 0], [0, 1]]
|
|
1026
|
+
sage: gU = g.restrict(U)
|
|
1027
|
+
sage: g[:] = [[1, 0], [0, 2]]
|
|
1028
|
+
sage: g.inverse()[:]
|
|
1029
|
+
[ 1 0]
|
|
1030
|
+
[ 0 1/2]
|
|
1031
|
+
sage: g.inverse().restrict(U)[:] # used to be wrong
|
|
1032
|
+
[ 1 0]
|
|
1033
|
+
[ 0 1/2]
|
|
1034
|
+
"""
|
|
1035
|
+
# dict. of restrictions to subdomains of self._domain
|
|
1036
|
+
self._restrictions = {}
|
|
1037
|
+
self._restrictions_graph = {(self._domain, self._codomain): self}
|
|
1038
|
+
# dict. of known extensions of self on bigger domains,
|
|
1039
|
+
# including self, with pairs of domain codomain as keys.
|
|
1040
|
+
# Its elements can be seen as incoming edges on a graph.
|
|
1041
|
+
self._extensions_graph = {(self._domain, self._codomain): self}
|
|
1042
|
+
# dict. of known restrictions of self on smaller domains,
|
|
1043
|
+
# including self, with pairs of domain codomain as keys.
|
|
1044
|
+
# Its elements can be seen as outgoing edges on a graph.
|
|
1045
|
+
|
|
1046
|
+
if self._is_identity:
|
|
1047
|
+
self._inverse = self
|
|
1048
|
+
else:
|
|
1049
|
+
self._inverse = None
|
|
1050
|
+
|
|
1051
|
+
def _del_derived(self):
|
|
1052
|
+
r"""
|
|
1053
|
+
Delete the derived quantities of ``self``.
|
|
1054
|
+
|
|
1055
|
+
TESTS::
|
|
1056
|
+
|
|
1057
|
+
sage: M = Manifold(2, 'M', structure='topological')
|
|
1058
|
+
sage: X.<x,y> = M.chart()
|
|
1059
|
+
sage: f = M.homeomorphism(M, [x+y, x-y])
|
|
1060
|
+
sage: f^(-1)
|
|
1061
|
+
Homeomorphism of the 2-dimensional topological manifold M
|
|
1062
|
+
sage: f._inverse # was set by f^(-1)
|
|
1063
|
+
Homeomorphism of the 2-dimensional topological manifold M
|
|
1064
|
+
sage: f._del_derived()
|
|
1065
|
+
sage: f._inverse # has been set to None by _del_derived()
|
|
1066
|
+
"""
|
|
1067
|
+
self._restrictions.clear()
|
|
1068
|
+
self._restrictions_graph = {(self._domain, self._codomain): self}
|
|
1069
|
+
self._extensions_graph = {(self._domain, self._codomain): self}
|
|
1070
|
+
if not self._is_identity:
|
|
1071
|
+
self._inverse = None
|
|
1072
|
+
|
|
1073
|
+
def display(self, chart1=None, chart2=None):
|
|
1074
|
+
r"""
|
|
1075
|
+
Display the expression of ``self`` in one or more pair of charts.
|
|
1076
|
+
|
|
1077
|
+
If the expression is not known already, it is computed from some
|
|
1078
|
+
expression in other charts by means of change-of-coordinate formulas.
|
|
1079
|
+
|
|
1080
|
+
INPUT:
|
|
1081
|
+
|
|
1082
|
+
- ``chart1`` -- (default: ``None``) chart on the domain of ``self``;
|
|
1083
|
+
if ``None``, the display is performed on all the charts on the
|
|
1084
|
+
domain in which the map is known or computable via some change
|
|
1085
|
+
of coordinates
|
|
1086
|
+
- ``chart2`` -- (default: ``None``) chart on the codomain of ``self``;
|
|
1087
|
+
if ``None``, the display is performed on all the charts on the
|
|
1088
|
+
codomain in which the map is known or computable via some change
|
|
1089
|
+
of coordinates
|
|
1090
|
+
|
|
1091
|
+
The output is either text-formatted (console mode) or LaTeX-formatted
|
|
1092
|
+
(notebook mode).
|
|
1093
|
+
|
|
1094
|
+
EXAMPLES:
|
|
1095
|
+
|
|
1096
|
+
A simple reparametrization::
|
|
1097
|
+
|
|
1098
|
+
sage: R.<t> = manifolds.RealLine()
|
|
1099
|
+
sage: I = R.open_interval(0, 2*pi)
|
|
1100
|
+
sage: J = R.open_interval(2*pi, 6*pi)
|
|
1101
|
+
sage: h = J.continuous_map(I, ((t-2*pi)/2,), name='h')
|
|
1102
|
+
sage: h.display()
|
|
1103
|
+
h: (2*pi, 6*pi) → (0, 2*pi)
|
|
1104
|
+
t ↦ t = -pi + 1/2*t
|
|
1105
|
+
sage: latex(h.display())
|
|
1106
|
+
\begin{array}{llcl} h:& \left(2 \, \pi, 6 \, \pi\right) &
|
|
1107
|
+
\longrightarrow & \left(0, 2 \, \pi\right) \\ & t & \longmapsto &
|
|
1108
|
+
t = -\pi + \frac{1}{2} \, t \end{array}
|
|
1109
|
+
|
|
1110
|
+
Standard embedding of the sphere `S^2` in `\RR^3`::
|
|
1111
|
+
|
|
1112
|
+
sage: M = Manifold(2, 'S^2', structure='topological') # the 2-dimensional sphere S^2
|
|
1113
|
+
sage: U = M.open_subset('U') # complement of the North pole
|
|
1114
|
+
sage: c_xy.<x,y> = U.chart() # stereographic coordinates from the North pole
|
|
1115
|
+
sage: V = M.open_subset('V') # complement of the South pole
|
|
1116
|
+
sage: c_uv.<u,v> = V.chart() # stereographic coordinates from the South pole
|
|
1117
|
+
sage: M.declare_union(U,V) # S^2 is the union of U and V
|
|
1118
|
+
sage: N = Manifold(3, 'R^3', latex_name=r'\RR^3', structure='topological') # R^3
|
|
1119
|
+
sage: c_cart.<X,Y,Z> = N.chart() # Cartesian coordinates on R^3
|
|
1120
|
+
sage: Phi = M.continuous_map(N,
|
|
1121
|
+
....: {(c_xy, c_cart): [2*x/(1+x^2+y^2), 2*y/(1+x^2+y^2), (x^2+y^2-1)/(1+x^2+y^2)],
|
|
1122
|
+
....: (c_uv, c_cart): [2*u/(1+u^2+v^2), 2*v/(1+u^2+v^2), (1-u^2-v^2)/(1+u^2+v^2)]},
|
|
1123
|
+
....: name='Phi', latex_name=r'\Phi')
|
|
1124
|
+
sage: Phi.display(c_xy, c_cart)
|
|
1125
|
+
Phi: S^2 → R^3
|
|
1126
|
+
on U: (x, y) ↦ (X, Y, Z) = (2*x/(x^2 + y^2 + 1), 2*y/(x^2 + y^2 + 1), (x^2 + y^2 - 1)/(x^2 + y^2 + 1))
|
|
1127
|
+
sage: Phi.display(c_uv, c_cart)
|
|
1128
|
+
Phi: S^2 → R^3
|
|
1129
|
+
on V: (u, v) ↦ (X, Y, Z) = (2*u/(u^2 + v^2 + 1), 2*v/(u^2 + v^2 + 1), -(u^2 + v^2 - 1)/(u^2 + v^2 + 1))
|
|
1130
|
+
|
|
1131
|
+
The LaTeX output of that embedding is::
|
|
1132
|
+
|
|
1133
|
+
sage: latex(Phi.display(c_xy, c_cart))
|
|
1134
|
+
\begin{array}{llcl} \Phi:& S^2 & \longrightarrow & \RR^3
|
|
1135
|
+
\\ \text{on}\ U : & \left(x, y\right) & \longmapsto
|
|
1136
|
+
& \left(X, Y, Z\right) = \left(\frac{2 \, x}{x^{2} + y^{2} + 1},
|
|
1137
|
+
\frac{2 \, y}{x^{2} + y^{2} + 1},
|
|
1138
|
+
\frac{x^{2} + y^{2} - 1}{x^{2} + y^{2} + 1}\right)
|
|
1139
|
+
\end{array}
|
|
1140
|
+
|
|
1141
|
+
If the argument ``chart2`` is not specified, the display is performed
|
|
1142
|
+
on all the charts on the codomain in which the map is known
|
|
1143
|
+
or computable via some change of coordinates (here only one chart:
|
|
1144
|
+
``c_cart``)::
|
|
1145
|
+
|
|
1146
|
+
sage: Phi.display(c_xy)
|
|
1147
|
+
Phi: S^2 → R^3
|
|
1148
|
+
on U: (x, y) ↦ (X, Y, Z) = (2*x/(x^2 + y^2 + 1), 2*y/(x^2 + y^2 + 1), (x^2 + y^2 - 1)/(x^2 + y^2 + 1))
|
|
1149
|
+
|
|
1150
|
+
Similarly, if the argument ``chart1`` is omitted, the display is
|
|
1151
|
+
performed on all the charts on the domain of ``Phi`` in which the
|
|
1152
|
+
map is known or computable via some change of coordinates::
|
|
1153
|
+
|
|
1154
|
+
sage: Phi.display(chart2=c_cart)
|
|
1155
|
+
Phi: S^2 → R^3
|
|
1156
|
+
on U: (x, y) ↦ (X, Y, Z) = (2*x/(x^2 + y^2 + 1), 2*y/(x^2 + y^2 + 1), (x^2 + y^2 - 1)/(x^2 + y^2 + 1))
|
|
1157
|
+
on V: (u, v) ↦ (X, Y, Z) = (2*u/(u^2 + v^2 + 1), 2*v/(u^2 + v^2 + 1), -(u^2 + v^2 - 1)/(u^2 + v^2 + 1))
|
|
1158
|
+
|
|
1159
|
+
If neither ``chart1`` nor ``chart2`` is specified, the display is
|
|
1160
|
+
performed on all the pair of charts in which ``Phi`` is known or
|
|
1161
|
+
computable via some change of coordinates::
|
|
1162
|
+
|
|
1163
|
+
sage: Phi.display()
|
|
1164
|
+
Phi: S^2 → R^3
|
|
1165
|
+
on U: (x, y) ↦ (X, Y, Z) = (2*x/(x^2 + y^2 + 1), 2*y/(x^2 + y^2 + 1), (x^2 + y^2 - 1)/(x^2 + y^2 + 1))
|
|
1166
|
+
on V: (u, v) ↦ (X, Y, Z) = (2*u/(u^2 + v^2 + 1), 2*v/(u^2 + v^2 + 1), -(u^2 + v^2 - 1)/(u^2 + v^2 + 1))
|
|
1167
|
+
|
|
1168
|
+
If a chart covers entirely the map's domain, the mention "on ..."
|
|
1169
|
+
is omitted::
|
|
1170
|
+
|
|
1171
|
+
sage: Phi.restrict(U).display()
|
|
1172
|
+
Phi: U → R^3
|
|
1173
|
+
(x, y) ↦ (X, Y, Z) = (2*x/(x^2 + y^2 + 1), 2*y/(x^2 + y^2 + 1), (x^2 + y^2 - 1)/(x^2 + y^2 + 1))
|
|
1174
|
+
|
|
1175
|
+
A shortcut of ``display()`` is ``disp()``::
|
|
1176
|
+
|
|
1177
|
+
sage: Phi.disp()
|
|
1178
|
+
Phi: S^2 → R^3
|
|
1179
|
+
on U: (x, y) ↦ (X, Y, Z) = (2*x/(x^2 + y^2 + 1), 2*y/(x^2 + y^2 + 1), (x^2 + y^2 - 1)/(x^2 + y^2 + 1))
|
|
1180
|
+
on V: (u, v) ↦ (X, Y, Z) = (2*u/(u^2 + v^2 + 1), 2*v/(u^2 + v^2 + 1), -(u^2 + v^2 - 1)/(u^2 + v^2 + 1))
|
|
1181
|
+
|
|
1182
|
+
Display when SymPy is the symbolic engine::
|
|
1183
|
+
|
|
1184
|
+
sage: M.set_calculus_method('sympy')
|
|
1185
|
+
sage: N.set_calculus_method('sympy')
|
|
1186
|
+
sage: Phi.display(c_xy, c_cart)
|
|
1187
|
+
Phi: S^2 → R^3
|
|
1188
|
+
on U: (x, y) ↦ (X, Y, Z) = (2*x/(x**2 + y**2 + 1),
|
|
1189
|
+
2*y/(x**2 + y**2 + 1), (x**2 + y**2 - 1)/(x**2 + y**2 + 1))
|
|
1190
|
+
sage: latex(Phi.display(c_xy, c_cart))
|
|
1191
|
+
\begin{array}{llcl} \Phi:& S^2 & \longrightarrow & \RR^3
|
|
1192
|
+
\\ \text{on}\ U : & \left(x, y\right) & \longmapsto
|
|
1193
|
+
& \left(X, Y, Z\right) = \left(\frac{2 x}{x^{2} + y^{2} + 1},
|
|
1194
|
+
\frac{2 y}{x^{2} + y^{2} + 1},
|
|
1195
|
+
\frac{x^{2} + y^{2} - 1}{x^{2} + y^{2} + 1}\right)
|
|
1196
|
+
\end{array}
|
|
1197
|
+
"""
|
|
1198
|
+
from sage.misc.latex import latex
|
|
1199
|
+
from sage.tensor.modules.format_utilities import FormattedExpansion
|
|
1200
|
+
from sage.typeset.unicode_characters import unicode_mapsto, unicode_to
|
|
1201
|
+
|
|
1202
|
+
def _display_expression(self, chart1, chart2, result):
|
|
1203
|
+
r"""
|
|
1204
|
+
Helper function for :meth:`display`.
|
|
1205
|
+
"""
|
|
1206
|
+
try:
|
|
1207
|
+
# get coordinate expression
|
|
1208
|
+
coord_func = self.coord_functions(chart1, chart2)
|
|
1209
|
+
expression = coord_func.expr()
|
|
1210
|
+
except (TypeError, ValueError):
|
|
1211
|
+
return
|
|
1212
|
+
# if that succeeds, proceed:
|
|
1213
|
+
coords1 = chart1[:]
|
|
1214
|
+
if len(coords1) == 1:
|
|
1215
|
+
coords1 = coords1[0]
|
|
1216
|
+
coords2 = chart2[:]
|
|
1217
|
+
if len(coords2) == 1:
|
|
1218
|
+
coords2 = coords2[0]
|
|
1219
|
+
if len(expression) == 1:
|
|
1220
|
+
expression = expression[0]
|
|
1221
|
+
coord_func = coord_func[0]
|
|
1222
|
+
if chart1._domain == self._domain:
|
|
1223
|
+
result._txt += ' '
|
|
1224
|
+
result._latex += ' & '
|
|
1225
|
+
else:
|
|
1226
|
+
result._txt += 'on ' + chart1._domain._name + ': '
|
|
1227
|
+
result._latex += r'\text{on}\ ' + latex(chart1._domain) + r': & '
|
|
1228
|
+
result._txt += repr(coords1) + ' ' + unicode_mapsto + ' '
|
|
1229
|
+
result._latex += latex(coords1) + r'& \longmapsto & '
|
|
1230
|
+
if chart2 == chart1:
|
|
1231
|
+
result._txt += repr(expression) + '\n'
|
|
1232
|
+
result._latex += latex(coord_func) + r'\\'
|
|
1233
|
+
else:
|
|
1234
|
+
result._txt += repr(coords2) + ' = ' + repr(expression) + '\n'
|
|
1235
|
+
result._latex += latex(coords2) + ' = ' + latex(coord_func) + r'\\'
|
|
1236
|
+
|
|
1237
|
+
result = FormattedExpansion()
|
|
1238
|
+
if self._name is None:
|
|
1239
|
+
symbol = ''
|
|
1240
|
+
else:
|
|
1241
|
+
symbol = self._name + ': '
|
|
1242
|
+
result._txt = (
|
|
1243
|
+
symbol
|
|
1244
|
+
+ self._domain._name
|
|
1245
|
+
+ ' '
|
|
1246
|
+
+ unicode_to
|
|
1247
|
+
+ ' '
|
|
1248
|
+
+ self._codomain._name
|
|
1249
|
+
+ '\n'
|
|
1250
|
+
)
|
|
1251
|
+
if self._latex_name is None:
|
|
1252
|
+
symbol = ''
|
|
1253
|
+
else:
|
|
1254
|
+
symbol = self._latex_name + ':'
|
|
1255
|
+
result._latex = (
|
|
1256
|
+
r'\begin{array}{llcl} '
|
|
1257
|
+
+ symbol
|
|
1258
|
+
+ r'&'
|
|
1259
|
+
+ latex(self._domain)
|
|
1260
|
+
+ r'& \longrightarrow & '
|
|
1261
|
+
+ latex(self._codomain)
|
|
1262
|
+
+ r'\\'
|
|
1263
|
+
)
|
|
1264
|
+
if chart1 is None:
|
|
1265
|
+
if chart2 is None:
|
|
1266
|
+
for ch1 in self._domain._top_charts:
|
|
1267
|
+
for ch2 in self._codomain.atlas():
|
|
1268
|
+
_display_expression(self, ch1, ch2, result)
|
|
1269
|
+
else:
|
|
1270
|
+
for ch1 in self._domain._top_charts:
|
|
1271
|
+
_display_expression(self, ch1, chart2, result)
|
|
1272
|
+
else:
|
|
1273
|
+
if chart2 is None:
|
|
1274
|
+
for ch2 in self._codomain.atlas():
|
|
1275
|
+
_display_expression(self, chart1, ch2, result)
|
|
1276
|
+
else:
|
|
1277
|
+
_display_expression(self, chart1, chart2, result)
|
|
1278
|
+
result._txt = result._txt[:-1]
|
|
1279
|
+
result._latex = result._latex[:-2] + r'\end{array}'
|
|
1280
|
+
return result
|
|
1281
|
+
|
|
1282
|
+
disp = display
|
|
1283
|
+
|
|
1284
|
+
def coord_functions(self, chart1=None, chart2=None):
|
|
1285
|
+
r"""
|
|
1286
|
+
Return the functions of the coordinates representing ``self``
|
|
1287
|
+
in a given pair of charts.
|
|
1288
|
+
|
|
1289
|
+
If these functions are not already known, they are computed from
|
|
1290
|
+
known ones by means of change-of-chart formulas.
|
|
1291
|
+
|
|
1292
|
+
INPUT:
|
|
1293
|
+
|
|
1294
|
+
- ``chart1`` -- (default: ``None``) chart on the domain of ``self``;
|
|
1295
|
+
if ``None``, the domain's default chart is assumed
|
|
1296
|
+
- ``chart2`` -- (default: ``None``) chart on the codomain of ``self``;
|
|
1297
|
+
if ``None``, the codomain's default chart is assumed
|
|
1298
|
+
|
|
1299
|
+
OUTPUT:
|
|
1300
|
+
|
|
1301
|
+
- a :class:`~sage.manifolds.chart_func.MultiCoordFunction`
|
|
1302
|
+
representing the continuous map in the above two charts
|
|
1303
|
+
|
|
1304
|
+
EXAMPLES:
|
|
1305
|
+
|
|
1306
|
+
Continuous map from a 2-dimensional manifold to a 3-dimensional
|
|
1307
|
+
one::
|
|
1308
|
+
|
|
1309
|
+
sage: M = Manifold(2, 'M', structure='topological')
|
|
1310
|
+
sage: N = Manifold(3, 'N', structure='topological')
|
|
1311
|
+
sage: c_uv.<u,v> = M.chart()
|
|
1312
|
+
sage: c_xyz.<x,y,z> = N.chart()
|
|
1313
|
+
sage: Phi = M.continuous_map(N, (u*v, u/v, u+v), name='Phi',
|
|
1314
|
+
....: latex_name=r'\Phi')
|
|
1315
|
+
sage: Phi.display()
|
|
1316
|
+
Phi: M → N
|
|
1317
|
+
(u, v) ↦ (x, y, z) = (u*v, u/v, u + v)
|
|
1318
|
+
sage: Phi.coord_functions(c_uv, c_xyz)
|
|
1319
|
+
Coordinate functions (u*v, u/v, u + v) on the Chart (M, (u, v))
|
|
1320
|
+
sage: Phi.coord_functions() # equivalent to above since 'uv' and 'xyz' are default charts
|
|
1321
|
+
Coordinate functions (u*v, u/v, u + v) on the Chart (M, (u, v))
|
|
1322
|
+
sage: type(Phi.coord_functions())
|
|
1323
|
+
<class 'sage.manifolds.chart_func.MultiCoordFunction'>
|
|
1324
|
+
|
|
1325
|
+
Coordinate representation in other charts::
|
|
1326
|
+
|
|
1327
|
+
sage: c_UV.<U,V> = M.chart() # new chart on M
|
|
1328
|
+
sage: ch_uv_UV = c_uv.transition_map(c_UV, [u-v, u+v])
|
|
1329
|
+
sage: ch_uv_UV.inverse()(U,V)
|
|
1330
|
+
(1/2*U + 1/2*V, -1/2*U + 1/2*V)
|
|
1331
|
+
sage: c_XYZ.<X,Y,Z> = N.chart() # new chart on N
|
|
1332
|
+
sage: ch_xyz_XYZ = c_xyz.transition_map(c_XYZ,
|
|
1333
|
+
....: [2*x-3*y+z, y+z-x, -x+2*y-z])
|
|
1334
|
+
sage: ch_xyz_XYZ.inverse()(X,Y,Z)
|
|
1335
|
+
(3*X + Y + 4*Z, 2*X + Y + 3*Z, X + Y + Z)
|
|
1336
|
+
sage: Phi.coord_functions(c_UV, c_xyz)
|
|
1337
|
+
Coordinate functions (-1/4*U^2 + 1/4*V^2, -(U + V)/(U - V), V) on
|
|
1338
|
+
the Chart (M, (U, V))
|
|
1339
|
+
sage: Phi.coord_functions(c_uv, c_XYZ)
|
|
1340
|
+
Coordinate functions (((2*u + 1)*v^2 + u*v - 3*u)/v,
|
|
1341
|
+
-((u - 1)*v^2 - u*v - u)/v, -((u + 1)*v^2 + u*v - 2*u)/v) on the
|
|
1342
|
+
Chart (M, (u, v))
|
|
1343
|
+
sage: Phi.coord_functions(c_UV, c_XYZ)
|
|
1344
|
+
Coordinate functions
|
|
1345
|
+
(-1/2*(U^3 - (U - 2)*V^2 + V^3 - (U^2 + 2*U + 6)*V - 6*U)/(U - V),
|
|
1346
|
+
1/4*(U^3 - (U + 4)*V^2 + V^3 - (U^2 - 4*U + 4)*V - 4*U)/(U - V),
|
|
1347
|
+
1/4*(U^3 - (U - 4)*V^2 + V^3 - (U^2 + 4*U + 8)*V - 8*U)/(U - V))
|
|
1348
|
+
on the Chart (M, (U, V))
|
|
1349
|
+
|
|
1350
|
+
Coordinate representation with respect to a subchart in the domain::
|
|
1351
|
+
|
|
1352
|
+
sage: A = M.open_subset('A', coord_def={c_uv: u>0})
|
|
1353
|
+
sage: Phi.coord_functions(c_uv.restrict(A), c_xyz)
|
|
1354
|
+
Coordinate functions (u*v, u/v, u + v) on the Chart (A, (u, v))
|
|
1355
|
+
|
|
1356
|
+
Coordinate representation with respect to a superchart
|
|
1357
|
+
in the codomain::
|
|
1358
|
+
|
|
1359
|
+
sage: B = N.open_subset('B', coord_def={c_xyz: x<0})
|
|
1360
|
+
sage: c_xyz_B = c_xyz.restrict(B)
|
|
1361
|
+
sage: Phi1 = M.continuous_map(B, {(c_uv, c_xyz_B): (u*v, u/v, u+v)})
|
|
1362
|
+
sage: Phi1.coord_functions(c_uv, c_xyz_B) # definition charts
|
|
1363
|
+
Coordinate functions (u*v, u/v, u + v) on the Chart (M, (u, v))
|
|
1364
|
+
sage: Phi1.coord_functions(c_uv, c_xyz) # c_xyz = superchart of c_xyz_B
|
|
1365
|
+
Coordinate functions (u*v, u/v, u + v) on the Chart (M, (u, v))
|
|
1366
|
+
|
|
1367
|
+
Coordinate representation with respect to a pair
|
|
1368
|
+
``(subchart, superchart)``::
|
|
1369
|
+
|
|
1370
|
+
sage: Phi1.coord_functions(c_uv.restrict(A), c_xyz)
|
|
1371
|
+
Coordinate functions (u*v, u/v, u + v) on the Chart (A, (u, v))
|
|
1372
|
+
|
|
1373
|
+
Same example with SymPy as the symbolic calculus engine::
|
|
1374
|
+
|
|
1375
|
+
sage: M.set_calculus_method('sympy')
|
|
1376
|
+
sage: N.set_calculus_method('sympy')
|
|
1377
|
+
sage: Phi = M.continuous_map(N, (u*v, u/v, u+v), name='Phi',
|
|
1378
|
+
....: latex_name=r'\Phi')
|
|
1379
|
+
sage: Phi.coord_functions(c_uv, c_xyz)
|
|
1380
|
+
Coordinate functions (u*v, u/v, u + v) on the Chart (M, (u, v))
|
|
1381
|
+
sage: Phi.coord_functions(c_UV, c_xyz)
|
|
1382
|
+
Coordinate functions (-U**2/4 + V**2/4, (-U - V)/(U - V), V) on the Chart (M, (U, V))
|
|
1383
|
+
sage: Phi.coord_functions(c_UV, c_XYZ)
|
|
1384
|
+
Coordinate functions ((-U**3 + U**2*V + U*V**2 + 2*U*V + 6*U - V**3
|
|
1385
|
+
- 2*V**2 + 6*V)/(2*(U - V)), (U**3/4 - U**2*V/4 - U*V**2/4 + U*V
|
|
1386
|
+
- U + V**3/4 - V**2 - V)/(U - V), (U**3 - U**2*V - U*V**2 - 4*U*V
|
|
1387
|
+
- 8*U + V**3 + 4*V**2 - 8*V)/(4*(U - V))) on the Chart (M, (U, V))
|
|
1388
|
+
"""
|
|
1389
|
+
dom1 = self._domain
|
|
1390
|
+
dom2 = self._codomain
|
|
1391
|
+
def_chart1 = dom1._def_chart
|
|
1392
|
+
def_chart2 = dom2._def_chart
|
|
1393
|
+
if chart1 is None:
|
|
1394
|
+
chart1 = def_chart1
|
|
1395
|
+
if chart2 is None:
|
|
1396
|
+
chart2 = def_chart2
|
|
1397
|
+
if (chart1, chart2) not in self._coord_expression:
|
|
1398
|
+
# Check whether (chart1, chart2) are (subchart, superchart) of
|
|
1399
|
+
# a pair of charts where the expression of self is known:
|
|
1400
|
+
for ochart1, ochart2 in self._coord_expression:
|
|
1401
|
+
if chart1 in ochart1._subcharts and ochart2 in chart2._subcharts:
|
|
1402
|
+
coord_functions = self._coord_expression[(ochart1, ochart2)].expr()
|
|
1403
|
+
self._coord_expression[(chart1, chart2)] = chart1.multifunction(
|
|
1404
|
+
*coord_functions
|
|
1405
|
+
)
|
|
1406
|
+
return self._coord_expression[(chart1, chart2)]
|
|
1407
|
+
# Special case of the identity in a single chart:
|
|
1408
|
+
if self._is_identity and chart1 == chart2:
|
|
1409
|
+
coord_functions = chart1[:]
|
|
1410
|
+
self._coord_expression[(chart1, chart1)] = chart1.multifunction(
|
|
1411
|
+
*coord_functions
|
|
1412
|
+
)
|
|
1413
|
+
return self._coord_expression[(chart1, chart2)]
|
|
1414
|
+
# Some change of coordinates must be performed
|
|
1415
|
+
change_start = []
|
|
1416
|
+
change_arrival = []
|
|
1417
|
+
for ochart1, ochart2 in self._coord_expression:
|
|
1418
|
+
if chart1 == ochart1:
|
|
1419
|
+
change_arrival.append(ochart2)
|
|
1420
|
+
if chart2 == ochart2:
|
|
1421
|
+
change_start.append(ochart1)
|
|
1422
|
+
# 1/ Trying to make a change of chart only on the codomain:
|
|
1423
|
+
# the codomain's default chart is privileged:
|
|
1424
|
+
sel_chart2 = None # selected chart2
|
|
1425
|
+
if (
|
|
1426
|
+
def_chart2 in change_arrival
|
|
1427
|
+
and (def_chart2, chart2) in dom2._coord_changes
|
|
1428
|
+
):
|
|
1429
|
+
sel_chart2 = def_chart2
|
|
1430
|
+
else:
|
|
1431
|
+
for ochart2 in change_arrival:
|
|
1432
|
+
if (ochart2, chart2) in dom2._coord_changes:
|
|
1433
|
+
sel_chart2 = ochart2
|
|
1434
|
+
break
|
|
1435
|
+
if sel_chart2 is not None:
|
|
1436
|
+
oexpr = self._coord_expression[(chart1, sel_chart2)]
|
|
1437
|
+
chg2 = dom2._coord_changes[(sel_chart2, chart2)]
|
|
1438
|
+
self._coord_expression[(chart1, chart2)] = chart1.multifunction(
|
|
1439
|
+
*chg2(*oexpr.expr())
|
|
1440
|
+
)
|
|
1441
|
+
return self._coord_expression[(chart1, chart2)]
|
|
1442
|
+
|
|
1443
|
+
# 2/ Trying to make a change of chart only on the start domain:
|
|
1444
|
+
# the domain's default chart is privileged:
|
|
1445
|
+
sel_chart1 = None # selected chart1
|
|
1446
|
+
if (
|
|
1447
|
+
def_chart1 in change_start
|
|
1448
|
+
and (chart1, def_chart1) in dom1._coord_changes
|
|
1449
|
+
):
|
|
1450
|
+
sel_chart1 = def_chart1
|
|
1451
|
+
else:
|
|
1452
|
+
for ochart1 in change_start:
|
|
1453
|
+
if (chart1, ochart1) in dom1._coord_changes:
|
|
1454
|
+
sel_chart1 = ochart1
|
|
1455
|
+
break
|
|
1456
|
+
if sel_chart1 is not None:
|
|
1457
|
+
oexpr = self._coord_expression[(sel_chart1, chart2)]
|
|
1458
|
+
chg1 = dom1._coord_changes[(chart1, sel_chart1)]
|
|
1459
|
+
self._coord_expression[(chart1, chart2)] = chart1.multifunction(
|
|
1460
|
+
*oexpr(*chg1._transf.expr())
|
|
1461
|
+
)
|
|
1462
|
+
return self._coord_expression[(chart1, chart2)]
|
|
1463
|
+
|
|
1464
|
+
# 3/ If this point is reached, it is necessary to perform some
|
|
1465
|
+
# coordinate change both on the start domain and the arrival one
|
|
1466
|
+
# the default charts are privileged:
|
|
1467
|
+
if (
|
|
1468
|
+
(def_chart1, def_chart2) in self._coord_expression
|
|
1469
|
+
and (chart1, def_chart1) in dom1._coord_changes
|
|
1470
|
+
and (def_chart2, chart2) in dom2._coord_changes
|
|
1471
|
+
):
|
|
1472
|
+
sel_chart1 = def_chart1
|
|
1473
|
+
sel_chart2 = def_chart2
|
|
1474
|
+
else:
|
|
1475
|
+
for ochart1, ochart2 in self._coord_expression:
|
|
1476
|
+
if (chart1, ochart1) in dom1._coord_changes and (
|
|
1477
|
+
ochart2,
|
|
1478
|
+
chart2,
|
|
1479
|
+
) in dom2._coord_changes:
|
|
1480
|
+
sel_chart1 = ochart1
|
|
1481
|
+
sel_chart2 = ochart2
|
|
1482
|
+
break
|
|
1483
|
+
if sel_chart1 is not None and sel_chart2 is not None:
|
|
1484
|
+
oexpr = self._coord_expression[(sel_chart1, sel_chart2)]
|
|
1485
|
+
chg1 = dom1._coord_changes[(chart1, sel_chart1)]
|
|
1486
|
+
chg2 = dom2._coord_changes[(sel_chart2, chart2)]
|
|
1487
|
+
self._coord_expression[(chart1, chart2)] = chart1.multifunction(
|
|
1488
|
+
*chg2(*oexpr(*chg1._transf.expr()))
|
|
1489
|
+
)
|
|
1490
|
+
return self._coord_expression[(chart1, chart2)]
|
|
1491
|
+
|
|
1492
|
+
# 4/ If this point is reached, the demanded value cannot be
|
|
1493
|
+
# computed
|
|
1494
|
+
raise ValueError(
|
|
1495
|
+
"the expression of the map in the pair "
|
|
1496
|
+
+ "({}, {})".format(chart1, chart2)
|
|
1497
|
+
+ " cannot "
|
|
1498
|
+
+ "be computed by means of known changes of charts"
|
|
1499
|
+
)
|
|
1500
|
+
|
|
1501
|
+
return self._coord_expression[(chart1, chart2)]
|
|
1502
|
+
|
|
1503
|
+
def expr(self, chart1=None, chart2=None):
|
|
1504
|
+
r"""
|
|
1505
|
+
Return the expression of ``self`` in terms of
|
|
1506
|
+
specified coordinates.
|
|
1507
|
+
|
|
1508
|
+
If the expression is not already known, it is computed from some
|
|
1509
|
+
known expression by means of change-of-chart formulas.
|
|
1510
|
+
|
|
1511
|
+
INPUT:
|
|
1512
|
+
|
|
1513
|
+
- ``chart1`` -- (default: ``None``) chart on the map's domain;
|
|
1514
|
+
if ``None``, the domain's default chart is assumed
|
|
1515
|
+
- ``chart2`` -- (default: ``None``) chart on the map's codomain;
|
|
1516
|
+
if ``None``, the codomain's default chart is assumed
|
|
1517
|
+
|
|
1518
|
+
OUTPUT:
|
|
1519
|
+
|
|
1520
|
+
- symbolic expression representing the continuous map in the
|
|
1521
|
+
above two charts
|
|
1522
|
+
|
|
1523
|
+
EXAMPLES:
|
|
1524
|
+
|
|
1525
|
+
Continuous map from a 2-dimensional manifold to a
|
|
1526
|
+
3-dimensional one::
|
|
1527
|
+
|
|
1528
|
+
sage: M = Manifold(2, 'M', structure='topological')
|
|
1529
|
+
sage: N = Manifold(3, 'N', structure='topological')
|
|
1530
|
+
sage: c_uv.<u,v> = M.chart()
|
|
1531
|
+
sage: c_xyz.<x,y,z> = N.chart()
|
|
1532
|
+
sage: Phi = M.continuous_map(N, (u*v, u/v, u+v), name='Phi',
|
|
1533
|
+
....: latex_name=r'\Phi')
|
|
1534
|
+
sage: Phi.display()
|
|
1535
|
+
Phi: M → N
|
|
1536
|
+
(u, v) ↦ (x, y, z) = (u*v, u/v, u + v)
|
|
1537
|
+
sage: Phi.expr(c_uv, c_xyz)
|
|
1538
|
+
(u*v, u/v, u + v)
|
|
1539
|
+
sage: Phi.expr() # equivalent to above since 'uv' and 'xyz' are default charts
|
|
1540
|
+
(u*v, u/v, u + v)
|
|
1541
|
+
sage: type(Phi.expr()[0])
|
|
1542
|
+
<class 'sage.symbolic.expression.Expression'>
|
|
1543
|
+
|
|
1544
|
+
Expressions in other charts::
|
|
1545
|
+
|
|
1546
|
+
sage: c_UV.<U,V> = M.chart() # new chart on M
|
|
1547
|
+
sage: ch_uv_UV = c_uv.transition_map(c_UV, [u-v, u+v])
|
|
1548
|
+
sage: ch_uv_UV.inverse()(U,V)
|
|
1549
|
+
(1/2*U + 1/2*V, -1/2*U + 1/2*V)
|
|
1550
|
+
sage: c_XYZ.<X,Y,Z> = N.chart() # new chart on N
|
|
1551
|
+
sage: ch_xyz_XYZ = c_xyz.transition_map(c_XYZ,
|
|
1552
|
+
....: [2*x-3*y+z, y+z-x, -x+2*y-z])
|
|
1553
|
+
sage: ch_xyz_XYZ.inverse()(X,Y,Z)
|
|
1554
|
+
(3*X + Y + 4*Z, 2*X + Y + 3*Z, X + Y + Z)
|
|
1555
|
+
sage: Phi.expr(c_UV, c_xyz)
|
|
1556
|
+
(-1/4*U^2 + 1/4*V^2, -(U + V)/(U - V), V)
|
|
1557
|
+
sage: Phi.expr(c_uv, c_XYZ)
|
|
1558
|
+
(((2*u + 1)*v^2 + u*v - 3*u)/v,
|
|
1559
|
+
-((u - 1)*v^2 - u*v - u)/v,
|
|
1560
|
+
-((u + 1)*v^2 + u*v - 2*u)/v)
|
|
1561
|
+
sage: Phi.expr(c_UV, c_XYZ)
|
|
1562
|
+
(-1/2*(U^3 - (U - 2)*V^2 + V^3 - (U^2 + 2*U + 6)*V - 6*U)/(U - V),
|
|
1563
|
+
1/4*(U^3 - (U + 4)*V^2 + V^3 - (U^2 - 4*U + 4)*V - 4*U)/(U - V),
|
|
1564
|
+
1/4*(U^3 - (U - 4)*V^2 + V^3 - (U^2 + 4*U + 8)*V - 8*U)/(U - V))
|
|
1565
|
+
|
|
1566
|
+
A rotation in some Euclidean plane::
|
|
1567
|
+
|
|
1568
|
+
sage: M = Manifold(2, 'M', structure='topological') # the plane (minus a segment to have global regular spherical coordinates)
|
|
1569
|
+
sage: c_spher.<r,ph> = M.chart(r'r:(0,+oo) ph:(0,2*pi):\phi') # spherical coordinates on the plane
|
|
1570
|
+
sage: rot = M.continuous_map(M, (r, ph+pi/3), name='R') # pi/3 rotation around r=0
|
|
1571
|
+
sage: rot.expr()
|
|
1572
|
+
(r, 1/3*pi + ph)
|
|
1573
|
+
|
|
1574
|
+
Expression of the rotation in terms of Cartesian coordinates::
|
|
1575
|
+
|
|
1576
|
+
sage: c_cart.<x,y> = M.chart() # Declaration of Cartesian coordinates
|
|
1577
|
+
sage: ch_spher_cart = c_spher.transition_map(c_cart,
|
|
1578
|
+
....: [r*cos(ph), r*sin(ph)]) # relation to spherical coordinates
|
|
1579
|
+
sage: ch_spher_cart.set_inverse(sqrt(x^2+y^2), atan2(y,x))
|
|
1580
|
+
Check of the inverse coordinate transformation:
|
|
1581
|
+
r == r *passed*
|
|
1582
|
+
ph == arctan2(r*sin(ph), r*cos(ph)) **failed**
|
|
1583
|
+
x == x *passed*
|
|
1584
|
+
y == y *passed*
|
|
1585
|
+
NB: a failed report can reflect a mere lack of simplification.
|
|
1586
|
+
sage: rot.expr(c_cart, c_cart)
|
|
1587
|
+
(-1/2*sqrt(3)*y + 1/2*x, 1/2*sqrt(3)*x + 1/2*y)
|
|
1588
|
+
"""
|
|
1589
|
+
return self.coord_functions(chart1, chart2).expr()
|
|
1590
|
+
|
|
1591
|
+
expression = expr
|
|
1592
|
+
|
|
1593
|
+
def set_expr(self, chart1, chart2, coord_functions):
|
|
1594
|
+
r"""
|
|
1595
|
+
Set a new coordinate representation of ``self``.
|
|
1596
|
+
|
|
1597
|
+
The expressions with respect to other charts are deleted, in order to
|
|
1598
|
+
avoid any inconsistency. To keep them, use :meth:`add_expr` instead.
|
|
1599
|
+
|
|
1600
|
+
INPUT:
|
|
1601
|
+
|
|
1602
|
+
- ``chart1`` -- chart for the coordinates on the domain of ``self``
|
|
1603
|
+
- ``chart2`` -- chart for the coordinates on the codomain of ``self``
|
|
1604
|
+
- ``coord_functions`` -- the coordinate symbolic expression of the
|
|
1605
|
+
map in the above charts: list (or tuple) of the coordinates of
|
|
1606
|
+
the image expressed in terms of the coordinates of the considered
|
|
1607
|
+
point; if the dimension of the arrival manifold is 1, a single
|
|
1608
|
+
coordinate expression can be passed instead of a tuple with a
|
|
1609
|
+
single element
|
|
1610
|
+
|
|
1611
|
+
EXAMPLES:
|
|
1612
|
+
|
|
1613
|
+
Polar representation of a planar rotation initially defined in
|
|
1614
|
+
Cartesian coordinates::
|
|
1615
|
+
|
|
1616
|
+
sage: M = Manifold(2, 'R^2', latex_name=r'\RR^2', structure='topological') # the Euclidean plane R^2
|
|
1617
|
+
sage: c_xy.<x,y> = M.chart() # Cartesian coordinate on R^2
|
|
1618
|
+
sage: U = M.open_subset('U', coord_def={c_xy: (y!=0, x<0)}) # the complement of the segment y=0 and x>0
|
|
1619
|
+
sage: c_cart = c_xy.restrict(U) # Cartesian coordinates on U
|
|
1620
|
+
sage: c_spher.<r,ph> = U.chart(r'r:(0,+oo) ph:(0,2*pi):\phi') # spherical coordinates on U
|
|
1621
|
+
|
|
1622
|
+
Links between spherical coordinates and Cartesian ones::
|
|
1623
|
+
|
|
1624
|
+
sage: ch_cart_spher = c_cart.transition_map(c_spher,
|
|
1625
|
+
....: [sqrt(x*x+y*y), atan2(y,x)])
|
|
1626
|
+
sage: ch_cart_spher.set_inverse(r*cos(ph), r*sin(ph))
|
|
1627
|
+
Check of the inverse coordinate transformation:
|
|
1628
|
+
x == x *passed*
|
|
1629
|
+
y == y *passed*
|
|
1630
|
+
r == r *passed*
|
|
1631
|
+
ph == arctan2(r*sin(ph), r*cos(ph)) **failed**
|
|
1632
|
+
NB: a failed report can reflect a mere lack of simplification.
|
|
1633
|
+
sage: rot = U.continuous_map(U, ((x - sqrt(3)*y)/2, (sqrt(3)*x + y)/2),
|
|
1634
|
+
....: name='R')
|
|
1635
|
+
sage: rot.display(c_cart, c_cart)
|
|
1636
|
+
R: U → U
|
|
1637
|
+
(x, y) ↦ (-1/2*sqrt(3)*y + 1/2*x, 1/2*sqrt(3)*x + 1/2*y)
|
|
1638
|
+
|
|
1639
|
+
Let us use the method :meth:`set_expr` to set the
|
|
1640
|
+
spherical-coordinate expression by hand::
|
|
1641
|
+
|
|
1642
|
+
sage: rot.set_expr(c_spher, c_spher, (r, ph+pi/3))
|
|
1643
|
+
sage: rot.display(c_spher, c_spher)
|
|
1644
|
+
R: U → U
|
|
1645
|
+
(r, ph) ↦ (r, 1/3*pi + ph)
|
|
1646
|
+
|
|
1647
|
+
The expression in Cartesian coordinates has been erased::
|
|
1648
|
+
|
|
1649
|
+
sage: rot._coord_expression
|
|
1650
|
+
{(Chart (U, (r, ph)),
|
|
1651
|
+
Chart (U, (r, ph))): Coordinate functions (r, 1/3*pi + ph)
|
|
1652
|
+
on the Chart (U, (r, ph))}
|
|
1653
|
+
|
|
1654
|
+
It is recovered (thanks to the known change of coordinates) by a call
|
|
1655
|
+
to :meth:`display`::
|
|
1656
|
+
|
|
1657
|
+
sage: rot.display(c_cart, c_cart)
|
|
1658
|
+
R: U → U
|
|
1659
|
+
(x, y) ↦ (-1/2*sqrt(3)*y + 1/2*x, 1/2*sqrt(3)*x + 1/2*y)
|
|
1660
|
+
|
|
1661
|
+
sage: rot._coord_expression # random (dictionary output)
|
|
1662
|
+
{(Chart (U, (x, y)),
|
|
1663
|
+
Chart (U, (x, y))): Coordinate functions (-1/2*sqrt(3)*y + 1/2*x,
|
|
1664
|
+
1/2*sqrt(3)*x + 1/2*y) on the Chart (U, (x, y)),
|
|
1665
|
+
(Chart (U, (r, ph)),
|
|
1666
|
+
Chart (U, (r, ph))): Coordinate functions (r, 1/3*pi + ph)
|
|
1667
|
+
on the Chart (U, (r, ph))}
|
|
1668
|
+
|
|
1669
|
+
TESTS:
|
|
1670
|
+
|
|
1671
|
+
We check that this does not change the equality nor the hash value::
|
|
1672
|
+
|
|
1673
|
+
sage: M = Manifold(2, 'R^2', latex_name=r'\RR^2', structure='topological')
|
|
1674
|
+
sage: c_xy.<x,y> = M.chart()
|
|
1675
|
+
sage: U = M.open_subset('U', coord_def={c_xy: (y!=0, x<0)})
|
|
1676
|
+
sage: c_cart = c_xy.restrict(U)
|
|
1677
|
+
sage: c_spher.<r,ph> = U.chart(r'r:(0,+oo) ph:(0,2*pi):\phi')
|
|
1678
|
+
sage: ch_cart_spher = c_cart.transition_map(c_spher,
|
|
1679
|
+
....: [sqrt(x*x+y*y), atan2(y,x)])
|
|
1680
|
+
sage: ch_cart_spher.set_inverse(r*cos(ph), r*sin(ph))
|
|
1681
|
+
Check of the inverse coordinate transformation:
|
|
1682
|
+
x == x *passed*
|
|
1683
|
+
y == y *passed*
|
|
1684
|
+
r == r *passed*
|
|
1685
|
+
ph == arctan2(r*sin(ph), r*cos(ph)) **failed**
|
|
1686
|
+
NB: a failed report can reflect a mere lack of simplification.
|
|
1687
|
+
sage: rot = U.continuous_map(U, ((x - sqrt(3)*y)/2, (sqrt(3)*x + y)/2),
|
|
1688
|
+
....: name='R')
|
|
1689
|
+
sage: rot2 = copy(rot)
|
|
1690
|
+
sage: rot == rot2 and hash(rot) == hash(rot2)
|
|
1691
|
+
True
|
|
1692
|
+
sage: rot.set_expr(c_spher, c_spher, (r, ph+pi/3))
|
|
1693
|
+
sage: rot == rot2 and hash(rot) == hash(rot2)
|
|
1694
|
+
True
|
|
1695
|
+
"""
|
|
1696
|
+
if self._is_identity:
|
|
1697
|
+
raise NotImplementedError(
|
|
1698
|
+
"set_expr() must not be used for the identity map"
|
|
1699
|
+
)
|
|
1700
|
+
if chart1 not in self._domain.atlas():
|
|
1701
|
+
raise ValueError(
|
|
1702
|
+
"the {}".format(chart1)
|
|
1703
|
+
+ " has not been defined on the {}".format(self._domain)
|
|
1704
|
+
)
|
|
1705
|
+
if chart2 not in self._codomain.atlas():
|
|
1706
|
+
raise ValueError(
|
|
1707
|
+
"the {}".format(chart2)
|
|
1708
|
+
+ " has not been defined on the {}".format(self._codomain)
|
|
1709
|
+
)
|
|
1710
|
+
self._coord_expression.clear()
|
|
1711
|
+
self._del_derived()
|
|
1712
|
+
n2 = self._codomain.dim()
|
|
1713
|
+
if n2 > 1:
|
|
1714
|
+
if len(coord_functions) != n2:
|
|
1715
|
+
raise ValueError(
|
|
1716
|
+
"{} coordinate functions must ".format(n2) + "be provided."
|
|
1717
|
+
)
|
|
1718
|
+
self._coord_expression[(chart1, chart2)] = chart1.multifunction(
|
|
1719
|
+
*coord_functions
|
|
1720
|
+
)
|
|
1721
|
+
else:
|
|
1722
|
+
if isinstance(coord_functions, (list, tuple)):
|
|
1723
|
+
coord_functions = coord_functions[0]
|
|
1724
|
+
self._coord_expression[(chart1, chart2)] = chart1.multifunction(
|
|
1725
|
+
coord_functions
|
|
1726
|
+
)
|
|
1727
|
+
|
|
1728
|
+
set_expression = set_expr
|
|
1729
|
+
|
|
1730
|
+
def add_expr(self, chart1, chart2, coord_functions):
|
|
1731
|
+
r"""
|
|
1732
|
+
Set a new coordinate representation of ``self``.
|
|
1733
|
+
|
|
1734
|
+
The previous expressions with respect to other charts are kept. To
|
|
1735
|
+
clear them, use :meth:`set_expr` instead.
|
|
1736
|
+
|
|
1737
|
+
INPUT:
|
|
1738
|
+
|
|
1739
|
+
- ``chart1`` -- chart for the coordinates on the map's domain
|
|
1740
|
+
- ``chart2`` -- chart for the coordinates on the map's codomain
|
|
1741
|
+
- ``coord_functions`` -- the coordinate symbolic expression of the
|
|
1742
|
+
map in the above charts: list (or tuple) of the coordinates of
|
|
1743
|
+
the image expressed in terms of the coordinates of the considered
|
|
1744
|
+
point; if the dimension of the arrival manifold is 1, a single
|
|
1745
|
+
coordinate expression can be passed instead of a tuple with a
|
|
1746
|
+
single element
|
|
1747
|
+
|
|
1748
|
+
.. WARNING::
|
|
1749
|
+
|
|
1750
|
+
If the map has already expressions in other charts, it
|
|
1751
|
+
is the user's responsibility to make sure that the expression
|
|
1752
|
+
to be added is consistent with them.
|
|
1753
|
+
|
|
1754
|
+
EXAMPLES:
|
|
1755
|
+
|
|
1756
|
+
Polar representation of a planar rotation initially defined in
|
|
1757
|
+
Cartesian coordinates::
|
|
1758
|
+
|
|
1759
|
+
sage: M = Manifold(2, 'R^2', latex_name=r'\RR^2', structure='topological') # the Euclidean plane R^2
|
|
1760
|
+
sage: c_xy.<x,y> = M.chart() # Cartesian coordinate on R^2
|
|
1761
|
+
sage: U = M.open_subset('U', coord_def={c_xy: (y!=0, x<0)}) # the complement of the segment y=0 and x>0
|
|
1762
|
+
sage: c_cart = c_xy.restrict(U) # Cartesian coordinates on U
|
|
1763
|
+
sage: c_spher.<r,ph> = U.chart(r'r:(0,+oo) ph:(0,2*pi):\phi') # spherical coordinates on U
|
|
1764
|
+
|
|
1765
|
+
We construct the links between spherical coordinates and
|
|
1766
|
+
Cartesian ones::
|
|
1767
|
+
|
|
1768
|
+
sage: ch_cart_spher = c_cart.transition_map(c_spher, [sqrt(x*x+y*y), atan2(y,x)])
|
|
1769
|
+
sage: ch_cart_spher.set_inverse(r*cos(ph), r*sin(ph))
|
|
1770
|
+
Check of the inverse coordinate transformation:
|
|
1771
|
+
x == x *passed*
|
|
1772
|
+
y == y *passed*
|
|
1773
|
+
r == r *passed*
|
|
1774
|
+
ph == arctan2(r*sin(ph), r*cos(ph)) **failed**
|
|
1775
|
+
NB: a failed report can reflect a mere lack of simplification.
|
|
1776
|
+
sage: rot = U.continuous_map(U, ((x - sqrt(3)*y)/2, (sqrt(3)*x + y)/2),
|
|
1777
|
+
....: name='R')
|
|
1778
|
+
sage: rot.display(c_cart, c_cart)
|
|
1779
|
+
R: U → U
|
|
1780
|
+
(x, y) ↦ (-1/2*sqrt(3)*y + 1/2*x, 1/2*sqrt(3)*x + 1/2*y)
|
|
1781
|
+
|
|
1782
|
+
If we calculate the expression in terms of spherical coordinates,
|
|
1783
|
+
via the method :meth:`display`, we notice some difficulties
|
|
1784
|
+
in ``arctan2`` simplifications::
|
|
1785
|
+
|
|
1786
|
+
sage: rot.display(c_spher, c_spher)
|
|
1787
|
+
R: U → U
|
|
1788
|
+
(r, ph) ↦ (r, arctan2(1/2*(sqrt(3)*cos(ph) + sin(ph))*r, -1/2*(sqrt(3)*sin(ph) - cos(ph))*r))
|
|
1789
|
+
|
|
1790
|
+
Therefore, we use the method :meth:`add_expr` to set the
|
|
1791
|
+
spherical-coordinate expression by hand::
|
|
1792
|
+
|
|
1793
|
+
sage: rot.add_expr(c_spher, c_spher, (r, ph+pi/3))
|
|
1794
|
+
sage: rot.display(c_spher, c_spher)
|
|
1795
|
+
R: U → U
|
|
1796
|
+
(r, ph) ↦ (r, 1/3*pi + ph)
|
|
1797
|
+
|
|
1798
|
+
The call to :meth:`add_expr` has not deleted the expression in
|
|
1799
|
+
terms of Cartesian coordinates, as we can check by printing the
|
|
1800
|
+
internal dictionary ``_coord_expression``, which stores the
|
|
1801
|
+
various internal representations of the continuous map::
|
|
1802
|
+
|
|
1803
|
+
sage: rot._coord_expression # random (dictionary output)
|
|
1804
|
+
{(Chart (U, (x, y)), Chart (U, (x, y))):
|
|
1805
|
+
Coordinate functions (-1/2*sqrt(3)*y + 1/2*x, 1/2*sqrt(3)*x + 1/2*y)
|
|
1806
|
+
on the Chart (U, (x, y)),
|
|
1807
|
+
(Chart (U, (r, ph)), Chart (U, (r, ph))):
|
|
1808
|
+
Coordinate functions (r, 1/3*pi + ph) on the Chart (U, (r, ph))}
|
|
1809
|
+
|
|
1810
|
+
If, on the contrary, we use :meth:`set_expr`, the expression in
|
|
1811
|
+
Cartesian coordinates is lost::
|
|
1812
|
+
|
|
1813
|
+
sage: rot.set_expr(c_spher, c_spher, (r, ph+pi/3))
|
|
1814
|
+
sage: rot._coord_expression
|
|
1815
|
+
{(Chart (U, (r, ph)), Chart (U, (r, ph))):
|
|
1816
|
+
Coordinate functions (r, 1/3*pi + ph) on the Chart (U, (r, ph))}
|
|
1817
|
+
|
|
1818
|
+
It is recovered (thanks to the known change of coordinates) by
|
|
1819
|
+
a call to :meth:`display`::
|
|
1820
|
+
|
|
1821
|
+
sage: rot.display(c_cart, c_cart)
|
|
1822
|
+
R: U → U
|
|
1823
|
+
(x, y) ↦ (-1/2*sqrt(3)*y + 1/2*x, 1/2*sqrt(3)*x + 1/2*y)
|
|
1824
|
+
|
|
1825
|
+
sage: rot._coord_expression # random (dictionary output)
|
|
1826
|
+
{(Chart (U, (x, y)), Chart (U, (x, y))):
|
|
1827
|
+
Coordinate functions (-1/2*sqrt(3)*y + 1/2*x, 1/2*sqrt(3)*x + 1/2*y)
|
|
1828
|
+
on the Chart (U, (x, y)),
|
|
1829
|
+
(Chart (U, (r, ph)), Chart (U, (r, ph))):
|
|
1830
|
+
Coordinate functions (r, 1/3*pi + ph) on the Chart (U, (r, ph))}
|
|
1831
|
+
|
|
1832
|
+
The rotation can be applied to a point by means of either
|
|
1833
|
+
coordinate system::
|
|
1834
|
+
|
|
1835
|
+
sage: p = M.point((1,2)) # p defined by its Cartesian coord.
|
|
1836
|
+
sage: q = rot(p) # q is computed by means of Cartesian coord.
|
|
1837
|
+
sage: p1 = M.point((sqrt(5), arctan(2)), chart=c_spher) # p1 is defined only in terms of c_spher
|
|
1838
|
+
sage: q1 = rot(p1) # computation by means of spherical coordinates
|
|
1839
|
+
sage: q1 == q
|
|
1840
|
+
True
|
|
1841
|
+
"""
|
|
1842
|
+
if self._is_identity:
|
|
1843
|
+
raise NotImplementedError(
|
|
1844
|
+
"add_expr() must not be used for the identity map"
|
|
1845
|
+
)
|
|
1846
|
+
if chart1 not in self._domain.atlas():
|
|
1847
|
+
raise ValueError(
|
|
1848
|
+
"the {}".format(chart1)
|
|
1849
|
+
+ " has not been defined on the {}".format(self._domain)
|
|
1850
|
+
)
|
|
1851
|
+
if chart2 not in self._codomain.atlas():
|
|
1852
|
+
raise ValueError(
|
|
1853
|
+
"the {}".format(chart2)
|
|
1854
|
+
+ " has not been defined on the {}".format(self._codomain)
|
|
1855
|
+
)
|
|
1856
|
+
self._del_derived()
|
|
1857
|
+
n2 = self._codomain.dim()
|
|
1858
|
+
if n2 > 1:
|
|
1859
|
+
if len(coord_functions) != n2:
|
|
1860
|
+
raise ValueError("{} coordinate functions must be provided".format(n2))
|
|
1861
|
+
self._coord_expression[(chart1, chart2)] = chart1.multifunction(
|
|
1862
|
+
*coord_functions
|
|
1863
|
+
)
|
|
1864
|
+
else:
|
|
1865
|
+
if isinstance(coord_functions, (list, tuple)):
|
|
1866
|
+
coord_functions = coord_functions[0]
|
|
1867
|
+
self._coord_expression[(chart1, chart2)] = chart1.multifunction(
|
|
1868
|
+
coord_functions
|
|
1869
|
+
)
|
|
1870
|
+
|
|
1871
|
+
add_expression = add_expr
|
|
1872
|
+
|
|
1873
|
+
def restrict(self, subdomain, subcodomain=None):
|
|
1874
|
+
r"""
|
|
1875
|
+
Restriction of ``self`` to some open subset of its
|
|
1876
|
+
domain of definition.
|
|
1877
|
+
|
|
1878
|
+
INPUT:
|
|
1879
|
+
|
|
1880
|
+
- ``subdomain`` -- :class:`~sage.manifolds.manifold.TopologicalManifold`;
|
|
1881
|
+
an open subset of the domain of ``self``
|
|
1882
|
+
- ``subcodomain`` -- (default: ``None``) an open subset of the codomain
|
|
1883
|
+
of ``self``; if ``None``, the codomain of ``self`` is assumed
|
|
1884
|
+
|
|
1885
|
+
OUTPUT:
|
|
1886
|
+
|
|
1887
|
+
- a :class:`ContinuousMap` that is the restriction
|
|
1888
|
+
of ``self`` to ``subdomain``
|
|
1889
|
+
|
|
1890
|
+
EXAMPLES:
|
|
1891
|
+
|
|
1892
|
+
Restriction to an annulus of a homeomorphism between the open unit
|
|
1893
|
+
disk and `\RR^2`::
|
|
1894
|
+
|
|
1895
|
+
sage: M = Manifold(2, 'R^2', structure='topological') # R^2
|
|
1896
|
+
sage: c_xy.<x,y> = M.chart() # Cartesian coord. on R^2
|
|
1897
|
+
sage: D = M.open_subset('D', coord_def={c_xy: x^2+y^2<1}) # the open unit disk
|
|
1898
|
+
sage: Phi = D.continuous_map(M, [x/sqrt(1-x^2-y^2), y/sqrt(1-x^2-y^2)],
|
|
1899
|
+
....: name='Phi', latex_name=r'\Phi')
|
|
1900
|
+
sage: Phi.display()
|
|
1901
|
+
Phi: D → R^2
|
|
1902
|
+
(x, y) ↦ (x, y) = (x/sqrt(-x^2 - y^2 + 1), y/sqrt(-x^2 - y^2 + 1))
|
|
1903
|
+
sage: c_xy_D = c_xy.restrict(D)
|
|
1904
|
+
sage: U = D.open_subset('U', coord_def={c_xy_D: x^2+y^2>1/2}) # the annulus 1/2 < r < 1
|
|
1905
|
+
sage: Phi.restrict(U)
|
|
1906
|
+
Continuous map Phi
|
|
1907
|
+
from the Open subset U of the 2-dimensional topological manifold R^2
|
|
1908
|
+
to the 2-dimensional topological manifold R^2
|
|
1909
|
+
sage: Phi.restrict(U).parent()
|
|
1910
|
+
Set of Morphisms from Open subset U of the 2-dimensional topological
|
|
1911
|
+
manifold R^2 to 2-dimensional topological manifold R^2 in Category
|
|
1912
|
+
of manifolds over Real Field with 53 bits of precision
|
|
1913
|
+
sage: Phi.domain()
|
|
1914
|
+
Open subset D of the 2-dimensional topological manifold R^2
|
|
1915
|
+
sage: Phi.restrict(U).domain()
|
|
1916
|
+
Open subset U of the 2-dimensional topological manifold R^2
|
|
1917
|
+
sage: Phi.restrict(U).display()
|
|
1918
|
+
Phi: U → R^2
|
|
1919
|
+
(x, y) ↦ (x, y) = (x/sqrt(-x^2 - y^2 + 1), y/sqrt(-x^2 - y^2 + 1))
|
|
1920
|
+
|
|
1921
|
+
The result is cached::
|
|
1922
|
+
|
|
1923
|
+
sage: Phi.restrict(U) is Phi.restrict(U)
|
|
1924
|
+
True
|
|
1925
|
+
|
|
1926
|
+
The restriction of the identity map::
|
|
1927
|
+
|
|
1928
|
+
sage: id = D.identity_map() ; id
|
|
1929
|
+
Identity map Id_D of the Open subset D of the 2-dimensional
|
|
1930
|
+
topological manifold R^2
|
|
1931
|
+
sage: id.restrict(U)
|
|
1932
|
+
Identity map Id_U of the Open subset U of the 2-dimensional
|
|
1933
|
+
topological manifold R^2
|
|
1934
|
+
sage: id.restrict(U) is U.identity_map()
|
|
1935
|
+
True
|
|
1936
|
+
|
|
1937
|
+
The codomain can be restricted (i.e. made tighter)::
|
|
1938
|
+
|
|
1939
|
+
sage: Phi = D.continuous_map(M, [x/sqrt(1+x^2+y^2), y/sqrt(1+x^2+y^2)])
|
|
1940
|
+
sage: Phi
|
|
1941
|
+
Continuous map from
|
|
1942
|
+
the Open subset D of the 2-dimensional topological manifold R^2
|
|
1943
|
+
to the 2-dimensional topological manifold R^2
|
|
1944
|
+
sage: Phi.restrict(D, subcodomain=D)
|
|
1945
|
+
Continuous map from the Open subset D of the 2-dimensional
|
|
1946
|
+
topological manifold R^2 to itself
|
|
1947
|
+
"""
|
|
1948
|
+
if subcodomain is None:
|
|
1949
|
+
if self._is_identity:
|
|
1950
|
+
subcodomain = subdomain
|
|
1951
|
+
else:
|
|
1952
|
+
subcodomain = self._codomain
|
|
1953
|
+
if subdomain == self._domain and subcodomain == self._codomain:
|
|
1954
|
+
return self
|
|
1955
|
+
if (subdomain, subcodomain) not in self._restrictions:
|
|
1956
|
+
if not subdomain.is_subset(self._domain):
|
|
1957
|
+
raise ValueError(
|
|
1958
|
+
"the specified domain is not a subset"
|
|
1959
|
+
" of the domain of definition of the"
|
|
1960
|
+
" continuous map"
|
|
1961
|
+
)
|
|
1962
|
+
if not subcodomain.is_subset(self._codomain):
|
|
1963
|
+
raise ValueError(
|
|
1964
|
+
"the specified codomain is not a subset"
|
|
1965
|
+
" of the codomain of the continuous map"
|
|
1966
|
+
)
|
|
1967
|
+
# Special case of the identity map:
|
|
1968
|
+
if self._is_identity:
|
|
1969
|
+
self._restrictions[(subdomain, subcodomain)] = subdomain.identity_map()
|
|
1970
|
+
return self._restrictions[(subdomain, subcodomain)]
|
|
1971
|
+
|
|
1972
|
+
# First one tries to get the restriction from a tighter domain:
|
|
1973
|
+
for dom, rst in self._restrictions.items():
|
|
1974
|
+
if (
|
|
1975
|
+
subdomain.is_subset(dom[0])
|
|
1976
|
+
and (subdomain, subcodomain) in rst._restrictions
|
|
1977
|
+
):
|
|
1978
|
+
res = rst._restrictions[(subdomain, subcodomain)]
|
|
1979
|
+
self._restrictions[(subdomain, subcodomain)] = res
|
|
1980
|
+
self._restrictions.update(res._restrictions)
|
|
1981
|
+
self._restrictions_graph.update(res._restrictions_graph)
|
|
1982
|
+
res._extensions_graph.update(self._extensions_graph)
|
|
1983
|
+
for ext in self._extensions_graph.values():
|
|
1984
|
+
ext._restrictions[subdomain] = res
|
|
1985
|
+
ext._restrictions.update(res._restrictions)
|
|
1986
|
+
ext._restrictions_graph.update(res._restrictions_graph)
|
|
1987
|
+
return self._restrictions[(subdomain, subcodomain)]
|
|
1988
|
+
|
|
1989
|
+
# Maybe it didn't exist but could have:
|
|
1990
|
+
for dom, rst in self._restrictions.items():
|
|
1991
|
+
if subdomain.is_subset(dom[0]) and subcodomain.is_subset(dom[1]):
|
|
1992
|
+
res = rst.restrict(subdomain, subcodomain) # all propagation
|
|
1993
|
+
# is done here
|
|
1994
|
+
# should be useless:
|
|
1995
|
+
self._restrictions[(subdomain, subcodomain)] = res
|
|
1996
|
+
self._restrictions_graph[(subdomain, subcodomain)] = res
|
|
1997
|
+
return self._restrictions[(subdomain, subcodomain)]
|
|
1998
|
+
|
|
1999
|
+
# Secondly one tries to get the restriction from one previously
|
|
2000
|
+
# defined on a larger domain:
|
|
2001
|
+
for dom, ext in self._extensions_graph.items():
|
|
2002
|
+
if (subdomain, subcodomain) in ext._restrictions:
|
|
2003
|
+
res = ext._restrictions[(subdomain, subcodomain)]
|
|
2004
|
+
self._restrictions[(subdomain, subcodomain)] = res
|
|
2005
|
+
self._restrictions.update(res._restrictions)
|
|
2006
|
+
self._restrictions_graph.update(res._restrictions_graph)
|
|
2007
|
+
res._extensions_graph.update(self._extensions_graph)
|
|
2008
|
+
for ext in self._extensions_graph.values():
|
|
2009
|
+
ext._restrictions[subdomain] = res
|
|
2010
|
+
ext._restrictions.update(res._restrictions)
|
|
2011
|
+
ext._restrictions_graph.update(res._restrictions_graph)
|
|
2012
|
+
return self._restrictions[(subdomain, subcodomain)]
|
|
2013
|
+
|
|
2014
|
+
# Generic case:
|
|
2015
|
+
homset = Hom(subdomain, subcodomain)
|
|
2016
|
+
resu = type(self)(homset, name=self._name, latex_name=self._latex_name)
|
|
2017
|
+
for charts in self._coord_expression:
|
|
2018
|
+
for ch1 in charts[0]._subcharts:
|
|
2019
|
+
if ch1._domain.is_subset(subdomain):
|
|
2020
|
+
for ch2 in charts[1]._subcharts:
|
|
2021
|
+
if ch2._domain.is_subset(subcodomain):
|
|
2022
|
+
for sch2 in ch2._supercharts:
|
|
2023
|
+
if (ch1, sch2) in resu._coord_expression:
|
|
2024
|
+
break
|
|
2025
|
+
else:
|
|
2026
|
+
for sch2 in ch2._subcharts:
|
|
2027
|
+
if (ch1, sch2) in resu._coord_expression:
|
|
2028
|
+
del resu._coord_expression[(ch1, sch2)]
|
|
2029
|
+
coord_functions = self._coord_expression[
|
|
2030
|
+
charts
|
|
2031
|
+
].expr()
|
|
2032
|
+
resu._coord_expression[(ch1, ch2)] = (
|
|
2033
|
+
ch1.multifunction(*coord_functions)
|
|
2034
|
+
)
|
|
2035
|
+
|
|
2036
|
+
# propagate extensions
|
|
2037
|
+
for dom, ext in self._extensions_graph.items(): # includes self
|
|
2038
|
+
ext._restrictions[(subdomain, subcodomain)] = resu
|
|
2039
|
+
ext._restrictions_graph[(subdomain, subcodomain)] = resu
|
|
2040
|
+
|
|
2041
|
+
# propagate restrictions
|
|
2042
|
+
for dom, rst in self._restrictions.items():
|
|
2043
|
+
if dom[0].is_subset(subdomain) and dom[1].is_subset(subcodomain):
|
|
2044
|
+
if rst is not resu:
|
|
2045
|
+
resu._restrictions.update(rst._restrictions_graph)
|
|
2046
|
+
resu._restrictions_graph.update(rst._restrictions_graph)
|
|
2047
|
+
rst._extensions_graph.update(resu._extensions_graph)
|
|
2048
|
+
|
|
2049
|
+
self._restrictions[(subdomain, subcodomain)] = resu
|
|
2050
|
+
self._restrictions_graph[(subdomain, subcodomain)] = resu
|
|
2051
|
+
resu._extensions_graph.update(self._extensions_graph)
|
|
2052
|
+
|
|
2053
|
+
return self._restrictions[(subdomain, subcodomain)]
|
|
2054
|
+
|
|
2055
|
+
def __invert__(self):
|
|
2056
|
+
r"""
|
|
2057
|
+
Return the inverse of ``self`` if it is an isomorphism.
|
|
2058
|
+
|
|
2059
|
+
OUTPUT: the inverse isomorphism
|
|
2060
|
+
|
|
2061
|
+
EXAMPLES:
|
|
2062
|
+
|
|
2063
|
+
The inverse of a rotation in the Euclidean plane::
|
|
2064
|
+
|
|
2065
|
+
sage: M = Manifold(2, 'R^2', latex_name=r'\RR^2', structure='topological')
|
|
2066
|
+
sage: c_cart.<x,y> = M.chart()
|
|
2067
|
+
|
|
2068
|
+
A pi/3 rotation around the origin::
|
|
2069
|
+
|
|
2070
|
+
sage: rot = M.homeomorphism(M, ((x - sqrt(3)*y)/2, (sqrt(3)*x + y)/2),
|
|
2071
|
+
....: name='R')
|
|
2072
|
+
sage: rot.inverse()
|
|
2073
|
+
Homeomorphism R^(-1) of the 2-dimensional topological manifold R^2
|
|
2074
|
+
sage: rot.inverse().display()
|
|
2075
|
+
R^(-1): R^2 → R^2
|
|
2076
|
+
(x, y) ↦ (1/2*sqrt(3)*y + 1/2*x, -1/2*sqrt(3)*x + 1/2*y)
|
|
2077
|
+
|
|
2078
|
+
Checking that applying successively the homeomorphism and its
|
|
2079
|
+
inverse results in the identity::
|
|
2080
|
+
|
|
2081
|
+
sage: (a, b) = var('a b')
|
|
2082
|
+
sage: p = M.point((a,b)) # a generic point on M
|
|
2083
|
+
sage: q = rot(p)
|
|
2084
|
+
sage: p1 = rot.inverse()(q)
|
|
2085
|
+
sage: p1 == p
|
|
2086
|
+
True
|
|
2087
|
+
|
|
2088
|
+
The result is cached::
|
|
2089
|
+
|
|
2090
|
+
sage: rot.inverse() is rot.inverse()
|
|
2091
|
+
True
|
|
2092
|
+
|
|
2093
|
+
The notations ``^(-1)`` or ``~`` can also be used for the inverse::
|
|
2094
|
+
|
|
2095
|
+
sage: rot^(-1) is rot.inverse()
|
|
2096
|
+
True
|
|
2097
|
+
sage: ~rot is rot.inverse()
|
|
2098
|
+
True
|
|
2099
|
+
|
|
2100
|
+
An example with multiple charts: the equatorial symmetry on the
|
|
2101
|
+
2-sphere::
|
|
2102
|
+
|
|
2103
|
+
sage: M = Manifold(2, 'M', structure='topological') # the 2-dimensional sphere S^2
|
|
2104
|
+
sage: U = M.open_subset('U') # complement of the North pole
|
|
2105
|
+
sage: c_xy.<x,y> = U.chart() # stereographic coordinates from the North pole
|
|
2106
|
+
sage: V = M.open_subset('V') # complement of the South pole
|
|
2107
|
+
sage: c_uv.<u,v> = V.chart() # stereographic coordinates from the South pole
|
|
2108
|
+
sage: M.declare_union(U,V) # S^2 is the union of U and V
|
|
2109
|
+
sage: xy_to_uv = c_xy.transition_map(c_uv, (x/(x^2+y^2), y/(x^2+y^2)),
|
|
2110
|
+
....: intersection_name='W',
|
|
2111
|
+
....: restrictions1=x^2+y^2!=0,
|
|
2112
|
+
....: restrictions2=u^2+v^2!=0)
|
|
2113
|
+
sage: uv_to_xy = xy_to_uv.inverse()
|
|
2114
|
+
sage: s = M.homeomorphism(M, {(c_xy, c_uv): [x, y], (c_uv, c_xy): [u, v]},
|
|
2115
|
+
....: name='s')
|
|
2116
|
+
sage: s.display()
|
|
2117
|
+
s: M → M
|
|
2118
|
+
on U: (x, y) ↦ (u, v) = (x, y)
|
|
2119
|
+
on V: (u, v) ↦ (x, y) = (u, v)
|
|
2120
|
+
sage: si = s.inverse(); si
|
|
2121
|
+
Homeomorphism s^(-1) of the 2-dimensional topological manifold M
|
|
2122
|
+
sage: si.display()
|
|
2123
|
+
s^(-1): M → M
|
|
2124
|
+
on U: (x, y) ↦ (u, v) = (x, y)
|
|
2125
|
+
on V: (u, v) ↦ (x, y) = (u, v)
|
|
2126
|
+
|
|
2127
|
+
The equatorial symmetry is of course an involution::
|
|
2128
|
+
|
|
2129
|
+
sage: si == s
|
|
2130
|
+
True
|
|
2131
|
+
"""
|
|
2132
|
+
from sage.symbolic.relation import solve
|
|
2133
|
+
from sage.symbolic.ring import SR
|
|
2134
|
+
|
|
2135
|
+
if self._inverse is not None:
|
|
2136
|
+
return self._inverse
|
|
2137
|
+
if not self._is_isomorphism:
|
|
2138
|
+
raise ValueError("the {} is not an isomorphism".format(self))
|
|
2139
|
+
coord_functions = {} # coordinate expressions of the result
|
|
2140
|
+
for chart1, chart2 in self._coord_expression:
|
|
2141
|
+
coord_map = self._coord_expression[(chart1, chart2)]
|
|
2142
|
+
n1 = len(chart1._xx)
|
|
2143
|
+
n2 = len(chart2._xx)
|
|
2144
|
+
# New symbolic variables (different from chart2._xx to allow for a
|
|
2145
|
+
# correct solution even when chart2 = chart1):
|
|
2146
|
+
x2 = SR.temp_var(n=n2)
|
|
2147
|
+
equations = [x2[i] == coord_map._functions[i].expr() for i in range(n2)]
|
|
2148
|
+
solutions = solve(equations, chart1._xx, solution_dict=True)
|
|
2149
|
+
if not solutions:
|
|
2150
|
+
raise ValueError("no solution found")
|
|
2151
|
+
if len(solutions) > 1:
|
|
2152
|
+
raise ValueError("non-unique solution found")
|
|
2153
|
+
substitutions = dict(zip(x2, chart2._xx))
|
|
2154
|
+
sol = solutions[0]
|
|
2155
|
+
inv_functions = [sol[chart1._xx[i]].subs(substitutions) for i in range(n1)]
|
|
2156
|
+
for i in range(n1):
|
|
2157
|
+
x = inv_functions[i]
|
|
2158
|
+
try:
|
|
2159
|
+
# simplify derived from calculus_method
|
|
2160
|
+
inv_functions[i] = chart2.simplify(x)
|
|
2161
|
+
except AttributeError:
|
|
2162
|
+
pass
|
|
2163
|
+
coord_functions[(chart2, chart1)] = inv_functions
|
|
2164
|
+
SR.cleanup_var(x2)
|
|
2165
|
+
if self._name is None:
|
|
2166
|
+
name = None
|
|
2167
|
+
else:
|
|
2168
|
+
name = self._name + '^(-1)'
|
|
2169
|
+
if self._latex_name is None:
|
|
2170
|
+
latex_name = None
|
|
2171
|
+
else:
|
|
2172
|
+
latex_name = self._latex_name + r'^{-1}'
|
|
2173
|
+
homset = Hom(self._codomain, self._domain)
|
|
2174
|
+
self._inverse = type(self)(
|
|
2175
|
+
homset,
|
|
2176
|
+
coord_functions=coord_functions,
|
|
2177
|
+
name=name,
|
|
2178
|
+
latex_name=latex_name,
|
|
2179
|
+
is_isomorphism=True,
|
|
2180
|
+
)
|
|
2181
|
+
return self._inverse
|
|
2182
|
+
|
|
2183
|
+
inverse = __invert__
|