Average Error: 35.0 → 6.4
Time: 25.8s
Precision: 64
Internal precision: 3200
\[\frac{\left(-b\right) - \sqrt{{b}^2 - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\]
\[\begin{array}{l} \mathbf{if}\;b \le -3.460964309611288 \cdot 10^{+19}:\\ \;\;\;\;\frac{\left(-b\right) + b}{a + a} - \frac{c}{b}\\ \mathbf{if}\;b \le -5.874839546400093 \cdot 10^{-149}:\\ \;\;\;\;\frac{\frac{a \cdot \left(4 \cdot c\right)}{\left(-b\right) + \sqrt{{b}^2 - 4 \cdot \left(a \cdot c\right)}}}{2 \cdot a}\\ \mathbf{if}\;b \le 1.1073706101041596 \cdot 10^{+76}:\\ \;\;\;\;\frac{1}{\frac{2 \cdot a}{\left(-b\right) - \sqrt{{b}^2 - 4 \cdot \left(a \cdot c\right)}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{-b}{a}\\ \end{array}\]

Error

Bits error versus a

Bits error versus b

Bits error versus c

Target

Original35.0
Comparison22.8
Herbie6.4
\[ \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 < -3.460964309611288e+19

    1. Initial program 58.0

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

      \[\leadsto \frac{\left(-b\right) - \left(2 \cdot \frac{c \cdot a}{b} - b\right)}{2 \cdot a}\]
    3. Taylor expanded around -inf 41.5

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

      \[\leadsto \color{blue}{\frac{\left(-b\right) + b}{a + a} - \frac{\frac{c}{b}}{1}}\]
    5. Applied simplify 0

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

    if -3.460964309611288e+19 < b < -5.874839546400093e-149

    1. Initial program 34.2

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

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

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

    if -5.874839546400093e-149 < b < 1.1073706101041596e+76

    1. Initial program 11.6

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

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

    if 1.1073706101041596e+76 < b

    1. Initial program 41.9

      \[\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: 25.8s) Debug logProfile

Please include this information when filing a bug report:

herbie shell --seed '#(1064555532 179913862 452496668 2441903500 287849034 462453547)'
(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)))