Fast way to calculate sequence

47 Views Asked by At

is there a fast way to calculate the sequence:

$f_k = 0.5 * (f_{k-1}+1) + 0.5* (\frac{1}{f_{k-1}})$

for $f_7$ with $f_1=100$?

Specifically, the question was that a coin was thrown: If I get heads, I get one additional dollar and if I get tails, my earnings are being inverted (for instance I have 200\$, after one tail, I only have 1/200 \$).

The game is played 7 times. How much is my expected value?

Thanks! Johannes

2

There are 2 best solutions below

0
On

I do not think your recursion gives the correct expected value, and it would be better to find the $64$ equally probable values and take the mean.

Using R code for the recursion

> f <- 100
> for (i in 2:7){ f <- 0.5 * (f+1) + 0.5 * 1/f }
> f
[1] 2.713338

while for the problem itself

> f <- 100
> for (i in 2:7){ f <- c(f+1, 1/f) }
> f
 [1] 1.060000e+02 5.010000e+00 4.009901e+00 1.040000e+02 3.009804e+00
 [6] 3.990099e+00 1.040000e+02 3.010000e+00 2.009709e+00 2.497512e+00
[11] 2.990196e+00 2.009901e+00 1.040000e+02 3.010000e+00 2.009901e+00
[16] 1.020000e+02 1.009615e+00 1.332226e+00 1.497537e+00 1.009804e+00
[21] 1.990291e+00 1.502488e+00 1.009804e+00 1.990099e+00 1.040000e+02
[26] 3.010000e+00 2.009901e+00 1.020000e+02 1.009804e+00 1.990099e+00
[31] 1.020000e+02 1.010000e+00 9.523810e-03 2.493766e-01 3.322368e-01
[36] 9.708738e-03 4.975610e-01 3.344371e-01 9.708738e-03 4.975124e-01
[41] 9.903846e-01 6.677741e-01 5.024631e-01 9.901961e-01 9.708738e-03
[46] 4.975124e-01 9.901961e-01 9.900990e-03 1.040000e+02 3.010000e+00
[51] 2.009901e+00 1.020000e+02 1.009804e+00 1.990099e+00 1.020000e+02
[56] 1.010000e+00 9.708738e-03 4.975124e-01 9.901961e-01 9.900990e-03
[61] 1.020000e+02 1.010000e+00 9.900990e-03 1.000000e+02
> mean(f)
[1] 22.03256

which is rather different

0
On

It's not true that $f_k$ represents your expected value.

$2f_k = (f_{k-1}+1) + \frac{1}{f_{k-1}}$

$f_1 = 100$, so $f_2 = 50.505$, $f_3 \approx 25.763$.

But your expected value after two plays is

$\frac{102 + \frac{1}{101} + (1 + \frac{1}{100}) + 100}{4} \approx 50.755$