Mode of #cas

roots

Every real or complex root of a polynomial equation, exact or enclosed, with a theorem that the list is complete.

#cas [roots x] (lhs = rhs)
lists every real solution of a polynomial equation in x, the rational ones exactly and the others as truncated decimals, and proves that the list is complete.
#cas [roots z in ℂ] (lhs = rhs)
lists every complex solution once, with exact values when all of them are Gaussian rationals and certified enclosures otherwise, and proves that the list is complete.
#cas (digits := d) [roots x] (lhs = rhs)
the same as the first form with d decimals, from 1 to 60.

roots gives you every real solution of a polynomial equation. A rational solution is printed exactly, and an irrational one as a decimal truncated to 20 places, with a rational interval of width at most 10−20 around it in the theorem. For me the important part is the last clause of the theorem, which says that there are no other solutions. So the count in the report is the number of real solutions: when it says a cubic has one real root, it has one, and not one that a numerical method happened to find.

With in ℂ the list has the complex solutions too. When all of them are Gaussian rationals, such as i or 1/2+i/2, they are exact. Otherwise each real one has an interval, and each pair of conjugates α±iβ has an interval for α and one for β.

Details and Options

  • For each real solution that is not a printed rational, the report gives a rational interval (l, u) of width at most 10−d whose end nearer to zero is the printed decimal. When the search finds no such decimal interval, the interval is narrower and the report prints it as (l, u). The theorem is the conjunction of ∃! x, x ∈ Set.Ioo l u ∧ lhs = rhs for each interval, of lhs = rhs at each printed rational, and of ∀ x : ℝ, lhs = rhs → (x = r₁ ∨ … ∨ x = rₖ) ∨ x ∈ Set.Ioo l₁ u₁ ∨ …. When rhs is not 0, the theorem writes the equation as lhs - rhs = 0.
  • lhs and rhs are polynomials in x alone with rational coefficients, of any degree. The search of the real form works with cells, intervals with no root or exactly one, and an equation that needs more than 1024 cells is refused. In the real form a polynomial p alone stands for p = 0, and the form with in ℂ takes an equation. Each solution is listed once, whatever its multiplicity. An equation without real solutions gives “no real solutions”.
  • (digits := d), from 1 to 60 and by default 20, is the number of decimals of the enclosed real solutions. The complex form has no options.
  • With in ℂ, for the expanded difference p of the two sides, the theorem is ∀ z : ℂ, p = 0 ↔ z = w₁ ∨ … ∨ z = wₖ when every root is a Gaussian rational. Otherwise it is ∀ z : ℂ, p = 0 ↔ z ∈ [r₁, …, z₁, conj z₁, …], where each real root rᵢ is a CAS.AlgRoot.real number in an interval, and each zᵢ is a CAS.AlgRoot.complex number with intervals for its real and imaginary parts.
  • In a proof, cas proves bounds on a real root, such as ∃ x : ℝ, x ^ 3 - 2 * x - 5 = 0 ∧ 2 < x ∧ x < 3, and counts of real roots Fintype.card (p.rootSet ℝ) = n for p : ℚ[X].

Examples (19)#

Basic Examples (3)

The cubic on which Newton showed his method, with its only real solution:

In[1]:=
#cas [roots x] (x^3 - 2*x - 5 = 0)
Out[1]=

the only real solution, by 20 decimals, truncated

2.09455148154232659148
Input (polynomial equation)
(x^3 - 2*x - 5 = 0)

Checked by Lean’s kernel: Complete list of real solutions

(∃! x,
    x ∈ Set.Ioo (209455148154232659148 / 10 ^ 20) (209455148154232659149 / 10 ^ 20) ∧ x ^ 3 - 2 * x - 5 = 0) ∧
  ∀ (x : ℝ),
    x ^ 3 - 2 * x - 5 = 0 → x ∈ Set.Ioo (209455148154232659148 / 10 ^ 20) (209455148154232659149 / 10 ^ 20)

from CAS.Polynomial.RealRoot.of_exprRootCheck

