
(FPCore (d1 d2 d3) :precision binary64 (+ (+ (* d1 d2) (* (+ d3 5.0) d1)) (* d1 32.0)))
double code(double d1, double d2, double d3) {
return ((d1 * d2) + ((d3 + 5.0) * d1)) + (d1 * 32.0);
}
real(8) function code(d1, d2, d3)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
code = ((d1 * d2) + ((d3 + 5.0d0) * d1)) + (d1 * 32.0d0)
end function
public static double code(double d1, double d2, double d3) {
return ((d1 * d2) + ((d3 + 5.0) * d1)) + (d1 * 32.0);
}
def code(d1, d2, d3): return ((d1 * d2) + ((d3 + 5.0) * d1)) + (d1 * 32.0)
function code(d1, d2, d3) return Float64(Float64(Float64(d1 * d2) + Float64(Float64(d3 + 5.0) * d1)) + Float64(d1 * 32.0)) end
function tmp = code(d1, d2, d3) tmp = ((d1 * d2) + ((d3 + 5.0) * d1)) + (d1 * 32.0); end
code[d1_, d2_, d3_] := N[(N[(N[(d1 * d2), $MachinePrecision] + N[(N[(d3 + 5.0), $MachinePrecision] * d1), $MachinePrecision]), $MachinePrecision] + N[(d1 * 32.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(d1 \cdot d2 + \left(d3 + 5\right) \cdot d1\right) + d1 \cdot 32
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (d1 d2 d3) :precision binary64 (+ (+ (* d1 d2) (* (+ d3 5.0) d1)) (* d1 32.0)))
double code(double d1, double d2, double d3) {
return ((d1 * d2) + ((d3 + 5.0) * d1)) + (d1 * 32.0);
}
real(8) function code(d1, d2, d3)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
code = ((d1 * d2) + ((d3 + 5.0d0) * d1)) + (d1 * 32.0d0)
end function
public static double code(double d1, double d2, double d3) {
return ((d1 * d2) + ((d3 + 5.0) * d1)) + (d1 * 32.0);
}
def code(d1, d2, d3): return ((d1 * d2) + ((d3 + 5.0) * d1)) + (d1 * 32.0)
function code(d1, d2, d3) return Float64(Float64(Float64(d1 * d2) + Float64(Float64(d3 + 5.0) * d1)) + Float64(d1 * 32.0)) end
function tmp = code(d1, d2, d3) tmp = ((d1 * d2) + ((d3 + 5.0) * d1)) + (d1 * 32.0); end
code[d1_, d2_, d3_] := N[(N[(N[(d1 * d2), $MachinePrecision] + N[(N[(d3 + 5.0), $MachinePrecision] * d1), $MachinePrecision]), $MachinePrecision] + N[(d1 * 32.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(d1 \cdot d2 + \left(d3 + 5\right) \cdot d1\right) + d1 \cdot 32
\end{array}
NOTE: d2 and d3 should be sorted in increasing order before calling this function. (FPCore (d1 d2 d3) :precision binary64 (fma (+ d2 37.0) d1 (* d1 d3)))
assert(d2 < d3);
double code(double d1, double d2, double d3) {
return fma((d2 + 37.0), d1, (d1 * d3));
}
d2, d3 = sort([d2, d3]) function code(d1, d2, d3) return fma(Float64(d2 + 37.0), d1, Float64(d1 * d3)) end
NOTE: d2 and d3 should be sorted in increasing order before calling this function. code[d1_, d2_, d3_] := N[(N[(d2 + 37.0), $MachinePrecision] * d1 + N[(d1 * d3), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[d2, d3] = \mathsf{sort}([d2, d3])\\
\\
\mathsf{fma}\left(d2 + 37, d1, d1 \cdot d3\right)
\end{array}
Initial program 99.2%
+-commutative99.2%
+-commutative99.2%
*-commutative99.2%
distribute-lft-out100.0%
distribute-lft-out100.0%
remove-double-neg100.0%
sub-neg100.0%
sub-neg100.0%
remove-double-neg100.0%
associate-+r+100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
+-commutative100.0%
associate-+l+100.0%
metadata-eval100.0%
Simplified100.0%
distribute-rgt-in99.2%
fma-def99.6%
*-commutative99.6%
Applied egg-rr99.6%
Final simplification99.6%
NOTE: d2 and d3 should be sorted in increasing order before calling this function.
(FPCore (d1 d2 d3)
:precision binary64
(if (<= d3 -2.1e-282)
(* d2 d1)
(if (<= d3 6e-274)
(* 37.0 d1)
(if (<= d3 1.35e-240)
(* d2 d1)
(if (<= d3 1.08e-186)
(* 37.0 d1)
(if (<= d3 1.06e-135)
(* d2 d1)
(if (<= d3 5.5e-5) (* 37.0 d1) (* d1 d3))))))))assert(d2 < d3);
double code(double d1, double d2, double d3) {
double tmp;
if (d3 <= -2.1e-282) {
tmp = d2 * d1;
} else if (d3 <= 6e-274) {
tmp = 37.0 * d1;
} else if (d3 <= 1.35e-240) {
tmp = d2 * d1;
} else if (d3 <= 1.08e-186) {
tmp = 37.0 * d1;
} else if (d3 <= 1.06e-135) {
tmp = d2 * d1;
} else if (d3 <= 5.5e-5) {
tmp = 37.0 * d1;
} else {
tmp = d1 * d3;
}
return tmp;
}
NOTE: d2 and d3 should be sorted in increasing order before calling this function.
real(8) function code(d1, d2, d3)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8) :: tmp
if (d3 <= (-2.1d-282)) then
tmp = d2 * d1
else if (d3 <= 6d-274) then
tmp = 37.0d0 * d1
else if (d3 <= 1.35d-240) then
tmp = d2 * d1
else if (d3 <= 1.08d-186) then
tmp = 37.0d0 * d1
else if (d3 <= 1.06d-135) then
tmp = d2 * d1
else if (d3 <= 5.5d-5) then
tmp = 37.0d0 * d1
else
tmp = d1 * d3
end if
code = tmp
end function
assert d2 < d3;
public static double code(double d1, double d2, double d3) {
double tmp;
if (d3 <= -2.1e-282) {
tmp = d2 * d1;
} else if (d3 <= 6e-274) {
tmp = 37.0 * d1;
} else if (d3 <= 1.35e-240) {
tmp = d2 * d1;
} else if (d3 <= 1.08e-186) {
tmp = 37.0 * d1;
} else if (d3 <= 1.06e-135) {
tmp = d2 * d1;
} else if (d3 <= 5.5e-5) {
tmp = 37.0 * d1;
} else {
tmp = d1 * d3;
}
return tmp;
}
[d2, d3] = sort([d2, d3]) def code(d1, d2, d3): tmp = 0 if d3 <= -2.1e-282: tmp = d2 * d1 elif d3 <= 6e-274: tmp = 37.0 * d1 elif d3 <= 1.35e-240: tmp = d2 * d1 elif d3 <= 1.08e-186: tmp = 37.0 * d1 elif d3 <= 1.06e-135: tmp = d2 * d1 elif d3 <= 5.5e-5: tmp = 37.0 * d1 else: tmp = d1 * d3 return tmp
d2, d3 = sort([d2, d3]) function code(d1, d2, d3) tmp = 0.0 if (d3 <= -2.1e-282) tmp = Float64(d2 * d1); elseif (d3 <= 6e-274) tmp = Float64(37.0 * d1); elseif (d3 <= 1.35e-240) tmp = Float64(d2 * d1); elseif (d3 <= 1.08e-186) tmp = Float64(37.0 * d1); elseif (d3 <= 1.06e-135) tmp = Float64(d2 * d1); elseif (d3 <= 5.5e-5) tmp = Float64(37.0 * d1); else tmp = Float64(d1 * d3); end return tmp end
d2, d3 = num2cell(sort([d2, d3])){:}
function tmp_2 = code(d1, d2, d3)
tmp = 0.0;
if (d3 <= -2.1e-282)
tmp = d2 * d1;
elseif (d3 <= 6e-274)
tmp = 37.0 * d1;
elseif (d3 <= 1.35e-240)
tmp = d2 * d1;
elseif (d3 <= 1.08e-186)
tmp = 37.0 * d1;
elseif (d3 <= 1.06e-135)
tmp = d2 * d1;
elseif (d3 <= 5.5e-5)
tmp = 37.0 * d1;
else
tmp = d1 * d3;
end
tmp_2 = tmp;
end
NOTE: d2 and d3 should be sorted in increasing order before calling this function. code[d1_, d2_, d3_] := If[LessEqual[d3, -2.1e-282], N[(d2 * d1), $MachinePrecision], If[LessEqual[d3, 6e-274], N[(37.0 * d1), $MachinePrecision], If[LessEqual[d3, 1.35e-240], N[(d2 * d1), $MachinePrecision], If[LessEqual[d3, 1.08e-186], N[(37.0 * d1), $MachinePrecision], If[LessEqual[d3, 1.06e-135], N[(d2 * d1), $MachinePrecision], If[LessEqual[d3, 5.5e-5], N[(37.0 * d1), $MachinePrecision], N[(d1 * d3), $MachinePrecision]]]]]]]
\begin{array}{l}
[d2, d3] = \mathsf{sort}([d2, d3])\\
\\
\begin{array}{l}
\mathbf{if}\;d3 \leq -2.1 \cdot 10^{-282}:\\
\;\;\;\;d2 \cdot d1\\
\mathbf{elif}\;d3 \leq 6 \cdot 10^{-274}:\\
\;\;\;\;37 \cdot d1\\
\mathbf{elif}\;d3 \leq 1.35 \cdot 10^{-240}:\\
\;\;\;\;d2 \cdot d1\\
\mathbf{elif}\;d3 \leq 1.08 \cdot 10^{-186}:\\
\;\;\;\;37 \cdot d1\\
\mathbf{elif}\;d3 \leq 1.06 \cdot 10^{-135}:\\
\;\;\;\;d2 \cdot d1\\
\mathbf{elif}\;d3 \leq 5.5 \cdot 10^{-5}:\\
\;\;\;\;37 \cdot d1\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d3\\
\end{array}
\end{array}
if d3 < -2.10000000000000012e-282 or 5.99999999999999954e-274 < d3 < 1.35000000000000009e-240 or 1.08e-186 < d3 < 1.06000000000000004e-135Initial program 99.3%
+-commutative99.3%
+-commutative99.3%
*-commutative99.3%
distribute-lft-out100.0%
distribute-lft-out100.0%
remove-double-neg100.0%
sub-neg100.0%
sub-neg100.0%
remove-double-neg100.0%
associate-+r+100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
+-commutative100.0%
associate-+l+100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in d2 around inf 42.3%
if -2.10000000000000012e-282 < d3 < 5.99999999999999954e-274 or 1.35000000000000009e-240 < d3 < 1.08e-186 or 1.06000000000000004e-135 < d3 < 5.5000000000000002e-5Initial program 99.9%
+-commutative99.9%
+-commutative99.9%
*-commutative99.9%
distribute-lft-out99.9%
distribute-lft-out100.0%
remove-double-neg100.0%
sub-neg100.0%
sub-neg100.0%
remove-double-neg100.0%
associate-+r+100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
+-commutative100.0%
associate-+l+100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in d3 around 0 100.0%
Taylor expanded in d2 around 0 66.7%
if 5.5000000000000002e-5 < d3 Initial program 98.0%
+-commutative98.0%
+-commutative98.0%
*-commutative98.0%
distribute-lft-out100.0%
distribute-lft-out100.0%
remove-double-neg100.0%
sub-neg100.0%
sub-neg100.0%
remove-double-neg100.0%
associate-+r+100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
+-commutative100.0%
associate-+l+100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in d3 around inf 84.9%
Final simplification55.1%
NOTE: d2 and d3 should be sorted in increasing order before calling this function. (FPCore (d1 d2 d3) :precision binary64 (if (<= d3 1.3e+23) (* (+ d2 37.0) d1) (* d1 d3)))
assert(d2 < d3);
double code(double d1, double d2, double d3) {
double tmp;
if (d3 <= 1.3e+23) {
tmp = (d2 + 37.0) * d1;
} else {
tmp = d1 * d3;
}
return tmp;
}
NOTE: d2 and d3 should be sorted in increasing order before calling this function.
real(8) function code(d1, d2, d3)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8) :: tmp
if (d3 <= 1.3d+23) then
tmp = (d2 + 37.0d0) * d1
else
tmp = d1 * d3
end if
code = tmp
end function
assert d2 < d3;
public static double code(double d1, double d2, double d3) {
double tmp;
if (d3 <= 1.3e+23) {
tmp = (d2 + 37.0) * d1;
} else {
tmp = d1 * d3;
}
return tmp;
}
[d2, d3] = sort([d2, d3]) def code(d1, d2, d3): tmp = 0 if d3 <= 1.3e+23: tmp = (d2 + 37.0) * d1 else: tmp = d1 * d3 return tmp
d2, d3 = sort([d2, d3]) function code(d1, d2, d3) tmp = 0.0 if (d3 <= 1.3e+23) tmp = Float64(Float64(d2 + 37.0) * d1); else tmp = Float64(d1 * d3); end return tmp end
d2, d3 = num2cell(sort([d2, d3])){:}
function tmp_2 = code(d1, d2, d3)
tmp = 0.0;
if (d3 <= 1.3e+23)
tmp = (d2 + 37.0) * d1;
else
tmp = d1 * d3;
end
tmp_2 = tmp;
end
NOTE: d2 and d3 should be sorted in increasing order before calling this function. code[d1_, d2_, d3_] := If[LessEqual[d3, 1.3e+23], N[(N[(d2 + 37.0), $MachinePrecision] * d1), $MachinePrecision], N[(d1 * d3), $MachinePrecision]]
\begin{array}{l}
[d2, d3] = \mathsf{sort}([d2, d3])\\
\\
\begin{array}{l}
\mathbf{if}\;d3 \leq 1.3 \cdot 10^{+23}:\\
\;\;\;\;\left(d2 + 37\right) \cdot d1\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d3\\
\end{array}
\end{array}
if d3 < 1.29999999999999996e23Initial program 99.5%
+-commutative99.5%
+-commutative99.5%
*-commutative99.5%
distribute-lft-out100.0%
distribute-lft-out100.0%
remove-double-neg100.0%
sub-neg100.0%
sub-neg100.0%
remove-double-neg100.0%
associate-+r+100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
+-commutative100.0%
associate-+l+100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in d3 around 0 73.6%
if 1.29999999999999996e23 < d3 Initial program 97.9%
+-commutative97.9%
+-commutative97.9%
*-commutative97.9%
distribute-lft-out100.0%
distribute-lft-out100.0%
remove-double-neg100.0%
sub-neg100.0%
sub-neg100.0%
remove-double-neg100.0%
associate-+r+100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
+-commutative100.0%
associate-+l+100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in d3 around inf 88.4%
Final simplification76.4%
NOTE: d2 and d3 should be sorted in increasing order before calling this function. (FPCore (d1 d2 d3) :precision binary64 (if (<= d2 -2.8e+27) (* d2 d1) (* d1 (+ 37.0 d3))))
assert(d2 < d3);
double code(double d1, double d2, double d3) {
double tmp;
if (d2 <= -2.8e+27) {
tmp = d2 * d1;
} else {
tmp = d1 * (37.0 + d3);
}
return tmp;
}
NOTE: d2 and d3 should be sorted in increasing order before calling this function.
real(8) function code(d1, d2, d3)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8) :: tmp
if (d2 <= (-2.8d+27)) then
tmp = d2 * d1
else
tmp = d1 * (37.0d0 + d3)
end if
code = tmp
end function
assert d2 < d3;
public static double code(double d1, double d2, double d3) {
double tmp;
if (d2 <= -2.8e+27) {
tmp = d2 * d1;
} else {
tmp = d1 * (37.0 + d3);
}
return tmp;
}
[d2, d3] = sort([d2, d3]) def code(d1, d2, d3): tmp = 0 if d2 <= -2.8e+27: tmp = d2 * d1 else: tmp = d1 * (37.0 + d3) return tmp
d2, d3 = sort([d2, d3]) function code(d1, d2, d3) tmp = 0.0 if (d2 <= -2.8e+27) tmp = Float64(d2 * d1); else tmp = Float64(d1 * Float64(37.0 + d3)); end return tmp end
d2, d3 = num2cell(sort([d2, d3])){:}
function tmp_2 = code(d1, d2, d3)
tmp = 0.0;
if (d2 <= -2.8e+27)
tmp = d2 * d1;
else
tmp = d1 * (37.0 + d3);
end
tmp_2 = tmp;
end
NOTE: d2 and d3 should be sorted in increasing order before calling this function. code[d1_, d2_, d3_] := If[LessEqual[d2, -2.8e+27], N[(d2 * d1), $MachinePrecision], N[(d1 * N[(37.0 + d3), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[d2, d3] = \mathsf{sort}([d2, d3])\\
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -2.8 \cdot 10^{+27}:\\
\;\;\;\;d2 \cdot d1\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(37 + d3\right)\\
\end{array}
\end{array}
if d2 < -2.7999999999999999e27Initial program 100.0%
+-commutative100.0%
+-commutative100.0%
*-commutative100.0%
distribute-lft-out100.0%
distribute-lft-out100.0%
remove-double-neg100.0%
sub-neg100.0%
sub-neg100.0%
remove-double-neg100.0%
associate-+r+100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
+-commutative100.0%
associate-+l+100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in d2 around inf 83.9%
if -2.7999999999999999e27 < d2 Initial program 99.0%
+-commutative99.0%
+-commutative99.0%
*-commutative99.0%
distribute-lft-out100.0%
distribute-lft-out100.0%
remove-double-neg100.0%
sub-neg100.0%
sub-neg100.0%
remove-double-neg100.0%
associate-+r+100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
+-commutative100.0%
associate-+l+100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in d2 around 0 76.8%
Final simplification78.2%
NOTE: d2 and d3 should be sorted in increasing order before calling this function. (FPCore (d1 d2 d3) :precision binary64 (* d1 (+ (+ d2 37.0) d3)))
assert(d2 < d3);
double code(double d1, double d2, double d3) {
return d1 * ((d2 + 37.0) + d3);
}
NOTE: d2 and d3 should be sorted in increasing order before calling this function.
real(8) function code(d1, d2, d3)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
code = d1 * ((d2 + 37.0d0) + d3)
end function
assert d2 < d3;
public static double code(double d1, double d2, double d3) {
return d1 * ((d2 + 37.0) + d3);
}
[d2, d3] = sort([d2, d3]) def code(d1, d2, d3): return d1 * ((d2 + 37.0) + d3)
d2, d3 = sort([d2, d3]) function code(d1, d2, d3) return Float64(d1 * Float64(Float64(d2 + 37.0) + d3)) end
d2, d3 = num2cell(sort([d2, d3])){:}
function tmp = code(d1, d2, d3)
tmp = d1 * ((d2 + 37.0) + d3);
end
NOTE: d2 and d3 should be sorted in increasing order before calling this function. code[d1_, d2_, d3_] := N[(d1 * N[(N[(d2 + 37.0), $MachinePrecision] + d3), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[d2, d3] = \mathsf{sort}([d2, d3])\\
\\
d1 \cdot \left(\left(d2 + 37\right) + d3\right)
\end{array}
Initial program 99.2%
+-commutative99.2%
+-commutative99.2%
*-commutative99.2%
distribute-lft-out100.0%
distribute-lft-out100.0%
remove-double-neg100.0%
sub-neg100.0%
sub-neg100.0%
remove-double-neg100.0%
associate-+r+100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
+-commutative100.0%
associate-+l+100.0%
metadata-eval100.0%
Simplified100.0%
Final simplification100.0%
NOTE: d2 and d3 should be sorted in increasing order before calling this function. (FPCore (d1 d2 d3) :precision binary64 (if (<= d2 -3300.0) (* d2 d1) (* 37.0 d1)))
assert(d2 < d3);
double code(double d1, double d2, double d3) {
double tmp;
if (d2 <= -3300.0) {
tmp = d2 * d1;
} else {
tmp = 37.0 * d1;
}
return tmp;
}
NOTE: d2 and d3 should be sorted in increasing order before calling this function.
real(8) function code(d1, d2, d3)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8) :: tmp
if (d2 <= (-3300.0d0)) then
tmp = d2 * d1
else
tmp = 37.0d0 * d1
end if
code = tmp
end function
assert d2 < d3;
public static double code(double d1, double d2, double d3) {
double tmp;
if (d2 <= -3300.0) {
tmp = d2 * d1;
} else {
tmp = 37.0 * d1;
}
return tmp;
}
[d2, d3] = sort([d2, d3]) def code(d1, d2, d3): tmp = 0 if d2 <= -3300.0: tmp = d2 * d1 else: tmp = 37.0 * d1 return tmp
d2, d3 = sort([d2, d3]) function code(d1, d2, d3) tmp = 0.0 if (d2 <= -3300.0) tmp = Float64(d2 * d1); else tmp = Float64(37.0 * d1); end return tmp end
d2, d3 = num2cell(sort([d2, d3])){:}
function tmp_2 = code(d1, d2, d3)
tmp = 0.0;
if (d2 <= -3300.0)
tmp = d2 * d1;
else
tmp = 37.0 * d1;
end
tmp_2 = tmp;
end
NOTE: d2 and d3 should be sorted in increasing order before calling this function. code[d1_, d2_, d3_] := If[LessEqual[d2, -3300.0], N[(d2 * d1), $MachinePrecision], N[(37.0 * d1), $MachinePrecision]]
\begin{array}{l}
[d2, d3] = \mathsf{sort}([d2, d3])\\
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -3300:\\
\;\;\;\;d2 \cdot d1\\
\mathbf{else}:\\
\;\;\;\;37 \cdot d1\\
\end{array}
\end{array}
if d2 < -3300Initial program 98.1%
+-commutative98.1%
+-commutative98.1%
*-commutative98.1%
distribute-lft-out100.0%
distribute-lft-out100.0%
remove-double-neg100.0%
sub-neg100.0%
sub-neg100.0%
remove-double-neg100.0%
associate-+r+100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
+-commutative100.0%
associate-+l+100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in d2 around inf 77.9%
if -3300 < d2 Initial program 99.5%
+-commutative99.5%
+-commutative99.5%
*-commutative99.5%
distribute-lft-out100.0%
distribute-lft-out100.0%
remove-double-neg100.0%
sub-neg100.0%
sub-neg100.0%
remove-double-neg100.0%
associate-+r+100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
+-commutative100.0%
associate-+l+100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in d3 around 0 60.2%
Taylor expanded in d2 around 0 36.6%
Final simplification45.1%
NOTE: d2 and d3 should be sorted in increasing order before calling this function. (FPCore (d1 d2 d3) :precision binary64 (* 37.0 d1))
assert(d2 < d3);
double code(double d1, double d2, double d3) {
return 37.0 * d1;
}
NOTE: d2 and d3 should be sorted in increasing order before calling this function.
real(8) function code(d1, d2, d3)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
code = 37.0d0 * d1
end function
assert d2 < d3;
public static double code(double d1, double d2, double d3) {
return 37.0 * d1;
}
[d2, d3] = sort([d2, d3]) def code(d1, d2, d3): return 37.0 * d1
d2, d3 = sort([d2, d3]) function code(d1, d2, d3) return Float64(37.0 * d1) end
d2, d3 = num2cell(sort([d2, d3])){:}
function tmp = code(d1, d2, d3)
tmp = 37.0 * d1;
end
NOTE: d2 and d3 should be sorted in increasing order before calling this function. code[d1_, d2_, d3_] := N[(37.0 * d1), $MachinePrecision]
\begin{array}{l}
[d2, d3] = \mathsf{sort}([d2, d3])\\
\\
37 \cdot d1
\end{array}
Initial program 99.2%
+-commutative99.2%
+-commutative99.2%
*-commutative99.2%
distribute-lft-out100.0%
distribute-lft-out100.0%
remove-double-neg100.0%
sub-neg100.0%
sub-neg100.0%
remove-double-neg100.0%
associate-+r+100.0%
+-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
+-commutative100.0%
associate-+l+100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in d3 around 0 63.9%
Taylor expanded in d2 around 0 29.3%
Final simplification29.3%
(FPCore (d1 d2 d3) :precision binary64 (* d1 (+ (+ 37.0 d3) d2)))
double code(double d1, double d2, double d3) {
return d1 * ((37.0 + d3) + d2);
}
real(8) function code(d1, d2, d3)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
code = d1 * ((37.0d0 + d3) + d2)
end function
public static double code(double d1, double d2, double d3) {
return d1 * ((37.0 + d3) + d2);
}
def code(d1, d2, d3): return d1 * ((37.0 + d3) + d2)
function code(d1, d2, d3) return Float64(d1 * Float64(Float64(37.0 + d3) + d2)) end
function tmp = code(d1, d2, d3) tmp = d1 * ((37.0 + d3) + d2); end
code[d1_, d2_, d3_] := N[(d1 * N[(N[(37.0 + d3), $MachinePrecision] + d2), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
d1 \cdot \left(\left(37 + d3\right) + d2\right)
\end{array}
herbie shell --seed 2023293
(FPCore (d1 d2 d3)
:name "FastMath dist3"
:precision binary64
:herbie-target
(* d1 (+ (+ 37.0 d3) d2))
(+ (+ (* d1 d2) (* (+ d3 5.0) d1)) (* d1 32.0)))