For a function that depend on various variables, having it pretty print as u(x, y, z, w)
is quite tedious to read when the result is long.
from sympy import *
init_printing()
x, y, z, w = symbols('x y z w')
u = Function('u')(x, y, z, w)
f = u.diff(x)
pprint(f)
It prints out
∂
──(u(x, y, z, w))
∂x
Even though it is sensible, it is disturbing when there are many terms. How can it print just
∂
──(u)
∂x
froggiecroaks is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
2
To accomplish your goal, you can use the following code:
.subs(u, Function('u'))
: Substitutes the symbol u
with the function symbol Function('u')
in the result. This effectively replaces the long function notation with just u without calling it.
from sympy import *
init_printing()
x, y, z, w = symbols('x y z w')
u = Function('u')(x, y, z, w)
f = u.diff(x)
pprint(f.subs(u, Function('u')))