Opened 10 years ago

Closed 9 years ago

Last modified 8 years ago

#11842 closed defect (duplicate)

substitute_function doesn't work as expected in many cases

Reported by: mjo Owned by: burcin
Priority: major Milestone: sage-duplicate/invalid/wontfix
Component: symbolics Keywords:
Cc: Merged in:
Authors: Reviewers: Burcin Erocal
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description (last modified by mjo)

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. Works..
x = var('x')
f = function('f')
g = function('g')
p = f(x).diff()(1)
print p.substitute_function(f, g) # Prints D[0](g)(1).

Change History (6)

comment:1 Changed 9 years ago by mjo

  • Milestone changed from sage-4.8 to sage-duplicate/invalid/wontfix

It looks like I accidentally duped #6480 here.

comment:2 Changed 9 years ago by burcin

  • Reviewers set to Burcin Erocal
  • Status changed from new to needs_review

comment:3 Changed 9 years ago by burcin

  • Status changed from needs_review to positive_review

comment:4 Changed 9 years ago by jdemeyer

  • Resolution set to duplicate
  • Status changed from positive_review to closed

comment:5 Changed 8 years ago by mjo

  • Description modified (diff)

comment:6 Changed 8 years ago by mjo

  • Description modified (diff)
Note: See TracTickets for help on using tickets.