diff --git a/src/sage/manifolds/differentiable/chart.py b/src/sage/manifolds/differentiable/chart.py index a2c40d33231..70c6b885253 100644 --- a/src/sage/manifolds/differentiable/chart.py +++ b/src/sage/manifolds/differentiable/chart.py @@ -488,7 +488,7 @@ def coframe(self): sage: ey = c_xy.frame()[1] ; ey Vector field d/dy on the 2-dimensional differentiable manifold M sage: dx(ex).display() - dx(d/dx): M --> R + dx(d/dx): M --> R (x, y) |--> 1 sage: dx(ey).display() zero: M --> R diff --git a/src/sage/manifolds/differentiable/tensorfield.py b/src/sage/manifolds/differentiable/tensorfield.py index 654096b41ae..57fb7f24250 100644 --- a/src/sage/manifolds/differentiable/tensorfield.py +++ b/src/sage/manifolds/differentiable/tensorfield.py @@ -4538,7 +4538,7 @@ def apply_map(self, fun, frame=None, chart=None, sage: v.display(P.frame(), P) (p^2 - q^2 - 2*p - 2*q) d/dp + (2*pi - 2*pi^2 - 2*(pi - pi^2)*p) d/dq sage: v.display(P.frame(), X) - (x^2 - y^2) d/dp - 2*(pi - pi^2)*x d/dq + (x + y)*(x - y) d/dp + 2*pi*(pi - 1)*x d/dq By default, the components of ``v`` in frames distinct from the specified one have been deleted:: @@ -4553,7 +4553,7 @@ def apply_map(self, fun, frame=None, chart=None, is effective in ``X.frame()`` as well:: sage: v.display(X.frame(), X) - (x^2 - y^2) d/dx - 2*(pi - pi^2)*x d/dy + (x + y)*(x - y) d/dx + 2*pi*(pi - 1)*x d/dy When the requested operation does not change the value of the tensor field, one can use the keyword argument ``keep_other_components=True``, diff --git a/src/sage/manifolds/local_frame.py b/src/sage/manifolds/local_frame.py index 507c37055c6..7830e24a280 100644 --- a/src/sage/manifolds/local_frame.py +++ b/src/sage/manifolds/local_frame.py @@ -119,7 +119,7 @@ Let us check that the coframe `(e^i)` is indeed the dual of the vector frame `(e_i)`:: - sage: e_dual[1](e[1]) # the linear form e^1 applied to the local section e_1 + sage: e_dual[1](e[1]) # linear form e^1 applied to local section e_1 Scalar field e^1(e_1) on the Open subset U of the 3-dimensional topological manifold M sage: e_dual[1](e[1]).expr() # the explicit expression of e^1(e_1) diff --git a/src/sage/manifolds/scalarfield.py b/src/sage/manifolds/scalarfield.py index e48520c1ed6..38514061dbb 100644 --- a/src/sage/manifolds/scalarfield.py +++ b/src/sage/manifolds/scalarfield.py @@ -2508,10 +2508,10 @@ def _add_(self, other): True """ - # Special cases: - if self._is_zero: + # Trivial cases: + if self.is_trivial_zero(): return other - if other._is_zero: + if other.is_trivial_zero(): return self # Generic case: com_charts = self.common_charts(other) @@ -2557,11 +2557,13 @@ def _sub_(self, other): True """ - # Special cases: - if self._is_zero: + # Trivial cases: + if self.is_trivial_zero(): return -other - if other._is_zero: + if other.is_trivial_zero(): return self + if self is other: + return self.parent().zero() # Generic case: com_charts = self.common_charts(other) if com_charts is None: @@ -2576,7 +2578,6 @@ def _sub_(self, other): result._latex_name = self._latex_name + '-' + other._latex_name return result - def _mul_(self, other): r""" Scalar field multiplication. @@ -2609,12 +2610,16 @@ def _mul_(self, other): True """ - from sage.tensor.modules.format_utilities import (format_mul_txt, - format_mul_latex) - # Special cases: - if self._is_zero or other._is_zero: + # Trivial cases: + if self.is_trivial_zero() or other.is_trivial_zero(): return self._domain.zero_scalar_field() + if (self - 1).is_trivial_zero(): + return other + if (other - 1).is_trivial_zero(): + return self # Generic case: + from sage.tensor.modules.format_utilities import (format_mul_txt, + format_mul_latex) com_charts = self.common_charts(other) if com_charts is None: raise ValueError("no common chart for the multiplication") @@ -2661,10 +2666,10 @@ def _div_(self, other): """ from sage.tensor.modules.format_utilities import format_mul_txt, \ format_mul_latex - # Special cases: - if other._is_zero: + # Trivial cases: + if other.is_trivial_zero(): raise ZeroDivisionError("division of a scalar field by zero") - if self._is_zero: + if self.is_trivial_zero(): return self._domain.zero_scalar_field() # Generic case: com_charts = self.common_charts(other) @@ -2726,6 +2731,7 @@ def _lmul_(self, number): True """ + # Trivial cases: try: if number.is_trivial_zero(): return self.parent().zero() @@ -2737,6 +2743,7 @@ def _lmul_(self, number): return self.parent().zero() if number == 1: return self + # Generic case: result = type(self)(self.parent()) if isinstance(number, Expression): var = number.variables() # possible symbolic variables in number