Average Error: 33.2 → 10.1
Time: 19.9s
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.499464302465673 \cdot 10^{+151}:\\ \;\;\;\;\mathsf{fma}\left(\frac{b_2}{a}, -2, \frac{\frac{1}{2} \cdot c}{b_2}\right)\\ \mathbf{elif}\;b_2 \le 5.930445637544082 \cdot 10^{-86}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\sqrt{\sqrt[3]{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt[3]{b_2 \cdot b_2 - a \cdot c}}, \sqrt{\sqrt[3]{b_2 \cdot b_2 - a \cdot c}}, -b_2\right)}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b_2} \cdot \frac{-1}{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.499464302465673 \cdot 10^{+151}:\\
\;\;\;\;\mathsf{fma}\left(\frac{b_2}{a}, -2, \frac{\frac{1}{2} \cdot c}{b_2}\right)\\

\mathbf{elif}\;b_2 \le 5.930445637544082 \cdot 10^{-86}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\sqrt{\sqrt[3]{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt[3]{b_2 \cdot b_2 - a \cdot c}}, \sqrt{\sqrt[3]{b_2 \cdot b_2 - a \cdot c}}, -b_2\right)}{a}\\

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

\end{array}
double f(double a, double b_2, double c) {
        double r647103 = b_2;
        double r647104 = -r647103;
        double r647105 = r647103 * r647103;
        double r647106 = a;
        double r647107 = c;
        double r647108 = r647106 * r647107;
        double r647109 = r647105 - r647108;
        double r647110 = sqrt(r647109);
        double r647111 = r647104 + r647110;
        double r647112 = r647111 / r647106;
        return r647112;
}

double f(double a, double b_2, double c) {
        double r647113 = b_2;
        double r647114 = -4.499464302465673e+151;
        bool r647115 = r647113 <= r647114;
        double r647116 = a;
        double r647117 = r647113 / r647116;
        double r647118 = -2.0;
        double r647119 = 0.5;
        double r647120 = c;
        double r647121 = r647119 * r647120;
        double r647122 = r647121 / r647113;
        double r647123 = fma(r647117, r647118, r647122);
        double r647124 = 5.930445637544082e-86;
        bool r647125 = r647113 <= r647124;
        double r647126 = r647113 * r647113;
        double r647127 = r647116 * r647120;
        double r647128 = r647126 - r647127;
        double r647129 = cbrt(r647128);
        double r647130 = r647129 * r647129;
        double r647131 = sqrt(r647130);
        double r647132 = sqrt(r647129);
        double r647133 = -r647113;
        double r647134 = fma(r647131, r647132, r647133);
        double r647135 = r647134 / r647116;
        double r647136 = r647120 / r647113;
        double r647137 = -0.5;
        double r647138 = r647136 * r647137;
        double r647139 = r647125 ? r647135 : r647138;
        double r647140 = r647115 ? r647123 : r647139;
        return r647140;
}

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.499464302465673e+151

    1. Initial program 59.7

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

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

      \[\leadsto \color{blue}{\frac{1}{2} \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}}\]
    4. Simplified2.1

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

    if -4.499464302465673e+151 < b_2 < 5.930445637544082e-86

    1. Initial program 11.6

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

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. Using strategy rm
    4. Applied add-cube-cbrt12.0

      \[\leadsto \frac{\sqrt{\color{blue}{\left(\sqrt[3]{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt[3]{b_2 \cdot b_2 - a \cdot c}\right) \cdot \sqrt[3]{b_2 \cdot b_2 - a \cdot c}}} - b_2}{a}\]
    5. Applied sqrt-prod12.0

      \[\leadsto \frac{\color{blue}{\sqrt{\sqrt[3]{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt[3]{b_2 \cdot b_2 - a \cdot c}} \cdot \sqrt{\sqrt[3]{b_2 \cdot b_2 - a \cdot c}}} - b_2}{a}\]
    6. Applied fma-neg12.0

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

    if 5.930445637544082e-86 < b_2

    1. Initial program 52.2

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -4.499464302465673 \cdot 10^{+151}:\\ \;\;\;\;\mathsf{fma}\left(\frac{b_2}{a}, -2, \frac{\frac{1}{2} \cdot c}{b_2}\right)\\ \mathbf{elif}\;b_2 \le 5.930445637544082 \cdot 10^{-86}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\sqrt{\sqrt[3]{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt[3]{b_2 \cdot b_2 - a \cdot c}}, \sqrt{\sqrt[3]{b_2 \cdot b_2 - a \cdot c}}, -b_2\right)}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b_2} \cdot \frac{-1}{2}\\ \end{array}\]

Reproduce

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