Average Error: 20.2 → 9.0
Time: 8.4s
Precision: binary64
\[\begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array}\]
\[\begin{array}{l} \mathbf{if}\;b \le -1.56013531511213721 \cdot 10^{110}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\left(2 \cdot \frac{a \cdot c}{b} - b\right) - b}{2}}{a}\\ \end{array}\\ \mathbf{elif}\;b \le 1.1692565862096847 \cdot 10^{102}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\sqrt{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b} \cdot \sqrt{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}}{2}}{a}\\ \end{array}\\ \mathbf{elif}\;b \ge 0.0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \left(b - 2 \cdot \frac{a \cdot c}{b}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}{2}}{a}\\ \end{array}\]

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 3 regimes
  2. if b < -1.56013531511213721e110

    1. Initial program 48.9

      \[\begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array}\]
    2. Simplified48.9

      \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}{2}}{a}\\ \end{array}}\]
    3. Taylor expanded around -inf 11.6

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\left(2 \cdot \frac{a \cdot c}{b} - b\right) - b}{2}}{a}\\ \end{array}\]

    if -1.56013531511213721e110 < b < 1.1692565862096847e102

    1. Initial program 9.2

      \[\begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array}\]
    2. Simplified9.2

      \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}{2}}{a}\\ \end{array}}\]
    3. Using strategy rm
    4. Applied add-sqr-sqrt9.4

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\sqrt{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b} \cdot \sqrt{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}}{2}}{a}\\ \end{array}\]

    if 1.1692565862096847e102 < b

    1. Initial program 30.2

      \[\begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array}\]
    2. Simplified30.2

      \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}{2}}{a}\\ \end{array}}\]
    3. Taylor expanded around inf 6.4

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \color{blue}{\left(b - 2 \cdot \frac{a \cdot c}{b}\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}{2}}{a}\\ \end{array}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification9.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -1.56013531511213721 \cdot 10^{110}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\left(2 \cdot \frac{a \cdot c}{b} - b\right) - b}{2}}{a}\\ \end{array}\\ \mathbf{elif}\;b \le 1.1692565862096847 \cdot 10^{102}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\sqrt{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b} \cdot \sqrt{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}}{2}}{a}\\ \end{array}\\ \mathbf{elif}\;b \ge 0.0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \left(b - 2 \cdot \frac{a \cdot c}{b}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}{2}}{a}\\ \end{array}\]

Reproduce

herbie shell --seed 2020182 
(FPCore (a b c)
  :name "jeff quadratic root 2"
  :precision binary64
  (if (>= b 0.0) (/ (* 2.0 c) (- (neg b) (sqrt (- (* b b) (* (* 4.0 a) c))))) (/ (+ (neg b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a))))