Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question already has an answer here:

How would I plot the following in Mathematica?

$ \displaystyle\sum_{n=2}^{10} \bigg(\dfrac {4ine^{inx}(-1)^n}{(n^2 - 1)^2} - \dfrac{4in e^{-inx}(-1)^n}{(n^2 - 1)^2} \bigg) $


share|improve this question

migrated from Dec 31 '13 at 23:42

This question came from our site for people studying math at any level and professionals in related fields.

marked as duplicate by bobthechemist, R. M. Jan 1 '14 at 3:27

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

Please make the title more informative and tell us what you have tried. – Lost1 Dec 31 '13 at 23:42
If the answer to the similar question you more recently asked doesn't apply here, please clarify. – bobthechemist Jan 1 '14 at 1:51

Here is a plot from $x=-1$ to $x=1$.

Plot[Sum[4 I n Exp[I n x] (-1)^n/(n^2 - 1)^2 - 
4 I n Exp[-I n x] (-1)^n/(n^2 - 1)^2, {n, 2, 10}], {x, -1, 1}]

enter image description here

The Syntax is just

Plot[ formula you want to plot, {x, lowest x, highest x}]

For the sums, the setup is

Sum[sequence to sum, {n,first n, last n}]

Put the two together and you get what I created to plot the sum you've mentioned.

NOTE. More importantly, this plot should look VERY familiar to you. Which means you should be able to do a bit of algebra to the sum you presented and obtain a fairly simple function with which you are familiar!

share|improve this answer

You can define the function as a series -- and Mathematica excels at simplifying and putting these into nice form. For your function, you can write:

f[x_] := FullSimplify[Sum[4 I n Exp[I n x] (-1)^n/(n^2 - 1)^2 - 
                          4 I n Exp[-I n x] (-1)^n/(n^2 - 1)^2, {n, 2, 10}]]

Now you can evaluate

-(16/9) Sin[2 x] + 3/8 Sin[3 x] - 32/225 Sin[4 x] + 5/72 Sin[5 x] - (48 Sin[6 x])/1225 
    + 7/288 Sin[7 x] - (64 Sin[8 x])/3969 +  9/800 Sin[9 x] - (80 Sin[10 x])/9801

and see that the series is a weighted sum of sinusoids. Plotting this is easy:


gives a plot identical to that of mathematics2x2life.

share|improve this answer

Adam - you are plotting the wrong function.

c1[n_] := 1/2/Pi Integrate[x^2 Sin[x] Exp[-I n x], {x, -Pi, Pi}];

c2[n_] = Simplify[c1[n], Assumptions -> Element[n, Integers]];

c[n_] := If[n == 1, c11, If[n == -1, c1[-1], c2[n]]];

f5[x_] = Sum[c[k] Exp[I k x], {k, -5, 5}];

Plot[{f5[x], x^2 Sin[x]}, {x, -Pi, Pi}]

Output of plot

share|improve this answer