lately I tried to develop an interface that will plot the furier sum of a given function up to a given number of terms.
The code is here:
isEven[f_] := SameQ[f[t], f[(-t)]] a[n_, f_] := If[isEven[f], Integrate[f[y]*Cos[n y], {y, -Pi, Pi}], 0] b[n_, f_] := If[isEven[f], 0, Integrate[f[y]*Sin[n y], {y, -Pi, Pi}]] fourier[f_, m_] := Sum[a[n, f]*Cos[n x] + b[n, f]*Sin[n x], {n, 1, m}] Interpretation[ {g = x^2, min = 0, max = 2 Pi, sum = 5}, Panel[ Grid[{{Style["Furier Series", Bold], SpanFromLeft}, {"Function:", InputField[Dynamic[g]]}, {"Min:", InputField[Dynamic[min]]}, {"Max:", InputField[Dynamic[max]]}, {"Sum:", InputField[Dynamic[sum]]}}] ], Plot[Evaluate[fourier[g[x], sum]], {x, min, max}]]
The first part specifies the functions I would need, and the second part is an inteface to use the tool.
When i run the code, a keep getting these errors:
And then gives me an empty plot.
Does anyone here know what is the problem?
Thanks a lot!