问题
I want to use Complex to calculate the minus pow.
As $(-10)^(1/3)$ that use the Math.Pow will get the NAN.
But when I use Complex.Pow, I can get the result.
Complex c = Complex.Pow(-10, 1.0/3);
var r = c.Magnitude;//2.1544346900318843
But the real result is -2.1544346900318843.
I don't know the result is positive for the Magnitude is Abs.
I can't add -1*
in all the result for the pow can make the result is positive.
(-10)^(2/3)
should get the positive result.
How can I judge the result is positive and To determine whether there is a real solution?
See:https://stackoverflow.com/a/43539898/6116637
--
edit
(-10)^(2/3)
Imaginary 4.0197338438308483 double
Magnitude 4.6415888336127784 double
Phase 2.0943951023931953 double
Real -2.3207944168063883 double
(-10)^(1/3)
Imaginary 1.8657951723620641 double
Magnitude 2.1544346900318843 double
Phase 1.0471975511965976 double
Real 1.0772173450159421 double
How to calculate it,see:https://en.wikipedia.org/wiki/De_Moivre%27s_formula
回答1:
In complex numbers there are three cubical roots for any number.
For negative numbers (negative real part, no imaginary part), the three roots are arranged like this.
X1
/
/
/
/
X2------------0
\
\
\
\
X3
They all have the same magnitude, which is practically the distance from (0,0)==0+i0.
X1 and X3 have the same real part, which is half of the real part of X2.
X1 and X3 have the same absolute value of the imaginary part, with different sign.
X2 has no imaginary part. The real part of X2 is minus the magnitude.
So, the real part of X2, which is negative, is not the magnitude.
The magnitude, by definition, is positive for all of the roots.
Note that the square of the three roots do not necessarily have positive real parts either.
Especially the square of the first root (X1
), being the first in mathematical positive direction, starting at positive real axis.
The square of the complex numbers without imaginary part is positive and has no imaginary part, but that is not true for complex numbers with non-zero imaginary part.
X1^2
\
\
\
\
0------------X2^2
/
/
/
/
X3^2
The attribute "positive" is not defined for compley numbers. It is only defined for each of the two parts, the imaginary part and the real part.
The magnitude of a complex number is always >=0. But the magnitude is not neccessarily identical to the square of the complex number (or the square root of the square).
There are two square roots for each complex number. Since they are 180° apart, one of them will always have negative real part, the other positive real part, or both are zero.
Whether there is one or more roots with zero imaginary part and positive real part (which seems to be what you mean when saying "positive") is something you will have to check by inspecting each of them. You can do that by getting all the powers 1..N-1 of the first root (which is the result for X^(1/N)). At least I do not know a shortcut for that.
Note that (as a comment made me aware) the numbers calculated are not the roots, but they have the same phase and therefor allow judging.
回答2:
This is getting into maths territory a bit too much for my comfort, but a magnitude will always be positive, as it is an Absolute value. A magnitude on it's own has no valuable meaning in the context of Complex number, because it includes an infinite number of points on a circle of radius r=2.1544...
in this case.
Instead, you need to use both the Magnitude and the Argument (angle), or you can use the Real and Imaginary components.
If the angle is between -90° and 90° (0° is at the Real axis, going counter clockwise), then the Real component is positive, for angles between 0° and 180° the Imaginary component is positive
回答3:
There are two typical ways represent a complex number--either in Cartesian form or polar form.
Cartesian Form
c = real + imaginary * i
Polar Form
c = r * exp(i * theta)
The r
here is the magnitude (c.Magnitude
) and is one component that along with the angle (c.Phase
) describes a point in the complex plane.
No ordering is defined on the complex set of numbers. You can ask if the real portion is positive. Alternatively you can ask if the imaginary component is positive.
c.Real > 0
c.Imaginary > 0
来源:https://stackoverflow.com/questions/43602038/how-to-know-the-result-of-complex-has-one-or-more-real-roots