The certificate: 1 checked step
  1. Complete list of real solutions

    (∃! x,
        x ∈ Set.Ioo (209455148154232659148 / 10 ^ 20) (209455148154232659149 / 10 ^ 20) ∧ x ^ 3 - 2 * x - 5 = 0) ∧
      ∀ (x : ℝ),
        x ^ 3 - 2 * x - 5 = 0 → x ∈ Set.Ioo (209455148154232659148 / 10 ^ 20) (209455148154232659149 / 10 ^ 20)

    Checked by Lean’s kernel · CAS.Polynomial.RealRoot.of_exprRootCheck

The computation
  • Certified isolation

    Square-free polynomial of degree 3, Cauchy bound 8, 6 cells
    Guarantee: the listed solutions are distinct, each rational is a solution, each decimal interval contains exactly one solution, and there are no other real solutions

Rational and irrational solutions together. The double root 1 is listed once:

In[2]:=
#cas [roots x] ((x - 1)^2 * (x + 2) * (x^2 - 2))
Out[2]=

all 4 real solutions; enclosed ones by 20 decimals, truncated

−2,1,−1.41421356237309504880,1.41421356237309504880
-2, 1, -1.41421356237309504880, 1.41421356237309504880
Input (polynomial equation)
((x - 1)^2 * (x + 2) * (x^2 - 2))

Checked by Lean’s kernel: Complete list of real solutions

((∃! x,
      x ∈ Set.Ioo (-141421356237309504881 / 10 ^ 20) (-141421356237309504880 / 10 ^ 20) ∧
        (x - 1) ^ 2 * (x + 2) * (x ^ 2 - 2) = 0) ∧
    ∃! x,
      x ∈ Set.Ioo (141421356237309504880 / 10 ^ 20) (141421356237309504881 / 10 ^ 20) ∧
        (x - 1) ^ 2 * (x + 2) * (x ^ 2 - 2) = 0) ∧
  ((-2 - 1) ^ 2 * (-2 + 2) * ((-2) ^ 2 - 2) = 0 ∧ (1 - 1) ^ 2 * (1 + 2) * (1 ^ 2 - 2) = 0) ∧
    ∀ (x : ℝ),
      (x - 1) ^ 2 * (x + 2) * (x ^ 2 - 2) = 0 →
        (x = -2 ∨ x = 1) ∨
          x ∈ Set.Ioo (-141421356237309504881 / 10 ^ 20) (-141421356237309504880 / 10 ^ 20) ∨
            x ∈ Set.Ioo (141421356237309504880 / 10 ^ 20) (141421356237309504881 / 10 ^ 20)

from CAS.Polynomial.RealRoot.of_exprRootCheck

The certificate: 1 checked step
  1. Complete list of real solutions

    ((∃! x,
          x ∈ Set.Ioo (-141421356237309504881 / 10 ^ 20) (-141421356237309504880 / 10 ^ 20) ∧
            (x - 1) ^ 2 * (x + 2) * (x ^ 2 - 2) = 0) ∧
        ∃! x,
          x ∈ Set.Ioo (141421356237309504880 / 10 ^ 20) (141421356237309504881 / 10 ^ 20) ∧
            (x - 1) ^ 2 * (x + 2) * (x ^ 2 - 2) = 0) ∧
      ((-2 - 1) ^ 2 * (-2 + 2) * ((-2) ^ 2 - 2) = 0 ∧ (1 - 1) ^ 2 * (1 + 2) * (1 ^ 2 - 2) = 0) ∧
        ∀ (x : ℝ),
          (x - 1) ^ 2 * (x + 2) * (x ^ 2 - 2) = 0 →
            (x = -2 ∨ x = 1) ∨
              x ∈ Set.Ioo (-141421356237309504881 / 10 ^ 20) (-141421356237309504880 / 10 ^ 20) ∨
                x ∈ Set.Ioo (141421356237309504880 / 10 ^ 20) (141421356237309504881 / 10 ^ 20)

    Checked by Lean’s kernel · CAS.Polynomial.RealRoot.of_exprRootCheck

The computation
  • Certified isolation

    2 rational roots split off; square-free remaining factor of degree 2, Cauchy bound 3, 4 cells
    Guarantee: the listed solutions are distinct, each rational is a solution, each decimal interval contains exactly one solution, and there are no other real solutions

