
(FPCore (x y z) :precision binary64 (+ (* x 0.5) (* y (+ (- 1.0 z) (log z)))))
double code(double x, double y, double z) {
return (x * 0.5) + (y * ((1.0 - z) + log(z)));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x * 0.5d0) + (y * ((1.0d0 - z) + log(z)))
end function
public static double code(double x, double y, double z) {
return (x * 0.5) + (y * ((1.0 - z) + Math.log(z)));
}
def code(x, y, z): return (x * 0.5) + (y * ((1.0 - z) + math.log(z)))
function code(x, y, z) return Float64(Float64(x * 0.5) + Float64(y * Float64(Float64(1.0 - z) + log(z)))) end
function tmp = code(x, y, z) tmp = (x * 0.5) + (y * ((1.0 - z) + log(z))); end
code[x_, y_, z_] := N[(N[(x * 0.5), $MachinePrecision] + N[(y * N[(N[(1.0 - z), $MachinePrecision] + N[Log[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot 0.5 + y \cdot \left(\left(1 - z\right) + \log z\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (+ (* x 0.5) (* y (+ (- 1.0 z) (log z)))))
double code(double x, double y, double z) {
return (x * 0.5) + (y * ((1.0 - z) + log(z)));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x * 0.5d0) + (y * ((1.0d0 - z) + log(z)))
end function
public static double code(double x, double y, double z) {
return (x * 0.5) + (y * ((1.0 - z) + Math.log(z)));
}
def code(x, y, z): return (x * 0.5) + (y * ((1.0 - z) + math.log(z)))
function code(x, y, z) return Float64(Float64(x * 0.5) + Float64(y * Float64(Float64(1.0 - z) + log(z)))) end
function tmp = code(x, y, z) tmp = (x * 0.5) + (y * ((1.0 - z) + log(z))); end
code[x_, y_, z_] := N[(N[(x * 0.5), $MachinePrecision] + N[(y * N[(N[(1.0 - z), $MachinePrecision] + N[Log[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot 0.5 + y \cdot \left(\left(1 - z\right) + \log z\right)
\end{array}
(FPCore (x y z) :precision binary64 (fma (+ 1.0 (- (log z) z)) y (* x 0.5)))
double code(double x, double y, double z) {
return fma((1.0 + (log(z) - z)), y, (x * 0.5));
}
function code(x, y, z) return fma(Float64(1.0 + Float64(log(z) - z)), y, Float64(x * 0.5)) end
code[x_, y_, z_] := N[(N[(1.0 + N[(N[Log[z], $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision] * y + N[(x * 0.5), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(1 + \left(\log z - z\right), y, x \cdot 0.5\right)
\end{array}
Initial program 99.8%
+-commutative99.8%
*-commutative99.8%
fma-def99.8%
sub-neg99.8%
associate-+l+99.8%
+-commutative99.8%
sub-neg99.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* y (+ (log z) 1.0))) (t_1 (- (* x 0.5) (* z y))))
(if (<= z 3.2e-282)
t_0
(if (<= z 3.6e-238)
t_1
(if (<= z 3.5e-222)
t_0
(if (<= z 3.6e-191)
t_1
(if (<= z 9e-164)
(+ y (* (log z) y))
(if (<= z 1.15e-53)
t_1
(if (<= z 2.1e-9) t_0 (fma (- z) y (* x 0.5)))))))))))
double code(double x, double y, double z) {
double t_0 = y * (log(z) + 1.0);
double t_1 = (x * 0.5) - (z * y);
double tmp;
if (z <= 3.2e-282) {
tmp = t_0;
} else if (z <= 3.6e-238) {
tmp = t_1;
} else if (z <= 3.5e-222) {
tmp = t_0;
} else if (z <= 3.6e-191) {
tmp = t_1;
} else if (z <= 9e-164) {
tmp = y + (log(z) * y);
} else if (z <= 1.15e-53) {
tmp = t_1;
} else if (z <= 2.1e-9) {
tmp = t_0;
} else {
tmp = fma(-z, y, (x * 0.5));
}
return tmp;
}
function code(x, y, z) t_0 = Float64(y * Float64(log(z) + 1.0)) t_1 = Float64(Float64(x * 0.5) - Float64(z * y)) tmp = 0.0 if (z <= 3.2e-282) tmp = t_0; elseif (z <= 3.6e-238) tmp = t_1; elseif (z <= 3.5e-222) tmp = t_0; elseif (z <= 3.6e-191) tmp = t_1; elseif (z <= 9e-164) tmp = Float64(y + Float64(log(z) * y)); elseif (z <= 1.15e-53) tmp = t_1; elseif (z <= 2.1e-9) tmp = t_0; else tmp = fma(Float64(-z), y, Float64(x * 0.5)); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(N[Log[z], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x * 0.5), $MachinePrecision] - N[(z * y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, 3.2e-282], t$95$0, If[LessEqual[z, 3.6e-238], t$95$1, If[LessEqual[z, 3.5e-222], t$95$0, If[LessEqual[z, 3.6e-191], t$95$1, If[LessEqual[z, 9e-164], N[(y + N[(N[Log[z], $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.15e-53], t$95$1, If[LessEqual[z, 2.1e-9], t$95$0, N[((-z) * y + N[(x * 0.5), $MachinePrecision]), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \left(\log z + 1\right)\\
t_1 := x \cdot 0.5 - z \cdot y\\
\mathbf{if}\;z \leq 3.2 \cdot 10^{-282}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 3.6 \cdot 10^{-238}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq 3.5 \cdot 10^{-222}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 3.6 \cdot 10^{-191}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq 9 \cdot 10^{-164}:\\
\;\;\;\;y + \log z \cdot y\\
\mathbf{elif}\;z \leq 1.15 \cdot 10^{-53}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq 2.1 \cdot 10^{-9}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-z, y, x \cdot 0.5\right)\\
\end{array}
\end{array}
if z < 3.19999999999999983e-282 or 3.6000000000000001e-238 < z < 3.50000000000000024e-222 or 1.1500000000000001e-53 < z < 2.10000000000000019e-9Initial program 99.5%
sub-neg99.5%
associate-+l+99.5%
distribute-lft-in99.4%
*-rgt-identity99.4%
associate-+r+99.4%
fma-def99.4%
+-commutative99.4%
unsub-neg99.4%
Simplified99.4%
Taylor expanded in z around 0 98.1%
Taylor expanded in y around inf 84.0%
if 3.19999999999999983e-282 < z < 3.6000000000000001e-238 or 3.50000000000000024e-222 < z < 3.60000000000000019e-191 or 8.9999999999999995e-164 < z < 1.1500000000000001e-53Initial program 99.8%
Taylor expanded in z around inf 69.2%
mul-1-neg69.2%
distribute-rgt-neg-out69.2%
Simplified69.2%
fma-def69.2%
distribute-rgt-neg-out69.2%
add-sqr-sqrt69.2%
sqrt-unprod69.2%
sqr-neg69.2%
sqrt-unprod0.0%
add-sqr-sqrt68.6%
fma-neg68.6%
*-commutative68.6%
add-sqr-sqrt0.0%
sqrt-unprod69.2%
sqr-neg69.2%
sqrt-unprod69.2%
add-sqr-sqrt69.2%
Applied egg-rr69.2%
if 3.60000000000000019e-191 < z < 8.9999999999999995e-164Initial program 99.5%
sub-neg99.5%
associate-+l+99.5%
distribute-lft-in99.7%
*-rgt-identity99.7%
associate-+r+99.7%
fma-def99.7%
+-commutative99.7%
unsub-neg99.7%
Simplified99.7%
Taylor expanded in z around 0 99.7%
Taylor expanded in x around 0 72.9%
if 2.10000000000000019e-9 < z Initial program 100.0%
+-commutative100.0%
*-commutative100.0%
fma-def100.0%
sub-neg100.0%
associate-+l+100.0%
+-commutative100.0%
sub-neg100.0%
Applied egg-rr100.0%
Taylor expanded in z around inf 98.2%
neg-mul-198.2%
Simplified98.2%
Final simplification86.9%
(FPCore (x y z)
:precision binary64
(if (or (<= z 5.2e-283)
(and (not (<= z 5.6e-238))
(or (<= z 4.6e-222)
(and (not (<= z 4.4e-191))
(or (<= z 3e-163)
(and (not (<= z 1.05e-52)) (<= z 2.4e-9)))))))
(* y (+ (log z) 1.0))
(- (* x 0.5) (* z y))))
double code(double x, double y, double z) {
double tmp;
if ((z <= 5.2e-283) || (!(z <= 5.6e-238) && ((z <= 4.6e-222) || (!(z <= 4.4e-191) && ((z <= 3e-163) || (!(z <= 1.05e-52) && (z <= 2.4e-9))))))) {
tmp = y * (log(z) + 1.0);
} else {
tmp = (x * 0.5) - (z * y);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z <= 5.2d-283) .or. (.not. (z <= 5.6d-238)) .and. (z <= 4.6d-222) .or. (.not. (z <= 4.4d-191)) .and. (z <= 3d-163) .or. (.not. (z <= 1.05d-52)) .and. (z <= 2.4d-9)) then
tmp = y * (log(z) + 1.0d0)
else
tmp = (x * 0.5d0) - (z * y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= 5.2e-283) || (!(z <= 5.6e-238) && ((z <= 4.6e-222) || (!(z <= 4.4e-191) && ((z <= 3e-163) || (!(z <= 1.05e-52) && (z <= 2.4e-9))))))) {
tmp = y * (Math.log(z) + 1.0);
} else {
tmp = (x * 0.5) - (z * y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= 5.2e-283) or (not (z <= 5.6e-238) and ((z <= 4.6e-222) or (not (z <= 4.4e-191) and ((z <= 3e-163) or (not (z <= 1.05e-52) and (z <= 2.4e-9)))))): tmp = y * (math.log(z) + 1.0) else: tmp = (x * 0.5) - (z * y) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= 5.2e-283) || (!(z <= 5.6e-238) && ((z <= 4.6e-222) || (!(z <= 4.4e-191) && ((z <= 3e-163) || (!(z <= 1.05e-52) && (z <= 2.4e-9))))))) tmp = Float64(y * Float64(log(z) + 1.0)); else tmp = Float64(Float64(x * 0.5) - Float64(z * y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= 5.2e-283) || (~((z <= 5.6e-238)) && ((z <= 4.6e-222) || (~((z <= 4.4e-191)) && ((z <= 3e-163) || (~((z <= 1.05e-52)) && (z <= 2.4e-9))))))) tmp = y * (log(z) + 1.0); else tmp = (x * 0.5) - (z * y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, 5.2e-283], And[N[Not[LessEqual[z, 5.6e-238]], $MachinePrecision], Or[LessEqual[z, 4.6e-222], And[N[Not[LessEqual[z, 4.4e-191]], $MachinePrecision], Or[LessEqual[z, 3e-163], And[N[Not[LessEqual[z, 1.05e-52]], $MachinePrecision], LessEqual[z, 2.4e-9]]]]]]], N[(y * N[(N[Log[z], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(x * 0.5), $MachinePrecision] - N[(z * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 5.2 \cdot 10^{-283} \lor \neg \left(z \leq 5.6 \cdot 10^{-238}\right) \land \left(z \leq 4.6 \cdot 10^{-222} \lor \neg \left(z \leq 4.4 \cdot 10^{-191}\right) \land \left(z \leq 3 \cdot 10^{-163} \lor \neg \left(z \leq 1.05 \cdot 10^{-52}\right) \land z \leq 2.4 \cdot 10^{-9}\right)\right):\\
\;\;\;\;y \cdot \left(\log z + 1\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot 0.5 - z \cdot y\\
\end{array}
\end{array}
if z < 5.2000000000000002e-283 or 5.60000000000000008e-238 < z < 4.6000000000000003e-222 or 4.39999999999999996e-191 < z < 3.0000000000000002e-163 or 1.0499999999999999e-52 < z < 2.4e-9Initial program 99.5%
sub-neg99.5%
associate-+l+99.5%
distribute-lft-in99.5%
*-rgt-identity99.5%
associate-+r+99.5%
fma-def99.5%
+-commutative99.5%
unsub-neg99.5%
Simplified99.5%
Taylor expanded in z around 0 98.7%
Taylor expanded in y around inf 79.9%
if 5.2000000000000002e-283 < z < 5.60000000000000008e-238 or 4.6000000000000003e-222 < z < 4.39999999999999996e-191 or 3.0000000000000002e-163 < z < 1.0499999999999999e-52 or 2.4e-9 < z Initial program 99.9%
Taylor expanded in z around inf 88.6%
mul-1-neg88.6%
distribute-rgt-neg-out88.6%
Simplified88.6%
fma-def88.6%
distribute-rgt-neg-out88.6%
add-sqr-sqrt88.3%
sqrt-unprod67.3%
sqr-neg67.3%
sqrt-unprod0.0%
add-sqr-sqrt39.6%
fma-neg39.6%
*-commutative39.6%
add-sqr-sqrt0.0%
sqrt-unprod67.3%
sqr-neg67.3%
sqrt-unprod88.3%
add-sqr-sqrt88.6%
Applied egg-rr88.6%
Final simplification86.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* y (+ (log z) 1.0))) (t_1 (- (* x 0.5) (* z y))))
(if (<= z 6.5e-282)
t_0
(if (<= z 6.6e-238)
t_1
(if (<= z 3.4e-220)
t_0
(if (<= z 2.45e-191)
t_1
(if (<= z 2.2e-163)
(+ y (* (log z) y))
(if (or (<= z 2.55e-53) (not (<= z 3.4e-9))) t_1 t_0))))))))
double code(double x, double y, double z) {
double t_0 = y * (log(z) + 1.0);
double t_1 = (x * 0.5) - (z * y);
double tmp;
if (z <= 6.5e-282) {
tmp = t_0;
} else if (z <= 6.6e-238) {
tmp = t_1;
} else if (z <= 3.4e-220) {
tmp = t_0;
} else if (z <= 2.45e-191) {
tmp = t_1;
} else if (z <= 2.2e-163) {
tmp = y + (log(z) * y);
} else if ((z <= 2.55e-53) || !(z <= 3.4e-9)) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = y * (log(z) + 1.0d0)
t_1 = (x * 0.5d0) - (z * y)
if (z <= 6.5d-282) then
tmp = t_0
else if (z <= 6.6d-238) then
tmp = t_1
else if (z <= 3.4d-220) then
tmp = t_0
else if (z <= 2.45d-191) then
tmp = t_1
else if (z <= 2.2d-163) then
tmp = y + (log(z) * y)
else if ((z <= 2.55d-53) .or. (.not. (z <= 3.4d-9))) then
tmp = t_1
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = y * (Math.log(z) + 1.0);
double t_1 = (x * 0.5) - (z * y);
double tmp;
if (z <= 6.5e-282) {
tmp = t_0;
} else if (z <= 6.6e-238) {
tmp = t_1;
} else if (z <= 3.4e-220) {
tmp = t_0;
} else if (z <= 2.45e-191) {
tmp = t_1;
} else if (z <= 2.2e-163) {
tmp = y + (Math.log(z) * y);
} else if ((z <= 2.55e-53) || !(z <= 3.4e-9)) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = y * (math.log(z) + 1.0) t_1 = (x * 0.5) - (z * y) tmp = 0 if z <= 6.5e-282: tmp = t_0 elif z <= 6.6e-238: tmp = t_1 elif z <= 3.4e-220: tmp = t_0 elif z <= 2.45e-191: tmp = t_1 elif z <= 2.2e-163: tmp = y + (math.log(z) * y) elif (z <= 2.55e-53) or not (z <= 3.4e-9): tmp = t_1 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(y * Float64(log(z) + 1.0)) t_1 = Float64(Float64(x * 0.5) - Float64(z * y)) tmp = 0.0 if (z <= 6.5e-282) tmp = t_0; elseif (z <= 6.6e-238) tmp = t_1; elseif (z <= 3.4e-220) tmp = t_0; elseif (z <= 2.45e-191) tmp = t_1; elseif (z <= 2.2e-163) tmp = Float64(y + Float64(log(z) * y)); elseif ((z <= 2.55e-53) || !(z <= 3.4e-9)) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = y * (log(z) + 1.0); t_1 = (x * 0.5) - (z * y); tmp = 0.0; if (z <= 6.5e-282) tmp = t_0; elseif (z <= 6.6e-238) tmp = t_1; elseif (z <= 3.4e-220) tmp = t_0; elseif (z <= 2.45e-191) tmp = t_1; elseif (z <= 2.2e-163) tmp = y + (log(z) * y); elseif ((z <= 2.55e-53) || ~((z <= 3.4e-9))) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(N[Log[z], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x * 0.5), $MachinePrecision] - N[(z * y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, 6.5e-282], t$95$0, If[LessEqual[z, 6.6e-238], t$95$1, If[LessEqual[z, 3.4e-220], t$95$0, If[LessEqual[z, 2.45e-191], t$95$1, If[LessEqual[z, 2.2e-163], N[(y + N[(N[Log[z], $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[z, 2.55e-53], N[Not[LessEqual[z, 3.4e-9]], $MachinePrecision]], t$95$1, t$95$0]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \left(\log z + 1\right)\\
t_1 := x \cdot 0.5 - z \cdot y\\
\mathbf{if}\;z \leq 6.5 \cdot 10^{-282}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 6.6 \cdot 10^{-238}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq 3.4 \cdot 10^{-220}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 2.45 \cdot 10^{-191}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq 2.2 \cdot 10^{-163}:\\
\;\;\;\;y + \log z \cdot y\\
\mathbf{elif}\;z \leq 2.55 \cdot 10^{-53} \lor \neg \left(z \leq 3.4 \cdot 10^{-9}\right):\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if z < 6.50000000000000012e-282 or 6.59999999999999939e-238 < z < 3.39999999999999993e-220 or 2.55000000000000022e-53 < z < 3.3999999999999998e-9Initial program 99.5%
sub-neg99.5%
associate-+l+99.5%
distribute-lft-in99.4%
*-rgt-identity99.4%
associate-+r+99.4%
fma-def99.4%
+-commutative99.4%
unsub-neg99.4%
Simplified99.4%
Taylor expanded in z around 0 98.1%
Taylor expanded in y around inf 84.0%
if 6.50000000000000012e-282 < z < 6.59999999999999939e-238 or 3.39999999999999993e-220 < z < 2.45e-191 or 2.20000000000000011e-163 < z < 2.55000000000000022e-53 or 3.3999999999999998e-9 < z Initial program 99.9%
Taylor expanded in z around inf 88.6%
mul-1-neg88.6%
distribute-rgt-neg-out88.6%
Simplified88.6%
fma-def88.6%
distribute-rgt-neg-out88.6%
add-sqr-sqrt88.3%
sqrt-unprod67.3%
sqr-neg67.3%
sqrt-unprod0.0%
add-sqr-sqrt39.6%
fma-neg39.6%
*-commutative39.6%
add-sqr-sqrt0.0%
sqrt-unprod67.3%
sqr-neg67.3%
sqrt-unprod88.3%
add-sqr-sqrt88.6%
Applied egg-rr88.6%
if 2.45e-191 < z < 2.20000000000000011e-163Initial program 99.5%
sub-neg99.5%
associate-+l+99.5%
distribute-lft-in99.7%
*-rgt-identity99.7%
associate-+r+99.7%
fma-def99.7%
+-commutative99.7%
unsub-neg99.7%
Simplified99.7%
Taylor expanded in z around 0 99.7%
Taylor expanded in x around 0 72.9%
Final simplification86.9%
(FPCore (x y z)
:precision binary64
(if (<= (* x 0.5) -5e-58)
(fma (- z) y (* x 0.5))
(if (<= (* x 0.5) 1e+17)
(* y (- (+ (log z) 1.0) z))
(- (* x 0.5) (* z y)))))
double code(double x, double y, double z) {
double tmp;
if ((x * 0.5) <= -5e-58) {
tmp = fma(-z, y, (x * 0.5));
} else if ((x * 0.5) <= 1e+17) {
tmp = y * ((log(z) + 1.0) - z);
} else {
tmp = (x * 0.5) - (z * y);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (Float64(x * 0.5) <= -5e-58) tmp = fma(Float64(-z), y, Float64(x * 0.5)); elseif (Float64(x * 0.5) <= 1e+17) tmp = Float64(y * Float64(Float64(log(z) + 1.0) - z)); else tmp = Float64(Float64(x * 0.5) - Float64(z * y)); end return tmp end
code[x_, y_, z_] := If[LessEqual[N[(x * 0.5), $MachinePrecision], -5e-58], N[((-z) * y + N[(x * 0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * 0.5), $MachinePrecision], 1e+17], N[(y * N[(N[(N[Log[z], $MachinePrecision] + 1.0), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision], N[(N[(x * 0.5), $MachinePrecision] - N[(z * y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot 0.5 \leq -5 \cdot 10^{-58}:\\
\;\;\;\;\mathsf{fma}\left(-z, y, x \cdot 0.5\right)\\
\mathbf{elif}\;x \cdot 0.5 \leq 10^{+17}:\\
\;\;\;\;y \cdot \left(\left(\log z + 1\right) - z\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot 0.5 - z \cdot y\\
\end{array}
\end{array}
if (*.f64 x 1/2) < -4.99999999999999977e-58Initial program 99.8%
+-commutative99.8%
*-commutative99.8%
fma-def99.9%
sub-neg99.9%
associate-+l+99.9%
+-commutative99.9%
sub-neg99.9%
Applied egg-rr99.9%
Taylor expanded in z around inf 90.5%
neg-mul-190.5%
Simplified90.5%
if -4.99999999999999977e-58 < (*.f64 x 1/2) < 1e17Initial program 99.8%
+-commutative99.8%
*-commutative99.8%
fma-def99.8%
sub-neg99.8%
associate-+l+99.8%
+-commutative99.8%
sub-neg99.8%
Applied egg-rr99.8%
Taylor expanded in y around inf 89.4%
if 1e17 < (*.f64 x 1/2) Initial program 99.9%
Taylor expanded in z around inf 88.1%
mul-1-neg88.1%
distribute-rgt-neg-out88.1%
Simplified88.1%
fma-def88.1%
distribute-rgt-neg-out88.1%
add-sqr-sqrt87.8%
sqrt-unprod71.3%
sqr-neg71.3%
sqrt-unprod0.0%
add-sqr-sqrt52.8%
fma-neg52.8%
*-commutative52.8%
add-sqr-sqrt0.0%
sqrt-unprod71.3%
sqr-neg71.3%
sqrt-unprod87.8%
add-sqr-sqrt88.1%
Applied egg-rr88.1%
Final simplification89.5%
(FPCore (x y z)
:precision binary64
(if (<= (* x 0.5) -5e-58)
(fma (- z) y (* x 0.5))
(if (<= (* x 0.5) 1e+17)
(* y (+ 1.0 (- (log z) z)))
(- (* x 0.5) (* z y)))))
double code(double x, double y, double z) {
double tmp;
if ((x * 0.5) <= -5e-58) {
tmp = fma(-z, y, (x * 0.5));
} else if ((x * 0.5) <= 1e+17) {
tmp = y * (1.0 + (log(z) - z));
} else {
tmp = (x * 0.5) - (z * y);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (Float64(x * 0.5) <= -5e-58) tmp = fma(Float64(-z), y, Float64(x * 0.5)); elseif (Float64(x * 0.5) <= 1e+17) tmp = Float64(y * Float64(1.0 + Float64(log(z) - z))); else tmp = Float64(Float64(x * 0.5) - Float64(z * y)); end return tmp end
code[x_, y_, z_] := If[LessEqual[N[(x * 0.5), $MachinePrecision], -5e-58], N[((-z) * y + N[(x * 0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * 0.5), $MachinePrecision], 1e+17], N[(y * N[(1.0 + N[(N[Log[z], $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * 0.5), $MachinePrecision] - N[(z * y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot 0.5 \leq -5 \cdot 10^{-58}:\\
\;\;\;\;\mathsf{fma}\left(-z, y, x \cdot 0.5\right)\\
\mathbf{elif}\;x \cdot 0.5 \leq 10^{+17}:\\
\;\;\;\;y \cdot \left(1 + \left(\log z - z\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot 0.5 - z \cdot y\\
\end{array}
\end{array}
if (*.f64 x 1/2) < -4.99999999999999977e-58Initial program 99.8%
+-commutative99.8%
*-commutative99.8%
fma-def99.9%
sub-neg99.9%
associate-+l+99.9%
+-commutative99.9%
sub-neg99.9%
Applied egg-rr99.9%
Taylor expanded in z around inf 90.5%
neg-mul-190.5%
Simplified90.5%
if -4.99999999999999977e-58 < (*.f64 x 1/2) < 1e17Initial program 99.8%
sub-neg99.8%
associate-+l+99.8%
distribute-lft-in99.7%
*-rgt-identity99.7%
associate-+r+99.7%
fma-def99.7%
+-commutative99.7%
unsub-neg99.7%
Simplified99.7%
Taylor expanded in y around -inf 89.4%
mul-1-neg89.4%
distribute-rgt-neg-in89.4%
sub-neg89.4%
mul-1-neg89.4%
sub-neg89.4%
+-commutative89.4%
distribute-neg-in89.4%
remove-double-neg89.4%
sub-neg89.4%
metadata-eval89.4%
+-commutative89.4%
Simplified89.4%
if 1e17 < (*.f64 x 1/2) Initial program 99.9%
Taylor expanded in z around inf 88.1%
mul-1-neg88.1%
distribute-rgt-neg-out88.1%
Simplified88.1%
fma-def88.1%
distribute-rgt-neg-out88.1%
add-sqr-sqrt87.8%
sqrt-unprod71.3%
sqr-neg71.3%
sqrt-unprod0.0%
add-sqr-sqrt52.8%
fma-neg52.8%
*-commutative52.8%
add-sqr-sqrt0.0%
sqrt-unprod71.3%
sqr-neg71.3%
sqrt-unprod87.8%
add-sqr-sqrt88.1%
Applied egg-rr88.1%
Final simplification89.5%
(FPCore (x y z) :precision binary64 (if (<= z 0.013) (+ (* (log z) y) (+ y (* x 0.5))) (fma (- z) y (* x 0.5))))
double code(double x, double y, double z) {
double tmp;
if (z <= 0.013) {
tmp = (log(z) * y) + (y + (x * 0.5));
} else {
tmp = fma(-z, y, (x * 0.5));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (z <= 0.013) tmp = Float64(Float64(log(z) * y) + Float64(y + Float64(x * 0.5))); else tmp = fma(Float64(-z), y, Float64(x * 0.5)); end return tmp end
code[x_, y_, z_] := If[LessEqual[z, 0.013], N[(N[(N[Log[z], $MachinePrecision] * y), $MachinePrecision] + N[(y + N[(x * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-z) * y + N[(x * 0.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 0.013:\\
\;\;\;\;\log z \cdot y + \left(y + x \cdot 0.5\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-z, y, x \cdot 0.5\right)\\
\end{array}
\end{array}
if z < 0.0129999999999999994Initial program 99.7%
sub-neg99.7%
associate-+l+99.7%
distribute-lft-in99.7%
*-rgt-identity99.7%
associate-+r+99.7%
fma-def99.7%
+-commutative99.7%
unsub-neg99.7%
Simplified99.7%
Taylor expanded in z around 0 98.2%
if 0.0129999999999999994 < z Initial program 100.0%
+-commutative100.0%
*-commutative100.0%
fma-def100.0%
sub-neg100.0%
associate-+l+100.0%
+-commutative100.0%
sub-neg100.0%
Applied egg-rr100.0%
Taylor expanded in z around inf 99.4%
neg-mul-199.4%
Simplified99.4%
Final simplification98.8%
(FPCore (x y z) :precision binary64 (+ (* x 0.5) (* y (+ (log z) (- 1.0 z)))))
double code(double x, double y, double z) {
return (x * 0.5) + (y * (log(z) + (1.0 - z)));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x * 0.5d0) + (y * (log(z) + (1.0d0 - z)))
end function
public static double code(double x, double y, double z) {
return (x * 0.5) + (y * (Math.log(z) + (1.0 - z)));
}
def code(x, y, z): return (x * 0.5) + (y * (math.log(z) + (1.0 - z)))
function code(x, y, z) return Float64(Float64(x * 0.5) + Float64(y * Float64(log(z) + Float64(1.0 - z)))) end
function tmp = code(x, y, z) tmp = (x * 0.5) + (y * (log(z) + (1.0 - z))); end
code[x_, y_, z_] := N[(N[(x * 0.5), $MachinePrecision] + N[(y * N[(N[Log[z], $MachinePrecision] + N[(1.0 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot 0.5 + y \cdot \left(\log z + \left(1 - z\right)\right)
\end{array}
Initial program 99.8%
Final simplification99.8%
(FPCore (x y z) :precision binary64 (- (* x 0.5) (* z y)))
double code(double x, double y, double z) {
return (x * 0.5) - (z * y);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x * 0.5d0) - (z * y)
end function
public static double code(double x, double y, double z) {
return (x * 0.5) - (z * y);
}
def code(x, y, z): return (x * 0.5) - (z * y)
function code(x, y, z) return Float64(Float64(x * 0.5) - Float64(z * y)) end
function tmp = code(x, y, z) tmp = (x * 0.5) - (z * y); end
code[x_, y_, z_] := N[(N[(x * 0.5), $MachinePrecision] - N[(z * y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot 0.5 - z \cdot y
\end{array}
Initial program 99.8%
Taylor expanded in z around inf 75.3%
mul-1-neg75.3%
distribute-rgt-neg-out75.3%
Simplified75.3%
fma-def75.3%
distribute-rgt-neg-out75.3%
add-sqr-sqrt75.0%
sqrt-unprod58.1%
sqr-neg58.1%
sqrt-unprod0.0%
add-sqr-sqrt35.4%
fma-neg35.4%
*-commutative35.4%
add-sqr-sqrt0.0%
sqrt-unprod58.1%
sqr-neg58.1%
sqrt-unprod75.0%
add-sqr-sqrt75.3%
Applied egg-rr75.3%
Final simplification75.3%
(FPCore (x y z) :precision binary64 (if (<= z 16500000000000.0) (* x 0.5) (* z (- y))))
double code(double x, double y, double z) {
double tmp;
if (z <= 16500000000000.0) {
tmp = x * 0.5;
} else {
tmp = z * -y;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (z <= 16500000000000.0d0) then
tmp = x * 0.5d0
else
tmp = z * -y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= 16500000000000.0) {
tmp = x * 0.5;
} else {
tmp = z * -y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= 16500000000000.0: tmp = x * 0.5 else: tmp = z * -y return tmp
function code(x, y, z) tmp = 0.0 if (z <= 16500000000000.0) tmp = Float64(x * 0.5); else tmp = Float64(z * Float64(-y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= 16500000000000.0) tmp = x * 0.5; else tmp = z * -y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, 16500000000000.0], N[(x * 0.5), $MachinePrecision], N[(z * (-y)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 16500000000000:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(-y\right)\\
\end{array}
\end{array}
if z < 1.65e13Initial program 99.7%
Taylor expanded in x around inf 48.1%
if 1.65e13 < z Initial program 100.0%
+-commutative100.0%
*-commutative100.0%
fma-def100.0%
sub-neg100.0%
associate-+l+100.0%
+-commutative100.0%
sub-neg100.0%
Applied egg-rr100.0%
Taylor expanded in z around inf 75.9%
mul-1-neg75.9%
*-commutative75.9%
distribute-rgt-neg-in75.9%
Simplified75.9%
Final simplification62.3%
(FPCore (x y z) :precision binary64 (* x 0.5))
double code(double x, double y, double z) {
return x * 0.5;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x * 0.5d0
end function
public static double code(double x, double y, double z) {
return x * 0.5;
}
def code(x, y, z): return x * 0.5
function code(x, y, z) return Float64(x * 0.5) end
function tmp = code(x, y, z) tmp = x * 0.5; end
code[x_, y_, z_] := N[(x * 0.5), $MachinePrecision]
\begin{array}{l}
\\
x \cdot 0.5
\end{array}
Initial program 99.8%
Taylor expanded in x around inf 36.3%
Final simplification36.3%
(FPCore (x y z) :precision binary64 (- (+ y (* 0.5 x)) (* y (- z (log z)))))
double code(double x, double y, double z) {
return (y + (0.5 * x)) - (y * (z - log(z)));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (y + (0.5d0 * x)) - (y * (z - log(z)))
end function
public static double code(double x, double y, double z) {
return (y + (0.5 * x)) - (y * (z - Math.log(z)));
}
def code(x, y, z): return (y + (0.5 * x)) - (y * (z - math.log(z)))
function code(x, y, z) return Float64(Float64(y + Float64(0.5 * x)) - Float64(y * Float64(z - log(z)))) end
function tmp = code(x, y, z) tmp = (y + (0.5 * x)) - (y * (z - log(z))); end
code[x_, y_, z_] := N[(N[(y + N[(0.5 * x), $MachinePrecision]), $MachinePrecision] - N[(y * N[(z - N[Log[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(y + 0.5 \cdot x\right) - y \cdot \left(z - \log z\right)
\end{array}
herbie shell --seed 2023199
(FPCore (x y z)
:name "System.Random.MWC.Distributions:gamma from mwc-random-0.13.3.2"
:precision binary64
:herbie-target
(- (+ y (* 0.5 x)) (* y (- z (log z))))
(+ (* x 0.5) (* y (+ (- 1.0 z) (log z)))))