1
$\begingroup$

I have the following code:

NSum[(-1)^(i + j + i*j)* Exp[(-t*Pi)/2*(i^2 + j^2)],{i,-Infinity, Infinity}, {j, -Infinity, Infinity}, NSumTerms -> 30, Method -> "AlternatingSigns", WorkingPrecision -> 40]

I want to evaluate this at a list of different values of t at once, say

t={1/1000,1/100,1/10,1,2,5/4,3}

How can I achieve this? It will be nice to display the results as table/matrix of two column, too; values of t and its respective evaluation.

$\endgroup$
5
  • $\begingroup$ You could define a function aymane[t_?NumericQ] := NSum[(* stuff *)]... $\endgroup$ Apr 6, 2017 at 12:34
  • $\begingroup$ Thank you, I already did that. now how I evaluate in a set of values, can you give me some hints because I am beginner user. how I achieve the table look? $\endgroup$ Apr 6, 2017 at 12:38
  • $\begingroup$ Look up Table[] and Grid[], then. $\endgroup$ Apr 6, 2017 at 12:40
  • $\begingroup$ Thank you. I come up with this Grid[{{1/1000, 1/100, 1/10, 1, 2, 5/4, 3}, Table[aymane[i], {i, {1/1000, 1/100, 1/10, 1, 2, 5/4, 3}}]}] But I remarked that Grid round the numerical values. $\endgroup$ Apr 6, 2017 at 13:08
  • $\begingroup$ @J.M. Can you help me with this problem, because I want all the decimals without any rounding. $\endgroup$ Apr 6, 2017 at 13:19

1 Answer 1

2
$\begingroup$

For a start:

Clear@sum
sum[t_?NumericQ] := {t, 
  NSum[(-1)^(i + j + i*j)*Exp[(-t*Pi)/2*(i^2 + j^2)], {i, -Infinity, 
    Infinity}, {j, -Infinity, Infinity}, NSumTerms -> 30, 
   Method -> "AlternatingSigns", WorkingPrecision -> 40]}

out = sum /@ {1/1000, 1/100, 1/10, 1, 2, 5/4, 3};

Grid[{{"t", "sum"}}~Join~Chop[out], Frame -> All, Alignment -> "."]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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