Ask Your Question

Revision history [back]

While one can "hold" multiplication as follows, to prevent any simplification of an expression:

sage: rho = function('rho')(x)
sage: J = function('J')(x)

sage: a, b = J(x)/rho(x), rho(x)
sage: a * b
J(x)

sage: a.mul(b, hold=True)
(J(x)/rho(x))*rho(x)

the same is not true for differentiation:

sage: diff(J(x)^2/rho(x), x, hold=True)
Traceback (most recent call last)
...
TypeError: derivative() got an unexpected keyword argument 'hold'

The only workaround I can think of is this trick:

sage: f = function('(J^2/rho)')(x)
sage: diff(f, x)
diff((J^2/rho)(x), x)

sage: f = function('J(x)^2/rho')(x)
sage: diff(f, x)
diff(J(x)^2/rho(x), x)

which one might then try to combine with expression substitutions...