I would like to plot the Fourier sine series for $f(x) = x$.

I would like to manipulate the parameter n from $0$ to $10$ and plot the sine waves over $(0,1)$. My code below does not work; what is wrong?

Manipulate[Plot[FourierSinSeries[x, x, n], {x, 0, 1}], {n, 0, 10}]
  • 1
    $\begingroup$ Tried adding Evaluated -> True to Plot[]? $\endgroup$
    – J. M.'s torpor
    May 6 '13 at 4:29
  • $\begingroup$ Also, for this function, n cannot be zero, so you'll need to change {n,0,10} to {n,1,10}. If you only intended to plot for integer n, then it's {n,1,10,1} $\endgroup$
    – bill s
    May 6 '13 at 5:07

As per the comment:

Manipulate[Plot[Evaluate[FourierSinSeries[x, x, n]], {x, 0, 10}], {n, 1, 10}]

What is happening here is that Plot has the attribute HoldAll so that the FourierSinSeries function has not been evaluated (at the points n) when the plot occurs. There are some examples of this in the documentation for Plot: for instance look at the Neat Example and try removing the Evaluated command -- the plot will disappear.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.