Average Error: 19.7 → 7.1
Time: 25.7s
Precision: 64
\[\begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array}\]
\[\begin{array}{l} \mathbf{if}\;b \le -8.035809894237901445931970544225072398237 \cdot 10^{152}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \left(b - \left(2 \cdot c\right) \cdot \frac{a}{b}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{a}{b} \cdot c, 2, b \cdot -2\right)}{a \cdot 2}\\ \end{array}\\ \mathbf{elif}\;b \le 2.235297100260681827349252490508121260989 \cdot 10^{45}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{2 \cdot c}{\mathsf{fma}\left(\sqrt[3]{-b} \cdot \sqrt[3]{-b}, \sqrt[3]{-b}, \left(-\sqrt{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\right) \cdot \sqrt{\sqrt{\sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c}} \cdot \sqrt{\sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c} \cdot \sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c}}}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{a \cdot 2}\\ \end{array}\\ \mathbf{elif}\;b \ge 0.0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \left(b - \left(2 \cdot c\right) \cdot \frac{a}{b}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \left(2 \cdot \frac{a \cdot c}{b} - b\right)}{a \cdot 2}\\ \end{array}\]
\begin{array}{l}
\mathbf{if}\;b \ge 0.0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\

\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\

\end{array}
\begin{array}{l}
\mathbf{if}\;b \le -8.035809894237901445931970544225072398237 \cdot 10^{152}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \ge 0.0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \left(b - \left(2 \cdot c\right) \cdot \frac{a}{b}\right)}\\

\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{a}{b} \cdot c, 2, b \cdot -2\right)}{a \cdot 2}\\

\end{array}\\

\mathbf{elif}\;b \le 2.235297100260681827349252490508121260989 \cdot 10^{45}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \ge 0.0:\\
\;\;\;\;\frac{2 \cdot c}{\mathsf{fma}\left(\sqrt[3]{-b} \cdot \sqrt[3]{-b}, \sqrt[3]{-b}, \left(-\sqrt{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\right) \cdot \sqrt{\sqrt{\sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c}} \cdot \sqrt{\sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c} \cdot \sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c}}}\right)}\\

\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{a \cdot 2}\\

\end{array}\\

\mathbf{elif}\;b \ge 0.0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \left(b - \left(2 \cdot c\right) \cdot \frac{a}{b}\right)}\\

\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) + \left(2 \cdot \frac{a \cdot c}{b} - b\right)}{a \cdot 2}\\

\end{array}
double f(double a, double b, double c) {
        double r1029281 = b;
        double r1029282 = 0.0;
        bool r1029283 = r1029281 >= r1029282;
        double r1029284 = 2.0;
        double r1029285 = c;
        double r1029286 = r1029284 * r1029285;
        double r1029287 = -r1029281;
        double r1029288 = r1029281 * r1029281;
        double r1029289 = 4.0;
        double r1029290 = a;
        double r1029291 = r1029289 * r1029290;
        double r1029292 = r1029291 * r1029285;
        double r1029293 = r1029288 - r1029292;
        double r1029294 = sqrt(r1029293);
        double r1029295 = r1029287 - r1029294;
        double r1029296 = r1029286 / r1029295;
        double r1029297 = r1029287 + r1029294;
        double r1029298 = r1029284 * r1029290;
        double r1029299 = r1029297 / r1029298;
        double r1029300 = r1029283 ? r1029296 : r1029299;
        return r1029300;
}

