id summary reporter owner description type status priority milestone component resolution keywords cc merged author reviewer upstream work_issues branch commit dependencies stopgaps
27601 Customizing simplifications in symbolic calculus on manifolds egourgoulhon "Currently the end user has no direct control of the simplification algorithm used in coordinate calculus on manifolds. For instance, if the manifold is real and the coordinate calculus method is Sage's default symbolic engine (SR), the simplifying function is
[http://doc.sagemath.org/html/en/reference/manifolds/sage/manifolds/utilities.html#sage.manifolds.utilities.simplify_chain_real simplify_chain_real]. This function is quite exhaustive (similar to `simplify_full()`) but since it is invoked at each elementary step of a calculation, the computation can be quite slow. In some cases, it would be desirable to use a lighter simplifying function. See for instance [https://ask.sagemath.org/question/45959/grad-at-glacial-speed/ this ask.sagemath question].
This ticket proposes some interface for passing any user-defined simplifying function. As an example, let us perform the addition of two scalar fields on a 2-dimensional real smooth manifold:
{{{
sage: M = Manifold(2, 'M')
sage: X. = M.chart()
sage: f = M.scalar_field(cos(x)^2)
sage: g = M.scalar_field(sin(x)^2)
sage: s = f + g
}}}
Thanks to the use of `simplify_chain_real` in the `_add_` operator, the result is automatically simplified:
{{{
sage: s.display()
M --> R
(x, y) |--> 1
}}}
With the code indroduce in this ticket, one can replace `simplify_chain_real` by any function, for instance Sage's `simplify`:
{{{
sage: M.set_simplify_function(simplify)
sage: s = f + g
sage: s.display()
M --> R
(x, y) |--> cos(x)^2 + sin(x)^2
}}}
As we can see, the capabilities of `simplify` are quite limited! Let us replace it by a user-defined function:
{{{
sage: def simpl(expr):
....: return expr.simplify_trig()
....:
sage: M.set_simplify_function(simpl)
sage: s = f + g
sage: s.display()
M --> R
(x, y) |--> 1
}}}
For more flexibility, it is possible to provide a different simplifying function for each chart on the manifold, via
{{{
sage: X.calculcus_method().set_simplify_function(simpl)
}}}
Besides, this ticket improves the documentation and functionalities of the class
[http://doc.sagemath.org/html/en/reference/manifolds/sage/manifolds/calculus_method.html CalculusMethod], which governs the various symbolic backends available on manifolds (SR and !SymPy at the moment).
" enhancement closed major sage-8.8 geometry fixed simplification, symbolic, manifolds tscrim Eric Gourgoulhon Travis Scrimshaw N/A 80b87d805f31ca9095f24ce834c20579de099ded 80b87d805f31ca9095f24ce834c20579de099ded