
(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 11 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.9%
sub-neg99.9%
associate--l+99.9%
*-commutative99.9%
fma-def99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (- (- (- z) (* x (log (/ 1.0 y)))) y))
double code(double x, double y, double z) {
return (-z - (x * log((1.0 / y)))) - 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 - (x * log((1.0d0 / y)))) - y
end function
public static double code(double x, double y, double z) {
return (-z - (x * Math.log((1.0 / y)))) - y;
}
def code(x, y, z): return (-z - (x * math.log((1.0 / y)))) - y
function code(x, y, z) return Float64(Float64(Float64(-z) - Float64(x * log(Float64(1.0 / y)))) - y) end
function tmp = code(x, y, z) tmp = (-z - (x * log((1.0 / y)))) - y; end
code[x_, y_, z_] := N[(N[((-z) - N[(x * N[Log[N[(1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(-z\right) - x \cdot \log \left(\frac{1}{y}\right)\right) - y
\end{array}
Initial program 99.9%
Taylor expanded in y around inf 99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (or (<= x -9.8e+154) (not (<= x 5.2e+121))) (- (* (log y) x) y) (- (- z) y)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -9.8e+154) || !(x <= 5.2e+121)) {
tmp = (log(y) * x) - 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.8d+154)) .or. (.not. (x <= 5.2d+121))) then
tmp = (log(y) * x) - 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.8e+154) || !(x <= 5.2e+121)) {
tmp = (Math.log(y) * x) - y;
} else {
tmp = -z - y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -9.8e+154) or not (x <= 5.2e+121): tmp = (math.log(y) * x) - y else: tmp = -z - y return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -9.8e+154) || !(x <= 5.2e+121)) tmp = Float64(Float64(log(y) * x) - y); else tmp = Float64(Float64(-z) - y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -9.8e+154) || ~((x <= 5.2e+121))) tmp = (log(y) * x) - y; else tmp = -z - y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -9.8e+154], N[Not[LessEqual[x, 5.2e+121]], $MachinePrecision]], N[(N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision] - y), $MachinePrecision], N[((-z) - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9.8 \cdot 10^{+154} \lor \neg \left(x \leq 5.2 \cdot 10^{+121}\right):\\
\;\;\;\;\log y \cdot x - y\\
\mathbf{else}:\\
\;\;\;\;\left(-z\right) - y\\
\end{array}
\end{array}
if x < -9.8000000000000003e154 or 5.1999999999999998e121 < x Initial program 99.8%
Taylor expanded in z around 0 90.7%
if -9.8000000000000003e154 < x < 5.1999999999999998e121Initial program 100.0%
Taylor expanded in x around 0 87.0%
neg-mul-187.0%
Simplified87.0%
Final simplification87.9%
(FPCore (x y z) :precision binary64 (if (or (<= x -1.15e+206) (not (<= x 2.2e+123))) (* (log y) x) (- (- z) y)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1.15e+206) || !(x <= 2.2e+123)) {
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 <= (-1.15d+206)) .or. (.not. (x <= 2.2d+123))) 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 <= -1.15e+206) || !(x <= 2.2e+123)) {
tmp = Math.log(y) * x;
} else {
tmp = -z - y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -1.15e+206) or not (x <= 2.2e+123): tmp = math.log(y) * x else: tmp = -z - y return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -1.15e+206) || !(x <= 2.2e+123)) 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 <= -1.15e+206) || ~((x <= 2.2e+123))) tmp = log(y) * x; else tmp = -z - y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -1.15e+206], N[Not[LessEqual[x, 2.2e+123]], $MachinePrecision]], N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision], N[((-z) - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.15 \cdot 10^{+206} \lor \neg \left(x \leq 2.2 \cdot 10^{+123}\right):\\
\;\;\;\;\log y \cdot x\\
\mathbf{else}:\\
\;\;\;\;\left(-z\right) - y\\
\end{array}
\end{array}
if x < -1.15000000000000008e206 or 2.19999999999999992e123 < x Initial program 99.7%
sub-neg99.7%
associate--l+99.7%
*-commutative99.7%
fma-def99.8%
Applied egg-rr99.8%
Taylor expanded in x around inf 78.0%
if -1.15000000000000008e206 < x < 2.19999999999999992e123Initial program 100.0%
Taylor expanded in x around 0 86.0%
neg-mul-186.0%
Simplified86.0%
Final simplification84.2%
(FPCore (x y z) :precision binary64 (if (<= y 1.3e+80) (- (* (log y) x) z) (- (- z) y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.3e+80) {
tmp = (log(y) * x) - 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.3d+80) then
tmp = (log(y) * x) - 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.3e+80) {
tmp = (Math.log(y) * x) - z;
} else {
tmp = -z - y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1.3e+80: tmp = (math.log(y) * x) - z else: tmp = -z - y return tmp
function code(x, y, z) tmp = 0.0 if (y <= 1.3e+80) tmp = Float64(Float64(log(y) * x) - z); else tmp = Float64(Float64(-z) - y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 1.3e+80) tmp = (log(y) * x) - z; else tmp = -z - y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1.3e+80], N[(N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision] - z), $MachinePrecision], N[((-z) - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.3 \cdot 10^{+80}:\\
\;\;\;\;\log y \cdot x - z\\
\mathbf{else}:\\
\;\;\;\;\left(-z\right) - y\\
\end{array}
\end{array}
if y < 1.29999999999999991e80Initial program 99.9%
sub-neg99.9%
associate--l+99.9%
*-commutative99.9%
fma-def99.9%
Applied egg-rr99.9%
Taylor expanded in y around 0 87.6%
if 1.29999999999999991e80 < y Initial program 100.0%
Taylor expanded in x around 0 88.1%
neg-mul-188.1%
Simplified88.1%
Final simplification87.8%
(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.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(if (<= z -1.16e-29)
(- z)
(if (<= z 1.8e-39)
(- y)
(if (or (<= z 2.2e-11) (not (<= z 3.4e+43))) (- z) (- z y)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.16e-29) {
tmp = -z;
} else if (z <= 1.8e-39) {
tmp = -y;
} else if ((z <= 2.2e-11) || !(z <= 3.4e+43)) {
tmp = -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 (z <= (-1.16d-29)) then
tmp = -z
else if (z <= 1.8d-39) then
tmp = -y
else if ((z <= 2.2d-11) .or. (.not. (z <= 3.4d+43))) then
tmp = -z
else
tmp = z - y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -1.16e-29) {
tmp = -z;
} else if (z <= 1.8e-39) {
tmp = -y;
} else if ((z <= 2.2e-11) || !(z <= 3.4e+43)) {
tmp = -z;
} else {
tmp = z - y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.16e-29: tmp = -z elif z <= 1.8e-39: tmp = -y elif (z <= 2.2e-11) or not (z <= 3.4e+43): tmp = -z else: tmp = z - y return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.16e-29) tmp = Float64(-z); elseif (z <= 1.8e-39) tmp = Float64(-y); elseif ((z <= 2.2e-11) || !(z <= 3.4e+43)) tmp = Float64(-z); else tmp = Float64(z - y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.16e-29) tmp = -z; elseif (z <= 1.8e-39) tmp = -y; elseif ((z <= 2.2e-11) || ~((z <= 3.4e+43))) tmp = -z; else tmp = z - y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.16e-29], (-z), If[LessEqual[z, 1.8e-39], (-y), If[Or[LessEqual[z, 2.2e-11], N[Not[LessEqual[z, 3.4e+43]], $MachinePrecision]], (-z), N[(z - y), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.16 \cdot 10^{-29}:\\
\;\;\;\;-z\\
\mathbf{elif}\;z \leq 1.8 \cdot 10^{-39}:\\
\;\;\;\;-y\\
\mathbf{elif}\;z \leq 2.2 \cdot 10^{-11} \lor \neg \left(z \leq 3.4 \cdot 10^{+43}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;z - y\\
\end{array}
\end{array}
if z < -1.15999999999999996e-29 or 1.8e-39 < z < 2.2000000000000002e-11 or 3.40000000000000012e43 < z Initial program 99.9%
sub-neg99.9%
associate--l+99.9%
*-commutative99.9%
fma-def99.9%
Applied egg-rr99.9%
Taylor expanded in z around inf 65.9%
mul-1-neg65.9%
Simplified65.9%
if -1.15999999999999996e-29 < z < 1.8e-39Initial program 99.9%
Taylor expanded in y around inf 56.1%
neg-mul-156.1%
Simplified56.1%
if 2.2000000000000002e-11 < z < 3.40000000000000012e43Initial program 99.9%
sub-neg99.9%
associate--l+99.9%
*-commutative99.9%
fma-def99.9%
Applied egg-rr99.9%
fma-udef99.9%
+-commutative99.9%
add-sqr-sqrt0.0%
sqrt-unprod90.9%
sqr-neg90.9%
sqrt-unprod90.9%
add-sqr-sqrt90.9%
Applied egg-rr90.9%
+-commutative90.9%
fma-def90.9%
Simplified90.9%
Taylor expanded in x around 0 56.6%
Final simplification61.6%
(FPCore (x y z)
:precision binary64
(if (or (<= z -1.55e-29)
(and (not (<= z 1.8e-39)) (or (<= z 3.6e-10) (not (<= z 6.4e+44)))))
(- z)
(- y)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.55e-29) || (!(z <= 1.8e-39) && ((z <= 3.6e-10) || !(z <= 6.4e+44)))) {
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.55d-29)) .or. (.not. (z <= 1.8d-39)) .and. (z <= 3.6d-10) .or. (.not. (z <= 6.4d+44))) 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.55e-29) || (!(z <= 1.8e-39) && ((z <= 3.6e-10) || !(z <= 6.4e+44)))) {
tmp = -z;
} else {
tmp = -y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.55e-29) or (not (z <= 1.8e-39) and ((z <= 3.6e-10) or not (z <= 6.4e+44))): tmp = -z else: tmp = -y return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.55e-29) || (!(z <= 1.8e-39) && ((z <= 3.6e-10) || !(z <= 6.4e+44)))) tmp = Float64(-z); else tmp = Float64(-y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.55e-29) || (~((z <= 1.8e-39)) && ((z <= 3.6e-10) || ~((z <= 6.4e+44))))) tmp = -z; else tmp = -y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.55e-29], And[N[Not[LessEqual[z, 1.8e-39]], $MachinePrecision], Or[LessEqual[z, 3.6e-10], N[Not[LessEqual[z, 6.4e+44]], $MachinePrecision]]]], (-z), (-y)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.55 \cdot 10^{-29} \lor \neg \left(z \leq 1.8 \cdot 10^{-39}\right) \land \left(z \leq 3.6 \cdot 10^{-10} \lor \neg \left(z \leq 6.4 \cdot 10^{+44}\right)\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;-y\\
\end{array}
\end{array}
if z < -1.55000000000000013e-29 or 1.8e-39 < z < 3.6e-10 or 6.40000000000000009e44 < z Initial program 99.9%
sub-neg99.9%
associate--l+99.9%
*-commutative99.9%
fma-def99.9%
Applied egg-rr99.9%
Taylor expanded in z around inf 65.9%
mul-1-neg65.9%
Simplified65.9%
if -1.55000000000000013e-29 < z < 1.8e-39 or 3.6e-10 < z < 6.40000000000000009e44Initial program 99.9%
Taylor expanded in y around inf 56.1%
neg-mul-156.1%
Simplified56.1%
Final simplification61.6%
(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 71.4%
neg-mul-171.4%
Simplified71.4%
Final simplification71.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 32.9%
neg-mul-132.9%
Simplified32.9%
Final simplification32.9%
(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 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%
sub-neg99.9%
associate--l+99.9%
*-commutative99.9%
fma-def99.9%
Applied egg-rr99.9%
fma-udef99.9%
+-commutative99.9%
add-sqr-sqrt55.7%
sqrt-unprod66.3%
sqr-neg66.3%
sqrt-unprod26.2%
add-sqr-sqrt60.0%
Applied egg-rr60.0%
+-commutative60.0%
fma-def60.0%
Simplified60.0%
Taylor expanded in z around inf 2.1%
Final simplification2.1%
herbie shell --seed 2023320
(FPCore (x y z)
:name "Statistics.Distribution.Poisson:$clogProbability from math-functions-0.1.5.2"
:precision binary64
(- (- (* x (log y)) z) y))