# Trouble using pattern matching with derivatives

I'm going to pre-reference this similar question as its very nearly what I need but my attempt at extending it to my case doesn't seem to quite work: Pattern matching a multivariate derivative

In my case I have a wide range of terms that look like:

Derivative[0, 1][\[Chi]][r[], \[Theta][]]^2*Derivative[0, 2][\[Chi]][r[], \[Theta][]]*Derivative[1, 0][\[Chi]][r[], \[Theta][]]^2


I want to set terms that are the product of 3 derivatives to 0. My thought is that this would be exactly the referenced question and I would just set the brackets to be a total wild card ___ and add a new wild card after each derivative to catch possible powers that may mess up the pattern matching:

% /. Derivative[___][___][___] ___*Derivative[___][___][___]*
Derivative[___][___][___] ___ -> 0


But this just returns the original case:

Derivative[0, 1][\[Chi]][r[], \[Theta][]]^2*Derivative[0, 2][\[Chi]][r[], \[Theta][]]*
Derivative[1, 0][\[Chi]][r[], \[Theta][]]^2


Any advice as to what I'm missing?

• I think that powers cannot get automatically matched. For example a b^2 /. a b -> c does not work. But you can explicitly include powers and make them optional: ... /. HoldPattern[Derivative[__][_][__]*Derivative[__][_][__]^_.*Derivative[__][_][__]^_.] -> 0. HoldPattern is used to prevent the evaluation of unnamed patterns. Oct 7 '21 at 0:17
• @Domen, yes this works thank you! If you want to make it an answer I'll obviously accept it or if the question seems to trivial I can also delete it. :) Oct 7 '21 at 0:21
• I suggest that you wait for the others – there might be a better solution for your problem! Also, you should check whether this pattern truly works for all your cases :-) Oct 7 '21 at 0:26