Average Error: 20.4 → 6.9
Time: 6.1s
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 -1.71075788809424871 \cdot 10^{87}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{2 \cdot \left(\left(c \cdot \left(\sqrt[3]{a} \cdot \sqrt[3]{a}\right)\right) \cdot \frac{\sqrt[3]{a}}{b}\right) - \left(b + b\right)}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \left(c \cdot \left(2 \cdot \frac{a}{b}\right) - b\right)}\\ \end{array}\\ \mathbf{elif}\;b \le 2.3540792276628007 \cdot 10^{82}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;c \cdot \frac{2}{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}}\\ \end{array}\\ \mathbf{elif}\;b \ge 0.0:\\ \;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{2}{\sqrt{\left(-b\right) + \left(2 \cdot \left(c \cdot \frac{a}{b}\right) - b\right)}} \cdot \frac{c}{\sqrt{\left(-b\right) + \left(2 \cdot \left(c \cdot \frac{a}{b}\right) - b\right)}}\\ \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.71075788809424871e87

    1. Initial program 30.1

      \[\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 30.1

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{\color{blue}{2 \cdot \frac{a \cdot c}{b} - 2 \cdot b}}{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}\]
    3. Simplified30.1

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{\color{blue}{2 \cdot \left(c \cdot \frac{a}{b}\right) - \left(b + b\right)}}{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}\]
    4. Taylor expanded around -inf 7.4

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{2 \cdot \left(c \cdot \frac{a}{b}\right) - \left(b + b\right)}{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}\]
    5. Simplified3.4

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{2 \cdot \left(c \cdot \frac{a}{b}\right) - \left(b + b\right)}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\color{blue}{\left(-b\right) + \left(c \cdot \left(\frac{a}{b} \cdot 2\right) - b\right)}}\\ \end{array}\]
    6. Using strategy rm
    7. Applied *-un-lft-identity3.4

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

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

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

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

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

    if -1.71075788809424871e87 < b < 2.3540792276628007e82

    1. Initial program 9.2

      \[\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}{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}\\ \end{array}}\]

    if 2.3540792276628007e82 < b

    1. Initial program 43.8

      \[\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 10.1

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{\color{blue}{2 \cdot \frac{a \cdot c}{b} - 2 \cdot b}}{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}\]
    3. Simplified4.3

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{\color{blue}{2 \cdot \left(c \cdot \frac{a}{b}\right) - \left(b + b\right)}}{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}\]
    4. Taylor expanded around -inf 4.3

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{2 \cdot \left(c \cdot \frac{a}{b}\right) - \left(b + b\right)}{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}\]
    5. Simplified4.3

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{2 \cdot \left(c \cdot \frac{a}{b}\right) - \left(b + b\right)}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\color{blue}{\left(-b\right) + \left(c \cdot \left(\frac{a}{b} \cdot 2\right) - b\right)}}\\ \end{array}\]
    6. Taylor expanded around 0 4.1

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -1.71075788809424871 \cdot 10^{87}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{2 \cdot \left(\left(c \cdot \left(\sqrt[3]{a} \cdot \sqrt[3]{a}\right)\right) \cdot \frac{\sqrt[3]{a}}{b}\right) - \left(b + b\right)}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \left(c \cdot \left(2 \cdot \frac{a}{b}\right) - b\right)}\\ \end{array}\\ \mathbf{elif}\;b \le 2.3540792276628007 \cdot 10^{82}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;c \cdot \frac{2}{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}}\\ \end{array}\\ \mathbf{elif}\;b \ge 0.0:\\ \;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{2}{\sqrt{\left(-b\right) + \left(2 \cdot \left(c \cdot \frac{a}{b}\right) - b\right)}} \cdot \frac{c}{\sqrt{\left(-b\right) + \left(2 \cdot \left(c \cdot \frac{a}{b}\right) - b\right)}}\\ \end{array}\]

Reproduce

herbie shell --seed 2020179 
(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)))))))