Average Error: 34.5 → 6.2
Time: 5.3m
Precision: 64
Internal Precision: 2944
\[\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 -3.880192169685904 \cdot 10^{+136}:\\ \;\;\;\;\frac{\left(-b\right) + b}{a + a} - \frac{c}{b}\\ \mathbf{if}\;b \le -4.911115753907739 \cdot 10^{-141}:\\ \;\;\;\;\frac{\sqrt{\frac{4}{\sqrt[3]{\left(-b\right) + \sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4}}}}}{2} \cdot \left(\frac{c}{\sqrt[3]{\left(-b\right) + \sqrt{b \cdot b - \left(c \cdot 4\right) \cdot a}} \cdot \sqrt[3]{\left(-b\right) + \sqrt{b \cdot b - \left(c \cdot 4\right) \cdot a}}} \cdot \sqrt{\frac{4}{\sqrt[3]{\left(-b\right) + \sqrt{b \cdot b - \left(c \cdot 4\right) \cdot a}}}}\right)\\ \mathbf{if}\;b \le 4.022936252353642 \cdot 10^{+122}:\\ \;\;\;\;\frac{-b}{2 \cdot a} - \frac{\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

Original34.5
Target21.3
Herbie6.2
\[\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 < -3.880192169685904e+136

    1. Initial program 61.2

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

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

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

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

    if -3.880192169685904e+136 < b < -4.911115753907739e-141

    1. Initial program 41.3

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

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

      \[\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. Using strategy rm
    6. Applied add-cube-cbrt16.9

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

      \[\leadsto \frac{\color{blue}{\frac{c \cdot a}{\sqrt[3]{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}} \cdot \sqrt[3]{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}} \cdot \frac{4}{\sqrt[3]{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}}}}{2 \cdot a}\]
    8. Applied associate-/l*17.0

      \[\leadsto \color{blue}{\frac{\frac{c \cdot a}{\sqrt[3]{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}} \cdot \sqrt[3]{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}}}{\frac{2 \cdot a}{\frac{4}{\sqrt[3]{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}}}}}\]
    9. Using strategy rm
    10. Applied add-sqr-sqrt17.0

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

      \[\leadsto \frac{\frac{c \cdot a}{\sqrt[3]{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}} \cdot \sqrt[3]{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}}}{\color{blue}{\frac{2}{\sqrt{\frac{4}{\sqrt[3]{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}}}} \cdot \frac{a}{\sqrt{\frac{4}{\sqrt[3]{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}}}}}}\]
    12. Applied *-un-lft-identity17.1

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

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

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

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

    if -4.911115753907739e-141 < b < 4.022936252353642e+122

    1. Initial program 11.4

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

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

    if 4.022936252353642e+122 < b

    1. Initial program 51.5

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

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

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

Runtime

Time bar (total: 5.3m)Debug logProfile

herbie shell --seed '#(1062803647 245428163 493620569 3595423923 1908391097 2390014376)' 
(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)))