# How do you create an alternating series with the sign being the same twice in a row?

I am working on a Taylor series question and I have created a series which alternates however, it does so in doubles. in other words it follows the following pattern: $x$, $x$, $-x$, $-x$, $x$, $x$,...

My goal is to write this series using summation notation. I know that to produce a normal alternative series I simply use $(-1)^n$. However, I've found this significantly harder to create in summation notation because any manipulation to the $(-1)^n$ part of the sum only moves the position where the alternating series starts. Any suggestions are appreciated!

edit: please note that in my example, "$x$" is just an arbitrary function and each other $x$ does not equal the other $x$'s.

• How about $(-1)^{\lfloor \frac{n}{2}\rfloor}$? Apr 16, 2016 at 20:49
• Try using a variation of $\sin$ or $\cos$. Apr 16, 2016 at 20:49
• @NobleMushtak my taylor series is in fact just the one for the function sin(x) centered at PI/4. I'm not certain how to write this in summation notation. Apr 16, 2016 at 20:52
• @almagest yes thank you, this works! Apr 16, 2016 at 20:53
• As an alternative, depending on the form of your summands it may be worthwhile to groups the sum into pairs, i.e. for $f(0)+f(1)-f(2)-f(3)+\ldots$, you could use $\sum_i(-1)^i(f(2i)+f(2i+1))$. Apr 16, 2016 at 23:11

If you are looking for a formula for the sequence $1,1,-1,-1,1,1,-1,-1,\ldots$ then try some of the suggestions at OEIS A057077, such as $$(-1)^{n(n-1)/2}$$

• Suppose I take some simple series and use these signs with them, do I get something well-known? I was thinking $$\sum_{n=1}^\infty \frac{(-1)^{n(n-1)/2}}{n}$$ i.e. the harmonic series taken with signs like this, is the sum of this series known? Apr 16, 2016 at 23:41
• Well, if we group every second term we get stuff like $\sum_{m=1}^\infty (-1)^{m-1} \left( \frac{1}{2m-1} \pm \frac{1}{2m} \right)$ which can be handled by Wolfram Alpha, so the answer is yes. Apr 17, 2016 at 0:11
• This answer is right. It's (-1) raised to the power of the sum from 1 to n. Note that for any given n, the sum from 1 to n has sign k (either + or -). The next odd number added to the sum changes the sign, the next even number keeps the sign the same: so you get two odds, then two evens, then two odds, then two evens.... Apr 17, 2016 at 3:59
• @JimZipCode nice way of looking at it :)
– Ant
Apr 17, 2016 at 9:50

It seems that you want to simulate the series $1, 1, -1, -1, 1, 1, -1, -1, ...$. These kinds of alternating series are usually easiest to do using $\sin$ or $\cos$ functions. (Although the formula $(-1)^{n(n-1)/2}$ works just as well, I think it's kind of interesting to see this series modeled with a trig function, so I'm going to do it anyway.)

Think about a $\cos$ function going through $(0, 1)$, $(1, 1)$, $(2, -1)$, $(3, -1)$, $(4, 1)$ and so on.

Where are the maximums and minimums? They're in between points with the same values, like $\frac{0+1} 2=0.5$ and $\frac{2+3} 2=2.5$.

Which is the maximum? It's the one in between the points of higher value, which is $0.5$. This represents our right shift since $\cos 0$ is the maximum.

What's the period? It's two times the difference between two consecutive extrema, or $2(2.5-0.5)=4$. The period is usually $2\pi$, so our coefficient of $x$ must be $\frac{2\pi} 4=\frac \pi 2$.

Thus, we have $\cos\left(\frac \pi 2\left(x-\frac 1 2\right)\right)$. However, this gives us $\frac{1}{\sqrt 2}$ for $x=0$, so we must multiply by $\sqrt 2$ to get the following function:

$$f(x)=\sqrt 2\cos\left(\frac \pi 2\left(x-\frac 1 2\right)\right)$$

If we put this into WolframAlpha, we clearly see that this gives us the sequence we wanted.

There is a very general way to attack the problem of writing a repeating sequence of coefficients.

The discrete Fourier transform of the sequence "$1,1,-1,-1$", of length $N=4$, is $0,1+\mathrm{i},0,1-\mathrm{i}$". This says that $$0 \mathrm{e}^{-2\pi \mathrm{i} \cdot 0 n /N} + (1+\mathrm{i}) \mathrm{e}^{-2\pi \mathrm{i} \cdot 1 n /N} + 0 \mathrm{e}^{-2\pi \mathrm{i} \cdot 2 n /N} + (1 - \mathrm{i}) \mathrm{e}^{-2\pi \mathrm{i} \cdot 3 n /N}$$ is a constant multiple of your desired sequence. ("Constant multiple" because there are constant premultipliers I have ignored to make the above more direct.) That expression, in which we may ignore the two terms starting with zero, produces a sequence starting from $n=0$: $$2, 2, -2, -2, 2, 2, -2, -2, \dots \text{.}$$ So, $$\frac{(1+\mathrm{i}) \mathrm{e}^{-2\pi \mathrm{i} \cdot 1 n /4} + (1 - \mathrm{i}) \mathrm{e}^{-2\pi \mathrm{i} \cdot 3 n /4}}{2}$$ does what you want.

