Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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}]
share|improve this question
1  
Tried adding Evaluated -> True to Plot[]? –  J. M. May 6 '13 at 4:29
    
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} –  bill s May 6 '13 at 5:07
add comment

1 Answer

up vote 3 down vote accepted

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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