diff --git a/src/sage/manifolds/continuous_map.py b/src/sage/manifolds/continuous_map.py index 2decc53e463..8c330cab7dc 100644 --- a/src/sage/manifolds/continuous_map.py +++ b/src/sage/manifolds/continuous_map.py @@ -1163,26 +1163,22 @@ def coord_functions(self, chart1=None, chart2=None): sage: Phi1.coord_functions(c_uv.restrict(A), c_xyz) Coordinate functions (u*v, u/v, u + v) on the Chart (A, (u, v)) - The same test with ``sympy``:: + Same example with SymPy as the symbolic calculus engine:: - # sage: X.set_calculus_method('sympy') - sage: M = Manifold(2, 'M', structure='topological') - sage: N = Manifold(3, 'N', structure='topological') - sage: c_uv. = M.chart(calc_method='sympy') - sage: c_xyz. = N.chart(calc_method='sympy') + sage: M.set_calculus_method('sympy') + sage: N.set_calculus_method('sympy') sage: Phi = M.continuous_map(N, (u*v, u/v, u+v), name='Phi', ....: latex_name=r'\Phi') - sage: Phi.display() - Phi: M --> N - (u, v) |--> (x, y, z) = (u*v, u/v, u + v) sage: Phi.coord_functions(c_uv, c_xyz) Coordinate functions (u*v, u/v, u + v) on the Chart (M, (u, v)) - sage: Phi.coord_functions() # equivalent to above since 'uv' and 'xyz' are default charts - Coordinate functions (u*v, u/v, u + v) on the Chart (M, (u, v)) - sage: type(Phi.coord_functions()) - - - + sage: Phi.coord_functions(c_UV, c_xyz) + Coordinate functions (-U**2/4 + V**2/4, -(U + V)/(U - V), V) + on the Chart (M, (U, V)) + sage: Phi.coord_functions(c_UV, c_XYZ) + Coordinate functions ((-U**3 + U**2*V + U*V**2 + 2*U*V + 6*U - V**3 + - 2*V**2 + 6*V)/(2*(U - V)), (U**3/4 - U**2*V/4 - U*V**2/4 + U*V + - U + V**3/4 - V**2 - V)/(U - V), (U**3 - U**2*V - U*V**2 - 4*U*V + - 8*U + V**3 + 4*V**2 - 8*V)/(4*(U - V))) on the Chart (M, (U, V)) """ dom1 = self._domain; dom2 = self._codomain @@ -1826,7 +1822,6 @@ def __invert__(self): if not self._is_isomorphism: raise ValueError("the {} is not an isomorphism".format(self)) coord_functions = {} # coordinate expressions of the result - for (chart1, chart2) in self._coord_expression: coord_map = self._coord_expression[(chart1, chart2)] n1 = len(chart1._xx) diff --git a/src/sage/manifolds/differentiable/affine_connection.py b/src/sage/manifolds/differentiable/affine_connection.py index 2c0b224d311..e1d6601acc2 100644 --- a/src/sage/manifolds/differentiable/affine_connection.py +++ b/src/sage/manifolds/differentiable/affine_connection.py @@ -293,20 +293,11 @@ class AffineConnection(SageObject): sage: nab.restrict(U)(a.restrict(V)) == da.restrict(W) True - Same tests with ``sympy``:: + Same examples with SymPy as the engine for symbolic calculus:: sage: M.set_calculus_method('sympy') - sage: nab = M.affine_connection('nabla', r'\nabla') - - The connection is first defined on the open subset U by means of its - coefficients w.r.t. the frame eU (the manifold's default frame):: - sage: nab[0,0,0], nab[1,0,1] = x, x*y - - The coefficients w.r.t the frame eV are deduced by continuation of the - coefficients w.r.t. the frame eVW on the open subset `W=U\cap V`:: - sage: for i in M.irange(): ....: for j in M.irange(): ....: for k in M.irange(): @@ -338,7 +329,6 @@ class AffineConnection(SageObject): manifold M sage: da.display(eU) nabla(a) = -x*y d/dx*dx - d/dx*dy + d/dy*dx - x*y**2 d/dy*dy - sage: da.display(eV) nabla(a) = (-u**3/16 + u**2*v/16 - u**2/8 + u*v**2/16 - v**3/16 + v**2/8) d/du*du + (u**3/16 - u**2*v/16 - u**2/8 - u*v**2/16 + v**3/16 + v**2/8 + 1) d/du*dv diff --git a/src/sage/manifolds/differentiable/diff_form.py b/src/sage/manifolds/differentiable/diff_form.py index 8751c663a60..8029f565106 100644 --- a/src/sage/manifolds/differentiable/diff_form.py +++ b/src/sage/manifolds/differentiable/diff_form.py @@ -207,21 +207,16 @@ class DiffForm(TensorField): 1/2*u^2*v du - 1/2*u^3 dv - Same tests with ``sympy``:: + .. RUBRIC:: Examples with SymPy as the symbolic engine + + From now on, we ask that all symbolic calculus on manifold `M` are + performed by SymPy:: sage: M.set_calculus_method('sympy') - sage: U.set_calculus_method('sympy') - sage: V.set_calculus_method('sympy') - sage: W.set_calculus_method('sympy') - sage: a = M.diff_form(2, name='a') ; a - 2-form a on the 2-dimensional differentiable manifold M - sage: a.parent() - Module Omega^2(M) of 2-forms on the 2-dimensional differentiable - manifold M - sage: a.degree() - 2 - Setting the components of ``a``:: + We define a 2-form `a` as above:: + + sage: a = M.diff_form(2, name='a') sage: a[eU,0,1] = x*y^2 + 2*x sage: a.add_comp_by_continuation(eV, W, c_uv) sage: a.display(eU) @@ -231,16 +226,7 @@ class DiffForm(TensorField): A 1-form on ``M``:: - sage: a = M.one_form('a') ; a - 1-form a on the 2-dimensional differentiable manifold M - sage: a.parent() - Module Omega^1(M) of 1-forms on the 2-dimensional differentiable - manifold M - sage: a.degree() - 1 - - Setting the components of the 1-form in a consistent way:: - + sage: a = M.one_form('a') sage: a[eU,:] = [-y, x] sage: a.add_comp_by_continuation(eV, W, c_uv) sage: a.display(eU) @@ -248,10 +234,9 @@ class DiffForm(TensorField): sage: a.display(eV) a = v/2 du - u/2 dv - The exterior derivative of the 1-form is a 2-form:: + The exterior derivative of ``a``:: - sage: da = a.exterior_derivative() ; da - 2-form da on the 2-dimensional differentiable manifold M + sage: da = a.exterior_derivative() sage: da.display(eU) da = 2 dx/\dy sage: da.display(eV) @@ -263,35 +248,31 @@ class DiffForm(TensorField): sage: b[eU,:] = [1+x*y, x^2] sage: b.add_comp_by_continuation(eV, W, c_uv) - Adding two 1-forms results in another 1-form:: + Adding two 1-forms:: - sage: s = a + b ; s - 1-form a+b on the 2-dimensional differentiable manifold M + sage: s = a + b sage: s.display(eU) a+b = (x*y - y + 1) dx + x*(x + 1) dy sage: s.display(eV) a+b = (u**2/4 + u*v/4 + v/2 + 1/2) du + (-u*v/4 - u/2 - v**2/4 + 1/2) dv - The exterior product of two 1-forms is a 2-form:: + The exterior product of two 1-forms:: - sage: s = a.wedge(b) ; s - 2-form a/\b on the 2-dimensional differentiable manifold M + sage: s = a.wedge(b) sage: s.display(eU) a/\b = -x*(2*x*y + 1) dx/\dy sage: s.display(eV) a/\b = (u**3/8 + u**2*v/8 - u*v**2/8 + u/4 - v**3/8 + v/4) du/\dv - Multiplying a 1-form by a scalar field results in another 1-form:: + Multiplying a 1-form by a scalar field:: sage: f = M.scalar_field({c_xy: (x+y)^2, c_uv: u^2}, name='f') - sage: s = f*a ; s - 1-form on the 2-dimensional differentiable manifold M + sage: s = f*a sage: s.display(eU) -y*(x**2 + 2*x*y + y**2) dx + x*(x**2 + 2*x*y + y**2) dy sage: s.display(eV) u**2*v/2 du - u**3/2 dv - """ def __init__(self, vector_field_module, degree, name=None, latex_name=None): r""" diff --git a/src/sage/manifolds/differentiable/levi_civita_connection.py b/src/sage/manifolds/differentiable/levi_civita_connection.py index 5ed53a3fcaa..2776ab98592 100644 --- a/src/sage/manifolds/differentiable/levi_civita_connection.py +++ b/src/sage/manifolds/differentiable/levi_civita_connection.py @@ -720,7 +720,8 @@ def ricci(self, name=None, latex_name=None): sage: g[0,0], g[1,1] = -(1-2*m/r), 1/(1-2*m/r) sage: g[2,2], g[3,3] = r^2, (r*sin(th))^2 sage: g.display() - g = (2*m/r - 1) dt*dt - 1/(2*m/r - 1) dr*dr + r^2 dth*dth + r^2*sin(th)^2 dph*dph + g = (2*m/r - 1) dt*dt - 1/(2*m/r - 1) dr*dr + r^2 dth*dth + + r^2*sin(th)^2 dph*dph sage: nab = g.connection() ; nab Levi-Civita connection nabla_g associated with the Lorentzian metric g on the 4-dimensional differentiable manifold M diff --git a/src/sage/manifolds/manifold.py b/src/sage/manifolds/manifold.py index c7880abccc0..3751c1cad81 100644 --- a/src/sage/manifolds/manifold.py +++ b/src/sage/manifolds/manifold.py @@ -1655,20 +1655,6 @@ def scalar_field(self, coord_expression=None, chart=None, name=None, F: U --> R (x, y, z) |--> cos(y)*sin(x) + z - - Same tests with ``sympy``:: - - sage: c_xyz.set_calculus_method('sympy') - sage: f = U.scalar_field(sin(x)*cos(y) + z, name='F'); f - Scalar field F on the Open subset U of the 3-dimensional topological manifold M - sage: f.display() - F: U --> R - (x, y, z) |--> z + sin(x)*cos(y) - - sage: type(f.coord_function(c_xyz).expr()) - - - See the documentation of class :class:`~sage.manifolds.scalarfield.ScalarField` for more examples. diff --git a/src/sage/manifolds/scalarfield.py b/src/sage/manifolds/scalarfield.py index e892b89e0e6..37956eafbe0 100644 --- a/src/sage/manifolds/scalarfield.py +++ b/src/sage/manifolds/scalarfield.py @@ -602,7 +602,7 @@ class ScalarField(CommutativeAlgebraElement): .. RUBRIC:: Examples with SymPy as the symbolic engine - From now on, we ask that all symbolic calculus on manifold `M` is + From now on, we ask that all symbolic calculus on manifold `M` are performed by SymPy:: sage: M.set_calculus_method('sympy') @@ -1544,7 +1544,6 @@ def coord_function(self, chart=None, from_chart=None): new_expr = self._express[known_chart].expr() self._express[chart] = chart.function(new_expr) return self._express[chart] - # If this point is reached, the expression must be computed # from that in the chart from_chart, by means of a # change-of-coordinates formula: @@ -1567,15 +1566,12 @@ def coord_function(self, chart=None, from_chart=None): if not found: raise ValueError("no starting chart could be found to " + "compute the expression in the {}".format(chart)) - change = self._domain._coord_changes[(chart, from_chart)] - # old coordinates expressed in terms of the new ones: coords = [ change._transf._functions[i].expr() for i in range(self._manifold.dim()) ] new_expr = self._express[from_chart](*coords) self._express[chart] = chart.function(new_expr) - self._del_derived() return self._express[chart] @@ -1902,7 +1898,6 @@ def _display_expression(self, chart, result): result._latex = r"\begin{array}{llcl} " + symbol + r"&" + \ latex(self._domain) + r"& \longrightarrow & " + \ field_latex_name + r" \\" - if chart is None: for ch in self._domain._top_charts: _display_expression(self, ch, result)