# Define custom operator and specific application

I want to define a specific operator that will act in generic functions that depend, say, in the variable z. My problem is that I want when a specific function is given as an input, to have specific outcome. For example, I would like to overload CircleTimes such that CircleTimes[f[z],g[z] will do nothing but if CircleTimes[f[z],DiracDelta[1-z]] the output to be f and similarly for CircleTimes[DiracDelta[1-z],f[z]]. This should hold for any f[z].

• Is CircleTimes[] commutative? Is the behavior of CircleTimes[DiracDelta[1 - z], f[z]] unique to DiracDelta[1 - z], or should similar behavior be expected for e.g. DiracDelta[z - 3]? – J. M.'s discontentment Mar 7 '19 at 9:34
• Well if its not a huge trouble (or huge implementation) it would be neat to have it generic but for my needs, DiracDelta[1-z] is enough. And yes it is commutative. – hal Mar 7 '19 at 9:36

Use TagSetDelayed (i.e. /: and :=) to associate a "special rule" to f only when it appears within CircleTimes with DiracDelta:

ClearAll[f]
f /: CircleTimes[f[_], DiracDelta[_]] := f
f /: CircleTimes[DiracDelta[_], f[_]] := f


You can then see the following:

CircleTimes[f[z + 1], DiracDelta[1 + x]]       (* Out: f *)
CircleTimes[DiracDelta[-z], f[whatever]]       (* Out: f *)


When a function that is not DiracDelta is involved, then no simplification is made:

CircleTimes[g[z], f[x]]                        (* Out: g[z] ⊗ f[x] *)
CircleTimes[f[z], g[z]]                        (* Out: f[z] ⊗ g[z] *)

• Thank you for your comment. Ok that looks good but this is only for function f. I would like it to be for any function f that is dependent specifically on variable, say, z. That means CircleTimes[c1 f[z],c2 DiracDelta[1-z]]=c1 c2 f.. – hal Mar 7 '19 at 14:58
• @hal OK. It would have been much more helpful if you had specified those requirements directly in the original question though, so the question doesn't become a moving target – MarcoB Mar 7 '19 at 15:02
• Thank you for your answer. I had. I stated that it should hold for any f[z]. – hal Mar 7 '19 at 15:20
• @hal Yes, you said for any f[z] which here does NOT mean "any function of $z$", but any function of the form f[z]. We deal with code, not math. Also, note that in your example CircleTimes[c1 f[z],c2 DiracDelta[1-z]]=c1 c2 f you are not specifying what c1 or c2 should be. Are those numbers? Reals? Perhaps the easiest way is for you to give a few examples of expressions you expect to encounter, carefully definining what each variable means, together with the output you expect. Add those to your question to get better answers. – MarcoB Mar 7 '19 at 15:25