The routines in solve() for solving for a function or a derivative
could probably be adapted to diff (and others?) pretty easily. See
commit 5e5a333da78a3af743e5dc5f0130448aaea7c85a.
Aaron Meurer
On Jun 28, 2009, at 7:11 AM, Alan Bromborsky wrote:
>
> I tried this:
>
> from sympy import *
>
> x = Symbol('x')
> print x
> f = Function('f')(x)
> print f
> y = cos(x)
> dydx = diff(y,x)
> print dydx
> y = cos(f)
> dfdx = diff(y,f)
> print dfdx
>
> and got:
>
> x
> f(x)
> -sin(x)
> Traceback (most recent call last):
> File "/home/brombo/diff.py", line 11, in <module>
> dfdx = diff(y,f)
> File
> "/usr/local/lib/python2.6/dist-packages/sympy-0.6.5_beta2_git-
> py2.6.egg/sympy/core/multidimensional.py",
> line 127, in wrapper
> return f(*args, **kwargs)
> File
> "/usr/local/lib/python2.6/dist-packages/sympy-0.6.5_beta2_git-
> py2.6.egg/sympy/core/function.py",
> line 708, in diff
> return Derivative(f,x,times, **{'evaluate':evaluate})
> File
> "/usr/local/lib/python2.6/dist-packages/sympy-0.6.5_beta2_git-
> py2.6.egg/sympy/core/function.py",
> line 486, in __new__
> raise ValueError('Invalid literal: %s is not a valid variable' % s)
> ValueError: Invalid literal: f(x) is not a valid variable
>
>
> There was a discussion about this topic a while back. Is anything
> being
> done about it? Is the only current workaround to substitue a dummy
> variable for 'f', differentiate, and substitute 'f' for the dummy
> variable? I too wish to work with Lagragians and generalized
> coordinates.
>
> >
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sympy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [email protected]
For more options, visit this group at http://groups.google.com/group/sympy?hl=en
-~----------~----~----~----~------~----~------~--~---