# Server Bug Fix: Wait, it is worth it?

You went to a Casino, and saw a quite interesting stall.

The cardboard besides the stall says:

You first pay \$$$5$$

You have to toss the fair coin. If it lands heads, you can throw again. If it lands tails, you have to stop. You throw the coin until it lands tail. The the money you get is the number of throws squared.

But is this worth it?

Bonus: What is the expected money gain or loss per round?

Ok, this puzzle is quite easy. This is because I want to celebrate that I hit the rep cap for three consecutive days.

The expected value is

$$E = frac{1}{2}(1) + frac{1}{4}(4) + frac{1}{8}(9) + frac{1}{16}(16) + frac{1}{32}(25) …$$, so $$E = sum left(frac{1}{2}right)^n (n^2)$$ (all sums are 1 to infinity).

What you can do here is

Consider $$sum x^n = frac{x}{1-x}$$, for $$|x|<1$$. This equals $$1 – frac{1}{1-x}$$. We take the derivative of both sides: $$sum nx^{n-1} = frac{1}{(1-x)^2}$$.

Then,

Consider multiplying both sides by $$x$$, and differentiating: on the left, we get $$left(sum nx^nright)’= sum n^2 x^{n-1}$$; on the right we get $$left(frac{x}{(1-x)^2}right)’ = frac{1+x}{(1-x)^3}$$.

Next,

Multiply both sides by $$x$$: $$sum n^2 x^n = frac{x(1+x)}{(1-x)^3}$$, for $$|x| < 1$$. Then sub in $$x = frac{1}{2}$$, to get $$sum n^2 left(frac{1}{2}right)^n = frac{(1/2)(3/2)}{(1-1/2)^3} = frac{3/4}{1/8} = 6$$.

Therefore

The expected payout is 6, so the expected profit of every round is +1 (the bonus answer), which means you should play (the initial answer).

Yes, it is worth it.

Proof:

Let’s assume the number of throws is limited at 7. Then we have to evaluate the sum $$sum_1^7 frac{n^2}{2^n}$$ to get a lower bound on your expected winnings. That can be done on a calculator. It can be seen that the sum evaluates to about 5.35\$, and since there are no negative elements in the corresponding infinite sum, the expected value will never decrease. Therefore, your expected profit is not less than about 0.35\$. The series seem to converge to 6, but I am not sure how to prove that.

Tagged : /