Average Error: 26.5 → 8.3
Time: 15.7s
Precision: 64
$\sqrt{{b}^{2} - \left(4 \cdot a\right) \cdot c}$
$\begin{array}{l} \mathbf{if}\;b \le -1.348495931813199651380956550510723066785 \cdot 10^{154}:\\ \;\;\;\;2 \cdot \frac{a \cdot c}{b} - b\\ \mathbf{elif}\;b \le 2.308057678369688085897871314010226265927 \cdot 10^{44}:\\ \;\;\;\;\sqrt{{b}^{2} - \left(4 \cdot a\right) \cdot c}\\ \mathbf{else}:\\ \;\;\;\;b - 2 \cdot \frac{a \cdot c}{b}\\ \end{array}$
\sqrt{{b}^{2} - \left(4 \cdot a\right) \cdot c}
\begin{array}{l}
\mathbf{if}\;b \le -1.348495931813199651380956550510723066785 \cdot 10^{154}:\\
\;\;\;\;2 \cdot \frac{a \cdot c}{b} - b\\

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

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

\end{array}
double f(double b, double a, double c) {
double r456059 = b;
double r456060 = 2.0;
double r456061 = pow(r456059, r456060);
double r456062 = 4.0;
double r456063 = a;
double r456064 = r456062 * r456063;
double r456065 = c;
double r456066 = r456064 * r456065;
double r456067 = r456061 - r456066;
double r456068 = sqrt(r456067);
return r456068;
}


double f(double b, double a, double c) {
double r456069 = b;
double r456070 = -1.3484959318131997e+154;
bool r456071 = r456069 <= r456070;
double r456072 = 2.0;
double r456073 = a;
double r456074 = c;
double r456075 = r456073 * r456074;
double r456076 = r456075 / r456069;
double r456077 = r456072 * r456076;
double r456078 = r456077 - r456069;
double r456079 = 2.308057678369688e+44;
bool r456080 = r456069 <= r456079;
double r456081 = pow(r456069, r456072);
double r456082 = 4.0;
double r456083 = r456082 * r456073;
double r456084 = r456083 * r456074;
double r456085 = r456081 - r456084;
double r456086 = sqrt(r456085);
double r456087 = r456069 - r456077;
double r456088 = r456080 ? r456086 : r456087;
double r456089 = r456071 ? r456078 : r456088;
return r456089;
}



# Try it out

Results

 In Out
Enter valid numbers for all inputs

# Derivation

1. Split input into 3 regimes
2. ## if b < -1.3484959318131997e+154

1. Initial program 64.0

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

$\leadsto \color{blue}{2 \cdot \frac{a \cdot c}{b} - b}$

## if -1.3484959318131997e+154 < b < 2.308057678369688e+44

1. Initial program 8.7

$\sqrt{{b}^{2} - \left(4 \cdot a\right) \cdot c}$

## if 2.308057678369688e+44 < b

1. Initial program 40.5

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

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

$\leadsto \begin{array}{l} \mathbf{if}\;b \le -1.348495931813199651380956550510723066785 \cdot 10^{154}:\\ \;\;\;\;2 \cdot \frac{a \cdot c}{b} - b\\ \mathbf{elif}\;b \le 2.308057678369688085897871314010226265927 \cdot 10^{44}:\\ \;\;\;\;\sqrt{{b}^{2} - \left(4 \cdot a\right) \cdot c}\\ \mathbf{else}:\\ \;\;\;\;b - 2 \cdot \frac{a \cdot c}{b}\\ \end{array}$

# Reproduce

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