Average Error: 33.8 → 8.7
Time: 13.1s
Precision: 64
\[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
\[\begin{array}{l} \mathbf{if}\;b_2 \le -7.93152454634661985 \cdot 10^{153}:\\ \;\;\;\;\mathsf{fma}\left(\frac{c}{b_2}, \frac{1}{2}, \frac{b_2}{a} \cdot -2\right)\\ \mathbf{elif}\;b_2 \le 1.3419504689715689 \cdot 10^{-262}:\\ \;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b_2, b_2, -a \cdot c\right)} - b_2}{a}\\ \mathbf{elif}\;b_2 \le 1.1172319783923582 \cdot 10^{-10}:\\ \;\;\;\;\frac{\frac{a \cdot c}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \end{array}\]
\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}
\begin{array}{l}
\mathbf{if}\;b_2 \le -7.93152454634661985 \cdot 10^{153}:\\
\;\;\;\;\mathsf{fma}\left(\frac{c}{b_2}, \frac{1}{2}, \frac{b_2}{a} \cdot -2\right)\\

\mathbf{elif}\;b_2 \le 1.3419504689715689 \cdot 10^{-262}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b_2, b_2, -a \cdot c\right)} - b_2}{a}\\

\mathbf{elif}\;b_2 \le 1.1172319783923582 \cdot 10^{-10}:\\
\;\;\;\;\frac{\frac{a \cdot c}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}{a}\\

\mathbf{else}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

\end{array}
double f(double a, double b_2, double c) {
        double r18548 = b_2;
        double r18549 = -r18548;
        double r18550 = r18548 * r18548;
        double r18551 = a;
        double r18552 = c;
        double r18553 = r18551 * r18552;
        double r18554 = r18550 - r18553;
        double r18555 = sqrt(r18554);
        double r18556 = r18549 + r18555;
        double r18557 = r18556 / r18551;
        return r18557;
}

double f(double a, double b_2, double c) {
        double r18558 = b_2;
        double r18559 = -7.93152454634662e+153;
        bool r18560 = r18558 <= r18559;
        double r18561 = c;
        double r18562 = r18561 / r18558;
        double r18563 = 0.5;
        double r18564 = a;
        double r18565 = r18558 / r18564;
        double r18566 = -2.0;
        double r18567 = r18565 * r18566;
        double r18568 = fma(r18562, r18563, r18567);
        double r18569 = 1.341950468971569e-262;
        bool r18570 = r18558 <= r18569;
        double r18571 = r18564 * r18561;
        double r18572 = -r18571;
        double r18573 = fma(r18558, r18558, r18572);
        double r18574 = sqrt(r18573);
        double r18575 = r18574 - r18558;
        double r18576 = r18575 / r18564;
        double r18577 = 1.1172319783923582e-10;
        bool r18578 = r18558 <= r18577;
        double r18579 = -r18558;
        double r18580 = r18558 * r18558;
        double r18581 = r18580 - r18571;
        double r18582 = sqrt(r18581);
        double r18583 = r18579 - r18582;
        double r18584 = r18571 / r18583;
        double r18585 = r18584 / r18564;
        double r18586 = -0.5;
        double r18587 = r18586 * r18562;
        double r18588 = r18578 ? r18585 : r18587;
        double r18589 = r18570 ? r18576 : r18588;
        double r18590 = r18560 ? r18568 : r18589;
        return r18590;
}

Error

Bits error versus a

Bits error versus b_2

Bits error versus c

