Average Error: 33.7 → 10.9
Time: 1.5m
Precision: 64
Internal Precision: 128
\[\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 -2.042858470713346 \cdot 10^{-160}:\\ \;\;\;\;-\frac{c}{b}\\ \mathbf{elif}\;b \le 9.271363032678826 \cdot 10^{+122}:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{\sqrt[3]{\left(c \cdot a\right) \cdot -4 + b \cdot b} \cdot \left(\sqrt[3]{\left(c \cdot a\right) \cdot -4 + b \cdot b} \cdot \sqrt[3]{\left(c \cdot a\right) \cdot -4 + b \cdot b}\right)}}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \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.7
Target20.9
Herbie10.9
\[\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 3 regimes
  2. if b < -2.042858470713346e-160

    1. Initial program 50.0

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{c}{b}}\]
    4. Simplified12.8

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

    if -2.042858470713346e-160 < b < 9.271363032678826e+122

    1. Initial program 11.0

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

      \[\leadsto \frac{\left(-b\right) - \sqrt{b \cdot b + -4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\]
    3. Using strategy rm
    4. Applied add-cube-cbrt11.5

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

    if 9.271363032678826e+122 < b

    1. Initial program 49.7

      \[\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\]
    2. Initial simplification49.7

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

      \[\leadsto \color{blue}{\frac{c}{b} - \frac{b}{a}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification10.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -2.042858470713346 \cdot 10^{-160}:\\ \;\;\;\;-\frac{c}{b}\\ \mathbf{elif}\;b \le 9.271363032678826 \cdot 10^{+122}:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{\sqrt[3]{\left(c \cdot a\right) \cdot -4 + b \cdot b} \cdot \left(\sqrt[3]{\left(c \cdot a\right) \cdot -4 + b \cdot b} \cdot \sqrt[3]{\left(c \cdot a\right) \cdot -4 + b \cdot b}\right)}}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \end{array}\]

Runtime

Time bar (total: 1.5m)Debug logProfile

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