
(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.2e+70) (not (<= x 2.2e+18))) (- (* x (log y)) y) (- (- z) y)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -9.2e+70) || !(x <= 2.2e+18)) {
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.2d+70)) .or. (.not. (x <= 2.2d+18))) 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.2e+70) || !(x <= 2.2e+18)) {
tmp = (x * Math.log(y)) - y;
} else {
tmp = -z - y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -9.2e+70) or not (x <= 2.2e+18): tmp = (x * math.log(y)) - y else: tmp = -z - y return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -9.2e+70) || !(x <= 2.2e+18)) 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.2e+70) || ~((x <= 2.2e+18))) tmp = (x * log(y)) - y; else tmp = -z - y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -9.2e+70], N[Not[LessEqual[x, 2.2e+18]], $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.2 \cdot 10^{+70} \lor \neg \left(x \leq 2.2 \cdot 10^{+18}\right):\\
\;\;\;\;x \cdot \log y - y\\
\mathbf{else}:\\
\;\;\;\;\left(-z\right) - y\\
\end{array}
\end{array}
if x < -9.19999999999999975e70 or 2.2e18 < x Initial program 99.7%
Taylor expanded in z around 0 85.1%
if -9.19999999999999975e70 < x < 2.2e18Initial program 100.0%
Taylor expanded in x around 0 89.7%
neg-mul-189.7%
+-commutative89.7%
distribute-neg-in89.7%
sub-neg89.7%
Simplified89.7%
Final simplification87.6%
(FPCore (x y z) :precision binary64 (if (or (<= x -1.65e-42) (not (<= x 3.8e-40))) (- (* x (log y)) z) (- (- z) y)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1.65e-42) || !(x <= 3.8e-40)) {
tmp = (x * log(y)) - z;
} 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 <= (-1.65d-42)) .or. (.not. (x <= 3.8d-40))) then
tmp = (x * log(y)) - z
else
tmp = -z - y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -1.65e-42) || !(x <= 3.8e-40)) {
tmp = (x * Math.log(y)) - z;
} else {
tmp = -z - y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -1.65e-42) or not (x <= 3.8e-40): tmp = (x * math.log(y)) - z else: tmp = -z - y return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -1.65e-42) || !(x <= 3.8e-40)) tmp = Float64(Float64(x * log(y)) - z); else tmp = Float64(Float64(-z) - y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -1.65e-42) || ~((x <= 3.8e-40))) tmp = (x * log(y)) - z; else tmp = -z - y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -1.65e-42], N[Not[LessEqual[x, 3.8e-40]], $MachinePrecision]], N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], N[((-z) - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.65 \cdot 10^{-42} \lor \neg \left(x \leq 3.8 \cdot 10^{-40}\right):\\
\;\;\;\;x \cdot \log y - z\\
\mathbf{else}:\\
\;\;\;\;\left(-z\right) - y\\
\end{array}
\end{array}
if x < -1.6500000000000001e-42 or 3.7999999999999999e-40 < x Initial program 99.7%
Taylor expanded in y around 0 88.6%
if -1.6500000000000001e-42 < x < 3.7999999999999999e-40Initial program 100.0%
Taylor expanded in x around 0 92.9%
neg-mul-192.9%
+-commutative92.9%
distribute-neg-in92.9%
sub-neg92.9%
Simplified92.9%
Final simplification90.6%
(FPCore (x y z) :precision binary64 (if (or (<= x -5e+71) (not (<= x 1.22e+145))) (* x (log y)) (- (- z) y)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -5e+71) || !(x <= 1.22e+145)) {
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 <= (-5d+71)) .or. (.not. (x <= 1.22d+145))) 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 <= -5e+71) || !(x <= 1.22e+145)) {
tmp = x * Math.log(y);
} else {
tmp = -z - y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -5e+71) or not (x <= 1.22e+145): tmp = x * math.log(y) else: tmp = -z - y return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -5e+71) || !(x <= 1.22e+145)) 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 <= -5e+71) || ~((x <= 1.22e+145))) tmp = x * log(y); else tmp = -z - y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -5e+71], N[Not[LessEqual[x, 1.22e+145]], $MachinePrecision]], N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision], N[((-z) - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5 \cdot 10^{+71} \lor \neg \left(x \leq 1.22 \cdot 10^{+145}\right):\\
\;\;\;\;x \cdot \log y\\
\mathbf{else}:\\
\;\;\;\;\left(-z\right) - y\\
\end{array}
\end{array}
if x < -4.99999999999999972e71 or 1.21999999999999994e145 < x Initial program 99.6%
Taylor expanded in y around 0 89.6%
Taylor expanded in x around inf 79.8%
if -4.99999999999999972e71 < x < 1.21999999999999994e145Initial program 100.0%
Taylor expanded in x around 0 84.3%
neg-mul-184.3%
+-commutative84.3%
distribute-neg-in84.3%
sub-neg84.3%
Simplified84.3%
Final simplification82.7%
(FPCore (x y z) :precision binary64 (if (<= y 1.52e+35) (- z) (- y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.52e+35) {
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 <= 1.52d+35) 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 <= 1.52e+35) {
tmp = -z;
} else {
tmp = -y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1.52e+35: tmp = -z else: tmp = -y return tmp
function code(x, y, z) tmp = 0.0 if (y <= 1.52e+35) tmp = Float64(-z); else tmp = Float64(-y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 1.52e+35) tmp = -z; else tmp = -y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1.52e+35], (-z), (-y)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.52 \cdot 10^{+35}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;-y\\
\end{array}
\end{array}
if y < 1.5200000000000001e35Initial program 99.8%
Taylor expanded in z around inf 45.1%
neg-mul-145.1%
Simplified45.1%
if 1.5200000000000001e35 < y Initial program 99.9%
Taylor expanded in y around inf 57.3%
neg-mul-157.3%
Simplified57.3%
Final simplification50.1%
(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 61.4%
neg-mul-161.4%
+-commutative61.4%
distribute-neg-in61.4%
sub-neg61.4%
Simplified61.4%
Final simplification61.4%
(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 29.5%
neg-mul-129.5%
Simplified29.5%
Final simplification29.5%
herbie shell --seed 2023196
(FPCore (x y z)
:name "Statistics.Distribution.Poisson:$clogProbability from math-functions-0.1.5.2"
:precision binary64
(- (- (* x (log y)) z) y))