I'm trying to verify a solution to a simple probability problem using Mathematica. Here's the problem:
A drawer contains red socks and black socks. When two socks are drawn at random, the probability that both are red is 1/2. How small can the number of socks in the drawer be if the number of black socks is even?
From manual trial and error, it is trivial to find a solution of red = 15 and black = 6. However, when I try to verify the solution, Minimize
and NMinimize
fails to find an exact solution.
Minimize simply returns without having found a solution.
Minimize[{r + b, Binomial[r, 2]/Binomial[r + b, 2] == 1/2, r > 0,
b > 0, b/2 == i}, {r \[Element] Integers, b \[Element] Integers,
i \[Element] Integers}]
NMinimize throws an NMinimize:nosat
error and proposes a close enough solution of red = 5 and black = 2. The probability works out to be $\frac{\binom{5}{2}}{\binom{7}{2}}=\frac{10}{21}$, which is not exactly 1/2.
NMinimize[{r + b, Binomial[r, 2]/Binomial[r + b, 2] == 1/2, r > 0,
b > 0, b/2 == i}, {r \[Element] Integers, b \[Element] Integers,
i \[Element] Integers}]
Is there something wrong with my setup, or is this a bug? I've tried all Methods
, but neither made a difference