@@ -189,8 +189,7 @@ class CoordFunctionSymb(CoordFunction):
189189 1
190190
191191 Another difference regards the display of partial derivatives:
192- for callable symbolic functions, it relies on Pynac notation
193- ``D[0]``, ``D[1]``, etc.::
192+ for callable symbolic functions, it involves ``diff``::
194193
195194 sage: g = function('g')(x, y)
196195 sage: f0(x,y) = diff(g, x) + diff(g, y)
@@ -211,13 +210,13 @@ class CoordFunctionSymb(CoordFunction):
211210 \frac{\partial\,g}{\partial x} + \frac{\partial\,g}{\partial y}
212211
213212 Note that this regards only the display of coordinate functions:
214- internally, the Pynac notation is still used, as we can check by asking
213+ internally, the ``diff`` notation is still used, as we can check by asking
215214 for the symbolic expression stored in ``f``::
216215
217216 sage: f.expr()
218217 diff(g(x, y), x) + diff(g(x, y), y)
219218
220- One can switch to Pynac notation by changing the options::
219+ One can switch to the standard symbolic notation by changing the options::
221220
222221 sage: Manifold.options.textbook_output=False
223222 sage: latex(f)
@@ -519,6 +518,54 @@ def __bool__(self):
519518
520519 __nonzero__ = __bool__ # For Python2 compatibility
521520
521+ def is_trivial_zero (self ):
522+ r"""
523+ Check if ``self`` is trivially equal to zero without any
524+ simplification.
525+
526+ This method is supposed to be fast as compared with
527+ ``self.is_zero()`` or ``self == 0`` and is intended to be
528+ used in library code where trying to obtain a mathematically
529+ correct result by applying potentially expensive rewrite rules
530+ is not desirable.
531+
532+ EXAMPLES::
533+
534+ sage: M = Manifold(2, 'M', structure='topological')
535+ sage: X.<x,y> = M.chart()
536+ sage: f = X.function(0)
537+ sage: f.is_trivial_zero()
538+ True
539+ sage: f = X.function(float(0.0))
540+ sage: f.is_trivial_zero()
541+ True
542+ sage: f = X.function(x-x)
543+ sage: f.is_trivial_zero()
544+ True
545+ sage: X.zero_function().is_trivial_zero()
546+ True
547+
548+ No simplification is attempted, so that ``False`` is returned for
549+ non-trivial cases::
550+
551+ sage: f = X.function(cos(x)^2 + sin(x)^2 - 1)
552+ sage: f.is_trivial_zero()
553+ False
554+
555+ On the contrary, the method
556+ :meth:`~sage.structure.element.Element.is_zero` and the direct
557+ comparison to zero involve some simplification algorithms and
558+ return ``True``::
559+
560+ sage: f.is_zero()
561+ True
562+ sage: f == 0
563+ True
564+
565+ """
566+ return self ._express .is_trivial_zero ()
567+
568+
522569 def copy (self ):
523570 r"""
524571 Return an exact copy of the object.
@@ -1742,7 +1789,7 @@ def characteristic(self):
17421789 0
17431790 """
17441791 return self ._chart .manifold ().base_field ().characteristic ()
1745-
1792+
17461793 def from_base_ring (self , r ):
17471794 """
17481795 Return the canonical embedding of ``r`` into ``self``.
0 commit comments