Average Error: 33.8 → 12.9
Time: 32.2s
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 -2.101293750180749 \cdot 10^{+143}:\\ \;\;\;\;\frac{-2 \cdot \frac{a \cdot c}{b}}{a} \cdot \frac{1}{2}\\ \mathbf{elif}\;b \le -1.6881136136793343 \cdot 10^{-90}:\\ \;\;\;\;\frac{\left(4 \cdot c\right) \cdot a}{\left(\sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)} + \left(-b\right)\right) \cdot \left(a \cdot 2\right)}\\ \mathbf{elif}\;b \le 3.02491424793758 \cdot 10^{+47}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{\left(-b\right) - \sqrt{c \cdot \left(a \cdot -4\right) + b \cdot b}}{a}\\ \mathbf{else}:\\ \;\;\;\;-\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.8
Target21.3
Herbie12.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 4 regimes
  2. if b < -2.101293750180749e+143

    1. Initial program 61.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 sub-neg61.9

      \[\leadsto \frac{\left(-b\right) - \sqrt{\color{blue}{b \cdot b + \left(-4 \cdot \left(a \cdot c\right)\right)}}}{2 \cdot a}\]
    4. Using strategy rm
    5. Applied *-un-lft-identity61.9

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

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

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

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

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

    if -2.101293750180749e+143 < b < -1.6881136136793343e-90

    1. Initial program 43.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--43.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 associate-/l/45.8

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

      \[\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 -1.6881136136793343e-90 < b < 3.02491424793758e+47

    1. Initial program 13.7

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

      \[\leadsto \frac{\left(-b\right) - \sqrt{\color{blue}{b \cdot b + \left(-4 \cdot \left(a \cdot c\right)\right)}}}{2 \cdot a}\]
    4. Using strategy rm
    5. Applied *-un-lft-identity13.7

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

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

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

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

    if 3.02491424793758e+47 < b

    1. Initial program 36.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 sub-neg36.1

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

      \[\leadsto \color{blue}{-1 \cdot \frac{b}{a}}\]
    5. Simplified6.0

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -2.101293750180749 \cdot 10^{+143}:\\ \;\;\;\;\frac{-2 \cdot \frac{a \cdot c}{b}}{a} \cdot \frac{1}{2}\\ \mathbf{elif}\;b \le -1.6881136136793343 \cdot 10^{-90}:\\ \;\;\;\;\frac{\left(4 \cdot c\right) \cdot a}{\left(\sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)} + \left(-b\right)\right) \cdot \left(a \cdot 2\right)}\\ \mathbf{elif}\;b \le 3.02491424793758 \cdot 10^{+47}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{\left(-b\right) - \sqrt{c \cdot \left(a \cdot -4\right) + b \cdot b}}{a}\\ \mathbf{else}:\\ \;\;\;\;-\frac{b}{a}\\ \end{array}\]

Runtime

Time bar (total: 32.2s)Debug logProfile

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