Complex roots that are Gaussian rationals are exact:

In[3]:=
#cas [roots z in ℂ] (z ^ 2 + 1 = 0)
Out[3]=

all 2 distinct complex roots

i,−i
i, -i
Domain
z ∈ ℂ
Input (polynomial equation with rational coefficients)
(z ^ 2 + 1 = 0)

Checked by Lean’s kernel: The complex roots and no other root

∀ (z : ℂ), z ^ 2 + 1 = 0 ↔ z = Complex.I ∨ z = -Complex.I
The certificate: 1 checked step
  1. The complex roots and no other root

    ∀ (z : ℂ), z ^ 2 + 1 = 0 ↔ z = Complex.I ∨ z = -Complex.I

    Checked by Lean’s kernel

Scope (7)

A polynomial alone stands for the equation p=0:

In[4]:=
#cas [roots x] (x^5 - x - 1)
Out[4]=

the only real solution, by 20 decimals, truncated

1.16730397826141868425
Input (polynomial equation)
(x^5 - x - 1)

Checked by Lean’s kernel: Complete list of real solutions

(∃! x,
    x ∈ Set.Ioo (116730397826141868425 / 10 ^ 20) (116730397826141868426 / 10 ^ 20) ∧ x ^ 5 - x - 1 = 0) ∧
  ∀ (x : ℝ), x ^ 5 - x - 1 = 0 → x ∈ Set.Ioo (116730397826141868425 / 10 ^ 20) (116730397826141868426 / 10 ^ 20)

from CAS.Polynomial.RealRoot.of_exprRootCheck

The certificate: 1 checked step
  1. Complete list of real solutions

    (∃! x,
        x ∈ Set.Ioo (116730397826141868425 / 10 ^ 20) (116730397826141868426 / 10 ^ 20) ∧ x ^ 5 - x - 1 = 0) ∧
      ∀ (x : ℝ), x ^ 5 - x - 1 = 0 → x ∈ Set.Ioo (116730397826141868425 / 10 ^ 20) (116730397826141868426 / 10 ^ 20)

    Checked by Lean’s kernel · CAS.Polynomial.RealRoot.of_exprRootCheck

The computation
  • Certified isolation

    Square-free polynomial of degree 5, Cauchy bound 3, 7 cells
    Guarantee: the listed solutions are distinct, each rational is a solution, each decimal interval contains exactly one solution, and there are no other real solutions

Only rational solutions:

In[5]:=
#cas [roots x] ((x-1)*(x-2)*(x-3)*(x-4) = 0)
Out[5]=

all 4 real solutions

1,2,3,4
1, 2, 3, 4
Input (polynomial equation)
((x-1)*(x-2)*(x-3)*(x-4) = 0)

Checked by Lean’s kernel: Complete list of real solutions

((1 - 1) * (1 - 2) * (1 - 3) * (1 - 4) = 0 ∧
    (2 - 1) * (2 - 2) * (2 - 3) * (2 - 4) = 0 ∧
      (3 - 1) * (3 - 2) * (3 - 3) * (3 - 4) = 0 ∧ (4 - 1) * (4 - 2) * (4 - 3) * (4 - 4) = 0) ∧
  ∀ (x : ℝ), (x - 1) * (x - 2) * (x - 3) * (x - 4) = 0 → x = 1 ∨ x = 2 ∨ x = 3 ∨ x = 4

from CAS.Polynomial.RealRoot.of_exprRootCheck

The certificate: 1 checked step
  1. Complete list of real solutions

    ((1 - 1) * (1 - 2) * (1 - 3) * (1 - 4) = 0 ∧
        (2 - 1) * (2 - 2) * (2 - 3) * (2 - 4) = 0 ∧
          (3 - 1) * (3 - 2) * (3 - 3) * (3 - 4) = 0 ∧ (4 - 1) * (4 - 2) * (4 - 3) * (4 - 4) = 0) ∧
      ∀ (x : ℝ), (x - 1) * (x - 2) * (x - 3) * (x - 4) = 0 → x = 1 ∨ x = 2 ∨ x = 3 ∨ x = 4

    Checked by Lean’s kernel · CAS.Polynomial.RealRoot.of_exprRootCheck