Just as for $(-1)^n$, we may rewrite this using trigonometric functions. $$\left(\cos \left(\frac{\pi n}{2}\right)-\sin \left(\frac{\pi n}{2}\right)\right) (\cos (\pi n)-i \sin (\pi n))$$

Say, instead of starting at $n=0$, you want to start at $n=1$. We cyclically rotate the sequence to get the term we want at the position where $n=1$, i.e., we consider the sequence $-1,1,1,-1$. This gives transform $0,-1+\mathrm{i}, 0, -1-\mathrm{i}$. The term to use in your sum is then $$\frac{(-1+\mathrm{i}) \mathrm{e}^{-2\pi \mathrm{i} \cdot 1 n /4} + (-1 - \mathrm{i}) \mathrm{e}^{-2\pi \mathrm{i} \cdot 3 n /4}}{2} \text{,}$$ which is equivalent to $$\left(\sin \left(\frac{\pi n}{2}\right)+\cos \left(\frac{\pi n}{2}\right)\right) (-\cos (\pi n)+i \sin (\pi n)) \text{.}$$

Just for kicks:

$$f(n)=\lim_{x\to n_-}\left\lfloor{\sin \frac{\pi x}{2}}\right\rfloor$$

This can be used to generalize sequences like:

$$\underbrace{1,1,1,\cdots,1}_{k \space1's},\underbrace{-1,-1,-1,\cdots,-1}_{k \space 1's}, 1\cdots$$

Can be represented as

$$f(n)=\lim_{x\to n_-} \left\lfloor{\sin \frac{\pi x}{k}}\right\rfloor$$

I thought that this might a bit cool for the OP.

• Very creative (+1)
– user331360
Apr 17, 2016 at 1:46

$\frac{i^n+i^{-n}}2=\{1,0,-1,0,\dots\}$ has period $4$, so putting it together with itself shifted by one gives $$\{1,1,-1,-1,\dots\}=\overbrace{\frac{i^n+i^{-n}}2}^{1,0,-1,0,\dots}+\overbrace{\frac{i^{n-1}+i^{1-n}}2}^{0,1,0,-1,\dots}\tag{1}$$

Using the series $-\log(1-x)=\sum\limits_{n=1}^\infty\frac{x^n}n$, we get \begin{align} \frac11-\frac12-\frac13+\frac14+\cdots &=\sum_{n=1}^\infty\left(\frac{i^n+i^{-n}}2+\frac{i^{n-1}+i^{1-n}}2\right)\frac1n\\ &=-\frac12\log(1-i)-\frac12\log(1+i)+\frac i2\log(1-i)-\frac i2\log(1+i)\\ &=-\frac12\log(2)+\frac i2\log(-i)\\[6pt] &=\frac{\pi-\log(4)}4\tag{2} \end{align}

• would the downvoter care to comment?
– robjohn
Apr 17, 2016 at 11:34
• I didn't downvote, but it is difficult to see what everything after "Thus, using the series…" has to do with the question. Apr 17, 2016 at 18:26
• The question is answered in $(1)$. After that, I was applying this representation to the question posed in a comment by Jeppe Stig Nielsen about the usability of the representation $(-1)^{n(n-1)/2}$ in a series like $$\sum_{n=1}^\infty\frac{(-1)^{n(n-1)/2}}{n}$$ In other words, $(2)$ is attempting to demonstrate usefulness.
– robjohn
Apr 17, 2016 at 18:44

Instead of trying to represent the sign sequence directly, you can also approach this problem by grouping you summands into pairs. So for a sum of the form

$f(0)+f(1)-f(2)-f(3)+f(4)+\dots$,

you would write

$\sum_i(-1)^i(f(2i)+f(2i+1))$.

Here's a more "blunt force" way of doing this. Given a sequence like

$$1 + \frac12 - \frac13 -\frac14 + \frac15 + \frac16 - \frac17 - \frac18 + \cdots,$$

then you could notate it as follows:

$$\sum_{n=1}^\infty \frac{s(n)}{n},$$ where $$s(n) = \begin{cases} 1 & \text{if } n \mod 4 = 1 \operatorname{or} 2, \\ -1 & \text{if } n \mod 4 = 3 \operatorname{or} 0\end{cases}$$