I would like some help on what should be a simple computation that I'm failing to see through to the end. Suppose I have a qubit which can be in the state $|v\rangle$ with probability $p$, or $|w\rangle$ with probability $1-p$. I will choose some unitary basis $|a\rangle, |b\rangle$, and measure the qubit -- if I get $a$ I will guess the state was $v$, and if I get $b$ I will guess the state was $w$. My probability of success is $$S = p|\langle a|v \rangle|^2 + (1-p)|\langle b | w \rangle|^2$$ What I want is to maximize this probability. I can think of $a,b$ as functions of some parameter and apply calculus: $$S' = p 2 \Re(\langle a' | v \rangle \langle v | a \rangle) + (1-p)2\Re(\langle b' | w\rangle \langle w | b\rangle)$$ If we're setting this to $0$ we can ignore the factor of $2$.
Since $\langle a | a \rangle = 1$, differentiating we obtain $\Re\langle a' | a \rangle = 0$, and similarly $\Re\langle b'|b \rangle = 0$.
Writing for now $v = v_a a + v_b b$ we get $\langle v|a \rangle = \overline{v_a}$. Hence $$\Re(\langle a'|v\rangle \langle v|a \rangle) = \Re(v_a \overline{v_a} \langle a'|a \rangle + \overline{v_a}v_b \langle a'|b \rangle)$$ but since $v_a \overline{v_a} = |v_a|^2$ is real and $\langle a' | a \rangle$ is purely imaginary the first term dies and we obtain $\Re(\overline{v_a}v_b \langle a'|b \rangle)$. A similar computation goes for $w$, and in the end we can write
$$0 = S'/2 = \Re(p \overline{v_a}v_b \langle a'|b \rangle + (1-p) w_a \overline{w_b} (-\overline{\langle a'|b \rangle}))$$
where I used $\langle b'|a \rangle = - \overline{\langle a'|b \rangle}$ which is obtained by differentiating the relation $\langle a | b \rangle = 0$.
This is where I get stuck. It feels like I need to combine these terms somehow so some kind of cancellation between the $\langle a'|b \rangle$ and $- \overline{\langle a'|b \rangle}$ terms happen, but I don't see how to do it. Any help is greatly appreciated.
Edit: I realize now we can use $w_a \overline{w_b} = \overline{\overline{w_a}w_b}$ to obtain $$p \Re(\overline{v_a}v_b \langle a'|b \rangle) = (1-p) \Re(\overline{w_a}w_b \langle a'|b \rangle)$$ where I can ignore the conjugate over everything on the right hand side since we're taking the real part.
(What I wrote previously after this did not make sense)