
(FPCore (d1 d2 d3 d4) :precision binary64 (- (+ (- (* d1 d2) (* d1 d3)) (* d4 d1)) (* d1 d1)))
double code(double d1, double d2, double d3, double d4) {
return (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1);
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
code = (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1)
end function
public static double code(double d1, double d2, double d3, double d4) {
return (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1);
}
def code(d1, d2, d3, d4): return (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1)
function code(d1, d2, d3, d4) return Float64(Float64(Float64(Float64(d1 * d2) - Float64(d1 * d3)) + Float64(d4 * d1)) - Float64(d1 * d1)) end
function tmp = code(d1, d2, d3, d4) tmp = (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1); end
code[d1_, d2_, d3_, d4_] := N[(N[(N[(N[(d1 * d2), $MachinePrecision] - N[(d1 * d3), $MachinePrecision]), $MachinePrecision] + N[(d4 * d1), $MachinePrecision]), $MachinePrecision] - N[(d1 * d1), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (d1 d2 d3 d4) :precision binary64 (- (+ (- (* d1 d2) (* d1 d3)) (* d4 d1)) (* d1 d1)))
double code(double d1, double d2, double d3, double d4) {
return (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1);
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
code = (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1)
end function
public static double code(double d1, double d2, double d3, double d4) {
return (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1);
}
def code(d1, d2, d3, d4): return (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1)
function code(d1, d2, d3, d4) return Float64(Float64(Float64(Float64(d1 * d2) - Float64(d1 * d3)) + Float64(d4 * d1)) - Float64(d1 * d1)) end
function tmp = code(d1, d2, d3, d4) tmp = (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1); end
code[d1_, d2_, d3_, d4_] := N[(N[(N[(N[(d1 * d2), $MachinePrecision] - N[(d1 * d3), $MachinePrecision]), $MachinePrecision] + N[(d4 * d1), $MachinePrecision]), $MachinePrecision] - N[(d1 * d1), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1
\end{array}
(FPCore (d1 d2 d3 d4) :precision binary64 (* d1 (- (- d4 d3) (- d1 d2))))
double code(double d1, double d2, double d3, double d4) {
return d1 * ((d4 - d3) - (d1 - d2));
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
code = d1 * ((d4 - d3) - (d1 - d2))
end function
public static double code(double d1, double d2, double d3, double d4) {
return d1 * ((d4 - d3) - (d1 - d2));
}
def code(d1, d2, d3, d4): return d1 * ((d4 - d3) - (d1 - d2))
function code(d1, d2, d3, d4) return Float64(d1 * Float64(Float64(d4 - d3) - Float64(d1 - d2))) end
function tmp = code(d1, d2, d3, d4) tmp = d1 * ((d4 - d3) - (d1 - d2)); end
code[d1_, d2_, d3_, d4_] := N[(d1 * N[(N[(d4 - d3), $MachinePrecision] - N[(d1 - d2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
d1 \cdot \left(\left(d4 - d3\right) - \left(d1 - d2\right)\right)
\end{array}
Initial program 85.5%
sub-neg85.5%
associate-+l+85.5%
*-commutative85.5%
+-commutative85.5%
*-commutative85.5%
sub-neg85.5%
+-commutative85.5%
associate--l+85.5%
distribute-lft-out--85.9%
distribute-rgt-out--90.6%
distribute-lft-out100.0%
+-commutative100.0%
sub-neg100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
sub-neg100.0%
sub-neg100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (d1 d2 d3 d4)
:precision binary64
(let* ((t_0 (* d1 (- d1))) (t_1 (* d1 (- d3))))
(if (<= d2 -7.5e+131)
(* d1 d2)
(if (<= d2 -4e-24)
t_1
(if (<= d2 -1.32e-151)
(* d1 d4)
(if (<= d2 5e-269)
t_0
(if (<= d2 3.2e-247) t_1 (if (<= d2 9.2e-198) t_0 (* d1 d4)))))))))
double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * -d1;
double t_1 = d1 * -d3;
double tmp;
if (d2 <= -7.5e+131) {
tmp = d1 * d2;
} else if (d2 <= -4e-24) {
tmp = t_1;
} else if (d2 <= -1.32e-151) {
tmp = d1 * d4;
} else if (d2 <= 5e-269) {
tmp = t_0;
} else if (d2 <= 3.2e-247) {
tmp = t_1;
} else if (d2 <= 9.2e-198) {
tmp = t_0;
} else {
tmp = d1 * d4;
}
return tmp;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = d1 * -d1
t_1 = d1 * -d3
if (d2 <= (-7.5d+131)) then
tmp = d1 * d2
else if (d2 <= (-4d-24)) then
tmp = t_1
else if (d2 <= (-1.32d-151)) then
tmp = d1 * d4
else if (d2 <= 5d-269) then
tmp = t_0
else if (d2 <= 3.2d-247) then
tmp = t_1
else if (d2 <= 9.2d-198) then
tmp = t_0
else
tmp = d1 * d4
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * -d1;
double t_1 = d1 * -d3;
double tmp;
if (d2 <= -7.5e+131) {
tmp = d1 * d2;
} else if (d2 <= -4e-24) {
tmp = t_1;
} else if (d2 <= -1.32e-151) {
tmp = d1 * d4;
} else if (d2 <= 5e-269) {
tmp = t_0;
} else if (d2 <= 3.2e-247) {
tmp = t_1;
} else if (d2 <= 9.2e-198) {
tmp = t_0;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): t_0 = d1 * -d1 t_1 = d1 * -d3 tmp = 0 if d2 <= -7.5e+131: tmp = d1 * d2 elif d2 <= -4e-24: tmp = t_1 elif d2 <= -1.32e-151: tmp = d1 * d4 elif d2 <= 5e-269: tmp = t_0 elif d2 <= 3.2e-247: tmp = t_1 elif d2 <= 9.2e-198: tmp = t_0 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) t_0 = Float64(d1 * Float64(-d1)) t_1 = Float64(d1 * Float64(-d3)) tmp = 0.0 if (d2 <= -7.5e+131) tmp = Float64(d1 * d2); elseif (d2 <= -4e-24) tmp = t_1; elseif (d2 <= -1.32e-151) tmp = Float64(d1 * d4); elseif (d2 <= 5e-269) tmp = t_0; elseif (d2 <= 3.2e-247) tmp = t_1; elseif (d2 <= 9.2e-198) tmp = t_0; else tmp = Float64(d1 * d4); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) t_0 = d1 * -d1; t_1 = d1 * -d3; tmp = 0.0; if (d2 <= -7.5e+131) tmp = d1 * d2; elseif (d2 <= -4e-24) tmp = t_1; elseif (d2 <= -1.32e-151) tmp = d1 * d4; elseif (d2 <= 5e-269) tmp = t_0; elseif (d2 <= 3.2e-247) tmp = t_1; elseif (d2 <= 9.2e-198) tmp = t_0; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := Block[{t$95$0 = N[(d1 * (-d1)), $MachinePrecision]}, Block[{t$95$1 = N[(d1 * (-d3)), $MachinePrecision]}, If[LessEqual[d2, -7.5e+131], N[(d1 * d2), $MachinePrecision], If[LessEqual[d2, -4e-24], t$95$1, If[LessEqual[d2, -1.32e-151], N[(d1 * d4), $MachinePrecision], If[LessEqual[d2, 5e-269], t$95$0, If[LessEqual[d2, 3.2e-247], t$95$1, If[LessEqual[d2, 9.2e-198], t$95$0, N[(d1 * d4), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := d1 \cdot \left(-d1\right)\\
t_1 := d1 \cdot \left(-d3\right)\\
\mathbf{if}\;d2 \leq -7.5 \cdot 10^{+131}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d2 \leq -4 \cdot 10^{-24}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d2 \leq -1.32 \cdot 10^{-151}:\\
\;\;\;\;d1 \cdot d4\\
\mathbf{elif}\;d2 \leq 5 \cdot 10^{-269}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d2 \leq 3.2 \cdot 10^{-247}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d2 \leq 9.2 \cdot 10^{-198}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d2 < -7.4999999999999995e131Initial program 78.9%
sub-neg78.9%
associate-+l+78.9%
*-commutative78.9%
+-commutative78.9%
*-commutative78.9%
sub-neg78.9%
+-commutative78.9%
associate--l+78.9%
distribute-lft-out--78.9%
distribute-rgt-out--86.8%
distribute-lft-out100.0%
+-commutative100.0%
sub-neg100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
sub-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in d2 around inf 81.8%
if -7.4999999999999995e131 < d2 < -3.99999999999999969e-24 or 4.99999999999999979e-269 < d2 < 3.19999999999999993e-247Initial program 83.6%
sub-neg83.6%
associate-+l+83.6%
*-commutative83.6%
+-commutative83.6%
*-commutative83.6%
sub-neg83.6%
+-commutative83.6%
associate--l+83.6%
distribute-lft-out--83.6%
distribute-rgt-out--85.7%
distribute-lft-out99.9%
+-commutative99.9%
sub-neg99.9%
+-commutative99.9%
remove-double-neg99.9%
sub-neg99.9%
sub-neg99.9%
distribute-neg-in99.9%
sub-neg99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in d3 around inf 50.7%
mul-1-neg50.7%
distribute-rgt-neg-out50.7%
Simplified50.7%
if -3.99999999999999969e-24 < d2 < -1.31999999999999999e-151 or 9.20000000000000053e-198 < d2 Initial program 85.8%
sub-neg85.8%
associate-+l+85.8%
*-commutative85.8%
+-commutative85.8%
*-commutative85.8%
sub-neg85.8%
+-commutative85.8%
associate--l+85.8%
distribute-lft-out--86.6%
distribute-rgt-out--93.3%
distribute-lft-out100.0%
+-commutative100.0%
sub-neg100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
sub-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in d4 around inf 34.8%
if -1.31999999999999999e-151 < d2 < 4.99999999999999979e-269 or 3.19999999999999993e-247 < d2 < 9.20000000000000053e-198Initial program 91.8%
sub-neg91.8%
associate-+l+91.8%
*-commutative91.8%
+-commutative91.8%
*-commutative91.8%
sub-neg91.8%
+-commutative91.8%
associate--l+91.8%
distribute-lft-out--91.8%
distribute-rgt-out--91.8%
distribute-lft-out100.0%
+-commutative100.0%
sub-neg100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
sub-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in d4 around 0 76.9%
+-commutative76.9%
associate--r+76.9%
Simplified76.9%
Taylor expanded in d1 around inf 54.7%
neg-mul-154.7%
Simplified54.7%
Final simplification48.6%
(FPCore (d1 d2 d3 d4)
:precision binary64
(if (<= d4 -1.08e-147)
(* d1 (- d2 d3))
(if (<= d4 -4.6e-276)
(* d1 (- d2 d1))
(if (<= d4 4.1e+71)
(* d1 (- (- d1) d3))
(if (<= d4 1.56e+177) (* d1 (+ d2 d4)) (* d1 (- d4 d3)))))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= -1.08e-147) {
tmp = d1 * (d2 - d3);
} else if (d4 <= -4.6e-276) {
tmp = d1 * (d2 - d1);
} else if (d4 <= 4.1e+71) {
tmp = d1 * (-d1 - d3);
} else if (d4 <= 1.56e+177) {
tmp = d1 * (d2 + d4);
} else {
tmp = d1 * (d4 - d3);
}
return tmp;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if (d4 <= (-1.08d-147)) then
tmp = d1 * (d2 - d3)
else if (d4 <= (-4.6d-276)) then
tmp = d1 * (d2 - d1)
else if (d4 <= 4.1d+71) then
tmp = d1 * (-d1 - d3)
else if (d4 <= 1.56d+177) then
tmp = d1 * (d2 + d4)
else
tmp = d1 * (d4 - d3)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= -1.08e-147) {
tmp = d1 * (d2 - d3);
} else if (d4 <= -4.6e-276) {
tmp = d1 * (d2 - d1);
} else if (d4 <= 4.1e+71) {
tmp = d1 * (-d1 - d3);
} else if (d4 <= 1.56e+177) {
tmp = d1 * (d2 + d4);
} else {
tmp = d1 * (d4 - d3);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= -1.08e-147: tmp = d1 * (d2 - d3) elif d4 <= -4.6e-276: tmp = d1 * (d2 - d1) elif d4 <= 4.1e+71: tmp = d1 * (-d1 - d3) elif d4 <= 1.56e+177: tmp = d1 * (d2 + d4) else: tmp = d1 * (d4 - d3) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= -1.08e-147) tmp = Float64(d1 * Float64(d2 - d3)); elseif (d4 <= -4.6e-276) tmp = Float64(d1 * Float64(d2 - d1)); elseif (d4 <= 4.1e+71) tmp = Float64(d1 * Float64(Float64(-d1) - d3)); elseif (d4 <= 1.56e+177) tmp = Float64(d1 * Float64(d2 + d4)); else tmp = Float64(d1 * Float64(d4 - d3)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d4 <= -1.08e-147) tmp = d1 * (d2 - d3); elseif (d4 <= -4.6e-276) tmp = d1 * (d2 - d1); elseif (d4 <= 4.1e+71) tmp = d1 * (-d1 - d3); elseif (d4 <= 1.56e+177) tmp = d1 * (d2 + d4); else tmp = d1 * (d4 - d3); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, -1.08e-147], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], If[LessEqual[d4, -4.6e-276], N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision], If[LessEqual[d4, 4.1e+71], N[(d1 * N[((-d1) - d3), $MachinePrecision]), $MachinePrecision], If[LessEqual[d4, 1.56e+177], N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - d3), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq -1.08 \cdot 10^{-147}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{elif}\;d4 \leq -4.6 \cdot 10^{-276}:\\
\;\;\;\;d1 \cdot \left(d2 - d1\right)\\
\mathbf{elif}\;d4 \leq 4.1 \cdot 10^{+71}:\\
\;\;\;\;d1 \cdot \left(\left(-d1\right) - d3\right)\\
\mathbf{elif}\;d4 \leq 1.56 \cdot 10^{+177}:\\
\;\;\;\;d1 \cdot \left(d2 + d4\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\end{array}
\end{array}
if d4 < -1.07999999999999995e-147Initial program 85.4%
sub-neg85.4%
associate-+l+85.4%
*-commutative85.4%
+-commutative85.4%
*-commutative85.4%
sub-neg85.4%
+-commutative85.4%
associate--l+85.4%
distribute-lft-out--86.5%
distribute-rgt-out--92.1%
distribute-lft-out100.0%
+-commutative100.0%
sub-neg100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
sub-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in d4 around 0 74.0%
+-commutative74.0%
associate--r+74.0%
Simplified74.0%
Taylor expanded in d1 around 0 54.7%
if -1.07999999999999995e-147 < d4 < -4.59999999999999963e-276Initial program 81.2%
sub-neg81.2%
associate-+l+81.2%
*-commutative81.2%
+-commutative81.2%
*-commutative81.2%
sub-neg81.2%
+-commutative81.2%
associate--l+81.2%
distribute-lft-out--81.2%
distribute-rgt-out--90.6%
distribute-lft-out100.0%
+-commutative100.0%
sub-neg100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
sub-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in d4 around 0 100.0%
+-commutative100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in d3 around 0 76.6%
if -4.59999999999999963e-276 < d4 < 4.1000000000000002e71Initial program 90.4%
sub-neg90.4%
associate-+l+90.4%
*-commutative90.4%
+-commutative90.4%
*-commutative90.4%
sub-neg90.4%
+-commutative90.4%
associate--l+90.4%
distribute-lft-out--90.4%
distribute-rgt-out--94.0%
distribute-lft-out100.0%
+-commutative100.0%
sub-neg100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
sub-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in d4 around 0 95.9%
+-commutative95.9%
associate--r+95.9%
Simplified95.9%
Taylor expanded in d2 around 0 71.4%
associate-*r*71.4%
neg-mul-171.4%
Simplified71.4%
if 4.1000000000000002e71 < d4 < 1.5600000000000001e177Initial program 76.9%
sub-neg76.9%
associate-+l+76.9%
*-commutative76.9%
+-commutative76.9%
*-commutative76.9%
sub-neg76.9%
+-commutative76.9%
associate--l+76.9%
distribute-lft-out--76.9%
distribute-rgt-out--80.7%
distribute-lft-out99.9%
+-commutative99.9%
sub-neg99.9%
+-commutative99.9%
remove-double-neg99.9%
sub-neg99.9%
sub-neg99.9%
distribute-neg-in99.9%
sub-neg99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in d1 around 0 76.9%
Taylor expanded in d3 around 0 62.7%
+-commutative62.7%
Simplified62.7%
if 1.5600000000000001e177 < d4 Initial program 84.0%
sub-neg84.0%
associate-+l+84.0%
*-commutative84.0%
+-commutative84.0%
*-commutative84.0%
sub-neg84.0%
+-commutative84.0%
associate--l+84.0%
distribute-lft-out--83.9%
distribute-rgt-out--83.9%
distribute-lft-out99.9%
+-commutative99.9%
sub-neg99.9%
+-commutative99.9%
remove-double-neg99.9%
sub-neg99.9%
sub-neg99.9%
distribute-neg-in99.9%
sub-neg99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in d1 around 0 95.9%
Taylor expanded in d2 around 0 92.2%
Final simplification67.4%
(FPCore (d1 d2 d3 d4)
:precision binary64
(if (<= d2 -3.6e+111)
(* d1 d2)
(if (or (<= d2 -1.8e-38) (and (not (<= d2 -4e-152)) (<= d2 4.2e-199)))
(* d1 (- d1))
(* d1 d4))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -3.6e+111) {
tmp = d1 * d2;
} else if ((d2 <= -1.8e-38) || (!(d2 <= -4e-152) && (d2 <= 4.2e-199))) {
tmp = d1 * -d1;
} else {
tmp = d1 * d4;
}
return tmp;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if (d2 <= (-3.6d+111)) then
tmp = d1 * d2
else if ((d2 <= (-1.8d-38)) .or. (.not. (d2 <= (-4d-152))) .and. (d2 <= 4.2d-199)) then
tmp = d1 * -d1
else
tmp = d1 * d4
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -3.6e+111) {
tmp = d1 * d2;
} else if ((d2 <= -1.8e-38) || (!(d2 <= -4e-152) && (d2 <= 4.2e-199))) {
tmp = d1 * -d1;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -3.6e+111: tmp = d1 * d2 elif (d2 <= -1.8e-38) or (not (d2 <= -4e-152) and (d2 <= 4.2e-199)): tmp = d1 * -d1 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -3.6e+111) tmp = Float64(d1 * d2); elseif ((d2 <= -1.8e-38) || (!(d2 <= -4e-152) && (d2 <= 4.2e-199))) tmp = Float64(d1 * Float64(-d1)); else tmp = Float64(d1 * d4); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d2 <= -3.6e+111) tmp = d1 * d2; elseif ((d2 <= -1.8e-38) || (~((d2 <= -4e-152)) && (d2 <= 4.2e-199))) tmp = d1 * -d1; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -3.6e+111], N[(d1 * d2), $MachinePrecision], If[Or[LessEqual[d2, -1.8e-38], And[N[Not[LessEqual[d2, -4e-152]], $MachinePrecision], LessEqual[d2, 4.2e-199]]], N[(d1 * (-d1)), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -3.6 \cdot 10^{+111}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d2 \leq -1.8 \cdot 10^{-38} \lor \neg \left(d2 \leq -4 \cdot 10^{-152}\right) \land d2 \leq 4.2 \cdot 10^{-199}:\\
\;\;\;\;d1 \cdot \left(-d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d2 < -3.6000000000000002e111Initial program 80.0%
sub-neg80.0%
associate-+l+80.0%
*-commutative80.0%
+-commutative80.0%
*-commutative80.0%
sub-neg80.0%
+-commutative80.0%
associate--l+80.0%
distribute-lft-out--80.0%
distribute-rgt-out--86.6%
distribute-lft-out100.0%
+-commutative100.0%
sub-neg100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
sub-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in d2 around inf 74.1%
if -3.6000000000000002e111 < d2 < -1.8e-38 or -4.00000000000000026e-152 < d2 < 4.20000000000000004e-199Initial program 88.2%
sub-neg88.2%
associate-+l+88.2%
*-commutative88.2%
+-commutative88.2%
*-commutative88.2%
sub-neg88.2%
+-commutative88.2%
associate--l+88.2%
distribute-lft-out--88.1%
distribute-rgt-out--89.2%
distribute-lft-out100.0%
+-commutative100.0%
sub-neg100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
sub-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in d4 around 0 76.2%
+-commutative76.2%
associate--r+76.2%
Simplified76.2%
Taylor expanded in d1 around inf 41.8%
neg-mul-141.8%
Simplified41.8%
if -1.8e-38 < d2 < -4.00000000000000026e-152 or 4.20000000000000004e-199 < d2 Initial program 85.6%
sub-neg85.6%
associate-+l+85.6%
*-commutative85.6%
+-commutative85.6%
*-commutative85.6%
sub-neg85.6%
+-commutative85.6%
associate--l+85.6%
distribute-lft-out--86.4%
distribute-rgt-out--93.2%
distribute-lft-out100.0%
+-commutative100.0%
sub-neg100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
sub-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in d4 around inf 34.5%
Final simplification44.1%
(FPCore (d1 d2 d3 d4)
:precision binary64
(let* ((t_0 (* d1 (- d3))))
(if (<= d3 -3.6e+125)
t_0
(if (<= d3 2e-85)
(* d1 (+ d2 d4))
(if (<= d3 2.1e+152) (* d1 (- d2 d1)) t_0)))))
double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * -d3;
double tmp;
if (d3 <= -3.6e+125) {
tmp = t_0;
} else if (d3 <= 2e-85) {
tmp = d1 * (d2 + d4);
} else if (d3 <= 2.1e+152) {
tmp = d1 * (d2 - d1);
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: t_0
real(8) :: tmp
t_0 = d1 * -d3
if (d3 <= (-3.6d+125)) then
tmp = t_0
else if (d3 <= 2d-85) then
tmp = d1 * (d2 + d4)
else if (d3 <= 2.1d+152) then
tmp = d1 * (d2 - d1)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * -d3;
double tmp;
if (d3 <= -3.6e+125) {
tmp = t_0;
} else if (d3 <= 2e-85) {
tmp = d1 * (d2 + d4);
} else if (d3 <= 2.1e+152) {
tmp = d1 * (d2 - d1);
} else {
tmp = t_0;
}
return tmp;
}
def code(d1, d2, d3, d4): t_0 = d1 * -d3 tmp = 0 if d3 <= -3.6e+125: tmp = t_0 elif d3 <= 2e-85: tmp = d1 * (d2 + d4) elif d3 <= 2.1e+152: tmp = d1 * (d2 - d1) else: tmp = t_0 return tmp
function code(d1, d2, d3, d4) t_0 = Float64(d1 * Float64(-d3)) tmp = 0.0 if (d3 <= -3.6e+125) tmp = t_0; elseif (d3 <= 2e-85) tmp = Float64(d1 * Float64(d2 + d4)); elseif (d3 <= 2.1e+152) tmp = Float64(d1 * Float64(d2 - d1)); else tmp = t_0; end return tmp end
function tmp_2 = code(d1, d2, d3, d4) t_0 = d1 * -d3; tmp = 0.0; if (d3 <= -3.6e+125) tmp = t_0; elseif (d3 <= 2e-85) tmp = d1 * (d2 + d4); elseif (d3 <= 2.1e+152) tmp = d1 * (d2 - d1); else tmp = t_0; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := Block[{t$95$0 = N[(d1 * (-d3)), $MachinePrecision]}, If[LessEqual[d3, -3.6e+125], t$95$0, If[LessEqual[d3, 2e-85], N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision], If[LessEqual[d3, 2.1e+152], N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := d1 \cdot \left(-d3\right)\\
\mathbf{if}\;d3 \leq -3.6 \cdot 10^{+125}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d3 \leq 2 \cdot 10^{-85}:\\
\;\;\;\;d1 \cdot \left(d2 + d4\right)\\
\mathbf{elif}\;d3 \leq 2.1 \cdot 10^{+152}:\\
\;\;\;\;d1 \cdot \left(d2 - d1\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if d3 < -3.6000000000000003e125 or 2.1000000000000002e152 < d3 Initial program 80.5%
sub-neg80.5%
associate-+l+80.5%
*-commutative80.5%
+-commutative80.5%
*-commutative80.5%
sub-neg80.5%
+-commutative80.5%
associate--l+80.5%
distribute-lft-out--80.5%
distribute-rgt-out--84.7%
distribute-lft-out100.0%
+-commutative100.0%
sub-neg100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
sub-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in d3 around inf 77.3%
mul-1-neg77.3%
distribute-rgt-neg-out77.3%
Simplified77.3%
if -3.6000000000000003e125 < d3 < 2e-85Initial program 89.3%
sub-neg89.3%
associate-+l+89.3%
*-commutative89.3%
+-commutative89.3%
*-commutative89.3%
sub-neg89.3%
+-commutative89.3%
associate--l+89.3%
distribute-lft-out--90.0%
distribute-rgt-out--94.6%
distribute-lft-out100.0%
+-commutative100.0%
sub-neg100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
sub-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in d1 around 0 77.8%
Taylor expanded in d3 around 0 70.1%
+-commutative70.1%
Simplified70.1%
if 2e-85 < d3 < 2.1000000000000002e152Initial program 83.0%
sub-neg83.0%
associate-+l+83.0%
*-commutative83.0%
+-commutative83.0%
*-commutative83.0%
sub-neg83.0%
+-commutative83.0%
associate--l+83.0%
distribute-lft-out--83.0%
distribute-rgt-out--88.7%
distribute-lft-out100.0%
+-commutative100.0%
sub-neg100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
sub-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in d4 around 0 78.4%
+-commutative78.4%
associate--r+78.4%
Simplified78.4%
Taylor expanded in d3 around 0 65.1%
Final simplification71.1%
(FPCore (d1 d2 d3 d4)
:precision binary64
(let* ((t_0 (* d1 (- d2 d3))))
(if (<= d3 -12500.0)
t_0
(if (<= d3 1.85e-87)
(* d1 (+ d2 d4))
(if (<= d3 1.1e+152) (* d1 (- d2 d1)) t_0)))))
double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * (d2 - d3);
double tmp;
if (d3 <= -12500.0) {
tmp = t_0;
} else if (d3 <= 1.85e-87) {
tmp = d1 * (d2 + d4);
} else if (d3 <= 1.1e+152) {
tmp = d1 * (d2 - d1);
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: t_0
real(8) :: tmp
t_0 = d1 * (d2 - d3)
if (d3 <= (-12500.0d0)) then
tmp = t_0
else if (d3 <= 1.85d-87) then
tmp = d1 * (d2 + d4)
else if (d3 <= 1.1d+152) then
tmp = d1 * (d2 - d1)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * (d2 - d3);
double tmp;
if (d3 <= -12500.0) {
tmp = t_0;
} else if (d3 <= 1.85e-87) {
tmp = d1 * (d2 + d4);
} else if (d3 <= 1.1e+152) {
tmp = d1 * (d2 - d1);
} else {
tmp = t_0;
}
return tmp;
}
def code(d1, d2, d3, d4): t_0 = d1 * (d2 - d3) tmp = 0 if d3 <= -12500.0: tmp = t_0 elif d3 <= 1.85e-87: tmp = d1 * (d2 + d4) elif d3 <= 1.1e+152: tmp = d1 * (d2 - d1) else: tmp = t_0 return tmp
function code(d1, d2, d3, d4) t_0 = Float64(d1 * Float64(d2 - d3)) tmp = 0.0 if (d3 <= -12500.0) tmp = t_0; elseif (d3 <= 1.85e-87) tmp = Float64(d1 * Float64(d2 + d4)); elseif (d3 <= 1.1e+152) tmp = Float64(d1 * Float64(d2 - d1)); else tmp = t_0; end return tmp end
function tmp_2 = code(d1, d2, d3, d4) t_0 = d1 * (d2 - d3); tmp = 0.0; if (d3 <= -12500.0) tmp = t_0; elseif (d3 <= 1.85e-87) tmp = d1 * (d2 + d4); elseif (d3 <= 1.1e+152) tmp = d1 * (d2 - d1); else tmp = t_0; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := Block[{t$95$0 = N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d3, -12500.0], t$95$0, If[LessEqual[d3, 1.85e-87], N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision], If[LessEqual[d3, 1.1e+152], N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := d1 \cdot \left(d2 - d3\right)\\
\mathbf{if}\;d3 \leq -12500:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d3 \leq 1.85 \cdot 10^{-87}:\\
\;\;\;\;d1 \cdot \left(d2 + d4\right)\\
\mathbf{elif}\;d3 \leq 1.1 \cdot 10^{+152}:\\
\;\;\;\;d1 \cdot \left(d2 - d1\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if d3 < -12500 or 1.0999999999999999e152 < d3 Initial program 83.3%
sub-neg83.3%
associate-+l+83.3%
*-commutative83.3%
+-commutative83.3%
*-commutative83.3%
sub-neg83.3%
+-commutative83.3%
associate--l+83.3%
distribute-lft-out--84.3%
distribute-rgt-out--87.2%
distribute-lft-out100.0%
+-commutative100.0%
sub-neg100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
sub-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in d4 around 0 91.6%
+-commutative91.6%
associate--r+91.6%
Simplified91.6%
Taylor expanded in d1 around 0 81.5%
if -12500 < d3 < 1.8500000000000001e-87Initial program 89.1%
sub-neg89.1%
associate-+l+89.1%
*-commutative89.1%
+-commutative89.1%
*-commutative89.1%
sub-neg89.1%
+-commutative89.1%
associate--l+89.1%
distribute-lft-out--89.1%
distribute-rgt-out--95.0%
distribute-lft-out100.0%
+-commutative100.0%
sub-neg100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
sub-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in d1 around 0 76.7%
Taylor expanded in d3 around 0 75.1%
+-commutative75.1%
Simplified75.1%
if 1.8500000000000001e-87 < d3 < 1.0999999999999999e152Initial program 83.0%
sub-neg83.0%
associate-+l+83.0%
*-commutative83.0%
+-commutative83.0%
*-commutative83.0%
sub-neg83.0%
+-commutative83.0%
associate--l+83.0%
distribute-lft-out--83.0%
distribute-rgt-out--88.7%
distribute-lft-out100.0%
+-commutative100.0%
sub-neg100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
sub-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in d4 around 0 78.4%
+-commutative78.4%
associate--r+78.4%
Simplified78.4%
Taylor expanded in d3 around 0 65.1%
Final simplification75.6%
(FPCore (d1 d2 d3 d4)
:precision binary64
(let* ((t_0 (* d1 (- d2 d3))))
(if (<= d4 -2.8e-148)
t_0
(if (<= d4 -6.6e-273)
(* d1 (- d2 d1))
(if (<= d4 1.1e+44) t_0 (* d1 (- d4 d3)))))))
double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * (d2 - d3);
double tmp;
if (d4 <= -2.8e-148) {
tmp = t_0;
} else if (d4 <= -6.6e-273) {
tmp = d1 * (d2 - d1);
} else if (d4 <= 1.1e+44) {
tmp = t_0;
} else {
tmp = d1 * (d4 - d3);
}
return tmp;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: t_0
real(8) :: tmp
t_0 = d1 * (d2 - d3)
if (d4 <= (-2.8d-148)) then
tmp = t_0
else if (d4 <= (-6.6d-273)) then
tmp = d1 * (d2 - d1)
else if (d4 <= 1.1d+44) then
tmp = t_0
else
tmp = d1 * (d4 - d3)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * (d2 - d3);
double tmp;
if (d4 <= -2.8e-148) {
tmp = t_0;
} else if (d4 <= -6.6e-273) {
tmp = d1 * (d2 - d1);
} else if (d4 <= 1.1e+44) {
tmp = t_0;
} else {
tmp = d1 * (d4 - d3);
}
return tmp;
}
def code(d1, d2, d3, d4): t_0 = d1 * (d2 - d3) tmp = 0 if d4 <= -2.8e-148: tmp = t_0 elif d4 <= -6.6e-273: tmp = d1 * (d2 - d1) elif d4 <= 1.1e+44: tmp = t_0 else: tmp = d1 * (d4 - d3) return tmp
function code(d1, d2, d3, d4) t_0 = Float64(d1 * Float64(d2 - d3)) tmp = 0.0 if (d4 <= -2.8e-148) tmp = t_0; elseif (d4 <= -6.6e-273) tmp = Float64(d1 * Float64(d2 - d1)); elseif (d4 <= 1.1e+44) tmp = t_0; else tmp = Float64(d1 * Float64(d4 - d3)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) t_0 = d1 * (d2 - d3); tmp = 0.0; if (d4 <= -2.8e-148) tmp = t_0; elseif (d4 <= -6.6e-273) tmp = d1 * (d2 - d1); elseif (d4 <= 1.1e+44) tmp = t_0; else tmp = d1 * (d4 - d3); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := Block[{t$95$0 = N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d4, -2.8e-148], t$95$0, If[LessEqual[d4, -6.6e-273], N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision], If[LessEqual[d4, 1.1e+44], t$95$0, N[(d1 * N[(d4 - d3), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := d1 \cdot \left(d2 - d3\right)\\
\mathbf{if}\;d4 \leq -2.8 \cdot 10^{-148}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d4 \leq -6.6 \cdot 10^{-273}:\\
\;\;\;\;d1 \cdot \left(d2 - d1\right)\\
\mathbf{elif}\;d4 \leq 1.1 \cdot 10^{+44}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\end{array}
\end{array}
if d4 < -2.8e-148 or -6.5999999999999998e-273 < d4 < 1.09999999999999998e44Initial program 88.1%
sub-neg88.1%
associate-+l+88.1%
*-commutative88.1%
+-commutative88.1%
*-commutative88.1%
sub-neg88.1%
+-commutative88.1%
associate--l+88.1%
distribute-lft-out--88.7%
distribute-rgt-out--93.5%
distribute-lft-out100.0%
+-commutative100.0%
sub-neg100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
sub-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in d4 around 0 84.8%
+-commutative84.8%
associate--r+84.8%
Simplified84.8%
Taylor expanded in d1 around 0 63.3%
if -2.8e-148 < d4 < -6.5999999999999998e-273Initial program 79.9%
sub-neg79.9%
associate-+l+79.9%
*-commutative79.9%
+-commutative79.9%
*-commutative79.9%
sub-neg79.9%
+-commutative79.9%
associate--l+79.9%
distribute-lft-out--79.9%
distribute-rgt-out--89.9%
distribute-lft-out100.0%
+-commutative100.0%
sub-neg100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
sub-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in d4 around 0 100.0%
+-commutative100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in d3 around 0 78.3%
if 1.09999999999999998e44 < d4 Initial program 80.7%
sub-neg80.7%
associate-+l+80.7%
*-commutative80.7%
+-commutative80.7%
*-commutative80.7%
sub-neg80.7%
+-commutative80.7%
associate--l+80.7%
distribute-lft-out--80.6%
distribute-rgt-out--82.4%
distribute-lft-out99.9%
+-commutative99.9%
sub-neg99.9%
+-commutative99.9%
remove-double-neg99.9%
sub-neg99.9%
sub-neg99.9%
distribute-neg-in99.9%
sub-neg99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in d1 around 0 84.2%
Taylor expanded in d2 around 0 74.5%
Final simplification67.5%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (or (<= d1 -4.5e+71) (not (<= d1 6.3e+133))) (* d1 (- (- d1) d3)) (* d1 (- (+ d2 d4) d3))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d1 <= -4.5e+71) || !(d1 <= 6.3e+133)) {
tmp = d1 * (-d1 - d3);
} else {
tmp = d1 * ((d2 + d4) - d3);
}
return tmp;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if ((d1 <= (-4.5d+71)) .or. (.not. (d1 <= 6.3d+133))) then
tmp = d1 * (-d1 - d3)
else
tmp = d1 * ((d2 + d4) - d3)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d1 <= -4.5e+71) || !(d1 <= 6.3e+133)) {
tmp = d1 * (-d1 - d3);
} else {
tmp = d1 * ((d2 + d4) - d3);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if (d1 <= -4.5e+71) or not (d1 <= 6.3e+133): tmp = d1 * (-d1 - d3) else: tmp = d1 * ((d2 + d4) - d3) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if ((d1 <= -4.5e+71) || !(d1 <= 6.3e+133)) tmp = Float64(d1 * Float64(Float64(-d1) - d3)); else tmp = Float64(d1 * Float64(Float64(d2 + d4) - d3)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if ((d1 <= -4.5e+71) || ~((d1 <= 6.3e+133))) tmp = d1 * (-d1 - d3); else tmp = d1 * ((d2 + d4) - d3); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[Or[LessEqual[d1, -4.5e+71], N[Not[LessEqual[d1, 6.3e+133]], $MachinePrecision]], N[(d1 * N[((-d1) - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(N[(d2 + d4), $MachinePrecision] - d3), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d1 \leq -4.5 \cdot 10^{+71} \lor \neg \left(d1 \leq 6.3 \cdot 10^{+133}\right):\\
\;\;\;\;d1 \cdot \left(\left(-d1\right) - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(\left(d2 + d4\right) - d3\right)\\
\end{array}
\end{array}
if d1 < -4.50000000000000043e71 or 6.30000000000000049e133 < d1 Initial program 57.0%
sub-neg57.0%
associate-+l+57.0%
*-commutative57.0%
+-commutative57.0%
*-commutative57.0%
sub-neg57.0%
+-commutative57.0%
associate--l+57.0%
distribute-lft-out--58.1%
distribute-rgt-out--72.1%
distribute-lft-out100.0%
+-commutative100.0%
sub-neg100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
sub-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in d4 around 0 96.5%
+-commutative96.5%
associate--r+96.5%
Simplified96.5%
Taylor expanded in d2 around 0 88.3%
associate-*r*88.3%
neg-mul-188.3%
Simplified88.3%
if -4.50000000000000043e71 < d1 < 6.30000000000000049e133Initial program 100.0%
sub-neg100.0%
associate-+l+100.0%
*-commutative100.0%
+-commutative100.0%
*-commutative100.0%
sub-neg100.0%
+-commutative100.0%
associate--l+100.0%
distribute-lft-out--100.0%
distribute-rgt-out--100.0%
distribute-lft-out100.0%
+-commutative100.0%
sub-neg100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
sub-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in d1 around 0 92.2%
Final simplification90.9%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (or (<= d3 -2.2e+121) (not (<= d3 1.12e+152))) (* d1 (- d3)) (* d1 (+ d2 d4))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d3 <= -2.2e+121) || !(d3 <= 1.12e+152)) {
tmp = d1 * -d3;
} else {
tmp = d1 * (d2 + d4);
}
return tmp;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if ((d3 <= (-2.2d+121)) .or. (.not. (d3 <= 1.12d+152))) then
tmp = d1 * -d3
else
tmp = d1 * (d2 + d4)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d3 <= -2.2e+121) || !(d3 <= 1.12e+152)) {
tmp = d1 * -d3;
} else {
tmp = d1 * (d2 + d4);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if (d3 <= -2.2e+121) or not (d3 <= 1.12e+152): tmp = d1 * -d3 else: tmp = d1 * (d2 + d4) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if ((d3 <= -2.2e+121) || !(d3 <= 1.12e+152)) tmp = Float64(d1 * Float64(-d3)); else tmp = Float64(d1 * Float64(d2 + d4)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if ((d3 <= -2.2e+121) || ~((d3 <= 1.12e+152))) tmp = d1 * -d3; else tmp = d1 * (d2 + d4); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[Or[LessEqual[d3, -2.2e+121], N[Not[LessEqual[d3, 1.12e+152]], $MachinePrecision]], N[(d1 * (-d3)), $MachinePrecision], N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d3 \leq -2.2 \cdot 10^{+121} \lor \neg \left(d3 \leq 1.12 \cdot 10^{+152}\right):\\
\;\;\;\;d1 \cdot \left(-d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d2 + d4\right)\\
\end{array}
\end{array}
if d3 < -2.20000000000000001e121 or 1.11999999999999995e152 < d3 Initial program 80.5%
sub-neg80.5%
associate-+l+80.5%
*-commutative80.5%
+-commutative80.5%
*-commutative80.5%
sub-neg80.5%
+-commutative80.5%
associate--l+80.5%
distribute-lft-out--80.5%
distribute-rgt-out--84.7%
distribute-lft-out100.0%
+-commutative100.0%
sub-neg100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
sub-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in d3 around inf 77.3%
mul-1-neg77.3%
distribute-rgt-neg-out77.3%
Simplified77.3%
if -2.20000000000000001e121 < d3 < 1.11999999999999995e152Initial program 87.5%
sub-neg87.5%
associate-+l+87.5%
*-commutative87.5%
+-commutative87.5%
*-commutative87.5%
sub-neg87.5%
+-commutative87.5%
associate--l+87.5%
distribute-lft-out--88.0%
distribute-rgt-out--92.9%
distribute-lft-out100.0%
+-commutative100.0%
sub-neg100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
sub-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in d1 around 0 75.2%
Taylor expanded in d3 around 0 66.5%
+-commutative66.5%
Simplified66.5%
Final simplification69.5%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 4.4e+16) (* d1 (- (- d2 d3) d1)) (* d1 (- (+ d2 d4) d3))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 4.4e+16) {
tmp = d1 * ((d2 - d3) - d1);
} else {
tmp = d1 * ((d2 + d4) - d3);
}
return tmp;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if (d4 <= 4.4d+16) then
tmp = d1 * ((d2 - d3) - d1)
else
tmp = d1 * ((d2 + d4) - d3)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 4.4e+16) {
tmp = d1 * ((d2 - d3) - d1);
} else {
tmp = d1 * ((d2 + d4) - d3);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 4.4e+16: tmp = d1 * ((d2 - d3) - d1) else: tmp = d1 * ((d2 + d4) - d3) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 4.4e+16) tmp = Float64(d1 * Float64(Float64(d2 - d3) - d1)); else tmp = Float64(d1 * Float64(Float64(d2 + d4) - d3)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d4 <= 4.4e+16) tmp = d1 * ((d2 - d3) - d1); else tmp = d1 * ((d2 + d4) - d3); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 4.4e+16], N[(d1 * N[(N[(d2 - d3), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(N[(d2 + d4), $MachinePrecision] - d3), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 4.4 \cdot 10^{+16}:\\
\;\;\;\;d1 \cdot \left(\left(d2 - d3\right) - d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(\left(d2 + d4\right) - d3\right)\\
\end{array}
\end{array}
if d4 < 4.4e16Initial program 86.8%
sub-neg86.8%
associate-+l+86.8%
*-commutative86.8%
+-commutative86.8%
*-commutative86.8%
sub-neg86.8%
+-commutative86.8%
associate--l+86.8%
distribute-lft-out--87.3%
distribute-rgt-out--92.9%
distribute-lft-out100.0%
+-commutative100.0%
sub-neg100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
sub-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in d4 around 0 87.0%
+-commutative87.0%
associate--r+87.0%
Simplified87.0%
if 4.4e16 < d4 Initial program 81.3%
sub-neg81.3%
associate-+l+81.3%
*-commutative81.3%
+-commutative81.3%
*-commutative81.3%
sub-neg81.3%
+-commutative81.3%
associate--l+81.3%
distribute-lft-out--81.3%
distribute-rgt-out--83.0%
distribute-lft-out99.9%
+-commutative99.9%
sub-neg99.9%
+-commutative99.9%
remove-double-neg99.9%
sub-neg99.9%
sub-neg99.9%
distribute-neg-in99.9%
sub-neg99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in d1 around 0 84.7%
Final simplification86.5%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -1.7e-45) (* d1 (- (- d2 d3) d1)) (* d1 (- (- d4 d3) d1))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -1.7e-45) {
tmp = d1 * ((d2 - d3) - d1);
} else {
tmp = d1 * ((d4 - d3) - d1);
}
return tmp;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if (d2 <= (-1.7d-45)) then
tmp = d1 * ((d2 - d3) - d1)
else
tmp = d1 * ((d4 - d3) - d1)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -1.7e-45) {
tmp = d1 * ((d2 - d3) - d1);
} else {
tmp = d1 * ((d4 - d3) - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -1.7e-45: tmp = d1 * ((d2 - d3) - d1) else: tmp = d1 * ((d4 - d3) - d1) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -1.7e-45) tmp = Float64(d1 * Float64(Float64(d2 - d3) - d1)); else tmp = Float64(d1 * Float64(Float64(d4 - d3) - d1)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d2 <= -1.7e-45) tmp = d1 * ((d2 - d3) - d1); else tmp = d1 * ((d4 - d3) - d1); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -1.7e-45], N[(d1 * N[(N[(d2 - d3), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(N[(d4 - d3), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -1.7 \cdot 10^{-45}:\\
\;\;\;\;d1 \cdot \left(\left(d2 - d3\right) - d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(\left(d4 - d3\right) - d1\right)\\
\end{array}
\end{array}
if d2 < -1.70000000000000002e-45Initial program 80.7%
sub-neg80.7%
associate-+l+80.7%
*-commutative80.7%
+-commutative80.7%
*-commutative80.7%
sub-neg80.7%
+-commutative80.7%
associate--l+80.7%
distribute-lft-out--80.7%
distribute-rgt-out--85.5%
distribute-lft-out100.0%
+-commutative100.0%
sub-neg100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
sub-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in d4 around 0 88.2%
+-commutative88.2%
associate--r+88.2%
Simplified88.2%
if -1.70000000000000002e-45 < d2 Initial program 87.8%
sub-neg87.8%
associate-+l+87.8%
*-commutative87.8%
+-commutative87.8%
*-commutative87.8%
sub-neg87.8%
+-commutative87.8%
associate--l+87.8%
distribute-lft-out--88.4%
distribute-rgt-out--93.0%
distribute-lft-out100.0%
+-commutative100.0%
sub-neg100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
sub-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in d2 around 0 84.4%
+-commutative84.4%
associate--r+84.4%
Simplified84.4%
Final simplification85.6%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -520000.0) (* d1 d2) (* d1 d4)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -520000.0) {
tmp = d1 * d2;
} else {
tmp = d1 * d4;
}
return tmp;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if (d2 <= (-520000.0d0)) then
tmp = d1 * d2
else
tmp = d1 * d4
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -520000.0) {
tmp = d1 * d2;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -520000.0: tmp = d1 * d2 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -520000.0) tmp = Float64(d1 * d2); else tmp = Float64(d1 * d4); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d2 <= -520000.0) tmp = d1 * d2; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -520000.0], N[(d1 * d2), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -520000:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d2 < -5.2e5Initial program 80.0%
sub-neg80.0%
associate-+l+80.0%
*-commutative80.0%
+-commutative80.0%
*-commutative80.0%
sub-neg80.0%
+-commutative80.0%
associate--l+80.0%
distribute-lft-out--80.0%
distribute-rgt-out--86.1%
distribute-lft-out100.0%
+-commutative100.0%
sub-neg100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
sub-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in d2 around inf 56.5%
if -5.2e5 < d2 Initial program 87.4%
sub-neg87.4%
associate-+l+87.4%
*-commutative87.4%
+-commutative87.4%
*-commutative87.4%
sub-neg87.4%
+-commutative87.4%
associate--l+87.4%
distribute-lft-out--87.9%
distribute-rgt-out--92.1%
distribute-lft-out100.0%
+-commutative100.0%
sub-neg100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
sub-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in d4 around inf 34.8%
Final simplification40.3%
(FPCore (d1 d2 d3 d4) :precision binary64 (* d1 d2))
double code(double d1, double d2, double d3, double d4) {
return d1 * d2;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
code = d1 * d2
end function
public static double code(double d1, double d2, double d3, double d4) {
return d1 * d2;
}
def code(d1, d2, d3, d4): return d1 * d2
function code(d1, d2, d3, d4) return Float64(d1 * d2) end
function tmp = code(d1, d2, d3, d4) tmp = d1 * d2; end
code[d1_, d2_, d3_, d4_] := N[(d1 * d2), $MachinePrecision]
\begin{array}{l}
\\
d1 \cdot d2
\end{array}
Initial program 85.5%
sub-neg85.5%
associate-+l+85.5%
*-commutative85.5%
+-commutative85.5%
*-commutative85.5%
sub-neg85.5%
+-commutative85.5%
associate--l+85.5%
distribute-lft-out--85.9%
distribute-rgt-out--90.6%
distribute-lft-out100.0%
+-commutative100.0%
sub-neg100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
sub-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in d2 around inf 30.7%
Final simplification30.7%
(FPCore (d1 d2 d3 d4) :precision binary64 (* d1 (- (+ (- d2 d3) d4) d1)))
double code(double d1, double d2, double d3, double d4) {
return d1 * (((d2 - d3) + d4) - d1);
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
code = d1 * (((d2 - d3) + d4) - d1)
end function
public static double code(double d1, double d2, double d3, double d4) {
return d1 * (((d2 - d3) + d4) - d1);
}
def code(d1, d2, d3, d4): return d1 * (((d2 - d3) + d4) - d1)
function code(d1, d2, d3, d4) return Float64(d1 * Float64(Float64(Float64(d2 - d3) + d4) - d1)) end
function tmp = code(d1, d2, d3, d4) tmp = d1 * (((d2 - d3) + d4) - d1); end
code[d1_, d2_, d3_, d4_] := N[(d1 * N[(N[(N[(d2 - d3), $MachinePrecision] + d4), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
d1 \cdot \left(\left(\left(d2 - d3\right) + d4\right) - d1\right)
\end{array}
herbie shell --seed 2024023
(FPCore (d1 d2 d3 d4)
:name "FastMath dist4"
:precision binary64
:herbie-target
(* d1 (- (+ (- d2 d3) d4) d1))
(- (+ (- (* d1 d2) (* d1 d3)) (* d4 d1)) (* d1 d1)))