Sympy how to symbolically change of variables for derivatives?

56 views Asked by At

Given

x = x_c * chi
t = t_c * tau

expressing dx/dt in chi, tau is: x_c/t_c * dchi / dtau
https://www.wikiwand.com/en/Nondimensionalization#Conventions

How to evaluate the dx/dt change of variables with sympy given x(chi), t(tau) expressions?

from sympy import symbols, diff

# Define the symbols
x, chi, x_c, t, tau, t_c = symbols('x chi x_c t tau t_c', real=True)

# Define the expressions for x and t in terms of chi and tau
x_expr = x_c * chi
t_expr = t_c * tau

x_expr.diff(t_expr)

results in the somewhat obvious error:

ValueError: Can't calculate derivative wrt t_c*tau.
0

There are 0 answers