
(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 11 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--88.7%
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 (- d1))) (t_1 (* d1 (+ d2 d4))))
(if (<= d1 -2.45e+154)
t_0
(if (<= d1 2.2e-262)
t_1
(if (<= d1 6e-208) (* d1 (- d3)) (if (<= d1 6.8e+140) t_1 t_0))))))
double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * -d1;
double t_1 = d1 * (d2 + d4);
double tmp;
if (d1 <= -2.45e+154) {
tmp = t_0;
} else if (d1 <= 2.2e-262) {
tmp = t_1;
} else if (d1 <= 6e-208) {
tmp = d1 * -d3;
} else if (d1 <= 6.8e+140) {
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 * -d1
t_1 = d1 * (d2 + d4)
if (d1 <= (-2.45d+154)) then
tmp = t_0
else if (d1 <= 2.2d-262) then
tmp = t_1
else if (d1 <= 6d-208) then
tmp = d1 * -d3
else if (d1 <= 6.8d+140) 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 * -d1;
double t_1 = d1 * (d2 + d4);
double tmp;
if (d1 <= -2.45e+154) {
tmp = t_0;
} else if (d1 <= 2.2e-262) {
tmp = t_1;
} else if (d1 <= 6e-208) {
tmp = d1 * -d3;
} else if (d1 <= 6.8e+140) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(d1, d2, d3, d4): t_0 = d1 * -d1 t_1 = d1 * (d2 + d4) tmp = 0 if d1 <= -2.45e+154: tmp = t_0 elif d1 <= 2.2e-262: tmp = t_1 elif d1 <= 6e-208: tmp = d1 * -d3 elif d1 <= 6.8e+140: tmp = t_1 else: tmp = t_0 return tmp
function code(d1, d2, d3, d4) t_0 = Float64(d1 * Float64(-d1)) t_1 = Float64(d1 * Float64(d2 + d4)) tmp = 0.0 if (d1 <= -2.45e+154) tmp = t_0; elseif (d1 <= 2.2e-262) tmp = t_1; elseif (d1 <= 6e-208) tmp = Float64(d1 * Float64(-d3)); elseif (d1 <= 6.8e+140) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(d1, d2, d3, d4) t_0 = d1 * -d1; t_1 = d1 * (d2 + d4); tmp = 0.0; if (d1 <= -2.45e+154) tmp = t_0; elseif (d1 <= 2.2e-262) tmp = t_1; elseif (d1 <= 6e-208) tmp = d1 * -d3; elseif (d1 <= 6.8e+140) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := Block[{t$95$0 = N[(d1 * (-d1)), $MachinePrecision]}, Block[{t$95$1 = N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d1, -2.45e+154], t$95$0, If[LessEqual[d1, 2.2e-262], t$95$1, If[LessEqual[d1, 6e-208], N[(d1 * (-d3)), $MachinePrecision], If[LessEqual[d1, 6.8e+140], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := d1 \cdot \left(-d1\right)\\
t_1 := d1 \cdot \left(d2 + d4\right)\\
\mathbf{if}\;d1 \leq -2.45 \cdot 10^{+154}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d1 \leq 2.2 \cdot 10^{-262}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d1 \leq 6 \cdot 10^{-208}:\\
\;\;\;\;d1 \cdot \left(-d3\right)\\
\mathbf{elif}\;d1 \leq 6.8 \cdot 10^{+140}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if d1 < -2.4500000000000001e154 or 6.8e140 < d1 Initial program 51.5%
associate--l+51.5%
distribute-lft-out--57.6%
distribute-rgt-out--63.6%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around inf 85.2%
unpow285.2%
mul-1-neg85.2%
distribute-rgt-neg-out85.2%
Simplified85.2%
if -2.4500000000000001e154 < d1 < 2.19999999999999989e-262 or 5.99999999999999972e-208 < d1 < 6.8e140Initial program 98.3%
associate--l+98.3%
distribute-lft-out--99.4%
distribute-rgt-out--99.4%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 76.7%
Taylor expanded in d1 around 0 69.6%
if 2.19999999999999989e-262 < d1 < 5.99999999999999972e-208Initial program 100.0%
associate--l+100.0%
distribute-lft-out--100.0%
distribute-rgt-out--100.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around inf 78.4%
associate-*r*78.4%
neg-mul-178.4%
Simplified78.4%
Final simplification73.9%
(FPCore (d1 d2 d3 d4)
:precision binary64
(let* ((t_0 (* d1 (- d1))))
(if (<= d4 1.02e-245)
(* d1 d2)
(if (<= d4 5.4e-136)
t_0
(if (<= d4 2.15e-21) (* d1 d2) (if (<= d4 1.4e+41) t_0 (* d1 d4)))))))
double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * -d1;
double tmp;
if (d4 <= 1.02e-245) {
tmp = d1 * d2;
} else if (d4 <= 5.4e-136) {
tmp = t_0;
} else if (d4 <= 2.15e-21) {
tmp = d1 * d2;
} else if (d4 <= 1.4e+41) {
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) :: tmp
t_0 = d1 * -d1
if (d4 <= 1.02d-245) then
tmp = d1 * d2
else if (d4 <= 5.4d-136) then
tmp = t_0
else if (d4 <= 2.15d-21) then
tmp = d1 * d2
else if (d4 <= 1.4d+41) 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 tmp;
if (d4 <= 1.02e-245) {
tmp = d1 * d2;
} else if (d4 <= 5.4e-136) {
tmp = t_0;
} else if (d4 <= 2.15e-21) {
tmp = d1 * d2;
} else if (d4 <= 1.4e+41) {
tmp = t_0;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): t_0 = d1 * -d1 tmp = 0 if d4 <= 1.02e-245: tmp = d1 * d2 elif d4 <= 5.4e-136: tmp = t_0 elif d4 <= 2.15e-21: tmp = d1 * d2 elif d4 <= 1.4e+41: tmp = t_0 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) t_0 = Float64(d1 * Float64(-d1)) tmp = 0.0 if (d4 <= 1.02e-245) tmp = Float64(d1 * d2); elseif (d4 <= 5.4e-136) tmp = t_0; elseif (d4 <= 2.15e-21) tmp = Float64(d1 * d2); elseif (d4 <= 1.4e+41) tmp = t_0; else tmp = Float64(d1 * d4); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) t_0 = d1 * -d1; tmp = 0.0; if (d4 <= 1.02e-245) tmp = d1 * d2; elseif (d4 <= 5.4e-136) tmp = t_0; elseif (d4 <= 2.15e-21) tmp = d1 * d2; elseif (d4 <= 1.4e+41) 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]}, If[LessEqual[d4, 1.02e-245], N[(d1 * d2), $MachinePrecision], If[LessEqual[d4, 5.4e-136], t$95$0, If[LessEqual[d4, 2.15e-21], N[(d1 * d2), $MachinePrecision], If[LessEqual[d4, 1.4e+41], t$95$0, N[(d1 * d4), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := d1 \cdot \left(-d1\right)\\
\mathbf{if}\;d4 \leq 1.02 \cdot 10^{-245}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d4 \leq 5.4 \cdot 10^{-136}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d4 \leq 2.15 \cdot 10^{-21}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d4 \leq 1.4 \cdot 10^{+41}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d4 < 1.01999999999999994e-245 or 5.3999999999999997e-136 < d4 < 2.1499999999999999e-21Initial program 85.7%
associate--l+85.7%
distribute-lft-out--88.1%
distribute-rgt-out--89.9%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around inf 33.9%
if 1.01999999999999994e-245 < d4 < 5.3999999999999997e-136 or 2.1499999999999999e-21 < d4 < 1.4e41Initial program 86.1%
associate--l+86.1%
distribute-lft-out--88.9%
distribute-rgt-out--88.9%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around inf 49.4%
unpow249.4%
mul-1-neg49.4%
distribute-rgt-neg-out49.4%
Simplified49.4%
if 1.4e41 < d4 Initial program 88.4%
associate--l+88.4%
distribute-lft-out--90.4%
distribute-rgt-out--92.3%
distribute-lft-out99.9%
Simplified99.9%
Taylor expanded in d4 around inf 62.8%
Final simplification42.0%
(FPCore (d1 d2 d3 d4)
:precision binary64
(let* ((t_0 (* d1 (- d1))))
(if (<= d4 1e-241)
(* d1 d2)
(if (<= d4 8.4e-153)
t_0
(if (<= d4 4.8e-13)
(* d1 (- d3))
(if (<= d4 1.1e+43) t_0 (* d1 d4)))))))
double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * -d1;
double tmp;
if (d4 <= 1e-241) {
tmp = d1 * d2;
} else if (d4 <= 8.4e-153) {
tmp = t_0;
} else if (d4 <= 4.8e-13) {
tmp = d1 * -d3;
} else if (d4 <= 1.1e+43) {
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) :: tmp
t_0 = d1 * -d1
if (d4 <= 1d-241) then
tmp = d1 * d2
else if (d4 <= 8.4d-153) then
tmp = t_0
else if (d4 <= 4.8d-13) then
tmp = d1 * -d3
else if (d4 <= 1.1d+43) 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 tmp;
if (d4 <= 1e-241) {
tmp = d1 * d2;
} else if (d4 <= 8.4e-153) {
tmp = t_0;
} else if (d4 <= 4.8e-13) {
tmp = d1 * -d3;
} else if (d4 <= 1.1e+43) {
tmp = t_0;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): t_0 = d1 * -d1 tmp = 0 if d4 <= 1e-241: tmp = d1 * d2 elif d4 <= 8.4e-153: tmp = t_0 elif d4 <= 4.8e-13: tmp = d1 * -d3 elif d4 <= 1.1e+43: tmp = t_0 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) t_0 = Float64(d1 * Float64(-d1)) tmp = 0.0 if (d4 <= 1e-241) tmp = Float64(d1 * d2); elseif (d4 <= 8.4e-153) tmp = t_0; elseif (d4 <= 4.8e-13) tmp = Float64(d1 * Float64(-d3)); elseif (d4 <= 1.1e+43) tmp = t_0; else tmp = Float64(d1 * d4); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) t_0 = d1 * -d1; tmp = 0.0; if (d4 <= 1e-241) tmp = d1 * d2; elseif (d4 <= 8.4e-153) tmp = t_0; elseif (d4 <= 4.8e-13) tmp = d1 * -d3; elseif (d4 <= 1.1e+43) 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]}, If[LessEqual[d4, 1e-241], N[(d1 * d2), $MachinePrecision], If[LessEqual[d4, 8.4e-153], t$95$0, If[LessEqual[d4, 4.8e-13], N[(d1 * (-d3)), $MachinePrecision], If[LessEqual[d4, 1.1e+43], t$95$0, N[(d1 * d4), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := d1 \cdot \left(-d1\right)\\
\mathbf{if}\;d4 \leq 10^{-241}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d4 \leq 8.4 \cdot 10^{-153}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d4 \leq 4.8 \cdot 10^{-13}:\\
\;\;\;\;d1 \cdot \left(-d3\right)\\
\mathbf{elif}\;d4 \leq 1.1 \cdot 10^{+43}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d4 < 9.9999999999999997e-242Initial program 86.8%
associate--l+86.8%
distribute-lft-out--88.9%
distribute-rgt-out--91.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around inf 32.5%
if 9.9999999999999997e-242 < d4 < 8.40000000000000017e-153 or 4.7999999999999997e-13 < d4 < 1.1e43Initial program 87.1%
associate--l+87.1%
distribute-lft-out--90.3%
distribute-rgt-out--90.3%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around inf 44.3%
unpow244.3%
mul-1-neg44.3%
distribute-rgt-neg-out44.3%
Simplified44.3%
if 8.40000000000000017e-153 < d4 < 4.7999999999999997e-13Initial program 79.3%
associate--l+79.3%
distribute-lft-out--82.8%
distribute-rgt-out--82.8%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around inf 48.2%
associate-*r*48.2%
neg-mul-148.2%
Simplified48.2%
if 1.1e43 < d4 Initial program 88.4%
associate--l+88.4%
distribute-lft-out--90.4%
distribute-rgt-out--92.3%
distribute-lft-out99.9%
Simplified99.9%
Taylor expanded in d4 around inf 62.8%
Final simplification41.9%
(FPCore (d1 d2 d3 d4)
:precision binary64
(if (<= d2 -3e+61)
(* d1 (+ d2 d4))
(if (or (<= d2 2e-193) (not (<= d2 7e-187)))
(* d1 (- d4 d1))
(* d1 (- d3)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -3e+61) {
tmp = d1 * (d2 + d4);
} else if ((d2 <= 2e-193) || !(d2 <= 7e-187)) {
tmp = d1 * (d4 - d1);
} else {
tmp = d1 * -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 (d2 <= (-3d+61)) then
tmp = d1 * (d2 + d4)
else if ((d2 <= 2d-193) .or. (.not. (d2 <= 7d-187))) then
tmp = d1 * (d4 - d1)
else
tmp = d1 * -d3
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -3e+61) {
tmp = d1 * (d2 + d4);
} else if ((d2 <= 2e-193) || !(d2 <= 7e-187)) {
tmp = d1 * (d4 - d1);
} else {
tmp = d1 * -d3;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -3e+61: tmp = d1 * (d2 + d4) elif (d2 <= 2e-193) or not (d2 <= 7e-187): tmp = d1 * (d4 - d1) else: tmp = d1 * -d3 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -3e+61) tmp = Float64(d1 * Float64(d2 + d4)); elseif ((d2 <= 2e-193) || !(d2 <= 7e-187)) tmp = Float64(d1 * Float64(d4 - d1)); else tmp = Float64(d1 * Float64(-d3)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d2 <= -3e+61) tmp = d1 * (d2 + d4); elseif ((d2 <= 2e-193) || ~((d2 <= 7e-187))) tmp = d1 * (d4 - d1); else tmp = d1 * -d3; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -3e+61], N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[d2, 2e-193], N[Not[LessEqual[d2, 7e-187]], $MachinePrecision]], N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision], N[(d1 * (-d3)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -3 \cdot 10^{+61}:\\
\;\;\;\;d1 \cdot \left(d2 + d4\right)\\
\mathbf{elif}\;d2 \leq 2 \cdot 10^{-193} \lor \neg \left(d2 \leq 7 \cdot 10^{-187}\right):\\
\;\;\;\;d1 \cdot \left(d4 - d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(-d3\right)\\
\end{array}
\end{array}
if d2 < -3e61Initial program 83.9%
associate--l+83.9%
distribute-lft-out--93.5%
distribute-rgt-out--93.5%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 84.3%
Taylor expanded in d1 around 0 79.4%
if -3e61 < d2 < 2.0000000000000001e-193 or 6.99999999999999958e-187 < d2 Initial program 87.9%
associate--l+87.9%
distribute-lft-out--87.9%
distribute-rgt-out--90.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 77.9%
Taylor expanded in d2 around 0 59.7%
if 2.0000000000000001e-193 < d2 < 6.99999999999999958e-187Initial program 33.3%
associate--l+33.3%
distribute-lft-out--33.3%
distribute-rgt-out--33.3%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around inf 100.0%
associate-*r*100.0%
neg-mul-1100.0%
Simplified100.0%
Final simplification64.9%
(FPCore (d1 d2 d3 d4)
:precision binary64
(let* ((t_0 (* d1 (- d2 d3))))
(if (<= d4 2.15e-240)
t_0
(if (<= d4 1.9e-197)
(* d1 (- d1))
(if (<= d4 6.5e-13) t_0 (* d1 (- d4 d1)))))))
double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * (d2 - d3);
double tmp;
if (d4 <= 2.15e-240) {
tmp = t_0;
} else if (d4 <= 1.9e-197) {
tmp = d1 * -d1;
} else if (d4 <= 6.5e-13) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = d1 * (d2 - d3)
if (d4 <= 2.15d-240) then
tmp = t_0
else if (d4 <= 1.9d-197) then
tmp = d1 * -d1
else if (d4 <= 6.5d-13) then
tmp = t_0
else
tmp = d1 * (d4 - d1)
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.15e-240) {
tmp = t_0;
} else if (d4 <= 1.9e-197) {
tmp = d1 * -d1;
} else if (d4 <= 6.5e-13) {
tmp = t_0;
} else {
tmp = d1 * (d4 - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): t_0 = d1 * (d2 - d3) tmp = 0 if d4 <= 2.15e-240: tmp = t_0 elif d4 <= 1.9e-197: tmp = d1 * -d1 elif d4 <= 6.5e-13: tmp = t_0 else: tmp = d1 * (d4 - d1) return tmp
function code(d1, d2, d3, d4) t_0 = Float64(d1 * Float64(d2 - d3)) tmp = 0.0 if (d4 <= 2.15e-240) tmp = t_0; elseif (d4 <= 1.9e-197) tmp = Float64(d1 * Float64(-d1)); elseif (d4 <= 6.5e-13) tmp = t_0; else tmp = Float64(d1 * Float64(d4 - d1)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) t_0 = d1 * (d2 - d3); tmp = 0.0; if (d4 <= 2.15e-240) tmp = t_0; elseif (d4 <= 1.9e-197) tmp = d1 * -d1; elseif (d4 <= 6.5e-13) tmp = t_0; else tmp = d1 * (d4 - d1); 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.15e-240], t$95$0, If[LessEqual[d4, 1.9e-197], N[(d1 * (-d1)), $MachinePrecision], If[LessEqual[d4, 6.5e-13], t$95$0, N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := d1 \cdot \left(d2 - d3\right)\\
\mathbf{if}\;d4 \leq 2.15 \cdot 10^{-240}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d4 \leq 1.9 \cdot 10^{-197}:\\
\;\;\;\;d1 \cdot \left(-d1\right)\\
\mathbf{elif}\;d4 \leq 6.5 \cdot 10^{-13}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d1\right)\\
\end{array}
\end{array}
if d4 < 2.15000000000000007e-240 or 1.8999999999999999e-197 < d4 < 6.49999999999999957e-13Initial program 85.7%
associate--l+85.7%
distribute-lft-out--88.5%
distribute-rgt-out--90.1%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around 0 82.4%
Taylor expanded in d1 around 0 62.4%
if 2.15000000000000007e-240 < d4 < 1.8999999999999999e-197Initial program 84.6%
associate--l+84.6%
distribute-lft-out--84.6%
distribute-rgt-out--84.6%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around inf 48.0%
unpow248.0%
mul-1-neg48.0%
distribute-rgt-neg-out48.0%
Simplified48.0%
if 6.49999999999999957e-13 < d4 Initial program 88.5%
associate--l+88.5%
distribute-lft-out--90.1%
distribute-rgt-out--91.8%
distribute-lft-out99.9%
Simplified99.9%
Taylor expanded in d3 around 0 84.3%
Taylor expanded in d2 around 0 68.3%
Final simplification63.1%
(FPCore (d1 d2 d3 d4)
:precision binary64
(let* ((t_0 (* d1 (- d2 d3))))
(if (<= d4 2.35e-245)
t_0
(if (<= d4 5.4e-137)
(* d1 (- (- d1) d3))
(if (<= d4 6.5e-13) t_0 (* d1 (- d4 d1)))))))
double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * (d2 - d3);
double tmp;
if (d4 <= 2.35e-245) {
tmp = t_0;
} else if (d4 <= 5.4e-137) {
tmp = d1 * (-d1 - d3);
} else if (d4 <= 6.5e-13) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = d1 * (d2 - d3)
if (d4 <= 2.35d-245) then
tmp = t_0
else if (d4 <= 5.4d-137) then
tmp = d1 * (-d1 - d3)
else if (d4 <= 6.5d-13) then
tmp = t_0
else
tmp = d1 * (d4 - d1)
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.35e-245) {
tmp = t_0;
} else if (d4 <= 5.4e-137) {
tmp = d1 * (-d1 - d3);
} else if (d4 <= 6.5e-13) {
tmp = t_0;
} else {
tmp = d1 * (d4 - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): t_0 = d1 * (d2 - d3) tmp = 0 if d4 <= 2.35e-245: tmp = t_0 elif d4 <= 5.4e-137: tmp = d1 * (-d1 - d3) elif d4 <= 6.5e-13: tmp = t_0 else: tmp = d1 * (d4 - d1) return tmp
function code(d1, d2, d3, d4) t_0 = Float64(d1 * Float64(d2 - d3)) tmp = 0.0 if (d4 <= 2.35e-245) tmp = t_0; elseif (d4 <= 5.4e-137) tmp = Float64(d1 * Float64(Float64(-d1) - d3)); elseif (d4 <= 6.5e-13) tmp = t_0; else tmp = Float64(d1 * Float64(d4 - d1)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) t_0 = d1 * (d2 - d3); tmp = 0.0; if (d4 <= 2.35e-245) tmp = t_0; elseif (d4 <= 5.4e-137) tmp = d1 * (-d1 - d3); elseif (d4 <= 6.5e-13) tmp = t_0; else tmp = d1 * (d4 - d1); 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.35e-245], t$95$0, If[LessEqual[d4, 5.4e-137], N[(d1 * N[((-d1) - d3), $MachinePrecision]), $MachinePrecision], If[LessEqual[d4, 6.5e-13], t$95$0, N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := d1 \cdot \left(d2 - d3\right)\\
\mathbf{if}\;d4 \leq 2.35 \cdot 10^{-245}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d4 \leq 5.4 \cdot 10^{-137}:\\
\;\;\;\;d1 \cdot \left(\left(-d1\right) - d3\right)\\
\mathbf{elif}\;d4 \leq 6.5 \cdot 10^{-13}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d1\right)\\
\end{array}
\end{array}
if d4 < 2.3500000000000001e-245 or 5.39999999999999986e-137 < d4 < 6.49999999999999957e-13Initial program 86.0%
associate--l+86.0%
distribute-lft-out--88.3%
distribute-rgt-out--90.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around 0 81.2%
Taylor expanded in d1 around 0 61.1%
if 2.3500000000000001e-245 < d4 < 5.39999999999999986e-137Initial program 83.3%
associate--l+83.3%
distribute-lft-out--87.5%
distribute-rgt-out--87.5%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around 0 100.0%
Taylor expanded in d2 around 0 64.0%
mul-1-neg64.0%
*-commutative64.0%
distribute-rgt-neg-in64.0%
Simplified64.0%
if 6.49999999999999957e-13 < d4 Initial program 88.5%
associate--l+88.5%
distribute-lft-out--90.1%
distribute-rgt-out--91.8%
distribute-lft-out99.9%
Simplified99.9%
Taylor expanded in d3 around 0 84.3%
Taylor expanded in d2 around 0 68.3%
Final simplification63.1%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (or (<= d3 -8.2e+109) (not (<= d3 7.2e+174))) (* d1 (- d2 d3)) (* d1 (- (+ d2 d4) d1))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d3 <= -8.2e+109) || !(d3 <= 7.2e+174)) {
tmp = d1 * (d2 - 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+109)) .or. (.not. (d3 <= 7.2d+174))) then
tmp = d1 * (d2 - 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+109) || !(d3 <= 7.2e+174)) {
tmp = d1 * (d2 - d3);
} else {
tmp = d1 * ((d2 + d4) - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if (d3 <= -8.2e+109) or not (d3 <= 7.2e+174): tmp = d1 * (d2 - d3) else: tmp = d1 * ((d2 + d4) - d1) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if ((d3 <= -8.2e+109) || !(d3 <= 7.2e+174)) tmp = Float64(d1 * Float64(d2 - 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+109) || ~((d3 <= 7.2e+174))) tmp = d1 * (d2 - d3); else tmp = d1 * ((d2 + d4) - d1); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[Or[LessEqual[d3, -8.2e+109], N[Not[LessEqual[d3, 7.2e+174]], $MachinePrecision]], N[(d1 * N[(d2 - 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^{+109} \lor \neg \left(d3 \leq 7.2 \cdot 10^{+174}\right):\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(\left(d2 + d4\right) - d1\right)\\
\end{array}
\end{array}
if d3 < -8.19999999999999939e109 or 7.2000000000000003e174 < d3 Initial program 79.1%
associate--l+79.1%
distribute-lft-out--86.5%
distribute-rgt-out--86.5%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around 0 88.5%
Taylor expanded in d1 around 0 84.0%
if -8.19999999999999939e109 < d3 < 7.2000000000000003e174Initial program 88.9%
associate--l+88.9%
distribute-lft-out--89.4%
distribute-rgt-out--91.5%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around 0 91.5%
Final simplification89.6%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 0.00032) (* d1 (- d2 (+ d1 d3))) (* d1 (- (+ d2 d4) d1))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 0.00032) {
tmp = d1 * (d2 - (d1 + 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 (d4 <= 0.00032d0) then
tmp = d1 * (d2 - (d1 + 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 (d4 <= 0.00032) {
tmp = d1 * (d2 - (d1 + d3));
} else {
tmp = d1 * ((d2 + d4) - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 0.00032: tmp = d1 * (d2 - (d1 + d3)) else: tmp = d1 * ((d2 + d4) - d1) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 0.00032) tmp = Float64(d1 * Float64(d2 - Float64(d1 + 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 (d4 <= 0.00032) tmp = d1 * (d2 - (d1 + d3)); else tmp = d1 * ((d2 + d4) - d1); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 0.00032], N[(d1 * N[(d2 - N[(d1 + d3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(N[(d2 + d4), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 0.00032:\\
\;\;\;\;d1 \cdot \left(d2 - \left(d1 + d3\right)\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(\left(d2 + d4\right) - d1\right)\\
\end{array}
\end{array}
if d4 < 3.20000000000000026e-4Initial program 85.9%
associate--l+85.9%
distribute-lft-out--88.4%
distribute-rgt-out--89.9%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around 0 83.3%
if 3.20000000000000026e-4 < d4 Initial program 87.9%
associate--l+87.9%
distribute-lft-out--89.6%
distribute-rgt-out--91.4%
distribute-lft-out99.9%
Simplified99.9%
Taylor expanded in d3 around 0 83.4%
Final simplification83.3%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 4.45e-10) (* d1 d2) (* d1 d4)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 4.45e-10) {
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 <= 4.45d-10) 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 <= 4.45e-10) {
tmp = d1 * d2;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 4.45e-10: tmp = d1 * d2 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 4.45e-10) 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 <= 4.45e-10) tmp = d1 * d2; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 4.45e-10], N[(d1 * d2), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 4.45 \cdot 10^{-10}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d4 < 4.45e-10Initial program 85.7%
associate--l+85.7%
distribute-lft-out--88.3%
distribute-rgt-out--89.8%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around inf 36.0%
if 4.45e-10 < d4 Initial program 88.3%
associate--l+88.3%
distribute-lft-out--90.0%
distribute-rgt-out--91.6%
distribute-lft-out99.9%
Simplified99.9%
Taylor expanded in d4 around inf 56.5%
Final simplification40.8%
(FPCore (d1 d2 d3 d4) :precision binary64 (* d1 d4))
double code(double d1, double d2, double d3, double d4) {
return d1 * d4;
}
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
end function
public static double code(double d1, double d2, double d3, double d4) {
return d1 * d4;
}
def code(d1, d2, d3, d4): return d1 * d4
function code(d1, d2, d3, d4) return Float64(d1 * d4) end
function tmp = code(d1, d2, d3, d4) tmp = d1 * d4; end
code[d1_, d2_, d3_, d4_] := N[(d1 * d4), $MachinePrecision]
\begin{array}{l}
\\
d1 \cdot d4
\end{array}
Initial program 86.3%
associate--l+86.3%
distribute-lft-out--88.7%
distribute-rgt-out--90.2%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around inf 30.8%
Final simplification30.8%
(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 2023173
(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)))