Average Error: 34.1 → 16.5
Time: 25.1s
Precision: 64
Internal Precision: 128
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
\[\begin{array}{l} \mathbf{if}\;b \le 1.476861038724565 \cdot 10^{-78}:\\ \;\;\;\;\frac{1}{\frac{2 \cdot a}{\sqrt{(\left(-4 \cdot a\right) \cdot c + \left(b \cdot b\right))_*} - b}}\\ \mathbf{elif}\;b \le 1.8275672346743634 \cdot 10^{-62}:\\ \;\;\;\;\frac{1}{-\frac{b}{c}}\\ \mathbf{elif}\;b \le 2.98055712028514 \cdot 10^{-51}:\\ \;\;\;\;\frac{\frac{\sqrt{(\left(-4 \cdot a\right) \cdot c + \left(b \cdot b\right))_*} \cdot \sqrt{(\left(-4 \cdot a\right) \cdot c + \left(b \cdot b\right))_*} - b \cdot b}{\sqrt{(\left(-4 \cdot a\right) \cdot c + \left(b \cdot b\right))_*} + b}}{2 \cdot a}\\ \mathbf{elif}\;b \le 1.6977371338282006 \cdot 10^{+36}:\\ \;\;\;\;\frac{c \cdot \left(-4 \cdot a\right)}{\left(2 \cdot a\right) \cdot \left(\sqrt{(\left(-4 \cdot a\right) \cdot c + \left(b \cdot b\right))_*} + b\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{-\frac{b}{c}}\\ \end{array}\]

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 4 regimes
  2. if b < 1.476861038724565e-78

    1. Initial program 21.7

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
    2. Initial simplification21.7

      \[\leadsto \frac{\sqrt{(\left(a \cdot -4\right) \cdot c + \left(b \cdot b\right))_*} - b}{2 \cdot a}\]
    3. Using strategy rm
    4. Applied *-un-lft-identity21.7

      \[\leadsto \frac{\color{blue}{1 \cdot \left(\sqrt{(\left(a \cdot -4\right) \cdot c + \left(b \cdot b\right))_*} - b\right)}}{2 \cdot a}\]
    5. Applied associate-/l*21.8

      \[\leadsto \color{blue}{\frac{1}{\frac{2 \cdot a}{\sqrt{(\left(a \cdot -4\right) \cdot c + \left(b \cdot b\right))_*} - b}}}\]

    if 1.476861038724565e-78 < b < 1.8275672346743634e-62 or 1.6977371338282006e+36 < b

    1. Initial program 55.7

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
    2. Initial simplification55.7

      \[\leadsto \frac{\sqrt{(\left(a \cdot -4\right) \cdot c + \left(b \cdot b\right))_*} - b}{2 \cdot a}\]
    3. Using strategy rm
    4. Applied *-un-lft-identity55.7

      \[\leadsto \frac{\color{blue}{1 \cdot \left(\sqrt{(\left(a \cdot -4\right) \cdot c + \left(b \cdot b\right))_*} - b\right)}}{2 \cdot a}\]
    5. Applied associate-/l*55.7

      \[\leadsto \color{blue}{\frac{1}{\frac{2 \cdot a}{\sqrt{(\left(a \cdot -4\right) \cdot c + \left(b \cdot b\right))_*} - b}}}\]
    6. Taylor expanded around 0 5.7

      \[\leadsto \frac{1}{\color{blue}{-1 \cdot \frac{b}{c}}}\]
    7. Simplified5.7

      \[\leadsto \frac{1}{\color{blue}{\frac{-b}{c}}}\]

    if 1.8275672346743634e-62 < b < 2.98055712028514e-51

    1. Initial program 34.0

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
    2. Initial simplification34.0

      \[\leadsto \frac{\sqrt{(\left(a \cdot -4\right) \cdot c + \left(b \cdot b\right))_*} - b}{2 \cdot a}\]
    3. Using strategy rm
    4. Applied flip--34.1

      \[\leadsto \frac{\color{blue}{\frac{\sqrt{(\left(a \cdot -4\right) \cdot c + \left(b \cdot b\right))_*} \cdot \sqrt{(\left(a \cdot -4\right) \cdot c + \left(b \cdot b\right))_*} - b \cdot b}{\sqrt{(\left(a \cdot -4\right) \cdot c + \left(b \cdot b\right))_*} + b}}}{2 \cdot a}\]

    if 2.98055712028514e-51 < b < 1.6977371338282006e+36

    1. Initial program 43.3

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
    2. Initial simplification43.3

      \[\leadsto \frac{\sqrt{(\left(a \cdot -4\right) \cdot c + \left(b \cdot b\right))_*} - b}{2 \cdot a}\]
    3. Using strategy rm
    4. Applied flip--43.4

      \[\leadsto \frac{\color{blue}{\frac{\sqrt{(\left(a \cdot -4\right) \cdot c + \left(b \cdot b\right))_*} \cdot \sqrt{(\left(a \cdot -4\right) \cdot c + \left(b \cdot b\right))_*} - b \cdot b}{\sqrt{(\left(a \cdot -4\right) \cdot c + \left(b \cdot b\right))_*} + b}}}{2 \cdot a}\]
    5. Applied associate-/l/46.3

      \[\leadsto \color{blue}{\frac{\sqrt{(\left(a \cdot -4\right) \cdot c + \left(b \cdot b\right))_*} \cdot \sqrt{(\left(a \cdot -4\right) \cdot c + \left(b \cdot b\right))_*} - b \cdot b}{\left(2 \cdot a\right) \cdot \left(\sqrt{(\left(a \cdot -4\right) \cdot c + \left(b \cdot b\right))_*} + b\right)}}\]
    6. Simplified17.1

      \[\leadsto \frac{\color{blue}{\left(a \cdot -4\right) \cdot c}}{\left(2 \cdot a\right) \cdot \left(\sqrt{(\left(a \cdot -4\right) \cdot c + \left(b \cdot b\right))_*} + b\right)}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification16.5

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le 1.476861038724565 \cdot 10^{-78}:\\ \;\;\;\;\frac{1}{\frac{2 \cdot a}{\sqrt{(\left(-4 \cdot a\right) \cdot c + \left(b \cdot b\right))_*} - b}}\\ \mathbf{elif}\;b \le 1.8275672346743634 \cdot 10^{-62}:\\ \;\;\;\;\frac{1}{-\frac{b}{c}}\\ \mathbf{elif}\;b \le 2.98055712028514 \cdot 10^{-51}:\\ \;\;\;\;\frac{\frac{\sqrt{(\left(-4 \cdot a\right) \cdot c + \left(b \cdot b\right))_*} \cdot \sqrt{(\left(-4 \cdot a\right) \cdot c + \left(b \cdot b\right))_*} - b \cdot b}{\sqrt{(\left(-4 \cdot a\right) \cdot c + \left(b \cdot b\right))_*} + b}}{2 \cdot a}\\ \mathbf{elif}\;b \le 1.6977371338282006 \cdot 10^{+36}:\\ \;\;\;\;\frac{c \cdot \left(-4 \cdot a\right)}{\left(2 \cdot a\right) \cdot \left(\sqrt{(\left(-4 \cdot a\right) \cdot c + \left(b \cdot b\right))_*} + b\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{-\frac{b}{c}}\\ \end{array}\]

Runtime

Time bar (total: 25.1s)Debug logProfile

BaselineHerbieOracleSpan%
Regimes34.216.512.921.383.1%
herbie shell --seed 2018354 +o rules:numerics
(FPCore (a b c)
  :name "Quadratic roots, full range"
  (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)))