Average Error: 33.1 → 9.1
Time: 1.4m
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 -1.6124744946043857 \cdot 10^{+143}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{1}{2}, \left(\frac{a}{\frac{b_2}{c}}\right), \left(b_2 \cdot -2\right)\right)}{a}\\ \mathbf{elif}\;b_2 \le 3.3843940179135867 \cdot 10^{-248}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}\\ \mathbf{elif}\;b_2 \le 9.494042583021857 \cdot 10^{+36}:\\ \;\;\;\;\frac{-\frac{a \cdot c}{a}}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}\\ \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 -1.6124744946043857 \cdot 10^{+143}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{1}{2}, \left(\frac{a}{\frac{b_2}{c}}\right), \left(b_2 \cdot -2\right)\right)}{a}\\

\mathbf{elif}\;b_2 \le 3.3843940179135867 \cdot 10^{-248}:\\
\;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}\\

\mathbf{elif}\;b_2 \le 9.494042583021857 \cdot 10^{+36}:\\
\;\;\;\;\frac{-\frac{a \cdot c}{a}}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}\\

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

\end{array}
double f(double a, double b_2, double c) {
        double r3218327 = b_2;
        double r3218328 = -r3218327;
        double r3218329 = r3218327 * r3218327;
        double r3218330 = a;
        double r3218331 = c;
        double r3218332 = r3218330 * r3218331;
        double r3218333 = r3218329 - r3218332;
        double r3218334 = sqrt(r3218333);
        double r3218335 = r3218328 + r3218334;
        double r3218336 = r3218335 / r3218330;
        return r3218336;
}

double f(double a, double b_2, double c) {
        double r3218337 = b_2;
        double r3218338 = -1.6124744946043857e+143;
        bool r3218339 = r3218337 <= r3218338;
        double r3218340 = 0.5;
        double r3218341 = a;
        double r3218342 = c;
        double r3218343 = r3218337 / r3218342;
        double r3218344 = r3218341 / r3218343;
        double r3218345 = -2.0;
        double r3218346 = r3218337 * r3218345;
        double r3218347 = fma(r3218340, r3218344, r3218346);
        double r3218348 = r3218347 / r3218341;
        double r3218349 = 3.3843940179135867e-248;
        bool r3218350 = r3218337 <= r3218349;
        double r3218351 = r3218337 * r3218337;
        double r3218352 = r3218341 * r3218342;
        double r3218353 = r3218351 - r3218352;
        double r3218354 = sqrt(r3218353);
        double r3218355 = r3218354 - r3218337;
        double r3218356 = r3218355 / r3218341;
        double r3218357 = 9.494042583021857e+36;
        bool r3218358 = r3218337 <= r3218357;
        double r3218359 = r3218352 / r3218341;
        double r3218360 = -r3218359;
        double r3218361 = r3218354 + r3218337;
        double r3218362 = r3218360 / r3218361;
        double r3218363 = r3218342 / r3218337;
        double r3218364 = -0.5;
        double r3218365 = r3218363 * r3218364;
        double r3218366 = r3218358 ? r3218362 : r3218365;
        double r3218367 = r3218350 ? r3218356 : r3218366;
        double r3218368 = r3218339 ? r3218348 : r3218367;
        return r3218368;
}

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 < -1.6124744946043857e+143

    1. Initial program 57.1

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

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

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

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

    if -1.6124744946043857e+143 < b_2 < 3.3843940179135867e-248

    1. Initial program 9.4

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

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

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

      \[\leadsto \frac{\color{blue}{1 \cdot \sqrt{b_2 \cdot b_2 - a \cdot c}} - 1 \cdot b_2}{a}\]
    6. Applied distribute-lft-out--9.4

      \[\leadsto \frac{\color{blue}{1 \cdot \left(\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2\right)}}{a}\]
    7. Applied associate-/l*9.5

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

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

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

      \[\leadsto \frac{1}{\color{blue}{\frac{1}{1} \cdot \frac{a}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}\]
    12. Applied add-sqr-sqrt9.5

      \[\leadsto \frac{\color{blue}{\sqrt{1} \cdot \sqrt{1}}}{\frac{1}{1} \cdot \frac{a}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}\]
    13. Applied times-frac9.5

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

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

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

    if 3.3843940179135867e-248 < b_2 < 9.494042583021857e+36

    1. Initial program 31.1

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

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

      \[\leadsto \frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - \color{blue}{1 \cdot b_2}}{a}\]
    5. Applied *-un-lft-identity31.1

      \[\leadsto \frac{\color{blue}{1 \cdot \sqrt{b_2 \cdot b_2 - a \cdot c}} - 1 \cdot b_2}{a}\]
    6. Applied distribute-lft-out--31.1

      \[\leadsto \frac{\color{blue}{1 \cdot \left(\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2\right)}}{a}\]
    7. Applied associate-/l*31.1

      \[\leadsto \color{blue}{\frac{1}{\frac{a}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}\]
    8. Using strategy rm
    9. Applied flip--31.2

      \[\leadsto \frac{1}{\frac{a}{\color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c} - b_2 \cdot b_2}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}}}}\]
    10. Applied associate-/r/31.3

      \[\leadsto \frac{1}{\color{blue}{\frac{a}{\sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c} - b_2 \cdot b_2} \cdot \left(\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2\right)}}\]
    11. Applied associate-/r*31.2

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

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

    if 9.494042583021857e+36 < b_2

    1. Initial program 55.2

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

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. Using strategy rm
    4. Applied div-inv55.2

      \[\leadsto \color{blue}{\left(\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2\right) \cdot \frac{1}{a}}\]
    5. Taylor expanded around inf 5.0

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -1.6124744946043857 \cdot 10^{+143}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{1}{2}, \left(\frac{a}{\frac{b_2}{c}}\right), \left(b_2 \cdot -2\right)\right)}{a}\\ \mathbf{elif}\;b_2 \le 3.3843940179135867 \cdot 10^{-248}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}\\ \mathbf{elif}\;b_2 \le 9.494042583021857 \cdot 10^{+36}:\\ \;\;\;\;\frac{-\frac{a \cdot c}{a}}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b_2} \cdot \frac{-1}{2}\\ \end{array}\]

Reproduce

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