Average Error: 52.2 → 37.4
Time: 26.0s
Precision: 64
$\frac{\left(\left(\left(\left(27 \cdot {A}^{2}\right) \cdot {D}^{2} + \left(4 \cdot {B}^{3}\right) \cdot D\right) - \left(\left(\left(18 \cdot A\right) \cdot B\right) \cdot C\right) \cdot D\right) + \left(4 \cdot A\right) \cdot {C}^{3}\right) - {B}^{2} \cdot {C}^{2}}{108 \cdot {A}^{4}}$
$\begin{array}{l} \mathbf{if}\;A \le -3.517679974979270657695970547610146818953 \cdot 10^{76}:\\ \;\;\;\;0\\ \mathbf{elif}\;A \le 3.568864378024860509585092130997392817121 \cdot 10^{76}:\\ \;\;\;\;\frac{\left(\left(\left(\left(27 \cdot {A}^{2}\right) \cdot {D}^{\left(\frac{2}{2}\right)}\right) \cdot {D}^{\left(\frac{2}{2}\right)} + D \cdot \left(4 \cdot {B}^{3} - \left(\left(18 \cdot A\right) \cdot B\right) \cdot C\right)\right) + \left(4 \cdot A\right) \cdot {C}^{3}\right) - {B}^{2} \cdot {C}^{2}}{108 \cdot {A}^{4}}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array}$
\frac{\left(\left(\left(\left(27 \cdot {A}^{2}\right) \cdot {D}^{2} + \left(4 \cdot {B}^{3}\right) \cdot D\right) - \left(\left(\left(18 \cdot A\right) \cdot B\right) \cdot C\right) \cdot D\right) + \left(4 \cdot A\right) \cdot {C}^{3}\right) - {B}^{2} \cdot {C}^{2}}{108 \cdot {A}^{4}}
\begin{array}{l}
\mathbf{if}\;A \le -3.517679974979270657695970547610146818953 \cdot 10^{76}:\\
\;\;\;\;0\\

\mathbf{elif}\;A \le 3.568864378024860509585092130997392817121 \cdot 10^{76}:\\
\;\;\;\;\frac{\left(\left(\left(\left(27 \cdot {A}^{2}\right) \cdot {D}^{\left(\frac{2}{2}\right)}\right) \cdot {D}^{\left(\frac{2}{2}\right)} + D \cdot \left(4 \cdot {B}^{3} - \left(\left(18 \cdot A\right) \cdot B\right) \cdot C\right)\right) + \left(4 \cdot A\right) \cdot {C}^{3}\right) - {B}^{2} \cdot {C}^{2}}{108 \cdot {A}^{4}}\\

\mathbf{else}:\\
\;\;\;\;0\\

\end{array}
double f(double A, double D, double B, double C) {
double r2632242 = 27.0;
double r2632243 = A;
double r2632244 = 2.0;
double r2632245 = pow(r2632243, r2632244);
double r2632246 = r2632242 * r2632245;
double r2632247 = D;
double r2632248 = pow(r2632247, r2632244);
double r2632249 = r2632246 * r2632248;
double r2632250 = 4.0;
double r2632251 = B;
double r2632252 = 3.0;
double r2632253 = pow(r2632251, r2632252);
double r2632254 = r2632250 * r2632253;
double r2632255 = r2632254 * r2632247;
double r2632256 = r2632249 + r2632255;
double r2632257 = 18.0;
double r2632258 = r2632257 * r2632243;
double r2632259 = r2632258 * r2632251;
double r2632260 = C;
double r2632261 = r2632259 * r2632260;
double r2632262 = r2632261 * r2632247;
double r2632263 = r2632256 - r2632262;
double r2632264 = r2632250 * r2632243;
double r2632265 = pow(r2632260, r2632252);
double r2632266 = r2632264 * r2632265;
double r2632267 = r2632263 + r2632266;
double r2632268 = pow(r2632251, r2632244);
double r2632269 = pow(r2632260, r2632244);
double r2632270 = r2632268 * r2632269;
double r2632271 = r2632267 - r2632270;
double r2632272 = 108.0;
double r2632273 = pow(r2632243, r2632250);
double r2632274 = r2632272 * r2632273;
double r2632275 = r2632271 / r2632274;
return r2632275;
}


double f(double A, double D, double B, double C) {
double r2632276 = A;
double r2632277 = -3.5176799749792707e+76;
bool r2632278 = r2632276 <= r2632277;
double r2632279 = 0.0;
double r2632280 = 3.5688643780248605e+76;
bool r2632281 = r2632276 <= r2632280;
double r2632282 = 27.0;
double r2632283 = 2.0;
double r2632284 = pow(r2632276, r2632283);
double r2632285 = r2632282 * r2632284;
double r2632286 = D;
double r2632287 = 2.0;
double r2632288 = r2632283 / r2632287;
double r2632289 = pow(r2632286, r2632288);
double r2632290 = r2632285 * r2632289;
double r2632291 = r2632290 * r2632289;
double r2632292 = 4.0;
double r2632293 = B;
double r2632294 = 3.0;
double r2632295 = pow(r2632293, r2632294);
double r2632296 = r2632292 * r2632295;
double r2632297 = 18.0;
double r2632298 = r2632297 * r2632276;
double r2632299 = r2632298 * r2632293;
double r2632300 = C;
double r2632301 = r2632299 * r2632300;
double r2632302 = r2632296 - r2632301;
double r2632303 = r2632286 * r2632302;
double r2632304 = r2632291 + r2632303;
double r2632305 = r2632292 * r2632276;
double r2632306 = pow(r2632300, r2632294);
double r2632307 = r2632305 * r2632306;
double r2632308 = r2632304 + r2632307;
double r2632309 = pow(r2632293, r2632283);
double r2632310 = pow(r2632300, r2632283);
double r2632311 = r2632309 * r2632310;
double r2632312 = r2632308 - r2632311;
double r2632313 = 108.0;
double r2632314 = pow(r2632276, r2632292);
double r2632315 = r2632313 * r2632314;
double r2632316 = r2632312 / r2632315;
double r2632317 = r2632281 ? r2632316 : r2632279;
double r2632318 = r2632278 ? r2632279 : r2632317;
return r2632318;
}



