The function substitute_expression() is one of the relics remaining
from the old symbolics code. IMHO, we should merge it with the
substitute() function and deprecate it.
> However that warning refers to Maxima whereas :
>
> sage: get_systems('P.subs_expr({x+y+w0:z+w0})')
> ['ginac']
>
> The weird example can also be solved using a wildcard :
>
> sage: t = var('t')
> sage: f(x,y,t) = cos(x) + sin(y) + x^2 + y^2 + t
> sage: f
> (x, y, t) |--> x^2 + y^2 + t + sin(y) + cos(x)
> sage: f.subs_expr(x^2 + y^2 == t)
> (x, y, t) |--> x^2 + y^2 + t + sin(y) + cos(x)
> sage: f.subs_expr(x^2 + y^2 + w0 == t + w0)
> (x, y, t) |--> 2*t + sin(y) + cos(x)
>
> I don't know if such a trick should be implemented in Sage, pynac, or
> even in GiNaC.
You can definitely suggest it to the ginac developers. I'm curious to
see what they think.
Note that this might not be so straight forward, especially if the
expression we're supposed to replace contains wildcards in the first
place. We can add some logic to our interface to ginac and add the
wildcard to the expression if none exists. Though I'm afraid this might
increase the confusion if someone is trying to debug substitutions in a
complex expression.
One other point against doing this by default is that substituting with
wildcards is slower. Even if we decide to do this, there should be an
option not to.
Cheers,
Burcin
On Wed, 29 Sep 2010 12:39:39 -0700 (PDT)
Jean-Pierre Flori <jpf...@gmail.com> wrote:
> I completely agree with that and am aware that it would be slower.
> That is why I don't think it should be done by default, but something
> in the doc should give someinsight on what is going on and what can be
> done.
I opened two tickets based on this thread:
* #10049 improve documentation of substitute for symbolic expressions
http://trac.sagemath.org/sage_trac/ticket/10049
* #10048 deprecate substitute_expression()
http://trac.sagemath.org/sage_trac/ticket/10048
Cheers,
Burcin