# Calculate maximum likelihood function for $\theta$ given data

Say you have a coin A that has probability of $$\theta$$ of landing on heads and a coin B with probability of $$2\theta$$ of landing heads. Then say we flipped A 7 times and the first 5 flips were tails and the last 2 were heads. Then we flipped B 3 times where the first 2 were heads and the last was tails.

The likelihood function (Not totally sure if I did this right):
$$P(Results|\theta) = \theta^2(1-\theta)^5\times(2\theta)^2(1-2\theta)$$

The MLE function can be written as:
$$log(P(Results|\theta)) = 2log(\theta)+5log(1-\theta)+2log(2\theta)+log(1-2\theta)$$
$$\frac{\partial l(\theta)}{\partial \theta} = \frac{2}{\theta}-\frac{5}{1-\theta}+\frac{4}{2\theta}-\frac{2}{1-2\theta}=0$$

Did do this correctly? How can I write the last equation as a function of $$\theta$$

$$\frac4\theta=\frac{5}{1-\theta}+\frac2{1-2\theta}$$
$$4(1-\theta)(1-2\theta)=5\theta(1-2\theta)+2\theta(1-\theta)$$
$$8\theta^2-12\theta+4=-12\theta^2+7\theta$$
$$20\theta^2-19\theta+4=0$$
To find $$\theta$$, you just have to solve the quadratic equation and note that since $$2\theta \le 1$$, we have $$\theta \le \frac12$$.