
(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 (- d4 (+ d1 d3)))))
double code(double d1, double d2, double d3, double d4) {
return d1 * (d2 + (d4 - (d1 + 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 + (d4 - (d1 + d3)))
end function
public static double code(double d1, double d2, double d3, double d4) {
return d1 * (d2 + (d4 - (d1 + d3)));
}
def code(d1, d2, d3, d4): return d1 * (d2 + (d4 - (d1 + d3)))
function code(d1, d2, d3, d4) return Float64(d1 * Float64(d2 + Float64(d4 - Float64(d1 + d3)))) end
function tmp = code(d1, d2, d3, d4) tmp = d1 * (d2 + (d4 - (d1 + d3))); end
code[d1_, d2_, d3_, d4_] := N[(d1 * N[(d2 + N[(d4 - N[(d1 + d3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
d1 \cdot \left(d2 + \left(d4 - \left(d1 + d3\right)\right)\right)
\end{array}
Initial program 89.8%
distribute-lft-out--N/A
*-commutativeN/A
distribute-lft-outN/A
distribute-lft-out--N/A
*-lowering-*.f64N/A
associate-+r-N/A
sub-negN/A
associate-+l+N/A
+-lowering-+.f64N/A
+-commutativeN/A
unsub-negN/A
associate--l-N/A
+-commutativeN/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64100.0%
Simplified100.0%
(FPCore (d1 d2 d3 d4) :precision binary64 (let* ((t_0 (* d1 (- 0.0 d3)))) (if (<= d3 -8.5e+113) t_0 (if (<= d3 3.8e+120) (* d1 (+ d2 d4)) t_0))))
double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * (0.0 - d3);
double tmp;
if (d3 <= -8.5e+113) {
tmp = t_0;
} else if (d3 <= 3.8e+120) {
tmp = d1 * (d2 + d4);
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: t_0
real(8) :: tmp
t_0 = d1 * (0.0d0 - d3)
if (d3 <= (-8.5d+113)) then
tmp = t_0
else if (d3 <= 3.8d+120) then
tmp = d1 * (d2 + d4)
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 * (0.0 - d3);
double tmp;
if (d3 <= -8.5e+113) {
tmp = t_0;
} else if (d3 <= 3.8e+120) {
tmp = d1 * (d2 + d4);
} else {
tmp = t_0;
}
return tmp;
}
def code(d1, d2, d3, d4): t_0 = d1 * (0.0 - d3) tmp = 0 if d3 <= -8.5e+113: tmp = t_0 elif d3 <= 3.8e+120: tmp = d1 * (d2 + d4) else: tmp = t_0 return tmp
function code(d1, d2, d3, d4) t_0 = Float64(d1 * Float64(0.0 - d3)) tmp = 0.0 if (d3 <= -8.5e+113) tmp = t_0; elseif (d3 <= 3.8e+120) tmp = Float64(d1 * Float64(d2 + d4)); else tmp = t_0; end return tmp end
function tmp_2 = code(d1, d2, d3, d4) t_0 = d1 * (0.0 - d3); tmp = 0.0; if (d3 <= -8.5e+113) tmp = t_0; elseif (d3 <= 3.8e+120) tmp = d1 * (d2 + d4); else tmp = t_0; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := Block[{t$95$0 = N[(d1 * N[(0.0 - d3), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d3, -8.5e+113], t$95$0, If[LessEqual[d3, 3.8e+120], N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := d1 \cdot \left(0 - d3\right)\\
\mathbf{if}\;d3 \leq -8.5 \cdot 10^{+113}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d3 \leq 3.8 \cdot 10^{+120}:\\
\;\;\;\;d1 \cdot \left(d2 + d4\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d3 < -8.5000000000000001e113 or 3.7999999999999998e120 < d3 Initial program 81.7%
distribute-lft-out--N/A
*-commutativeN/A
distribute-lft-outN/A
distribute-lft-out--N/A
*-lowering-*.f64N/A
associate-+r-N/A
sub-negN/A
associate-+l+N/A
+-lowering-+.f64N/A
+-commutativeN/A
unsub-negN/A
associate--l-N/A
+-commutativeN/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64100.0%
Simplified100.0%
Taylor expanded in d3 around inf
mul-1-negN/A
neg-sub0N/A
--lowering--.f64N/A
*-lowering-*.f6472.9%
Simplified72.9%
sub0-negN/A
neg-lowering-neg.f64N/A
*-lowering-*.f6472.9%
Applied egg-rr72.9%
if -8.5000000000000001e113 < d3 < 3.7999999999999998e120Initial program 93.7%
distribute-lft-out--N/A
*-commutativeN/A
distribute-lft-outN/A
distribute-lft-out--N/A
*-lowering-*.f64N/A
associate-+r-N/A
sub-negN/A
associate-+l+N/A
+-lowering-+.f64N/A
+-commutativeN/A
unsub-negN/A
associate--l-N/A
+-commutativeN/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64100.0%
Simplified100.0%
Taylor expanded in d4 around inf
Simplified69.4%
Final simplification70.5%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 5.5e-185) (* d1 d2) (if (<= d4 1.55e+65) (* d1 (- 0.0 d3)) (* d1 d4))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 5.5e-185) {
tmp = d1 * d2;
} else if (d4 <= 1.55e+65) {
tmp = d1 * (0.0 - d3);
} 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 <= 5.5d-185) then
tmp = d1 * d2
else if (d4 <= 1.55d+65) then
tmp = d1 * (0.0d0 - d3)
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 <= 5.5e-185) {
tmp = d1 * d2;
} else if (d4 <= 1.55e+65) {
tmp = d1 * (0.0 - d3);
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 5.5e-185: tmp = d1 * d2 elif d4 <= 1.55e+65: tmp = d1 * (0.0 - d3) else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 5.5e-185) tmp = Float64(d1 * d2); elseif (d4 <= 1.55e+65) tmp = Float64(d1 * Float64(0.0 - d3)); else tmp = Float64(d1 * d4); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d4 <= 5.5e-185) tmp = d1 * d2; elseif (d4 <= 1.55e+65) tmp = d1 * (0.0 - d3); else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 5.5e-185], N[(d1 * d2), $MachinePrecision], If[LessEqual[d4, 1.55e+65], N[(d1 * N[(0.0 - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 5.5 \cdot 10^{-185}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d4 \leq 1.55 \cdot 10^{+65}:\\
\;\;\;\;d1 \cdot \left(0 - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d4 < 5.4999999999999998e-185Initial program 91.2%
distribute-lft-out--N/A
*-commutativeN/A
distribute-lft-outN/A
distribute-lft-out--N/A
*-lowering-*.f64N/A
associate-+r-N/A
sub-negN/A
associate-+l+N/A
+-lowering-+.f64N/A
+-commutativeN/A
unsub-negN/A
associate--l-N/A
+-commutativeN/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64100.0%
Simplified100.0%
Taylor expanded in d2 around inf
*-lowering-*.f6435.1%
Simplified35.1%
if 5.4999999999999998e-185 < d4 < 1.54999999999999995e65Initial program 94.2%
distribute-lft-out--N/A
*-commutativeN/A
distribute-lft-outN/A
distribute-lft-out--N/A
*-lowering-*.f64N/A
associate-+r-N/A
sub-negN/A
associate-+l+N/A
+-lowering-+.f64N/A
+-commutativeN/A
unsub-negN/A
associate--l-N/A
+-commutativeN/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64100.0%
Simplified100.0%
Taylor expanded in d3 around inf
mul-1-negN/A
neg-sub0N/A
--lowering--.f64N/A
*-lowering-*.f6447.3%
Simplified47.3%
sub0-negN/A
neg-lowering-neg.f64N/A
*-lowering-*.f6447.3%
Applied egg-rr47.3%
if 1.54999999999999995e65 < d4 Initial program 79.9%
distribute-lft-out--N/A
*-commutativeN/A
distribute-lft-outN/A
distribute-lft-out--N/A
*-lowering-*.f64N/A
associate-+r-N/A
sub-negN/A
associate-+l+N/A
+-lowering-+.f64N/A
+-commutativeN/A
unsub-negN/A
associate--l-N/A
+-commutativeN/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f6499.9%
Simplified99.9%
Taylor expanded in d4 around inf
*-lowering-*.f6457.3%
Simplified57.3%
Final simplification41.5%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 2.4e-26) (* d1 (- d2 (+ d1 d3))) (* d1 (- d4 (+ d1 d3)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 2.4e-26) {
tmp = d1 * (d2 - (d1 + d3));
} else {
tmp = d1 * (d4 - (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 (d4 <= 2.4d-26) then
tmp = d1 * (d2 - (d1 + d3))
else
tmp = d1 * (d4 - (d1 + d3))
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 2.4e-26) {
tmp = d1 * (d2 - (d1 + d3));
} else {
tmp = d1 * (d4 - (d1 + d3));
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 2.4e-26: tmp = d1 * (d2 - (d1 + d3)) else: tmp = d1 * (d4 - (d1 + d3)) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 2.4e-26) tmp = Float64(d1 * Float64(d2 - Float64(d1 + d3))); else tmp = Float64(d1 * Float64(d4 - Float64(d1 + d3))); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d4 <= 2.4e-26) tmp = d1 * (d2 - (d1 + d3)); else tmp = d1 * (d4 - (d1 + d3)); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 2.4e-26], N[(d1 * N[(d2 - N[(d1 + d3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - N[(d1 + d3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 2.4 \cdot 10^{-26}:\\
\;\;\;\;d1 \cdot \left(d2 - \left(d1 + d3\right)\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - \left(d1 + d3\right)\right)\\
\end{array}
\end{array}
if d4 < 2.4000000000000001e-26Initial program 91.7%
distribute-lft-out--N/A
*-commutativeN/A
distribute-lft-outN/A
distribute-lft-out--N/A
*-lowering-*.f64N/A
associate-+r-N/A
sub-negN/A
associate-+l+N/A
+-lowering-+.f64N/A
+-commutativeN/A
unsub-negN/A
associate--l-N/A
+-commutativeN/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64100.0%
Simplified100.0%
Taylor expanded in d4 around 0
*-lowering-*.f64N/A
--lowering--.f64N/A
+-lowering-+.f6482.7%
Simplified82.7%
if 2.4000000000000001e-26 < d4 Initial program 84.1%
distribute-lft-out--N/A
*-commutativeN/A
distribute-lft-outN/A
distribute-lft-out--N/A
*-lowering-*.f64N/A
associate-+r-N/A
sub-negN/A
associate-+l+N/A
+-lowering-+.f64N/A
+-commutativeN/A
unsub-negN/A
associate--l-N/A
+-commutativeN/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64100.0%
Simplified100.0%
Taylor expanded in d2 around 0
*-lowering-*.f64N/A
--lowering--.f64N/A
+-lowering-+.f6482.4%
Simplified82.4%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 1.3e+71) (* d1 (- d2 (+ d1 d3))) (* d1 (- d4 d3))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 1.3e+71) {
tmp = d1 * (d2 - (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 <= 1.3d+71) then
tmp = d1 * (d2 - (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 <= 1.3e+71) {
tmp = d1 * (d2 - (d1 + d3));
} else {
tmp = d1 * (d4 - d3);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 1.3e+71: tmp = d1 * (d2 - (d1 + d3)) else: tmp = d1 * (d4 - d3) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 1.3e+71) tmp = Float64(d1 * Float64(d2 - 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 <= 1.3e+71) tmp = d1 * (d2 - (d1 + d3)); else tmp = d1 * (d4 - d3); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 1.3e+71], N[(d1 * N[(d2 - N[(d1 + d3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - d3), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 1.3 \cdot 10^{+71}:\\
\;\;\;\;d1 \cdot \left(d2 - \left(d1 + d3\right)\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\end{array}
\end{array}
if d4 < 1.29999999999999996e71Initial program 91.5%
distribute-lft-out--N/A
*-commutativeN/A
distribute-lft-outN/A
distribute-lft-out--N/A
*-lowering-*.f64N/A
associate-+r-N/A
sub-negN/A
associate-+l+N/A
+-lowering-+.f64N/A
+-commutativeN/A
unsub-negN/A
associate--l-N/A
+-commutativeN/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64100.0%
Simplified100.0%
Taylor expanded in d4 around 0
*-lowering-*.f64N/A
--lowering--.f64N/A
+-lowering-+.f6483.8%
Simplified83.8%
if 1.29999999999999996e71 < d4 Initial program 81.7%
distribute-lft-out--N/A
*-commutativeN/A
distribute-lft-outN/A
distribute-lft-out--N/A
*-lowering-*.f64N/A
associate-+r-N/A
sub-negN/A
associate-+l+N/A
+-lowering-+.f64N/A
+-commutativeN/A
unsub-negN/A
associate--l-N/A
+-commutativeN/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f6499.9%
Simplified99.9%
Taylor expanded in d2 around 0
*-lowering-*.f64N/A
--lowering--.f64N/A
+-lowering-+.f6485.7%
Simplified85.7%
Taylor expanded in d1 around 0
*-lowering-*.f64N/A
--lowering--.f6474.3%
Simplified74.3%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 2.65e-27) (* d1 (- d2 d3)) (* d1 (- d4 d3))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 2.65e-27) {
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 <= 2.65d-27) 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 <= 2.65e-27) {
tmp = d1 * (d2 - d3);
} else {
tmp = d1 * (d4 - d3);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 2.65e-27: tmp = d1 * (d2 - d3) else: tmp = d1 * (d4 - d3) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 2.65e-27) 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 <= 2.65e-27) tmp = d1 * (d2 - d3); else tmp = d1 * (d4 - d3); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 2.65e-27], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - d3), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 2.65 \cdot 10^{-27}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\end{array}
\end{array}
if d4 < 2.65000000000000003e-27Initial program 91.7%
distribute-lft-out--N/A
*-commutativeN/A
distribute-lft-outN/A
distribute-lft-out--N/A
*-lowering-*.f64N/A
associate-+r-N/A
sub-negN/A
associate-+l+N/A
+-lowering-+.f64N/A
+-commutativeN/A
unsub-negN/A
associate--l-N/A
+-commutativeN/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64100.0%
Simplified100.0%
Taylor expanded in d4 around 0
*-lowering-*.f64N/A
--lowering--.f64N/A
+-lowering-+.f6482.7%
Simplified82.7%
Taylor expanded in d1 around 0
*-lowering-*.f64N/A
--lowering--.f6461.7%
Simplified61.7%
if 2.65000000000000003e-27 < d4 Initial program 84.1%
distribute-lft-out--N/A
*-commutativeN/A
distribute-lft-outN/A
distribute-lft-out--N/A
*-lowering-*.f64N/A
associate-+r-N/A
sub-negN/A
associate-+l+N/A
+-lowering-+.f64N/A
+-commutativeN/A
unsub-negN/A
associate--l-N/A
+-commutativeN/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64100.0%
Simplified100.0%
Taylor expanded in d2 around 0
*-lowering-*.f64N/A
--lowering--.f64N/A
+-lowering-+.f6482.4%
Simplified82.4%
Taylor expanded in d1 around 0
*-lowering-*.f64N/A
--lowering--.f6469.8%
Simplified69.8%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 4.9e+68) (* d1 (- d2 d3)) (* d1 (- d4 d1))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 4.9e+68) {
tmp = d1 * (d2 - d3);
} 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 <= 4.9d+68) then
tmp = d1 * (d2 - d3)
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 <= 4.9e+68) {
tmp = d1 * (d2 - d3);
} else {
tmp = d1 * (d4 - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 4.9e+68: tmp = d1 * (d2 - d3) else: tmp = d1 * (d4 - d1) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 4.9e+68) tmp = Float64(d1 * Float64(d2 - d3)); else tmp = Float64(d1 * Float64(d4 - d1)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d4 <= 4.9e+68) tmp = d1 * (d2 - d3); else tmp = d1 * (d4 - d1); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 4.9e+68], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 4.9 \cdot 10^{+68}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d1\right)\\
\end{array}
\end{array}
if d4 < 4.89999999999999978e68Initial program 91.5%
distribute-lft-out--N/A
*-commutativeN/A
distribute-lft-outN/A
distribute-lft-out--N/A
*-lowering-*.f64N/A
associate-+r-N/A
sub-negN/A
associate-+l+N/A
+-lowering-+.f64N/A
+-commutativeN/A
unsub-negN/A
associate--l-N/A
+-commutativeN/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64100.0%
Simplified100.0%
Taylor expanded in d4 around 0
*-lowering-*.f64N/A
--lowering--.f64N/A
+-lowering-+.f6483.8%
Simplified83.8%
Taylor expanded in d1 around 0
*-lowering-*.f64N/A
--lowering--.f6463.3%
Simplified63.3%
if 4.89999999999999978e68 < d4 Initial program 81.7%
distribute-lft-out--N/A
*-commutativeN/A
distribute-lft-outN/A
distribute-lft-out--N/A
*-lowering-*.f64N/A
associate-+r-N/A
sub-negN/A
associate-+l+N/A
+-lowering-+.f64N/A
+-commutativeN/A
unsub-negN/A
associate--l-N/A
+-commutativeN/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f6499.9%
Simplified99.9%
Taylor expanded in d2 around 0
*-lowering-*.f64N/A
--lowering--.f64N/A
+-lowering-+.f6485.7%
Simplified85.7%
Taylor expanded in d3 around 0
*-lowering-*.f64N/A
--lowering--.f6470.0%
Simplified70.0%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 6e+67) (* d1 (- d2 d3)) (* d1 (+ d2 d4))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 6e+67) {
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 <= 6d+67) 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 <= 6e+67) {
tmp = d1 * (d2 - d3);
} else {
tmp = d1 * (d2 + d4);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 6e+67: tmp = d1 * (d2 - d3) else: tmp = d1 * (d2 + d4) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 6e+67) 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 <= 6e+67) tmp = d1 * (d2 - d3); else tmp = d1 * (d2 + d4); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 6e+67], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 6 \cdot 10^{+67}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d2 + d4\right)\\
\end{array}
\end{array}
if d4 < 6.0000000000000002e67Initial program 91.9%
distribute-lft-out--N/A
*-commutativeN/A
distribute-lft-outN/A
distribute-lft-out--N/A
*-lowering-*.f64N/A
associate-+r-N/A
sub-negN/A
associate-+l+N/A
+-lowering-+.f64N/A
+-commutativeN/A
unsub-negN/A
associate--l-N/A
+-commutativeN/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64100.0%
Simplified100.0%
Taylor expanded in d4 around 0
*-lowering-*.f64N/A
--lowering--.f64N/A
+-lowering-+.f6483.7%
Simplified83.7%
Taylor expanded in d1 around 0
*-lowering-*.f64N/A
--lowering--.f6463.2%
Simplified63.2%
if 6.0000000000000002e67 < d4 Initial program 79.9%
distribute-lft-out--N/A
*-commutativeN/A
distribute-lft-outN/A
distribute-lft-out--N/A
*-lowering-*.f64N/A
associate-+r-N/A
sub-negN/A
associate-+l+N/A
+-lowering-+.f64N/A
+-commutativeN/A
unsub-negN/A
associate--l-N/A
+-commutativeN/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f6499.9%
Simplified99.9%
Taylor expanded in d4 around inf
Simplified73.6%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 1.6e+68) (* d1 (- d2 d1)) (* d1 (+ d2 d4))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 1.6e+68) {
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 <= 1.6d+68) 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 <= 1.6e+68) {
tmp = d1 * (d2 - d1);
} else {
tmp = d1 * (d2 + d4);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 1.6e+68: tmp = d1 * (d2 - d1) else: tmp = d1 * (d2 + d4) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 1.6e+68) 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 <= 1.6e+68) tmp = d1 * (d2 - d1); else tmp = d1 * (d2 + d4); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 1.6e+68], N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 1.6 \cdot 10^{+68}:\\
\;\;\;\;d1 \cdot \left(d2 - d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d2 + d4\right)\\
\end{array}
\end{array}
if d4 < 1.59999999999999997e68Initial program 91.9%
distribute-lft-out--N/A
*-commutativeN/A
distribute-lft-outN/A
distribute-lft-out--N/A
*-lowering-*.f64N/A
associate-+r-N/A
sub-negN/A
associate-+l+N/A
+-lowering-+.f64N/A
+-commutativeN/A
unsub-negN/A
associate--l-N/A
+-commutativeN/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64100.0%
Simplified100.0%
Taylor expanded in d4 around 0
*-lowering-*.f64N/A
--lowering--.f64N/A
+-lowering-+.f6483.7%
Simplified83.7%
Taylor expanded in d3 around 0
*-lowering-*.f64N/A
--lowering--.f6457.1%
Simplified57.1%
if 1.59999999999999997e68 < d4 Initial program 79.9%
distribute-lft-out--N/A
*-commutativeN/A
distribute-lft-outN/A
distribute-lft-out--N/A
*-lowering-*.f64N/A
associate-+r-N/A
sub-negN/A
associate-+l+N/A
+-lowering-+.f64N/A
+-commutativeN/A
unsub-negN/A
associate--l-N/A
+-commutativeN/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f6499.9%
Simplified99.9%
Taylor expanded in d4 around inf
Simplified73.6%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 3.8e-21) (* d1 d2) (* d1 d4)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 3.8e-21) {
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 <= 3.8d-21) 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 <= 3.8e-21) {
tmp = d1 * d2;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 3.8e-21: tmp = d1 * d2 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 3.8e-21) 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 <= 3.8e-21) tmp = d1 * d2; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 3.8e-21], N[(d1 * d2), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 3.8 \cdot 10^{-21}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d4 < 3.7999999999999998e-21Initial program 91.7%
distribute-lft-out--N/A
*-commutativeN/A
distribute-lft-outN/A
distribute-lft-out--N/A
*-lowering-*.f64N/A
associate-+r-N/A
sub-negN/A
associate-+l+N/A
+-lowering-+.f64N/A
+-commutativeN/A
unsub-negN/A
associate--l-N/A
+-commutativeN/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64100.0%
Simplified100.0%
Taylor expanded in d2 around inf
*-lowering-*.f6435.8%
Simplified35.8%
if 3.7999999999999998e-21 < d4 Initial program 83.8%
distribute-lft-out--N/A
*-commutativeN/A
distribute-lft-outN/A
distribute-lft-out--N/A
*-lowering-*.f64N/A
associate-+r-N/A
sub-negN/A
associate-+l+N/A
+-lowering-+.f64N/A
+-commutativeN/A
unsub-negN/A
associate--l-N/A
+-commutativeN/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f6499.9%
Simplified99.9%
Taylor expanded in d4 around inf
*-lowering-*.f6443.9%
Simplified43.9%
(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 89.8%
distribute-lft-out--N/A
*-commutativeN/A
distribute-lft-outN/A
distribute-lft-out--N/A
*-lowering-*.f64N/A
associate-+r-N/A
sub-negN/A
associate-+l+N/A
+-lowering-+.f64N/A
+-commutativeN/A
unsub-negN/A
associate--l-N/A
+-commutativeN/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64100.0%
Simplified100.0%
Taylor expanded in d2 around inf
*-lowering-*.f6432.5%
Simplified32.5%
(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 2024155
(FPCore (d1 d2 d3 d4)
:name "FastMath dist4"
:precision binary64
:alt
(! :herbie-platform default (* d1 (- (+ (- d2 d3) d4) d1)))
(- (+ (- (* d1 d2) (* d1 d3)) (* d4 d1)) (* d1 d1)))