Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

This question already has an answer here:

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?

share|improve this question

marked as duplicate by Artes, Sjoerd C. de Vries, István Zachar, ssch, m_goldberg Sep 26 '13 at 0:43

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
If you read another answers to the question you linked to in your post you wouldn't have asked this one. –  Artes Sep 25 '13 at 21:25

1 Answer 1

up vote 8 down vote accepted

Surd is your friend:

Surd[a/(-2 + a), 3] /. a -> 0.5

-0.693361

It can be entered in formatted form as Esc surd Esc.

enter image description here

Surd was introduced in Mathematica 9. In previous versions you can use

((a/(-2 + a))^(1/3) /. {x_^y_ :> Sign[x] Abs[x]^y}) /. {a -> 0.5}

-0.693361

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.