
(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 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%
(FPCore (x y z) :precision binary64 (if (or (<= y -2.2e+128) (not (<= y 4.4e+114))) (* 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.2e+128) || !(y <= 4.4e+114)) {
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.2e+128) || !(y <= 4.4e+114)) 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.2e+128], N[Not[LessEqual[y, 4.4e+114]], $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.2 \cdot 10^{+128} \lor \neg \left(y \leq 4.4 \cdot 10^{+114}\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.20000000000000017e128 or 4.4000000000000001e114 < y Initial program 99.8%
Taylor expanded in x around inf 76.9%
associate-/l*76.9%
+-commutative76.9%
associate--l+76.9%
Simplified76.9%
Taylor expanded in x around inf 76.9%
Taylor expanded in x around 0 92.8%
if -2.20000000000000017e128 < y < 4.4000000000000001e114Initial program 99.9%
+-commutative99.9%
fma-define100.0%
Simplified100.0%
Taylor expanded in z around inf 85.2%
neg-mul-185.2%
Simplified85.2%
Final simplification87.5%
(FPCore (x y z) :precision binary64 (if (<= z 2.9e-22) (+ (* x 0.5) (* x (* (+ z -1.0) (/ y x)))) (if (<= z 3.8e-9) (* y (+ 1.0 (log z))) (fma y (- z) (* x 0.5)))))
double code(double x, double y, double z) {
double tmp;
if (z <= 2.9e-22) {
tmp = (x * 0.5) + (x * ((z + -1.0) * (y / x)));
} else if (z <= 3.8e-9) {
tmp = 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 <= 2.9e-22) tmp = Float64(Float64(x * 0.5) + Float64(x * Float64(Float64(z + -1.0) * Float64(y / x)))); elseif (z <= 3.8e-9) tmp = 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, 2.9e-22], N[(N[(x * 0.5), $MachinePrecision] + N[(x * N[(N[(z + -1.0), $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 3.8e-9], N[(y * N[(1.0 + N[Log[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y * (-z) + N[(x * 0.5), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 2.9 \cdot 10^{-22}:\\
\;\;\;\;x \cdot 0.5 + x \cdot \left(\left(z + -1\right) \cdot \frac{y}{x}\right)\\
\mathbf{elif}\;z \leq 3.8 \cdot 10^{-9}:\\
\;\;\;\;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 < 2.9000000000000002e-22Initial program 99.8%
Taylor expanded in x around -inf 90.3%
mul-1-neg90.3%
distribute-rgt-neg-in90.3%
sub-neg90.3%
mul-1-neg90.3%
*-commutative90.3%
+-commutative90.3%
associate--l+90.3%
+-commutative90.3%
associate-/l*90.3%
distribute-lft-neg-in90.3%
associate-+l-90.3%
sub-neg90.3%
distribute-neg-in90.3%
metadata-eval90.3%
remove-double-neg90.3%
Simplified90.3%
Taylor expanded in z around inf 52.6%
distribute-neg-in52.6%
metadata-eval52.6%
distribute-rgt-in52.6%
distribute-rgt-neg-in52.6%
add-sqr-sqrt28.7%
sqrt-unprod54.8%
sqr-neg54.8%
sqrt-unprod27.1%
add-sqr-sqrt58.0%
distribute-frac-neg258.0%
frac-2neg58.0%
Applied egg-rr58.0%
if 2.9000000000000002e-22 < z < 3.80000000000000011e-9Initial program 99.3%
Taylor expanded in x around -inf 72.9%
mul-1-neg72.9%
distribute-rgt-neg-in72.9%
sub-neg72.9%
mul-1-neg72.9%
*-commutative72.9%
+-commutative72.9%
associate--l+72.9%
+-commutative72.9%
associate-/l*72.7%
distribute-lft-neg-in72.7%
associate-+l-72.7%
sub-neg72.7%
distribute-neg-in72.7%
metadata-eval72.7%
remove-double-neg72.7%
Simplified72.7%
Taylor expanded in x around 0 89.2%
Taylor expanded in z around 0 84.4%
neg-mul-184.4%
distribute-rgt-neg-in84.4%
distribute-neg-in84.4%
metadata-eval84.4%
sub-neg84.4%
Simplified84.4%
Taylor expanded in y around 0 84.4%
if 3.80000000000000011e-9 < z Initial program 100.0%
+-commutative100.0%
fma-define100.0%
Simplified100.0%
Taylor expanded in z around inf 98.9%
neg-mul-198.9%
Simplified98.9%
Final simplification79.6%
(FPCore (x y z) :precision binary64 (if (<= z 1.8e-22) (+ (* x 0.5) (* x (* (+ z -1.0) (/ y x)))) (if (<= z 2.95e-9) (* y (+ 1.0 (log z))) (- (* x 0.5) (* y z)))))
double code(double x, double y, double z) {
double tmp;
if (z <= 1.8e-22) {
tmp = (x * 0.5) + (x * ((z + -1.0) * (y / x)));
} else if (z <= 2.95e-9) {
tmp = y * (1.0 + log(z));
} 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) :: tmp
if (z <= 1.8d-22) then
tmp = (x * 0.5d0) + (x * ((z + (-1.0d0)) * (y / x)))
else if (z <= 2.95d-9) then
tmp = y * (1.0d0 + log(z))
else
tmp = (x * 0.5d0) - (y * z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= 1.8e-22) {
tmp = (x * 0.5) + (x * ((z + -1.0) * (y / x)));
} else if (z <= 2.95e-9) {
tmp = y * (1.0 + Math.log(z));
} else {
tmp = (x * 0.5) - (y * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= 1.8e-22: tmp = (x * 0.5) + (x * ((z + -1.0) * (y / x))) elif z <= 2.95e-9: tmp = y * (1.0 + math.log(z)) else: tmp = (x * 0.5) - (y * z) return tmp
function code(x, y, z) tmp = 0.0 if (z <= 1.8e-22) tmp = Float64(Float64(x * 0.5) + Float64(x * Float64(Float64(z + -1.0) * Float64(y / x)))); elseif (z <= 2.95e-9) tmp = Float64(y * Float64(1.0 + log(z))); else tmp = Float64(Float64(x * 0.5) - Float64(y * z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= 1.8e-22) tmp = (x * 0.5) + (x * ((z + -1.0) * (y / x))); elseif (z <= 2.95e-9) tmp = y * (1.0 + log(z)); else tmp = (x * 0.5) - (y * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, 1.8e-22], N[(N[(x * 0.5), $MachinePrecision] + N[(x * N[(N[(z + -1.0), $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 2.95e-9], N[(y * N[(1.0 + N[Log[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * 0.5), $MachinePrecision] - N[(y * z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 1.8 \cdot 10^{-22}:\\
\;\;\;\;x \cdot 0.5 + x \cdot \left(\left(z + -1\right) \cdot \frac{y}{x}\right)\\
\mathbf{elif}\;z \leq 2.95 \cdot 10^{-9}:\\
\;\;\;\;y \cdot \left(1 + \log z\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot 0.5 - y \cdot z\\
\end{array}
\end{array}
if z < 1.7999999999999999e-22Initial program 99.8%
Taylor expanded in x around -inf 90.3%
mul-1-neg90.3%
distribute-rgt-neg-in90.3%
sub-neg90.3%
mul-1-neg90.3%
*-commutative90.3%
+-commutative90.3%
associate--l+90.3%
+-commutative90.3%
associate-/l*90.3%
distribute-lft-neg-in90.3%
associate-+l-90.3%
sub-neg90.3%
distribute-neg-in90.3%
metadata-eval90.3%
remove-double-neg90.3%
Simplified90.3%
Taylor expanded in z around inf 52.6%
distribute-neg-in52.6%
metadata-eval52.6%
distribute-rgt-in52.6%
distribute-rgt-neg-in52.6%
add-sqr-sqrt28.7%
sqrt-unprod54.8%
sqr-neg54.8%
sqrt-unprod27.1%
add-sqr-sqrt58.0%
distribute-frac-neg258.0%
frac-2neg58.0%
Applied egg-rr58.0%
if 1.7999999999999999e-22 < z < 2.9499999999999999e-9Initial program 99.3%
Taylor expanded in x around -inf 72.9%
mul-1-neg72.9%
distribute-rgt-neg-in72.9%
sub-neg72.9%
mul-1-neg72.9%
*-commutative72.9%
+-commutative72.9%
associate--l+72.9%
+-commutative72.9%
associate-/l*72.7%
distribute-lft-neg-in72.7%
associate-+l-72.7%
sub-neg72.7%
distribute-neg-in72.7%
metadata-eval72.7%
remove-double-neg72.7%
Simplified72.7%
Taylor expanded in x around 0 89.2%
Taylor expanded in z around 0 84.4%
neg-mul-184.4%
distribute-rgt-neg-in84.4%
distribute-neg-in84.4%
metadata-eval84.4%
sub-neg84.4%
Simplified84.4%
Taylor expanded in y around 0 84.4%
if 2.9499999999999999e-9 < z Initial program 100.0%
+-commutative100.0%
fma-define100.0%
Simplified100.0%
Taylor expanded in z around inf 98.9%
neg-mul-198.9%
Simplified98.9%
Taylor expanded in y around 0 98.9%
+-commutative98.9%
*-commutative98.9%
mul-1-neg98.9%
unsub-neg98.9%
*-commutative98.9%
Simplified98.9%
Final simplification79.6%
(FPCore (x y z) :precision binary64 (if (<= z 0.027) (+ (* y (+ 1.0 (log z))) (* x 0.5)) (- (* x 0.5) (* y (+ z -1.0)))))
double code(double x, double y, double z) {
double tmp;
if (z <= 0.027) {
tmp = (y * (1.0 + log(z))) + (x * 0.5);
} else {
tmp = (x * 0.5) - (y * (z + -1.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) :: tmp
if (z <= 0.027d0) then
tmp = (y * (1.0d0 + log(z))) + (x * 0.5d0)
else
tmp = (x * 0.5d0) - (y * (z + (-1.0d0)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= 0.027) {
tmp = (y * (1.0 + Math.log(z))) + (x * 0.5);
} else {
tmp = (x * 0.5) - (y * (z + -1.0));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= 0.027: tmp = (y * (1.0 + math.log(z))) + (x * 0.5) else: tmp = (x * 0.5) - (y * (z + -1.0)) return tmp
function code(x, y, z) tmp = 0.0 if (z <= 0.027) tmp = Float64(Float64(y * Float64(1.0 + log(z))) + Float64(x * 0.5)); else tmp = Float64(Float64(x * 0.5) - Float64(y * Float64(z + -1.0))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= 0.027) tmp = (y * (1.0 + log(z))) + (x * 0.5); else tmp = (x * 0.5) - (y * (z + -1.0)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, 0.027], N[(N[(y * N[(1.0 + N[Log[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x * 0.5), $MachinePrecision]), $MachinePrecision], N[(N[(x * 0.5), $MachinePrecision] - N[(y * N[(z + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 0.027:\\
\;\;\;\;y \cdot \left(1 + \log z\right) + x \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;x \cdot 0.5 - y \cdot \left(z + -1\right)\\
\end{array}
\end{array}
if z < 0.0269999999999999997Initial program 99.8%
Taylor expanded in z around 0 98.7%
if 0.0269999999999999997 < z Initial program 100.0%
Taylor expanded in x around -inf 85.9%
mul-1-neg85.9%
distribute-rgt-neg-in85.9%
sub-neg85.9%
mul-1-neg85.9%
*-commutative85.9%
+-commutative85.9%
associate--l+85.9%
+-commutative85.9%
associate-/l*85.8%
distribute-lft-neg-in85.8%
associate-+l-85.8%
sub-neg85.8%
distribute-neg-in85.8%
metadata-eval85.8%
remove-double-neg85.8%
Simplified85.8%
Taylor expanded in z around inf 85.7%
Taylor expanded in x around 0 99.6%
mul-1-neg99.6%
+-commutative99.6%
sub-neg99.6%
sub-neg99.6%
metadata-eval99.6%
+-commutative99.6%
Simplified99.6%
Final simplification99.1%
(FPCore (x y z) :precision binary64 (+ (* y (+ (- 1.0 z) (log z))) (* x 0.5)))
double code(double x, double y, double z) {
return (y * ((1.0 - z) + log(z))) + (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 = (y * ((1.0d0 - z) + log(z))) + (x * 0.5d0)
end function
public static double code(double x, double y, double z) {
return (y * ((1.0 - z) + Math.log(z))) + (x * 0.5);
}
def code(x, y, z): return (y * ((1.0 - z) + math.log(z))) + (x * 0.5)
function code(x, y, z) return Float64(Float64(y * Float64(Float64(1.0 - z) + log(z))) + Float64(x * 0.5)) end
function tmp = code(x, y, z) tmp = (y * ((1.0 - z) + log(z))) + (x * 0.5); end
code[x_, y_, z_] := N[(N[(y * N[(N[(1.0 - z), $MachinePrecision] + N[Log[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x * 0.5), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
y \cdot \left(\left(1 - z\right) + \log z\right) + x \cdot 0.5
\end{array}
Initial program 99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (<= z 0.027) (+ (* x 0.5) (* x (* (+ z -1.0) (/ y x)))) (- (* x 0.5) (* y (+ z -1.0)))))
double code(double x, double y, double z) {
double tmp;
if (z <= 0.027) {
tmp = (x * 0.5) + (x * ((z + -1.0) * (y / x)));
} else {
tmp = (x * 0.5) - (y * (z + -1.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) :: tmp
if (z <= 0.027d0) then
tmp = (x * 0.5d0) + (x * ((z + (-1.0d0)) * (y / x)))
else
tmp = (x * 0.5d0) - (y * (z + (-1.0d0)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= 0.027) {
tmp = (x * 0.5) + (x * ((z + -1.0) * (y / x)));
} else {
tmp = (x * 0.5) - (y * (z + -1.0));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= 0.027: tmp = (x * 0.5) + (x * ((z + -1.0) * (y / x))) else: tmp = (x * 0.5) - (y * (z + -1.0)) return tmp
function code(x, y, z) tmp = 0.0 if (z <= 0.027) tmp = Float64(Float64(x * 0.5) + Float64(x * Float64(Float64(z + -1.0) * Float64(y / x)))); else tmp = Float64(Float64(x * 0.5) - Float64(y * Float64(z + -1.0))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= 0.027) tmp = (x * 0.5) + (x * ((z + -1.0) * (y / x))); else tmp = (x * 0.5) - (y * (z + -1.0)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, 0.027], N[(N[(x * 0.5), $MachinePrecision] + N[(x * N[(N[(z + -1.0), $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * 0.5), $MachinePrecision] - N[(y * N[(z + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 0.027:\\
\;\;\;\;x \cdot 0.5 + x \cdot \left(\left(z + -1\right) \cdot \frac{y}{x}\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot 0.5 - y \cdot \left(z + -1\right)\\
\end{array}
\end{array}
if z < 0.0269999999999999997Initial program 99.8%
Taylor expanded in x around -inf 89.7%
mul-1-neg89.7%
distribute-rgt-neg-in89.7%
sub-neg89.7%
mul-1-neg89.7%
*-commutative89.7%
+-commutative89.7%
associate--l+89.7%
+-commutative89.7%
associate-/l*89.7%
distribute-lft-neg-in89.7%
associate-+l-89.7%
sub-neg89.7%
distribute-neg-in89.7%
metadata-eval89.7%
remove-double-neg89.7%
Simplified89.7%
Taylor expanded in z around inf 50.5%
distribute-neg-in50.5%
metadata-eval50.5%
distribute-rgt-in50.5%
distribute-rgt-neg-in50.5%
add-sqr-sqrt27.8%
sqrt-unprod52.7%
sqr-neg52.7%
sqrt-unprod25.9%
add-sqr-sqrt56.2%
distribute-frac-neg256.2%
frac-2neg56.2%
Applied egg-rr56.2%
if 0.0269999999999999997 < z Initial program 100.0%
Taylor expanded in x around -inf 85.9%
mul-1-neg85.9%
distribute-rgt-neg-in85.9%
sub-neg85.9%
mul-1-neg85.9%
*-commutative85.9%
+-commutative85.9%
associate--l+85.9%
+-commutative85.9%
associate-/l*85.8%
distribute-lft-neg-in85.8%
associate-+l-85.8%
sub-neg85.8%
distribute-neg-in85.8%
metadata-eval85.8%
remove-double-neg85.8%
Simplified85.8%
Taylor expanded in z around inf 85.7%
Taylor expanded in x around 0 99.6%
mul-1-neg99.6%
+-commutative99.6%
sub-neg99.6%
sub-neg99.6%
metadata-eval99.6%
+-commutative99.6%
Simplified99.6%
Final simplification77.7%
(FPCore (x y z) :precision binary64 (if (<= z 0.027) (* x (- (* (+ z -1.0) (/ y x)) -0.5)) (- (* x 0.5) (* y (+ z -1.0)))))
double code(double x, double y, double z) {
double tmp;
if (z <= 0.027) {
tmp = x * (((z + -1.0) * (y / x)) - -0.5);
} else {
tmp = (x * 0.5) - (y * (z + -1.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) :: tmp
if (z <= 0.027d0) then
tmp = x * (((z + (-1.0d0)) * (y / x)) - (-0.5d0))
else
tmp = (x * 0.5d0) - (y * (z + (-1.0d0)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= 0.027) {
tmp = x * (((z + -1.0) * (y / x)) - -0.5);
} else {
tmp = (x * 0.5) - (y * (z + -1.0));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= 0.027: tmp = x * (((z + -1.0) * (y / x)) - -0.5) else: tmp = (x * 0.5) - (y * (z + -1.0)) return tmp
function code(x, y, z) tmp = 0.0 if (z <= 0.027) tmp = Float64(x * Float64(Float64(Float64(z + -1.0) * Float64(y / x)) - -0.5)); else tmp = Float64(Float64(x * 0.5) - Float64(y * Float64(z + -1.0))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= 0.027) tmp = x * (((z + -1.0) * (y / x)) - -0.5); else tmp = (x * 0.5) - (y * (z + -1.0)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, 0.027], N[(x * N[(N[(N[(z + -1.0), $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision] - -0.5), $MachinePrecision]), $MachinePrecision], N[(N[(x * 0.5), $MachinePrecision] - N[(y * N[(z + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 0.027:\\
\;\;\;\;x \cdot \left(\left(z + -1\right) \cdot \frac{y}{x} - -0.5\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot 0.5 - y \cdot \left(z + -1\right)\\
\end{array}
\end{array}
if z < 0.0269999999999999997Initial program 99.8%
Taylor expanded in x around -inf 89.7%
mul-1-neg89.7%
distribute-rgt-neg-in89.7%
sub-neg89.7%
mul-1-neg89.7%
*-commutative89.7%
+-commutative89.7%
associate--l+89.7%
+-commutative89.7%
associate-/l*89.7%
distribute-lft-neg-in89.7%
associate-+l-89.7%
sub-neg89.7%
distribute-neg-in89.7%
metadata-eval89.7%
remove-double-neg89.7%
Simplified89.7%
Taylor expanded in z around inf 50.5%
distribute-neg-in50.5%
distribute-rgt-neg-in50.5%
add-sqr-sqrt27.8%
sqrt-unprod52.7%
sqr-neg52.7%
sqrt-unprod25.9%
add-sqr-sqrt56.2%
distribute-frac-neg256.2%
frac-2neg56.2%
sub-neg56.2%
Applied egg-rr56.2%
if 0.0269999999999999997 < z Initial program 100.0%
Taylor expanded in x around -inf 85.9%
mul-1-neg85.9%
distribute-rgt-neg-in85.9%
sub-neg85.9%
mul-1-neg85.9%
*-commutative85.9%
+-commutative85.9%
associate--l+85.9%
+-commutative85.9%
associate-/l*85.8%
distribute-lft-neg-in85.8%
associate-+l-85.8%
sub-neg85.8%
distribute-neg-in85.8%
metadata-eval85.8%
remove-double-neg85.8%
Simplified85.8%
Taylor expanded in z around inf 85.7%
Taylor expanded in x around 0 99.6%
mul-1-neg99.6%
+-commutative99.6%
sub-neg99.6%
sub-neg99.6%
metadata-eval99.6%
+-commutative99.6%
Simplified99.6%
Final simplification77.7%
(FPCore (x y z) :precision binary64 (if (<= z 8.5e+68) (* x 0.5) (* z (- y))))
double code(double x, double y, double z) {
double tmp;
if (z <= 8.5e+68) {
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 <= 8.5d+68) 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 <= 8.5e+68) {
tmp = x * 0.5;
} else {
tmp = z * -y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= 8.5e+68: tmp = x * 0.5 else: tmp = z * -y return tmp
function code(x, y, z) tmp = 0.0 if (z <= 8.5e+68) 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 <= 8.5e+68) tmp = x * 0.5; else tmp = z * -y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, 8.5e+68], N[(x * 0.5), $MachinePrecision], N[(z * (-y)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 8.5 \cdot 10^{+68}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(-y\right)\\
\end{array}
\end{array}
if z < 8.49999999999999966e68Initial program 99.8%
Taylor expanded in x around inf 53.4%
if 8.49999999999999966e68 < z Initial program 100.0%
+-commutative100.0%
fma-define100.0%
Simplified100.0%
Taylor expanded in z around inf 100.0%
neg-mul-1100.0%
Simplified100.0%
Taylor expanded in z around inf 100.0%
+-commutative100.0%
neg-mul-1100.0%
unsub-neg100.0%
associate-*r/100.0%
Simplified100.0%
Taylor expanded in x around 0 78.7%
neg-mul-178.7%
Simplified78.7%
Final simplification63.3%
(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%
+-commutative99.9%
fma-define99.9%
Simplified99.9%
Taylor expanded in z around inf 75.9%
neg-mul-175.9%
Simplified75.9%
Taylor expanded in y around 0 75.9%
+-commutative75.9%
*-commutative75.9%
mul-1-neg75.9%
unsub-neg75.9%
*-commutative75.9%
Simplified75.9%
Final simplification75.9%
(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 40.8%
Final simplification40.8%
(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 2024114
(FPCore (x y z)
:name "System.Random.MWC.Distributions:gamma from mwc-random-0.13.3.2"
:precision binary64
:alt
(! :herbie-platform default (- (+ y (* 1/2 x)) (* y (- z (log z)))))
(+ (* x 0.5) (* y (+ (- 1.0 z) (log z)))))