In the log utility model the formula solving the St. Petersburg paradox
$$\Delta E(U)=\sum_{k=1}^\infty \frac{1}{2^k}\left [\ln(w + 2^k - c) - \ln(w) \right ]$$
relates the wealth, $w,$ of the individual to how much they should be able to pay to enter the game, $c.$ The $\Delta E(U)$ should be positive.
The question is whether this $c$ value can be calculated in close form (using geometric series), or whether there is a need for numeric optimization.
For instance, the Wikipedia article states
For example, with natural log utility, a millionaire ($\$1,000,000$) should be willing to pay up to $\$20.88,$ a person with $\$1,000$ should pay up to $\$10.95,$ a person with $\$2$ should borrow $\$1.35$ and pay up to $\$3.35.$
How are these values calculated?
CODE OF THE FUNCTIONS IN THE ACCEPTED ANSWER IN R STATS:
E = function(w, c, epsilon){
ans = 0
k = 1
while(abs(val <- (log(max(epsilon, w + 2^k - c)) - log(w)) / 2^k) > epsilon){
k <- k + 1; ans <- ans + val
if(abs(val) < epsilon) break
}
ans
}
find_c = function(w, epsilon=10^(-10)){
lo = 0
c = 0
hi = 10^10
while(abs(lo - hi) > epsilon){
c = (hi + lo) / 2
exp_value = E(w, c, epsilon)
ifelse(exp_value > 0, lo <- c, hi <- c)
}
c
}
find_c(10^6); find_c(10^3)
20.8742701188956
10.9538128679429
My guess would be numerical methods. For example, in Python I get the following results, using a sort of binary search to hone in on the value of $c$ that makes the expected value near-$0$:
With results: