Let's assume I have a various functions for signal amplitudes, e.g. pulse[t_] = Sech[t]^2
and pulse2[t_]L = Exp[-2t^2]
.
What I'd like to have is a general function the computes different forms of autocorrelation-like responses, let's take the autocorrelation as example. The result should be a function of time. So the autocorrelation should take a function as argument and return a function: ac[pulse2] = 1/2 E^-#^2 Sqrt[\[Pi]]
An easy solution but something I don't want is:
ac1[fct_] := ac1[fct] = Convolve[fct[\[Tau]], fct[\[Tau]], \[Tau], t]
resp.
ac2[fct_] := ac2[fct] = Integrate[fct[\[Tau]]*fct[\[Tau] - t], {\[Tau], -Infinity, Infinity}, Assumptions -> {Element[{t}, Reals]}]
The problem is that it returns an expression dependent on t and not a function.
My approach was something like
ac3[fct_] := ac3[fct] = Convolve[fct[\[Tau]], fct[\[Tau]], \[Tau], t] /. {t -> #} &
(ac4
accordingly with ac2
) but this won't evaluate the autocorrelation yet: ac3[pulse2]=Convolve[pulse2[\[Tau]], pulse2[\[Tau]], \[Tau], t] /. {t -> #1} &
So how can I make Mathematica evaluate the whole autocorrelation first (using t
) and then replace t
with #
to get a function? I use version 11.1