Average Error: 52.3 → 35.3
Time: 39.4s
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 -5.692559815598021951589075805939527470231 \cdot 10^{50}:\\ \;\;\;\;0\\ \mathbf{elif}\;A \le 1.45314403643167712530367638063690702913 \cdot 10^{66}:\\ \;\;\;\;\frac{\left(\left(\left(27 \cdot {a}^{2}\right) \cdot {d}^{2} + \left(4 \cdot {b}^{3}\right) \cdot d\right) - A \cdot \left(\left(B \cdot 18\right) \cdot \left(C \cdot D\right) - {C}^{3} \cdot 4\right)\right) - {\left(C \cdot B\right)}^{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 -5.692559815598021951589075805939527470231 \cdot 10^{50}:\\
\;\;\;\;0\\

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

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

\end{array}
double f(double a, double d, double b, double A, double B, double C, double D) {
double r2611113 = 27.0;
double r2611114 = a;
double r2611115 = 2.0;
double r2611116 = pow(r2611114, r2611115);
double r2611117 = r2611113 * r2611116;
double r2611118 = d;
double r2611119 = pow(r2611118, r2611115);
double r2611120 = r2611117 * r2611119;
double r2611121 = 4.0;
double r2611122 = b;
double r2611123 = 3.0;
double r2611124 = pow(r2611122, r2611123);
double r2611125 = r2611121 * r2611124;
double r2611126 = r2611125 * r2611118;
double r2611127 = r2611120 + r2611126;
double r2611128 = 18.0;
double r2611129 = A;
double r2611130 = r2611128 * r2611129;
double r2611131 = B;
double r2611132 = r2611130 * r2611131;
double r2611133 = C;
double r2611134 = r2611132 * r2611133;
double r2611135 = D;
double r2611136 = r2611134 * r2611135;
double r2611137 = r2611127 - r2611136;
double r2611138 = r2611121 * r2611129;
double r2611139 = pow(r2611133, r2611123);
double r2611140 = r2611138 * r2611139;
double r2611141 = r2611137 + r2611140;
double r2611142 = pow(r2611131, r2611115);
double r2611143 = pow(r2611133, r2611115);
double r2611144 = r2611142 * r2611143;
double r2611145 = r2611141 - r2611144;
double r2611146 = 108.0;
double r2611147 = pow(r2611129, r2611121);
double r2611148 = r2611146 * r2611147;
double r2611149 = r2611145 / r2611148;
return r2611149;
}


double f(double a, double d, double b, double A, double B, double C, double D) {
double r2611150 = A;
double r2611151 = -5.692559815598022e+50;
bool r2611152 = r2611150 <= r2611151;
double r2611153 = 0.0;
double r2611154 = 1.4531440364316771e+66;
bool r2611155 = r2611150 <= r2611154;
double r2611156 = 27.0;
double r2611157 = a;
double r2611158 = 2.0;
double r2611159 = pow(r2611157, r2611158);
double r2611160 = r2611156 * r2611159;
double r2611161 = d;
double r2611162 = pow(r2611161, r2611158);
double r2611163 = r2611160 * r2611162;
double r2611164 = 4.0;
double r2611165 = b;
double r2611166 = 3.0;
double r2611167 = pow(r2611165, r2611166);
double r2611168 = r2611164 * r2611167;
double r2611169 = r2611168 * r2611161;
double r2611170 = r2611163 + r2611169;
double r2611171 = B;
double r2611172 = 18.0;
double r2611173 = r2611171 * r2611172;
double r2611174 = C;
double r2611175 = D;
double r2611176 = r2611174 * r2611175;
double r2611177 = r2611173 * r2611176;
double r2611178 = pow(r2611174, r2611166);
double r2611179 = r2611178 * r2611164;
double r2611180 = r2611177 - r2611179;
double r2611181 = r2611150 * r2611180;
double r2611182 = r2611170 - r2611181;
double r2611183 = r2611174 * r2611171;
double r2611184 = pow(r2611183, r2611158);
double r2611185 = r2611182 - r2611184;
double r2611186 = 108.0;
double r2611187 = pow(r2611150, r2611164);
double r2611188 = r2611186 * r2611187;
double r2611189 = r2611185 / r2611188;
double r2611190 = r2611155 ? r2611189 : r2611153;
double r2611191 = r2611152 ? r2611153 : r2611190;
return r2611191;
}



# Try it out

Results

 In Out
Enter valid numbers for all inputs

# Derivation

1. Split input into 2 regimes
2. ## if A < -5.692559815598022e+50 or 1.4531440364316771e+66 < A

1. Initial program 55.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. Simplified54.6

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

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

## if -5.692559815598022e+50 < A < 1.4531440364316771e+66

1. Initial program 37.0

$\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. Simplified36.1

$\leadsto \color{blue}{\frac{\left(\left(\left(27 \cdot {a}^{2}\right) \cdot {d}^{2} + \left(4 \cdot {b}^{3}\right) \cdot d\right) - A \cdot \left(\left(B \cdot 18\right) \cdot \left(C \cdot D\right) - {C}^{3} \cdot 4\right)\right) - {C}^{2} \cdot {B}^{2}}{108 \cdot {A}^{4}}}$
3. Using strategy rm
4. Applied pow-prod-down31.1

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

$\leadsto \begin{array}{l} \mathbf{if}\;A \le -5.692559815598021951589075805939527470231 \cdot 10^{50}:\\ \;\;\;\;0\\ \mathbf{elif}\;A \le 1.45314403643167712530367638063690702913 \cdot 10^{66}:\\ \;\;\;\;\frac{\left(\left(\left(27 \cdot {a}^{2}\right) \cdot {d}^{2} + \left(4 \cdot {b}^{3}\right) \cdot d\right) - A \cdot \left(\left(B \cdot 18\right) \cdot \left(C \cdot D\right) - {C}^{3} \cdot 4\right)\right) - {\left(C \cdot B\right)}^{2}}{108 \cdot {A}^{4}}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array}$

# Reproduce

herbie shell --seed 1
(FPCore (a d b A B C D)
: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))))