
(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.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (or (<= x -9.6e+51) (not (<= x 6.2e+22))) (- (* x (log y)) y) (- (- z) y)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -9.6e+51) || !(x <= 6.2e+22)) {
tmp = (x * log(y)) - 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 <= (-9.6d+51)) .or. (.not. (x <= 6.2d+22))) then
tmp = (x * log(y)) - 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 <= -9.6e+51) || !(x <= 6.2e+22)) {
tmp = (x * Math.log(y)) - y;
} else {
tmp = -z - y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -9.6e+51) or not (x <= 6.2e+22): tmp = (x * math.log(y)) - y else: tmp = -z - y return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -9.6e+51) || !(x <= 6.2e+22)) tmp = Float64(Float64(x * log(y)) - y); else tmp = Float64(Float64(-z) - y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -9.6e+51) || ~((x <= 6.2e+22))) tmp = (x * log(y)) - y; else tmp = -z - y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -9.6e+51], N[Not[LessEqual[x, 6.2e+22]], $MachinePrecision]], N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision], N[((-z) - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9.6 \cdot 10^{+51} \lor \neg \left(x \leq 6.2 \cdot 10^{+22}\right):\\
\;\;\;\;x \cdot \log y - y\\
\mathbf{else}:\\
\;\;\;\;\left(-z\right) - y\\
\end{array}
\end{array}
if x < -9.5999999999999994e51 or 6.2000000000000004e22 < x Initial program 99.7%
Taylor expanded in z around 0 82.8%
if -9.5999999999999994e51 < x < 6.2000000000000004e22Initial program 100.0%
Taylor expanded in x around 0 93.0%
neg-mul-193.0%
Simplified93.0%
Final simplification88.4%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* x (log y)))) (if (<= x -4.5e+61) (- t_0 z) (if (<= x 1e+23) (- (- z) y) (- t_0 y)))))
double code(double x, double y, double z) {
double t_0 = x * log(y);
double tmp;
if (x <= -4.5e+61) {
tmp = t_0 - z;
} else if (x <= 1e+23) {
tmp = -z - y;
} 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 (x <= (-4.5d+61)) then
tmp = t_0 - z
else if (x <= 1d+23) then
tmp = -z - y
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 (x <= -4.5e+61) {
tmp = t_0 - z;
} else if (x <= 1e+23) {
tmp = -z - y;
} else {
tmp = t_0 - y;
}
return tmp;
}
def code(x, y, z): t_0 = x * math.log(y) tmp = 0 if x <= -4.5e+61: tmp = t_0 - z elif x <= 1e+23: tmp = -z - y else: tmp = t_0 - y return tmp
function code(x, y, z) t_0 = Float64(x * log(y)) tmp = 0.0 if (x <= -4.5e+61) tmp = Float64(t_0 - z); elseif (x <= 1e+23) tmp = Float64(Float64(-z) - y); 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 (x <= -4.5e+61) tmp = t_0 - z; elseif (x <= 1e+23) tmp = -z - y; 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[LessEqual[x, -4.5e+61], N[(t$95$0 - z), $MachinePrecision], If[LessEqual[x, 1e+23], N[((-z) - y), $MachinePrecision], N[(t$95$0 - y), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \log y\\
\mathbf{if}\;x \leq -4.5 \cdot 10^{+61}:\\
\;\;\;\;t\_0 - z\\
\mathbf{elif}\;x \leq 10^{+23}:\\
\;\;\;\;\left(-z\right) - y\\
\mathbf{else}:\\
\;\;\;\;t\_0 - y\\
\end{array}
\end{array}
if x < -4.5e61Initial program 99.8%
Taylor expanded in y around 0 88.5%
if -4.5e61 < x < 9.9999999999999992e22Initial program 100.0%
Taylor expanded in x around 0 92.5%
neg-mul-192.5%
Simplified92.5%
if 9.9999999999999992e22 < x Initial program 99.7%
Taylor expanded in z around 0 83.9%
Final simplification89.7%
(FPCore (x y z) :precision binary64 (if (or (<= x -9.5e+137) (not (<= x 5.4e+104))) (* x (log y)) (- (- z) y)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -9.5e+137) || !(x <= 5.4e+104)) {
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 <= (-9.5d+137)) .or. (.not. (x <= 5.4d+104))) 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 <= -9.5e+137) || !(x <= 5.4e+104)) {
tmp = x * Math.log(y);
} else {
tmp = -z - y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -9.5e+137) or not (x <= 5.4e+104): tmp = x * math.log(y) else: tmp = -z - y return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -9.5e+137) || !(x <= 5.4e+104)) 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 <= -9.5e+137) || ~((x <= 5.4e+104))) tmp = x * log(y); else tmp = -z - y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -9.5e+137], N[Not[LessEqual[x, 5.4e+104]], $MachinePrecision]], N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision], N[((-z) - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9.5 \cdot 10^{+137} \lor \neg \left(x \leq 5.4 \cdot 10^{+104}\right):\\
\;\;\;\;x \cdot \log y\\
\mathbf{else}:\\
\;\;\;\;\left(-z\right) - y\\
\end{array}
\end{array}
if x < -9.50000000000000031e137 or 5.39999999999999969e104 < x Initial program 99.7%
sub-neg99.7%
associate--l+99.7%
*-commutative99.7%
add-cube-cbrt98.6%
associate-*l*98.5%
fma-define98.5%
pow298.5%
Applied egg-rr98.5%
Taylor expanded in x around inf 79.2%
*-commutative79.2%
Simplified79.2%
if -9.50000000000000031e137 < x < 5.39999999999999969e104Initial program 99.9%
Taylor expanded in x around 0 86.3%
neg-mul-186.3%
Simplified86.3%
Final simplification84.2%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.8e-66) (not (<= z 2.5e+96))) (- z) (- y)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.8e-66) || !(z <= 2.5e+96)) {
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 ((z <= (-1.8d-66)) .or. (.not. (z <= 2.5d+96))) 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 ((z <= -1.8e-66) || !(z <= 2.5e+96)) {
tmp = -z;
} else {
tmp = -y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.8e-66) or not (z <= 2.5e+96): tmp = -z else: tmp = -y return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.8e-66) || !(z <= 2.5e+96)) tmp = Float64(-z); else tmp = Float64(-y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.8e-66) || ~((z <= 2.5e+96))) tmp = -z; else tmp = -y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.8e-66], N[Not[LessEqual[z, 2.5e+96]], $MachinePrecision]], (-z), (-y)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.8 \cdot 10^{-66} \lor \neg \left(z \leq 2.5 \cdot 10^{+96}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;-y\\
\end{array}
\end{array}
if z < -1.80000000000000006e-66 or 2.5000000000000002e96 < z Initial program 99.9%
sub-neg99.9%
associate--l+99.9%
*-commutative99.9%
add-cube-cbrt99.7%
associate-*l*99.7%
fma-define99.6%
pow299.6%
Applied egg-rr99.6%
Taylor expanded in z around inf 62.5%
mul-1-neg62.5%
Simplified62.5%
if -1.80000000000000006e-66 < z < 2.5000000000000002e96Initial program 99.8%
Taylor expanded in y around inf 49.0%
neg-mul-149.0%
Simplified49.0%
Final simplification55.3%
(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.9%
Taylor expanded in x around 0 67.1%
neg-mul-167.1%
Simplified67.1%
Final simplification67.1%
(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.9%
Taylor expanded in y around inf 33.9%
neg-mul-133.9%
Simplified33.9%
Final simplification33.9%
herbie shell --seed 2024067
(FPCore (x y z)
:name "Statistics.Distribution.Poisson:$clogProbability from math-functions-0.1.5.2"
:precision binary64
(- (- (* x (log y)) z) y))