This is what I'd like to plot:

Plot[{(5/8) + 
   Sum[((2*Cos[((n*Pi)/2) ] - (n*Pi*Sin[(n*Pi)/2]) - 
         1)/((n^2)*(Pi^2)))*(Cos[(n*Pi*x)])]}, {n, 1, 20}, {x, 0, 1}]

but for some reason I'm getting an error message that says

Plot::nonopt: Options expected (instead of {x,0,1}) beyond position 2 in Plot[{5/8+Sum[((Times[<<2>>]+Times[<<2>>]-1) Cos[n [Pi] x])/Times[<<2>>]]},{n,1,20},{x,0,1}]. An option must be a rule or a list of rules. >>

Could someone please help me with this? Thanks.


closed as off-topic by march, Artes, MarcoB, m_goldberg, Sjoerd C. de Vries Sep 17 '15 at 5:22

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – march, Artes, MarcoB, m_goldberg, Sjoerd C. de Vries
If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ Basically, you're not matching up parentheses, square brackets, and curly braces correctly. Look through your code carefully. In addition---and this may just be a copy-and-paste problem, but you need to separate your variables with either spaces or *'s if you are multiplying quantities, e.g. nPiSin needs to be n*Pi*Sin. If you fix these problems, your function will plot. $\endgroup$ – march Sep 17 '15 at 1:18
  • $\begingroup$ Thank you, just got it. How would I add nmax= 20 and 80 on the same graph? So right now I have this :Plot[(5/8) + Sum[((2*Cos[((nPi)/2) ] - (nPiSin[(nPi)/2]) - 1)/((n^2)*(Pi^2)))*(Cos[(nPix)]), {n, 1, 20}], {x, 0, 1}] and it works, but it only gives me nmax=20, so how would I add nmax also equals 80? Thanks again and I apologize for the syntax. $\endgroup$ – Max Sep 17 '15 at 1:21
  • $\begingroup$ Look up the documentation for Plot; there are examples to help you there. By the way two things: (1) please use proper code formatting when posting. For help, click the grey question mark on the toolbar above your post after clicking the edit button below your post (or when you are posting). (2) people here expect a minimum level of self-help; you've made a good start by posting the code that you tried (many first-time posters don't think to do this), but you should always check the Mathematica help files first. They are very good. $\endgroup$ – march Sep 17 '15 at 1:25

If you were to write your expression with correct bracketing, which would be

Plot[5/8 + 
  Sum[((2*Cos[n*Pi/2] - n*Pi*Sin[n*Pi/2] - 1)*Cos[n*Pi*x])/(n^2*Pi^2), {n, 1, 20}], 
  {x, 0, 1}]

you would get



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