# Try it out

Results

 In Out
Enter valid numbers for all inputs

# Derivation

1. Split input into 2 regimes
2. ## if A < -3.5176799749792707e+76 or 3.5688643780248605e+76 < A

1. Initial program 60.4

$\frac{\left(\left(\left(\left(27 \cdot {A}^{2}\right) \cdot {D}^{2} + \left(4 \cdot {B}^{3}\right) \cdot D\right) - \left(\left(\left(18 \cdot A\right) \cdot B\right) \cdot C\right) \cdot D\right) + \left(4 \cdot A\right) \cdot {C}^{3}\right) - {B}^{2} \cdot {C}^{2}}{108 \cdot {A}^{4}}$
2. Simplified60.4

$\leadsto \color{blue}{\frac{\left(\left(\left(27 \cdot {A}^{2}\right) \cdot {D}^{2} + D \cdot \left(4 \cdot {B}^{3} - \left(\left(18 \cdot A\right) \cdot B\right) \cdot C\right)\right) + \left(4 \cdot A\right) \cdot {C}^{3}\right) - {B}^{2} \cdot {C}^{2}}{108 \cdot {A}^{4}}}$
3. Taylor expanded around 0 40.7

$\leadsto \color{blue}{0}$

## if -3.5176799749792707e+76 < A < 3.5688643780248605e+76

1. Initial program 27.7

$\frac{\left(\left(\left(\left(27 \cdot {A}^{2}\right) \cdot {D}^{2} + \left(4 \cdot {B}^{3}\right) \cdot D\right) - \left(\left(\left(18 \cdot A\right) \cdot B\right) \cdot C\right) \cdot D\right) + \left(4 \cdot A\right) \cdot {C}^{3}\right) - {B}^{2} \cdot {C}^{2}}{108 \cdot {A}^{4}}$
2. Simplified27.7

$\leadsto \color{blue}{\frac{\left(\left(\left(27 \cdot {A}^{2}\right) \cdot {D}^{2} + D \cdot \left(4 \cdot {B}^{3} - \left(\left(18 \cdot A\right) \cdot B\right) \cdot C\right)\right) + \left(4 \cdot A\right) \cdot {C}^{3}\right) - {B}^{2} \cdot {C}^{2}}{108 \cdot {A}^{4}}}$
3. Using strategy rm
4. Applied sqr-pow27.7

$\leadsto \frac{\left(\left(\left(27 \cdot {A}^{2}\right) \cdot \color{blue}{\left({D}^{\left(\frac{2}{2}\right)} \cdot {D}^{\left(\frac{2}{2}\right)}\right)} + D \cdot \left(4 \cdot {B}^{3} - \left(\left(18 \cdot A\right) \cdot B\right) \cdot C\right)\right) + \left(4 \cdot A\right) \cdot {C}^{3}\right) - {B}^{2} \cdot {C}^{2}}{108 \cdot {A}^{4}}$
5. Applied associate-*r*27.7

$\leadsto \frac{\left(\left(\color{blue}{\left(\left(27 \cdot {A}^{2}\right) \cdot {D}^{\left(\frac{2}{2}\right)}\right) \cdot {D}^{\left(\frac{2}{2}\right)}} + D \cdot \left(4 \cdot {B}^{3} - \left(\left(18 \cdot A\right) \cdot B\right) \cdot C\right)\right) + \left(4 \cdot A\right) \cdot {C}^{3}\right) - {B}^{2} \cdot {C}^{2}}{108 \cdot {A}^{4}}$
3. Recombined 2 regimes into one program.
4. Final simplification37.4

$\leadsto \begin{array}{l} \mathbf{if}\;A \le -3.517679974979270657695970547610146818953 \cdot 10^{76}:\\ \;\;\;\;0\\ \mathbf{elif}\;A \le 3.568864378024860509585092130997392817121 \cdot 10^{76}:\\ \;\;\;\;\frac{\left(\left(\left(\left(27 \cdot {A}^{2}\right) \cdot {D}^{\left(\frac{2}{2}\right)}\right) \cdot {D}^{\left(\frac{2}{2}\right)} + D \cdot \left(4 \cdot {B}^{3} - \left(\left(18 \cdot A\right) \cdot B\right) \cdot C\right)\right) + \left(4 \cdot A\right) \cdot {C}^{3}\right) - {B}^{2} \cdot {C}^{2}}{108 \cdot {A}^{4}}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array}$

# Reproduce

herbie shell --seed 1
(FPCore (A D B C)
:name "(27*A^2*D^2+4*B^3*D-18*A*B*C*D+4*A*C^3-B^2*C^2)/(108*A^4)"
:precision binary64
(/ (- (+ (- (+ (* (* 27 (pow A 2)) (pow D 2)) (* (* 4 (pow B 3)) D)) (* (* (* (* 18 A) B) C) D)) (* (* 4 A) (pow C 3))) (* (pow B 2) (pow C 2))) (* 108 (pow A 4))))