Average Error: 33.1 → 9.4
Time: 1.5m
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.7678040264959333 \cdot 10^{+146}:\\ \;\;\;\;\frac{c}{\mathsf{fma}\left(\frac{1}{2}, \left(\frac{a}{\frac{b_2}{c}}\right), \left(-2 \cdot b_2\right)\right)}\\ \mathbf{elif}\;b_2 \le 5.524249207244028 \cdot 10^{-127}:\\ \;\;\;\;\frac{c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}\\ \mathbf{elif}\;b_2 \le 5.890069572265506 \cdot 10^{-16}:\\ \;\;\;\;\frac{\frac{a \cdot c}{-\frac{a \cdot c}{b_2 + \sqrt{b_2 \cdot b_2 - a \cdot c}}}}{a}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\left(\frac{c}{b_2}\right), \frac{1}{2}, \left(\frac{-2}{a} \cdot b_2\right)\right)\\ \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.7678040264959333 \cdot 10^{+146}:\\
\;\;\;\;\frac{c}{\mathsf{fma}\left(\frac{1}{2}, \left(\frac{a}{\frac{b_2}{c}}\right), \left(-2 \cdot b_2\right)\right)}\\

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

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

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

\end{array}
double f(double a, double b_2, double c) {
        double r12347097 = b_2;
        double r12347098 = -r12347097;
        double r12347099 = r12347097 * r12347097;
        double r12347100 = a;
        double r12347101 = c;
        double r12347102 = r12347100 * r12347101;
        double r12347103 = r12347099 - r12347102;
        double r12347104 = sqrt(r12347103);
        double r12347105 = r12347098 - r12347104;
        double r12347106 = r12347105 / r12347100;
        return r12347106;
}

double f(double a, double b_2, double c) {
        double r12347107 = b_2;
        double r12347108 = -1.7678040264959333e+146;
        bool r12347109 = r12347107 <= r12347108;
        double r12347110 = c;
        double r12347111 = 0.5;
        double r12347112 = a;
        double r12347113 = r12347107 / r12347110;
        double r12347114 = r12347112 / r12347113;
        double r12347115 = -2.0;
        double r12347116 = r12347115 * r12347107;
        double r12347117 = fma(r12347111, r12347114, r12347116);
        double r12347118 = r12347110 / r12347117;
        double r12347119 = 5.524249207244028e-127;
        bool r12347120 = r12347107 <= r12347119;
        double r12347121 = r12347107 * r12347107;
        double r12347122 = r12347112 * r12347110;
        double r12347123 = r12347121 - r12347122;
        double r12347124 = sqrt(r12347123);
        double r12347125 = r12347124 - r12347107;
        double r12347126 = r12347110 / r12347125;
        double r12347127 = 5.890069572265506e-16;
        bool r12347128 = r12347107 <= r12347127;
        double r12347129 = r12347107 + r12347124;
        double r12347130 = r12347122 / r12347129;
        double r12347131 = -r12347130;
        double r12347132 = r12347122 / r12347131;
        double r12347133 = r12347132 / r12347112;
        double r12347134 = r12347110 / r12347107;
        double r12347135 = r12347115 / r12347112;
        double r12347136 = r12347135 * r12347107;
        double r12347137 = fma(r12347134, r12347111, r12347136);
        double r12347138 = r12347128 ? r12347133 : r12347137;
        double r12347139 = r12347120 ? r12347126 : r12347138;
        double r12347140 = r12347109 ? r12347118 : r12347139;
        return r12347140;
}

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.7678040264959333e+146

    1. Initial program 61.9

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

      \[\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. Simplified36.8

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

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

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

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

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

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

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

      \[\leadsto 1 \cdot \frac{c}{\color{blue}{\frac{1}{2} \cdot \frac{a \cdot c}{b_2} - 2 \cdot b_2}}\]
    13. Simplified1.6

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

    if -1.7678040264959333e+146 < b_2 < 5.524249207244028e-127

    1. Initial program 29.1

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Using strategy rm
    3. Applied flip--30.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. Simplified16.2

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

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

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

      \[\leadsto \frac{\color{blue}{1 \cdot \frac{a \cdot c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}{1 \cdot a}\]
    9. Applied times-frac16.2

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

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

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

    if 5.524249207244028e-127 < b_2 < 5.890069572265506e-16

    1. Initial program 6.4

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

      \[\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. Simplified36.2

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

      \[\leadsto \frac{\frac{a \cdot c}{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}{a}\]
    6. Using strategy rm
    7. Applied flip--36.2

      \[\leadsto \frac{\frac{a \cdot c}{\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}}}}{a}\]
    8. Simplified19.3

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

    if 5.890069572265506e-16 < b_2

    1. Initial program 28.8

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Taylor expanded around inf 9.4

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -1.7678040264959333 \cdot 10^{+146}:\\ \;\;\;\;\frac{c}{\mathsf{fma}\left(\frac{1}{2}, \left(\frac{a}{\frac{b_2}{c}}\right), \left(-2 \cdot b_2\right)\right)}\\ \mathbf{elif}\;b_2 \le 5.524249207244028 \cdot 10^{-127}:\\ \;\;\;\;\frac{c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}\\ \mathbf{elif}\;b_2 \le 5.890069572265506 \cdot 10^{-16}:\\ \;\;\;\;\frac{\frac{a \cdot c}{-\frac{a \cdot c}{b_2 + \sqrt{b_2 \cdot b_2 - a \cdot c}}}}{a}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\left(\frac{c}{b_2}\right), \frac{1}{2}, \left(\frac{-2}{a} \cdot b_2\right)\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019125 +o rules:numerics
(FPCore (a b_2 c)
  :name "NMSE problem 3.2.1"
  (/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))