double f(double a, double b, double c) {
        double r1029301 = b;
        double r1029302 = -8.035809894237901e+152;
        bool r1029303 = r1029301 <= r1029302;
        double r1029304 = 0.0;
        bool r1029305 = r1029301 >= r1029304;
        double r1029306 = 2.0;
        double r1029307 = c;
        double r1029308 = r1029306 * r1029307;
        double r1029309 = -r1029301;
        double r1029310 = a;
        double r1029311 = r1029310 / r1029301;
        double r1029312 = r1029308 * r1029311;
        double r1029313 = r1029301 - r1029312;
        double r1029314 = r1029309 - r1029313;
        double r1029315 = r1029308 / r1029314;
        double r1029316 = r1029311 * r1029307;
        double r1029317 = -2.0;
        double r1029318 = r1029301 * r1029317;
        double r1029319 = fma(r1029316, r1029306, r1029318);
        double r1029320 = r1029310 * r1029306;
        double r1029321 = r1029319 / r1029320;
        double r1029322 = r1029305 ? r1029315 : r1029321;
        double r1029323 = 2.2352971002606818e+45;
        bool r1029324 = r1029301 <= r1029323;
        double r1029325 = cbrt(r1029309);
        double r1029326 = r1029325 * r1029325;
        double r1029327 = r1029301 * r1029301;
        double r1029328 = 4.0;
        double r1029329 = r1029328 * r1029310;
        double r1029330 = r1029329 * r1029307;
        double r1029331 = r1029327 - r1029330;
        double r1029332 = sqrt(r1029331);
        double r1029333 = sqrt(r1029332);
        double r1029334 = -r1029333;
        double r1029335 = cbrt(r1029331);
        double r1029336 = sqrt(r1029335);
        double r1029337 = r1029335 * r1029335;
        double r1029338 = sqrt(r1029337);
        double r1029339 = r1029336 * r1029338;
        double r1029340 = sqrt(r1029339);
        double r1029341 = r1029334 * r1029340;
        double r1029342 = fma(r1029326, r1029325, r1029341);
        double r1029343 = r1029308 / r1029342;
        double r1029344 = r1029309 + r1029332;
        double r1029345 = r1029344 / r1029320;
        double r1029346 = r1029305 ? r1029343 : r1029345;
        double r1029347 = r1029310 * r1029307;
        double r1029348 = r1029347 / r1029301;
        double r1029349 = r1029306 * r1029348;
        double r1029350 = r1029349 - r1029301;
        double r1029351 = r1029309 + r1029350;
        double r1029352 = r1029351 / r1029320;
        double r1029353 = r1029305 ? r1029315 : r1029352;
        double r1029354 = r1029324 ? r1029346 : r1029353;
        double r1029355 = r1029303 ? r1029322 : r1029354;
        return r1029355;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 3 regimes
  2. if b < -8.035809894237901e+152

    1. Initial program 63.6

      \[\begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array}\]
    2. Taylor expanded around inf 63.6

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \color{blue}{\left(b - 2 \cdot \frac{a \cdot c}{b}\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array}\]
    3. Simplified63.6

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \color{blue}{\left(b - \frac{a}{b} \cdot \left(2 \cdot c\right)\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array}\]
    4. Taylor expanded around -inf 12.1

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \left(b - \frac{a}{b} \cdot \left(2 \cdot c\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot \frac{a \cdot c}{b} - 2 \cdot b}{2 \cdot a}\\ \end{array}\]
    5. Simplified2.1

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \left(b - \frac{a}{b} \cdot \left(2 \cdot c\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{a}{b} \cdot c, 2, -2 \cdot b\right)}{2 \cdot a}\\ \end{array}\]

    if -8.035809894237901e+152 < b < 2.2352971002606818e+45

    1. Initial program 9.3

      \[\begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array}\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt9.3

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{\color{blue}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} \cdot \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array}\]
    4. Applied sqrt-prod9.4

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \color{blue}{\sqrt{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}} \cdot \sqrt{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array}\]
    5. Applied add-cube-cbrt9.5

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{2 \cdot c}{\color{blue}{\left(\sqrt[3]{-b} \cdot \sqrt[3]{-b}\right) \cdot \sqrt[3]{-b}} - \sqrt{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}} \cdot \sqrt{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array}\]
    6. Applied prod-diff9.6

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{2 \cdot c}{\color{blue}{\mathsf{fma}\left(\sqrt[3]{-b} \cdot \sqrt[3]{-b}, \sqrt[3]{-b}, -\sqrt{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}} \cdot \sqrt{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\right) + \mathsf{fma}\left(-\sqrt{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}, \sqrt{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}, \sqrt{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}} \cdot \sqrt{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array}\]
    7. Simplified9.5

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{2 \cdot c}{\mathsf{fma}\left(\sqrt[3]{-b} \cdot \sqrt[3]{-b}, \sqrt[3]{-b}, -\sqrt{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}} \cdot \sqrt{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\right) + \color{blue}{0}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array}\]
    8. Using strategy rm
    9. Applied add-cube-cbrt9.5

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{2 \cdot c}{\mathsf{fma}\left(\sqrt[3]{-b} \cdot \sqrt[3]{-b}, \sqrt[3]{-b}, -\sqrt{\sqrt{\color{blue}{\left(\sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c} \cdot \sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c}\right) \cdot \sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c}}}} \cdot \sqrt{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\right) + 0}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array}\]
    10. Applied sqrt-prod9.5

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{2 \cdot c}{\mathsf{fma}\left(\sqrt[3]{-b} \cdot \sqrt[3]{-b}, \sqrt[3]{-b}, -\sqrt{\color{blue}{\sqrt{\sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c} \cdot \sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c}} \cdot \sqrt{\sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c}}}} \cdot \sqrt{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\right) + 0}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array}\]

    if 2.2352971002606818e+45 < b

    1. Initial program 25.1

      \[\begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array}\]
    2. Taylor expanded around inf 7.2

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \color{blue}{\left(b - 2 \cdot \frac{a \cdot c}{b}\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array}\]
    3. Simplified4.0

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \color{blue}{\left(b - \frac{a}{b} \cdot \left(2 \cdot c\right)\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array}\]
    4. Taylor expanded around -inf 4.0

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \left(b - \frac{a}{b} \cdot \left(2 \cdot c\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \left(2 \cdot \frac{a \cdot c}{b} - b\right)}{2 \cdot a}\\ \end{array}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification7.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -8.035809894237901445931970544225072398237 \cdot 10^{152}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \left(b - \left(2 \cdot c\right) \cdot \frac{a}{b}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{a}{b} \cdot c, 2, b \cdot -2\right)}{a \cdot 2}\\ \end{array}\\ \mathbf{elif}\;b \le 2.235297100260681827349252490508121260989 \cdot 10^{45}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{2 \cdot c}{\mathsf{fma}\left(\sqrt[3]{-b} \cdot \sqrt[3]{-b}, \sqrt[3]{-b}, \left(-\sqrt{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\right) \cdot \sqrt{\sqrt{\sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c}} \cdot \sqrt{\sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c} \cdot \sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c}}}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{a \cdot 2}\\ \end{array}\\ \mathbf{elif}\;b \ge 0.0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \left(b - \left(2 \cdot c\right) \cdot \frac{a}{b}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \left(2 \cdot \frac{a \cdot c}{b} - b\right)}{a \cdot 2}\\ \end{array}\]

Reproduce

herbie shell --seed 2019169 +o rules:numerics
(FPCore (a b c)
  :name "jeff quadratic root 2"
  (if (>= b 0.0) (/ (* 2.0 c) (- (- b) (sqrt (- (* b b) (* (* 4.0 a) c))))) (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a))))