Thanks for the workaround, William. I was thinking the same thing as a temporary fix but am having difficulties with that approach.
Here's my situation. I have a big symbolic expression E involving lots of derivatives. I want to substitute the derivatives with other symbolic expressions, and the substitutions are stored in a big dictionary D. Presently E.subs(D) does not work in Sage. I tried a keyword substitution instead, but got the error 'SyntaxError: keyword can't be an expression (<ipython console>, line 1)' Another approach is to convert E and the keys of D to strings, perform the substitution as strings, and then convert E back to a symbolic expression. I'm trying this now but am getting stuck with the string substitution step... If anyone out there can think of a simpler temporary workaround, please let me know. Thanks. Alex On Nov 20, 3:27 pm, William Stein <wst...@gmail.com> wrote: > On Thu, Nov 19, 2009 at 6:08 PM, Alex Raichev <tortoise.s...@gmail.com> wrote: > > Hi all: > > > Related tohttp://trac.sagemath.org/sage_trac/ticket/6243, it appears > > that using derivatives of callable symbolic functions as dictionary > > keys is broken in Sage 4.2.1. See below. It works for functions of > > one and two variables but not three. > > > Alex > > A temporary workaround is to use str(): > > X= var('x,y,z') > f= function('f',*X); f > d= {} > for l in [1..2]: > for s in UnorderedTuples(X,l): > print diff(f,s) > d[str(diff(f,s))]= 69 > > William > > > > > > > ---------------------------------------------------------------------- > > | Sage Version 4.2.1, Release Date: 2009-11-14 | > > | Type notebook() for the GUI, and license() for information. | > > ---------------------------------------------------------------------- > > sage: X= var('x,y,z') > > sage: f= function('f',*X); f > > f(x, y, z) > > sage: d= {} > > sage: for l in [1..2]: > > ....: for s in UnorderedTuples(X,l): > > ....: print diff(f,s) > > ....: d[diff(f,s)]= 69 > > ....: > > D[0](f)(x, y, z) > > D[1](f)(x, y, z) > > D[2](f)(x, y, z) > > D[0, 0](f)(x, y, z) > > --------------------------------------------------------------------------- > > NotImplementedError Traceback (most recent call > > last) > > > /Users/arai021/<ipython console> in <module>() > > > /Applications/sage/local/lib/python2.6/site-packages/sage/symbolic/ > > expression.so in sage.symbolic.expression.Expression.__nonzero__ (sage/ > > symbolic/expression.cpp:7801)() > > > /Applications/sage/local/lib/python2.6/site-packages/sage/symbolic/ > > expression.so in sage.symbolic.expression.Expression.test_relation > > (sage/symbolic/expression.cpp:9177)() > > > /Applications/sage/local/lib/python2.6/site-packages/sage/rings/ > > complex_interval_field.py in __call__(self, x, im) > > 286 > > 287 try: > > --> 288 return x._complex_mpfi_( self ) > > 289 except AttributeError: > > 290 pass > > > /Applications/sage/local/lib/python2.6/site-packages/sage/symbolic/ > > expression.so in sage.symbolic.expression.Expression._complex_mpfi_ > > (sage/symbolic/expression.cpp:5364)() > > > /Applications/sage/local/lib/python2.6/site-packages/sage/symbolic/ > > expression_conversions.py in __call__(self, ex) > > 212 div = self.get_fake_div(ex) > > 213 return self.arithmetic(div, div.operator()) > > --> 214 return self.arithmetic(ex, operator) > > 215 elif operator in relation_operators: > > 216 return self.relation(ex, operator) > > > /Applications/sage/local/lib/python2.6/site-packages/sage/symbolic/ > > expression_conversions.py in arithmetic(self, ex, operator) > > 1437 return base ** expt > > 1438 else: > > -> 1439 return reduce(operator, map(self, operands)) > > 1440 > > 1441 def composition(self, ex, operator): > > > /Applications/sage/local/lib/python2.6/site-packages/sage/symbolic/ > > expression_conversions.py in __call__(self, ex) > > 212 div = self.get_fake_div(ex) > > 213 return self.arithmetic(div, div.operator()) > > --> 214 return self.arithmetic(ex, operator) > > 215 elif operator in relation_operators: > > 216 return self.relation(ex, operator) > > > /Applications/sage/local/lib/python2.6/site-packages/sage/symbolic/ > > expression_conversions.py in arithmetic(self, ex, operator) > > 1437 return base ** expt > > 1438 else: > > -> 1439 return reduce(operator, map(self, operands)) > > 1440 > > 1441 def composition(self, ex, operator): > > > /Applications/sage/local/lib/python2.6/site-packages/sage/symbolic/ > > expression_conversions.py in __call__(self, ex) > > 216 return self.relation(ex, operator) > > 217 elif isinstance(operator, FDerivativeOperator): > > --> 218 return self.derivative(ex, operator) > > 219 else: > > 220 return self.composition(ex, operator) > > > /Applications/sage/local/lib/python2.6/site-packages/sage/symbolic/ > > expression_conversions.py in derivative(self, ex, operator) > > 344 NotImplementedError: derivative > > 345 """ > > --> 346 raise NotImplementedError, "derivative" > > 347 > > 348 def arithmetic(self, ex, operator): > > > NotImplementedError: derivative > > sage: > > > -- > > To post to this group, send email to sage-support@googlegroups.com > > To unsubscribe from this group, send email to > > sage-support-unsubscr...@googlegroups.com > > For more options, visit this group > > athttp://groups.google.com/group/sage-support > > URL:http://www.sagemath.org > > -- > William Stein > Associate Professor of Mathematics > University of Washingtonhttp://wstein.org -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org