I want to define a function s[t, n] that returns the value at point t of the FourierTrigSeries of n terms of a given function f(t). For instance, for f(t) = t^2:
s[t_, n_] = FourierTrigSeries[t^2, t, n]; (* 2nd input = indep. variable *)
s[t, 3]
Out = Pi^2 / 3 + 4 (-Cos[t] + 1/4 Cos[2 t] - 1/9 Cos[3 t])
which is fine (a function of t). To evaluate it at t = 0:
s[t, 3] /. t -> 0
Out = -31 / 9 + Pi^2 / 3
This is what I would like to see as the output of s[0, 3], meaning "evaluate at t=0 the FourierTrigSeries of 3 terms".
However doing s[0,3] makes t = 0 "too early", so the original function f(t)=t^2 becomes identically 0; even the independent variable t (second input to FourierTrigSeries) becomes 0 too, which makes no sense. The result is that Mathematica cannot read my mind and returns as follows:
s[0, 3]
Out = FourierTrigSeries[0,0,3]
Summarizing: I would like to define the function s[t, n] such that n is substituted for its value first and, only after that, t is substituted by its value for evaluation.
I have tried doing s[n, t] instead of s[t, n]; also tried := (delayed evaluation) instead of = in different ways, and in combination with things like
ss[tdelay_, n_] = s[t, n] /. t -> tdelay
But nothing seems to work. How can I get the behavior I want?
Thank you in advance!