Issue 1139: Description and Differentiation of vector, tensor, and multivector fields. http://code.google.com/p/sympy/issues/detail?id=1139
Comment #24 by [EMAIL PROTECTED]: I am almost there, but need to understand the following code: import sympy,types class ImplicitFunction(sympy.Function): def __new__(cls,Fstr,vars): vars = tuple(vars) obj = sympy.Function.__new__(cls, Fstr, *vars) return obj def __init__(self,Fstr,vars): self.vars = tuple(vars) sympy.Function.__init__(self,Fstr,self.vars) return def deriv(self,var): return(ImplicitDerivative(self,var)) class ImplicitDerivative(sympy.Derivative): def __init__(self,f,var): self.vars = f.vars if type(var) == types.IntType: xvar = self.vars[var] print 'self.vars[var] =',xvar sympy.Derivative(f,xvar) else: sympy.Derivative(f,var) return def deriv(self,var): df = ImplicitDerivative(self,var) return(df) x = sympy.symbols('x1','x2') x1 = x[0] x2 = x[1] print x f = ImplicitFunction('f',x) print 'f =',f df = f.deriv(0) print 'df =',df d2f = df.deriv(1) print d2f df = f.deriv(x1) print 'df =',df d2f = df.deriv(x2) print d2f The output of this code is: [x1, x2] f = ImplicitFunction(f, x1, x2) self.vars[var] = x1 df = D(ImplicitFunction(f, x1, x2)) self.vars[var] = x2 D(D(ImplicitFunction(f, x1, x2))) df = D(ImplicitFunction(f, x1, x2), x1) D(D(ImplicitFunction(f, x1, x2), x1), x2) so we have F.deriv(1) = D(ImplicitFunction(f, x1, x2)) but F.deriv(x2) = D(ImplicitFunction(f, x1, x2), x1) which is correct. From the code they should give the same answer. Why not? -- You received this message because you are listed in the owner or CC fields of this issue, or because you starred this issue. You may adjust your issue notification preferences at: http://code.google.com/hosting/settings --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sympy-issues" group. To post to this group, send email to sympy-issues@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sympy-issues?hl=en -~----------~----~----~----~------~----~------~--~---