
(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 (fma (log y) x (- (- z) y)))
double code(double x, double y, double z) {
return fma(log(y), x, (-z - y));
}
function code(x, y, z) return fma(log(y), x, Float64(Float64(-z) - y)) end
code[x_, y_, z_] := N[(N[Log[y], $MachinePrecision] * x + N[((-z) - y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\log y, x, \left(-z\right) - y\right)
\end{array}
Initial program 99.8%
associate--l-99.8%
*-commutative99.8%
fma-neg99.9%
+-commutative99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (or (<= z -2.5e+28) (not (<= z 3.7e-22))) (- (- z) y) (- (* (log y) x) y)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -2.5e+28) || !(z <= 3.7e-22)) {
tmp = -z - y;
} else {
tmp = (log(y) * x) - 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 <= (-2.5d+28)) .or. (.not. (z <= 3.7d-22))) then
tmp = -z - y
else
tmp = (log(y) * x) - y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -2.5e+28) || !(z <= 3.7e-22)) {
tmp = -z - y;
} else {
tmp = (Math.log(y) * x) - y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -2.5e+28) or not (z <= 3.7e-22): tmp = -z - y else: tmp = (math.log(y) * x) - y return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -2.5e+28) || !(z <= 3.7e-22)) tmp = Float64(Float64(-z) - y); else tmp = Float64(Float64(log(y) * x) - y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -2.5e+28) || ~((z <= 3.7e-22))) tmp = -z - y; else tmp = (log(y) * x) - y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -2.5e+28], N[Not[LessEqual[z, 3.7e-22]], $MachinePrecision]], N[((-z) - y), $MachinePrecision], N[(N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision] - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.5 \cdot 10^{+28} \lor \neg \left(z \leq 3.7 \cdot 10^{-22}\right):\\
\;\;\;\;\left(-z\right) - y\\
\mathbf{else}:\\
\;\;\;\;\log y \cdot x - y\\
\end{array}
\end{array}
if z < -2.49999999999999979e28 or 3.7e-22 < z Initial program 99.9%
Taylor expanded in x around 0 84.0%
neg-mul-184.0%
Simplified84.0%
if -2.49999999999999979e28 < z < 3.7e-22Initial program 99.8%
Taylor expanded in z around 0 92.7%
Final simplification88.8%
(FPCore (x y z) :precision binary64 (if (or (<= x -2.7e+49) (not (<= x 2.7e+92))) (* (log y) x) (- (- z) y)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -2.7e+49) || !(x <= 2.7e+92)) {
tmp = log(y) * x;
} 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 <= (-2.7d+49)) .or. (.not. (x <= 2.7d+92))) then
tmp = log(y) * x
else
tmp = -z - y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -2.7e+49) || !(x <= 2.7e+92)) {
tmp = Math.log(y) * x;
} else {
tmp = -z - y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -2.7e+49) or not (x <= 2.7e+92): tmp = math.log(y) * x else: tmp = -z - y return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -2.7e+49) || !(x <= 2.7e+92)) tmp = Float64(log(y) * x); else tmp = Float64(Float64(-z) - y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -2.7e+49) || ~((x <= 2.7e+92))) tmp = log(y) * x; else tmp = -z - y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -2.7e+49], N[Not[LessEqual[x, 2.7e+92]], $MachinePrecision]], N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision], N[((-z) - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.7 \cdot 10^{+49} \lor \neg \left(x \leq 2.7 \cdot 10^{+92}\right):\\
\;\;\;\;\log y \cdot x\\
\mathbf{else}:\\
\;\;\;\;\left(-z\right) - y\\
\end{array}
\end{array}
if x < -2.7000000000000001e49 or 2.6999999999999999e92 < x Initial program 99.6%
associate--l-99.6%
*-commutative99.6%
fma-neg99.7%
+-commutative99.7%
Applied egg-rr99.7%
Taylor expanded in x around inf 75.0%
if -2.7000000000000001e49 < x < 2.6999999999999999e92Initial program 99.9%
Taylor expanded in x around 0 84.3%
neg-mul-184.3%
Simplified84.3%
Final simplification81.1%
(FPCore (x y z) :precision binary64 (- (- (* (log y) x) z) y))
double code(double x, double y, double z) {
return ((log(y) * x) - 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 = ((log(y) * x) - z) - y
end function
public static double code(double x, double y, double z) {
return ((Math.log(y) * x) - z) - y;
}
def code(x, y, z): return ((math.log(y) * x) - z) - y
function code(x, y, z) return Float64(Float64(Float64(log(y) * x) - z) - y) end
function tmp = code(x, y, z) tmp = ((log(y) * x) - z) - y; end
code[x_, y_, z_] := N[(N[(N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision] - z), $MachinePrecision] - y), $MachinePrecision]
\begin{array}{l}
\\
\left(\log y \cdot x - z\right) - y
\end{array}
Initial program 99.8%
Final simplification99.8%
(FPCore (x y z) :precision binary64 (if (or (<= z -6.4e+27) (not (<= z 1.45e-26))) (- z) (- y)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -6.4e+27) || !(z <= 1.45e-26)) {
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 <= (-6.4d+27)) .or. (.not. (z <= 1.45d-26))) 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 <= -6.4e+27) || !(z <= 1.45e-26)) {
tmp = -z;
} else {
tmp = -y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -6.4e+27) or not (z <= 1.45e-26): tmp = -z else: tmp = -y return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -6.4e+27) || !(z <= 1.45e-26)) tmp = Float64(-z); else tmp = Float64(-y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -6.4e+27) || ~((z <= 1.45e-26))) tmp = -z; else tmp = -y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -6.4e+27], N[Not[LessEqual[z, 1.45e-26]], $MachinePrecision]], (-z), (-y)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -6.4 \cdot 10^{+27} \lor \neg \left(z \leq 1.45 \cdot 10^{-26}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;-y\\
\end{array}
\end{array}
if z < -6.4000000000000003e27 or 1.4499999999999999e-26 < z Initial program 99.9%
associate--l-99.9%
*-commutative99.9%
fma-neg99.9%
+-commutative99.9%
Applied egg-rr99.9%
Taylor expanded in z around inf 62.6%
neg-mul-162.6%
Simplified62.6%
if -6.4000000000000003e27 < z < 1.4499999999999999e-26Initial program 99.8%
Taylor expanded in y around inf 41.8%
neg-mul-141.8%
Simplified41.8%
Final simplification51.2%
(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 63.5%
neg-mul-163.5%
Simplified63.5%
Final simplification63.5%
(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 32.3%
neg-mul-132.3%
Simplified32.3%
Final simplification32.3%
herbie shell --seed 2024034
(FPCore (x y z)
:name "Statistics.Distribution.Poisson:$clogProbability from math-functions-0.1.5.2"
:precision binary64
(- (- (* x (log y)) z) y))