As stated in the title, I'm attempting to solve for the first partial derivative for the expected return of a group of wagers in a parimutuel pool.
Wikipedia describes parimutuel betting as "a betting system in which all bets of a particular type are placed together in a pool; taxes and the "house-take" or "vigorish" are deducted, and payoff odds are calculated by sharing the pool among all winning bets."1.
The expected return of a series of potential bets into a parimutuel pool with $N$ combinations can then be calculated by the formula:
$$\sum_{i=1}^N(\frac{Q(W + \sum_{j=1}^Nb_j)}{w_i + b_i} - 1)b_ip_i - (b_i(1 - p_i))$$
where $N$ is the number of combinations, $Q$ is the money returned to bettors by the house after taxes and vig (expressed as a percentage), $W$ is the total money wagered into the pool prior to our proposed bets, $w_i$ and $b_i$ are the money wagered on combination $i$ by the public (not including our wager) and on our wager, respectively (both values are in the range 0+), and $p_i$ is the probability that combination $i$ is the winner.
My first attempt at the partial derivative with respect to $b_i$, after pushing the $b_ip_i$ term into the quotient, was:
$$\frac{Q(Wp_i+\sum_{j\ne i}^N(b_j)p_i+2b_ip_i)(w_i+b_i)-Q(Wb_ip_i+\sum_{j=1}^N(b_j)b_ip_i))}{(w_i+b_i)^2}-1$$
However, I checked the gradient using python's scipy package (scipy.optimize.check_grad), which compares the derived gradient with the numerically estimated gradient. The results were significantly different. After some attempts, I realized I calculated the gradient of the quotient
$$Q(Wb_ip_i + (\sum_{j=1}^Nb_j)b_ip_i)$$
incorrectly. With some help from friends, I was able to solve it as
$$Q(Wp_i+\sum_{j=1}^N(b_jp_i+b_jp_j))$$
However, when I replaced that in the application of the quotient rule from my original attempt, the check_grad result was still significantly different.
At this point, I'm stuck and wondering if pushing the $b_ip_i$ term into the quotient was appropriate given the interaction of $b_i$ in the summation. I'm also wondering if applying the quotient rule to the denominator without considering both $i=j$ and $i \ne j$, is the issue. Any pointers or help would be greatly appreciated!
After bashing my head against a wall for days, I think I've figured it out. The solution I've coded up passes the scipy check_grad test, so I'm fairly confident it's accurate. However, I'm not confident in my ability to convert that to a proper latex formula, so apologies if what's posted below is inaccurate. Please let me know and I'll modify.
It helped to write out some explicit cases for a small number of bets i.e. $N=2$. From there it was clear that what I was missing were a given bet's impact on the ER when considering a separate bet. The $i=k$ vs $i\ne k$ case. There were a couple S/O posts that were useful there (1)(2). The solution is:
$$\sum_{i=1}^N[Q(\frac{(Wp_i+\sum_{j=1}^N(b_jp_i)+b_ip_i)(w_i+b_i)-(Wb_ip_i+\sum_{j=1}^N(b_j)(b_ip_i))}{(w_i + b_i)^2}+\sum_{j\ne i}^N(\frac{b_jp_j}{w_j + b_j})) - 1]$$