On Sun, Dec 14, 2008 at 9:40 PM, Friedrich Hagedorn <[email protected]> wrote: > > On Sun, Dec 14, 2008 at 03:18:10PM +0800, Aaron Yu ZHANG wrote: >> Hi Friedrich, >> >> I think I made the question even more misleading by giving the previous >> example. In fact, please look into [1]this equation. > > Ok. But I didnt change my opinion about the previous solution :-) I hope > I can explain it way. > >> Basically, T is a function of qi and qi_dot, which can be derived. > > What you say is that: > > T: R^2 --> R > > (qi, qi_dot) |--> T(qi, qi_dot) > > T maps the two real numbers (qi and qi_dot) to an other real number. > >> qi is a function of time, > > So this is: > > qi = f(t) > > Remember to school: y = f(x) x,y are real numbers and f is the function. > > Now you concatanate the functions T and f and get a new function which > depends from t: > > t |--> T( f(t), f'(t)) > >> I've no problem get diff(T,qi). But I cannot derive diff(T,qi_dot) > > That isnt a problem because you want derivate T with respect to the first > and second argument (qi and qi_dot): > > T_qi (qi, qi_dot) > > and > > T_qi_dot (qi, qi_dot) > > The derivatives of T, namly T_qi and T_qi_dot, are also functions of > qi and qi_dot. And then you concatanate T_qi and T_qi_dot with f: > > t |--> T_qi( f(t), f'(t)) > > and > > t |--> T_qi_dot( f(t), f'(t)) > > These are functions which depends from t. The last function should > be derivate with respect to t to get Qj. > > The point is: T and f are different function and must be concatenate > (substitute). If this was not clear you must ask again :-) > > By, > > Friedrich > >> Now, I have this idea: >> >> % isympy >> In [1]: var('t xDot') >> Out[1]: (t, xDot) >> >> In [2]: g = lambdify((x, xDot), x*xDot) >> >> In [3]: g(x, xDot) >> Out[3]: x*xDot >> >> In [4]: g(f(t), diff(f(t), t)) >> Out[4]: >> d >> f(t)*──(f(t)) >> dt >> >> In [5]: gDot = lambdify((x, xDot), diff(g(x, xDot), xDot)) >> >> In [6]: gDot(f(t), diff(f(t), t)) >> Out[6]: f(t)
Hi, thanks everyone for answering. Yes, as Riccardo has pointed out, the current implementation could be improved, but one can get the job done already with substitutions as pointed out. Ideally the improvement should be that Functions should behave exactly like Symbols (with respect to differentiation and maybe other things), but they will also carry the dependencies on other variables -- so that sympy can also differentiate with respect to those variables correctly. Ondrej --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
