
(FPCore (x y z) :precision binary64 (- (- (* x (log y)) z) y))
double code(double x, double y, double z) {
return ((x * log(y)) - 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 * log(y)) - z) - y
end function
public static double code(double x, double y, double z) {
return ((x * Math.log(y)) - z) - y;
}
def code(x, y, z): return ((x * math.log(y)) - z) - y
function code(x, y, z) return Float64(Float64(Float64(x * log(y)) - z) - y) end
function tmp = code(x, y, z) tmp = ((x * log(y)) - z) - y; end
code[x_, y_, z_] := N[(N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision] - y), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot \log y - z\right) - y
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (- (- (* x (log y)) z) y))
double code(double x, double y, double z) {
return ((x * log(y)) - 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 * log(y)) - z) - y
end function
public static double code(double x, double y, double z) {
return ((x * Math.log(y)) - z) - y;
}
def code(x, y, z): return ((x * math.log(y)) - z) - y
function code(x, y, z) return Float64(Float64(Float64(x * log(y)) - z) - y) end
function tmp = code(x, y, z) tmp = ((x * log(y)) - z) - y; end
code[x_, y_, z_] := N[(N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision] - y), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot \log y - z\right) - y
\end{array}
(FPCore (x y z) :precision binary64 (- (- (* x (log y)) z) y))
double code(double x, double y, double z) {
return ((x * log(y)) - 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 * log(y)) - z) - y
end function
public static double code(double x, double y, double z) {
return ((x * Math.log(y)) - z) - y;
}
def code(x, y, z): return ((x * math.log(y)) - z) - y
function code(x, y, z) return Float64(Float64(Float64(x * log(y)) - z) - y) end
function tmp = code(x, y, z) tmp = ((x * log(y)) - z) - y; end
code[x_, y_, z_] := N[(N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision] - y), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot \log y - z\right) - y
\end{array}
Initial program 99.8%
Final simplification99.8%
(FPCore (x y z)
:precision binary64
(if (or (<= x -4.2e+32)
(and (not (<= x 9.5e+44)) (or (<= x 2.3e+122) (not (<= x 2.8e+154)))))
(* x (log y))
(- (- z) y)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -4.2e+32) || (!(x <= 9.5e+44) && ((x <= 2.3e+122) || !(x <= 2.8e+154)))) {
tmp = x * log(y);
} 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 ((x <= (-4.2d+32)) .or. (.not. (x <= 9.5d+44)) .and. (x <= 2.3d+122) .or. (.not. (x <= 2.8d+154))) then
tmp = x * log(y)
else
tmp = -z - y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -4.2e+32) || (!(x <= 9.5e+44) && ((x <= 2.3e+122) || !(x <= 2.8e+154)))) {
tmp = x * Math.log(y);
} else {
tmp = -z - y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -4.2e+32) or (not (x <= 9.5e+44) and ((x <= 2.3e+122) or not (x <= 2.8e+154))): tmp = x * math.log(y) else: tmp = -z - y return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -4.2e+32) || (!(x <= 9.5e+44) && ((x <= 2.3e+122) || !(x <= 2.8e+154)))) tmp = Float64(x * log(y)); else tmp = Float64(Float64(-z) - y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -4.2e+32) || (~((x <= 9.5e+44)) && ((x <= 2.3e+122) || ~((x <= 2.8e+154))))) tmp = x * log(y); else tmp = -z - y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -4.2e+32], And[N[Not[LessEqual[x, 9.5e+44]], $MachinePrecision], Or[LessEqual[x, 2.3e+122], N[Not[LessEqual[x, 2.8e+154]], $MachinePrecision]]]], N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision], N[((-z) - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.2 \cdot 10^{+32} \lor \neg \left(x \leq 9.5 \cdot 10^{+44}\right) \land \left(x \leq 2.3 \cdot 10^{+122} \lor \neg \left(x \leq 2.8 \cdot 10^{+154}\right)\right):\\
\;\;\;\;x \cdot \log y\\
\mathbf{else}:\\
\;\;\;\;\left(-z\right) - y\\
\end{array}
\end{array}
if x < -4.2000000000000001e32 or 9.5000000000000004e44 < x < 2.3000000000000001e122 or 2.7999999999999999e154 < x Initial program 99.6%
sub-neg99.6%
associate--l+99.6%
add-cube-cbrt98.7%
associate-*l*98.7%
fma-define98.7%
pow298.7%
Applied egg-rr98.7%
Taylor expanded in x around inf 70.2%
if -4.2000000000000001e32 < x < 9.5000000000000004e44 or 2.3000000000000001e122 < x < 2.7999999999999999e154Initial program 100.0%
Taylor expanded in x around 0 88.1%
neg-mul-188.1%
+-commutative88.1%
distribute-neg-in88.1%
sub-neg88.1%
Simplified88.1%
Final simplification80.2%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (log y))))
(if (or (<= y 4e-65) (and (not (<= y 0.018)) (<= y 1300000.0)))
(- t_0 z)
(- t_0 y))))
double code(double x, double y, double z) {
double t_0 = x * log(y);
double tmp;
if ((y <= 4e-65) || (!(y <= 0.018) && (y <= 1300000.0))) {
tmp = t_0 - z;
} else {
tmp = t_0 - 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) :: t_0
real(8) :: tmp
t_0 = x * log(y)
if ((y <= 4d-65) .or. (.not. (y <= 0.018d0)) .and. (y <= 1300000.0d0)) then
tmp = t_0 - z
else
tmp = t_0 - y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x * Math.log(y);
double tmp;
if ((y <= 4e-65) || (!(y <= 0.018) && (y <= 1300000.0))) {
tmp = t_0 - z;
} else {
tmp = t_0 - y;
}
return tmp;
}
def code(x, y, z): t_0 = x * math.log(y) tmp = 0 if (y <= 4e-65) or (not (y <= 0.018) and (y <= 1300000.0)): tmp = t_0 - z else: tmp = t_0 - y return tmp
function code(x, y, z) t_0 = Float64(x * log(y)) tmp = 0.0 if ((y <= 4e-65) || (!(y <= 0.018) && (y <= 1300000.0))) tmp = Float64(t_0 - z); else tmp = Float64(t_0 - y); end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * log(y); tmp = 0.0; if ((y <= 4e-65) || (~((y <= 0.018)) && (y <= 1300000.0))) tmp = t_0 - z; else tmp = t_0 - y; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[y, 4e-65], And[N[Not[LessEqual[y, 0.018]], $MachinePrecision], LessEqual[y, 1300000.0]]], N[(t$95$0 - z), $MachinePrecision], N[(t$95$0 - y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \log y\\
\mathbf{if}\;y \leq 4 \cdot 10^{-65} \lor \neg \left(y \leq 0.018\right) \land y \leq 1300000:\\
\;\;\;\;t\_0 - z\\
\mathbf{else}:\\
\;\;\;\;t\_0 - y\\
\end{array}
\end{array}
if y < 3.99999999999999969e-65 or 0.0179999999999999986 < y < 1.3e6Initial program 99.8%
Taylor expanded in y around 0 95.4%
if 3.99999999999999969e-65 < y < 0.0179999999999999986 or 1.3e6 < y Initial program 99.8%
Taylor expanded in z around 0 84.7%
Final simplification89.2%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.1e+106) (not (<= z 3.6e+149))) (- (- z) y) (- (* x (log y)) y)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.1e+106) || !(z <= 3.6e+149)) {
tmp = -z - y;
} else {
tmp = (x * log(y)) - 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 <= (-1.1d+106)) .or. (.not. (z <= 3.6d+149))) then
tmp = -z - y
else
tmp = (x * log(y)) - y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.1e+106) || !(z <= 3.6e+149)) {
tmp = -z - y;
} else {
tmp = (x * Math.log(y)) - y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.1e+106) or not (z <= 3.6e+149): tmp = -z - y else: tmp = (x * math.log(y)) - y return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.1e+106) || !(z <= 3.6e+149)) tmp = Float64(Float64(-z) - y); else tmp = Float64(Float64(x * log(y)) - y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.1e+106) || ~((z <= 3.6e+149))) tmp = -z - y; else tmp = (x * log(y)) - y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.1e+106], N[Not[LessEqual[z, 3.6e+149]], $MachinePrecision]], N[((-z) - y), $MachinePrecision], N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.1 \cdot 10^{+106} \lor \neg \left(z \leq 3.6 \cdot 10^{+149}\right):\\
\;\;\;\;\left(-z\right) - y\\
\mathbf{else}:\\
\;\;\;\;x \cdot \log y - y\\
\end{array}
\end{array}
if z < -1.09999999999999996e106 or 3.59999999999999995e149 < z Initial program 99.9%
Taylor expanded in x around 0 83.8%
neg-mul-183.8%
+-commutative83.8%
distribute-neg-in83.8%
sub-neg83.8%
Simplified83.8%
if -1.09999999999999996e106 < z < 3.59999999999999995e149Initial program 99.8%
Taylor expanded in z around 0 88.1%
Final simplification86.9%
(FPCore (x y z) :precision binary64 (if (<= y 6.1e-65) (- z) (- y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 6.1e-65) {
tmp = -z;
} else {
tmp = -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 (y <= 6.1d-65) then
tmp = -z
else
tmp = -y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 6.1e-65) {
tmp = -z;
} else {
tmp = -y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 6.1e-65: tmp = -z else: tmp = -y return tmp
function code(x, y, z) tmp = 0.0 if (y <= 6.1e-65) tmp = Float64(-z); else tmp = Float64(-y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 6.1e-65) tmp = -z; else tmp = -y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 6.1e-65], (-z), (-y)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 6.1 \cdot 10^{-65}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;-y\\
\end{array}
\end{array}
if y < 6.10000000000000014e-65Initial program 99.8%
Taylor expanded in z around inf 44.5%
neg-mul-144.5%
Simplified44.5%
if 6.10000000000000014e-65 < y Initial program 99.8%
Taylor expanded in y around inf 52.9%
neg-mul-152.9%
Simplified52.9%
Final simplification49.5%
(FPCore (x y z) :precision binary64 (- (- z) y))
double code(double x, double y, double z) {
return -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 = -z - y
end function
public static double code(double x, double y, double z) {
return -z - y;
}
def code(x, y, z): return -z - y
function code(x, y, z) return Float64(Float64(-z) - y) end
function tmp = code(x, y, z) tmp = -z - y; end
code[x_, y_, z_] := N[((-z) - y), $MachinePrecision]
\begin{array}{l}
\\
\left(-z\right) - y
\end{array}
Initial program 99.8%
Taylor expanded in x around 0 61.6%
neg-mul-161.6%
+-commutative61.6%
distribute-neg-in61.6%
sub-neg61.6%
Simplified61.6%
Final simplification61.6%
(FPCore (x y z) :precision binary64 (- y))
double code(double x, double y, double z) {
return -y;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = -y
end function
public static double code(double x, double y, double z) {
return -y;
}
def code(x, y, z): return -y
function code(x, y, z) return Float64(-y) end
function tmp = code(x, y, z) tmp = -y; end
code[x_, y_, z_] := (-y)
\begin{array}{l}
\\
-y
\end{array}
Initial program 99.8%
Taylor expanded in y around inf 34.8%
neg-mul-134.8%
Simplified34.8%
Final simplification34.8%
herbie shell --seed 2024089
(FPCore (x y z)
:name "Statistics.Distribution.Poisson:$clogProbability from math-functions-0.1.5.2"
:precision binary64
(- (- (* x (log y)) z) y))