## Some Poker Theorems (Part 1)

I haven’t played poker for many years, but I thought I might get back into it, so I decided to write out a few theorems for myself that might be useful.

### Basic Calling Theorem

Theorem: Suppose in a poker game that you have the option of folding or paying $B$ dollars to call a bet. Suppose that the pot contains $P$ dollars before you call. If you call, no more bets are permitted (e.g. either you or your opponent is “all-in” or you are heads up on the river), more cards are dealt, and the probability of you winning is $\alpha$. Then you should call if

$$\alpha > \frac{B}{B+P}.$$

Proof: The expected value if you call is

$$E = \alpha P + (1-\alpha) (-B)$$
since you will gain $P$ dollars if you win and lose $B$ dollars if you lose. Now the following are equivalent
\begin{aligned} E&>0 \\ \alpha P + (1-\alpha) (-B) &>0\\ \alpha P -B +\alpha B&>0 \\ \alpha (P+B) &>B \\ \alpha &>\frac{B}{P+B}. \\ \end{aligned}
Thus, your expectation is greater than zero if and only if
$$\alpha > \frac{B}{B+P}.$$

### Example

Suppose that you are playing no limit Holdem poker, pre-flop a player goes all-in, and you are sure that he has a pair of aces, kings, queens, or jacks. You have seven six suited. All other players have folded. The pot contains \$130 and you need to pay \$90 to call. Should you call?

You have about a 21% chance to win. According to the Basic Calling Theorem, you should call if

\begin{aligned} \alpha &> \frac{B}{B+P} \\ 0.21 &>\frac{90}{90+130}\approx 0.4091. \end{aligned}
Your win probability $\alpha =0.21$ is not greater than $B/(B+P)\approx 0.4091$, so you should fold.

## Without using a calculator, which is bigger: sin(2°)/2 or sin(3°)/3 ? (Part 3)

In part 1, I presented a proof that sin(2°)/2 > sin(3°)/3 using only trigonometry. In part 2, I presented a proof using the Taylor series expansion of sine.  In part 3 below, I present three additional proofs:  a proof using the average value of a function and the mean value theorem, a proof by Reddit user Dala_The_Pimp which proves $f(x)=\sin(x)/x=\mathrm{sinc}(x)$ is strictly decreasing on $(0,\pi/2)$ using derivatives, and a proof using concavity of $\sin(x)$ on $(0, \pi)$.

It suffices to prove that $f(x) = \sin(x)/x$ is deceasing on $[0, \pi/2]$.

Let $$\mathrm{aveVal}(g(t) , x) = \frac1x \int_0^x g(t) dt.$$

Lemma 1:  If  $g(t)$ is continuous and strictly decreasing on $[0,a]$ and $$f(x)= \mathrm{aveVal}(g(t) , x),$$then $f(x)$ is strictly decreasing on $[0,a]$.

Proof: Notice that if $g(t)$ is continuous and $f(x)= \mathrm{aveVal}(g(t) , x)$, then for all $x\in[0,a]$,

$$f'(x) = -\frac1{x^2} \int_0^x g(t) dt + \frac{g(x)}x$$

$$= \frac1{x^2} \left( -\int_0^x g(t) dt + x g(x)\right)$$

$$= \frac1{x^2} ( -x g(c) + x g(x))$$

where $c\in(0,x)$ by the Mean Value Theorem, so

$$f'(x)= \frac1x (g(x) – g(c) ) <0$$

which proves the lemma.

Now,

\begin{aligned} \sin(x) – x &= \int_0^x (\cos(t) – 1)\, dt,\mathrm{\ so} \\ \sin(x)/x – 1 &=\mathrm{aveVal}(\cos(t) -1, x).\end{aligned}

By Lemma 1, $\cos(t)-1$ is strictly decreasing on $[0, \pi]$ implies

$$\mathrm{aveVal}(\cos(t)-1, 0, x)$$is strictly decreasing on $[0, \pi]$ implies$$\sin(x)/x – 1$$ is strictly decreasing on $[0, \pi]$ implies

$\sin(x)/x$ is strictly decreasing on $[0, \pi]$.

### Reddit post

Below I’m going to copy Reddit user Dala_The_Pimp’s solution Feb 8, 2023. (I am revising it just a little.)

