Average Error: 34.2 → 8.7
Time: 15.6s
Precision: 64
$\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}$
$\begin{array}{l} \mathbf{if}\;b \le -2.940001550635406357572527191036557327772 \cdot 10^{93}:\\ \;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\ \mathbf{elif}\;b \le 9.198411131351628166862459628206530754491 \cdot 10^{-222}:\\ \;\;\;\;\frac{\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}{2}}{a}\\ \mathbf{elif}\;b \le 1.697192458191632034009038064514048334805 \cdot 10^{79}:\\ \;\;\;\;\frac{\frac{\left(a \cdot c\right) \cdot 4}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;-1 \cdot \frac{c}{b}\\ \end{array}$
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\begin{array}{l}
\mathbf{if}\;b \le -2.940001550635406357572527191036557327772 \cdot 10^{93}:\\
\;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\

\mathbf{elif}\;b \le 9.198411131351628166862459628206530754491 \cdot 10^{-222}:\\
\;\;\;\;\frac{\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}{2}}{a}\\

\mathbf{elif}\;b \le 1.697192458191632034009038064514048334805 \cdot 10^{79}:\\
\;\;\;\;\frac{\frac{\left(a \cdot c\right) \cdot 4}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{2 \cdot a}\\

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

\end{array}
double f(double b, double a, double c) {
double r2466860 = b;
double r2466861 = -r2466860;
double r2466862 = r2466860 * r2466860;
double r2466863 = 4.0;
double r2466864 = a;
double r2466865 = r2466863 * r2466864;
double r2466866 = c;
double r2466867 = r2466865 * r2466866;
double r2466868 = r2466862 - r2466867;
double r2466869 = sqrt(r2466868);
double r2466870 = r2466861 + r2466869;
double r2466871 = 2.0;
double r2466872 = r2466871 * r2466864;
double r2466873 = r2466870 / r2466872;
return r2466873;
}


double f(double b, double a, double c) {
double r2466874 = b;
double r2466875 = -2.9400015506354064e+93;
bool r2466876 = r2466874 <= r2466875;
double r2466877 = 1.0;
double r2466878 = c;
double r2466879 = r2466878 / r2466874;
double r2466880 = a;
double r2466881 = r2466874 / r2466880;
double r2466882 = r2466879 - r2466881;
double r2466883 = r2466877 * r2466882;
double r2466884 = 9.198411131351628e-222;
bool r2466885 = r2466874 <= r2466884;
double r2466886 = r2466874 * r2466874;
double r2466887 = 4.0;
double r2466888 = r2466887 * r2466880;
double r2466889 = r2466888 * r2466878;
double r2466890 = r2466886 - r2466889;
double r2466891 = sqrt(r2466890);
double r2466892 = r2466891 - r2466874;
double r2466893 = 2.0;
double r2466894 = r2466892 / r2466893;
double r2466895 = r2466894 / r2466880;
double r2466896 = 1.697192458191632e+79;
bool r2466897 = r2466874 <= r2466896;
double r2466898 = r2466880 * r2466878;
double r2466899 = r2466898 * r2466887;
double r2466900 = -r2466874;
double r2466901 = r2466900 - r2466891;
double r2466902 = r2466899 / r2466901;
double r2466903 = r2466893 * r2466880;
double r2466904 = r2466902 / r2466903;
double r2466905 = -1.0;
double r2466906 = r2466905 * r2466879;
double r2466907 = r2466897 ? r2466904 : r2466906;
double r2466908 = r2466885 ? r2466895 : r2466907;
double r2466909 = r2466876 ? r2466883 : r2466908;
return r2466909;
}



# Try it out

Results

 In Out
Enter valid numbers for all inputs

# Derivation

1. Split input into 4 regimes
2. ## if b < -2.9400015506354064e+93

1. Initial program 45.8

$\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}$
2. Taylor expanded around -inf 3.3

$\leadsto \color{blue}{1 \cdot \frac{c}{b} - 1 \cdot \frac{b}{a}}$
3. Simplified3.3

$\leadsto \color{blue}{1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)}$

## if -2.9400015506354064e+93 < b < 9.198411131351628e-222

1. Initial program 9.8

$\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}$
2. Using strategy rm
3. Applied associate-/r*9.8

$\leadsto \color{blue}{\frac{\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2}}{a}}$
4. Simplified9.8

$\leadsto \frac{\color{blue}{\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}{2}}}{a}$

## if 9.198411131351628e-222 < b < 1.697192458191632e+79

1. Initial program 34.6

$\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}$
2. Using strategy rm
3. Applied flip-+34.6

$\leadsto \frac{\color{blue}{\frac{\left(-b\right) \cdot \left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} \cdot \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}}{2 \cdot a}$
4. Simplified16.4

$\leadsto \frac{\frac{\color{blue}{0 + \left(a \cdot c\right) \cdot 4}}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{2 \cdot a}$

## if 1.697192458191632e+79 < b

1. Initial program 58.3

$\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}$
2. Taylor expanded around inf 3.6

$\leadsto \color{blue}{-1 \cdot \frac{c}{b}}$
3. Recombined 4 regimes into one program.
4. Final simplification8.7

$\leadsto \begin{array}{l} \mathbf{if}\;b \le -2.940001550635406357572527191036557327772 \cdot 10^{93}:\\ \;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\ \mathbf{elif}\;b \le 9.198411131351628166862459628206530754491 \cdot 10^{-222}:\\ \;\;\;\;\frac{\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}{2}}{a}\\ \mathbf{elif}\;b \le 1.697192458191632034009038064514048334805 \cdot 10^{79}:\\ \;\;\;\;\frac{\frac{\left(a \cdot c\right) \cdot 4}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;-1 \cdot \frac{c}{b}\\ \end{array}$

# Reproduce

herbie shell --seed 1
(FPCore (b a c)
:name "(-b + sqrt(b*b - 4*a*c))/(2*a)"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)))