Derivation

  1. Split input into 4 regimes
  2. if b_2 < -7.93152454634662e+153

    1. Initial program 63.8

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Using strategy rm
    3. Applied clear-num63.8

      \[\leadsto \color{blue}{\frac{1}{\frac{a}{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}}}\]
    4. Simplified63.8

      \[\leadsto \frac{1}{\color{blue}{\frac{a}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}\]
    5. Using strategy rm
    6. Applied *-un-lft-identity63.8

      \[\leadsto \frac{1}{\frac{a}{\color{blue}{1 \cdot \left(\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2\right)}}}\]
    7. Applied *-un-lft-identity63.8

      \[\leadsto \frac{1}{\frac{\color{blue}{1 \cdot a}}{1 \cdot \left(\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2\right)}}\]
    8. Applied times-frac63.8

      \[\leadsto \frac{1}{\color{blue}{\frac{1}{1} \cdot \frac{a}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}\]
    9. Applied add-cube-cbrt63.8

      \[\leadsto \frac{\color{blue}{\left(\sqrt[3]{1} \cdot \sqrt[3]{1}\right) \cdot \sqrt[3]{1}}}{\frac{1}{1} \cdot \frac{a}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}\]
    10. Applied times-frac63.8

      \[\leadsto \color{blue}{\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{\frac{1}{1}} \cdot \frac{\sqrt[3]{1}}{\frac{a}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}\]
    11. Simplified63.8

      \[\leadsto \color{blue}{1} \cdot \frac{\sqrt[3]{1}}{\frac{a}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}\]
    12. Simplified63.8

      \[\leadsto 1 \cdot \color{blue}{\frac{\sqrt{\mathsf{fma}\left(b_2, b_2, -a \cdot c\right)} - b_2}{a}}\]
    13. Taylor expanded around -inf 1.9

      \[\leadsto 1 \cdot \color{blue}{\left(\frac{1}{2} \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}\right)}\]
    14. Simplified1.9

      \[\leadsto 1 \cdot \color{blue}{\mathsf{fma}\left(\frac{c}{b_2}, \frac{1}{2}, \frac{b_2}{a} \cdot -2\right)}\]

    if -7.93152454634662e+153 < b_2 < 1.341950468971569e-262

    1. Initial program 8.9

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Using strategy rm
    3. Applied clear-num9.1

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

      \[\leadsto \frac{1}{\color{blue}{\frac{a}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}\]
    5. Using strategy rm
    6. Applied *-un-lft-identity9.1

      \[\leadsto \frac{1}{\frac{a}{\color{blue}{1 \cdot \left(\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2\right)}}}\]
    7. Applied *-un-lft-identity9.1

      \[\leadsto \frac{1}{\frac{\color{blue}{1 \cdot a}}{1 \cdot \left(\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2\right)}}\]
    8. Applied times-frac9.1

      \[\leadsto \frac{1}{\color{blue}{\frac{1}{1} \cdot \frac{a}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}\]
    9. Applied add-cube-cbrt9.1

      \[\leadsto \frac{\color{blue}{\left(\sqrt[3]{1} \cdot \sqrt[3]{1}\right) \cdot \sqrt[3]{1}}}{\frac{1}{1} \cdot \frac{a}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}\]
    10. Applied times-frac9.1

      \[\leadsto \color{blue}{\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{\frac{1}{1}} \cdot \frac{\sqrt[3]{1}}{\frac{a}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}\]
    11. Simplified9.1

      \[\leadsto \color{blue}{1} \cdot \frac{\sqrt[3]{1}}{\frac{a}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}\]
    12. Simplified8.9

      \[\leadsto 1 \cdot \color{blue}{\frac{\sqrt{\mathsf{fma}\left(b_2, b_2, -a \cdot c\right)} - b_2}{a}}\]

    if 1.341950468971569e-262 < b_2 < 1.1172319783923582e-10

    1. Initial program 26.1

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Using strategy rm
    3. Applied flip-+26.1

      \[\leadsto \frac{\color{blue}{\frac{\left(-b_2\right) \cdot \left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c}}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}}{a}\]
    4. Simplified18.3

      \[\leadsto \frac{\frac{\color{blue}{a \cdot c + 0}}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}{a}\]

    if 1.1172319783923582e-10 < b_2

    1. Initial program 55.3

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Using strategy rm
    3. Applied clear-num55.3

      \[\leadsto \color{blue}{\frac{1}{\frac{a}{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}}}\]
    4. Simplified55.3

      \[\leadsto \frac{1}{\color{blue}{\frac{a}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}\]
    5. Using strategy rm
    6. Applied *-un-lft-identity55.3

      \[\leadsto \frac{1}{\frac{a}{\color{blue}{1 \cdot \left(\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2\right)}}}\]
    7. Applied *-un-lft-identity55.3

      \[\leadsto \frac{1}{\frac{\color{blue}{1 \cdot a}}{1 \cdot \left(\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2\right)}}\]
    8. Applied times-frac55.3

      \[\leadsto \frac{1}{\color{blue}{\frac{1}{1} \cdot \frac{a}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}\]
    9. Applied add-cube-cbrt55.3

      \[\leadsto \frac{\color{blue}{\left(\sqrt[3]{1} \cdot \sqrt[3]{1}\right) \cdot \sqrt[3]{1}}}{\frac{1}{1} \cdot \frac{a}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}\]
    10. Applied times-frac55.3

      \[\leadsto \color{blue}{\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{\frac{1}{1}} \cdot \frac{\sqrt[3]{1}}{\frac{a}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}\]
    11. Simplified55.3

      \[\leadsto \color{blue}{1} \cdot \frac{\sqrt[3]{1}}{\frac{a}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}\]
    12. Simplified55.3

      \[\leadsto 1 \cdot \color{blue}{\frac{\sqrt{\mathsf{fma}\left(b_2, b_2, -a \cdot c\right)} - b_2}{a}}\]
    13. Taylor expanded around inf 6.1

      \[\leadsto 1 \cdot \color{blue}{\left(\frac{-1}{2} \cdot \frac{c}{b_2}\right)}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification8.7

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -7.93152454634661985 \cdot 10^{153}:\\ \;\;\;\;\mathsf{fma}\left(\frac{c}{b_2}, \frac{1}{2}, \frac{b_2}{a} \cdot -2\right)\\ \mathbf{elif}\;b_2 \le 1.3419504689715689 \cdot 10^{-262}:\\ \;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b_2, b_2, -a \cdot c\right)} - b_2}{a}\\ \mathbf{elif}\;b_2 \le 1.1172319783923582 \cdot 10^{-10}:\\ \;\;\;\;\frac{\frac{a \cdot c}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \end{array}\]

Reproduce

herbie shell --seed 2020043 +o rules:numerics
(FPCore (a b_2 c)
  :name "quad2p (problem 3.2.1, positive)"
  :precision binary64
  (/ (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))