# [sympy] chain rule ugly output

so i am implementing a simple chain rule differentiation , given two
functions m2 , m
with:

m2 = r0**2 + r1**2 + r2**2

m= m2**(0.5)

i want to get the differentiation of (m  wrt r0), so i calculate: diff(m
wrt m2) * diff (m2 wrt r0).

expected output:
r0 *  m2**(-0.5).

sympy output:
1.0*r0*m2(r0**2 + r1**2 + r2**2)**(-0.5)*Subs(Derivative(m(_xi_1), _xi_1),
(_xi_1,), (m2(r0**2 + r1**2 + r2**2)**0.5,))*Subs(Derivative(m2(_xi_1),
_xi_1), (_xi_1,), (r0**2 + r1**2 + r2**2,))

---------------------------------------------------------------

first thing i want to know is why instead of writing just m2 it has to
write this (m2(r0**2 + r1**2 + r2**2)) ?
second, why is this term (Subs(Derivative(m(_xi_1), _xi_1), (_xi_1,),
(m2(r0**2 + r1**2 + r2**2)**0.5,))*Subs(Derivative(m2(_xi_1), _xi_1),
(_xi_1,), (r0**2 + r1**2 + r2**2,))) here?
and what does it actually means?

Here's my code:

import sympy as sp

r0, r1, r2, t0 = sp.symbols(
"r0,r1,r2,t0", real=True)

m2, m = sp.symbols('m2, m', cls=sp.Function)

m2 = m2(r0**2 + r1**2 + r2**2)

m = m(m2 ** (0.5))

dm2r0 = sp.Derivative(m2,r0)

dmm2 = sp.Derivative(m,m2)

dmr0 = dmm2 * dm2r0

print("dmr0:\n"+str(dmr0.doit())+"\n\n")

--
You received this message because you are subscribed to the Google Groups
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email