The computation
  • Certified isolation

    4 rational roots split off; the remaining factor is constant
    Guarantee: the listed solutions are distinct, each rational is a solution, each decimal interval contains exactly one solution, and there are no other real solutions

No real solutions:

In[6]:=
#cas [roots x] (x^2 + 1)
Out[6]=

complete list of real solutions

no real solutions
Input (polynomial equation)
(x^2 + 1)

Checked by Lean’s kernel: Complete list of real solutions

∀ (x : ℝ), x ^ 2 + 1 = 0 → False

from CAS.Polynomial.RealRoot.of_exprRootCheck

The certificate: 1 checked step
  1. Complete list of real solutions

    ∀ (x : ℝ), x ^ 2 + 1 = 0 → False

    Checked by Lean’s kernel · CAS.Polynomial.RealRoot.of_exprRootCheck

The computation
  • Certified isolation

    Square-free polynomial of degree 2, Cauchy bound 2, 1 cell
    Guarantee: the listed solutions are distinct, each rational is a solution, each decimal interval contains exactly one solution, and there are no other real solutions

Rational solutions are exact, however small:

In[7]:=
#cas [roots x] (x^2 = 1/10^30)
Out[7]=

all 2 real solutions

−11000000000000000,11000000000000000
-1/1000000000000000, 1/1000000000000000
Input (polynomial equation)
(x^2 = 1/10^30)

Checked by Lean’s kernel: Complete list of real solutions

((-1 / 1000000000000000) ^ 2 - 1 / 10 ^ 30 = 0 ∧ (1 / 1000000000000000) ^ 2 - 1 / 10 ^ 30 = 0) ∧
  ∀ (x : ℝ), x ^ 2 - 1 / 10 ^ 30 = 0 → x = -1 / 1000000000000000 ∨ x = 1 / 1000000000000000

from CAS.Polynomial.RealRoot.of_exprRootCheck

The certificate: 1 checked step
  1. Complete list of real solutions

    ((-1 / 1000000000000000) ^ 2 - 1 / 10 ^ 30 = 0 ∧ (1 / 1000000000000000) ^ 2 - 1 / 10 ^ 30 = 0) ∧
      ∀ (x : ℝ), x ^ 2 - 1 / 10 ^ 30 = 0 → x = -1 / 1000000000000000 ∨ x = 1 / 1000000000000000

    Checked by Lean’s kernel · CAS.Polynomial.RealRoot.of_exprRootCheck

The computation
  • Certified isolation

    2 rational roots split off; the remaining factor is constant
    Guarantee: the listed solutions are distinct, each rational is a solution, each decimal interval contains exactly one solution, and there are no other real solutions

Complex roots with rational real and imaginary parts:

In[8]:=
#cas [roots z in ℂ] (2 * z ^ 2 - 2 * z + 1 = 0)
Out[8]=

all 2 distinct complex roots

12+12i,12−12i
1/2 + 1/2*i, 1/2 - 1/2*i
Domain
z ∈ ℂ
Input (polynomial equation with rational coefficients)
(2 * z ^ 2 - 2 * z + 1 = 0)

Checked by Lean’s kernel: The complex roots and no other root

∀ (z : ℂ),
  2 * z ^ 2 - 2 * z + 1 = 0 ↔ z = 1 / 2 + 1 / 2 * Complex.I ∨ z = 1 / 2 - 1 / 2 * Complex.I
The certificate: 1 checked step
  1. The complex roots and no other root

    ∀ (z : ℂ),
      2 * z ^ 2 - 2 * z + 1 = 0 ↔ z = 1 / 2 + 1 / 2 * Complex.I ∨ z = 1 / 2 - 1 / 2 * Complex.I

    Checked by Lean’s kernel

In[9]:=
#cas [roots z in ℂ] ((z - 1) ^ 3 * (z ^ 2 + 1) = 0)
Out[9]=

all 3 distinct complex roots

