Average Error: 32.5 → 7.0
Time: 26.7s
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 -2.4629151126589693 \cdot 10^{+107}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le -9.739621771792007 \cdot 10^{-284}:\\ \;\;\;\;\frac{c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}\\ \mathbf{elif}\;b_2 \le 5.3869004057037945 \cdot 10^{+35}:\\ \;\;\;\;\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{c}{b_2}, \frac{1}{2}, \frac{b_2}{a} \cdot -2\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 -2.4629151126589693 \cdot 10^{+107}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

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

\mathbf{elif}\;b_2 \le 5.3869004057037945 \cdot 10^{+35}:\\
\;\;\;\;\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\\

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

\end{array}
double f(double a, double b_2, double c) {
        double r1752778 = b_2;
        double r1752779 = -r1752778;
        double r1752780 = r1752778 * r1752778;
        double r1752781 = a;
        double r1752782 = c;
        double r1752783 = r1752781 * r1752782;
        double r1752784 = r1752780 - r1752783;
        double r1752785 = sqrt(r1752784);
        double r1752786 = r1752779 - r1752785;
        double r1752787 = r1752786 / r1752781;
        return r1752787;
}

double f(double a, double b_2, double c) {
        double r1752788 = b_2;
        double r1752789 = -2.4629151126589693e+107;
        bool r1752790 = r1752788 <= r1752789;
        double r1752791 = -0.5;
        double r1752792 = c;
        double r1752793 = r1752792 / r1752788;
        double r1752794 = r1752791 * r1752793;
        double r1752795 = -9.739621771792007e-284;
        bool r1752796 = r1752788 <= r1752795;
        double r1752797 = r1752788 * r1752788;
        double r1752798 = a;
        double r1752799 = r1752798 * r1752792;
        double r1752800 = r1752797 - r1752799;
        double r1752801 = sqrt(r1752800);
        double r1752802 = r1752801 - r1752788;
        double r1752803 = r1752792 / r1752802;
        double r1752804 = 5.3869004057037945e+35;
        bool r1752805 = r1752788 <= r1752804;
        double r1752806 = -r1752788;
        double r1752807 = r1752806 - r1752801;
        double r1752808 = r1752807 / r1752798;
        double r1752809 = 0.5;
        double r1752810 = r1752788 / r1752798;
        double r1752811 = -2.0;
        double r1752812 = r1752810 * r1752811;
        double r1752813 = fma(r1752793, r1752809, r1752812);
        double r1752814 = r1752805 ? r1752808 : r1752813;
        double r1752815 = r1752796 ? r1752803 : r1752814;
        double r1752816 = r1752790 ? r1752794 : r1752815;
        return r1752816;
}

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 < -2.4629151126589693e+107

    1. Initial program 59.0

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

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

      \[\leadsto \frac{\frac{\left(b_2 \cdot b_2 - b_2 \cdot b_2\right) + 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-identity52.1

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

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

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

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

    if -2.4629151126589693e+107 < b_2 < -9.739621771792007e-284

    1. Initial program 31.2

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

      \[\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. Simplified14.3

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

      \[\leadsto \frac{\frac{\left(b_2 \cdot b_2 - b_2 \cdot b_2\right) + 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-identity14.3

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

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

      \[\leadsto \frac{1}{\color{blue}{\left(\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2\right) \cdot \frac{a}{a \cdot c}}}\]
    10. Using strategy rm
    11. Applied div-inv13.8

      \[\leadsto \color{blue}{1 \cdot \frac{1}{\left(\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2\right) \cdot \frac{a}{a \cdot c}}}\]
    12. Simplified7.7

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

    if -9.739621771792007e-284 < b_2 < 5.3869004057037945e+35

    1. Initial program 10.3

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

      \[\leadsto \frac{\left(-b_2\right) - \sqrt{\color{blue}{{b_2}^{2} - a \cdot c}}}{a}\]
    3. Simplified10.3

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

    if 5.3869004057037945e+35 < b_2

    1. Initial program 32.9

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

      \[\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. Simplified59.5

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -2.4629151126589693 \cdot 10^{+107}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le -9.739621771792007 \cdot 10^{-284}:\\ \;\;\;\;\frac{c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}\\ \mathbf{elif}\;b_2 \le 5.3869004057037945 \cdot 10^{+35}:\\ \;\;\;\;\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{c}{b_2}, \frac{1}{2}, \frac{b_2}{a} \cdot -2\right)\\ \end{array}\]

Reproduce

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