
(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%
(FPCore (x y z) :precision binary64 (if (<= x -7e+98) (- (* x (log y)) z) (if (<= x 3.3e-48) (- (- z) y) (fma (log y) x (- y)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -7e+98) {
tmp = (x * log(y)) - z;
} else if (x <= 3.3e-48) {
tmp = -z - y;
} else {
tmp = fma(log(y), x, -y);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= -7e+98) tmp = Float64(Float64(x * log(y)) - z); elseif (x <= 3.3e-48) tmp = Float64(Float64(-z) - y); else tmp = fma(log(y), x, Float64(-y)); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, -7e+98], N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[x, 3.3e-48], N[((-z) - y), $MachinePrecision], N[(N[Log[y], $MachinePrecision] * x + (-y)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -7 \cdot 10^{+98}:\\
\;\;\;\;x \cdot \log y - z\\
\mathbf{elif}\;x \leq 3.3 \cdot 10^{-48}:\\
\;\;\;\;\left(-z\right) - y\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\log y, x, -y\right)\\
\end{array}
\end{array}
if x < -7e98Initial program 99.7%
Taylor expanded in y around inf
mul-1-negN/A
lower-neg.f6412.4
Applied rewrites12.4%
Taylor expanded in y around 0
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
*-commutativeN/A
lower-fma.f64N/A
lower-log.f64N/A
mul-1-negN/A
lower-neg.f6489.0
Applied rewrites89.0%
Applied rewrites89.0%
if -7e98 < x < 3.3e-48Initial program 99.9%
Taylor expanded in x around 0
mul-1-negN/A
lower-neg.f6491.8
Applied rewrites91.8%
if 3.3e-48 < x Initial program 99.8%
Taylor expanded in z around 0
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
*-commutativeN/A
lower-fma.f64N/A
lower-log.f64N/A
mul-1-negN/A
lower-neg.f6486.8
Applied rewrites86.8%
(FPCore (x y z) :precision binary64 (if (<= (- (- (* x (log y)) z) y) -5e-107) (- y) (- z)))
double code(double x, double y, double z) {
double tmp;
if ((((x * log(y)) - z) - y) <= -5e-107) {
tmp = -y;
} else {
tmp = -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 * log(y)) - z) - y) <= (-5d-107)) then
tmp = -y
else
tmp = -z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((((x * Math.log(y)) - z) - y) <= -5e-107) {
tmp = -y;
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (((x * math.log(y)) - z) - y) <= -5e-107: tmp = -y else: tmp = -z return tmp
function code(x, y, z) tmp = 0.0 if (Float64(Float64(Float64(x * log(y)) - z) - y) <= -5e-107) tmp = Float64(-y); else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((((x * log(y)) - z) - y) <= -5e-107) tmp = -y; else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision] - y), $MachinePrecision], -5e-107], (-y), (-z)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(x \cdot \log y - z\right) - y \leq -5 \cdot 10^{-107}:\\
\;\;\;\;-y\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if (-.f64 (-.f64 (*.f64 x (log.f64 y)) z) y) < -4.99999999999999971e-107Initial program 99.9%
Taylor expanded in y around inf
mul-1-negN/A
lower-neg.f6453.0
Applied rewrites53.0%
if -4.99999999999999971e-107 < (-.f64 (-.f64 (*.f64 x (log.f64 y)) z) y) Initial program 99.8%
Taylor expanded in y around inf
mul-1-negN/A
lower-neg.f643.9
Applied rewrites3.9%
Taylor expanded in y around 0
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
*-commutativeN/A
lower-fma.f64N/A
lower-log.f64N/A
mul-1-negN/A
lower-neg.f6494.3
Applied rewrites94.3%
Taylor expanded in x around 0
Applied rewrites56.6%
(FPCore (x y z) :precision binary64 (if (or (<= x -4.2e+159) (not (<= x 1.9e+103))) (* (log y) x) (- (- z) y)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -4.2e+159) || !(x <= 1.9e+103)) {
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 <= (-4.2d+159)) .or. (.not. (x <= 1.9d+103))) 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 <= -4.2e+159) || !(x <= 1.9e+103)) {
tmp = Math.log(y) * x;
} else {
tmp = -z - y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -4.2e+159) or not (x <= 1.9e+103): tmp = math.log(y) * x else: tmp = -z - y return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -4.2e+159) || !(x <= 1.9e+103)) 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 <= -4.2e+159) || ~((x <= 1.9e+103))) tmp = log(y) * x; else tmp = -z - y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -4.2e+159], N[Not[LessEqual[x, 1.9e+103]], $MachinePrecision]], N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision], N[((-z) - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.2 \cdot 10^{+159} \lor \neg \left(x \leq 1.9 \cdot 10^{+103}\right):\\
\;\;\;\;\log y \cdot x\\
\mathbf{else}:\\
\;\;\;\;\left(-z\right) - y\\
\end{array}
\end{array}
if x < -4.19999999999999978e159 or 1.8999999999999998e103 < x Initial program 99.7%
Taylor expanded in z around 0
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
*-commutativeN/A
lower-fma.f64N/A
lower-log.f64N/A
mul-1-negN/A
lower-neg.f6490.9
Applied rewrites90.9%
Applied rewrites46.2%
Taylor expanded in x around -inf
Applied rewrites69.9%
if -4.19999999999999978e159 < x < 1.8999999999999998e103Initial program 99.9%
Taylor expanded in x around 0
mul-1-negN/A
lower-neg.f6484.9
Applied rewrites84.9%
Final simplification80.8%
(FPCore (x y z) :precision binary64 (if (<= y 1.4e+107) (- (* x (log y)) z) (- (- z) y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.4e+107) {
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 (y <= 1.4d+107) 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 (y <= 1.4e+107) {
tmp = (x * Math.log(y)) - z;
} else {
tmp = -z - y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1.4e+107: tmp = (x * math.log(y)) - z else: tmp = -z - y return tmp
function code(x, y, z) tmp = 0.0 if (y <= 1.4e+107) 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 (y <= 1.4e+107) tmp = (x * log(y)) - z; else tmp = -z - y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1.4e+107], N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], N[((-z) - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.4 \cdot 10^{+107}:\\
\;\;\;\;x \cdot \log y - z\\
\mathbf{else}:\\
\;\;\;\;\left(-z\right) - y\\
\end{array}
\end{array}
if y < 1.39999999999999992e107Initial program 99.8%
Taylor expanded in y around inf
mul-1-negN/A
lower-neg.f6416.4
Applied rewrites16.4%
Taylor expanded in y around 0
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
*-commutativeN/A
lower-fma.f64N/A
lower-log.f64N/A
mul-1-negN/A
lower-neg.f6485.7
Applied rewrites85.7%
Applied rewrites85.8%
if 1.39999999999999992e107 < y Initial program 99.9%
Taylor expanded in x around 0
mul-1-negN/A
lower-neg.f6490.9
Applied rewrites90.9%
(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
mul-1-negN/A
lower-neg.f6468.8
Applied rewrites68.8%
(FPCore (x y z) :precision binary64 (- z))
double code(double x, double y, double z) {
return -z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = -z
end function
public static double code(double x, double y, double z) {
return -z;
}
def code(x, y, z): return -z
function code(x, y, z) return Float64(-z) end
function tmp = code(x, y, z) tmp = -z; end
code[x_, y_, z_] := (-z)
\begin{array}{l}
\\
-z
\end{array}
Initial program 99.9%
Taylor expanded in y around inf
mul-1-negN/A
lower-neg.f6436.7
Applied rewrites36.7%
Taylor expanded in y around 0
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
*-commutativeN/A
lower-fma.f64N/A
lower-log.f64N/A
mul-1-negN/A
lower-neg.f6463.9
Applied rewrites63.9%
Taylor expanded in x around 0
Applied rewrites34.1%
herbie shell --seed 2024337
(FPCore (x y z)
:name "Statistics.Distribution.Poisson:$clogProbability from math-functions-0.1.5.2"
:precision binary64
(- (- (* x (log y)) z) y))