1,i,−i
1, i, -i
Domain
z ∈ ℂ
Input (polynomial equation with rational coefficients)
((z - 1) ^ 3 * (z ^ 2 + 1) = 0)

Checked by Lean’s kernel: The complex roots and no other root

∀ (z : ℂ),
  z ^ 5 - 3 * z ^ 4 + 4 * z ^ 3 - 4 * z ^ 2 + 3 * z - 1 = 0 ↔ z = 1 ∨ z = Complex.I ∨ z = -Complex.I
The certificate: 1 checked step
  1. The complex roots and no other root

    ∀ (z : ℂ),
      z ^ 5 - 3 * z ^ 4 + 4 * z ^ 3 - 4 * z ^ 2 + 3 * z - 1 = 0 ↔ z = 1 ∨ z = Complex.I ∨ z = -Complex.I

    Checked by Lean’s kernel


Enclosed complex roots, two pairs of conjugates:

In[10]:=
#cas [roots z in ℂ] (z ^ 4 + 1 = 0)
Out[10]=

all 4 distinct complex roots, by certified enclosures

z₁, conj z₁ = α ± iβ, α ∈ [-0.70710680, -0.70710676], β ∈ [0.70710676, 0.70710680], z₂, conj z₂ = α ± iβ, α ∈ [0.70710676, 0.70710680], β ∈ [0.70710676, 0.70710680]
Domain
z ∈ ℂ
Input (polynomial equation with rational coefficients)
(z ^ 4 + 1 = 0)

Checked by Lean’s kernel: The complex roots, by certified enclosures, and no other root

let z₁ := CAS.AlgRoot.complex [1, 0, 0, 0, 1] (-0.70710678) 0.70710678 2e-8;
let z₂ := CAS.AlgRoot.complex [1, 0, 0, 0, 1] 0.70710678 0.70710678 2e-8;
(z₁.re ∈ Set.Icc (-0.70710680) (-0.70710676) ∧ z₁.im ∈ Set.Icc 0.70710676 0.70710680) ∧
  (z₂.re ∈ Set.Icc 0.70710676 0.70710680 ∧ z₂.im ∈ Set.Icc 0.70710676 0.70710680) ∧
    ∀ (z : ℂ), z ^ 4 + 1 = 0 ↔ z ∈ [z₁, (starRingEnd ℂ) z₁, z₂, (starRingEnd ℂ) z₂]
The certificate: 1 checked step
  1. The complex roots, by certified enclosures, and no other root

    let z₁ := CAS.AlgRoot.complex [1, 0, 0, 0, 1] (-0.70710678) 0.70710678 2e-8;
    let z₂ := CAS.AlgRoot.complex [1, 0, 0, 0, 1] 0.70710678 0.70710678 2e-8;
    (z₁.re ∈ Set.Icc (-0.70710680) (-0.70710676) ∧ z₁.im ∈ Set.Icc 0.70710676 0.70710680) ∧
      (z₂.re ∈ Set.Icc 0.70710676 0.70710680 ∧ z₂.im ∈ Set.Icc 0.70710676 0.70710680) ∧
        ∀ (z : ℂ), z ^ 4 + 1 = 0 ↔ z ∈ [z₁, (starRingEnd ℂ) z₁, z₂, (starRingEnd ℂ) z₂]

    Checked by Lean’s kernel


One real root and one pair of conjugates:

In[11]:=
#cas [roots z in ℂ] (z ^ 3 = 2)
Out[11]=

all 3 distinct complex roots, by certified enclosures

r₁ ∈ (1.25992104, 1.25992106), z₁, conj z₁ = α ± iβ, α ∈ [-0.62996054, -0.62996050], β ∈ [1.09112362, 1.09112366]
Domain
z ∈ ℂ
Input (polynomial equation with rational coefficients)
(z ^ 3 = 2)

Checked by Lean’s kernel: The complex roots, by certified enclosures, and no other root

