Subs?

46 views
Skip to first unread message

m.de...@leeds.ac.uk

unread,
Jan 2, 2013, 4:33:15 AM1/2/13
to sy...@googlegroups.com
Hi,

The following runs almost as expected:

    x=Symbol('x')
    y=Symbol('y')
    t=Symbol('t')
    f=Function('f')
    u=f(x,t)

    phi=Function('phi')

    Phi = phi(x,t,u)

    part=Phi
    total=diff(part,x)

    print total


It gives:
Derivative(f(x, t), x)*Subs(Derivative(phi(x, t, _xi_3), _xi_3), (_xi_3,), (f(x, t),)) + Derivative(phi(x, t, f(x, t)), x)

which is probably the intended result (total derivative). Is  there documentation on Subs?

In the end I would simply want the substitution to be carried out, i.e.
Derivative(f(x,t),x)*Derivative(phi(x,t,f(x,t)) + Derivative(phi(x,t, f(x,t)),x)

How to do that?

Thanks,
Marc

Aaron Meurer

unread,
Jan 2, 2013, 5:37:17 AM1/2/13
to sy...@googlegroups.com
I'm assuming you mean that you want the derivative with respect to the
function f(x, t). This functionality was implemented later on, and I
guess the chain rule code was never updated to use it. Previously,
Subs was the only way to represent differentiation at a point, but
now, if that point is a function, you can just differentiate directly
with respect to that function.

This is something that should be changed. Until then, you can just
replace the Subs with the derivative you want. The replacement code
is a little complicated, so I'll leave it as an exercise to you (or
someone else on this list) to figure it out. Use either
total.atoms(Subs) and .args, or somehow use .replace.

Also, ideally, Subs.doit() would work in this case as well. I opened
https://code.google.com/p/sympy/issues/detail?id=3582 for this.

Aaron Meurer
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/sympy/-/tvR4MGVPTX0J.
> To post to this group, send email to sy...@googlegroups.com.
> To unsubscribe from this group, send email to
> sympy+un...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/sympy?hl=en.
Reply all
Reply to author
Forward
0 new messages