Average Error: 33.0 → 10.4
Time: 2.8m
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.0373992183972371 \cdot 10^{+38}:\\ \;\;\;\;\frac{-c}{b}\\ \mathbf{if}\;b \le -7.587065739737278 \cdot 10^{-20}:\\ \;\;\;\;\frac{\frac{\left(a \cdot c\right) \cdot 4}{\sqrt{b \cdot b - a \cdot \left(4 \cdot c\right)} - b}}{2 \cdot a}\\ \mathbf{if}\;b \le -2.2869707272504606 \cdot 10^{-173}:\\ \;\;\;\;\frac{-c}{b}\\ \mathbf{if}\;b \le 3.5962548250302795 \cdot 10^{+78}:\\ \;\;\;\;\frac{b + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{-2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-b}{a}\\ \end{array}\]

Error

Bits error versus a

Bits error versus b

Bits error versus c

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original33.0
Target20.6
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 4 regimes
  2. if b < -1.0373992183972371e+38 or -7.587065739737278e-20 < b < -2.2869707272504606e-173

    1. Initial program 49.0

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

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

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

    if -1.0373992183972371e+38 < b < -7.587065739737278e-20

    1. Initial program 43.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--43.2

      \[\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 simplify12.9

      \[\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 simplify12.9

      \[\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}\]

    if -2.2869707272504606e-173 < b < 3.5962548250302795e+78

    1. Initial program 10.2

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

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

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

    if 3.5962548250302795e+78 < b

    1. Initial program 40.5

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

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

      \[\leadsto \color{blue}{\frac{-b}{a}}\]
  3. Recombined 4 regimes into one program.
  4. Applied simplify10.4

    \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;b \le -1.0373992183972371 \cdot 10^{+38}:\\ \;\;\;\;\frac{-c}{b}\\ \mathbf{if}\;b \le -7.587065739737278 \cdot 10^{-20}:\\ \;\;\;\;\frac{\frac{\left(a \cdot c\right) \cdot 4}{\sqrt{b \cdot b - a \cdot \left(4 \cdot c\right)} - b}}{2 \cdot a}\\ \mathbf{if}\;b \le -2.2869707272504606 \cdot 10^{-173}:\\ \;\;\;\;\frac{-c}{b}\\ \mathbf{if}\;b \le 3.5962548250302795 \cdot 10^{+78}:\\ \;\;\;\;\frac{b + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{-2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-b}{a}\\ \end{array}}\]

Runtime

Time bar (total: 2.8m)Debug logProfile

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