
(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 10 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 86.3%
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
associate-+r-N/A
+-commutativeN/A
unsub-negN/A
associate--l-N/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64100.0%
Simplified100.0%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d1 -4.6e+117) (* d1 (- d2 d1)) (if (<= d1 9e+129) (* d1 (+ d2 (- d4 d3))) (* d1 (- d4 d1)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d1 <= -4.6e+117) {
tmp = d1 * (d2 - d1);
} else if (d1 <= 9e+129) {
tmp = d1 * (d2 + (d4 - 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 (d1 <= (-4.6d+117)) then
tmp = d1 * (d2 - d1)
else if (d1 <= 9d+129) then
tmp = d1 * (d2 + (d4 - 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 (d1 <= -4.6e+117) {
tmp = d1 * (d2 - d1);
} else if (d1 <= 9e+129) {
tmp = d1 * (d2 + (d4 - d3));
} else {
tmp = d1 * (d4 - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d1 <= -4.6e+117: tmp = d1 * (d2 - d1) elif d1 <= 9e+129: tmp = d1 * (d2 + (d4 - d3)) else: tmp = d1 * (d4 - d1) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d1 <= -4.6e+117) tmp = Float64(d1 * Float64(d2 - d1)); elseif (d1 <= 9e+129) tmp = Float64(d1 * Float64(d2 + Float64(d4 - d3))); else tmp = Float64(d1 * Float64(d4 - d1)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d1 <= -4.6e+117) tmp = d1 * (d2 - d1); elseif (d1 <= 9e+129) tmp = d1 * (d2 + (d4 - d3)); else tmp = d1 * (d4 - d1); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d1, -4.6e+117], N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision], If[LessEqual[d1, 9e+129], N[(d1 * N[(d2 + N[(d4 - d3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d1 \leq -4.6 \cdot 10^{+117}:\\
\;\;\;\;d1 \cdot \left(d2 - d1\right)\\
\mathbf{elif}\;d1 \leq 9 \cdot 10^{+129}:\\
\;\;\;\;d1 \cdot \left(d2 + \left(d4 - d3\right)\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d1\right)\\
\end{array}
\end{array}
if d1 < -4.59999999999999976e117Initial program 51.4%
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
associate-+r-N/A
+-commutativeN/A
unsub-negN/A
associate--l-N/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64100.0%
Simplified100.0%
+-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
--lowering--.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f6474.3%
Applied egg-rr74.3%
Taylor expanded in d4 around 0
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
distribute-lft-out--N/A
*-lowering-*.f64N/A
--lowering--.f64N/A
+-lowering-+.f6497.1%
Simplified97.1%
Taylor expanded in d3 around 0
*-lowering-*.f64N/A
--lowering--.f6488.6%
Simplified88.6%
if -4.59999999999999976e117 < d1 < 9.0000000000000003e129Initial program 99.4%
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
associate-+r-N/A
+-commutativeN/A
unsub-negN/A
associate--l-N/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64100.0%
Simplified100.0%
Taylor expanded in d1 around 0
*-lowering-*.f64N/A
sub-negN/A
mul-1-negN/A
associate-+r+N/A
+-lowering-+.f64N/A
mul-1-negN/A
sub-negN/A
--lowering--.f6491.7%
Simplified91.7%
if 9.0000000000000003e129 < d1 Initial program 55.3%
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
associate-+r-N/A
+-commutativeN/A
unsub-negN/A
associate--l-N/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64100.0%
Simplified100.0%
Taylor expanded in d2 around 0
*-lowering-*.f64N/A
--lowering--.f64N/A
+-lowering-+.f6491.8%
Simplified91.8%
Taylor expanded in d3 around 0
*-lowering-*.f64N/A
--lowering--.f6489.2%
Simplified89.2%
(FPCore (d1 d2 d3 d4) :precision binary64 (let* ((t_0 (* d1 (- d2 d3)))) (if (<= d3 -1.2e+85) t_0 (if (<= d3 2.1e+65) (* d1 (- d4 d1)) t_0))))
double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * (d2 - d3);
double tmp;
if (d3 <= -1.2e+85) {
tmp = t_0;
} else if (d3 <= 2.1e+65) {
tmp = d1 * (d4 - d1);
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: t_0
real(8) :: tmp
t_0 = d1 * (d2 - d3)
if (d3 <= (-1.2d+85)) then
tmp = t_0
else if (d3 <= 2.1d+65) then
tmp = d1 * (d4 - d1)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * (d2 - d3);
double tmp;
if (d3 <= -1.2e+85) {
tmp = t_0;
} else if (d3 <= 2.1e+65) {
tmp = d1 * (d4 - d1);
} else {
tmp = t_0;
}
return tmp;
}
def code(d1, d2, d3, d4): t_0 = d1 * (d2 - d3) tmp = 0 if d3 <= -1.2e+85: tmp = t_0 elif d3 <= 2.1e+65: tmp = d1 * (d4 - d1) else: tmp = t_0 return tmp
function code(d1, d2, d3, d4) t_0 = Float64(d1 * Float64(d2 - d3)) tmp = 0.0 if (d3 <= -1.2e+85) tmp = t_0; elseif (d3 <= 2.1e+65) tmp = Float64(d1 * Float64(d4 - d1)); else tmp = t_0; end return tmp end
function tmp_2 = code(d1, d2, d3, d4) t_0 = d1 * (d2 - d3); tmp = 0.0; if (d3 <= -1.2e+85) tmp = t_0; elseif (d3 <= 2.1e+65) tmp = d1 * (d4 - d1); else tmp = t_0; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := Block[{t$95$0 = N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d3, -1.2e+85], t$95$0, If[LessEqual[d3, 2.1e+65], N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := d1 \cdot \left(d2 - d3\right)\\
\mathbf{if}\;d3 \leq -1.2 \cdot 10^{+85}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d3 \leq 2.1 \cdot 10^{+65}:\\
\;\;\;\;d1 \cdot \left(d4 - d1\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d3 < -1.19999999999999998e85 or 2.09999999999999991e65 < d3 Initial program 84.0%
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
associate-+r-N/A
+-commutativeN/A
unsub-negN/A
associate--l-N/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64100.0%
Simplified100.0%
+-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
--lowering--.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f6492.5%
Applied egg-rr92.5%
Taylor expanded in d4 around 0
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
distribute-lft-out--N/A
*-lowering-*.f64N/A
--lowering--.f64N/A
+-lowering-+.f6486.7%
Simplified86.7%
Taylor expanded in d1 around 0
remove-double-negN/A
distribute-rgt-neg-outN/A
mul-1-negN/A
distribute-rgt-neg-inN/A
*-rgt-identityN/A
*-inversesN/A
associate-/l*N/A
associate-*l/N/A
associate-*r/N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-commutativeN/A
associate-*r/N/A
associate-*l/N/A
associate-/l*N/A
*-inversesN/A
*-rgt-identityN/A
sub-negN/A
distribute-lft-inN/A
mul-1-negN/A
remove-double-negN/A
Simplified81.7%
if -1.19999999999999998e85 < d3 < 2.09999999999999991e65Initial program 87.6%
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
associate-+r-N/A
+-commutativeN/A
unsub-negN/A
associate--l-N/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64100.0%
Simplified100.0%
Taylor expanded in d2 around 0
*-lowering-*.f64N/A
--lowering--.f64N/A
+-lowering-+.f6470.5%
Simplified70.5%
Taylor expanded in d3 around 0
*-lowering-*.f64N/A
--lowering--.f6465.9%
Simplified65.9%
(FPCore (d1 d2 d3 d4)
:precision binary64
(let* ((t_0 (* d1 (- d2 d3))))
(if (<= d3 -2.9e+146)
t_0
(if (<= d3 190000000000.0) (* d1 (+ d2 d4)) t_0))))
double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * (d2 - d3);
double tmp;
if (d3 <= -2.9e+146) {
tmp = t_0;
} else if (d3 <= 190000000000.0) {
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 * (d2 - d3)
if (d3 <= (-2.9d+146)) then
tmp = t_0
else if (d3 <= 190000000000.0d0) 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 * (d2 - d3);
double tmp;
if (d3 <= -2.9e+146) {
tmp = t_0;
} else if (d3 <= 190000000000.0) {
tmp = d1 * (d2 + d4);
} else {
tmp = t_0;
}
return tmp;
}
def code(d1, d2, d3, d4): t_0 = d1 * (d2 - d3) tmp = 0 if d3 <= -2.9e+146: tmp = t_0 elif d3 <= 190000000000.0: tmp = d1 * (d2 + d4) else: tmp = t_0 return tmp
function code(d1, d2, d3, d4) t_0 = Float64(d1 * Float64(d2 - d3)) tmp = 0.0 if (d3 <= -2.9e+146) tmp = t_0; elseif (d3 <= 190000000000.0) 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 * (d2 - d3); tmp = 0.0; if (d3 <= -2.9e+146) tmp = t_0; elseif (d3 <= 190000000000.0) 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[(d2 - d3), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d3, -2.9e+146], t$95$0, If[LessEqual[d3, 190000000000.0], N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := d1 \cdot \left(d2 - d3\right)\\
\mathbf{if}\;d3 \leq -2.9 \cdot 10^{+146}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d3 \leq 190000000000:\\
\;\;\;\;d1 \cdot \left(d2 + d4\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d3 < -2.8999999999999998e146 or 1.9e11 < d3 Initial program 87.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
associate-+r-N/A
+-commutativeN/A
unsub-negN/A
associate--l-N/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64100.0%
Simplified100.0%
+-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
--lowering--.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f6492.9%
Applied egg-rr92.9%
Taylor expanded in d4 around 0
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
distribute-lft-out--N/A
*-lowering-*.f64N/A
--lowering--.f64N/A
+-lowering-+.f6486.1%
Simplified86.1%
Taylor expanded in d1 around 0
remove-double-negN/A
distribute-rgt-neg-outN/A
mul-1-negN/A
distribute-rgt-neg-inN/A
*-rgt-identityN/A
*-inversesN/A
associate-/l*N/A
associate-*l/N/A
associate-*r/N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-commutativeN/A
associate-*r/N/A
associate-*l/N/A
associate-/l*N/A
*-inversesN/A
*-rgt-identityN/A
sub-negN/A
distribute-lft-inN/A
mul-1-negN/A
remove-double-negN/A
Simplified79.4%
if -2.8999999999999998e146 < d3 < 1.9e11Initial program 85.3%
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
associate-+r-N/A
+-commutativeN/A
unsub-negN/A
associate--l-N/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64100.0%
Simplified100.0%
Taylor expanded in d4 around inf
Simplified68.3%
(FPCore (d1 d2 d3 d4) :precision binary64 (let* ((t_0 (- 0.0 (* d1 d3)))) (if (<= d3 -1.25e+156) t_0 (if (<= d3 4.6e+66) (* d1 (+ d2 d4)) t_0))))
double code(double d1, double d2, double d3, double d4) {
double t_0 = 0.0 - (d1 * d3);
double tmp;
if (d3 <= -1.25e+156) {
tmp = t_0;
} else if (d3 <= 4.6e+66) {
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 = 0.0d0 - (d1 * d3)
if (d3 <= (-1.25d+156)) then
tmp = t_0
else if (d3 <= 4.6d+66) 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 = 0.0 - (d1 * d3);
double tmp;
if (d3 <= -1.25e+156) {
tmp = t_0;
} else if (d3 <= 4.6e+66) {
tmp = d1 * (d2 + d4);
} else {
tmp = t_0;
}
return tmp;
}
def code(d1, d2, d3, d4): t_0 = 0.0 - (d1 * d3) tmp = 0 if d3 <= -1.25e+156: tmp = t_0 elif d3 <= 4.6e+66: tmp = d1 * (d2 + d4) else: tmp = t_0 return tmp
function code(d1, d2, d3, d4) t_0 = Float64(0.0 - Float64(d1 * d3)) tmp = 0.0 if (d3 <= -1.25e+156) tmp = t_0; elseif (d3 <= 4.6e+66) tmp = Float64(d1 * Float64(d2 + d4)); else tmp = t_0; end return tmp end
function tmp_2 = code(d1, d2, d3, d4) t_0 = 0.0 - (d1 * d3); tmp = 0.0; if (d3 <= -1.25e+156) tmp = t_0; elseif (d3 <= 4.6e+66) tmp = d1 * (d2 + d4); else tmp = t_0; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := Block[{t$95$0 = N[(0.0 - N[(d1 * d3), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d3, -1.25e+156], t$95$0, If[LessEqual[d3, 4.6e+66], N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0 - d1 \cdot d3\\
\mathbf{if}\;d3 \leq -1.25 \cdot 10^{+156}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d3 \leq 4.6 \cdot 10^{+66}:\\
\;\;\;\;d1 \cdot \left(d2 + d4\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d3 < -1.24999999999999998e156 or 4.6e66 < d3 Initial program 87.0%
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
associate-+r-N/A
+-commutativeN/A
unsub-negN/A
associate--l-N/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-*.f6484.4%
Simplified84.4%
sub0-negN/A
neg-lowering-neg.f64N/A
*-lowering-*.f6484.4%
Applied egg-rr84.4%
if -1.24999999999999998e156 < d3 < 4.6e66Initial program 86.0%
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
associate-+r-N/A
+-commutativeN/A
unsub-negN/A
associate--l-N/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64100.0%
Simplified100.0%
Taylor expanded in d4 around inf
Simplified66.3%
Final simplification71.7%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 -2.85e-148) (* d1 d2) (if (<= d4 1.25e+107) (- 0.0 (* d1 d3)) (* d1 d4))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= -2.85e-148) {
tmp = d1 * d2;
} else if (d4 <= 1.25e+107) {
tmp = 0.0 - (d1 * 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 <= (-2.85d-148)) then
tmp = d1 * d2
else if (d4 <= 1.25d+107) then
tmp = 0.0d0 - (d1 * 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 <= -2.85e-148) {
tmp = d1 * d2;
} else if (d4 <= 1.25e+107) {
tmp = 0.0 - (d1 * d3);
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= -2.85e-148: tmp = d1 * d2 elif d4 <= 1.25e+107: tmp = 0.0 - (d1 * d3) else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= -2.85e-148) tmp = Float64(d1 * d2); elseif (d4 <= 1.25e+107) tmp = Float64(0.0 - Float64(d1 * d3)); else tmp = Float64(d1 * d4); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d4 <= -2.85e-148) tmp = d1 * d2; elseif (d4 <= 1.25e+107) tmp = 0.0 - (d1 * d3); else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, -2.85e-148], N[(d1 * d2), $MachinePrecision], If[LessEqual[d4, 1.25e+107], N[(0.0 - N[(d1 * d3), $MachinePrecision]), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq -2.85 \cdot 10^{-148}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d4 \leq 1.25 \cdot 10^{+107}:\\
\;\;\;\;0 - d1 \cdot d3\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d4 < -2.8499999999999999e-148Initial program 84.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
associate-+r-N/A
+-commutativeN/A
unsub-negN/A
associate--l-N/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64100.0%
Simplified100.0%
Taylor expanded in d2 around inf
*-lowering-*.f6426.8%
Simplified26.8%
if -2.8499999999999999e-148 < d4 < 1.25e107Initial program 88.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
associate-+r-N/A
+-commutativeN/A
unsub-negN/A
associate--l-N/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-*.f6443.5%
Simplified43.5%
sub0-negN/A
neg-lowering-neg.f64N/A
*-lowering-*.f6443.5%
Applied egg-rr43.5%
if 1.25e107 < d4 Initial program 84.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
associate-+r-N/A
+-commutativeN/A
unsub-negN/A
associate--l-N/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64100.0%
Simplified100.0%
Taylor expanded in d4 around inf
*-lowering-*.f6476.8%
Simplified76.8%
Final simplification41.8%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 4.5e-11) (* d1 (- d2 (+ d1 d3))) (* d1 (- d4 (+ d1 d3)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 4.5e-11) {
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 <= 4.5d-11) 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 <= 4.5e-11) {
tmp = d1 * (d2 - (d1 + d3));
} else {
tmp = d1 * (d4 - (d1 + d3));
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 4.5e-11: tmp = d1 * (d2 - (d1 + d3)) else: tmp = d1 * (d4 - (d1 + d3)) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 4.5e-11) 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 <= 4.5e-11) tmp = d1 * (d2 - (d1 + d3)); else tmp = d1 * (d4 - (d1 + d3)); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 4.5e-11], 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 4.5 \cdot 10^{-11}:\\
\;\;\;\;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 < 4.5e-11Initial program 87.0%
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
associate-+r-N/A
+-commutativeN/A
unsub-negN/A
associate--l-N/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64100.0%
Simplified100.0%
+-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
--lowering--.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f6493.5%
Applied egg-rr93.5%
Taylor expanded in d4 around 0
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
distribute-lft-out--N/A
*-lowering-*.f64N/A
--lowering--.f64N/A
+-lowering-+.f6487.9%
Simplified87.9%
if 4.5e-11 < d4 Initial program 83.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
associate-+r-N/A
+-commutativeN/A
unsub-negN/A
associate--l-N/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64100.0%
Simplified100.0%
Taylor expanded in d2 around 0
*-lowering-*.f64N/A
--lowering--.f64N/A
+-lowering-+.f6483.6%
Simplified83.6%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 0.017) (* d1 (- d2 (+ d1 d3))) (* d1 (+ d2 (- d4 d3)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 0.017) {
tmp = d1 * (d2 - (d1 + d3));
} else {
tmp = d1 * (d2 + (d4 - d3));
}
return tmp;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if (d4 <= 0.017d0) then
tmp = d1 * (d2 - (d1 + d3))
else
tmp = d1 * (d2 + (d4 - d3))
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 0.017) {
tmp = d1 * (d2 - (d1 + d3));
} else {
tmp = d1 * (d2 + (d4 - d3));
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 0.017: tmp = d1 * (d2 - (d1 + d3)) else: tmp = d1 * (d2 + (d4 - d3)) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 0.017) tmp = Float64(d1 * Float64(d2 - Float64(d1 + d3))); else tmp = Float64(d1 * Float64(d2 + Float64(d4 - d3))); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d4 <= 0.017) tmp = d1 * (d2 - (d1 + d3)); else tmp = d1 * (d2 + (d4 - d3)); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 0.017], N[(d1 * N[(d2 - N[(d1 + d3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d2 + N[(d4 - d3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 0.017:\\
\;\;\;\;d1 \cdot \left(d2 - \left(d1 + d3\right)\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d2 + \left(d4 - d3\right)\right)\\
\end{array}
\end{array}
if d4 < 0.017000000000000001Initial program 87.0%
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
associate-+r-N/A
+-commutativeN/A
unsub-negN/A
associate--l-N/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64100.0%
Simplified100.0%
+-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
--lowering--.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f6493.5%
Applied egg-rr93.5%
Taylor expanded in d4 around 0
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
distribute-lft-out--N/A
*-lowering-*.f64N/A
--lowering--.f64N/A
+-lowering-+.f6487.9%
Simplified87.9%
if 0.017000000000000001 < d4 Initial program 83.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
associate-+r-N/A
+-commutativeN/A
unsub-negN/A
associate--l-N/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64100.0%
Simplified100.0%
Taylor expanded in d1 around 0
*-lowering-*.f64N/A
sub-negN/A
mul-1-negN/A
associate-+r+N/A
+-lowering-+.f64N/A
mul-1-negN/A
sub-negN/A
--lowering--.f6489.7%
Simplified89.7%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 3.1e-7) (* d1 d2) (* d1 d4)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 3.1e-7) {
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.1d-7) 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.1e-7) {
tmp = d1 * d2;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 3.1e-7: tmp = d1 * d2 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 3.1e-7) 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.1e-7) tmp = d1 * d2; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 3.1e-7], N[(d1 * d2), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 3.1 \cdot 10^{-7}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d4 < 3.1e-7Initial program 87.0%
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
associate-+r-N/A
+-commutativeN/A
unsub-negN/A
associate--l-N/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64100.0%
Simplified100.0%
Taylor expanded in d2 around inf
*-lowering-*.f6432.1%
Simplified32.1%
if 3.1e-7 < d4 Initial program 83.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
associate-+r-N/A
+-commutativeN/A
unsub-negN/A
associate--l-N/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64100.0%
Simplified100.0%
Taylor expanded in d4 around inf
*-lowering-*.f6458.7%
Simplified58.7%
(FPCore (d1 d2 d3 d4) :precision binary64 (* d1 d2))
double code(double d1, double d2, double d3, double d4) {
return d1 * d2;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
code = d1 * d2
end function
public static double code(double d1, double d2, double d3, double d4) {
return d1 * d2;
}
def code(d1, d2, d3, d4): return d1 * d2
function code(d1, d2, d3, d4) return Float64(d1 * d2) end
function tmp = code(d1, d2, d3, d4) tmp = d1 * d2; end
code[d1_, d2_, d3_, d4_] := N[(d1 * d2), $MachinePrecision]
\begin{array}{l}
\\
d1 \cdot d2
\end{array}
Initial program 86.3%
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
associate-+r-N/A
+-commutativeN/A
unsub-negN/A
associate--l-N/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64100.0%
Simplified100.0%
Taylor expanded in d2 around inf
*-lowering-*.f6429.2%
Simplified29.2%
(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 2024139
(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)))