#11842: substitute_function doesn't work as expected in many cases
-----------------------------+----------------------------------------------
Reporter: mjo | Owner: burcin
Type: defect | Status: closed
Priority: major | Milestone: sage-duplicate/invalid/wontfix
Component: symbolics | Resolution: duplicate
Keywords: | Work issues:
Report Upstream: N/A | Reviewers: Burcin Erocal
Authors: | Merged in:
Dependencies: | Stopgaps:
-----------------------------+----------------------------------------------
Description changed by mjo:
Old description:
> I'm working on polynomial interpolation at the moment, and these are
> starting to hurt. Most of them have workarounds, but there don't seem to
> be any for the expressions involving derivatives.
>
> I've also tried with subs() and the like, but one step at a time.
>
> {{{
> from sage.all import *
>
> # 1. Fails.
> x = var('x')
> f = function('f', x)
> g = function('g', x)
> p = f
> print p.substitute_function(f, g) # Outputs "f(x)"
>
>
> # 2. Fails.
> x = var('x')
> f = function('f')
> g = function('g')
> p = f(x)
> print p.substitute_function(f(x), g(x)) # Outputs "f(x)"
>
>
> # 3. Fails.
> x = var('x')
> f = function('f')
> g = function('g')
> p = f(x)
> print p.substitute_function(f, g) # Outputs "g(x)"
>
>
> # 4. Fails.
> x = var('x')
> f = function('f')
> g = function('g')
> p = f(1)
> print p.substitute_function(f(1), g(1)) # Outputs "f(1)"
>
>
> # 5. Works.
> x = var('x')
> f = function('f')
> g = function('g')
> p = f(1)
> print p.substitute_function(f, g) # Outputs "g(1)"
>
>
> # 6. Fails.
> x = var('x')
> f = function('f', x)
> g = function('g', x)
> p = f.diff()
> print p.substitute_function(f, g) # Outputs "D[0](f)(x)"
>
>
> # 7. Fails.
> x = var('x')
> f = function('f', x)
> g = function('g', x)
> p = f.diff()
> print p.substitute_function(f(x), g(x)) # Outputs "D[0](f)(x)"
>
>
> # 8. Works.
> x = var('x')
> f = function('f')
> g = function('g')
> p = f(x).diff()
> print p.substitute_function(f, g) # Outputs "D[0](g)(x)"
>
>
> # 9. Fails.
> x = var('x')
> f = function('f')
> g = function('g')
> p = f(x).diff()(1)
> print p.substitute_function(f(x).diff(), g(x).diff()) # Outputs
> "D[0](f)(1)"
>
>
> # 10. Fails.
> x = var('x')
> f = function('f')
> g = function('g')
> p = f(x).diff()(1)
> print p.substitute_function(f, g) # Crashes.
> }}}
New description:
I'm working on polynomial interpolation at the moment, and these are
starting to hurt. Most of them have workarounds, but there don't seem to
be any for the expressions involving derivatives.
I've also tried with subs() and the like, but one step at a time.
{{{
from sage.all import *
# 1. Fails.
x = var('x')
f = function('f', x)
g = function('g', x)
p = f
print p.substitute_function(f, g) # Outputs "f(x)"
# 2. Fails.
x = var('x')
f = function('f')
g = function('g')
p = f(x)
print p.substitute_function(f(x), g(x)) # Outputs "f(x)"
# 3. Works.
x = var('x')
f = function('f')
g = function('g')
p = f(x)
print p.substitute_function(f, g) # Outputs "g(x)"
# 4. Fails.
x = var('x')
f = function('f')
g = function('g')
p = f(1)
print p.substitute_function(f(1), g(1)) # Outputs "f(1)"
# 5. Works.
x = var('x')
f = function('f')
g = function('g')
p = f(1)
print p.substitute_function(f, g) # Outputs "g(1)"
# 6. Fails.
x = var('x')
f = function('f', x)
g = function('g', x)
p = f.diff()
print p.substitute_function(f, g) # Outputs "D[0](f)(x)"
# 7. Fails.
x = var('x')
f = function('f', x)
g = function('g', x)
p = f.diff()
print p.substitute_function(f(x), g(x)) # Outputs "D[0](f)(x)"
# 8. Works.
x = var('x')
f = function('f')
g = function('g')
p = f(x).diff()
print p.substitute_function(f, g) # Outputs "D[0](g)(x)"
# 9. Fails.
x = var('x')
f = function('f')
g = function('g')
p = f(x).diff()(1)
print p.substitute_function(f(x).diff(), g(x).diff()) # Outputs
"D[0](f)(1)"
# 10. Fails.
x = var('x')
f = function('f')
g = function('g')
p = f(x).diff()(1)
print p.substitute_function(f, g) # Works, prints D[0](g)(1).
}}}
--
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/11842#comment:5>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.