Let $f(x)=\sin(x)/x$. Then
$$f'(x)= \frac{x\cos(x) -\sin(x)}{x^2}.$$
Now let $g(x) = x\cos(x) -\sin(x).$ Clearly $g(0)=0.$ Also
$$g'(x)=-x\sin(x)$$
which is clearly negative in $(0,\pi/2)$ thus $g(x)$ is decreasing hence $g(x)<g(0)$ and consequently $g(x)<0$, thus it is proven that since $g(x)<0, f'(x)<0$ and $f(x)$ is decreasing, hence $f(2^o)>f(3^o)$ and $\sin(2^o)/2^o >\sin(3^o)/3^o$ which implies
$$\sin(2^o)/2 >\sin(3^o)/3.$$

### proof using CONCAVITY

We also can use concavity to prove that $\sin(2^o)/2 >\sin(3^o)/3.$ The second derivative of $\sin(x)$ is $-\sin(x)$, thus the second derivative of $\sin(x)$ is strictly negative on $(0, \pi)$. That implies that $\sin(x)$ is strictly concave on $(0,\pi)$. (See e.g. the proof wiki). By the definition of strict concavity, for all $\lambda\in (0,1)$,
$$\sin( (1-\lambda)\cdot 0 + \lambda 3^o) > (1-\lambda)\sin(0) + \lambda\sin(3^0).$$
Setting $\lambda = 2/3$, we get$$\sin( 2^o) > 2/3 \sin(3^0),\mathrm{\ \ and\ hence}$$ $$\sin( 2^o)/2 > \sin(3^0)/3.$$

## Without using a calculator, which is bigger: sin(2°)/2 or sin(3°)/3 ? (Part 2)

In part 1, I proved that sin(2°)/2> sin(3°)/3 using trigonometry.  Here is a proof using power series.

In “Some Simple Lemmas For Bounding Power Series (Part 1)” Example 1, we applied the lemmas to prove that

$$x-x^3/6 + x^5/120>\sin(x) > x-x^3/6$$when $0<x<\sqrt{3}.$  (That’s actually true for all $x>0$, but I did not prove it.)

Let $\epsilon = 1^\circ$. Note that $\epsilon = \frac{\pi}{180} < 1/40.$

Then,

\begin{aligned}\frac{\sin(2^\circ)}2 – \frac{\sin(3^\circ)}3 &= \frac{\sin(2\epsilon)}2 – \frac{\sin(3\epsilon)}3\\&=\frac{ 3\sin(2\epsilon) – 2 \sin(3\epsilon)}6\\&>\frac{ 3 (2\epsilon – (2\epsilon)^3/6) – 2 (3\epsilon – (3\epsilon)^3/6 + (3\epsilon)^5/120 )}6\\&=\frac{ 3(2\epsilon – 4 \epsilon^3/3) – 2 (3\epsilon – 9\epsilon^3/2 + 81\epsilon^5/40 )}6\\&=\frac{ 6\epsilon – 4 \epsilon^3 – (6\epsilon – 9\epsilon^3 + 81\epsilon^5/20 )}6\\&=\frac{ – 4 \epsilon^3 + 9\epsilon^3 – 81\epsilon^5/20 }6\\&=\frac{ 5 – 81\epsilon^2/20 }6 \epsilon^3\\&>\frac{ 5 – 1/20 }6 \epsilon^3 \\&>0 \end{aligned}which proves sin(2°)/2> sin(3°)/3.

## Some Simple Lemmas For Bounding Power Series (Part 2)

Often functions are defined or approximated by infinitely long sums which can be thought of as polynomials with an infinite degree. For example,
$$\cos(x) = 1- x^2/2! + x^4/4! +x^6/6! + ….$$
(where $n! = n \cdot (n-1) \cdot (n-2) \cdots \cdot1$ and $4!=4\cdot 3\cdot 2\cdot 1$.) These sums are usually referred to as infinite series, and you can often use the first few terms to approximate the sum of all of the terms. For example,
$$\cos(x) \approx 1 – x^2/2$$when $|x| < 0.2$

