Average Error: 33.7 → 23.7
Time: 17.0s
Precision: 64
Internal Precision: 3392
\[\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 3.156993598427036 \cdot 10^{-12}:\\ \;\;\;\;\frac{\sqrt{(\left(a \cdot -4\right) \cdot c + \left(b \cdot b\right))_*} - b}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(a \cdot -4\right) \cdot c}{\left(b + \sqrt{(\left(a \cdot -4\right) \cdot c + \left(b \cdot b\right))_*}\right) \cdot \left(a \cdot 2\right)}\\ \end{array}\]

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 2 regimes
  2. if b < 3.156993598427036e-12

    1. Initial program 22.3

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

      \[\leadsto \frac{\sqrt{(\left(a \cdot -4\right) \cdot c + \left(b \cdot b\right))_*} - b}{2 \cdot a}\]
    3. Taylor expanded around inf 22.3

      \[\leadsto \frac{\sqrt{\color{blue}{{b}^{2} - 4 \cdot \left(a \cdot c\right)}} - b}{2 \cdot a}\]
    4. Simplified22.3

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

    if 3.156993598427036e-12 < b

    1. Initial program 55.0

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

      \[\leadsto \frac{\sqrt{(\left(a \cdot -4\right) \cdot c + \left(b \cdot b\right))_*} - b}{2 \cdot a}\]
    3. Taylor expanded around inf 55.0

      \[\leadsto \frac{\sqrt{\color{blue}{{b}^{2} - 4 \cdot \left(a \cdot c\right)}} - b}{2 \cdot a}\]
    4. Simplified55.0

      \[\leadsto \frac{\sqrt{\color{blue}{(\left(a \cdot -4\right) \cdot c + \left(b \cdot b\right))_*}} - b}{2 \cdot a}\]
    5. Using strategy rm
    6. Applied flip--55.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}\]
    7. Applied associate-/l/55.9

      \[\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)}}\]
    8. Simplified26.3

      \[\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 2 regimes into one program.
  4. Final simplification23.7

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le 3.156993598427036 \cdot 10^{-12}:\\ \;\;\;\;\frac{\sqrt{(\left(a \cdot -4\right) \cdot c + \left(b \cdot b\right))_*} - b}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(a \cdot -4\right) \cdot c}{\left(b + \sqrt{(\left(a \cdot -4\right) \cdot c + \left(b \cdot b\right))_*}\right) \cdot \left(a \cdot 2\right)}\\ \end{array}\]

Runtime

Time bar (total: 17.0s)Debug logProfile

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