NFourierTrigSeries and NFourierCoefficient
- To: mathgroup at smc.vnet.net
- Subject: [mg114356] NFourierTrigSeries and NFourierCoefficient
- From: zosi <zosi at to.infn.it>
- Date: Thu, 2 Dec 2010 05:38:06 -0500 (EST)
Dear All, My problem is about NFourierTrigSeries and NFourierCoefficient with V7 or V8. (everything OK with V6, with adequate FourierParameters). Suppose I have a very simple function, first defined in (-1,4) in two ways: Case A), with /; and Case B) with Piecewise and then extended periodically. Case A) (* it does work *) tmin = -1; tmax = 4; (* the interval is asymmetric around origin *) period = tmax - tmin; g[t_] := (t - 1)^2 /; tmin <= t <= tmax g[t_] := g[t - period] /; t > tmax g[t_] := g[t + period] /; t < tmin Plot[g[t], {t, tmin, 2 tmax + 1}] Needs["FourierSeries`"] b = Solve[(2 \[Pi] )/bb == period, bb][[1, 1, 2]] a = 1; sergNTrig = NFourierTrigSeries[g[t], t, 7, FourierParameters -> {a,b}] // Simplify Plot[{g[t], sergNTrig}, {t, tmin, 2 tmax + 1}] (* good reconstruction *) Case B) (* it fails *) (* I just use Piecewise instead of :; *) tmin = -1; tmax = 4; period = tmax - tmin; h[t_] := Piecewise[{{(t - 1)^2, tmin <= t <= tmax}}] h[t_] := h[t - period] /; t > tmax h[t_] := h[t + period] /; t < tmin Needs["FourierSeries`"] b = Solve[(2 \[Pi] )/bb == period, bb][[1, 1, 2]] a = 1; serhNTrig = NFourierTrigSeries[h[t], t, 7, FourierParameters -> {a, b}] // Simplify Plot[{h[t], serhNTrig}, {t, tmin, 2 tmax + 1}] (* reconstruction fails *) *) Finally, **in both cases** I am not able to find the right parameters (i.e., coefmul and {a,b}) in, e.g., direct$coeff = Table[coefmul*NFourierCoefficient[h[t], t, n, FourierParameters -> {a,b}], {n, 0, 7}] to obtain directly the Fourier coefficients. Where am I wrong ? Many thanks for your help. Gianfranco Zosi Dip Fisica Generale University of Turin