<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Partial Derivatives in sympy
Step1:  The case of a(n arbitrary) point transformation
cf. Introduction to Differential Invariants, Chapter 2 Lie Transformations pp. 16
Step2:  For $Y''(X)$,
Step4:  cf. How to do total derivatives
Step5:  This transformation is the Legendre transformation
cf. 4. Exercises Chapter 2 Lie Transformations Introduction to Differential Invariants.   
Consider transformation $(x,u)=(x,u(x)) \to (X,U)=(X(x,u),U(x,u))=(u,x)$.  Let $Y=Y(X)$.  $Y(X) \in \Gamma(\mathbb{R}^1 \times \mathbb{R}^1)$, i.e. $Y(X)$ is a section. So $Y(X) = Y(X(x,u)) = U(x,u)$.  And so in this case,
$Y(X(x,u))=Y(u)=U(x,u) = x$
Step6:  And so $Y'(X)$ is
Step7:  And so $Y''(X)$ is
Step8:  cf. (2) from 4. Exercises, Chapter 2 Lie Transformations pp. 20
Recall an arbitrary point transformation
Step9:  For $Y''(X)$,
<ASSISTANT_TASK:>
Python Code:
import sympy
x, u = sympy.symbols('x u', real=True)
U = sympy.Function('U')(x,u)
U
Explanation: Partial Derivatives in sympy
End of explanation
x = sympy.Symbol('x',real=True)
y = sympy.Function('y')(x)
U = sympy.Function('U')(x,y)
X = sympy.Function('X')(x,y)
Y = sympy.Function('Y')(X)
sympy.pprint(sympy.diff(U,x))
sympy.pprint( sympy.diff(Y,x))
sympy.pprint( sympy.diff(Y,x).args[0] )
sympy.pprint( sympy.diff(U,x)/ sympy.diff(Y,x).args[0])
Explanation: The case of a(n arbitrary) point transformation
cf. Introduction to Differential Invariants, Chapter 2 Lie Transformations pp. 16
End of explanation
YprimeX = sympy.diff(U,x)/sympy.diff(Y,x).args[0]
sympy.pprint( sympy.diff(YprimeX,x).simplify() )
sympy.factor_list( sympy.diff(Y,x)) # EY 20160522 I don't know how to simply obtain the factors of an expression 
# EY 20160522 update resolved: look at above and look at this page; it explains all: 
# http://docs.sympy.org/dev/tutorial/manipulation.html
t, x, u, u_1, x_t, u_t, u_1t = sympy.symbols('t x u u_1 x_t u_t u_1t', real=True)
X = -u_1
U = u - x*u_1
U_1 = x
Explanation: For $Y''(X)$,
End of explanation
from sympy import Derivative, diff, expr
def difftotal(expr, diffby, diffmap):
    Take the total derivative with respect to a variable.
    Example:
        theta, t, theta_dot = symbols("theta t theta_dot")
        difftotal(cos(theta), t, {theta: theta_dot})
    returns
        -theta_dot*sin(theta)
    
    # Replace all symbols in the diffmap by a functional form
    fnexpr = expr.subs({s:s(diffby) for s in diffmap})
    # Do the differentiation
    diffexpr = diff(fnexpr, diffby)
    # Replace the Derivatives with the variables in diffmap
    derivmap = {Derivative(v(diffby), diffby):dv 
                for v,dv in diffmap.iteritems()}
    finaldiff = diffexpr.subs(derivmap)
    # Replace the functional forms with their original form
    return finaldiff.subs({s(diffby):s for s in diffmap})
difftotal( U,t,{x:x_t, u:u_t, u_1:u_1t}) + (-U_1)* (-u_1t)
Explanation: cf. How to do total derivatives: http://robotfantastic.org/total-derivatives-in-sympy.html
End of explanation
x = sympy.Symbol('x',real=True)
u = sympy.Function('u')(x)
U = x
X = u
Y = sympy.Function('Y')(X)
sympy.pprint( sympy.diff(Y,x))
sympy.pprint(sympy.diff(U,x))
Explanation: This transformation is the Legendre transformation
cf. 4. Exercises Chapter 2 Lie Transformations Introduction to Differential Invariants.   
Consider transformation $(x,u)=(x,u(x)) \to (X,U)=(X(x,u),U(x,u))=(u,x)$.  Let $Y=Y(X)$.  $Y(X) \in \Gamma(\mathbb{R}^1 \times \mathbb{R}^1)$, i.e. $Y(X)$ is a section. So $Y(X) = Y(X(x,u)) = U(x,u)$.  And so in this case,
$Y(X(x,u))=Y(u)=U(x,u) = x$
End of explanation
sympy.pprint( 1/ sympy.diff(Y,x).args[0])
Explanation: And so $Y'(X)$ is
End of explanation
sympy.pprint( sympy.diff( 1/ sympy.diff(Y,x).args[0], x))
Explanation: And so $Y''(X)$ is
End of explanation
x = sympy.Symbol('x',real=True)
y = sympy.Function('y')(x)
U = sympy.Function('U')(x,y)
X = sympy.Function('X')(x,y)
Y = sympy.Function('Y')(X)
sympy.pprint(sympy.diff(U,x))
sympy.pprint( sympy.diff(Y,x))
sympy.pprint( sympy.diff(Y,x).args[0] )
sympy.pprint( sympy.diff(U,x)/ sympy.diff(Y,x).args[0])
Explanation: cf. (2) from 4. Exercises, Chapter 2 Lie Transformations pp. 20
Recall an arbitrary point transformation:
End of explanation
YprimeX = sympy.diff(U,x)/sympy.diff(Y,x).args[0]
Yprime2X = sympy.diff(YprimeX,x)
sympy.pprint( Yprime2X.simplify() )
Explanation: For $Y''(X)$,
End of explanation
<END_TASK>