\frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\begin{array}{l}
\mathbf{if}\;b \le -4.295892693885355 \cdot 10^{+120}:\\
\;\;\;\;\frac{\frac{\left(\frac{c}{b} \cdot a - b\right) \cdot 2}{2}}{a}\\
\mathbf{elif}\;b \le 5.818192251940127 \cdot 10^{-227}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(a, \left(-4 \cdot c\right), \left(b \cdot b\right)\right)} - b}{2 \cdot a}\\
\mathbf{elif}\;b \le 8.470092598943746 \cdot 10^{+147}:\\
\;\;\;\;\left(c \cdot \left(\frac{\frac{1}{2}}{a} \cdot \left(-4 \cdot a\right)\right)\right) \cdot \frac{1}{\sqrt{\mathsf{fma}\left(\left(-4 \cdot c\right), a, \left(b \cdot b\right)\right)} + b}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{-b}{c}}\\
\end{array}double f(double a, double b, double c) {
double r9033206 = b;
double r9033207 = -r9033206;
double r9033208 = r9033206 * r9033206;
double r9033209 = 4.0;
double r9033210 = a;
double r9033211 = c;
double r9033212 = r9033210 * r9033211;
double r9033213 = r9033209 * r9033212;
double r9033214 = r9033208 - r9033213;
double r9033215 = sqrt(r9033214);
double r9033216 = r9033207 + r9033215;
double r9033217 = 2.0;
double r9033218 = r9033217 * r9033210;
double r9033219 = r9033216 / r9033218;
return r9033219;
}
double f(double a, double b, double c) {
double r9033220 = b;
double r9033221 = -4.295892693885355e+120;
bool r9033222 = r9033220 <= r9033221;
double r9033223 = c;
double r9033224 = r9033223 / r9033220;
double r9033225 = a;
double r9033226 = r9033224 * r9033225;
double r9033227 = r9033226 - r9033220;
double r9033228 = 2.0;
double r9033229 = r9033227 * r9033228;
double r9033230 = r9033229 / r9033228;
double r9033231 = r9033230 / r9033225;
double r9033232 = 5.818192251940127e-227;
bool r9033233 = r9033220 <= r9033232;
double r9033234 = -4.0;
double r9033235 = r9033234 * r9033223;
double r9033236 = r9033220 * r9033220;
double r9033237 = fma(r9033225, r9033235, r9033236);
double r9033238 = sqrt(r9033237);
double r9033239 = r9033238 - r9033220;
double r9033240 = r9033228 * r9033225;
double r9033241 = r9033239 / r9033240;
double r9033242 = 8.470092598943746e+147;
bool r9033243 = r9033220 <= r9033242;
double r9033244 = 0.5;
double r9033245 = r9033244 / r9033225;
double r9033246 = r9033234 * r9033225;
double r9033247 = r9033245 * r9033246;
double r9033248 = r9033223 * r9033247;
double r9033249 = 1.0;
double r9033250 = fma(r9033235, r9033225, r9033236);
double r9033251 = sqrt(r9033250);
double r9033252 = r9033251 + r9033220;
double r9033253 = r9033249 / r9033252;
double r9033254 = r9033248 * r9033253;
double r9033255 = -r9033220;
double r9033256 = r9033255 / r9033223;
double r9033257 = r9033249 / r9033256;
double r9033258 = r9033243 ? r9033254 : r9033257;
double r9033259 = r9033233 ? r9033241 : r9033258;
double r9033260 = r9033222 ? r9033231 : r9033259;
return r9033260;
}




Bits error versus a




Bits error versus b




Bits error versus c
| Original | 32.9 |
|---|---|
| Target | 20.3 |
| Herbie | 6.6 |
if b < -4.295892693885355e+120Initial program 49.1
Simplified49.1
Taylor expanded around -inf 10.2
Simplified2.9
if -4.295892693885355e+120 < b < 5.818192251940127e-227Initial program 9.3
Simplified9.3
rmApplied add-cube-cbrt9.6
Applied *-un-lft-identity9.6
Applied sqrt-prod9.6
Applied prod-diff9.6
Simplified9.3
Simplified9.3
rmApplied associate-/l/9.3
Simplified9.3
if 5.818192251940127e-227 < b < 8.470092598943746e+147Initial program 36.3
Simplified36.3
rmApplied add-cube-cbrt39.9
Applied *-un-lft-identity39.9
Applied sqrt-prod39.9
Applied prod-diff40.7
Simplified40.7
Simplified36.3
rmApplied associate-/l/36.3
Simplified36.3
rmApplied clear-num36.3
rmApplied flip--36.4
Applied associate-/r/36.5
Applied add-sqr-sqrt36.5
Applied times-frac36.5
Simplified7.3
Simplified7.3
if 8.470092598943746e+147 < b Initial program 62.1
Simplified62.1
rmApplied add-cube-cbrt62.8
Applied *-un-lft-identity62.8
Applied sqrt-prod62.8
Applied prod-diff62.9
Simplified62.9
Simplified62.2
rmApplied associate-/l/62.2
Simplified62.2
rmApplied clear-num62.2
Taylor expanded around 0 2.7
Simplified2.7
Final simplification6.6
herbie shell --seed 2019124 +o rules:numerics
(FPCore (a b c)
:name "quadp (p42, positive)"
:herbie-target
(if (< b 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)))