In my last post, I presented some bounds on the error that occurs when you approximate an alternating series with the first few terms of the series. An alternating series is a infinite sum where the sign of the terms alternate between positive and negative. In this post, I will present a fairly simple bound on the error of approximating an infinite series where the terms grow no faster than exponentially.

We will use this well known, useful fact (#87 in the “100 Most useful Theorems and Ideas in Mathematics“).

Fact 1: If $|x|<1$,

$$1/(1-x) = 1 +x +x^2 + \cdots.$$

Proof: Fix any $x\in(-1,1)$. Let $S_n = 1+x+\cdots+x^n.$ Then
$\lim_{n\rightarrow\infty} S_n$ exists by Ratio test, and
\begin{aligned} S_n (1-x) &= 1- x^{n+1} \\ \lim_{n\rightarrow\infty} S_n (1-x)&= \lim_{n\rightarrow\infty} (1- x^{n+1})\\ (1-x)\lim_{n\rightarrow\infty} S_n&= 1\\ \lim_{n\rightarrow\infty} S_n&= 1/(1-x).\quad\mathrm{□} \end{aligned}

Lemma: Suppose $a_1, a_2, \ldots$ is a sequence of real numbers, $n$ is a positive integer, and $\alpha$ is a real number such that:

1. $0\leq \alpha < 1,$ and
2. $\alpha |a_i| \geq |a_{i+1}|$ for all integers $i\geq n+1$.

Then $S = \sum_{a=1}^\infty a_i$ exists, and $$\left| S – \sum_{i=1}^{n} a_i \right| \leq |a_{n+1}|/(1-\alpha).$$

Proof: $S$ exists by Ratio Test.  Now, I claim that for all positive integers $j$, $$|a_{n+j}| \leq \alpha\,^{j-1} |a_{n+1}|.$$ This holds almost trivially when $j=1$. And if we assume that the claim holds for $j=k$, then

$$|a_{n+k+1}| \leq \alpha |a_{n+k}| \leq \alpha\; \alpha\,^{k-1} |a_{n+1} | = \alpha\,^k |a_{n+1}|$$ which proves that the claim holds for $j=k+1$, which in turn proves that the claim is true by induction.

Now by the claim and Fact 1, \begin{aligned} \left| S – \sum_{i=1}^{n} a_i \right| &= \left|\sum_{i=n+1}^\infty a_i\right|\\ &\leq \sum_{i=n+1}^\infty | a_i | \\ &\leq \sum_{i=0}^\infty \alpha\,^i |a_{n+1}| \\ &= |a_{n+1}|/ (1-\alpha) \end{aligned}which proves the lemma.$\quad\mathrm{□}$

### Examples

Example 1: By definition,

$$\exp(x) = 1 + x + x^2/2! + x^3/3! + \cdots.$$
If $|x| <1$, then the lemma holds for $n=2$ and $\alpha=1/3$, so
$$| \exp(x) – (1+x) | \leq |x^2/2|/(1-\alpha) = \frac34 x^2.$$
We can also apply the lemma for $|x|<1$, $n=3$, and $\alpha = 1/4$ to get
$$| \exp(x) – (1+x+x^2/2) | \leq |x^3/6|/(1-\alpha) = \frac29 |x^3|.$$

$\mathrm{ }$

Example 2: By Fact 1 and integration,
$$-\log(1-x) = x + x^2/2+x^3/3+ x^4/4+\cdots$$when $|x|<1$. We can apply the lemma for $|x|<1$, $n=1,2,$ or 3, and $\alpha =|x|$ to get
\begin{aligned} |-\log(1-x) – x | & \leq |x^2/2|/(1-|x|),\\ |-\log(1-x) – (x+x^2/2) | &\leq |x^3/3|/(1-|x|),\mathrm{\ and}\\ |-\log(1-x) – (x+x^2/2+x^3/3) | &\leq |x^4/4|/(1-|x|).\\ \end{aligned}

## Some Simple Lemmas For Bounding Power Series (Part 1)

A few days ago, I wrote several proofs that  $\sin(2°)/2 > \sin(3°)/3$.  One of those proofs involves power series and two simple, useful lemmas.

Leibniz bound on alternating series (1682)

Theorem:  Suppose $a_1, a_2, \ldots$ is a sequence of real numbers such that:
1) $|a_i| \geq |a_{i+1}|$ for positive all integers $i$,
2) $a_1 >0$,
3) $a_j \cdot a_{j+1} <0$ for positive integers $j$ (i.e. the sequence alternates in sign), and
4) $\sum_{a=1}^\infty a_i$ exists.
Then $$0 \leq \sum_{i=1}^\infty a_i \leq a_1.$$

