0
$\begingroup$

How can I plot: $$\sum_{n=1}^{400}\frac1{n^3\sin^2(n)}$$ without using the Table function? I am looking for a plot similar to the discrete plot in Mathematica. I am new to this software, I was able to complete the job with Maple and MATLAB but can't figure out how to do so in Mathematica. Thank you for any help!

$\textbf{MAPLE CODE:}$

L:=ListTools:-PartialSums([seq(1/((n^3)*(sin(n)^2)),n=1..400)]):
plots:-listplot(L,style=point);

$\textbf{MAPLE OUTPUT:}$

enter image description here

$\textbf{MATLAB OUTPUT:}$

enter image description here

$\endgroup$
  • 2
    $\begingroup$ What do you mean by "plot the partial sum"? That sum is just a number, so what are you actually plotting? If you mean plot the sequence, then do look up DiscretePlot. $\endgroup$ – march Mar 23 '17 at 3:53
  • $\begingroup$ I mean by ploting the values of the given sum up to 400... $\endgroup$ – DMH16 Mar 23 '17 at 3:55
  • $\begingroup$ Can you share your try in Maple? $\endgroup$ – zhk Mar 23 '17 at 3:56
  • $\begingroup$ @MapleSE-Area51Proposal I forgot the paranthesis, now it should work $\endgroup$ – DMH16 Mar 23 '17 at 4:09
  • $\begingroup$ Would ListPlot[Accumulate[Function[n, 1/(n^3 Sin[n]^2)] @ Range[400]], Filling -> Axis] work for you? $\endgroup$ – J. M. will be back soon Mar 23 '17 at 4:11
1
$\begingroup$

Another way to do it, is to use Array.

f[N1_] = Sum[1/(n^3*Sin[n]^2), {n, 1, N1}]
Array[f, {400}];
ListPlot[%, PlotRange -> All, Filling -> Axis]

enter image description here

Edit

The approach suggested by @J.M. in the comment is more efficient than this one.

ListPlot[Array[f, {400}], PlotRange -> All, Filling -> Axis] // AbsoluteTiming

1.03085

ListPlot[Accumulate[Function[n, 1/(n^3 Sin[n]^2)]@Range[400]], Filling -> Axis, 
PlotRange -> All] // AbsoluteTiming

0.424839

$\endgroup$
  • $\begingroup$ The plot is not very clear, I will add the picture of the plots I am looking for (the ones i got with matlab and maple) $\endgroup$ – DMH16 Mar 23 '17 at 4:05
  • $\begingroup$ @DMH16 See the edit $\endgroup$ – zhk Mar 23 '17 at 4:30
  • 1
    $\begingroup$ You only need to add Filling -> Axis. This is a bit wasteful, tho, since terms are computed repeatedly in Sum[]. $\endgroup$ – J. M. will be back soon Mar 23 '17 at 4:31
3
$\begingroup$
partialSums = Accumulate[1/(#^3 Sin[#]^2) & /@ Range[400]];

Using ListLinePlot

ListLinePlot[partialSums, PlotRange -> All, Filling -> 0]

enter image description here

Using ListLogPlot

ListLogPlot[partialSums, Joined -> True, Filling -> Axis]

enter image description here

$\endgroup$
1
$\begingroup$

DiscretePlot as mentioned by march:

f[N1_] = Sum[1/(n^3*Sin[n]^2), {n, 1, N1}];

DiscretePlot[f[x], {x, 0, 400}, PlotRange -> All]

enter image description here

$\endgroup$

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.