
(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 10 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 y (+ (- 1.0 z) (log z)) (* x 0.5)))
double code(double x, double y, double z) {
return fma(y, ((1.0 - z) + log(z)), (x * 0.5));
}
function code(x, y, z) return fma(y, Float64(Float64(1.0 - z) + log(z)), Float64(x * 0.5)) end
code[x_, y_, z_] := N[(y * N[(N[(1.0 - z), $MachinePrecision] + N[Log[z], $MachinePrecision]), $MachinePrecision] + N[(x * 0.5), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(y, \left(1 - z\right) + \log z, x \cdot 0.5\right)
\end{array}
Initial program 99.9%
+-commutative99.9%
fma-define99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ y (* y (log z)))) (t_1 (* x (- 0.5 (* z (/ y x))))))
(if (<= z 5.5e-297)
t_1
(if (<= z 1e-264)
t_0
(if (<= z 2.25e-256)
(* x 0.5)
(if (<= z 7e-190)
(* y (+ 1.0 (log z)))
(if (<= z 6.2e-157)
t_1
(if (<= z 7.2e-6) t_0 (fma y (- z) (* x 0.5))))))))))
double code(double x, double y, double z) {
double t_0 = y + (y * log(z));
double t_1 = x * (0.5 - (z * (y / x)));
double tmp;
if (z <= 5.5e-297) {
tmp = t_1;
} else if (z <= 1e-264) {
tmp = t_0;
} else if (z <= 2.25e-256) {
tmp = x * 0.5;
} else if (z <= 7e-190) {
tmp = y * (1.0 + log(z));
} else if (z <= 6.2e-157) {
tmp = t_1;
} else if (z <= 7.2e-6) {
tmp = t_0;
} else {
tmp = fma(y, -z, (x * 0.5));
}
return tmp;
}
function code(x, y, z) t_0 = Float64(y + Float64(y * log(z))) t_1 = Float64(x * Float64(0.5 - Float64(z * Float64(y / x)))) tmp = 0.0 if (z <= 5.5e-297) tmp = t_1; elseif (z <= 1e-264) tmp = t_0; elseif (z <= 2.25e-256) tmp = Float64(x * 0.5); elseif (z <= 7e-190) tmp = Float64(y * Float64(1.0 + log(z))); elseif (z <= 6.2e-157) tmp = t_1; elseif (z <= 7.2e-6) tmp = t_0; else tmp = fma(y, Float64(-z), Float64(x * 0.5)); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(y + N[(y * N[Log[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x * N[(0.5 - N[(z * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, 5.5e-297], t$95$1, If[LessEqual[z, 1e-264], t$95$0, If[LessEqual[z, 2.25e-256], N[(x * 0.5), $MachinePrecision], If[LessEqual[z, 7e-190], N[(y * N[(1.0 + N[Log[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 6.2e-157], t$95$1, If[LessEqual[z, 7.2e-6], t$95$0, N[(y * (-z) + N[(x * 0.5), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y + y \cdot \log z\\
t_1 := x \cdot \left(0.5 - z \cdot \frac{y}{x}\right)\\
\mathbf{if}\;z \leq 5.5 \cdot 10^{-297}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 10^{-264}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 2.25 \cdot 10^{-256}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;z \leq 7 \cdot 10^{-190}:\\
\;\;\;\;y \cdot \left(1 + \log z\right)\\
\mathbf{elif}\;z \leq 6.2 \cdot 10^{-157}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 7.2 \cdot 10^{-6}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, -z, x \cdot 0.5\right)\\
\end{array}
\end{array}
if z < 5.5000000000000003e-297 or 6.9999999999999999e-190 < z < 6.1999999999999996e-157Initial program 100.0%
Taylor expanded in x around inf 88.0%
associate-/l*87.9%
+-commutative87.9%
associate--l+87.9%
Simplified87.9%
clear-num87.9%
un-div-inv87.9%
associate-+r-87.9%
+-commutative87.9%
associate--l+87.9%
Applied egg-rr87.9%
associate-/r/88.0%
Simplified88.0%
Taylor expanded in z around inf 74.1%
mul-1-neg74.1%
Simplified74.1%
distribute-rgt-neg-out74.1%
unsub-neg74.1%
*-commutative74.1%
Applied egg-rr74.1%
if 5.5000000000000003e-297 < z < 1e-264 or 6.1999999999999996e-157 < z < 7.19999999999999967e-6Initial program 99.7%
distribute-lft-in99.7%
Applied egg-rr99.7%
Taylor expanded in x around 0 67.8%
Taylor expanded in z around 0 65.8%
if 1e-264 < z < 2.2500000000000001e-256Initial program 100.0%
Taylor expanded in x around inf 100.0%
if 2.2500000000000001e-256 < z < 6.9999999999999999e-190Initial program 99.8%
distribute-lft-in99.5%
Applied egg-rr99.5%
Taylor expanded in x around 0 66.0%
Taylor expanded in z around 0 66.0%
*-commutative66.0%
distribute-rgt1-in66.2%
+-commutative66.2%
Applied egg-rr66.2%
if 7.19999999999999967e-6 < z Initial program 100.0%
+-commutative100.0%
fma-define100.0%
Simplified100.0%
Taylor expanded in z around inf 99.7%
mul-1-neg99.7%
Simplified99.7%
Final simplification85.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* y (+ 1.0 (log z)))) (t_1 (* x (- 0.5 (* z (/ y x))))))
(if (<= z 1.15e-296)
t_1
(if (<= z 5.6e-265)
t_0
(if (<= z 8e-256)
(* x 0.5)
(if (<= z 9.2e-189)
t_0
(if (<= z 8e-159)
t_1
(if (<= z 1.08e-5) t_0 (- (* x 0.5) (* y z))))))))))
double code(double x, double y, double z) {
double t_0 = y * (1.0 + log(z));
double t_1 = x * (0.5 - (z * (y / x)));
double tmp;
if (z <= 1.15e-296) {
tmp = t_1;
} else if (z <= 5.6e-265) {
tmp = t_0;
} else if (z <= 8e-256) {
tmp = x * 0.5;
} else if (z <= 9.2e-189) {
tmp = t_0;
} else if (z <= 8e-159) {
tmp = t_1;
} else if (z <= 1.08e-5) {
tmp = t_0;
} else {
tmp = (x * 0.5) - (y * z);
}
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 * (1.0d0 + log(z))
t_1 = x * (0.5d0 - (z * (y / x)))
if (z <= 1.15d-296) then
tmp = t_1
else if (z <= 5.6d-265) then
tmp = t_0
else if (z <= 8d-256) then
tmp = x * 0.5d0
else if (z <= 9.2d-189) then
tmp = t_0
else if (z <= 8d-159) then
tmp = t_1
else if (z <= 1.08d-5) then
tmp = t_0
else
tmp = (x * 0.5d0) - (y * z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = y * (1.0 + Math.log(z));
double t_1 = x * (0.5 - (z * (y / x)));
double tmp;
if (z <= 1.15e-296) {
tmp = t_1;
} else if (z <= 5.6e-265) {
tmp = t_0;
} else if (z <= 8e-256) {
tmp = x * 0.5;
} else if (z <= 9.2e-189) {
tmp = t_0;
} else if (z <= 8e-159) {
tmp = t_1;
} else if (z <= 1.08e-5) {
tmp = t_0;
} else {
tmp = (x * 0.5) - (y * z);
}
return tmp;
}
def code(x, y, z): t_0 = y * (1.0 + math.log(z)) t_1 = x * (0.5 - (z * (y / x))) tmp = 0 if z <= 1.15e-296: tmp = t_1 elif z <= 5.6e-265: tmp = t_0 elif z <= 8e-256: tmp = x * 0.5 elif z <= 9.2e-189: tmp = t_0 elif z <= 8e-159: tmp = t_1 elif z <= 1.08e-5: tmp = t_0 else: tmp = (x * 0.5) - (y * z) return tmp
function code(x, y, z) t_0 = Float64(y * Float64(1.0 + log(z))) t_1 = Float64(x * Float64(0.5 - Float64(z * Float64(y / x)))) tmp = 0.0 if (z <= 1.15e-296) tmp = t_1; elseif (z <= 5.6e-265) tmp = t_0; elseif (z <= 8e-256) tmp = Float64(x * 0.5); elseif (z <= 9.2e-189) tmp = t_0; elseif (z <= 8e-159) tmp = t_1; elseif (z <= 1.08e-5) tmp = t_0; else tmp = Float64(Float64(x * 0.5) - Float64(y * z)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = y * (1.0 + log(z)); t_1 = x * (0.5 - (z * (y / x))); tmp = 0.0; if (z <= 1.15e-296) tmp = t_1; elseif (z <= 5.6e-265) tmp = t_0; elseif (z <= 8e-256) tmp = x * 0.5; elseif (z <= 9.2e-189) tmp = t_0; elseif (z <= 8e-159) tmp = t_1; elseif (z <= 1.08e-5) tmp = t_0; else tmp = (x * 0.5) - (y * z); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(1.0 + N[Log[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x * N[(0.5 - N[(z * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, 1.15e-296], t$95$1, If[LessEqual[z, 5.6e-265], t$95$0, If[LessEqual[z, 8e-256], N[(x * 0.5), $MachinePrecision], If[LessEqual[z, 9.2e-189], t$95$0, If[LessEqual[z, 8e-159], t$95$1, If[LessEqual[z, 1.08e-5], t$95$0, N[(N[(x * 0.5), $MachinePrecision] - N[(y * z), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \left(1 + \log z\right)\\
t_1 := x \cdot \left(0.5 - z \cdot \frac{y}{x}\right)\\
\mathbf{if}\;z \leq 1.15 \cdot 10^{-296}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 5.6 \cdot 10^{-265}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 8 \cdot 10^{-256}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;z \leq 9.2 \cdot 10^{-189}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 8 \cdot 10^{-159}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 1.08 \cdot 10^{-5}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;x \cdot 0.5 - y \cdot z\\
\end{array}
\end{array}
if z < 1.15000000000000002e-296 or 9.1999999999999993e-189 < z < 7.99999999999999991e-159Initial program 100.0%
Taylor expanded in x around inf 88.0%
associate-/l*87.9%
+-commutative87.9%
associate--l+87.9%
Simplified87.9%
clear-num87.9%
un-div-inv87.9%
associate-+r-87.9%
+-commutative87.9%
associate--l+87.9%
Applied egg-rr87.9%
associate-/r/88.0%
Simplified88.0%
Taylor expanded in z around inf 74.1%
mul-1-neg74.1%
Simplified74.1%
distribute-rgt-neg-out74.1%
unsub-neg74.1%
*-commutative74.1%
Applied egg-rr74.1%
if 1.15000000000000002e-296 < z < 5.60000000000000047e-265 or 7.99999999999999982e-256 < z < 9.1999999999999993e-189 or 7.99999999999999991e-159 < z < 1.07999999999999999e-5Initial program 99.7%
distribute-lft-in99.6%
Applied egg-rr99.6%
Taylor expanded in x around 0 67.3%
Taylor expanded in z around 0 65.9%
*-commutative65.9%
distribute-rgt1-in65.9%
+-commutative65.9%
Applied egg-rr65.9%
if 5.60000000000000047e-265 < z < 7.99999999999999982e-256Initial program 100.0%
Taylor expanded in x around inf 100.0%
if 1.07999999999999999e-5 < z Initial program 100.0%
Taylor expanded in z around inf 99.6%
associate-*r*99.6%
mul-1-neg99.6%
Simplified99.6%
fma-define99.6%
distribute-lft-neg-out99.6%
add-log-exp43.9%
exp-neg43.8%
*-commutative43.8%
exp-prod29.5%
add-sqr-sqrt15.2%
sqrt-unprod28.5%
sqr-neg28.5%
sqrt-unprod0.7%
add-sqr-sqrt2.6%
exp-prod15.9%
*-commutative15.9%
neg-log15.9%
add-log-exp27.7%
fma-neg27.7%
Applied egg-rr99.6%
Final simplification85.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ y (* y (log z)))) (t_1 (* x (- 0.5 (* z (/ y x))))))
(if (<= z 8.5e-297)
t_1
(if (<= z 1.6e-264)
t_0
(if (<= z 6.2e-255)
(* x 0.5)
(if (<= z 1.45e-189)
(* y (+ 1.0 (log z)))
(if (<= z 1e-156)
t_1
(if (<= z 3.3e-5) t_0 (- (* x 0.5) (* y z))))))))))
double code(double x, double y, double z) {
double t_0 = y + (y * log(z));
double t_1 = x * (0.5 - (z * (y / x)));
double tmp;
if (z <= 8.5e-297) {
tmp = t_1;
} else if (z <= 1.6e-264) {
tmp = t_0;
} else if (z <= 6.2e-255) {
tmp = x * 0.5;
} else if (z <= 1.45e-189) {
tmp = y * (1.0 + log(z));
} else if (z <= 1e-156) {
tmp = t_1;
} else if (z <= 3.3e-5) {
tmp = t_0;
} else {
tmp = (x * 0.5) - (y * z);
}
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 + (y * log(z))
t_1 = x * (0.5d0 - (z * (y / x)))
if (z <= 8.5d-297) then
tmp = t_1
else if (z <= 1.6d-264) then
tmp = t_0
else if (z <= 6.2d-255) then
tmp = x * 0.5d0
else if (z <= 1.45d-189) then
tmp = y * (1.0d0 + log(z))
else if (z <= 1d-156) then
tmp = t_1
else if (z <= 3.3d-5) then
tmp = t_0
else
tmp = (x * 0.5d0) - (y * z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = y + (y * Math.log(z));
double t_1 = x * (0.5 - (z * (y / x)));
double tmp;
if (z <= 8.5e-297) {
tmp = t_1;
} else if (z <= 1.6e-264) {
tmp = t_0;
} else if (z <= 6.2e-255) {
tmp = x * 0.5;
} else if (z <= 1.45e-189) {
tmp = y * (1.0 + Math.log(z));
} else if (z <= 1e-156) {
tmp = t_1;
} else if (z <= 3.3e-5) {
tmp = t_0;
} else {
tmp = (x * 0.5) - (y * z);
}
return tmp;
}
def code(x, y, z): t_0 = y + (y * math.log(z)) t_1 = x * (0.5 - (z * (y / x))) tmp = 0 if z <= 8.5e-297: tmp = t_1 elif z <= 1.6e-264: tmp = t_0 elif z <= 6.2e-255: tmp = x * 0.5 elif z <= 1.45e-189: tmp = y * (1.0 + math.log(z)) elif z <= 1e-156: tmp = t_1 elif z <= 3.3e-5: tmp = t_0 else: tmp = (x * 0.5) - (y * z) return tmp
function code(x, y, z) t_0 = Float64(y + Float64(y * log(z))) t_1 = Float64(x * Float64(0.5 - Float64(z * Float64(y / x)))) tmp = 0.0 if (z <= 8.5e-297) tmp = t_1; elseif (z <= 1.6e-264) tmp = t_0; elseif (z <= 6.2e-255) tmp = Float64(x * 0.5); elseif (z <= 1.45e-189) tmp = Float64(y * Float64(1.0 + log(z))); elseif (z <= 1e-156) tmp = t_1; elseif (z <= 3.3e-5) tmp = t_0; else tmp = Float64(Float64(x * 0.5) - Float64(y * z)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = y + (y * log(z)); t_1 = x * (0.5 - (z * (y / x))); tmp = 0.0; if (z <= 8.5e-297) tmp = t_1; elseif (z <= 1.6e-264) tmp = t_0; elseif (z <= 6.2e-255) tmp = x * 0.5; elseif (z <= 1.45e-189) tmp = y * (1.0 + log(z)); elseif (z <= 1e-156) tmp = t_1; elseif (z <= 3.3e-5) tmp = t_0; else tmp = (x * 0.5) - (y * z); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y + N[(y * N[Log[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x * N[(0.5 - N[(z * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, 8.5e-297], t$95$1, If[LessEqual[z, 1.6e-264], t$95$0, If[LessEqual[z, 6.2e-255], N[(x * 0.5), $MachinePrecision], If[LessEqual[z, 1.45e-189], N[(y * N[(1.0 + N[Log[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1e-156], t$95$1, If[LessEqual[z, 3.3e-5], t$95$0, N[(N[(x * 0.5), $MachinePrecision] - N[(y * z), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y + y \cdot \log z\\
t_1 := x \cdot \left(0.5 - z \cdot \frac{y}{x}\right)\\
\mathbf{if}\;z \leq 8.5 \cdot 10^{-297}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 1.6 \cdot 10^{-264}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 6.2 \cdot 10^{-255}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;z \leq 1.45 \cdot 10^{-189}:\\
\;\;\;\;y \cdot \left(1 + \log z\right)\\
\mathbf{elif}\;z \leq 10^{-156}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 3.3 \cdot 10^{-5}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;x \cdot 0.5 - y \cdot z\\
\end{array}
\end{array}
if z < 8.49999999999999991e-297 or 1.45e-189 < z < 1.00000000000000004e-156Initial program 100.0%
Taylor expanded in x around inf 88.0%
associate-/l*87.9%
+-commutative87.9%
associate--l+87.9%
Simplified87.9%
clear-num87.9%
un-div-inv87.9%
associate-+r-87.9%
+-commutative87.9%
associate--l+87.9%
Applied egg-rr87.9%
associate-/r/88.0%
Simplified88.0%
Taylor expanded in z around inf 74.1%
mul-1-neg74.1%
Simplified74.1%
distribute-rgt-neg-out74.1%
unsub-neg74.1%
*-commutative74.1%
Applied egg-rr74.1%
if 8.49999999999999991e-297 < z < 1.59999999999999998e-264 or 1.00000000000000004e-156 < z < 3.3000000000000003e-5Initial program 99.7%
distribute-lft-in99.7%
Applied egg-rr99.7%
Taylor expanded in x around 0 67.8%
Taylor expanded in z around 0 65.8%
if 1.59999999999999998e-264 < z < 6.19999999999999995e-255Initial program 100.0%
Taylor expanded in x around inf 100.0%
if 6.19999999999999995e-255 < z < 1.45e-189Initial program 99.8%
distribute-lft-in99.5%
Applied egg-rr99.5%
Taylor expanded in x around 0 66.0%
Taylor expanded in z around 0 66.0%
*-commutative66.0%
distribute-rgt1-in66.2%
+-commutative66.2%
Applied egg-rr66.2%
if 3.3000000000000003e-5 < z Initial program 100.0%
Taylor expanded in z around inf 99.6%
associate-*r*99.6%
mul-1-neg99.6%
Simplified99.6%
fma-define99.6%
distribute-lft-neg-out99.6%
add-log-exp43.9%
exp-neg43.8%
*-commutative43.8%
exp-prod29.5%
add-sqr-sqrt15.2%
sqrt-unprod28.5%
sqr-neg28.5%
sqrt-unprod0.7%
add-sqr-sqrt2.6%
exp-prod15.9%
*-commutative15.9%
neg-log15.9%
add-log-exp27.7%
fma-neg27.7%
Applied egg-rr99.6%
Final simplification85.9%
(FPCore (x y z) :precision binary64 (if (or (<= y -2.8e+52) (not (<= y 1.9e-37))) (* y (- (+ 1.0 (log z)) z)) (fma y (- z) (* x 0.5))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -2.8e+52) || !(y <= 1.9e-37)) {
tmp = y * ((1.0 + log(z)) - z);
} else {
tmp = fma(y, -z, (x * 0.5));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if ((y <= -2.8e+52) || !(y <= 1.9e-37)) tmp = Float64(y * Float64(Float64(1.0 + log(z)) - z)); else tmp = fma(y, Float64(-z), Float64(x * 0.5)); end return tmp end
code[x_, y_, z_] := If[Or[LessEqual[y, -2.8e+52], N[Not[LessEqual[y, 1.9e-37]], $MachinePrecision]], N[(y * N[(N[(1.0 + N[Log[z], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision], N[(y * (-z) + N[(x * 0.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.8 \cdot 10^{+52} \lor \neg \left(y \leq 1.9 \cdot 10^{-37}\right):\\
\;\;\;\;y \cdot \left(\left(1 + \log z\right) - z\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, -z, x \cdot 0.5\right)\\
\end{array}
\end{array}
if y < -2.8e52 or 1.9000000000000002e-37 < y Initial program 99.8%
Taylor expanded in z around inf 76.0%
*-commutative76.0%
associate-/l*76.8%
distribute-lft-out76.8%
mul-1-neg76.8%
log-rec76.8%
remove-double-neg76.8%
Simplified76.8%
Taylor expanded in z around 0 99.0%
Taylor expanded in x around 0 88.8%
Taylor expanded in y around 0 89.6%
associate-+r+89.6%
mul-1-neg89.6%
sub-neg89.6%
Simplified89.6%
if -2.8e52 < y < 1.9000000000000002e-37Initial program 99.9%
+-commutative99.9%
fma-define100.0%
Simplified100.0%
Taylor expanded in z around inf 89.7%
mul-1-neg89.7%
Simplified89.7%
Final simplification89.6%
(FPCore (x y z) :precision binary64 (if (<= z 0.28) (+ (* x 0.5) (* y (+ 1.0 (log z)))) (fma y (- z) (* x 0.5))))
double code(double x, double y, double z) {
double tmp;
if (z <= 0.28) {
tmp = (x * 0.5) + (y * (1.0 + log(z)));
} else {
tmp = fma(y, -z, (x * 0.5));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (z <= 0.28) tmp = Float64(Float64(x * 0.5) + Float64(y * Float64(1.0 + log(z)))); else tmp = fma(y, Float64(-z), Float64(x * 0.5)); end return tmp end
code[x_, y_, z_] := If[LessEqual[z, 0.28], N[(N[(x * 0.5), $MachinePrecision] + N[(y * N[(1.0 + N[Log[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y * (-z) + N[(x * 0.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 0.28:\\
\;\;\;\;x \cdot 0.5 + y \cdot \left(1 + \log z\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, -z, x \cdot 0.5\right)\\
\end{array}
\end{array}
if z < 0.28000000000000003Initial program 99.8%
Taylor expanded in z around 0 98.7%
if 0.28000000000000003 < z Initial program 100.0%
+-commutative100.0%
fma-define100.0%
Simplified100.0%
Taylor expanded in z around inf 99.7%
mul-1-neg99.7%
Simplified99.7%
Final simplification99.2%
(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}
Initial program 99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (<= z 2.3e+39) (* x 0.5) (* y (- z))))
double code(double x, double y, double z) {
double tmp;
if (z <= 2.3e+39) {
tmp = x * 0.5;
} else {
tmp = y * -z;
}
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 <= 2.3d+39) then
tmp = x * 0.5d0
else
tmp = y * -z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= 2.3e+39) {
tmp = x * 0.5;
} else {
tmp = y * -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= 2.3e+39: tmp = x * 0.5 else: tmp = y * -z return tmp
function code(x, y, z) tmp = 0.0 if (z <= 2.3e+39) tmp = Float64(x * 0.5); else tmp = Float64(y * Float64(-z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= 2.3e+39) tmp = x * 0.5; else tmp = y * -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, 2.3e+39], N[(x * 0.5), $MachinePrecision], N[(y * (-z)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 2.3 \cdot 10^{+39}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(-z\right)\\
\end{array}
\end{array}
if z < 2.30000000000000012e39Initial program 99.8%
Taylor expanded in x around inf 49.5%
if 2.30000000000000012e39 < z Initial program 100.0%
Taylor expanded in z around inf 99.2%
*-commutative99.2%
associate-/l*100.0%
distribute-lft-out100.0%
mul-1-neg100.0%
log-rec100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in z around 0 99.2%
Taylor expanded in x around 0 76.9%
Taylor expanded in z around inf 77.7%
associate-*r*77.7%
mul-1-neg77.7%
Simplified77.7%
Final simplification63.4%
(FPCore (x y z) :precision binary64 (- (* x 0.5) (* y z)))
double code(double x, double y, double z) {
return (x * 0.5) - (y * 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 * z)
end function
public static double code(double x, double y, double z) {
return (x * 0.5) - (y * z);
}
def code(x, y, z): return (x * 0.5) - (y * z)
function code(x, y, z) return Float64(Float64(x * 0.5) - Float64(y * z)) end
function tmp = code(x, y, z) tmp = (x * 0.5) - (y * z); end
code[x_, y_, z_] := N[(N[(x * 0.5), $MachinePrecision] - N[(y * z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot 0.5 - y \cdot z
\end{array}
Initial program 99.9%
Taylor expanded in z around inf 75.8%
associate-*r*75.8%
mul-1-neg75.8%
Simplified75.8%
fma-define75.8%
distribute-lft-neg-out75.8%
add-log-exp44.8%
exp-neg44.8%
*-commutative44.8%
exp-prod36.9%
add-sqr-sqrt29.1%
sqrt-unprod36.4%
sqr-neg36.4%
sqrt-unprod21.1%
add-sqr-sqrt22.1%
exp-prod28.8%
*-commutative28.8%
neg-log28.8%
add-log-exp35.7%
fma-neg35.7%
Applied egg-rr75.8%
Final simplification75.8%
(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.9%
Taylor expanded in x around inf 36.6%
Final simplification36.6%
(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 2024080
(FPCore (x y z)
:name "System.Random.MWC.Distributions:gamma from mwc-random-0.13.3.2"
:precision binary64
:alt
(- (+ y (* 0.5 x)) (* y (- z (log z))))
(+ (* x 0.5) (* y (+ (- 1.0 z) (log z)))))