Average Error: 34.3 → 5.6
Time: 55.4s
Precision: 64
Internal precision: 2944
\[\frac{\left(-b\right) - \sqrt{{b}^2 - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\]
\[\begin{array}{l} \mathbf{if}\;b \le -2.4297612505128895 \cdot 10^{+125}:\\ \;\;\;\;\frac{\frac{c}{2} \cdot 4}{\frac{c + c}{\frac{b}{a}} - \left(b - \left(-b\right)\right)}\\ \mathbf{if}\;b \le 7.873756563569149 \cdot 10^{-300}:\\ \;\;\;\;\frac{4}{2} \cdot \frac{c}{\left(-b\right) + \sqrt{b \cdot b - a \cdot \left(c \cdot 4\right)}}\\ \mathbf{if}\;b \le 1.5428617303718363 \cdot 10^{+108}:\\ \;\;\;\;\left(\left(-b\right) - \sqrt{{b}^2 - 4 \cdot \left(a \cdot c\right)}\right) \cdot \frac{1}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-b}{a}\\ \end{array}\]

Error

Bits error versus a

Bits error versus b

Bits error versus c

Target

Original34.3
Comparison21.3
Herbie5.6
\[ \begin{array}{l} \mathbf{if}\;b \lt 0:\\ \;\;\;\;\frac{c}{a \cdot \frac{\left(-b\right) + \sqrt{{b}^2 - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{{b}^2 - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\\ \end{array} \]

Derivation

  1. Split input into 4 regimes.
  2. if b < -2.4297612505128895e+125

    1. Initial program 60.3

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

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

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

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

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

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

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

    if -2.4297612505128895e+125 < b < 7.873756563569149e-300

    1. Initial program 33.6

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

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

      \[\leadsto \frac{\frac{\color{blue}{4 \cdot \left(a \cdot c\right)}}{\left(-b\right) + \sqrt{{b}^2 - 4 \cdot \left(a \cdot c\right)}}}{2 \cdot a}\]
    5. Using strategy rm
    6. Applied *-un-lft-identity 16.2

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

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

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

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

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

    if 7.873756563569149e-300 < b < 1.5428617303718363e+108

    1. Initial program 8.2

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

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

    if 1.5428617303718363e+108 < b

    1. Initial program 47.7

      \[\frac{\left(-b\right) - \sqrt{{b}^2 - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\]
    2. Applied taylor 0

      \[\leadsto -1 \cdot \frac{b}{a}\]
    3. Taylor expanded around inf 0

      \[\leadsto \color{blue}{-1 \cdot \frac{b}{a}}\]
    4. Applied simplify 0

      \[\leadsto \color{blue}{\frac{-b}{a}}\]
  3. Recombined 4 regimes into one program.
  4. Removed slow pow expressions

Runtime

Time bar (total: 55.4s) Debug log

Please include this information when filing a bug report:

herbie shell --seed '#(2277612311 2645429965 1090895633 2857793080 2144184008 3989768357)'
(FPCore (a b c)
  :name "quadm (p42, negative)"

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

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