\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 -1.11981154530853106611761327467786604265 \cdot 10^{143}:\\
\;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\
\mathbf{elif}\;b \le 4.718890261991468628346768591871377778707 \cdot 10^{-106}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;-1 \cdot \frac{c}{b}\\
\end{array}double f(double a, double b, double c) {
double r122221 = b;
double r122222 = -r122221;
double r122223 = r122221 * r122221;
double r122224 = 4.0;
double r122225 = a;
double r122226 = r122224 * r122225;
double r122227 = c;
double r122228 = r122226 * r122227;
double r122229 = r122223 - r122228;
double r122230 = sqrt(r122229);
double r122231 = r122222 + r122230;
double r122232 = 2.0;
double r122233 = r122232 * r122225;
double r122234 = r122231 / r122233;
return r122234;
}
double f(double a, double b, double c) {
double r122235 = b;
double r122236 = -1.119811545308531e+143;
bool r122237 = r122235 <= r122236;
double r122238 = 1.0;
double r122239 = c;
double r122240 = r122239 / r122235;
double r122241 = a;
double r122242 = r122235 / r122241;
double r122243 = r122240 - r122242;
double r122244 = r122238 * r122243;
double r122245 = 4.718890261991469e-106;
bool r122246 = r122235 <= r122245;
double r122247 = r122235 * r122235;
double r122248 = 4.0;
double r122249 = r122248 * r122241;
double r122250 = r122249 * r122239;
double r122251 = r122247 - r122250;
double r122252 = sqrt(r122251);
double r122253 = r122252 - r122235;
double r122254 = 2.0;
double r122255 = r122254 * r122241;
double r122256 = r122253 / r122255;
double r122257 = -1.0;
double r122258 = r122257 * r122240;
double r122259 = r122246 ? r122256 : r122258;
double r122260 = r122237 ? r122244 : r122259;
return r122260;
}




Bits error versus a




Bits error versus b




Bits error versus c
Results
| Original | 34.1 |
|---|---|
| Target | 21.0 |
| Herbie | 10.0 |
if b < -1.119811545308531e+143Initial program 59.0
Simplified59.0
rmApplied div-inv59.0
rmApplied pow159.0
Applied pow159.0
Applied pow-prod-down59.0
Simplified59.0
Taylor expanded around -inf 2.4
Simplified2.4
if -1.119811545308531e+143 < b < 4.718890261991469e-106Initial program 11.1
Simplified11.1
rmApplied div-inv11.2
rmApplied pow111.2
Applied pow111.2
Applied pow-prod-down11.2
Simplified11.1
if 4.718890261991469e-106 < b Initial program 52.4
Simplified52.4
Taylor expanded around inf 10.9
Final simplification10.0
herbie shell --seed 2019326 +o rules:numerics
(FPCore (a b c)
:name "The quadratic formula (r1)"
:precision binary64
:herbie-target
(if (< b 0.0) (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)) (/ c (* a (/ (- (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)))))
(/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)))