Average Error: 33.2 → 9.8
Time: 18.6s
Precision: 64
\[\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.8774910265390396 \cdot 10^{-73}:\\ \;\;\;\;-\frac{c}{b}\\ \mathbf{elif}\;b \le 2.5703497435733685 \cdot 10^{+102}:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{a} \cdot \frac{1}{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \end{array}\]
\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.8774910265390396 \cdot 10^{-73}:\\
\;\;\;\;-\frac{c}{b}\\

\mathbf{elif}\;b \le 2.5703497435733685 \cdot 10^{+102}:\\
\;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{a} \cdot \frac{1}{2}\\

\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\

\end{array}
double f(double a, double b, double c) {
        double r1519362 = b;
        double r1519363 = -r1519362;
        double r1519364 = r1519362 * r1519362;
        double r1519365 = 4.0;
        double r1519366 = a;
        double r1519367 = c;
        double r1519368 = r1519366 * r1519367;
        double r1519369 = r1519365 * r1519368;
        double r1519370 = r1519364 - r1519369;
        double r1519371 = sqrt(r1519370);
        double r1519372 = r1519363 - r1519371;
        double r1519373 = 2.0;
        double r1519374 = r1519373 * r1519366;
        double r1519375 = r1519372 / r1519374;
        return r1519375;
}

double f(double a, double b, double c) {
        double r1519376 = b;
        double r1519377 = -1.8774910265390396e-73;
        bool r1519378 = r1519376 <= r1519377;
        double r1519379 = c;
        double r1519380 = r1519379 / r1519376;
        double r1519381 = -r1519380;
        double r1519382 = 2.5703497435733685e+102;
        bool r1519383 = r1519376 <= r1519382;
        double r1519384 = -r1519376;
        double r1519385 = r1519376 * r1519376;
        double r1519386 = 4.0;
        double r1519387 = a;
        double r1519388 = r1519387 * r1519379;
        double r1519389 = r1519386 * r1519388;
        double r1519390 = r1519385 - r1519389;
        double r1519391 = sqrt(r1519390);
        double r1519392 = r1519384 - r1519391;
        double r1519393 = r1519392 / r1519387;
        double r1519394 = 0.5;
        double r1519395 = r1519393 * r1519394;
        double r1519396 = r1519376 / r1519387;
        double r1519397 = r1519380 - r1519396;
        double r1519398 = r1519383 ? r1519395 : r1519397;
        double r1519399 = r1519378 ? r1519381 : r1519398;
        return r1519399;
}

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.2
Target20.4
Herbie9.8
\[\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 < -1.8774910265390396e-73

    1. Initial program 52.5

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

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

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

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

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

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

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

    if -1.8774910265390396e-73 < b < 2.5703497435733685e+102

    1. Initial program 13.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 *-un-lft-identity13.1

      \[\leadsto \frac{\left(-b\right) - \color{blue}{1 \cdot \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}}{2 \cdot a}\]
    4. Applied *-un-lft-identity13.1

      \[\leadsto \frac{\color{blue}{1 \cdot \left(-b\right)} - 1 \cdot \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\]
    5. Applied distribute-lft-out--13.1

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

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

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

      \[\leadsto \frac{1}{\frac{2 \cdot a}{\color{blue}{1 \cdot \left(-b\right)} - 1 \cdot \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}}\]
    10. Applied distribute-lft-out--13.2

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

      \[\leadsto \frac{1}{\color{blue}{\frac{2}{1} \cdot \frac{a}{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}}}\]
    12. Applied add-sqr-sqrt13.2

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

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

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

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

    if 2.5703497435733685e+102 < b

    1. Initial program 43.9

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

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

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

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

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

Reproduce

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