<s>[INST] How to use a conditional statement in an infinite series to approach a specific limit If I were to sum the infinite series:
$$\sum_{i=1}^\infty \frac{1}{2^n} = \frac{1}{2^1}+\frac{1}{2^2}...\frac{1}{2^\infty}$$
but as soon as the previous partial sum 
$\sum_{i=1}^\infty \frac{1}{2^{n-1}}$ becomes greater than 0.9 I subtract $\frac{1}{2^n}$ instead of adding it, forcing the series to approach 0.9.
What would would be the simplest form to write that, possibly using Iverson brackets? I'm not sure how to deal with the negative value though.
$$\sum_{i=1}^\infty \frac{1}{2^n}.[\sum_{i=1}^\infty \frac{1}{2^{n-1}} < 0.9]$$
or is this valid?
$$\sum_{i=1}^\infty f(n)=\begin {cases} \frac{1}{2^n} & \sum_{i=1}^\infty \frac{1}{2^{n-1}} < 0.9\\
\frac{-1}{2^n} & \sum_{i=1}^\infty \frac{1}{2^{n-1}} > 0.9 \end {cases}$$ 
or maybe:
$$\sum_{i=1}^\infty f(n)=\begin {cases} \frac{1}{2^n} & \sum_{i=1}^{n-1} \frac{1}{2^n} < 0.9\\
\frac{-1}{2^n} & \sum_{i=1}^{n-1} \frac{1}{2^n} > 0.9 \end {cases}$$ 
 [/INST] Claim:
The sign of the $k$-th term is precisely $(-1)^{\lfloor\tfrac{k+1}{2}\rfloor}$, excep for $k=1$ and $k=2$. To be precise, setting
$$f(1):=\frac12,
\qquad 
f(2):=\frac14,
\qquad\text{ and }\qquad
f(k):=\frac{(-1)^{\lfloor\tfrac{k+1}{2}\rfloor}}{2^k}
\quad
\text{ for all }k>2,$$
yields the desired sum. This means that for all $m\geq1$ the partial sum $S_m:=\sum_{k=1}^mf(k)$ satisfies
$$\begin{array}{ccc}
S_m<0.9\quad&\implies&\quad f(m+1)>0,\\
S_m>0.9\quad&\implies&\quad f(m+1)<0.\tag{1}
\end{array}$$
Proof:
This is clear for $m=1$ and $m=2$. To simplify $(1)$ note that $S_m\neq0.9$ for all $m$ because the denominator of $S_m$ is a power of $2$ whereas $0.9=\frac{3}{10}$. So $(1)$ is equivalent to
$$S_m<0.9\qquad\iff\qquad f(m+1)>0.$$
Moreover, the sign of $f(m+1)$ can be expressed simply in terms of $m$ because
$$f(m+1)>0
\quad\iff\quad
(-1)^{\lfloor\tfrac{m+2}{2}\rfloor}>0
\quad\iff\quad
m+2\equiv2,3\pmod{4}.$$
For $m>2$, to get rid of the first two irregular terms in the partial sum $S_m$, set $T_m:=\sum_{k=3}^mf(k)$. Then $T_m=S_m-\tfrac34$ and $(1)$ now simplifies to
$$T_m>\frac{3}{20}\qquad\iff\qquad m\equiv0,1\pmod{4}.$$
Writing out the first few summands of $T_m$ shows that if $m$ is even we can group the summands into pairs to get a simple geometric sum, for which it is easy to find a closed form:
\begin{eqnarray*}
T_{2n}&=&\left(\frac{1}{8}+\frac{1}{16}\right)
-\left(\frac{1}{32}+\frac{1}{64}\right)
+\left(\frac{1}{128}+\frac{1}{256}\right)
-\cdots\\
&=&\sum_{k=2}^n\left(-\frac{1}{4}\right)^k\left(2+1\right)
=3\sum_{k=2}^n\left(-\frac{1}{4}\right)^k\\
&=&3\frac{\left(-\tfrac{1}{4}\right)^2-\left(-\tfrac{1}{4}\right)^{n+1}}{1-\left(-\tfrac14\right)}
=\frac{3}{20}\left(1-\left(-\frac{1}{4}\right)^{n-1}\right)\\
&=&\frac{3}{20}-\frac{3}{20}\left(-\frac{1}{4}\right)^{n-1}\tag{2}
\end{eqnarray*}
In particular, this last expression shows that $T_{2n}>\frac{3}{20}$ if $n$ is even and $T_{2n}<\frac{3}{20}$ if $n$ is odd. This proves $(1)$ for all even $m$. For odd $m$, we simply add one summand to $(2)$ to get
\begin{eqnarray*}
T_{2n+1}&=&
\frac{3}{20}+\frac35\left(-\frac{1}{4}\right)^n+\frac{(-1)^{n+1}}{2^{2n+1}}\\
&=&\frac{3}{20}+(-1)^n\frac35\left(\frac{1}{4}\right)^n-\frac12\left(\frac{1}{4}\right)^n\\
&=&\frac{3}{20}+\left((-1)^n\frac35-\frac12\right)\left(\frac{1}{4}\right)^n,
\end{eqnarray*}
which shows that $T_{2n+1}>\tfrac{3}{20}$ if $n$ is even and $T_{2n+1}<\tfrac{3}{20}$ if $n$ is odd. This proves $(1)$ for all odd $m$, and hence for all $m$.
</s>