0
$\begingroup$

I've tried to plot the below density plot. But since there is a summation inside the plot and the term inside the summation goes to zero differently for different values of $a$ and $t$, I need to tell the summation that continues till the value of the term inside the summation becomes smaller than a certain value say $0.01$. How can I do that?

     DensityPlot[
         Sum[(a^(1 + 2 mz) Sin[(3 + 2 mz) t]), {mz, 0, 100}], {a, 0.1, 0.2}, {t, 0, Pi/2}]
$\endgroup$
  • $\begingroup$ In the Sum, the summation variable m does not appear in the Sum. Is the variable supposed to be mz or should mz actually be m*z? Since you are plotting, what values are you using for the undefined parameters (e.g., p1)? $\endgroup$ – Bob Hanlon Dec 2 at 22:29
  • $\begingroup$ Thanks. I've edited the code @BobHanlon $\endgroup$ – Marco Dec 2 at 22:39
  • $\begingroup$ Nest and FixedPoint might be worth mentioning. $\endgroup$ – Carl Lange Dec 2 at 23:41
  • $\begingroup$ How should I use them? @CarlLange $\endgroup$ – Marco Dec 3 at 8:10
1
$\begingroup$

A procedural method is just to make a function of a while loop.

whilesum[a_, t_] := Block[
  {mz = 0., 
   term = (-16 a^(2 + 4 mz) - 8 (-1)^mz a^(1 + 2 mz) (Sin[(3 + 2 mz) t] - Sin[t - 2 mz t]))/((-1 + a^(2 + 4 mz)) (1 + 2 mz) \[Pi]), 
   total = 0.},
  While[
   term >= 0.01,
   total += total + term;
   mz++
  ];
  total
]

DensityPlot[
 whilesum[a, t],
 {a, 0.1, 0.2},
 {t, 0, Pi/2}
 ]

enter image description here

$\endgroup$
  • $\begingroup$ When I run your code, I just get a blue totally blue plot with some white regions! $\endgroup$ – Marco Dec 2 at 23:10
  • $\begingroup$ @Marco Woops, thanks for the catch! I changed expr to term at the last minute and missed one. $\endgroup$ – That Gravity Guy Dec 2 at 23:15
  • $\begingroup$ Thanks, Could you please modify the term? I edited the term in the question so that the question seems more general. $\endgroup$ – Marco Dec 2 at 23:26

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.