Average Error: 33.2 → 6.4
Time: 22.8s
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 -9.20968712670863 \cdot 10^{+88}:\\ \;\;\;\;\mathsf{fma}\left(\frac{b_2}{a}, -2, \frac{\frac{1}{2}}{\frac{b_2}{c}}\right)\\ \mathbf{elif}\;b_2 \le 2.08048502174419 \cdot 10^{-299}:\\ \;\;\;\;\left(\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2\right) \cdot \frac{1}{a}\\ \mathbf{elif}\;b_2 \le 6.5172615559013 \cdot 10^{+137}:\\ \;\;\;\;-\frac{c}{\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 -9.20968712670863 \cdot 10^{+88}:\\
\;\;\;\;\mathsf{fma}\left(\frac{b_2}{a}, -2, \frac{\frac{1}{2}}{\frac{b_2}{c}}\right)\\

\mathbf{elif}\;b_2 \le 2.08048502174419 \cdot 10^{-299}:\\
\;\;\;\;\left(\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2\right) \cdot \frac{1}{a}\\

\mathbf{elif}\;b_2 \le 6.5172615559013 \cdot 10^{+137}:\\
\;\;\;\;-\frac{c}{\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 r550094 = b_2;
        double r550095 = -r550094;
        double r550096 = r550094 * r550094;
        double r550097 = a;
        double r550098 = c;
        double r550099 = r550097 * r550098;
        double r550100 = r550096 - r550099;
        double r550101 = sqrt(r550100);
        double r550102 = r550095 + r550101;
        double r550103 = r550102 / r550097;
        return r550103;
}

double f(double a, double b_2, double c) {
        double r550104 = b_2;
        double r550105 = -9.20968712670863e+88;
        bool r550106 = r550104 <= r550105;
        double r550107 = a;
        double r550108 = r550104 / r550107;
        double r550109 = -2.0;
        double r550110 = 0.5;
        double r550111 = c;
        double r550112 = r550104 / r550111;
        double r550113 = r550110 / r550112;
        double r550114 = fma(r550108, r550109, r550113);
        double r550115 = 2.08048502174419e-299;
        bool r550116 = r550104 <= r550115;
        double r550117 = r550104 * r550104;
        double r550118 = r550107 * r550111;
        double r550119 = r550117 - r550118;
        double r550120 = sqrt(r550119);
        double r550121 = r550120 - r550104;
        double r550122 = 1.0;
        double r550123 = r550122 / r550107;
        double r550124 = r550121 * r550123;
        double r550125 = 6.5172615559013e+137;
        bool r550126 = r550104 <= r550125;
        double r550127 = r550120 + r550104;
        double r550128 = r550111 / r550127;
        double r550129 = -r550128;
        double r550130 = r550111 / r550104;
        double r550131 = -0.5;
        double r550132 = r550130 * r550131;
        double r550133 = r550126 ? r550129 : r550132;
        double r550134 = r550116 ? r550124 : r550133;
        double r550135 = r550106 ? r550114 : r550134;
        return r550135;
}

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 < -9.20968712670863e+88

    1. Initial program 41.7

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

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

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

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

    if -9.20968712670863e+88 < b_2 < 2.08048502174419e-299

    1. Initial program 8.8

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

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

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

    if 2.08048502174419e-299 < b_2 < 6.5172615559013e+137

    1. Initial program 34.4

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

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

      \[\leadsto \color{blue}{\left(\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2\right) \cdot \frac{1}{a}}\]
    5. Using strategy rm
    6. Applied flip--34.5

      \[\leadsto \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}} \cdot \frac{1}{a}\]
    7. Applied associate-*l/34.5

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

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

      \[\leadsto \frac{\color{blue}{-1 \cdot c}}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}\]
    10. Simplified8.3

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

    if 6.5172615559013e+137 < b_2

    1. Initial program 61.0

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

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

      \[\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 1.7

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -9.20968712670863 \cdot 10^{+88}:\\ \;\;\;\;\mathsf{fma}\left(\frac{b_2}{a}, -2, \frac{\frac{1}{2}}{\frac{b_2}{c}}\right)\\ \mathbf{elif}\;b_2 \le 2.08048502174419 \cdot 10^{-299}:\\ \;\;\;\;\left(\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2\right) \cdot \frac{1}{a}\\ \mathbf{elif}\;b_2 \le 6.5172615559013 \cdot 10^{+137}:\\ \;\;\;\;-\frac{c}{\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 2019143 +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))