Average Error: 33.5 → 6.6
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 -7.493884136190196 \cdot 10^{+87}:\\ \;\;\;\;\frac{c \cdot 2}{\frac{2 \cdot a}{\frac{b}{c}} - \left(b + b\right)}\\ \mathbf{if}\;b \le -6.958911733493205 \cdot 10^{-282}:\\ \;\;\;\;\frac{1}{\frac{2}{\frac{c}{\frac{1}{4}}} \cdot \left(\sqrt{\left(c \cdot a\right) \cdot -4 + b \cdot b} - b\right)}\\ \mathbf{if}\;b \le 2.6873717073918 \cdot 10^{+112}:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-b}{a}\\ \end{array}\]

Error

Bits error versus a

Bits error versus b

Bits error versus c

Target

Original33.5
Target20.5
Herbie6.6
\[\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 < -7.493884136190196e+87

    1. Initial program 57.9

      \[\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--57.9

      \[\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 simplify30.5

      \[\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 simplify30.5

      \[\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. Taylor expanded around -inf 14.1

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

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

    if -7.493884136190196e+87 < b < -6.958911733493205e-282

    1. Initial program 32.9

      \[\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.0

      \[\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.6

      \[\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.6

      \[\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 clear-num16.8

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

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

    if -6.958911733493205e-282 < b < 2.6873717073918e+112

    1. Initial program 9.1

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

    if 2.6873717073918e+112 < b

    1. Initial program 48.0

      \[\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}}\]
  3. Recombined 4 regimes into one program.

Runtime

Time bar (total: 2.2m)Debug logProfile

herbie shell --seed '#(1071373924 2949776965 1885069702 3247780810 90874544 2263903749)' 
(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)))