Would there be any reason that the following should not be implemented: t = Symbol('t') q1 = Function('q1')(t) solve(q1 - 1, q1)
Currently, the solve function gives: --------------------------------------------------------------------------- TypeError Traceback (most recent call last) /home/luke/Documents/PythonDynamics/<ipython console> in <module>() /var/lib/python-support/python2.6/sympy/solvers/solvers.pyc in solve(f, *symbols, **flags) 73 74 if any(not s.is_Symbol for s in symbols): ---> 75 raise TypeError('not a Symbol') 76 77 if not isinstance(f, (tuple, list, set)): TypeError: not a Symbol In classical mechanics, the generalised coordinates are often treated as symbols implicitly dependent upon time. Not being able to solve for their time derivatives using solve requires tedious .subs() calls to replace them with symbols, solve, then replace them back with Functions. Similarly, is there a reason we can't differentiate with respect to a Function? For example, when using Lagrange's method for formulating equations of motion, we need to differentiate the Lagrangian with respect to the coordinates and with respect to the time derivatives of the coordinates, and then take the time derivative.... Not being able to differentiate with respect to q1.diff(t) means that one has to create a dummy symbol for q1.diff(t), replace all occurances of it in the Lagrangian, then take the derivative with respect to that symbol, then back substitute to replace the symbol with the function, then differentiate with respect to time.... a very burdensome approach indeed. This is what happens currently: In [12]: diff(q3-1, q3) --------------------------------------------------------------------------- ValueError Traceback (most recent call last) /home/luke/Documents/PythonDynamics/<ipython console> in <module>() /var/lib/python-support/python2.6/sympy/core/multidimensional.pyc in wrapper(*args, **kwargs) 125 result = apply_on_element(wrapper, args, kwargs, n) 126 return result --> 127 return f(*args, **kwargs) 128 wrapper.__doc__ = f.__doc__ 129 wrapper.__name__ = f.__name__ /var/lib/python-support/python2.6/sympy/core/function.pyc in diff(f, x, times, evaluate) 693 """ 694 --> 695 return Derivative(f,x,times, **{'evaluate':evaluate}) 696 697 @vectorize(0) /var/lib/python-support/python2.6/sympy/core/function.pyc in __new__(cls, expr, *symbols, **assumptions) 476 s = sympify(s) 477 if not isinstance(s, Symbol): --> 478 raise ValueError('Invalid literal: %s is not a valid variable' % s) 479 if not expr.has(s): 480 return S.Zero ValueError: Invalid literal: q3(t) is not a valid variable Or is there another way this can be done easily that I'm not aware of? Thanks, ~Luke --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sympy" group. To post to this group, send email to sympy@googlegroups.com To unsubscribe from this group, send email to sympy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sympy?hl=en -~----------~----~----~----~------~----~------~--~---