'Partial derivatives and substituitions with SymPy
I have the following code where I define a composite function f(r(x,y),theta(x,y)), and I'm trying to simplify f.diff(x) assuming that I know an expression for f.diff(r):
x, y = sp.symbols("x y", real=True)
r = sp.Function('r')(x, y)
phi = sp.Function('phi')(x, y)
f = sp.Function('f')(r, phi)
df_dr = sp.Function('df_dr')(r, phi)
df_phi = sp.Function('df_phi')(r, phi)
Next, I compute the derivatives of f(r,phi) with respect to x:
f.diff(x)
And I get the following:
Derivative(phi(x, y), x)*Subs(Derivative(f(r(x, y), _xi_2), _xi_2), _xi_2, phi(x, y)) + Derivative(r(x, y), x)*Subs(Derivative(f(_xi_1, phi(x, y)), _xi_1), _xi_1, r(x, y))
My question is: how can I replace Subs(Derivative(f(_xi_1, phi(x, y)), _xi_1) by df_dr?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
