Average Error: 19.7 → 7.3
Time: 5.2s
Precision: binary64
\[\begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \end{array}\]
\[\begin{array}{l} \mathbf{if}\;b \le -5.9697242670823925 \cdot 10^{-13} \lor \neg \left(b \le 3.8865772398298144 \cdot 10^{142}\right):\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{\left(2 \cdot \left(a \cdot \frac{c}{b}\right) - b\right) - b}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\left(\left(\sqrt[3]{a} \cdot \sqrt[3]{a}\right) \cdot \left(c \cdot \left(\sqrt[3]{a} \cdot \frac{2}{b}\right)\right) - b\right) - b}\\ \end{array}\\ \mathbf{elif}\;b \ge 0.0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;c \cdot \frac{2}{\sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)} - b}\\ \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 < -5.9697242670823925e-13 or 3.8865772398298144e142 < b

    1. Initial program 31.9

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

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\left(-\color{blue}{b}\right) + \left(\left(\left(\sqrt[3]{a} \cdot \sqrt[3]{a}\right) \cdot \sqrt[3]{a}\right) \cdot \left(c \cdot \frac{2}{b}\right) - b\right)}\\ \end{array}\]
    6. Applied associate-*l*20.1

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\color{blue}{\left(-b\right)} + \left(\left(\sqrt[3]{a} \cdot \sqrt[3]{a}\right) \cdot \left(\sqrt[3]{a} \cdot \left(c \cdot \frac{2}{b}\right)\right) - b\right)}\\ \end{array}\]
    7. Simplified20.1

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

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

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

    if -5.9697242670823925e-13 < b < 3.8865772398298144e142

    1. Initial program 9.3

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -5.9697242670823925 \cdot 10^{-13} \lor \neg \left(b \le 3.8865772398298144 \cdot 10^{142}\right):\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{\left(2 \cdot \left(a \cdot \frac{c}{b}\right) - b\right) - b}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\left(\left(\sqrt[3]{a} \cdot \sqrt[3]{a}\right) \cdot \left(c \cdot \left(\sqrt[3]{a} \cdot \frac{2}{b}\right)\right) - b\right) - b}\\ \end{array}\\ \mathbf{elif}\;b \ge 0.0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;c \cdot \frac{2}{\sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)} - b}\\ \end{array}\]

Reproduce

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