Possible Duplicate:
How to Plot an Infinite Series
Coding mistake?
I have Mathematica v9.0 and I am a newbie to Mathematica. I am trying to plot a function $f(x)=x$ over the interval $(-\pi,\pi)$. Together on the same plot, I want two partial sums, $S_{4}$ and $S_{8}$.
I have tried to plot $S_{4}$ and $f(x)$, but can't seem to get it right. Can anyone show me how to do it? Here is my code:
f[x_] = x
s[n_, x_] := Sum[((-1)^(n + 1)) (2/n) (Sin[nx]), {n, 1, Infinity}]
partialsums = Table[s[n, x], {n, 1, 4}];
Plot[Evaluate[f[x], partialsums], {x, -3, 3}]
Is there anything wrong with my code? Hope someone can shed light on this.
f[x_] := x s[k_, x_] := Sum[((-1)^(n + 1)) (2/n) (Sin[n x]), {n, 1, k}] partialsums = Table[s[n, x], {n, {4, 8, 12}}]; Plot[Evaluate[{f[x], partialsums}], {x, -3, 3}]! You are making some syntax errors. By the way think if you sum up to infinity can it be called a partial sum? – PlatoManiac Jan 07 '13 at 17:45