I have a complicated symbolic expression which contains many terms like $(a/(a-2))^{1/m}$, where $a/(a-2)$ could be positive or negative after replacement.
I only need the real root after replacement, but Power[]
function in Mathematica most of the time gives me a complex number instead. I found something that almost suits my need here (the realPower
function by Peter Breitfeld), but I have a hard time get it working in the way I want.
For example:
((a/(-2 + a))^(1/3) /. {x_^y_ :> realPower[x, y]}) /. {a -> 0.5}
still gives me a complex number. (it seems that realPower
only work with numerical values) What should I do to get only the real root after replacement?