Average Error: 33.9 → 10.4
Time: 1.6m
Precision: 64
Internal Precision: 3456
\[\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.2200045799418502 \cdot 10^{-68}:\\ \;\;\;\;\frac{c}{b} \cdot \frac{-2}{2}\\ \mathbf{if}\;b \le 9.622889278670843 \cdot 10^{+25}:\\ \;\;\;\;\frac{-b}{2 \cdot a} - \frac{\sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{c}{b}}{1} - \frac{b}{a}\\ \end{array}\]

Error

Bits error versus a

Bits error versus b

Bits error versus c

Target

Original33.9
Target20.8
Herbie10.4
\[\begin{array}{l} \mathbf{if}\;b \lt 0:\\ \;\;\;\;\frac{c}{a \cdot \frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}}\\ \mathbf{else}:\\ \;\;\;\;\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.2200045799418502e-68

    1. Initial program 53.1

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

      \[\leadsto \frac{\color{blue}{-2 \cdot \frac{c \cdot a}{b}}}{2 \cdot a}\]
    3. Applied simplify8.6

      \[\leadsto \color{blue}{\frac{c}{b} \cdot \frac{-2}{2}}\]

    if -1.2200045799418502e-68 < b < 9.622889278670843e+25

    1. Initial program 14.4

      \[\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\]
    2. Using strategy rm
    3. Applied div-sub14.4

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

    if 9.622889278670843e+25 < b

    1. Initial program 34.0

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

      \[\leadsto \frac{\color{blue}{2 \cdot \frac{c \cdot a}{b} - 2 \cdot b}}{2 \cdot a}\]
    3. Applied simplify6.4

      \[\leadsto \color{blue}{\frac{\frac{c}{b}}{1} - \frac{b}{a}}\]
  3. Recombined 3 regimes into one program.

Runtime

Time bar (total: 1.6m)Debug logProfile

herbie shell --seed '#(1064269945 2896236262 301053905 1701069080 1701464310 1614783279)' +o rules:numerics
(FPCore (a b c)
  :name "quadm (p42, negative)"

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

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