ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 08 Apr 2015 10:45:57 +0200Get variants of complex cube-roothttps://ask.sagemath.org/question/10063/get-variants-of-complex-cube-root/I found-out that complex cube-root can have 3 variants (see http://en.wikipedia.org/wiki/Cube_root)
But if I try in SageMath to do
(-1)^(1/3)
SageMath return (-1)^(1/3). When I try
(-1)^(1/3).n()
SageMath gives me numerical approximation of the one root (not real)...
How I can get all variants of complex cube-root without numerical approximation?
Thanks! P.S. Sorry for poor English...Thu, 25 Apr 2013 15:31:30 +0200https://ask.sagemath.org/question/10063/get-variants-of-complex-cube-root/Answer by vdelecroix for <p>I found-out that complex cube-root can have 3 variants (see <a href="http://en.wikipedia.org/wiki/Cube_root">http://en.wikipedia.org/wiki/Cube_root</a>)</p>
<p>But if I try in SageMath to do</p>
<pre><code>(-1)^(1/3)
</code></pre>
<p>SageMath return (-1)^(1/3). When I try</p>
<pre><code>(-1)^(1/3).n()
</code></pre>
<p>SageMath gives me numerical approximation of the one root (not real)...</p>
<p>How I can get all variants of complex cube-root without numerical approximation?</p>
<p>Thanks! P.S. Sorry for poor English...</p>
https://ask.sagemath.org/question/10063/get-variants-of-complex-cube-root/?answer=14845#post-id-14845Or you can alternatively use embeddings of a [number field](http://en.wikipedia.org/wiki/Algebraic_number_field) as follows. I first show the example for the three cube root of 2. The three cube roots are the solution of the polynomial equation $x^3 - 2 = 0$. You then do
sage: R1.<a> = NumberField(x^3 - 2, 'a')
sage: e1,e2,e3 = R.embeddings(QQbar)
sage: a1 = e1(a)
sage: a2 = e2(a)
sage: a3 = e3(a)
sage: a1
-0.6299605249474365? - 1.091123635971722?*I
sage: a1^3
2
sage: a2
-0.6299605249474365? + 1.091123635971722?*I
sage: a2^3
2
sage: a3
1.259921049894873?
sage: a3^3
2
For the roots of -1 it is different because its polynomial equation $x^3 + 1 = (x + 1)(x^2 - x + 1)$ is not [irreducible](http://en.wikipedia.org/wiki/Irreducible_polynomial) over QQ. But using the irreducible factor of degree 2 you can get the cube root as well:
sage: R2.<b> = NumberField(x^2 - x + 1, 'b')
sage: e1,e2 = R2.embeddings(QQbar)
sage: b1 = e1(b)
sage: b2 = e2(b)
sage: b1
0.50000000000000000? - 0.866025403784439?*I
sage: b1^3
-1
sage: b2
0.50000000000000000? + 0.866025403784439?*I
sage: b2^3
-1
The b1 and b2 above are exactly the numbers j and j^2 mentionned in tmonteil post. The advantage of this method is that it works for roots of polynomial equations and not only cubic roots.Thu, 25 Apr 2013 19:15:21 +0200https://ask.sagemath.org/question/10063/get-variants-of-complex-cube-root/?answer=14845#post-id-14845Answer by MvG for <p>I found-out that complex cube-root can have 3 variants (see <a href="http://en.wikipedia.org/wiki/Cube_root">http://en.wikipedia.org/wiki/Cube_root</a>)</p>
<p>But if I try in SageMath to do</p>
<pre><code>(-1)^(1/3)
</code></pre>
<p>SageMath return (-1)^(1/3). When I try</p>
<pre><code>(-1)^(1/3).n()
</code></pre>
<p>SageMath gives me numerical approximation of the one root (not real)...</p>
<p>How I can get all variants of complex cube-root without numerical approximation?</p>
<p>Thanks! P.S. Sorry for poor English...</p>
https://ask.sagemath.org/question/10063/get-variants-of-complex-cube-root/?answer=26464#post-id-26464If you want to find all numbers $x$ which satisfy $x^3=-1$ resp. $x^3+1=0$ you can do
sage: QQ[x](x^3+1).roots(QQbar)
[(-1, 1),
(0.500000000000000? - 0.866025403784439?*I, 1),
(0.500000000000000? + 0.866025403784439?*I, 1)]
The `x^3+1` is a symbolic polynomial using the symbolic variable `x` which is already defined by default, but which you could also define using `var('x')`. The `QQ[x]` defines a polynomial ring with rational coefficients and using `x` as the name for its indeterminate. Using that like a function is a type cast, which will turn the symbolic expression into an element of the polynomial ring. And for elements of polynomial rings, you can compute roots. In particular, you can compute all roots exactly by using the filed of algebraic numbers $\bar{\mathbb Q}$. The resulting list contains tuple: the root followed by its multiplicity.
If you want to see some more details along the way, look at this:
sage: x
x
sage: x.parent()
Symbolic Ring
sage: QQx = QQ[x]; QQx
Univariate Polynomial Ring in x over Rational Field
sage: p1 = x^3 + 1; p1
x^3 + 1
sage: p1.parent()
Symbolic Ring
sage: p2 = QQx(p1); p2
x^3 + 1
sage: p2.parent()
Univariate Polynomial Ring in x over Rational Field
sage: p2.roots(AA) # real only
[(-1.000000000000000?, 1)]
sage: p2.roots(QQbar, multiplicities=False)
[-1,
0.500000000000000? - 0.866025403784439?*I,
0.500000000000000? + 0.866025403784439?*I]
Wed, 08 Apr 2015 10:45:57 +0200https://ask.sagemath.org/question/10063/get-variants-of-complex-cube-root/?answer=26464#post-id-26464Answer by tmonteil for <p>I found-out that complex cube-root can have 3 variants (see <a href="http://en.wikipedia.org/wiki/Cube_root">http://en.wikipedia.org/wiki/Cube_root</a>)</p>
<p>But if I try in SageMath to do</p>
<pre><code>(-1)^(1/3)
</code></pre>
<p>SageMath return (-1)^(1/3). When I try</p>
<pre><code>(-1)^(1/3).n()
</code></pre>
<p>SageMath gives me numerical approximation of the one root (not real)...</p>
<p>How I can get all variants of complex cube-root without numerical approximation?</p>
<p>Thanks! P.S. Sorry for poor English...</p>
https://ask.sagemath.org/question/10063/get-variants-of-complex-cube-root/?answer=14842#post-id-14842Fist, when you write
sage: a = (-1)^(1/3)
you define an element of the `Symbolic Ring`, which is not a safe place:
sage: a.parent()
Symbolic Ring
sage: a^2
1
So it is better to work on `QQbar`, the set of algebraic complex numbers.
sage: a = QQbar(-1)^(1/3)
sage: a.parent()
Algebraic Field
sage: a^2
-0.500000000000000? + 0.866025403784439?*I
Now, if `a` is a cubic root of some complex number (in your case `-1`), the other cube roots are `a*j` and `a*j^2`, where `j=exp(2*I*pi/3)=(-1+I*sqrt(3))/2`. Hence you can define
sage: j = QQbar(-1)^(2/3)
sage: j == QQbar(e^(2*I*pi/3))
True
sage: j == QQbar(-1+I*sqrt(3))/2
True
sage: 1+j+j^2 == 0
True
sage: complex_cube_roots = [a, a*j, a*j^2]
and check
sage: for i in complex_cube_roots:
....: print i, 'whose cube is', i^3
0.500000000000000? + 0.866025403784439?*I whose cube is -1
-1 whose cube is -1
0.500000000000000? - 0.866025403784439?*I whose cube is -1
Thu, 25 Apr 2013 16:03:34 +0200https://ask.sagemath.org/question/10063/get-variants-of-complex-cube-root/?answer=14842#post-id-14842