(See Theorem 2 in this paper.) The following two lemmas are almost the same and almost follow from the Leibniz bound. (If you make the strict inequalities in the Lemmas non-strict, then you can prove them in one sentence using the Leibniz theorem.)

The following two Lemmas have almost the same proof with inequality signs reversed.  A proof for Lemma 2 is provided below.

Lemma 1: Suppose $a_1, a_2, \ldots$ is a sequence of real numbers such and $n$ is a positive integer such that:
1) $|a_i| > |a_{i+1}|$ for all integers $i\geq n$,
2) $a_n <0$,
3) $a_j \cdot a_{j+1} <0$ for all integers $j\geq n$ (i.e. the sequence alternates in sign), and
4) $\sum_{a=1}^\infty a_i$ exists.
Then $$\sum_{i=1}^\infty a_i > \sum_{i=1}^n a_i .$$

Lemma 2: Suppose $a_1, a_2, \ldots$ is a sequence of real numbers such and $n$ is a positive integer such that:
1) $|a_i| > |a_{i+1}|$ for all integers $i\geq n$,
2) $a_n >0$, and
3) $a_j \cdot a_{j+1} <0$ for all integers $j\geq n$ (i.e. the sequence alternates in sign), and
4) $\sum_{a=1}^\infty a_i$ exists.
Then $$\sum_{i=1}^\infty a_i < \sum_{i=1}^n a_i .$$

Proof of Lemma 2: Here is a proof that does not use the Leibniz Theorem.

The hypotheses imply that $a_{n +2k +1}<0$, $a_{n +2k +2}>0$, and
$$a_{n +2k +1} + a_{n +2k +2}<0$$
for all integers $k\geq 0$. So,
\begin{aligned} \sum_{i=1}^\infty a_i &= \sum_{i=1}^n a_i + \sum_{i=n+1}^\infty a_i \\ &= \sum_{i=1}^n a_i + \sum_{k=0}^\infty a_{n +2k +1} + a_{n +2k + 2j } \\ &< \sum_{i=1}^n a_i.\quad ■ \end{aligned}

Example 1:  $$\sin(x) = \sum_{i=0}^\infty (-1)^i x^{2i+1}/{(2i+1)!},$$so $$x> \sin(x) > x-x^3/6$$when $0<x<\sqrt{3}$ because the absolute value of the terms are decreasing for that interval.  (In reality, it is true for any real $x$, but you need more than the Lemmas above to prove that.) Furthermore,  $$x-x^3/6 + x^5/120 > \sin(x) > x-x^3/6 + x^5/120 – x^7/5040$$when $0<x<\sqrt{20}$.  (Once again, it is true for any real $x$.)

Example 2:  $$\cos(x) = \sum_{i=0}^\infty (-1)^i x^{2i}/{(2i)!},$$so $$1> \cos(x) > 1-x^2/2$$when $0<|x|<\sqrt{2}$ because the absolute value of the terms are decreasing for that interval.

Example 3:  $$\log(1+x) = \sum_{i=1}^\infty (-1)^{i+1} x^{i}/i$$when $|x|<1$, so $$x> \log(x+1) > x-x^2/2$$when $0<x<1$ because the absolute value of the terms are decreasing for that interval.  Furthermore, $$x-x^2/2 + x^3/3 > \log(x+1) > x-x^2/2 + x^3/3-x^4/4$$when $0<x<1$ because the absolute value of the terms are decreasing for that interval.

Example 4:  $$\mathrm{arctan}(x) = \sum_{i=0}^\infty (-1)^i x^{2i+1}/(2i+1),$$so $$x> \mathrm{arctan}(x) > x-x^3/3$$when $0<x<1$ because the absolute value of the terms are decreasing for that interval.  Furthermore, $$x-x^3/3+x^5/5 > \mathrm{arctan}(x) >x-x^3/3+x^5/5 -x^7/7$$when $0<x<1$ because the absolute value of the terms are decreasing for that interval.

