
(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 12 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 (+ (- d2 d1) (- d4 d3))))
double code(double d1, double d2, double d3, double d4) {
return d1 * ((d2 - d1) + (d4 - d3));
}
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) + (d4 - d3))
end function
public static double code(double d1, double d2, double d3, double d4) {
return d1 * ((d2 - d1) + (d4 - d3));
}
def code(d1, d2, d3, d4): return d1 * ((d2 - d1) + (d4 - d3))
function code(d1, d2, d3, d4) return Float64(d1 * Float64(Float64(d2 - d1) + Float64(d4 - d3))) end
function tmp = code(d1, d2, d3, d4) tmp = d1 * ((d2 - d1) + (d4 - d3)); end
code[d1_, d2_, d3_, d4_] := N[(d1 * N[(N[(d2 - d1), $MachinePrecision] + N[(d4 - d3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
d1 \cdot \left(\left(d2 - d1\right) + \left(d4 - d3\right)\right)
\end{array}
Initial program 87.9%
sub-neg87.9%
associate-+l+87.9%
*-commutative87.9%
+-commutative87.9%
*-commutative87.9%
sub-neg87.9%
+-commutative87.9%
associate--l+87.9%
distribute-lft-out--90.2%
distribute-rgt-out--94.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%
Final simplification100.0%
(FPCore (d1 d2 d3 d4)
:precision binary64
(let* ((t_0 (* d1 (+ d2 d4))) (t_1 (* d3 (- d1))) (t_2 (* d1 (- d2 d1))))
(if (<= d3 -4e+180)
t_1
(if (<= d3 -9e-170)
t_2
(if (<= d3 -3e-251)
t_0
(if (<= d3 -7.1e-304) t_2 (if (<= d3 4e+103) t_0 t_1)))))))
double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * (d2 + d4);
double t_1 = d3 * -d1;
double t_2 = d1 * (d2 - d1);
double tmp;
if (d3 <= -4e+180) {
tmp = t_1;
} else if (d3 <= -9e-170) {
tmp = t_2;
} else if (d3 <= -3e-251) {
tmp = t_0;
} else if (d3 <= -7.1e-304) {
tmp = t_2;
} else if (d3 <= 4e+103) {
tmp = t_0;
} else {
tmp = t_1;
}
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) :: t_2
real(8) :: tmp
t_0 = d1 * (d2 + d4)
t_1 = d3 * -d1
t_2 = d1 * (d2 - d1)
if (d3 <= (-4d+180)) then
tmp = t_1
else if (d3 <= (-9d-170)) then
tmp = t_2
else if (d3 <= (-3d-251)) then
tmp = t_0
else if (d3 <= (-7.1d-304)) then
tmp = t_2
else if (d3 <= 4d+103) then
tmp = t_0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * (d2 + d4);
double t_1 = d3 * -d1;
double t_2 = d1 * (d2 - d1);
double tmp;
if (d3 <= -4e+180) {
tmp = t_1;
} else if (d3 <= -9e-170) {
tmp = t_2;
} else if (d3 <= -3e-251) {
tmp = t_0;
} else if (d3 <= -7.1e-304) {
tmp = t_2;
} else if (d3 <= 4e+103) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(d1, d2, d3, d4): t_0 = d1 * (d2 + d4) t_1 = d3 * -d1 t_2 = d1 * (d2 - d1) tmp = 0 if d3 <= -4e+180: tmp = t_1 elif d3 <= -9e-170: tmp = t_2 elif d3 <= -3e-251: tmp = t_0 elif d3 <= -7.1e-304: tmp = t_2 elif d3 <= 4e+103: tmp = t_0 else: tmp = t_1 return tmp
function code(d1, d2, d3, d4) t_0 = Float64(d1 * Float64(d2 + d4)) t_1 = Float64(d3 * Float64(-d1)) t_2 = Float64(d1 * Float64(d2 - d1)) tmp = 0.0 if (d3 <= -4e+180) tmp = t_1; elseif (d3 <= -9e-170) tmp = t_2; elseif (d3 <= -3e-251) tmp = t_0; elseif (d3 <= -7.1e-304) tmp = t_2; elseif (d3 <= 4e+103) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(d1, d2, d3, d4) t_0 = d1 * (d2 + d4); t_1 = d3 * -d1; t_2 = d1 * (d2 - d1); tmp = 0.0; if (d3 <= -4e+180) tmp = t_1; elseif (d3 <= -9e-170) tmp = t_2; elseif (d3 <= -3e-251) tmp = t_0; elseif (d3 <= -7.1e-304) tmp = t_2; elseif (d3 <= 4e+103) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := Block[{t$95$0 = N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(d3 * (-d1)), $MachinePrecision]}, Block[{t$95$2 = N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d3, -4e+180], t$95$1, If[LessEqual[d3, -9e-170], t$95$2, If[LessEqual[d3, -3e-251], t$95$0, If[LessEqual[d3, -7.1e-304], t$95$2, If[LessEqual[d3, 4e+103], t$95$0, t$95$1]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := d1 \cdot \left(d2 + d4\right)\\
t_1 := d3 \cdot \left(-d1\right)\\
t_2 := d1 \cdot \left(d2 - d1\right)\\
\mathbf{if}\;d3 \leq -4 \cdot 10^{+180}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d3 \leq -9 \cdot 10^{-170}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;d3 \leq -3 \cdot 10^{-251}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d3 \leq -7.1 \cdot 10^{-304}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;d3 \leq 4 \cdot 10^{+103}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if d3 < -4e180 or 4e103 < d3 Initial program 85.2%
sub-neg85.2%
associate-+l+85.2%
*-commutative85.2%
+-commutative85.2%
*-commutative85.2%
sub-neg85.2%
+-commutative85.2%
associate--l+85.2%
distribute-lft-out--86.3%
distribute-rgt-out--90.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 d3 around inf 81.8%
mul-1-neg81.8%
distribute-rgt-neg-out81.8%
Simplified81.8%
if -4e180 < d3 < -9.00000000000000003e-170 or -2.9999999999999999e-251 < d3 < -7.1000000000000001e-304Initial program 85.3%
sub-neg85.3%
associate-+l+85.3%
*-commutative85.3%
+-commutative85.3%
*-commutative85.3%
sub-neg85.3%
+-commutative85.3%
associate--l+85.3%
distribute-lft-out--90.2%
distribute-rgt-out--93.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 74.6%
+-commutative74.6%
associate--r+74.6%
Simplified74.6%
Taylor expanded in d3 around 0 64.0%
if -9.00000000000000003e-170 < d3 < -2.9999999999999999e-251 or -7.1000000000000001e-304 < d3 < 4e103Initial program 93.0%
sub-neg93.0%
associate-+l+93.0%
*-commutative93.0%
+-commutative93.0%
*-commutative93.0%
sub-neg93.0%
+-commutative93.0%
associate--l+93.0%
distribute-lft-out--94.1%
fma-def94.2%
distribute-rgt-out--97.7%
Simplified97.7%
Taylor expanded in d3 around 0 90.2%
Taylor expanded in d1 around 0 78.1%
Final simplification74.9%
(FPCore (d1 d2 d3 d4)
:precision binary64
(if (<= d2 -1.8e+133)
(* d1 d2)
(if (or (<= d2 -2.5e-119) (and (not (<= d2 -2.4e-153)) (<= d2 1.3e-207)))
(* d3 (- d1))
(* d1 d4))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -1.8e+133) {
tmp = d1 * d2;
} else if ((d2 <= -2.5e-119) || (!(d2 <= -2.4e-153) && (d2 <= 1.3e-207))) {
tmp = d3 * -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 <= (-1.8d+133)) then
tmp = d1 * d2
else if ((d2 <= (-2.5d-119)) .or. (.not. (d2 <= (-2.4d-153))) .and. (d2 <= 1.3d-207)) then
tmp = d3 * -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 <= -1.8e+133) {
tmp = d1 * d2;
} else if ((d2 <= -2.5e-119) || (!(d2 <= -2.4e-153) && (d2 <= 1.3e-207))) {
tmp = d3 * -d1;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -1.8e+133: tmp = d1 * d2 elif (d2 <= -2.5e-119) or (not (d2 <= -2.4e-153) and (d2 <= 1.3e-207)): tmp = d3 * -d1 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -1.8e+133) tmp = Float64(d1 * d2); elseif ((d2 <= -2.5e-119) || (!(d2 <= -2.4e-153) && (d2 <= 1.3e-207))) tmp = Float64(d3 * Float64(-d1)); else tmp = Float64(d1 * d4); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d2 <= -1.8e+133) tmp = d1 * d2; elseif ((d2 <= -2.5e-119) || (~((d2 <= -2.4e-153)) && (d2 <= 1.3e-207))) tmp = d3 * -d1; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -1.8e+133], N[(d1 * d2), $MachinePrecision], If[Or[LessEqual[d2, -2.5e-119], And[N[Not[LessEqual[d2, -2.4e-153]], $MachinePrecision], LessEqual[d2, 1.3e-207]]], N[(d3 * (-d1)), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -1.8 \cdot 10^{+133}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d2 \leq -2.5 \cdot 10^{-119} \lor \neg \left(d2 \leq -2.4 \cdot 10^{-153}\right) \land d2 \leq 1.3 \cdot 10^{-207}:\\
\;\;\;\;d3 \cdot \left(-d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d2 < -1.79999999999999989e133Initial program 90.8%
sub-neg90.8%
associate-+l+90.8%
*-commutative90.8%
+-commutative90.8%
*-commutative90.8%
sub-neg90.8%
+-commutative90.8%
associate--l+90.8%
distribute-lft-out--90.8%
distribute-rgt-out--95.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 d2 around inf 74.4%
if -1.79999999999999989e133 < d2 < -2.49999999999999996e-119 or -2.4000000000000002e-153 < d2 < 1.3e-207Initial program 88.9%
sub-neg88.9%
associate-+l+88.9%
*-commutative88.9%
+-commutative88.9%
*-commutative88.9%
sub-neg88.9%
+-commutative88.9%
associate--l+88.9%
distribute-lft-out--91.4%
distribute-rgt-out--93.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 d3 around inf 53.3%
mul-1-neg53.3%
distribute-rgt-neg-out53.3%
Simplified53.3%
if -2.49999999999999996e-119 < d2 < -2.4000000000000002e-153 or 1.3e-207 < d2 Initial program 86.3%
sub-neg86.3%
associate-+l+86.3%
*-commutative86.3%
+-commutative86.3%
*-commutative86.3%
sub-neg86.3%
+-commutative86.3%
associate--l+86.3%
distribute-lft-out--88.8%
distribute-rgt-out--94.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 inf 33.8%
Final simplification46.2%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (or (<= d3 -2.8e+190) (not (<= d3 4e+92))) (* d1 (- d4 d3)) (* d1 (- (+ d2 d4) d1))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d3 <= -2.8e+190) || !(d3 <= 4e+92)) {
tmp = d1 * (d4 - d3);
} else {
tmp = d1 * ((d2 + d4) - 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 ((d3 <= (-2.8d+190)) .or. (.not. (d3 <= 4d+92))) then
tmp = d1 * (d4 - d3)
else
tmp = d1 * ((d2 + d4) - d1)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d3 <= -2.8e+190) || !(d3 <= 4e+92)) {
tmp = d1 * (d4 - d3);
} else {
tmp = d1 * ((d2 + d4) - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if (d3 <= -2.8e+190) or not (d3 <= 4e+92): tmp = d1 * (d4 - d3) else: tmp = d1 * ((d2 + d4) - d1) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if ((d3 <= -2.8e+190) || !(d3 <= 4e+92)) tmp = Float64(d1 * Float64(d4 - d3)); else tmp = Float64(d1 * Float64(Float64(d2 + d4) - d1)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if ((d3 <= -2.8e+190) || ~((d3 <= 4e+92))) tmp = d1 * (d4 - d3); else tmp = d1 * ((d2 + d4) - d1); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[Or[LessEqual[d3, -2.8e+190], N[Not[LessEqual[d3, 4e+92]], $MachinePrecision]], N[(d1 * N[(d4 - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(N[(d2 + d4), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d3 \leq -2.8 \cdot 10^{+190} \lor \neg \left(d3 \leq 4 \cdot 10^{+92}\right):\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(\left(d2 + d4\right) - d1\right)\\
\end{array}
\end{array}
if d3 < -2.79999999999999997e190 or 4.0000000000000002e92 < d3 Initial program 86.9%
sub-neg86.9%
associate-+l+86.9%
*-commutative86.9%
+-commutative86.9%
*-commutative86.9%
sub-neg86.9%
+-commutative86.9%
associate--l+86.9%
distribute-lft-out--88.1%
distribute-rgt-out--91.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 0 91.7%
+-commutative91.7%
associate--r+91.7%
Simplified91.7%
Taylor expanded in d1 around 0 90.5%
if -2.79999999999999997e190 < d3 < 4.0000000000000002e92Initial program 88.3%
sub-neg88.3%
associate-+l+88.3%
*-commutative88.3%
+-commutative88.3%
*-commutative88.3%
sub-neg88.3%
+-commutative88.3%
associate--l+88.3%
distribute-lft-out--91.3%
distribute-rgt-out--95.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 d3 around 0 90.7%
Final simplification90.7%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 2.2e-221) (* d1 (- d2 d3)) (if (<= d4 1.2e+61) (* d1 (- (- d1) d3)) (* d1 (- d4 d3)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 2.2e-221) {
tmp = d1 * (d2 - d3);
} else if (d4 <= 1.2e+61) {
tmp = d1 * (-d1 - d3);
} 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 <= 2.2d-221) then
tmp = d1 * (d2 - d3)
else if (d4 <= 1.2d+61) then
tmp = d1 * (-d1 - d3)
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 <= 2.2e-221) {
tmp = d1 * (d2 - d3);
} else if (d4 <= 1.2e+61) {
tmp = d1 * (-d1 - d3);
} else {
tmp = d1 * (d4 - d3);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 2.2e-221: tmp = d1 * (d2 - d3) elif d4 <= 1.2e+61: tmp = d1 * (-d1 - d3) else: tmp = d1 * (d4 - d3) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 2.2e-221) tmp = Float64(d1 * Float64(d2 - d3)); elseif (d4 <= 1.2e+61) tmp = Float64(d1 * Float64(Float64(-d1) - d3)); else tmp = Float64(d1 * Float64(d4 - d3)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d4 <= 2.2e-221) tmp = d1 * (d2 - d3); elseif (d4 <= 1.2e+61) tmp = d1 * (-d1 - d3); else tmp = d1 * (d4 - d3); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 2.2e-221], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], If[LessEqual[d4, 1.2e+61], N[(d1 * N[((-d1) - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - d3), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 2.2 \cdot 10^{-221}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{elif}\;d4 \leq 1.2 \cdot 10^{+61}:\\
\;\;\;\;d1 \cdot \left(\left(-d1\right) - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\end{array}
\end{array}
if d4 < 2.20000000000000001e-221Initial program 86.6%
sub-neg86.6%
associate-+l+86.6%
*-commutative86.6%
+-commutative86.6%
*-commutative86.6%
sub-neg86.6%
+-commutative86.6%
associate--l+86.6%
distribute-lft-out--89.4%
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 80.2%
+-commutative80.2%
associate--r+80.2%
Simplified80.2%
Taylor expanded in d1 around 0 61.6%
if 2.20000000000000001e-221 < d4 < 1.1999999999999999e61Initial program 87.3%
sub-neg87.3%
associate-+l+87.3%
*-commutative87.3%
+-commutative87.3%
*-commutative87.3%
sub-neg87.3%
+-commutative87.3%
associate--l+87.3%
distribute-lft-out--87.3%
distribute-rgt-out--95.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 97.0%
+-commutative97.0%
associate--r+97.0%
Simplified97.0%
Taylor expanded in d2 around 0 70.9%
mul-1-neg70.9%
*-commutative70.9%
distribute-rgt-neg-in70.9%
Simplified70.9%
if 1.1999999999999999e61 < d4 Initial program 92.1%
sub-neg92.1%
associate-+l+92.1%
*-commutative92.1%
+-commutative92.1%
*-commutative92.1%
sub-neg92.1%
+-commutative92.1%
associate--l+92.1%
distribute-lft-out--96.0%
distribute-rgt-out--96.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 d2 around 0 81.6%
+-commutative81.6%
associate--r+81.6%
Simplified81.6%
Taylor expanded in d1 around 0 78.9%
Final simplification67.3%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (or (<= d3 -1.8e+182) (not (<= d3 1.06e+105))) (* d3 (- d1)) (* d1 (+ d2 d4))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d3 <= -1.8e+182) || !(d3 <= 1.06e+105)) {
tmp = d3 * -d1;
} 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 <= (-1.8d+182)) .or. (.not. (d3 <= 1.06d+105))) then
tmp = d3 * -d1
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 <= -1.8e+182) || !(d3 <= 1.06e+105)) {
tmp = d3 * -d1;
} else {
tmp = d1 * (d2 + d4);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if (d3 <= -1.8e+182) or not (d3 <= 1.06e+105): tmp = d3 * -d1 else: tmp = d1 * (d2 + d4) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if ((d3 <= -1.8e+182) || !(d3 <= 1.06e+105)) tmp = Float64(d3 * Float64(-d1)); else tmp = Float64(d1 * Float64(d2 + d4)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if ((d3 <= -1.8e+182) || ~((d3 <= 1.06e+105))) tmp = d3 * -d1; else tmp = d1 * (d2 + d4); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[Or[LessEqual[d3, -1.8e+182], N[Not[LessEqual[d3, 1.06e+105]], $MachinePrecision]], N[(d3 * (-d1)), $MachinePrecision], N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d3 \leq -1.8 \cdot 10^{+182} \lor \neg \left(d3 \leq 1.06 \cdot 10^{+105}\right):\\
\;\;\;\;d3 \cdot \left(-d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d2 + d4\right)\\
\end{array}
\end{array}
if d3 < -1.8e182 or 1.06e105 < d3 Initial program 86.2%
sub-neg86.2%
associate-+l+86.2%
*-commutative86.2%
+-commutative86.2%
*-commutative86.2%
sub-neg86.2%
+-commutative86.2%
associate--l+86.2%
distribute-lft-out--87.3%
distribute-rgt-out--90.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 d3 around inf 81.6%
mul-1-neg81.6%
distribute-rgt-neg-out81.6%
Simplified81.6%
if -1.8e182 < d3 < 1.06e105Initial program 88.7%
sub-neg88.7%
associate-+l+88.7%
*-commutative88.7%
+-commutative88.7%
*-commutative88.7%
sub-neg88.7%
+-commutative88.7%
associate--l+88.7%
distribute-lft-out--91.7%
fma-def94.1%
distribute-rgt-out--98.8%
Simplified98.8%
Taylor expanded in d3 around 0 87.6%
Taylor expanded in d1 around 0 68.9%
Final simplification73.2%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 4.5e+90) (* d1 (- (- d2 d3) d1)) (* d1 (- (+ d2 d4) d1))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 4.5e+90) {
tmp = d1 * ((d2 - d3) - d1);
} else {
tmp = d1 * ((d2 + d4) - 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 (d4 <= 4.5d+90) then
tmp = d1 * ((d2 - d3) - d1)
else
tmp = d1 * ((d2 + d4) - d1)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 4.5e+90) {
tmp = d1 * ((d2 - d3) - d1);
} else {
tmp = d1 * ((d2 + d4) - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 4.5e+90: tmp = d1 * ((d2 - d3) - d1) else: tmp = d1 * ((d2 + d4) - d1) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 4.5e+90) tmp = Float64(d1 * Float64(Float64(d2 - d3) - d1)); else tmp = Float64(d1 * Float64(Float64(d2 + d4) - d1)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d4 <= 4.5e+90) tmp = d1 * ((d2 - d3) - d1); else tmp = d1 * ((d2 + d4) - d1); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 4.5e+90], N[(d1 * N[(N[(d2 - d3), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(N[(d2 + d4), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 4.5 \cdot 10^{+90}:\\
\;\;\;\;d1 \cdot \left(\left(d2 - d3\right) - d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(\left(d2 + d4\right) - d1\right)\\
\end{array}
\end{array}
if d4 < 4.5e90Initial program 87.1%
sub-neg87.1%
associate-+l+87.1%
*-commutative87.1%
+-commutative87.1%
*-commutative87.1%
sub-neg87.1%
+-commutative87.1%
associate--l+87.1%
distribute-lft-out--89.0%
distribute-rgt-out--93.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 85.4%
+-commutative85.4%
associate--r+85.4%
Simplified85.4%
if 4.5e90 < d4 Initial program 92.1%
sub-neg92.1%
associate-+l+92.1%
*-commutative92.1%
+-commutative92.1%
*-commutative92.1%
sub-neg92.1%
+-commutative92.1%
associate--l+92.1%
distribute-lft-out--97.3%
distribute-rgt-out--97.3%
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 0 92.4%
Final simplification86.4%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 8.4e+37) (* d1 (- (- d2 d3) d1)) (* d1 (- (- d4 d3) d1))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 8.4e+37) {
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 (d4 <= 8.4d+37) 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 (d4 <= 8.4e+37) {
tmp = d1 * ((d2 - d3) - d1);
} else {
tmp = d1 * ((d4 - d3) - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 8.4e+37: tmp = d1 * ((d2 - d3) - d1) else: tmp = d1 * ((d4 - d3) - d1) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 8.4e+37) 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 (d4 <= 8.4e+37) tmp = d1 * ((d2 - d3) - d1); else tmp = d1 * ((d4 - d3) - d1); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 8.4e+37], 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}\;d4 \leq 8.4 \cdot 10^{+37}:\\
\;\;\;\;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 d4 < 8.4000000000000004e37Initial program 86.7%
sub-neg86.7%
associate-+l+86.7%
*-commutative86.7%
+-commutative86.7%
*-commutative86.7%
sub-neg86.7%
+-commutative86.7%
associate--l+86.7%
distribute-lft-out--88.7%
distribute-rgt-out--93.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 85.8%
+-commutative85.8%
associate--r+85.8%
Simplified85.8%
if 8.4000000000000004e37 < d4 Initial program 92.2%
sub-neg92.2%
associate-+l+92.2%
*-commutative92.2%
+-commutative92.2%
*-commutative92.2%
sub-neg92.2%
+-commutative92.2%
associate--l+92.2%
distribute-lft-out--96.1%
distribute-rgt-out--96.1%
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 d2 around 0 81.9%
+-commutative81.9%
associate--r+81.9%
Simplified81.9%
Final simplification85.0%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 1.8e+91) (* d1 (- d2 d3)) (* d1 (+ d2 d4))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 1.8e+91) {
tmp = d1 * (d2 - 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 (d4 <= 1.8d+91) then
tmp = d1 * (d2 - 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 (d4 <= 1.8e+91) {
tmp = d1 * (d2 - d3);
} else {
tmp = d1 * (d2 + d4);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 1.8e+91: tmp = d1 * (d2 - d3) else: tmp = d1 * (d2 + d4) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 1.8e+91) tmp = Float64(d1 * Float64(d2 - d3)); else tmp = Float64(d1 * Float64(d2 + d4)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d4 <= 1.8e+91) tmp = d1 * (d2 - d3); else tmp = d1 * (d2 + d4); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 1.8e+91], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 1.8 \cdot 10^{+91}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d2 + d4\right)\\
\end{array}
\end{array}
if d4 < 1.8e91Initial program 87.1%
sub-neg87.1%
associate-+l+87.1%
*-commutative87.1%
+-commutative87.1%
*-commutative87.1%
sub-neg87.1%
+-commutative87.1%
associate--l+87.1%
distribute-lft-out--89.0%
distribute-rgt-out--93.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 85.4%
+-commutative85.4%
associate--r+85.4%
Simplified85.4%
Taylor expanded in d1 around 0 66.1%
if 1.8e91 < d4 Initial program 92.1%
sub-neg92.1%
associate-+l+92.1%
*-commutative92.1%
+-commutative92.1%
*-commutative92.1%
sub-neg92.1%
+-commutative92.1%
associate--l+92.1%
distribute-lft-out--97.3%
fma-def97.3%
distribute-rgt-out--97.3%
Simplified97.3%
Taylor expanded in d3 around 0 89.8%
Taylor expanded in d1 around 0 92.4%
Final simplification70.0%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 1.05e+66) (* d1 (- d2 d3)) (* d1 (- d4 d3))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 1.05e+66) {
tmp = d1 * (d2 - d3);
} 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.05d+66) then
tmp = d1 * (d2 - d3)
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.05e+66) {
tmp = d1 * (d2 - d3);
} else {
tmp = d1 * (d4 - d3);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 1.05e+66: tmp = d1 * (d2 - d3) else: tmp = d1 * (d4 - d3) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 1.05e+66) tmp = Float64(d1 * Float64(d2 - d3)); 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.05e+66) tmp = d1 * (d2 - d3); else tmp = d1 * (d4 - d3); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 1.05e+66], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - d3), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 1.05 \cdot 10^{+66}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\end{array}
\end{array}
if d4 < 1.05000000000000003e66Initial program 86.9%
sub-neg86.9%
associate-+l+86.9%
*-commutative86.9%
+-commutative86.9%
*-commutative86.9%
sub-neg86.9%
+-commutative86.9%
associate--l+86.9%
distribute-lft-out--88.8%
distribute-rgt-out--93.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 85.5%
+-commutative85.5%
associate--r+85.5%
Simplified85.5%
Taylor expanded in d1 around 0 65.1%
if 1.05000000000000003e66 < d4 Initial program 91.9%
sub-neg91.9%
associate-+l+91.9%
*-commutative91.9%
+-commutative91.9%
*-commutative91.9%
sub-neg91.9%
+-commutative91.9%
associate--l+91.9%
distribute-lft-out--95.9%
distribute-rgt-out--95.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 d2 around 0 83.1%
+-commutative83.1%
associate--r+83.1%
Simplified83.1%
Taylor expanded in d1 around 0 80.4%
Final simplification68.1%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 1.22e+67) (* d1 d2) (* d1 d4)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 1.22e+67) {
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 (d4 <= 1.22d+67) 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 (d4 <= 1.22e+67) {
tmp = d1 * d2;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 1.22e+67: tmp = d1 * d2 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 1.22e+67) 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 (d4 <= 1.22e+67) tmp = d1 * d2; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 1.22e+67], N[(d1 * d2), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 1.22 \cdot 10^{+67}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d4 < 1.22000000000000004e67Initial program 86.9%
sub-neg86.9%
associate-+l+86.9%
*-commutative86.9%
+-commutative86.9%
*-commutative86.9%
sub-neg86.9%
+-commutative86.9%
associate--l+86.9%
distribute-lft-out--88.9%
distribute-rgt-out--93.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 d2 around inf 31.9%
if 1.22000000000000004e67 < d4 Initial 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--95.8%
distribute-rgt-out--95.8%
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 d4 around inf 62.4%
Final simplification37.7%
(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 87.9%
sub-neg87.9%
associate-+l+87.9%
*-commutative87.9%
+-commutative87.9%
*-commutative87.9%
sub-neg87.9%
+-commutative87.9%
associate--l+87.9%
distribute-lft-out--90.2%
distribute-rgt-out--94.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 30.6%
Final simplification30.6%
(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 2024019
(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)))