FullSimplify[Sqrt[1/(a^2 b^2)], Element[{a, b}, Reals]]
gives
Abs[1/(a b)]
How do I simplify the following expression
FullSimplify[Sqrt[(1 + a + b)/(a^2 b^2)], Element[{a, b}, Reals]]
into $\frac{\sqrt{a+b+1}}{\left| a b\right| }$ ?
Answer
While LeafCount
is not the complete ComplexityFunction used by Simplify
it is a good first order approximation, and you can see that your expressions are equivalent under this metric:
expr1 = Sqrt[(1 + a + b)/(a^2 b^2)];
expr2 = Sqrt[a + b + 1]/Abs[a b];
LeafCount /@ {expr1, expr2}
{15, 15}
In your particular case merely using StringLength
works:
FullSimplify[expr1, {a, b} \[Element] Reals,
ComplexityFunction -> (StringLength @ ToString @ # &)]
Sqrt[1 + a + b]/Abs[a b]
Comments
Post a Comment