| 1 | initial version |
I figured this out. Sage's behavior is confusing to say the least. To make it work, I need the following:
gx=function('g', x)
dgx = gx.diff(x)
dgx
sage output: D[0](g)(x)
m(x)=h(x)*x
dgx.substitute_function(g, m)
sage output: x*D[0](h)(x) + h(x)
What's happening, as I understand, is:
function('g', x) has a side effect of creating a variable g with type : class 'sage.symbolic.function_factory.NewSymbolicFunction' which is important for my purpose, but the statement also returns an Express g(x). My original version assigned the returned Express to g, which overrided the NewSymbolicFunction that I need
I need to use .substitute_function() method instead of .subs(), and for that to work, I also need to first create another function m(x)
This seems unnecessarily complex and unintuitive. Is there a better way?
Thanks
Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.