## Without using a calculator, which is bigger: sin(2°)/2 or sin(3°)/3 ? (Part 1)

So, on Reddit, user Straight-Ad-7750 posted the question,

“Which is bigger without using a calculator: $\frac{\sin(2°)}{2}$ or $\frac{\sin(3°)}{3}$?”

(Note:  $2°= 2\cdot \frac{\pi}{180}$ and $3°= 3\cdot \frac{\pi}{180}$.)

There are many ways to prove that one is smaller than the other.  These proofs are great because each proof uses one or more useful lemma or commonly known identity.  Below we give a proof using only trig identities.  Proofs using calculus will be given in part 2.

The answer is stated in the paragraph below, so if you want to try to figure it out yourself, stop reading now!

Also, it turns out that this is a rather easy question to answer if you are a third or fourth year electrical engineering student because most electrical engineers know about the sinc function defined by $$\mathrm{sinc(x)} = \frac{\sin(x)}{x}.$$ But, let’s just assume that we don’t know about the sinc function and look at the proofs that do not require knowledge about the sinc function.

### Trig Proof

We can prove that $\frac{\sin(3°)}{3}$ is smaller just by using trig identities.
Lemma: cos(2°) < cos(1°)
Proof:  We will apply the cosine double angle formula, the fact that $\sin^2(1°)\neq0$, and the fact that $1>\cos(1°)>0$ to prove the lemma as follows:

$$\cos(2°) = \cos^2(1°) – \sin^2(1°) < \cos^2(1°) < \cos(1°). □$$
Theorem: $\sin(2°)/2 > \sin(3°)/3$.
Proof: By the fact $1>\cos(1°)>0$, the Lemma, the double angle formula for sine, and the sin of a sum formula,
3/2 = 1 + 1/2
> cos(1°) + 1/2*( cos(2°) / cos(1°))
= cos(1°) + sin(1°)cos(2°) / ( 2 sin(1°) cos(1°))
= cos(1°) + sin(1°)cos(2°) / sin(2°)
= [ sin(2°) cos(1°) + sin(1°)cos(2°)] / sin(2°)
= sin(3°) /sin(2°).
So,
$$3/2 > \sin(3°) /\sin(2°)$$
and hence
$$\sin(2°)/2 > \sin(3°)/3. □$$

Next week I hope to post two calculus based proof.  Both of those proofs have cool, useful, simple Lemma!

## Noxious Fumes+ : Certain Death in sqrt(h) turns

This post can also be found in a nicer format at GitHub (LaTex), Github blog format, and Reddit.

There are three great deck builder card games: Dominion, Slay the Spire, and Magic the Gathering. There are four different characters in Slay the Spire. My favorite is the Silent character who often uses poison to defeat the monsters.

One method of attacking with poison in Slay the Spire is to play the “Noxious Fumes+” card. The card self destructs after it is played (it cannot be played again until the you enter the next room in your quest.) Nothing happens on the turn in which it is played. The next turn, the monster experiences 3 damage from the poison. The next turn after that, the monster experiences 5 additional poison damage for a total of 8 poison damage. The next turn after that 7 additional poison damage for a total of 15 poison damage. And so on.

A few weeks ago, I wrote that if you play an ordinary Noxious Fumes card, every opponent monster with h health points or less will be dead in $\sqrt{2 h}$ turns. (See Footnote [1] for details.)

What about the upgraded Noxious Fumes+? Well amazingly, if you play a Noxious Fumes+, then the monster dies in $\sqrt{h}$  turns or less.

In fact, if

• the monster has h health points when the Noxious Fumes+ card is played,

• the monster can’t heal,

• the monster experiences no poison damage on the turn that the Noxious Fumes+ is played,

• it experiences 3 poison damage on the turn after Noxious Fumes+ is played, 5 poison damage on the next turn, 7 on the next, and so on for t=floor($\sqrt{h}$) turns, and

• the monster experiences only poison damage,

then the monster will die exactly

t = floor($\sqrt{h}$)

turns after the Noxious Fumes+ is played.

Notation: floor(x) is the largest whole number less than or equal to x. It is rounded down. For example, floor(3) = 3, floor(4.8) = 4, and floor(π) = 3.

