3

I recently installed Mathematica and I wanted to define a functional in it. This is what I did:

autocorrelate[f_[t], τ_, T_] := Integrate[ f[t]*f[t+τ], {t, 0 , T}]/T

This was processed without a hitch.

I tried using it as on a sine function:

autocorrelate[Sin[t], τ, 2Pi]

and it gave me the output of

Cos[τ]/2

Which is right.

Then I defined a function:

a[t_]:= E^t

and when I used the command:

autocorrelate[a[t],τ, 10]

I get the output as autocorrelate[E^t, τ, 10]. Can you please tell me where I'm going wrong?

LCarvalho
  • 9,233
  • 4
  • 40
  • 96
Sunil S.
  • 135
  • 7

1 Answers1

2

If you don't want to use SetAttributes then you can do

  autocorrelate[f_, t_, \[Tau]_, T_] := 
  Integrate[f[t]*f[t + \[Tau]], {t, 0, T}]/T

Then with a[t_] := E^t you get

 autocorrelate[a, t, \[Tau], 10]
(*1/20 E^\[Tau] (-1 + E^20)*)

For the Sin function we have

 autocorrelate[Sin, t, \[Tau], 2 Pi]
 (*Cos[\[Tau]]/2*)
Hubble07
  • 3,614
  • 13
  • 23