1

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

f[in[t]]=in[t]+in[t-s]

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

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

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.

Drakonomikon
  • 191
  • 7

2 Answers2

5

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

f[g_][t_]:=g[t]+g[t-s];

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.)

3

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]

george2079
  • 38,913
  • 1
  • 43
  • 110