Skip to content

substitute_function doesn't work as expected in many cases #11842

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
orlitzky opened this issue Sep 24, 2011 · 4 comments
Closed

substitute_function doesn't work as expected in many cases #11842

orlitzky opened this issue Sep 24, 2011 · 4 comments

Comments

@orlitzky
Copy link
Contributor

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).

Component: symbolics

Reviewer: Burcin Erocal

Issue created by migration from https://trac.sagemath.org/ticket/11842

@orlitzky
Copy link
Contributor Author

orlitzky commented Jan 3, 2012

comment:1

It looks like I accidentally duped #6480 here.

@orlitzky orlitzky removed this from the sage-4.8 milestone Jan 3, 2012
@burcin
Copy link
Contributor

burcin commented Feb 8, 2012

Reviewer: Burcin Erocal

@orlitzky

This comment has been minimized.

@orlitzky

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants