Average Error: 33.4 → 11.2
Time: 13.2s
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 -4.416784199311460515648544007521584449255 \cdot 10^{139}:\\ \;\;\;\;\mathsf{fma}\left(\frac{c}{b_2}, \frac{1}{2}, \frac{b_2}{a} \cdot -2\right)\\ \mathbf{elif}\;b_2 \le 5.330769455174493332636713829620953568317 \cdot 10^{-168} \lor \neg \left(b_2 \le 3.705250296078930544323375298653357812472 \cdot 10^{-110}\right) \land b_2 \le 1.846537578115044209159378851836663670838 \cdot 10^{-4}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{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 -4.416784199311460515648544007521584449255 \cdot 10^{139}:\\
\;\;\;\;\mathsf{fma}\left(\frac{c}{b_2}, \frac{1}{2}, \frac{b_2}{a} \cdot -2\right)\\

\mathbf{elif}\;b_2 \le 5.330769455174493332636713829620953568317 \cdot 10^{-168} \lor \neg \left(b_2 \le 3.705250296078930544323375298653357812472 \cdot 10^{-110}\right) \land b_2 \le 1.846537578115044209159378851836663670838 \cdot 10^{-4}:\\
\;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}\\

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

\end{array}
double f(double a, double b_2, double c) {
        double r16626 = b_2;
        double r16627 = -r16626;
        double r16628 = r16626 * r16626;
        double r16629 = a;
        double r16630 = c;
        double r16631 = r16629 * r16630;
        double r16632 = r16628 - r16631;
        double r16633 = sqrt(r16632);
        double r16634 = r16627 + r16633;
        double r16635 = r16634 / r16629;
        return r16635;
}

double f(double a, double b_2, double c) {
        double r16636 = b_2;
        double r16637 = -4.4167841993114605e+139;
        bool r16638 = r16636 <= r16637;
        double r16639 = c;
        double r16640 = r16639 / r16636;
        double r16641 = 0.5;
        double r16642 = a;
        double r16643 = r16636 / r16642;
        double r16644 = -2.0;
        double r16645 = r16643 * r16644;
        double r16646 = fma(r16640, r16641, r16645);
        double r16647 = 5.330769455174493e-168;
        bool r16648 = r16636 <= r16647;
        double r16649 = 3.7052502960789305e-110;
        bool r16650 = r16636 <= r16649;
        double r16651 = !r16650;
        double r16652 = 0.00018465375781150442;
        bool r16653 = r16636 <= r16652;
        bool r16654 = r16651 && r16653;
        bool r16655 = r16648 || r16654;
        double r16656 = r16636 * r16636;
        double r16657 = r16642 * r16639;
        double r16658 = r16656 - r16657;
        double r16659 = sqrt(r16658);
        double r16660 = r16659 - r16636;
        double r16661 = r16660 / r16642;
        double r16662 = -0.5;
        double r16663 = r16662 * r16640;
        double r16664 = r16655 ? r16661 : r16663;
        double r16665 = r16638 ? r16646 : r16664;
        return r16665;
}

Error

Bits error versus a

Bits error versus b_2

Bits error versus c

Derivation

  1. Split input into 3 regimes
  2. if b_2 < -4.4167841993114605e+139

    1. Initial program 58.7

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Simplified58.7

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. Using strategy rm
    4. Applied clear-num58.8

      \[\leadsto \color{blue}{\frac{1}{\frac{a}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}\]
    5. Using strategy rm
    6. Applied *-un-lft-identity58.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-identity58.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-frac58.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-cbrt58.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-frac58.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. Simplified58.8

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

      \[\leadsto 1 \cdot \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    13. Taylor expanded around -inf 2.7

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

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

    if -4.4167841993114605e+139 < b_2 < 5.330769455174493e-168 or 3.7052502960789305e-110 < b_2 < 0.00018465375781150442

    1. Initial program 13.8

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Simplified13.8

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. Using strategy rm
    4. Applied clear-num13.9

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

      \[\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-identity13.9

      \[\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-frac13.9

      \[\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-cbrt13.9

      \[\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-frac13.9

      \[\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. Simplified13.9

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

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

    if 5.330769455174493e-168 < b_2 < 3.7052502960789305e-110 or 0.00018465375781150442 < b_2

    1. Initial program 51.7

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Simplified51.7

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. Using strategy rm
    4. Applied clear-num51.7

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

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

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

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

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

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

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

      \[\leadsto 1 \cdot \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    13. Taylor expanded around inf 10.4

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -4.416784199311460515648544007521584449255 \cdot 10^{139}:\\ \;\;\;\;\mathsf{fma}\left(\frac{c}{b_2}, \frac{1}{2}, \frac{b_2}{a} \cdot -2\right)\\ \mathbf{elif}\;b_2 \le 5.330769455174493332636713829620953568317 \cdot 10^{-168} \lor \neg \left(b_2 \le 3.705250296078930544323375298653357812472 \cdot 10^{-110}\right) \land b_2 \le 1.846537578115044209159378851836663670838 \cdot 10^{-4}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \end{array}\]

Reproduce

herbie shell --seed 2019350 +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))