Fwd: Help differentiating composite functions



In 2002 Barton started to write a replacement for ndiff, called pdiff, 
his code is there:
www.math.utexas.edu/pipermail/maxima/2002/002387.html
ndiff represents derivatives positionally, so in your case the the 
derivative of f with respect to the first argument is f with a 
superscript of (1,0) and with respect to the second argument as f with a 
superscript of (0,1).
Barton's code may work better now, then it did then, as more bugs in 
maxima have been repaired.
However, you may get something working faster by assigning dummy 
variables to the positional arguments,
setting dependencies on them, and using diff, and substituting for 
del(x) and del(y).

for example:
diff(f)
'diff(f,y,1)*del(y)+'diff(f,x,1)*del(x)

You can also generate dummy variables if you want using gensym.
Jeffrey Hankins wrote:
>
>
> ---------- Forwarded message ----------
> From: *Jeffrey Hankins* <jhankin1 at gmail.com <mailto:jhankin1 at gmail.com>>
> Date: Tue, Jun 29, 2010 at 10:20
> Subject: Re: Help differentiating composite functions
> To: Rupert Swarbrick <rswarbrick at gmail.com <mailto:rswarbrick at gmail.com>>
>
>
> Thanks, Rupert. That is exactly what I meant.
>
>
> On Tue, Jun 29, 2010 at 08:55, Rupert Swarbrick <rswarbrick at gmail.com 
> <mailto:rswarbrick at gmail.com>> wrote:
>
>     Jaime Villate <villate at fe.up.pt <mailto:villate at fe.up.pt>> writes:
>
>     > On Mon, 2010-06-28 at 15:25 -0400, Jeffrey Hankins wrote:
>     >> Hey, there's something I can't do in Maxima. I cannot differentiate
>     >> things like f(g(t),h(t)) where f is a generic function and g
>     and h are
>     >> specific functions. If the depends tag is used, it will
>     differentiate
>     >> f with no arguments, but it will not differentiate something like
>     >> f(t^2+1,t^3) with respect to t. Is there anything I can do?
>     > You'll have to be more specific (show us the exact Maxima lines that
>     > lead you to conclude that it doesn't work).
>     > For instance, what you describe works well in this sense:
>     >
>     > (%i1) f(x,y):=x+2*y$
>     >
>     > (%i2) diff(f(t^2+1,t^3), t);
>     >
>     > (%o2) 6*t^2 + 2*t
>     >
>     I think he means he has an example where he wants the chain rule
>     to kick
>     in.
>
>     for example
>
>     (%i1) diff( f(x^3+2*cos(x), 4*x + x^3), x );
>                            d                 3   3
>     (%o1)                   -- (f(2 cos(x) + x , x  + 4 x))
>                            dx
>
>     and he wants an output something like
>
>     ??f(x^3+2*cos(x), 4*x + x^3)*(3*x^2-2*sin(x)) +
>     ??f(x^3+2*cos(x), 4*x + x^3)*(3*x^2+4)
>
>     or whatever. (Obviously I made up the ??,
?? notation: maybe a package
>     like pdiff could help?)
>
>
>     Rupert
>
>
>
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>