Example 1

Suppose there is a minion that has 8 hit points when the Noxious Fumes+ is played. Suppose that the minion is not healed, it has no poison on the turn that the Noxious Fumes+ is played, and you do not take any other offensive actions against that minion (nor do you play any area of effect cards). Then, that minion will die in exactly

t = floor($\sqrt{8}$) = floor(2.8284) = 2 turns.

One turn after the Noxious Fumes+ is played, it experiences 3 points poison damage, and the following turn it dies with 5 additional points poison damage.

Example 2

Suppose there is a monster that has 25 hit points when the Noxious Fumes+ is played. Suppose that the monster is not healed, it has no poison on the turn that the Noxious Fumes+ is played, and you do not take any other offensive actions against that monster (nor do you play any area of effect cards). Then, that monster will die in exactly

t = floor(√25) = floor(5) = 5 turns.

The total poison damage over the next 4 turns is 3+5+7+9 = 24. On the fifth turn after the Noxious Fumes+ is played, it experiences 11 additional poison damage and dies.

Footnote [1] If the monster can’t heal or avoid poison damage, and it experiences 2 poison damage on the next turn after an ordinary Noxious Fumes is played, 3 poison damage on the next turn, 4 on the next, and so on, then it will be dead within $\sqrt{2 h}$ turns after the Noxious Fumes is played. With a few more calculations, you can get a better, 100% accurate, but more complicated formula for the number of turns to death if all the damage comes from the Noxious Fumes card.

## Noxious Fumes: Certain Death in ceil((-3 + sqrt(8h + 9)) / 2) turns

### Intro

There are three great deck builder card games:  Dominion, Slay the Spire, and Magic the Gathering.  There are four different characters in Slay the Spire.  My favorite is the Silent character who often uses poison to defeat the monsters.

One method of attacking with poison in Slay the Spire is to play the “Noxious Fumes” card.  The card self destructs after it is played (it cannot be played again until the you enter the next room in your quest.)   Nothing happens on the turn in which it is played.  The next turn, the monster experiences 2 damage from the poison.  The next turn after that, the monster experiences 3 additional poison damage for a total of 5 poison damage.  The next turn after that 4 additional poison damage for a total of 9 poison damage.  And so on.

### Time to Death

I love Noxious Fumes. I love that once I play Noxious Fumes, the enemy will die in square root time no matter what he does and no matter what I do. In fact, every monster with $h$ or less health points will be dead in no more than
$$\mathrm{deathTime}=\mathrm{ceil}\left( \left( -3+ \sqrt{ 8h +9}\right)/2\right)$$ turns. [1][2]

Notation: $\mathrm{ceil}(x)$ is defined to be the smallest integer which is greater than or equal to $x$. For example, $\mathrm{ceil}(13) = 13$, $\mathrm{ceil}(3.2) = 4$, and $\mathrm{ceil}(\pi) = 4$.
“ceil” is an abbreviation for “ceiling” and $\mathrm{ceil}(x)$ is $x$ rounded upward.

### Example

Let’s try out the formula. If the monster has 100 health points, then it will be dead in
\begin{aligned} \mathrm{deathTime}&=\mathrm{ceil}\left( \left( -3+ \sqrt{ 8\cdot 100 +9}\right)/2\right) \\ &=\mathrm{ceil}\left( \left( -3+ \sqrt{ 809}\right)/2\right) \\ &=\mathrm{ceil}\left( \left( -3+ 28.44\right)/2\right) \\ &=\mathrm{ceil}\left( 25.44/2\right) \\ &=\mathrm{ceil}\left( 12.72\right) \\ &=13\end{aligned} turns.

• If you play the Noxious Fumes on turn 4, then on turn 4+1=5, the monster will have 2 poison, and 2 total poison damage.
• On turn 4+2=6, the monster will have 3 poison, and 2+3 total poison damage.
• On turn 4+3=7, the monster will have 4 poison, and 2+3+4 total poison damage.
• On turn 4+12=16, the monster will have 13 poison and $2+3+4+\cdots+13= 90$ total poison damage.
• On turn 4+13=17, the monster will have 14 poison and $2+3+4+\cdots+14= 104$ total poison damage and hence will be dead.

### Theorem

