Average Error: 20.2 → 6.6
Time: 1.2m
Precision: 64
Ground Truth: 128
\[\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}}\\ \end{array}\]
\[\begin{array}{l} \mathbf{if}\;b \le -6.810633232149731 \cdot 10^{+112}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{a + a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{a \cdot \frac{c}{b} - b}\\ \end{array}\\ \mathbf{if}\;b \le 4.876491143107084 \cdot 10^{+155}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) + {\left(\sqrt[3]{\sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}}\right)}^3}\\ \end{array}\\ \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c + c}{\sqrt{{b}^2 - \left(a \cdot 4\right) \cdot c} + \left(-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 < -6.810633232149731e+112

    1. Initial program 32.5

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\color{blue}{\frac{2 \cdot c}{2 \cdot \frac{c \cdot a}{b} - 2 \cdot b}}\\ \end{array}\]
    4. Applied simplify 1.4

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

    if -6.810633232149731e+112 < b < 4.876491143107084e+155

    1. Initial program 9.1

      \[\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}}\\ \end{array}\]
    2. Using strategy rm
    3. Applied add-cube-cbrt 9.5

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

    if 4.876491143107084e+155 < b

    1. Initial program 60.9

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

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

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

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c + c}{\sqrt{{b}^2 - \left(a \cdot 4\right) \cdot c} + \left(-b\right)}\\ \end{array}\]
  3. Recombined 3 regimes into one program.
  4. Removed slow pow expressions

Runtime

Total time: 1.2m Debug log

Please include this information when filing a bug report:

herbie --seed '#(2987685063 2946129298 4140658802 4195022158 2050996147 1442004703)'
(FPCore (a b c)
  :name "jeff quadratic root 1"
  (if (>= b 0) (/ (- (- b) (sqrt (- (sqr b) (* (* 4 a) c)))) (* 2 a)) (/ (* 2 c) (+ (- b) (sqrt (- (sqr b) (* (* 4 a) c)))))))