Using MATLAB exponential function:
(-8)^0.333333
ans = 1.0000 + 1.7320i
How to get (-8)^0.333333 = -2 instead?
x=-10:-1;
x.^0.333333
How to get real value?
How to redefine ^:
x.^y
to
sign(x).*abs(x.^y))
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
MATLAB 7.0 provides the
NTHROOTfunction, which returns the real roots of a number. So your formula becomesNTHROOT(-8, 3) = -2If you are using a version prior to MATLAB 7.0 (R14), please read the following:
To obtain the real cube root of a negative real number “x”, rather than executing:
use the command:
This will find the absolute value of the root and modify it by the sign of the argument.
See this