Why can Solve solve this system of expressions but not a similar system?
Is this what you want?
Clear[a, b, c, d, e, f];
eqn = {p^2 == (a d - b c)^2/(Sqrt[(a + b) (c + d) (a + c) (b + d)])^2,
s == (a + c)/(a + b + c + d), h == (a)/(a + c), f == b/(b + d)};
Solve[eqn, {p}, {a, b, c, d}]
(*
{{p -> -(((f - h) Sqrt[-1 + s] Sqrt[s])/
Sqrt[-f + f^2 + f s - 2 f^2 s - h s + 2 f h s + f^2 s^2 - 2 f h s^2 + h^2 s^2])},
{p -> ((f - h) Sqrt[-1 + s] Sqrt[s])/
Sqrt[-f + f^2 + f s - 2 f^2 s - h s + 2 f h s + f^2 s^2 - 2 f h s^2 + h^2 s^2]}}
*)
Even after fixing your error in specifying the equations (your equation for p
involved the variables ad
and bc
instead of the products a d
and b c
), Solve[]
still took its sweet time. We can help Solve[]
out a bit by using GroebnerBasis[]
as a preprocessor, which we can do since we have an algebraic system of equations (no transcendental functions involved). More precisely, we can remove the intermediate variables a
, b
, c
, d
like so:
neq = Simplify[First @
GroebnerBasis[{p == (a d - b c)/(Sqrt[(a + b) (c + d) (a + c) (b + d)]),
s == (a + c)/(a + b + c + d), h == (a)/(a + c),
f == b/(b + d)}, {p, h, s, f}, {a, b, c, d}]]
f^2 (p^2 (-1 + s) - s) (-1 + s) + h s (h - p^2 - h s + h p^2 s) -
f (-1 + s) (-2 h s + p^2 (-1 + 2 h s))
Solve[]
can now be used to solve for p
:
Solve[neq == 0, p] // FullSimplify
{{p -> ((-f + h) Sqrt[-1 + s] Sqrt[s])/Sqrt[(f (-1 + s) - h s) (1 + f (-1 + s) - h s)]},
{p -> ((f - h) Sqrt[-1 + s] Sqrt[s])/Sqrt[(f (-1 + s) - h s) (1 + f (-1 + s) - h s)]}}
where two solutions were returned. Since (you can check this yourself!) h (1 - f) - (1 - h) f == h - f
, the first solution is the desired one.
Unfortunately, the expression within the square root in the original source seems iffy, since (f (-1 + s) - h s) (1 + f (-1 + s) - h s)/(s (s - 1))
doesn't quite simplify to (h/(1 - s) + f/s) ((1 - h)/(1 - s) + (1 - f)/s)
. Checking which of these formulae is sensible to your application is something I'll leave for you to determine.