let r₁ := CAS.AlgRoot.real [-2, 0, 0, 1] 1.25992104 1.25992106;
let z₁ := CAS.AlgRoot.complex [-2, 0, 0, 1] (-0.62996052) 1.09112364 2e-8;
r₁ ∈ Set.Ioo 1.25992104 1.25992106 ∧
  (z₁.re ∈ Set.Icc (-0.62996054) (-0.62996050) ∧ z₁.im ∈ Set.Icc 1.09112362 1.09112366) ∧
    ∀ (z : ℂ), z ^ 3 - 2 = 0 ↔ z ∈ [↑r₁, z₁, (starRingEnd ℂ) z₁]
The certificate: 1 checked step
  1. The complex roots, by certified enclosures, and no other root

    let r₁ := CAS.AlgRoot.real [-2, 0, 0, 1] 1.25992104 1.25992106;
    let z₁ := CAS.AlgRoot.complex [-2, 0, 0, 1] (-0.62996052) 1.09112364 2e-8;
    r₁ ∈ Set.Ioo 1.25992104 1.25992106 ∧
      (z₁.re ∈ Set.Icc (-0.62996054) (-0.62996050) ∧ z₁.im ∈ Set.Icc 1.09112362 1.09112366) ∧
        ∀ (z : ℂ), z ^ 3 - 2 = 0 ↔ z ∈ [↑r₁, z₁, (starRingEnd ℂ) z₁]

    Checked by Lean’s kernel

Options (1)

(digits := 40) gives 40 decimals, with intervals of width 10−40:

In[12]:=
#cas (digits := 40) [roots x] (x^2 = 2)
Out[12]=

all 2 real solutions; enclosed ones by 40 decimals, truncated

−1.4142135623730950488016887242096980785696,1.4142135623730950488016887242096980785696
-1.4142135623730950488016887242096980785696, 1.4142135623730950488016887242096980785696
Input (polynomial equation)
(x^2 = 2)

Checked by Lean’s kernel: Complete list of real solutions

((∃! x,
      x ∈
          Set.Ioo (-14142135623730950488016887242096980785697 / 10 ^ 40)
            (-14142135623730950488016887242096980785696 / 10 ^ 40) ∧
        x ^ 2 - 2 = 0) ∧
    ∃! x,
      x ∈
          Set.Ioo (14142135623730950488016887242096980785696 / 10 ^ 40)
            (14142135623730950488016887242096980785697 / 10 ^ 40) ∧
        x ^ 2 - 2 = 0) ∧
  ∀ (x : ℝ),
    x ^ 2 - 2 = 0 →
      x ∈
          Set.Ioo (-14142135623730950488016887242096980785697 / 10 ^ 40)
            (-14142135623730950488016887242096980785696 / 10 ^ 40) ∨
        x ∈
          Set.Ioo (14142135623730950488016887242096980785696 / 10 ^ 40)
            (14142135623730950488016887242096980785697 / 10 ^ 40)

from CAS.Polynomial.RealRoot.of_exprRootCheck

The certificate: 1 checked step
  1. Complete list of real solutions

    ((∃! x,
          x ∈
              Set.Ioo (-14142135623730950488016887242096980785697 / 10 ^ 40)
                (-14142135623730950488016887242096980785696 / 10 ^ 40) ∧
            x ^ 2 - 2 = 0) ∧
        ∃! x,
          x ∈
              Set.Ioo (14142135623730950488016887242096980785696 / 10 ^ 40)
                (14142135623730950488016887242096980785697 / 10 ^ 40) ∧
            x ^ 2 - 2 = 0) ∧
      ∀ (x : ℝ),
        x ^ 2 - 2 = 0 →
          x ∈
              Set.Ioo (-14142135623730950488016887242096980785697 / 10 ^ 40)
                (-14142135623730950488016887242096980785696 / 10 ^ 40) ∨
            x ∈
              Set.Ioo (14142135623730950488016887242096980785696 / 10 ^ 40)
                (14142135623730950488016887242096980785697 / 10 ^ 40)

    Checked by Lean’s kernel · CAS.Polynomial.RealRoot.of_exprRootCheck

The computation
  • Certified isolation

    Square-free polynomial of degree 2, Cauchy bound 3, 6 cells
    Guarantee: the listed solutions are distinct, each rational is a solution, each decimal interval contains exactly one solution, and there are no other real solutions

