Definition of a general rule
rule = Sqrt[a_. * expr_^n_?EvenQ] :> expr^(n/2)*Sqrt[a];
expr = {Sqrt[x^2], Sqrt[x^2 * y], Sqrt[x^2*y^2], Sqrt[x^2*y*z],
Sqrt[x^4*y^2 *z]};
Using ReplaceAll
(/.
)
expr /. rule
{x, x Sqrt[y], x Sqrt[y^2], x Sqrt[y z], x^2 Sqrt[y^2 z]}
However, in general ReplaceRepeated
(//.
) is needed
expr //. rule
(* {x, x Sqrt[y], x y, x Sqrt[y z], x^2 y Sqrt[z]} *)
Why not use PowerExpand
:
PowerExpand[Sqrt[x^2 y]]
x Sqrt[y]