Average Error: 33.6 → 10.5
Time: 21.5s
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 -1.1752148889497213 \cdot 10^{+82}:\\ \;\;\;\;\frac{-c}{b}\\ \mathbf{elif}\;b \le -5.0686223234608026 \cdot 10^{+32}:\\ \;\;\;\;\frac{\left(4 \cdot c\right) \cdot a}{\left(2 \cdot a\right) \cdot \left(\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right)}\\ \mathbf{elif}\;b \le -8.718490259337974 \cdot 10^{-24}:\\ \;\;\;\;\frac{-c}{b}\\ \mathbf{elif}\;b \le 1.5737584830589724 \cdot 10^{+148}:\\ \;\;\;\;\frac{-b}{2 \cdot a} - \frac{\sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-b}{2 \cdot a} - \frac{1}{2} \cdot \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.6
Target20.9
Herbie10.5
\[\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.1752148889497213e+82 or -5.0686223234608026e+32 < b < -8.718490259337974e-24

    1. Initial program 55.9

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

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

      \[\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 associate-/l*58.0

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

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

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

    if -1.1752148889497213e+82 < b < -5.0686223234608026e+32

    1. Initial program 44.5

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

      \[\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 associate-/l/48.0

      \[\leadsto \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(2 \cdot a\right) \cdot \left(\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right)}}\]
    5. Simplified15.5

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

    if -8.718490259337974e-24 < b < 1.5737584830589724e+148

    1. Initial program 14.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-sub14.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 1.5737584830589724e+148 < b

    1. Initial program 58.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-sub58.3

      \[\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 *-un-lft-identity58.3

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

      \[\leadsto \frac{-b}{2 \cdot a} - \frac{\color{blue}{\sqrt{1} \cdot \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}}{2 \cdot a}\]
    7. Applied associate-/l*58.3

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

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

      \[\leadsto \frac{-b}{2 \cdot a} - \color{blue}{\frac{1}{2} \cdot \frac{b}{a}}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification10.5

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -1.1752148889497213 \cdot 10^{+82}:\\ \;\;\;\;\frac{-c}{b}\\ \mathbf{elif}\;b \le -5.0686223234608026 \cdot 10^{+32}:\\ \;\;\;\;\frac{\left(4 \cdot c\right) \cdot a}{\left(2 \cdot a\right) \cdot \left(\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right)}\\ \mathbf{elif}\;b \le -8.718490259337974 \cdot 10^{-24}:\\ \;\;\;\;\frac{-c}{b}\\ \mathbf{elif}\;b \le 1.5737584830589724 \cdot 10^{+148}:\\ \;\;\;\;\frac{-b}{2 \cdot a} - \frac{\sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-b}{2 \cdot a} - \frac{1}{2} \cdot \frac{b}{a}\\ \end{array}\]

Reproduce

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