The list of functions provided in SystemOptions["DifferentiationOptions" -> "ExcludedFunctions"] show which symbols will not be touched by D. For example

D[x > y, x]

returns unevaluated.

However, I also need the same behavior when these functions are in their Inactive form:


unfortunately evaluates to Derivative[1,0][Inactive[Greater]][x,y]. Rather I need it to be unevaluated.

How do I change the SystemOptions so that inactive forms are also untouched.

Supplying option NonConstants->Greater to D is inadequate because then I get the funny behavior that now D[Less[a,b],x,NonConstants->Greater] no longer evaluates to 0.

  • $\begingroup$ does this work: excludedfuncs = "ExcludedFunctions" /. ("DifferentiationOptions" /. SystemOptions["DifferentiationOptions"]); SetSystemOptions[ "DifferentiationOptions" -> {"ExcludedFunctions" -> Append[excludedfuncs, Inactivate]}]? $\endgroup$ – kglr May 26 '18 at 14:06
  • $\begingroup$ @kglr no, it doesn't work. Did it work for you? $\endgroup$ – QuantumDot May 26 '18 at 15:17
  • $\begingroup$ Do you really need it to remain unevaluated, or do you need it to evaluate to something like Inactive[Greater][1, 0]? $\endgroup$ – Carl Woll Jun 24 '18 at 0:57

Since Derivative isn't protected, I would suggest adding a definition that transforms the undesired output a little further:

Derivative[1, 0][Inactive[Greater]][x_, y_] := Inactive[Greater][x, y]

The right-hand side can be adjusted depending on what you want. You could also add definitions that work for the other variable slot, but that wasn't asked for in the question.

With the above, you get the output

D[Inactive[Greater][x, y], x] // FullForm

Inactive[Greater][x, y]


Generalizing to more complex arguments, you could do the following:

HoldPattern[D[Inactive[Greater][f_, g_], x_]] :=  Inactive[Greater][f, g];

Then you get the extpected result:

D[Inactive[Greater][a x, y], x] // FullForm

Inactive[Greater][Times[a, x], y]

  • $\begingroup$ There is the strange problem that D[Inactive[Greater][a x, y], x] leads to a factor of a as a coefficient. Any ideas on how to fix that? $\endgroup$ – QuantumDot Jun 24 '18 at 15:49
  • $\begingroup$ That's right, it's the chain rule. I addressed this in another answer, but to add it here would be more difficult... In this case you may have to add the definition to D but this requires unprotecting it first, which may be too far from what you're willing to do. $\endgroup$ – Jens Jun 24 '18 at 15:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.