
(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 13 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.8%
+-commutative99.8%
fma-define99.8%
Simplified99.8%
(FPCore (x y z) :precision binary64 (fma x 0.5 (* y (+ 1.0 (- (log z) z)))))
double code(double x, double y, double z) {
return fma(x, 0.5, (y * (1.0 + (log(z) - z))));
}
function code(x, y, z) return fma(x, 0.5, Float64(y * Float64(1.0 + Float64(log(z) - z)))) end
code[x_, y_, z_] := N[(x * 0.5 + N[(y * N[(1.0 + N[(N[Log[z], $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(x, 0.5, y \cdot \left(1 + \left(\log z - z\right)\right)\right)
\end{array}
Initial program 99.8%
cancel-sign-sub99.8%
fma-neg99.8%
distribute-lft-neg-in99.8%
remove-double-neg99.8%
+-commutative99.8%
associate-+r-99.8%
+-commutative99.8%
associate--l+99.8%
Simplified99.8%
(FPCore (x y z) :precision binary64 (if (<= (* x 0.5) -5e-40) (* x (- 0.5 (* z (/ y x)))) (if (<= (* x 0.5) 5e+21) (+ y (* y (- (log z) z))) (- (* x 0.5) (* y z)))))
double code(double x, double y, double z) {
double tmp;
if ((x * 0.5) <= -5e-40) {
tmp = x * (0.5 - (z * (y / x)));
} else if ((x * 0.5) <= 5e+21) {
tmp = y + (y * (log(z) - 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 ((x * 0.5d0) <= (-5d-40)) then
tmp = x * (0.5d0 - (z * (y / x)))
else if ((x * 0.5d0) <= 5d+21) then
tmp = y + (y * (log(z) - 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 ((x * 0.5) <= -5e-40) {
tmp = x * (0.5 - (z * (y / x)));
} else if ((x * 0.5) <= 5e+21) {
tmp = y + (y * (Math.log(z) - z));
} else {
tmp = (x * 0.5) - (y * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x * 0.5) <= -5e-40: tmp = x * (0.5 - (z * (y / x))) elif (x * 0.5) <= 5e+21: tmp = y + (y * (math.log(z) - z)) else: tmp = (x * 0.5) - (y * z) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(x * 0.5) <= -5e-40) tmp = Float64(x * Float64(0.5 - Float64(z * Float64(y / x)))); elseif (Float64(x * 0.5) <= 5e+21) tmp = Float64(y + Float64(y * Float64(log(z) - 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 ((x * 0.5) <= -5e-40) tmp = x * (0.5 - (z * (y / x))); elseif ((x * 0.5) <= 5e+21) tmp = y + (y * (log(z) - z)); else tmp = (x * 0.5) - (y * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(x * 0.5), $MachinePrecision], -5e-40], N[(x * N[(0.5 - N[(z * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * 0.5), $MachinePrecision], 5e+21], N[(y + N[(y * N[(N[Log[z], $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * 0.5), $MachinePrecision] - N[(y * z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot 0.5 \leq -5 \cdot 10^{-40}:\\
\;\;\;\;x \cdot \left(0.5 - z \cdot \frac{y}{x}\right)\\
\mathbf{elif}\;x \cdot 0.5 \leq 5 \cdot 10^{+21}:\\
\;\;\;\;y + y \cdot \left(\log z - z\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot 0.5 - y \cdot z\\
\end{array}
\end{array}
if (*.f64 x #s(literal 1/2 binary64)) < -4.99999999999999965e-40Initial program 99.9%
+-commutative99.9%
fma-define99.9%
Simplified99.9%
Taylor expanded in z around inf 79.1%
neg-mul-179.1%
Simplified79.1%
Taylor expanded in x around inf 79.1%
associate-*r/79.1%
mul-1-neg79.1%
*-commutative79.1%
distribute-rgt-neg-in79.1%
Simplified79.1%
frac-2neg79.1%
*-commutative79.1%
neg-mul-179.1%
associate-*r*79.1%
distribute-frac-neg79.1%
associate-*r*79.1%
neg-mul-179.1%
add-sqr-sqrt36.8%
sqrt-unprod66.1%
sqr-neg66.1%
sqrt-unprod32.8%
add-sqr-sqrt62.3%
remove-double-neg62.3%
mul-1-neg62.3%
frac-2neg62.3%
associate-*r*62.3%
neg-mul-162.3%
*-commutative62.3%
associate-/l*62.3%
Applied egg-rr80.3%
if -4.99999999999999965e-40 < (*.f64 x #s(literal 1/2 binary64)) < 5e21Initial program 99.7%
cancel-sign-sub99.7%
fma-neg99.7%
distribute-lft-neg-in99.7%
remove-double-neg99.7%
+-commutative99.7%
associate-+r-99.7%
+-commutative99.7%
associate--l+99.7%
Simplified99.7%
fma-undefine99.7%
distribute-rgt-in99.8%
*-un-lft-identity99.8%
associate-+r+99.8%
Applied egg-rr99.8%
Taylor expanded in x around 0 89.9%
if 5e21 < (*.f64 x #s(literal 1/2 binary64)) Initial program 99.9%
+-commutative99.9%
fma-define99.9%
Simplified99.9%
Taylor expanded in z around inf 92.7%
neg-mul-192.7%
Simplified92.7%
Taylor expanded in y around 0 92.7%
+-commutative92.7%
associate-*r*92.7%
mul-1-neg92.7%
cancel-sign-sub-inv92.7%
Simplified92.7%
Final simplification87.8%
(FPCore (x y z)
:precision binary64
(if (<= (* x 0.5) -5e-40)
(* x (- 0.5 (* z (/ y x))))
(if (<= (* x 0.5) 5e+21)
(* y (+ 1.0 (- (log z) z)))
(- (* x 0.5) (* y z)))))
double code(double x, double y, double z) {
double tmp;
if ((x * 0.5) <= -5e-40) {
tmp = x * (0.5 - (z * (y / x)));
} else if ((x * 0.5) <= 5e+21) {
tmp = y * (1.0 + (log(z) - 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 ((x * 0.5d0) <= (-5d-40)) then
tmp = x * (0.5d0 - (z * (y / x)))
else if ((x * 0.5d0) <= 5d+21) then
tmp = y * (1.0d0 + (log(z) - 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 ((x * 0.5) <= -5e-40) {
tmp = x * (0.5 - (z * (y / x)));
} else if ((x * 0.5) <= 5e+21) {
tmp = y * (1.0 + (Math.log(z) - z));
} else {
tmp = (x * 0.5) - (y * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x * 0.5) <= -5e-40: tmp = x * (0.5 - (z * (y / x))) elif (x * 0.5) <= 5e+21: tmp = y * (1.0 + (math.log(z) - z)) else: tmp = (x * 0.5) - (y * z) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(x * 0.5) <= -5e-40) tmp = Float64(x * Float64(0.5 - Float64(z * Float64(y / x)))); elseif (Float64(x * 0.5) <= 5e+21) tmp = Float64(y * Float64(1.0 + Float64(log(z) - 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 ((x * 0.5) <= -5e-40) tmp = x * (0.5 - (z * (y / x))); elseif ((x * 0.5) <= 5e+21) tmp = y * (1.0 + (log(z) - z)); else tmp = (x * 0.5) - (y * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(x * 0.5), $MachinePrecision], -5e-40], N[(x * N[(0.5 - N[(z * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * 0.5), $MachinePrecision], 5e+21], N[(y * N[(1.0 + N[(N[Log[z], $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * 0.5), $MachinePrecision] - N[(y * z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot 0.5 \leq -5 \cdot 10^{-40}:\\
\;\;\;\;x \cdot \left(0.5 - z \cdot \frac{y}{x}\right)\\
\mathbf{elif}\;x \cdot 0.5 \leq 5 \cdot 10^{+21}:\\
\;\;\;\;y \cdot \left(1 + \left(\log z - z\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot 0.5 - y \cdot z\\
\end{array}
\end{array}
if (*.f64 x #s(literal 1/2 binary64)) < -4.99999999999999965e-40Initial program 99.9%
+-commutative99.9%
fma-define99.9%
Simplified99.9%
Taylor expanded in z around inf 79.1%
neg-mul-179.1%
Simplified79.1%
Taylor expanded in x around inf 79.1%
associate-*r/79.1%
mul-1-neg79.1%
*-commutative79.1%
distribute-rgt-neg-in79.1%
Simplified79.1%
frac-2neg79.1%
*-commutative79.1%
neg-mul-179.1%
associate-*r*79.1%
distribute-frac-neg79.1%
associate-*r*79.1%
neg-mul-179.1%
add-sqr-sqrt36.8%
sqrt-unprod66.1%
sqr-neg66.1%
sqrt-unprod32.8%
add-sqr-sqrt62.3%
remove-double-neg62.3%
mul-1-neg62.3%
frac-2neg62.3%
associate-*r*62.3%
neg-mul-162.3%
*-commutative62.3%
associate-/l*62.3%
Applied egg-rr80.3%
if -4.99999999999999965e-40 < (*.f64 x #s(literal 1/2 binary64)) < 5e21Initial program 99.7%
cancel-sign-sub99.7%
fma-neg99.7%
distribute-lft-neg-in99.7%
remove-double-neg99.7%
+-commutative99.7%
associate-+r-99.7%
+-commutative99.7%
associate--l+99.7%
Simplified99.7%
fma-undefine99.7%
+-commutative99.7%
+-commutative99.7%
sub-neg99.7%
associate-+l+99.7%
+-commutative99.7%
sub-neg99.7%
*-un-lft-identity99.7%
+-commutative99.7%
*-un-lft-identity99.7%
distribute-rgt-in98.9%
associate-+l+98.9%
Applied egg-rr98.9%
Taylor expanded in y around inf 89.8%
associate--l+89.9%
Simplified89.9%
if 5e21 < (*.f64 x #s(literal 1/2 binary64)) Initial program 99.9%
+-commutative99.9%
fma-define99.9%
Simplified99.9%
Taylor expanded in z around inf 92.7%
neg-mul-192.7%
Simplified92.7%
Taylor expanded in y around 0 92.7%
+-commutative92.7%
associate-*r*92.7%
mul-1-neg92.7%
cancel-sign-sub-inv92.7%
Simplified92.7%
Final simplification87.8%
(FPCore (x y z) :precision binary64 (if (<= z 6.4e-236) (* x (- 0.5 (* z (/ y x)))) (if (<= z 1.95e-41) (* y (+ 1.0 (log z))) (fma y (- z) (* x 0.5)))))
double code(double x, double y, double z) {
double tmp;
if (z <= 6.4e-236) {
tmp = x * (0.5 - (z * (y / x)));
} else if (z <= 1.95e-41) {
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 <= 6.4e-236) tmp = Float64(x * Float64(0.5 - Float64(z * Float64(y / x)))); elseif (z <= 1.95e-41) 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, 6.4e-236], N[(x * N[(0.5 - N[(z * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.95e-41], 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 6.4 \cdot 10^{-236}:\\
\;\;\;\;x \cdot \left(0.5 - z \cdot \frac{y}{x}\right)\\
\mathbf{elif}\;z \leq 1.95 \cdot 10^{-41}:\\
\;\;\;\;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 < 6.3999999999999999e-236Initial program 99.8%
+-commutative99.8%
fma-define99.8%
Simplified99.8%
Taylor expanded in z around inf 65.6%
neg-mul-165.6%
Simplified65.6%
Taylor expanded in x around inf 65.6%
associate-*r/65.6%
mul-1-neg65.6%
*-commutative65.6%
distribute-rgt-neg-in65.6%
Simplified65.6%
frac-2neg65.6%
*-commutative65.6%
neg-mul-165.6%
associate-*r*65.6%
distribute-frac-neg65.6%
associate-*r*65.6%
neg-mul-165.6%
add-sqr-sqrt28.0%
sqrt-unprod65.6%
sqr-neg65.6%
sqrt-unprod37.5%
add-sqr-sqrt65.4%
remove-double-neg65.4%
mul-1-neg65.4%
frac-2neg65.4%
associate-*r*65.4%
neg-mul-165.4%
*-commutative65.4%
associate-/l*65.4%
Applied egg-rr65.8%
if 6.3999999999999999e-236 < z < 1.94999999999999995e-41Initial program 99.7%
Taylor expanded in z around 0 99.7%
*-commutative99.7%
Simplified99.7%
Taylor expanded in x around inf 85.4%
Taylor expanded in x around 0 61.8%
if 1.94999999999999995e-41 < z Initial program 99.9%
+-commutative99.9%
fma-define99.9%
Simplified99.9%
Taylor expanded in z around inf 92.0%
neg-mul-192.0%
Simplified92.0%
Final simplification78.9%
(FPCore (x y z) :precision binary64 (if (<= z 1e-235) (* x (- 0.5 (* z (/ y x)))) (if (<= z 2.6e-41) (* y (+ 1.0 (log z))) (- (* x 0.5) (* y z)))))
double code(double x, double y, double z) {
double tmp;
if (z <= 1e-235) {
tmp = x * (0.5 - (z * (y / x)));
} else if (z <= 2.6e-41) {
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 <= 1d-235) then
tmp = x * (0.5d0 - (z * (y / x)))
else if (z <= 2.6d-41) 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 <= 1e-235) {
tmp = x * (0.5 - (z * (y / x)));
} else if (z <= 2.6e-41) {
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 <= 1e-235: tmp = x * (0.5 - (z * (y / x))) elif z <= 2.6e-41: 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 <= 1e-235) tmp = Float64(x * Float64(0.5 - Float64(z * Float64(y / x)))); elseif (z <= 2.6e-41) 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 <= 1e-235) tmp = x * (0.5 - (z * (y / x))); elseif (z <= 2.6e-41) 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, 1e-235], N[(x * N[(0.5 - N[(z * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 2.6e-41], 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 10^{-235}:\\
\;\;\;\;x \cdot \left(0.5 - z \cdot \frac{y}{x}\right)\\
\mathbf{elif}\;z \leq 2.6 \cdot 10^{-41}:\\
\;\;\;\;y \cdot \left(1 + \log z\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot 0.5 - y \cdot z\\
\end{array}
\end{array}
if z < 9.9999999999999996e-236Initial program 99.8%
+-commutative99.8%
fma-define99.8%
Simplified99.8%
Taylor expanded in z around inf 65.6%
neg-mul-165.6%
Simplified65.6%
Taylor expanded in x around inf 65.6%
associate-*r/65.6%
mul-1-neg65.6%
*-commutative65.6%
distribute-rgt-neg-in65.6%
Simplified65.6%
frac-2neg65.6%
*-commutative65.6%
neg-mul-165.6%
associate-*r*65.6%
distribute-frac-neg65.6%
associate-*r*65.6%
neg-mul-165.6%
add-sqr-sqrt28.0%
sqrt-unprod65.6%
sqr-neg65.6%
sqrt-unprod37.5%
add-sqr-sqrt65.4%
remove-double-neg65.4%
mul-1-neg65.4%
frac-2neg65.4%
associate-*r*65.4%
neg-mul-165.4%
*-commutative65.4%
associate-/l*65.4%
Applied egg-rr65.8%
if 9.9999999999999996e-236 < z < 2.5999999999999999e-41Initial program 99.7%
Taylor expanded in z around 0 99.7%
*-commutative99.7%
Simplified99.7%
Taylor expanded in x around inf 85.4%
Taylor expanded in x around 0 61.8%
if 2.5999999999999999e-41 < z Initial program 99.9%
+-commutative99.9%
fma-define99.9%
Simplified99.9%
Taylor expanded in z around inf 92.0%
neg-mul-192.0%
Simplified92.0%
Taylor expanded in y around 0 92.0%
+-commutative92.0%
associate-*r*92.0%
mul-1-neg92.0%
cancel-sign-sub-inv92.0%
Simplified92.0%
Final simplification78.9%
(FPCore (x y z) :precision binary64 (if (<= z 0.28) (+ (+ y (* x 0.5)) (* y (log z))) (fma y (- z) (* x 0.5))))
double code(double x, double y, double z) {
double tmp;
if (z <= 0.28) {
tmp = (y + (x * 0.5)) + (y * 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(y + Float64(x * 0.5)) + Float64(y * 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[(y + N[(x * 0.5), $MachinePrecision]), $MachinePrecision] + N[(y * 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 0.28:\\
\;\;\;\;\left(y + x \cdot 0.5\right) + y \cdot \log z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, -z, x \cdot 0.5\right)\\
\end{array}
\end{array}
if z < 0.28000000000000003Initial program 99.7%
cancel-sign-sub99.7%
fma-neg99.7%
distribute-lft-neg-in99.7%
remove-double-neg99.7%
+-commutative99.7%
associate-+r-99.7%
+-commutative99.7%
associate--l+99.7%
Simplified99.7%
fma-undefine99.7%
distribute-rgt-in99.7%
*-un-lft-identity99.7%
associate-+r+99.7%
Applied egg-rr99.7%
Taylor expanded in z around 0 98.8%
if 0.28000000000000003 < z Initial program 99.9%
+-commutative99.9%
fma-define100.0%
Simplified100.0%
Taylor expanded in z around inf 98.2%
neg-mul-198.2%
Simplified98.2%
Final simplification98.5%
(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.7%
Taylor expanded in z around 0 98.7%
*-commutative98.7%
Simplified98.7%
if 0.28000000000000003 < z Initial program 99.9%
+-commutative99.9%
fma-define100.0%
Simplified100.0%
Taylor expanded in z around inf 98.2%
neg-mul-198.2%
Simplified98.2%
Final simplification98.5%
(FPCore (x y z) :precision binary64 (+ (+ y (* x 0.5)) (* y (- (log z) z))))
double code(double x, double y, double z) {
return (y + (x * 0.5)) + (y * (log(z) - 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 + (x * 0.5d0)) + (y * (log(z) - z))
end function
public static double code(double x, double y, double z) {
return (y + (x * 0.5)) + (y * (Math.log(z) - z));
}
def code(x, y, z): return (y + (x * 0.5)) + (y * (math.log(z) - z))
function code(x, y, z) return Float64(Float64(y + Float64(x * 0.5)) + Float64(y * Float64(log(z) - z))) end
function tmp = code(x, y, z) tmp = (y + (x * 0.5)) + (y * (log(z) - z)); end
code[x_, y_, z_] := N[(N[(y + N[(x * 0.5), $MachinePrecision]), $MachinePrecision] + N[(y * N[(N[Log[z], $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(y + x \cdot 0.5\right) + y \cdot \left(\log z - z\right)
\end{array}
Initial program 99.8%
cancel-sign-sub99.8%
fma-neg99.8%
distribute-lft-neg-in99.8%
remove-double-neg99.8%
+-commutative99.8%
associate-+r-99.8%
+-commutative99.8%
associate--l+99.8%
Simplified99.8%
fma-undefine99.8%
distribute-rgt-in99.8%
*-un-lft-identity99.8%
associate-+r+99.8%
Applied egg-rr99.8%
Final simplification99.8%
(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.8%
(FPCore (x y z) :precision binary64 (if (<= z 2.8e+16) (* x 0.5) (* y (- z))))
double code(double x, double y, double z) {
double tmp;
if (z <= 2.8e+16) {
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.8d+16) 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.8e+16) {
tmp = x * 0.5;
} else {
tmp = y * -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= 2.8e+16: tmp = x * 0.5 else: tmp = y * -z return tmp
function code(x, y, z) tmp = 0.0 if (z <= 2.8e+16) 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.8e+16) tmp = x * 0.5; else tmp = y * -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, 2.8e+16], N[(x * 0.5), $MachinePrecision], N[(y * (-z)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 2.8 \cdot 10^{+16}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(-z\right)\\
\end{array}
\end{array}
if z < 2.8e16Initial program 99.7%
sub-neg99.7%
associate-+l+99.7%
+-commutative99.7%
sub-neg99.7%
add-cbrt-cube99.4%
pow399.5%
Applied egg-rr99.5%
Taylor expanded in x around inf 47.4%
if 2.8e16 < z Initial program 100.0%
cancel-sign-sub100.0%
fma-neg100.0%
distribute-lft-neg-in100.0%
remove-double-neg100.0%
+-commutative100.0%
associate-+r-100.0%
+-commutative100.0%
associate--l+100.0%
Simplified100.0%
Taylor expanded in z around inf 70.3%
associate-*r*70.3%
mul-1-neg70.3%
Simplified70.3%
Final simplification57.7%
(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.8%
+-commutative99.8%
fma-define99.8%
Simplified99.8%
Taylor expanded in z around inf 71.9%
neg-mul-171.9%
Simplified71.9%
Taylor expanded in y around 0 71.9%
+-commutative71.9%
associate-*r*71.9%
mul-1-neg71.9%
cancel-sign-sub-inv71.9%
Simplified71.9%
Final simplification71.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.8%
sub-neg99.8%
associate-+l+99.8%
+-commutative99.8%
sub-neg99.8%
add-cbrt-cube79.4%
pow379.4%
Applied egg-rr79.4%
Taylor expanded in x around inf 40.6%
Final simplification40.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 2024123
(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)))))