On Tue, Apr 01, 2008 at 04:30:18PM +0200, Ondrej Certik wrote:
> 
> On Tue, Apr 1, 2008 at 4:18 PM, Alan Bromborsky <[EMAIL PROTECTED]> wrote:
> >
> >
> >  Ondrej Certik wrote:
> >  > Hi Alan!
> >  >
> >  > On Sun, Mar 30, 2008 at 6:20 PM, Alan Bromborsky <[EMAIL PROTECTED]> 
> > wrote:
> >  >
> >  >>  If F(x,y,z,w) and x=x(t) and y=y(t) here is what I did to calculate
> >  >>  df/dt.  Do you have a built in method to do that?
> >  >>
> >  >
> >  > You mean dF/dt, right?
> >  >
> >  >
> >  >>  from GAsympy import *
> >  >>  from sympy import *
> >  >>
> >  >>  set_main(sys.modules[__name__])
> >  >>
> >  >>  def PDerive(f,vlst,t):
> >  >>     dfdt = 0
> >  >>     for v in vlst:
> >  >>         dvdt = sympy.Symbol('d'+v.__str__()+'d'+t.__str__())
> >  >>         dfdt += sympy.diff(f,v)*dvdt
> >  >>     return(dfdt)
> >  >>
> >  >>  make_symbols('a b c x y z w t')
> >  >>
> >  >>  f = a*x+exp(-y)*b*z*c*w**2*x
> >  >>
> >  >>  print 'f =',f
> >  >>
> >  >>  dfdt = PDerive(f,[x,y],t)
> >  >>
> >  >>  print 'dfdt =',dfdt
> >  >>
> >  >>  ##  Program output
> >  >>  ##  f = a*x + b*c*x*z*w**2*exp(-y)
> >  >>  ##  dfdt = dxdt*(a + b*c*z*w**2*exp(-y)) - b*c*dydt*x*z*w**2*exp(-y)

Here is my proposal:

In [1]: var('a b c x y z w t')
Out[1]: (a, b, c, x, y, z, w, t)

In [2]: f = a*x + b*c*x*z*w**2*exp(-y)

In [3]: fx = Function('fx')

In [4]: fy = Function('fy')

In [5]: g=f.subs(x,fx(t)).subs(y,fy(t))

In [6]: g
Out[6]: 
                 2  -fy(t)      
a*fx(t) + b*c*z*w *ℯ      *fx(t)

In [7]: g.diff(t)
Out[7]: 
  d                  2  -fy(t) d                  2  -fy(t)       d        
a*──(fx(t)) + b*c*z*w *ℯ      *──(fx(t)) - b*c*z*w *ℯ      *fx(t)*──(fy(t))
  dt                           dt                                 dt       

By the way, have you an advice to simply factor out the df/dt?

As I adviced in my pdf-file comment its good to distinguish the
different mathematical objects. So you have solved the naming problem.
Here is my opinion about

        y = f(x, y)

So y is a function of the _symbols_ x and y. These symbols represent
maybe a real number. But when you say
 
        x(t)

you correctly mean

(*)     x = fx(t)   

So x is now a function of the symbol t. When you substitute x now in f
you get an new function namly

        g(t, y) = f( fx(t), y ) 

My question is whether anybody has a better proposal for the name fx in
(*)?


By, Friedrich

--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sympy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to