Average Error: 33.5 → 7.3
Time: 2.0m
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 -1.6564287285243543 \cdot 10^{+130}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{if}\;-b \le 2.3410290397911453 \cdot 10^{-217}:\\ \;\;\;\;\frac{1}{\frac{2 \cdot a}{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}}\\ \mathbf{if}\;-b \le 1.3229040377013218 \cdot 10^{+58}:\\ \;\;\;\;\left(\sqrt[3]{\frac{\frac{c}{2} \cdot 4}{\sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)} - b}} \cdot \sqrt[3]{\frac{\frac{c}{2} \cdot 4}{e^{\log \left(\sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right)} - b}}\right) \cdot \sqrt[3]{\frac{\frac{4}{2} \cdot c}{e^{\log \left(\sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right)} - b}}\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{b}\\ \end{array}\]

Error

Bits error versus a

Bits error versus b

Bits error versus c

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original33.5
Target20.4
Herbie7.3
\[\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) < -1.6564287285243543e+130

    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 10.5

      \[\leadsto \frac{\color{blue}{2 \cdot \frac{c \cdot a}{b} - 2 \cdot b}}{2 \cdot a}\]
    3. Applied simplify3.0

      \[\leadsto \color{blue}{\frac{c}{b} \cdot 1 - \frac{b}{a}}\]

    if -1.6564287285243543e+130 < (- b) < 2.3410290397911453e-217

    1. Initial program 9.6

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

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

    if 2.3410290397911453e-217 < (- b) < 1.3229040377013218e+58

    1. Initial program 33.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 flip--33.5

      \[\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 simplify17.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 simplify17.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. Using strategy rm
    7. Applied add-cube-cbrt18.2

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

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

      \[\leadsto \left(\sqrt[3]{\frac{\frac{c}{2} \cdot \frac{4}{1}}{\sqrt{b \cdot b - \left(a \cdot c\right) \cdot 4} - b}} \cdot \sqrt[3]{\frac{\frac{c}{2} \cdot \frac{4}{1}}{\sqrt{b \cdot b - \left(a \cdot c\right) \cdot 4} - b}}\right) \cdot \color{blue}{\sqrt[3]{\frac{c \cdot \left(1 \cdot \frac{4}{2}\right)}{\sqrt{b \cdot b - \left(a \cdot c\right) \cdot 4} - b}}}\]
    10. Using strategy rm
    11. Applied add-exp-log9.9

      \[\leadsto \left(\sqrt[3]{\frac{\frac{c}{2} \cdot \frac{4}{1}}{\sqrt{b \cdot b - \left(a \cdot c\right) \cdot 4} - b}} \cdot \sqrt[3]{\frac{\frac{c}{2} \cdot \frac{4}{1}}{\sqrt{b \cdot b - \left(a \cdot c\right) \cdot 4} - b}}\right) \cdot \sqrt[3]{\frac{c \cdot \left(1 \cdot \frac{4}{2}\right)}{\color{blue}{e^{\log \left(\sqrt{b \cdot b - \left(a \cdot c\right) \cdot 4}\right)}} - b}}\]
    12. Using strategy rm
    13. Applied add-exp-log10.6

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

    if 1.3229040377013218e+58 < (- b)

    1. Initial program 57.2

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

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

      \[\leadsto \color{blue}{\left(-1\right) \cdot \frac{c}{b}}\]
  3. Recombined 4 regimes into one program.
  4. Applied simplify7.3

    \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;-b \le -1.6564287285243543 \cdot 10^{+130}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{if}\;-b \le 2.3410290397911453 \cdot 10^{-217}:\\ \;\;\;\;\frac{1}{\frac{2 \cdot a}{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}}\\ \mathbf{if}\;-b \le 1.3229040377013218 \cdot 10^{+58}:\\ \;\;\;\;\left(\sqrt[3]{\frac{\frac{c}{2} \cdot 4}{\sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)} - b}} \cdot \sqrt[3]{\frac{\frac{c}{2} \cdot 4}{e^{\log \left(\sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right)} - b}}\right) \cdot \sqrt[3]{\frac{\frac{4}{2} \cdot c}{e^{\log \left(\sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right)} - b}}\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{b}\\ \end{array}}\]

Runtime

Time bar (total: 2.0m)Debug logProfile

herbie shell --seed 2018201 
(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)))