Average Error: 33.4 → 10.0
Time: 42.8s
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.4826136748139784 \cdot 10^{-46}:\\ \;\;\;\;-\frac{c}{b}\\ \mathbf{elif}\;b \le 1.9950290346988235 \cdot 10^{+62}:\\ \;\;\;\;\frac{-b}{2 \cdot a} - \frac{\sqrt{b \cdot b - \left(a \cdot c\right) \cdot 4}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-b}{2 \cdot a} - \left(\frac{1}{2} \cdot \frac{b}{a} - \frac{c}{b}\right)\\ \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.4
Target20.7
Herbie10.0
\[\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.4826136748139784e-46

    1. Initial program 53.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 div-sub54.5

      \[\leadsto \color{blue}{\frac{-b}{2 \cdot a} - \frac{\sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}}\]
    4. Using strategy rm
    5. Applied add-sqr-sqrt56.1

      \[\leadsto \frac{-b}{2 \cdot a} - \frac{\color{blue}{\sqrt{\sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}} \cdot \sqrt{\sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}}}{2 \cdot a}\]
    6. Applied times-frac56.5

      \[\leadsto \frac{-b}{2 \cdot a} - \color{blue}{\frac{\sqrt{\sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}}{2} \cdot \frac{\sqrt{\sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}}{a}}\]
    7. Taylor expanded around -inf 7.5

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

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

    if -2.4826136748139784e-46 < b < 1.9950290346988235e+62

    1. Initial program 14.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 div-sub14.3

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

    if 1.9950290346988235e+62 < b

    1. Initial program 38.1

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

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

      \[\leadsto \frac{-b}{2 \cdot a} - \color{blue}{\left(\frac{1}{2} \cdot \frac{b}{a} - \frac{c}{b}\right)}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification10.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -2.4826136748139784 \cdot 10^{-46}:\\ \;\;\;\;-\frac{c}{b}\\ \mathbf{elif}\;b \le 1.9950290346988235 \cdot 10^{+62}:\\ \;\;\;\;\frac{-b}{2 \cdot a} - \frac{\sqrt{b \cdot b - \left(a \cdot c\right) \cdot 4}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-b}{2 \cdot a} - \left(\frac{1}{2} \cdot \frac{b}{a} - \frac{c}{b}\right)\\ \end{array}\]

Runtime

Time bar (total: 42.8s)Debug logProfile

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