Average Error: 34.9 → 5.6
Time: 20.5s
Precision: 64
Internal precision: 2688
\[\frac{\left(-b\right) - \sqrt{{b}^2 - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\]
\[\begin{array}{l} \mathbf{if}\;b \le -4.437635090274828 \cdot 10^{+72}:\\ \;\;\;\;\frac{\left(-b\right) + b}{a + a} - \frac{c}{b}\\ \mathbf{if}\;b \le -5.122826773439569 \cdot 10^{-234}:\\ \;\;\;\;\frac{1}{\frac{2}{4 \cdot c} \cdot \left(\sqrt{b \cdot b - \left(a \cdot c\right) \cdot 4} + \left(-b\right)\right)}\\ \mathbf{if}\;b \le 5.782486744451723 \cdot 10^{+116}:\\ \;\;\;\;\frac{-b}{2 \cdot a} - \frac{\sqrt{{b}^2 - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \end{array}\]

Error

Bits error versus a

Bits error versus b

Bits error versus c

Target

Original34.9
Comparison22.2
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 < -4.437635090274828e+72

    1. Initial program 59.0

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

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

      \[\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 -4.437635090274828e+72 < b < -5.122826773439569e-234

    1. Initial program 34.5

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

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

      \[\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}\]
    5. Using strategy rm
    6. Applied clear-num 17.9

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

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

    if -5.122826773439569e-234 < b < 5.782486744451723e+116

    1. Initial program 9.7

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

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

    if 5.782486744451723e+116 < b

    1. Initial program 51.1

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

      \[\leadsto \frac{2 \cdot \frac{c \cdot a}{b} - 2 \cdot b}{2 \cdot a}\]
    3. Taylor expanded around inf 12.8

      \[\leadsto \frac{\color{blue}{2 \cdot \frac{c \cdot a}{b} - 2 \cdot b}}{2 \cdot a}\]
    4. Applied simplify 0.0

      \[\leadsto \color{blue}{\frac{\frac{c}{b}}{1} - \frac{b}{a}}\]
    5. Applied simplify 0.0

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

Runtime

Time bar (total: 20.5s) Debug logProfile

Please include this information when filing a bug report:

herbie shell --seed '#(1065033997 2389885643 4100569014 2620012693 26800780 3144211646)'
(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)))