
(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 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(d2 - d3) + Float64(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[(d2 - d3), $MachinePrecision] + N[(d4 - d1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
d1 \cdot \left(\left(d2 - d3\right) + \left(d4 - d1\right)\right)
\end{array}
Initial program 86.3%
associate--l+86.3%
distribute-lft-out--87.1%
distribute-rgt-out--90.2%
distribute-lft-out100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (d1 d2 d3 d4)
:precision binary64
(let* ((t_0 (* d1 (- d2 d1))) (t_1 (* d1 (- (- d1) d3))))
(if (<= d4 -1.12e-132)
t_0
(if (<= d4 -8.2e-253)
t_1
(if (<= d4 2.75e-105)
t_0
(if (<= d4 1.15e+79) t_1 (* d1 (- d4 d3))))))))
double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * (d2 - d1);
double t_1 = d1 * (-d1 - d3);
double tmp;
if (d4 <= -1.12e-132) {
tmp = t_0;
} else if (d4 <= -8.2e-253) {
tmp = t_1;
} else if (d4 <= 2.75e-105) {
tmp = t_0;
} else if (d4 <= 1.15e+79) {
tmp = t_1;
} 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) :: t_1
real(8) :: tmp
t_0 = d1 * (d2 - d1)
t_1 = d1 * (-d1 - d3)
if (d4 <= (-1.12d-132)) then
tmp = t_0
else if (d4 <= (-8.2d-253)) then
tmp = t_1
else if (d4 <= 2.75d-105) then
tmp = t_0
else if (d4 <= 1.15d+79) then
tmp = t_1
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 - d1);
double t_1 = d1 * (-d1 - d3);
double tmp;
if (d4 <= -1.12e-132) {
tmp = t_0;
} else if (d4 <= -8.2e-253) {
tmp = t_1;
} else if (d4 <= 2.75e-105) {
tmp = t_0;
} else if (d4 <= 1.15e+79) {
tmp = t_1;
} else {
tmp = d1 * (d4 - d3);
}
return tmp;
}
def code(d1, d2, d3, d4): t_0 = d1 * (d2 - d1) t_1 = d1 * (-d1 - d3) tmp = 0 if d4 <= -1.12e-132: tmp = t_0 elif d4 <= -8.2e-253: tmp = t_1 elif d4 <= 2.75e-105: tmp = t_0 elif d4 <= 1.15e+79: tmp = t_1 else: tmp = d1 * (d4 - d3) return tmp
function code(d1, d2, d3, d4) t_0 = Float64(d1 * Float64(d2 - d1)) t_1 = Float64(d1 * Float64(Float64(-d1) - d3)) tmp = 0.0 if (d4 <= -1.12e-132) tmp = t_0; elseif (d4 <= -8.2e-253) tmp = t_1; elseif (d4 <= 2.75e-105) tmp = t_0; elseif (d4 <= 1.15e+79) tmp = t_1; else tmp = Float64(d1 * Float64(d4 - d3)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) t_0 = d1 * (d2 - d1); t_1 = d1 * (-d1 - d3); tmp = 0.0; if (d4 <= -1.12e-132) tmp = t_0; elseif (d4 <= -8.2e-253) tmp = t_1; elseif (d4 <= 2.75e-105) tmp = t_0; elseif (d4 <= 1.15e+79) tmp = t_1; else tmp = d1 * (d4 - d3); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := Block[{t$95$0 = N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(d1 * N[((-d1) - d3), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d4, -1.12e-132], t$95$0, If[LessEqual[d4, -8.2e-253], t$95$1, If[LessEqual[d4, 2.75e-105], t$95$0, If[LessEqual[d4, 1.15e+79], t$95$1, N[(d1 * N[(d4 - d3), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := d1 \cdot \left(d2 - d1\right)\\
t_1 := d1 \cdot \left(\left(-d1\right) - d3\right)\\
\mathbf{if}\;d4 \leq -1.12 \cdot 10^{-132}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d4 \leq -8.2 \cdot 10^{-253}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;d4 \leq 2.75 \cdot 10^{-105}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d4 \leq 1.15 \cdot 10^{+79}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\end{array}
\end{array}
if d4 < -1.1199999999999999e-132 or -8.20000000000000004e-253 < d4 < 2.75000000000000015e-105Initial program 90.8%
associate--l+90.8%
distribute-lft-out--91.5%
distribute-rgt-out--91.5%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 80.0%
Taylor expanded in d4 around 0 61.0%
if -1.1199999999999999e-132 < d4 < -8.20000000000000004e-253 or 2.75000000000000015e-105 < d4 < 1.15e79Initial program 86.5%
associate--l+86.5%
distribute-lft-out--86.5%
distribute-rgt-out--89.5%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around 0 73.8%
+-commutative73.8%
associate--r+73.8%
Simplified73.8%
Taylor expanded in d4 around 0 69.8%
associate-*r*69.8%
neg-mul-169.8%
Simplified69.8%
if 1.15e79 < d4 Initial program 72.3%
associate--l+72.3%
distribute-lft-out--74.4%
distribute-rgt-out--87.2%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around 0 84.4%
+-commutative84.4%
associate--r+84.4%
Simplified84.4%
Taylor expanded in d1 around 0 73.7%
Final simplification65.6%
(FPCore (d1 d2 d3 d4)
:precision binary64
(let* ((t_0 (* d1 (- d3))) (t_1 (* d1 (+ d2 d4))))
(if (<= d3 -6e+138)
t_0
(if (<= d3 -1.25e-286)
t_1
(if (<= d3 6.8e-275) (* d1 (- d1)) (if (<= d3 5e+198) t_1 t_0))))))
double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * -d3;
double t_1 = d1 * (d2 + d4);
double tmp;
if (d3 <= -6e+138) {
tmp = t_0;
} else if (d3 <= -1.25e-286) {
tmp = t_1;
} else if (d3 <= 6.8e-275) {
tmp = d1 * -d1;
} else if (d3 <= 5e+198) {
tmp = t_1;
} 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) :: t_1
real(8) :: tmp
t_0 = d1 * -d3
t_1 = d1 * (d2 + d4)
if (d3 <= (-6d+138)) then
tmp = t_0
else if (d3 <= (-1.25d-286)) then
tmp = t_1
else if (d3 <= 6.8d-275) then
tmp = d1 * -d1
else if (d3 <= 5d+198) then
tmp = t_1
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 t_1 = d1 * (d2 + d4);
double tmp;
if (d3 <= -6e+138) {
tmp = t_0;
} else if (d3 <= -1.25e-286) {
tmp = t_1;
} else if (d3 <= 6.8e-275) {
tmp = d1 * -d1;
} else if (d3 <= 5e+198) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(d1, d2, d3, d4): t_0 = d1 * -d3 t_1 = d1 * (d2 + d4) tmp = 0 if d3 <= -6e+138: tmp = t_0 elif d3 <= -1.25e-286: tmp = t_1 elif d3 <= 6.8e-275: tmp = d1 * -d1 elif d3 <= 5e+198: tmp = t_1 else: tmp = t_0 return tmp
function code(d1, d2, d3, d4) t_0 = Float64(d1 * Float64(-d3)) t_1 = Float64(d1 * Float64(d2 + d4)) tmp = 0.0 if (d3 <= -6e+138) tmp = t_0; elseif (d3 <= -1.25e-286) tmp = t_1; elseif (d3 <= 6.8e-275) tmp = Float64(d1 * Float64(-d1)); elseif (d3 <= 5e+198) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(d1, d2, d3, d4) t_0 = d1 * -d3; t_1 = d1 * (d2 + d4); tmp = 0.0; if (d3 <= -6e+138) tmp = t_0; elseif (d3 <= -1.25e-286) tmp = t_1; elseif (d3 <= 6.8e-275) tmp = d1 * -d1; elseif (d3 <= 5e+198) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := Block[{t$95$0 = N[(d1 * (-d3)), $MachinePrecision]}, Block[{t$95$1 = N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d3, -6e+138], t$95$0, If[LessEqual[d3, -1.25e-286], t$95$1, If[LessEqual[d3, 6.8e-275], N[(d1 * (-d1)), $MachinePrecision], If[LessEqual[d3, 5e+198], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := d1 \cdot \left(-d3\right)\\
t_1 := d1 \cdot \left(d2 + d4\right)\\
\mathbf{if}\;d3 \leq -6 \cdot 10^{+138}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d3 \leq -1.25 \cdot 10^{-286}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;d3 \leq 6.8 \cdot 10^{-275}:\\
\;\;\;\;d1 \cdot \left(-d1\right)\\
\mathbf{elif}\;d3 \leq 5 \cdot 10^{+198}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d3 < -6.0000000000000002e138 or 5.00000000000000049e198 < d3 Initial program 80.0%
associate--l+80.0%
distribute-lft-out--84.0%
distribute-rgt-out--86.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around inf 84.9%
mul-1-neg84.9%
distribute-rgt-neg-out84.9%
Simplified84.9%
if -6.0000000000000002e138 < d3 < -1.25000000000000009e-286 or 6.79999999999999936e-275 < d3 < 5.00000000000000049e198Initial program 88.0%
associate--l+88.0%
distribute-lft-out--88.0%
distribute-rgt-out--91.6%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 90.3%
Taylor expanded in d1 around 0 67.4%
+-commutative67.4%
Simplified67.4%
if -1.25000000000000009e-286 < d3 < 6.79999999999999936e-275Initial program 85.7%
associate--l+85.7%
distribute-lft-out--85.7%
distribute-rgt-out--85.7%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around 0 86.4%
+-commutative86.4%
associate--r+86.4%
Simplified86.4%
Taylor expanded in d1 around inf 79.6%
neg-mul-179.6%
Simplified79.6%
Final simplification71.5%
(FPCore (d1 d2 d3 d4)
:precision binary64
(if (<= d4 -8e-131)
(* d1 d2)
(if (<= d4 -1.95e-252)
(* d1 (- d3))
(if (<= d4 1.12e-178)
(* d1 d2)
(if (<= d4 1.7e+75) (* d1 (- d1)) (* d1 d4))))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= -8e-131) {
tmp = d1 * d2;
} else if (d4 <= -1.95e-252) {
tmp = d1 * -d3;
} else if (d4 <= 1.12e-178) {
tmp = d1 * d2;
} else if (d4 <= 1.7e+75) {
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 (d4 <= (-8d-131)) then
tmp = d1 * d2
else if (d4 <= (-1.95d-252)) then
tmp = d1 * -d3
else if (d4 <= 1.12d-178) then
tmp = d1 * d2
else if (d4 <= 1.7d+75) 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 (d4 <= -8e-131) {
tmp = d1 * d2;
} else if (d4 <= -1.95e-252) {
tmp = d1 * -d3;
} else if (d4 <= 1.12e-178) {
tmp = d1 * d2;
} else if (d4 <= 1.7e+75) {
tmp = d1 * -d1;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= -8e-131: tmp = d1 * d2 elif d4 <= -1.95e-252: tmp = d1 * -d3 elif d4 <= 1.12e-178: tmp = d1 * d2 elif d4 <= 1.7e+75: tmp = d1 * -d1 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= -8e-131) tmp = Float64(d1 * d2); elseif (d4 <= -1.95e-252) tmp = Float64(d1 * Float64(-d3)); elseif (d4 <= 1.12e-178) tmp = Float64(d1 * d2); elseif (d4 <= 1.7e+75) 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 (d4 <= -8e-131) tmp = d1 * d2; elseif (d4 <= -1.95e-252) tmp = d1 * -d3; elseif (d4 <= 1.12e-178) tmp = d1 * d2; elseif (d4 <= 1.7e+75) tmp = d1 * -d1; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, -8e-131], N[(d1 * d2), $MachinePrecision], If[LessEqual[d4, -1.95e-252], N[(d1 * (-d3)), $MachinePrecision], If[LessEqual[d4, 1.12e-178], N[(d1 * d2), $MachinePrecision], If[LessEqual[d4, 1.7e+75], N[(d1 * (-d1)), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq -8 \cdot 10^{-131}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d4 \leq -1.95 \cdot 10^{-252}:\\
\;\;\;\;d1 \cdot \left(-d3\right)\\
\mathbf{elif}\;d4 \leq 1.12 \cdot 10^{-178}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d4 \leq 1.7 \cdot 10^{+75}:\\
\;\;\;\;d1 \cdot \left(-d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d4 < -7.9999999999999999e-131 or -1.9499999999999999e-252 < d4 < 1.12e-178Initial program 92.0%
associate--l+92.0%
distribute-lft-out--92.0%
distribute-rgt-out--92.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around inf 35.9%
if -7.9999999999999999e-131 < d4 < -1.9499999999999999e-252Initial program 89.3%
associate--l+89.3%
distribute-lft-out--89.2%
distribute-rgt-out--89.2%
distribute-lft-out99.9%
Simplified99.9%
Taylor expanded in d3 around inf 38.5%
mul-1-neg38.5%
distribute-rgt-neg-out38.5%
Simplified38.5%
if 1.12e-178 < d4 < 1.70000000000000006e75Initial program 83.9%
associate--l+83.9%
distribute-lft-out--85.7%
distribute-rgt-out--89.2%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around 0 74.2%
+-commutative74.2%
associate--r+74.2%
Simplified74.2%
Taylor expanded in d1 around inf 51.1%
neg-mul-151.1%
Simplified51.1%
if 1.70000000000000006e75 < d4 Initial program 72.3%
associate--l+72.3%
distribute-lft-out--74.4%
distribute-rgt-out--87.2%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around inf 66.2%
Final simplification45.1%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (or (<= d3 -8.2e+113) (not (<= d3 5e+198))) (* d1 (- d4 d3)) (* d1 (- (+ d2 d4) d1))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d3 <= -8.2e+113) || !(d3 <= 5e+198)) {
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 <= (-8.2d+113)) .or. (.not. (d3 <= 5d+198))) 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 <= -8.2e+113) || !(d3 <= 5e+198)) {
tmp = d1 * (d4 - d3);
} else {
tmp = d1 * ((d2 + d4) - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if (d3 <= -8.2e+113) or not (d3 <= 5e+198): tmp = d1 * (d4 - d3) else: tmp = d1 * ((d2 + d4) - d1) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if ((d3 <= -8.2e+113) || !(d3 <= 5e+198)) 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 <= -8.2e+113) || ~((d3 <= 5e+198))) tmp = d1 * (d4 - d3); else tmp = d1 * ((d2 + d4) - d1); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[Or[LessEqual[d3, -8.2e+113], N[Not[LessEqual[d3, 5e+198]], $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 -8.2 \cdot 10^{+113} \lor \neg \left(d3 \leq 5 \cdot 10^{+198}\right):\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(\left(d2 + d4\right) - d1\right)\\
\end{array}
\end{array}
if d3 < -8.19999999999999985e113 or 5.00000000000000049e198 < d3 Initial program 81.5%
associate--l+81.5%
distribute-lft-out--85.2%
distribute-rgt-out--87.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around 0 91.5%
+-commutative91.5%
associate--r+91.5%
Simplified91.5%
Taylor expanded in d1 around 0 89.7%
if -8.19999999999999985e113 < d3 < 5.00000000000000049e198Initial program 87.6%
associate--l+87.6%
distribute-lft-out--87.6%
distribute-rgt-out--91.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 91.5%
Final simplification91.1%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 1.65e-178) (* d1 d2) (if (<= d4 1.35e+79) (* d1 (- d1)) (* d1 d4))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 1.65e-178) {
tmp = d1 * d2;
} else if (d4 <= 1.35e+79) {
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 (d4 <= 1.65d-178) then
tmp = d1 * d2
else if (d4 <= 1.35d+79) 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 (d4 <= 1.65e-178) {
tmp = d1 * d2;
} else if (d4 <= 1.35e+79) {
tmp = d1 * -d1;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 1.65e-178: tmp = d1 * d2 elif d4 <= 1.35e+79: tmp = d1 * -d1 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 1.65e-178) tmp = Float64(d1 * d2); elseif (d4 <= 1.35e+79) 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 (d4 <= 1.65e-178) tmp = d1 * d2; elseif (d4 <= 1.35e+79) tmp = d1 * -d1; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 1.65e-178], N[(d1 * d2), $MachinePrecision], If[LessEqual[d4, 1.35e+79], N[(d1 * (-d1)), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 1.65 \cdot 10^{-178}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d4 \leq 1.35 \cdot 10^{+79}:\\
\;\;\;\;d1 \cdot \left(-d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d4 < 1.6500000000000001e-178Initial program 91.5%
associate--l+91.5%
distribute-lft-out--91.5%
distribute-rgt-out--91.5%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around inf 36.6%
if 1.6500000000000001e-178 < d4 < 1.35e79Initial program 83.9%
associate--l+83.9%
distribute-lft-out--85.7%
distribute-rgt-out--89.2%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around 0 74.2%
+-commutative74.2%
associate--r+74.2%
Simplified74.2%
Taylor expanded in d1 around inf 51.1%
neg-mul-151.1%
Simplified51.1%
if 1.35e79 < d4 Initial program 72.3%
associate--l+72.3%
distribute-lft-out--74.4%
distribute-rgt-out--87.2%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around inf 66.2%
Final simplification45.2%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 1.6e+42) (* d1 (- (- d2 d3) d1)) (* d1 (- (+ d2 d4) d1))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 1.6e+42) {
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 <= 1.6d+42) 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 <= 1.6e+42) {
tmp = d1 * ((d2 - d3) - d1);
} else {
tmp = d1 * ((d2 + d4) - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 1.6e+42: tmp = d1 * ((d2 - d3) - d1) else: tmp = d1 * ((d2 + d4) - d1) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 1.6e+42) 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 <= 1.6e+42) tmp = d1 * ((d2 - d3) - d1); else tmp = d1 * ((d2 + d4) - d1); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 1.6e+42], 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 1.6 \cdot 10^{+42}:\\
\;\;\;\;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 < 1.60000000000000001e42Initial program 89.8%
associate--l+89.8%
distribute-lft-out--90.3%
distribute-rgt-out--90.8%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around 0 86.1%
+-commutative86.1%
associate--r+86.1%
Simplified86.1%
if 1.60000000000000001e42 < d4 Initial program 71.4%
associate--l+71.4%
distribute-lft-out--73.4%
distribute-rgt-out--87.7%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 89.9%
Final simplification86.8%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 1.36e-52) (* d1 (- (- d2 d3) d1)) (* d1 (- (- d4 d3) d1))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 1.36e-52) {
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 <= 1.36d-52) 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 <= 1.36e-52) {
tmp = d1 * ((d2 - d3) - d1);
} else {
tmp = d1 * ((d4 - d3) - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 1.36e-52: tmp = d1 * ((d2 - d3) - d1) else: tmp = d1 * ((d4 - d3) - d1) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 1.36e-52) 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 <= 1.36e-52) tmp = d1 * ((d2 - d3) - d1); else tmp = d1 * ((d4 - d3) - d1); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 1.36e-52], 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 1.36 \cdot 10^{-52}:\\
\;\;\;\;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 < 1.36e-52Initial program 90.6%
associate--l+90.6%
distribute-lft-out--91.1%
distribute-rgt-out--91.1%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around 0 85.0%
+-commutative85.0%
associate--r+85.0%
Simplified85.0%
if 1.36e-52 < d4 Initial program 76.0%
associate--l+76.0%
distribute-lft-out--77.3%
distribute-rgt-out--88.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around 0 86.3%
+-commutative86.3%
associate--r+86.3%
Simplified86.3%
Final simplification85.4%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 3e+75) (* d1 (- d2 d1)) (* d1 (+ d2 d4))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 3e+75) {
tmp = d1 * (d2 - 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 (d4 <= 3d+75) then
tmp = d1 * (d2 - 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 (d4 <= 3e+75) {
tmp = d1 * (d2 - d1);
} else {
tmp = d1 * (d2 + d4);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 3e+75: tmp = d1 * (d2 - d1) else: tmp = d1 * (d2 + d4) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 3e+75) tmp = Float64(d1 * Float64(d2 - d1)); else tmp = Float64(d1 * Float64(d2 + d4)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d4 <= 3e+75) tmp = d1 * (d2 - d1); else tmp = d1 * (d2 + d4); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 3e+75], N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 3 \cdot 10^{+75}:\\
\;\;\;\;d1 \cdot \left(d2 - d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d2 + d4\right)\\
\end{array}
\end{array}
if d4 < 3e75Initial program 89.5%
associate--l+89.5%
distribute-lft-out--89.9%
distribute-rgt-out--90.9%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 77.8%
Taylor expanded in d4 around 0 64.0%
if 3e75 < d4 Initial program 72.3%
associate--l+72.3%
distribute-lft-out--74.4%
distribute-rgt-out--87.2%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 89.4%
Taylor expanded in d1 around 0 80.9%
+-commutative80.9%
Simplified80.9%
Final simplification67.1%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 6.2e-11) (* d1 (- d2 d1)) (* d1 (- d4 d1))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 6.2e-11) {
tmp = d1 * (d2 - d1);
} else {
tmp = d1 * (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 <= 6.2d-11) then
tmp = d1 * (d2 - d1)
else
tmp = d1 * (d4 - d1)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 6.2e-11) {
tmp = d1 * (d2 - d1);
} else {
tmp = d1 * (d4 - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 6.2e-11: tmp = d1 * (d2 - d1) else: tmp = d1 * (d4 - d1) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 6.2e-11) tmp = Float64(d1 * Float64(d2 - d1)); else tmp = Float64(d1 * Float64(d4 - d1)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d4 <= 6.2e-11) tmp = d1 * (d2 - d1); else tmp = d1 * (d4 - d1); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 6.2e-11], N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 6.2 \cdot 10^{-11}:\\
\;\;\;\;d1 \cdot \left(d2 - d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d1\right)\\
\end{array}
\end{array}
if d4 < 6.20000000000000056e-11Initial program 89.8%
associate--l+89.8%
distribute-lft-out--90.3%
distribute-rgt-out--90.3%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 77.5%
Taylor expanded in d4 around 0 63.7%
if 6.20000000000000056e-11 < d4 Initial program 74.6%
associate--l+74.6%
distribute-lft-out--76.2%
distribute-rgt-out--89.8%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around 0 85.9%
+-commutative85.9%
associate--r+85.9%
Simplified85.9%
Taylor expanded in d3 around 0 74.9%
Final simplification66.3%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 1.05e+54) (* d1 d2) (* d1 d4)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 1.05e+54) {
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.05d+54) 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.05e+54) {
tmp = d1 * d2;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 1.05e+54: tmp = d1 * d2 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 1.05e+54) 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.05e+54) tmp = d1 * d2; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 1.05e+54], N[(d1 * d2), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 1.05 \cdot 10^{+54}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d4 < 1.04999999999999993e54Initial program 89.8%
associate--l+89.8%
distribute-lft-out--90.3%
distribute-rgt-out--90.8%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around inf 38.1%
if 1.04999999999999993e54 < d4 Initial program 71.4%
associate--l+71.4%
distribute-lft-out--73.4%
distribute-rgt-out--87.7%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around inf 65.5%
Final simplification43.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 86.3%
associate--l+86.3%
distribute-lft-out--87.1%
distribute-rgt-out--90.2%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around inf 34.9%
Final simplification34.9%
(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 2024076
(FPCore (d1 d2 d3 d4)
:name "FastMath dist4"
:precision binary64
:alt
(* d1 (- (+ (- d2 d3) d4) d1))
(- (+ (- (* d1 d2) (* d1 d3)) (* d4 d1)) (* d1 d1)))