Solving for $p$ binomcdf$(n,p,k)$=$x$ In Binomial Probability with Unknown p, this is done for a case in which $n=0$, which ends up being a simple solution. With $n > 0$,  things aren't as simple, trying to naively directly solve gets you higher and higher power equations.
E.g. solving $\text{binomcdf}(17,p,8) = 0.3$ (The probability of 8 or less successes is exactly 0.3) is, written out;
$$\sum^{8}_{n=0}\binom{17}{n} p^n(1-p)^{17-n} = 0.3$$
That's a polynomial of a very high degree. What would be a good way to solve or in a numerically stable way approximate the solution to arbitrary precision of such an equation?
In particular, I'm motivated by the following problem:
Let there be $n$ members in a legislature. There are 3 measures suggested to this legislature. The first measure to pass invalidates the others. The legislature unanimously wants one measure to pass with each measure to have an equal chance of passing, but each member only has control over their own vote. In an even-numbered legislature a hung vote means a failed measure.
The members decide on a certain nash-probability $p_1$ for which the chance of passing a measure is $\frac{1}{3}$ and another $p_2$ for a chance of $\frac{1}{2}$, with the last measure always getting a unanimous vote. What are these values?
The solution would be to solve the equations
$$\text{binomcdf}(n,p_1,\lfloor\frac{n}{2}\rfloor) = \sum^{\lfloor\frac{n}{2}\rfloor}_{k=0} \binom{n}{k}p_1^k(1-p_1)^{n-k} = \frac{1}{3}$$
$$\text{binomcdf}(n,p_2,\lfloor\frac{n}{2}\rfloor) = \sum^{\lfloor\frac{n}{2}\rfloor}_{k=0} \binom{n}{k}p_2^k(1-p_2)^{n-k} = \frac{1}{2}$$
for respectively $p_1$ and $p_2$.
For odd values of $n$ and the case where the target probability is $\frac{1}{2}$, there a simple solution, $p_2 = 0.5$, and this is the only answer.
So far I've simply applied a spreadsheet, fiddling with the value of $p_1$ until I get close to the desired chance, but I wonder if a more general method exists.
 A: There will be numerical methods but if you want an approximation where you want a target probability of $t$  [$t=0.3$ in your $\text{binomcdf}(17,p,8) = 0.3$ example] with $k$ or fewer successes from $n$ [$k=8$ and $n=17$ in your example], you could try the normal approximation with a continuity correction to solve
$$\Phi\left(\frac{k+\frac12-np}{\sqrt{np(1-p)}}\right)=t$$ which gives a quadratic with solution  $$p \approx \frac{2\left(k+\frac12\right)+\Phi^{-1}(t)^2 \pm \sqrt{\left(2\left(k+\frac12\right)+\Phi^{-1}(t)^2\right)^2-4\left(n+\Phi^{-1}(t)^2\right)\frac{\left(k+\frac12\right)^2}{n}}}{2\left(n+\Phi^{-1}(t)^2\right)}$$
In your example this gives $ p \approx 0.4369153$ or $0.5630847$.  You want the larger value (choosing $+$ for the $\pm$), as the other is spurious and corresponds to the case starting with $t=0.7$ .
How good is $p \approx 0.5630847$?  Putting it back in the binomial sum gives about $0.2980416$ rather than $0.3$, so not bad in this case.  The exact desired value for $p$ is just over $0.56241865$ so again the approximation is not far off.
A: Concerning the first question, hoping that the solution you are looking for is not close to the bounds, try a series expansion around $p=\frac 12$. This would give for
$$f(p)=\sum^{8}_{n=0}\binom{17}{n} p^n(1-p)^{17-n}$$
$$f(p)=\frac{1}{2}-\frac{109395 }{32768}\left(p-\frac{1}{2}\right)+\frac{36465
  }{1024} \left(p-\frac{1}{2}\right)^3-\frac{153153}{512}
   \left(p-\frac{1}{2}\right)^5+\frac{109395}{64}
   \left(p-\frac{1}{2}\right)^7-\frac{425425}{64} \left(p-\frac{1}{2}\right)^9+O\left(\left(p-\frac{1}{2}\right)^{11}\right)$$ Now, using series reversion the approximation
$$p_{(m)}=\frac 1 2+\sum_{n=1}^m \frac {a_n}{b_n}\left(k-\frac{1}{2}\right)^{2n-1}$$
Trying for $k=\frac 3{10}$ this would give the following estimates
$$\left(
\begin{array}{cc}
m & p_{(m)} \\
 1 & 0.559908 \\
 2 & 0.562201 \\
 3 & 0.562395 \\
 4 & 0.562416
\end{array}
\right)$$ while the "exact" solution is $0.562419$.
A: As Felix Marin points out, we have bounds on when we have $\operatorname{binomcdf}(n,p,k)-t$ changes sign given by $p=0$ and $p=1$, so bracketing methods can safely be tried to get fast and guaranteed convergence. You may want to try Brent's method, Chandrupatla's method, or even the Newton-Raphson method since the derivative is known.
The only issue remaining is you may get slow convergence if the desired value is close to the boundary, where the cdf becomes very flat. This can be done using symmetry along with the asymptotic behavior near either $0$ or $1$. For $0<k<n-1$:
$$\operatorname{binomcdf}(n,p,k)\approx\binom nk(1-p)^{n-k},\quad p\approx1\\\operatorname{binomcdf}(n,p,k)\approx1-\binom n{k+1}p^{k+1},\quad p\approx0$$
For your example of $\operatorname{binomcdf}(17,p,8)=0.3$, these approximations can be solved to give
$$0.313\le p\le0.715$$
which is closer to the more exact $p=0.56241865$.
See here for an implementation using Chandrupatla's method.
