Average Error: 33.5 → 6.3
Time: 2.1m
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 -6.749681311314221 \cdot 10^{+155}:\\ \;\;\;\;\frac{-b}{a}\\ \mathbf{if}\;-b \le 1.454644076748988 \cdot 10^{-268}:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\\ \mathbf{if}\;-b \le 1.0619928095503435 \cdot 10^{+91}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{4 \cdot c}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{4}{2} \cdot c}{\frac{c}{b} \cdot \left(a \cdot 2\right) - \left(b + b\right)}\\ \end{array}\]

Error

Bits error versus a

Bits error versus b

Bits error versus c

Target

Original33.5
Target20.5
Herbie6.3
\[\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 4 regimes
  2. if (- b) < -6.749681311314221e+155

    1. Initial program 60.9

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

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

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

    if -6.749681311314221e+155 < (- b) < 1.454644076748988e-268

    1. Initial program 8.9

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

    if 1.454644076748988e-268 < (- b) < 1.0619928095503435e+91

    1. Initial program 33.8

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

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

      \[\leadsto \frac{\frac{\color{blue}{\left(c \cdot a\right) \cdot 4}}{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}}{2 \cdot a}\]
    5. Applied simplify16.0

      \[\leadsto \frac{\frac{\left(c \cdot a\right) \cdot 4}{\color{blue}{\sqrt{b \cdot b - \left(4 \cdot c\right) \cdot a} - b}}}{2 \cdot a}\]
    6. Using strategy rm
    7. Applied *-un-lft-identity16.0

      \[\leadsto \frac{\color{blue}{1 \cdot \frac{\left(c \cdot a\right) \cdot 4}{\sqrt{b \cdot b - \left(4 \cdot c\right) \cdot a} - b}}}{2 \cdot a}\]
    8. Applied times-frac16.0

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

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

    if 1.0619928095503435e+91 < (- b)

    1. Initial program 58.1

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

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

      \[\leadsto \frac{\frac{\color{blue}{\left(c \cdot a\right) \cdot 4}}{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}}{2 \cdot a}\]
    5. Applied simplify31.0

      \[\leadsto \frac{\frac{\left(c \cdot a\right) \cdot 4}{\color{blue}{\sqrt{b \cdot b - \left(4 \cdot c\right) \cdot a} - b}}}{2 \cdot a}\]
    6. Using strategy rm
    7. Applied *-un-lft-identity31.0

      \[\leadsto \frac{\color{blue}{1 \cdot \frac{\left(c \cdot a\right) \cdot 4}{\sqrt{b \cdot b - \left(4 \cdot c\right) \cdot a} - b}}}{2 \cdot a}\]
    8. Applied times-frac31.0

      \[\leadsto \color{blue}{\frac{1}{2} \cdot \frac{\frac{\left(c \cdot a\right) \cdot 4}{\sqrt{b \cdot b - \left(4 \cdot c\right) \cdot a} - b}}{a}}\]
    9. Applied simplify28.7

      \[\leadsto \frac{1}{2} \cdot \color{blue}{\frac{4 \cdot c}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}}\]
    10. Taylor expanded around -inf 6.5

      \[\leadsto \frac{1}{2} \cdot \frac{4 \cdot c}{\color{blue}{\left(2 \cdot \frac{c \cdot a}{b} - b\right)} - b}\]
    11. Applied simplify2.7

      \[\leadsto \color{blue}{\frac{\frac{4}{2} \cdot c}{\frac{c}{b} \cdot \left(a \cdot 2\right) - \left(b + b\right)}}\]
  3. Recombined 4 regimes into one program.

Runtime

Time bar (total: 2.1m)Debug logProfile

herbie shell --seed '#(1071948828 1180510430 2986424009 997076509 406109801 420189285)' 
(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)))