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]
.
$\begingroup$
$\endgroup$
2
1 Answer
$\begingroup$
$\endgroup$
4
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] *)
-
$\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 functionf
that is dependent specifically on variable, say,z
. That meansCircleTimes[c1 f[z],c2 DiracDelta[1-z]]=c1 c2 f[1]
.. $\endgroup$– halCommented Mar 7, 2019 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$– MarcoBCommented Mar 7, 2019 at 15:02
-
$\begingroup$ Thank you for your answer. I had. I stated that it should hold for any
f[z]
. $\endgroup$– halCommented Mar 7, 2019 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 formf[z]
. We deal with code, not math. Also, note that in your exampleCircleTimes[c1 f[z],c2 DiracDelta[1-z]]=c1 c2 f[1]
you are not specifying whatc1
orc2
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$– MarcoBCommented Mar 7, 2019 at 15:25
CircleTimes[]
commutative? Is the behavior ofCircleTimes[DiracDelta[1 - z], f[z]]
unique toDiracDelta[1 - z]
, or should similar behavior be expected for e.g.DiracDelta[z - 3]
? $\endgroup$DiracDelta[1-z]
is enough. And yes it is commutative. $\endgroup$