0
$\begingroup$

I am a beginner with Mathematica, so I apologise in advance if this question might sound trivial for most people. I am interested in evaluating a sum of the form

$$\underset{j \, \equiv \, n \pmod2}{\sum_{j=0}^{k/2}\sum_{n=-j}^{j}}f(n)g(j)$$

with $k\in\mathbb{Z}$ and $j\in\frac{1}{2}\mathbb{Z}$, subject to the restriction $j\equiv n \pmod2$. Also the step in the sum is $1/2$.

My question is how do I perform a sum with a restriction like this in Mathematica?

$\endgroup$
7
  • $\begingroup$ I tried for example Sum[1,{n,Mod[-j,2],Mod[j,2],1/2}] but I realized that the step $1/2$ is added to the the result of Mod[...] and not to $j$. Well as I said I am just a beginner with Mathematica. $\endgroup$ – Dimitris May 8 '17 at 12:24
  • $\begingroup$ Is the step in both sums 1/2? $\endgroup$ – MikeY May 8 '17 at 12:56
  • $\begingroup$ Not sure the equation makes sense. j restricted to n(mod 2) means j takes values {0,1/2,1,3/2}, but what if k = 1,000,000? $\endgroup$ – MikeY May 8 '17 at 12:57
  • $\begingroup$ @MikeY Yes the step is 1/2 in both sums. Say k=1 then $$\underset{j \, \equiv \, n \pmod2}{\sum_{j=0}^{1/2}\sum_{n=-1/2}^{1/2}}f(n)g(j)$$ This will give $$f(0)g(0)+\underset{1/2 \, \equiv \, n \pmod2}{\sum_{n=-1/2}^{1/2}}f(n)g(1/2)=f(0)g(0)+f(1/2)g(1/2)$$ $\endgroup$ – Dimitris May 8 '17 at 16:06
  • $\begingroup$ What if k=6? How does that summation work? $\endgroup$ – MikeY May 8 '17 at 16:35
0
$\begingroup$

I'd write

Sum[If[Mod[j, 2] == Mod[n, 2], f[n] g[j], 0], {j, 0, k/2, 1/2}, {n, -j, j, 1/2}]

Let k=3;

f[0] g[0] + f[1/2] g[1/2] + f[-1] g[1] + f[1] g[1] + f[-(1/2)] g[3/2] + f[3/2] g[3/2]
$\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.