Applications (2)

Bounds on a root in a proof. cas proves them, and only the three standard axioms are used:

In[13]:=
theorem roots_cubic : ∃ x : ℝ, x ^ 3 - 2 * x - 5 = 0 ∧ 2 < x ∧ x < 3 := by
  cas

#print axioms roots_cubic
Out[13]=

roots_cubic depends on the axioms propext, Classical.choice, Quot.sound.


A count of real roots, for a polynomial over ℚ:

In[14]:=
open Polynomial in
example : Fintype.card ((X ^ 5 - 4 * X + 2 : ℚ[X]).rootSet ℝ) = 3 := by
  cas
Out[14]=

Lean accepts the proof.

Properties and Relations (1)

The real root of z5−z−1 among its complex roots is the one that the real form finds above:

In[15]:=
#cas [roots z in ℂ] (z ^ 5 - z - 1 = 0)
Out[15]=

all 5 distinct complex roots, by certified enclosures

r₁ ∈ (1.16730397, 1.16730399), z₁, conj z₁ = α ± iβ, α ∈ [-0.76488445, -0.76488441], β ∈ [0.35247153, 0.35247157], z₂, conj z₂ = α ± iβ, α ∈ [0.18123242, 0.18123246], β ∈ [1.08395408, 1.08395412]
Domain
z ∈ ℂ
Input (polynomial equation with rational coefficients)
(z ^ 5 - z - 1 = 0)

Checked by Lean’s kernel: The complex roots, by certified enclosures, and no other root

let r₁ := CAS.AlgRoot.real [-1, -1, 0, 0, 0, 1] 1.16730397 1.16730399;
let z₁ := CAS.AlgRoot.complex [-1, -1, 0, 0, 0, 1] (-0.76488443) 0.35247155 2e-8;
let z₂ := CAS.AlgRoot.complex [-1, -1, 0, 0, 0, 1] 0.18123244 1.08395410 2e-8;
r₁ ∈ Set.Ioo 1.16730397 1.16730399 ∧
  (z₁.re ∈ Set.Icc (-0.76488445) (-0.76488441) ∧ z₁.im ∈ Set.Icc 0.35247153 0.35247157) ∧
    (z₂.re ∈ Set.Icc 0.18123242 0.18123246 ∧ z₂.im ∈ Set.Icc 1.08395408 1.08395412) ∧
      ∀ (z : ℂ), z ^ 5 - z - 1 = 0 ↔ z ∈ [↑r₁, z₁, (starRingEnd ℂ) z₁, z₂, (starRingEnd ℂ) z₂]
The certificate: 1 checked step
  1. The complex roots, by certified enclosures, and no other root

    let r₁ := CAS.AlgRoot.real [-1, -1, 0, 0, 0, 1] 1.16730397 1.16730399;
    let z₁ := CAS.AlgRoot.complex [-1, -1, 0, 0, 0, 1] (-0.76488443) 0.35247155 2e-8;
    let z₂ := CAS.AlgRoot.complex [-1, -1, 0, 0, 0, 1] 0.18123244 1.08395410 2e-8;
    r₁ ∈ Set.Ioo 1.16730397 1.16730399 ∧
      (z₁.re ∈ Set.Icc (-0.76488445) (-0.76488441) ∧ z₁.im ∈ Set.Icc 0.35247153 0.35247157) ∧
        (z₂.re ∈ Set.Icc 0.18123242 0.18123246 ∧ z₂.im ∈ Set.Icc 1.08395408 1.08395412) ∧
          ∀ (z : ℂ), z ^ 5 - z - 1 = 0 ↔ z ∈ [↑r₁, z₁, (starRingEnd ℂ) z₁, z₂, (starRingEnd ℂ) z₂]

    Checked by Lean’s kernel

Possible Issues (4)

An identity has every real number as a solution, so there is no list:

In[16]:=
#cas [roots x] (x = x)
Out[16]=

Error

the polynomial is zero; every real number is a solution

The input is an equation. For the roots of a polynomial p, write p = 0:

In[17]:=
#cas [roots z in ℂ] (z ^ 2 + 1)
Out[17]=

