Guide

Equations

Polynomial equations, systems and inequalities solved completely, and certified roots of other equations in an interval.

Before I solve anything, I ask myself whether I need every solution or one root in a particular interval. For a polynomial equation or system, SymLean gives every real solution, and the theorem says that the printed list holds all of them, so nothing is missing. That completeness is the important part. Rational solutions are exact. An irrational one is a closed form such as 2 in solve, or it is named by an interval that holds exactly one solution. An inequality is reduced to a union of intervals. And for an equation with other functions, such as cosx=x, I ask for a certified root in an interval.

Exact solutions

  • solveEvery real solution of a polynomial equation or system, with a theorem that the list is complete.
  • reduceA polynomial equation or inequality reduced to an equivalent union of intervals, with a theorem.

Roots

  • rootsEvery real or complex root of a polynomial equation, exact or enclosed, with a theorem that the list is complete.
  • findRootA certified simple root of a function in an interval, to a chosen number of decimals, with a uniqueness theorem.

Newton showed his method on this cubic. It has one real solution, and the theorem says that there are no others. The decimal is truncated to 20 places, and the theorem puts the root in a rational interval of width 10−20:

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

No algebra solves this next equation, so I ask for a root in [0,1]. The theorem says that exactly one solution lies within 10−10 of the printed value:

In[2]:=
#cas [findRoot x in [0, 1]] (cos x = x)
Out[2]=

certified simple root

x=0.7390851332±10−10
x = 0.7390851332 ± 10^-10
Domain
x ∈ [0, 1]
Input (equation in ℝ)
(cos x = x)

Checked by Lean’s kernel: Unique root in the interval

∃! x, x ∈ Set.Icc (7390851331 / 10 ^ 10) (7390851333 / 10 ^ 10) ∧ Real.cos x = x
The certificate: 1 checked step
  1. Unique root in the interval

    ∃! x, x ∈ Set.Icc (7390851331 / 10 ^ 10) (7390851333 / 10 ^ 10) ∧ Real.cos x = x

    Checked by Lean’s kernel

The computation
  • Certified root

    Sign change found by interval sampling and bisection (not proof)
    Unique root in [0.7390851331, 0.7390851333], within 10^-10 of 0.7390851332: endpoint signs and a derivative of one sign, checked by the kernel

The exact modes stop at polynomials. solve and roots take polynomial equations with rational coefficients, reduce takes polynomial relations and quotients compared with 0, and for other equations findRoot is the mode. A nonlinear system goes through a Gröbner basis and needs finitely many complex solutions, so a circle on its own is refused. findRoot finds one simple root at a time. It samples the function at 65 points of the interval and narrows the first sign change from the left, and then the kernel checks opposite signs at the ends of a small interval and a derivative of one sign on it. That’s also where it stops. It refuses a double root, or any root where the derivative vanishes, two roots closer than the sample spacing, and a sign change across a pole. For a polynomial with a multiple root, roots is the mode to use.

The report of a nonlinear system, as on the solve page, uses three words that need a gloss. solve looks for a lexicographic Gröbner basis in shape position: one polynomial R(t) in a single quantity t, and for each unknown v an equation v=gv(t) with a polynomial gv. The polynomial R is the eliminant. Its real roots are isolated with a certificate that the kernel checks, and each root gives one solution, read off the equations v=gv(t). The quantity t is one of the unknowns when that gives such a basis. When each unknown takes the same value at two of the solutions, t is a separating form instead: a combination x+cy+c2z+… of the unknowns, tried for c=1,2,…, and the report names it.