I'm looking for a definition of a functional f which works correctly with varying arguments t while it will be nested.

For example, I've the following code

f[g__[t__]] := g[t] + g[t - s]

For an input function in[t] I'll get


So far so good. But I want to nest the functional like f[f[in[t]] and I'm expecting


as result. But what I get with the above definition is -s + 2 in[t] + 2 in[-s + t]. My application is a cascaded FIR digital filter. The output of the first FIR is the input of the next one and so on.


2 Answers 2


maybe do something like this:

f[ fn_Function ] := (fn[#] + fn[# - s]) &

f[in[#] &][t]

in[t] + in[-s + t]

f[f[in[#] &]][t]

in[t] + in[-2 s + t] + 2 in[-s + t]


The problem is that your function $f$ does not act on the number $g(t)$, it acts on the function $g$. I don't have Mathematica at hand, but


should work. (Note that you will need to adjust your examples as

f[in][t] (*gives in[t]+in[t-s]*)
f[f[in]][t] (*gives in[t]+2in[t-s]+in[t-2s]*)

to make them work with this definition.)

  • $\begingroup$ There is a little mistake in your definition. You have swapped the argument t-s. But your solution works fine. $\endgroup$ Commented Jun 28, 2017 at 21:58
  • $\begingroup$ @Drakonomikon Fixed, thanks! $\endgroup$ Commented Jun 29, 2017 at 18:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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