Theorem: If a monster has $h$ health points when a Noxious Fumes card is played and that monster has no way to heal or remove the Noxious Fumes, then it will be dead $$\mathrm{deathTime}=\mathrm{ceil}\left( \left( -3+ \sqrt{ 8h +9}\right)/2\right)$$ turns later. [3]

For the few of you who like proofs, here it is.

Proof:
The sum $2+3+4+\ldots+n$ is the sum of $n-1$ numbers whose average value is $\frac{n+2}{2}$, so that sum is
$$2+3+4+\ldots+n = (n-1)\frac{n+2}{2}.$$
For example,
$$2+3+4+5 = (5-1)\cdot (5+2) /2 = (4\cdot 7)/2 = 28/2 = 14.$$

$t$ turns after the Noxious Fumes card is played, the monster will have $t+1$ poison and a total poison damage of
$$\mathrm{totalPoisonDamage} = 2+3+4+\cdots+(t+1)= t (t+3)/2.$$

If the monster had $h$ health points when the Noxious Fumes card was played, then $t$ turns later the monster will be dead if
$$h\leq \mathrm{totalPoisonDamage} = t (t+3)/2.$$
Now let’s try to find the value of $t$ where the left hand side equals the right hand side. The following are equivalent
\begin{aligned} h&= t (t+3)/2 \\ 0&= \frac{t^2}{2} + \frac{3 t}{2} -h. \\ \end{aligned} According to the quadratic formula, the equation above will be satisfied by
\begin{aligned} t &= \frac{ -3/2 \pm \sqrt{(3/2)^2 – 4 (1/2) (-h) } }{2\cdot (1/2)}\\ &= -3/2 \pm \sqrt{9/4 + 2h } \\ &= \frac{-3 \pm \sqrt{9 + 8h }}{2}.\\ \end{aligned}
The solution $t = \frac{-3 – \sqrt{9 + 8h }}{2}$ can be disregarded because it is negative. So,
$$h = t (t+3)/2$$
if $t = \frac{-3 + \sqrt{9 + 8h }}{2}$. The fact that poison damage is always increasing implies that
$$h \leq t (t+3)/2\quad\mathrm{if\ }t\geq \frac{-3 + \sqrt{9 + 8h }}{2}.$$
If $t$ is an integer, then
$$h \leq t (t+3)/2\quad\mathrm{if\ }t\geq \mathrm{ceil}\left( \frac{-3 + \sqrt{9 + 8h }}{2}\right)$$
which implies the monster is dead if
$$t\geq \mathrm{ceil}\left( \frac{-3 + \sqrt{9 + 8h }}{2}\right).$$

### Endnote

That’s it. Watch out for the sequel,

“Noxious Fumes+ : Guaranteed Death in <Spoiler Removed> turns or less”.

### Footnotes

[1] Alright, technically this formula does not work if the monster can heal or if the monster can remove the noxious fumes. The list of monsters that can heal or remove debuffs includes: Centurion/Mystic, Spheric Guardian, Reptomancer, The Collector, the Awakened One, and the Time Eater.}

[2] It’s not too hard to show that $$\left( -3+ \sqrt{ 8h +9}\right)/2 < \sqrt{2 h}.$$  In fact, $$\frac{\left( -3+ \sqrt{ 8h +9}\right)/2}{\sqrt{2 h}} = \frac{1}{\sqrt{\frac{9}{8 h}+1}+\frac{3}{2 \sqrt{2} \sqrt{h}}} < 1.$$

[3] Possibly earlier if there is any other source of damage.

## Why is 1/log(1+1/k) ≈ k + 1/2 ?

