I have a question about notation: What's the proper mathematical notation to write (sum from i=1 to X)(sum from j=1 to X) 1 if gcd(i,j)==2, 0 otherwise?
5 Answers
For that Knuth uses Iverson's convention: $[\gcd(i, j) = 2]$ is 1 if the condition is true, 0 if false.
- 27,812
-
-
Yes, BUT if you are going to use this notation I would advise letting everybody know as not everyone will understand otherwise. – Gerry Myerson Mar 08 '13 at 00:57
There is the Kronecker delta $\delta_{i,j}=0$ if $i\neq j$ 1 otherwise.
For you $\sum_{i=1}^X \sum_{j=1}^X \delta_{\gcd(i,j),2}$.
I hope it helps.
- 2,732
I might just write $$ \sum_{\begin{smallmatrix} 1\le i\le X \\ 1\le j\le X \\ \gcd(i,j)=2 \end{smallmatrix}} 1. $$
If you need to write it as an iterated sum, you could write $$ \sum_{1\le i\le X} \sum_{\begin{smallmatrix} 1\le j \le X \\ \gcd(i,j)=2 \end{smallmatrix}} 1. $$
But it won't do to write $$ \sum_{\begin{smallmatrix} 1\le i \le X \\ \gcd(i,j)=2 \end{smallmatrix}} \sum_{1\le j \le X } 1 $$ because there's not yet anything called $j$. For example, suppose one has $$ \sum_{i=1}^4 \sum_{j=1}^3 (i^2+j). $$ This is $$ \underbrace{\Big((1^2+1)+(1^2+2)+(1^2+3)\Big)}_{i=1} + \underbrace{\Big((2^2+1)+(2^2+2)+(2^2+3)\Big)}_{i=2} + \underbrace{\Big((3^2+1)+(3^2+2)+(3^2+3)\Big)}_{i=3} $$
Within the term in which $i=2$, we find one term in which $j=2$ and two other terms. But we cannot include or exclude in its entirety the term labeled with the $\underbrace{\text{underbrace}}$ as $i=2$ on the grounds of its relationship with some other variable called $j$.
$$\sum_{1\le i\le X,\gcd(i,j)=2}\sum_{1\le j\le X}1$$ will do. Also, you could look up the Iverson bracket notation.
EDIT: Sorry, make that $$\sum_{1\le i\le X}\sum_{1\le j\le X,\gcd(i,j)=2}1$$ (Thanks, Michael)
- 179,216
-
I don't see how this can work. You're writing $\displaystyle\sum_{1\le i\le X,\ \gcd(i,j)=1}\left(\sum_{1\le j\le X}\cdots\cdots\cdots\right)$. You're referring to the index $j$ in the outside summation, although $j$ is a variable bound by the inside summation. – Michael Hardy Mar 08 '13 at 00:52
You could do something like this, for instance: $$ f(X)=\sum_{1\leq i,j\leq X, (i,j)=2}^X1=1+2\sum_{1\leq i<j\leq X, (i,j)=2}^X1 $$ $$ =1+2\sum_{2\leq 2i<2j\leq X, (i,j)=1}^X1 $$ $$ =1+2\sum_{j=1}^{\lfloor X/2\rfloor}\sum_{1\leq i<j, (i,j)=1}1 $$ $$ =1+2\sum_{j=2}^{\lfloor X/2\rfloor}\phi(j) $$ where $\phi(j)$ is Euler's totient function which counts the number of $i$ between $1$ and $j$ such that $(i,j)=1$.
This way you can get an asymptotic estimate: $$ f(X)=\frac{3X^2}{4\pi^2}+O(X\log X). $$
- 44,791
-
@user64283 In case it is of any use, I developed the formula a little bit to express it with Euler's totient function and obtain an asymptotic estimate. – Julien Mar 08 '13 at 01:10