1
$\begingroup$

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.

$\endgroup$
3
$\begingroup$

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]

$\endgroup$
6
$\begingroup$

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

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

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.