This is just a minor extension of my last post.
Why is $$1/\log(1+1/k) \approx k + 1/2\ ?$$
At first, I was surprised that $$1/\log(1+1/237) \approx 237,$$ but then I realize that $$\log(1+x) \approx x$$ if $|x|$ is small, so
$$1/\log(1+x) \approx 1/x,\mathrm{\ thus}$$
$$1/\log(1+1/k) \approx k.$$
Where does the 1/2 come from? Well, you’ve got to get a better approximation of $\log(1 +x)$ to find the 1/2. You can do this with calculus.  If $|x| <$1 and $|y| < 1$, then $$(1-x)\cdot( 1+ x + x^2 + x^3 + \ldots) = 1$$
$$1/(1-x) = 1+ x + x^2 + x^3 + \ldots$$
$$\int_0^y 1/(1-x) \;dy = y + y^2/2 + y^3/3 + \ldots$$
$$-\log(1-y) = y + y^2/2 + y^3/3 + \ldots,\mathrm{\, so}$$
$$\log(1+x) = x – x^2/2 + O(x^3)$$ using big O notation.  (Aside: $-\log( 1 – .001) = 0.0010005003335835335…$)
Now,
\begin{aligned} 1/\log(1+x) &= 1/(x – x^2/2 + O(x^3)) \\ &= 1/x \cdot 1/(1 – x/2 + O(x^2)) \\ &= 1/x \cdot [ 1 + ( x/2 + O(x^2)) + O( ( x/2 + O(x^2))^2) ] \\ &= 1/x \cdot ( 1 + x/2 + O(x^2) + O( x^2) ) \\ &= 1/x \cdot ( 1 + x/2 + O( x^2) ) \\ &= 1/x + 1/2 + O(x). \end{aligned}Replacing $x$ with $1/k$ gives$$1/\log(1+1/k) = k + 1/2 + O(1/k).$$

It is more work to prove sharper bounds.

## 1/log(1+1/237) = 237.49964912… ??

I was rather surprised one day when I typed $$1/\log(1+1/237)$$ into a calculator and got 237.4996491…. I just thought it was strange that it was so very close to 237.5 but very slightly less.

I had been trying to find the maximum number of tanks that you can produce in the tank-factory game. You start the game with any number of factories. On each turn, you can either invest in more factories thereby increasing the number of factories by 10% or you can use the turn to produce one tank per turn per factory. The game lasts for $T$ turns with $T>10$. If you build factories for $k$ turns and build tanks for $T-k$ turns, then the total number of tanks produced is $$f(k) = f_0 \; 1.1^k (T-k)$$ where $f_0$ is the starting number of factories.

Perhaps surprisingly, the maximum value of $f(k)$ is attained both at $k=T-10$ and $k=T-11$. Mathematically[1],
$$\max\{ f(k) | k = 1,2, …, T\} = f(T-10) = f(T-11) \approx 3.9\cdot 1.1^T f_0.$$

But, $f(x)$ can also be thought of as a real valued function, so the maximum value of $f(x)$ over positive real numbers $x$ should be about half way between $x=T-10$ and $x=T-11$.
$$\max_{x>0} f(x) \approx f(T-10.5).$$
To find the precise maximum of $f$ over positive real numbers, we find the point on the curve $y=f(x)$ where the tangent line is horizontal (i.e. where the derivative is zero) as follows: (TFAE)
\begin{aligned} f'(x) &= 0 \\f_0 1.1^x \log(1.1) (T-x) – f_0 1.1^x &= 0 \\ \log(1.1) (T-x) -1 &= 0 \\ \log(1.1) (T-x) &= 1 \\ T-x &= 1/\log(1.1) \\ T- 1/\log(1.1) &=x.\end{aligned}
The max of $f(x)$ occurs at $x = T- 1/\log(1.1)$, but before we estimated that the max would occur at $x\approx T – 10.5$, so we can conlude that
$$1/ \log(1+1/10) = 1/\log(1.1) \approx 10.5.$$
Indeed,
$$1/\log(1.1) = 10.492058687….$$

You can use simillar reasoning to conclude that
$$1/\log( 1 + 1/k) \approx k + 1/2$$
for all positive integers $k$.

A more precise bound can be found with Taylor series. If you go through the math you can prove that for all positive real numbers $x$,
$$f(x) = 1/\log(1+1/x) = x + 1/2 – 1/(12 x) + e(x)$$
where $0< e(x) < 1/(24 x^2).$

Footnote:
[1] More generally, if $k$ and $T$ are postive integers, $k<T$, and $$g(k, n, T) = (1+1/k)^n (T-n),$$ then
\begin{aligned} \max\,\{ g(k,n, T)\; |\; n &= 0, 1,2, \ldots, T \} \\ &= g(k, T-k, T) \\&= g(k, T-k-1, T).\end{aligned}

« Older entries