1
$\begingroup$

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[1] and similarly for CircleTimes[DiracDelta[1-z],f[z]]. This should hold for any f[z].

$\endgroup$
  • $\begingroup$ 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]? $\endgroup$ – J. M. will be back soon Mar 7 at 9:34
  • $\begingroup$ 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. $\endgroup$ – hal Mar 7 at 9:36
1
$\begingroup$

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[1]
f /: CircleTimes[DiracDelta[_], f[_]] := f[1]

You can then see the following:

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

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] *)
$\endgroup$
  • $\begingroup$ 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[1].. $\endgroup$ – hal Mar 7 at 14:58
  • $\begingroup$ @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 $\endgroup$ – MarcoB Mar 7 at 15:02
  • $\begingroup$ Thank you for your answer. I had. I stated that it should hold for any f[z]. $\endgroup$ – hal Mar 7 at 15:20
  • $\begingroup$ @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[1] 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. $\endgroup$ – MarcoB Mar 7 at 15:25

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.