1
$\begingroup$

I'm trying to find a way to plot the sum of a series from n to nmax.

Here is the code for the series:

ClearAll[a, b, Gx, Gy, n, bD, nmax, simp]
simp[n_] = 
  Simplify[1/(3 Sqrt[Gx] (π + 2 n π)^5)
     8 Gy (b Sqrt[
       Gx] (1 + 2 n) π (a^3 (π + 2 n π)^4 + 
         96 (-1)^n Sin[1/2 a (1 + 2 n) π]) + 
      96 (-1)^n Sqrt[
       Gy] (a (1 + 2 n) π Cos[1/2 a (1 + 2 n) π] - 
         4 Sin[1/2 a (1 + 2 n) π]) Tanh[(
        b Sqrt[Gx] (1 + 2 n) π)/(2 Sqrt[Gy])])];
bD[nmax_] := Sum[simp[n], {n, 0, nmax}];
a = 0.005; b = a; Gy = 41018756.0; Gx = 72463203.0; nmax = 200;

I tried Plot[Evaluate[Table[bD[nmax], {n, 5}]], {n, 0, 5}], but it produces a straight line. It seems like most times when others had similar problems, like here and here, they had two constants to work with. I only have n so I'm not sure how to proceed.

When I check the contents of [Table[bD[nmax], {n, 5}]], I find that it has {0.26291, 0.26291, 0.26291, 0.26291, 0.26291}, so I'm guessing that for some reason that I can't see, Mathematica is doing the full sum for every entry in the table.

Edit

I managed to get a plot using ListPlot[Table[Sum[simp[n], {n}], {n, 0, nmax}]], but comparing the last value in the table to that from Sum[simp[n], {n, 0, nmax}] shows that they are different. Using the table seems to give a different result to just using a sum.

$\endgroup$
0
$\begingroup$

Let's redefine the terms of your sum so that they evaluated fairly quickly.

With[{a = 0.005, b = 0.005, Gy = 41018756.0, Gx = 72463203.0}, 
  term[n_] = 
    1/(3 Sqrt[Gx] (π + 2 n π)^5) 8 Gy * 
      (b Sqrt[Gx] (1 + 2 n) π (a^3 (π + 2 n π)^4 + 
        96 (-1)^n Sin[1/2 a (1 + 2 n) π]) + 96 (-1)^n Sqrt[Gy] * 
          (a (1 + 2 n) π Cos[1/2 a (1 + 2 n) π] - 4 Sin[1/2 a (1 + 2 n) π]) * 
            Tanh[(b Sqrt[Gx] (1 + 2 n) π)/(2 Sqrt[Gy])]) // N];

Now we compute a table of 15 terms.

Table[term[i], {i, 15}]
{0.0461359, 0.0816871, 0.0588642, 0.0757376, 0.0623486, 
 0.0734383, 0.0639842, 0.0722128, 0.0649383, 0.0714477, 
 0.0655664, 0.0709223, 0.066013, 0.0705375, 0.0663482}

As you can see, the terms don't vary much, so the accumulated sum will be pretty near a straight line.

sum[nmax_] := Accumulate[Table[term[i], {i, nmax}]]
ListPlot[sum[16]]

plot

I would guess that term[i] is converging to a constant as i -> ∞, and the plot is asymptotically approaching a straight line.

$\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.