I want to write a function using sigma notation that could represent an arbitrary number of terms of, for example, $1+2+4+5+7+8+10+11+13\ldots$, skipping every third term. I think one would need functions like floor and mod, but I'm not certain.
6 Answers
You want this
$$\sum_{k=1}^nk-\sum_{k=1}^{\lfloor n/3\rfloor}3k=\frac12\Big((n+1)n-3(\lfloor n/3\rfloor+1)\lfloor n/3\rfloor\Big)$$
- 30,417
To get a periodic pattern like "multiply by 1, multiply by 1, multiply by 0", we can exploit a periodic function like cosine: $$\sum_{k=1}^nk*\frac{2-2\cos(2\pi k/3)}3$$ This is the sum up to $n$ where every third term is zero. The number of nonzero terms is $\lfloor2(n+1)/3\rfloor$ where I'm using the floor function.
For other discussion of tricks/notation for periodic sequences, see this answer.
- 23,925
Ok I misinterpreted your question originally. For one, you can just define a function $f\colon \Bbb N \to \Bbb R$ where $f(1)=1$, $f(2)=2$, and $f(n)=f(n-2)+3$.
$f(3)=f(1)+3=4$
$f(4)=f(2)+3=5$
$f(6)=f(3)+3=7.$
This is a well defined function, although you may be looking for something that doesn't use induction so you can program it into a computer.
- 19,216
If $n=3K+p $ with $0\le p <3$,
it is
$$\sum_{i=1}^ni -3\sum_{i=1}^K i $$
$$=\frac {n (n+1)}{2}-3\frac{K (K+1)}{2} $$
$$=\frac {1}{2}\Bigl ( n^2-3K^2+p\Bigr) $$
- 62,951
Notice that splitting the series into two groups gives $(1+2) + (4+5) + (7+8)\cdots$, which is also $3 + 9 + 15\cdots$ or $3(1 + 3 + 5\cdots)$.
Since the sum of consecutive odd numbers is $k^2$, when the series ends on an even number of terms the sum is $3 (n/2)^2$. For an odd number of terms you can modify the sum by subtracting the last term, so the sum can be represented as $(3(n/2)^2) - n-1$.
In this sequence, $n$ is the number of terms rounded up to an even number, and $n$ has to be an integer > $1$.
- 16,827
-
Ha, I like that :P Unfortunately I think the OP wants a more general solution. – Chris Jun 10 '17 at 02:30
-
Sorry about the notation - I wasn't sure how to express my number and ended up using sigma which was not needed at all. – Toby Mak Jun 10 '17 at 02:31
-
@Chris, still worth an upvote as it's by far the most elegant solution. – Wildcard Jun 10 '17 at 03:12
-
The $r$-th roots of unity $\exp\left(\frac{2\pi ij}{r}\right), 0\leq j<r$ have the nice property to filter elements. For $r>0$ we obtain \begin{align*} \frac{1}{r}\sum_{j=0}^{r-1}\exp\left(\frac{2\pi ij n}{r}\right)= \begin{cases} 1&\qquad r\mid n\\ 0& \qquad otherwise \end{cases} \end{align*}
In case $r=3$ we obtain the sequence \begin{align*} \left(\frac{1}{3}\sum_{j=0}^2\exp\left(\frac{2\pi ijn}{3}\right)\right)_{n=0}^{\infty} =(1,0,0,1,0,0,1,0,0,1,0,0,1,\ldots) \end{align*} which generates a $1$ at each $3$-rd position and $0$ otherwise.
If we need the positions of $1$ shifted by $k$ positions to the right, we subtract $k$ from the index $j$. With $k=2$ we get \begin{align*} \left(\frac{1}{3}\sum_{j=0}^2\exp\left(\frac{2\pi i(j-2)n}{3}\right)\right)_{n=0}^{\infty} =(0,0,1,0,0,1,0,0,1,0,0,1,0,\ldots) \end{align*}
and reverting the sequence by subtracting the elements from $1$ we finally get \begin{align*} \left(1-\frac{1}{3}\sum_{j=0}^2\exp\left(\frac{2\pi i(j-2)n}{3}\right)\right)_{n=0}^{\infty} =(1,1,\color{blue}{0},1,1,\color{blue}{0},1,1,\color{blue}{0},1,1,\color{blue}{0},1,\ldots) \end{align*}
Multiplying this sequence elementwise with $(a_n)_{n=0}^\infty$ and summing up the values gives the wanted series with each third element skipped.
Hint: Some instructive examples can be found in H.S. Wilf's book generatingfunctionology, (2.4.5) to (2.4.9).
- 108,315
provided that $3|n$. (If not, you will need to make slight modifications.)
– Chris Jun 10 '17 at 02:22