On 04/04/12 15:39, Nils Bruin wrote: > On Apr 1, 2:34 pm, Michael Orlitzky <mich...@orlitzky.com> wrote: > >> Substitution doesn't even work pre-evaluation: >> >> sage: f = function('f', x) >> sage: f_prime = f.diff(x) >> sage: g = function('g', x) >> sage: f_prime.substitute_function(f,g) >> D[0](f)(x) > > That's because you're trying to substitute expressions, not functions: > > sage: f,g > (f(x), g(x)) >
I sort of buy that, but if, sage: f = function('f', x) doesn't make `f` a function, that's a user-interface WTF =) It wouldn't matter if I could substitute them as expressions, but that doesn't work either: sage: f = function('f', x) sage: g = function('g', x) sage: f.diff(x).substitute_expression(f==g) D[0](f)(x) sage: f.diff(x).subs(f=g) D[0](f)(x) sage: f.diff(x)(f=g) D[0](f)(x) I reported a lot of these at, http://trac.sagemath.org/sage_trac/ticket/11842 and later duped it to, http://trac.sagemath.org/sage_trac/ticket/6480 which seems to be the first report of the problem. > For that, you would have to use a different substitution function and > it wouldn't have any effect anyway because the expression f(x) does > not occur in f_prime. > > If you fix this, the substitution does work: > > sage: f = f.operator() > sage: g = g.operator() > sage: f,g > (f, g) > sage: f_prime.substitute_function(f,g) > D[0](g)(x) > > There is a different issue, which is fixed by > http://trac.sagemath.org/sage_trac/ticket/12801 > After #12801, I'm having trouble reconciling these two examples: sage: f = function('f', x) sage: g = function('g') sage: f.diff(x).substitute_function(f,g) D[0](f)(x) versus, sage: f = function('f') sage: g = function('g') sage: f(x).diff(x).substitute_function(f,g) D[0](g)(x) It would be slightly better I think if the first example worked, but I can live with using the second (although I never would have discovered it on my own). What I would /really/ like to be able to do is, midpoint = (1/2)*( f(a) + f(b) ) and then approximate multiple functions by swapping out the symbolic `f` for a real function like sine. -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org