Average Error: 33.5 → 9.7
Time: 24.2s
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 -7.016796193946308 \cdot 10^{+56}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{elif}\;b \le 1.9043057091884097 \cdot 10^{-112}:\\ \;\;\;\;\frac{\sqrt{a \cdot \left(-4 \cdot c\right) + b \cdot b} - b}{a \cdot 2}\\ \mathbf{elif}\;b \le 1.6472829075515696 \cdot 10^{+64}:\\ \;\;\;\;\frac{a \cdot \left(-4 \cdot c\right)}{\left(\sqrt{a \cdot \left(-4 \cdot c\right) + b \cdot b} + b\right) \cdot \left(a \cdot 2\right)}\\ \mathbf{else}:\\ \;\;\;\;-\frac{c}{b}\\ \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 < -7.016796193946308e+56

    1. Initial program 36.0

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

      \[\leadsto \color{blue}{\frac{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} - b}{2 \cdot a}}\]
    3. Taylor expanded around -inf 5.1

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

    if -7.016796193946308e+56 < b < 1.9043057091884097e-112

    1. Initial program 12.2

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

      \[\leadsto \color{blue}{\frac{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} - b}{2 \cdot a}}\]
    3. Using strategy rm
    4. Applied clear-num12.3

      \[\leadsto \color{blue}{\frac{1}{\frac{2 \cdot a}{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} - b}}}\]
    5. Using strategy rm
    6. Applied associate-/r/12.4

      \[\leadsto \color{blue}{\frac{1}{2 \cdot a} \cdot \left(\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} - b\right)}\]
    7. Using strategy rm
    8. Applied associate-*l/12.2

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

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

    if 1.9043057091884097e-112 < b < 1.6472829075515696e+64

    1. Initial program 41.6

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

      \[\leadsto \color{blue}{\frac{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} - b}{2 \cdot a}}\]
    3. Using strategy rm
    4. Applied clear-num41.6

      \[\leadsto \color{blue}{\frac{1}{\frac{2 \cdot a}{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} - b}}}\]
    5. Using strategy rm
    6. Applied associate-/r/41.6

      \[\leadsto \color{blue}{\frac{1}{2 \cdot a} \cdot \left(\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} - b\right)}\]
    7. Using strategy rm
    8. Applied associate-*l/41.6

      \[\leadsto \color{blue}{\frac{1 \cdot \left(\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} - b\right)}{2 \cdot a}}\]
    9. Simplified41.7

      \[\leadsto \frac{\color{blue}{\sqrt{\left(c \cdot -4\right) \cdot a + b \cdot b} - b}}{2 \cdot a}\]
    10. Using strategy rm
    11. Applied flip--41.8

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

      \[\leadsto \color{blue}{\frac{\sqrt{\left(c \cdot -4\right) \cdot a + b \cdot b} \cdot \sqrt{\left(c \cdot -4\right) \cdot a + b \cdot b} - b \cdot b}{\left(2 \cdot a\right) \cdot \left(\sqrt{\left(c \cdot -4\right) \cdot a + b \cdot b} + b\right)}}\]
    13. Simplified20.5

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

    if 1.6472829075515696e+64 < b

    1. Initial program 58.0

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

      \[\leadsto \color{blue}{\frac{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} - b}{2 \cdot a}}\]
    3. Taylor expanded around inf 3.5

      \[\leadsto \color{blue}{-1 \cdot \frac{c}{b}}\]
    4. Simplified3.5

      \[\leadsto \color{blue}{-\frac{c}{b}}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification9.7

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -7.016796193946308 \cdot 10^{+56}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{elif}\;b \le 1.9043057091884097 \cdot 10^{-112}:\\ \;\;\;\;\frac{\sqrt{a \cdot \left(-4 \cdot c\right) + b \cdot b} - b}{a \cdot 2}\\ \mathbf{elif}\;b \le 1.6472829075515696 \cdot 10^{+64}:\\ \;\;\;\;\frac{a \cdot \left(-4 \cdot c\right)}{\left(\sqrt{a \cdot \left(-4 \cdot c\right) + b \cdot b} + b\right) \cdot \left(a \cdot 2\right)}\\ \mathbf{else}:\\ \;\;\;\;-\frac{c}{b}\\ \end{array}\]

Reproduce

herbie shell --seed 2019093 
(FPCore (a b c)
  :name "Quadratic roots, full range"
  (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)))