Error

roots: expected an equation p = q

Only polynomial equations. For other equations, findRoot certifies one root in an interval:

In[18]:=
#cas [roots x] (sin x = 0)
Out[18]=

Error

roots supports polynomial equations with rational coefficients

At most 60 decimals:

In[19]:=
#cas (digits := 61) [roots x] (x^2 = 2)
Out[19]=

Error

roots accepts between 1 and 60 digits

Neat Examples (1)

The sixth roots of unity, two real and two pairs of conjugates:

In[20]:=
#cas [roots z in ℂ] (z ^ 6 = 1)
Out[20]=

all 6 distinct complex roots, by certified enclosures

r₁ ∈ (-1.00000001, -0.99999999), r₂ ∈ (0.99999999, 1.00000001), z₁, conj z₁ = α ± iβ, α ∈ [-0.50000002, -0.49999998], β ∈ [0.86602538, 0.86602542], z₂, conj z₂ = α ± iβ, α ∈ [0.49999998, 0.50000002], β ∈ [0.86602538, 0.86602542]
Domain
z ∈ ℂ
Input (polynomial equation with rational coefficients)
(z ^ 6 = 1)

Checked by Lean’s kernel: The complex roots, by certified enclosures, and no other root

let r₁ := CAS.AlgRoot.real [-1, 0, 0, 0, 0, 0, 1] (-1.00000001) (-0.99999999);
let r₂ := CAS.AlgRoot.real [-1, 0, 0, 0, 0, 0, 1] 0.99999999 1.00000001;
let z₁ := CAS.AlgRoot.complex [-1, 0, 0, 0, 0, 0, 1] (-0.50000000) 0.86602540 2e-8;
let z₂ := CAS.AlgRoot.complex [-1, 0, 0, 0, 0, 0, 1] 0.50000000 0.86602540 2e-8;
r₁ ∈ Set.Ioo (-1.00000001) (-0.99999999) ∧
  r₂ ∈ Set.Ioo 0.99999999 1.00000001 ∧
    (z₁.re ∈ Set.Icc (-0.50000002) (-0.49999998) ∧ z₁.im ∈ Set.Icc 0.86602538 0.86602542) ∧
      (z₂.re ∈ Set.Icc 0.49999998 0.50000002 ∧ z₂.im ∈ Set.Icc 0.86602538 0.86602542) ∧
        ∀ (z : ℂ), z ^ 6 - 1 = 0 ↔ z ∈ [↑r₁, ↑r₂, z₁, (starRingEnd ℂ) z₁, z₂, (starRingEnd ℂ) z₂]
The certificate: 1 checked step
  1. The complex roots, by certified enclosures, and no other root

    let r₁ := CAS.AlgRoot.real [-1, 0, 0, 0, 0, 0, 1] (-1.00000001) (-0.99999999);
    let r₂ := CAS.AlgRoot.real [-1, 0, 0, 0, 0, 0, 1] 0.99999999 1.00000001;
    let z₁ := CAS.AlgRoot.complex [-1, 0, 0, 0, 0, 0, 1] (-0.50000000) 0.86602540 2e-8;
    let z₂ := CAS.AlgRoot.complex [-1, 0, 0, 0, 0, 0, 1] 0.50000000 0.86602540 2e-8;
    r₁ ∈ Set.Ioo (-1.00000001) (-0.99999999) ∧
      r₂ ∈ Set.Ioo 0.99999999 1.00000001 ∧
        (z₁.re ∈ Set.Icc (-0.50000002) (-0.49999998) ∧ z₁.im ∈ Set.Icc 0.86602538 0.86602542) ∧
          (z₂.re ∈ Set.Icc 0.49999998 0.50000002 ∧ z₂.im ∈ Set.Icc 0.86602538 0.86602542) ∧
            ∀ (z : ℂ), z ^ 6 - 1 = 0 ↔ z ∈ [↑r₁, ↑r₂, z₁, (starRingEnd ℂ) z₁, z₂, (starRingEnd ℂ) z₂]

    Checked by Lean’s kernel

See Also

solve · findRoot · reduce · factor · cas