Average Error: 33.0 → 10.9
Time: 2.2m
Precision: 64
Internal Precision: 3392
\[\frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\]
\[\begin{array}{l} \mathbf{if}\;b \le -1.1387810658296382 \cdot 10^{+116}:\\ \;\;\;\;-\frac{b}{a}\\ \mathbf{if}\;b \le 4.1715358376740176 \cdot 10^{-156}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{b}\\ \end{array}\]

Error

Bits error versus a

Bits error versus b

Bits error versus c

Target

Original33.0
Target20.4
Herbie10.9
\[\begin{array}{l} \mathbf{if}\;b \lt 0:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{a \cdot \frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}}\\ \end{array}\]

Derivation

  1. Split input into 3 regimes
  2. if b < -1.1387810658296382e+116

    1. Initial program 48.2

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\]
    2. Taylor expanded around -inf 3.7

      \[\leadsto \color{blue}{-1 \cdot \frac{b}{a}}\]
    3. Applied simplify3.7

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

    if -1.1387810658296382e+116 < b < 4.1715358376740176e-156

    1. Initial program 10.3

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

    if 4.1715358376740176e-156 < b

    1. Initial program 48.5

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\]
    2. Taylor expanded around inf 48.8

      \[\leadsto \frac{\left(-b\right) + \color{blue}{\left(b - 2 \cdot \frac{c \cdot a}{b}\right)}}{2 \cdot a}\]
    3. Applied simplify13.8

      \[\leadsto \color{blue}{\left(-1\right) \cdot \frac{c}{b}}\]
  3. Recombined 3 regimes into one program.
  4. Applied simplify10.9

    \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;b \le -1.1387810658296382 \cdot 10^{+116}:\\ \;\;\;\;-\frac{b}{a}\\ \mathbf{if}\;b \le 4.1715358376740176 \cdot 10^{-156}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{b}\\ \end{array}}\]

Runtime

Time bar (total: 2.2m)Debug logProfile

herbie shell --seed '#(1071852389 864846987 1238109217 3425890003 4124793586 650694553)' 
(FPCore (a b c)
  :name "quadp (p42, positive)"

  :herbie-target
  (if (< b 0) (/ (+ (- b) (sqrt (- (* b b) (* 4 (* a c))))) (* 2 a)) (/ c (* a (/ (- (- b) (sqrt (- (* b b) (* 4 (* a c))))) (* 2 a)))))

  (/ (+ (- b) (sqrt (- (* b b) (* 4 (* a c))))) (* 2 a)))