Hi:
source code:
import sympy
x=sympy.symbols('x',real=True)
f=sympy.symbols('f',cls=sympy.Function)
f.is_real=True
a=sympy.Abs(f(x).diff(x)).diff(f(x).diff(x))
a
the output is:
(re(Derivative(f(x), x))*Subs(Derivative(re(_xi_2), _xi_2), (_xi_2,), (Derivative(f(x), x),)) + im(Derivative(f(x), x))*Subs(Derivative(im(_xi_2), _xi_2), (_xi_2,), (Derivative(f(x), x),)))/Abs(Derivative(f(x), x))
the imaginary part still exist. Obviously, sympy does not think f(x).diff(x) is real. So I try:
sympy.refine(a,sympy.Q.real(f(x).diff(x)))
but the output remains the same. So how to tell sympy that f(x).diff(x) is real?
More weird stuff is:
f(x).diff(f(x))
the output is 1
but:
sympy.Abs(f(x)).diff(f(x))
the output is:
f(x)*Subs(Derivative(re(_xi_2), _xi_2), (_xi_2,), (f(x),))/Abs(f(x))
why sympy is not smart enough to simplify it to f(x)/Abs(f(x))?
I use python3.4 and sympy 0.7.6