
(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 8 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.8%
(FPCore (x y z) :precision binary64 (if (or (<= z -5.8e+54) (not (<= z 1.15e+32))) (- (- z) y) (- (* x (log y)) y)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -5.8e+54) || !(z <= 1.15e+32)) {
tmp = -z - y;
} else {
tmp = (x * log(y)) - 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 <= (-5.8d+54)) .or. (.not. (z <= 1.15d+32))) then
tmp = -z - y
else
tmp = (x * log(y)) - y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -5.8e+54) || !(z <= 1.15e+32)) {
tmp = -z - y;
} else {
tmp = (x * Math.log(y)) - y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -5.8e+54) or not (z <= 1.15e+32): tmp = -z - y else: tmp = (x * math.log(y)) - y return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -5.8e+54) || !(z <= 1.15e+32)) tmp = Float64(Float64(-z) - y); else tmp = Float64(Float64(x * log(y)) - y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -5.8e+54) || ~((z <= 1.15e+32))) tmp = -z - y; else tmp = (x * log(y)) - y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -5.8e+54], N[Not[LessEqual[z, 1.15e+32]], $MachinePrecision]], N[((-z) - y), $MachinePrecision], N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.8 \cdot 10^{+54} \lor \neg \left(z \leq 1.15 \cdot 10^{+32}\right):\\
\;\;\;\;\left(-z\right) - y\\
\mathbf{else}:\\
\;\;\;\;x \cdot \log y - y\\
\end{array}
\end{array}
if z < -5.7999999999999997e54 or 1.15e32 < z Initial program 100.0%
Taylor expanded in x around 0 86.5%
neg-mul-186.5%
Simplified86.5%
if -5.7999999999999997e54 < z < 1.15e32Initial program 99.8%
Taylor expanded in z around 0 90.7%
Final simplification88.8%
(FPCore (x y z) :precision binary64 (if (or (<= x -2.9e+197) (not (<= x 6.8e+108))) (* x (log y)) (- (- z) y)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -2.9e+197) || !(x <= 6.8e+108)) {
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 <= (-2.9d+197)) .or. (.not. (x <= 6.8d+108))) 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 <= -2.9e+197) || !(x <= 6.8e+108)) {
tmp = x * Math.log(y);
} else {
tmp = -z - y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -2.9e+197) or not (x <= 6.8e+108): tmp = x * math.log(y) else: tmp = -z - y return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -2.9e+197) || !(x <= 6.8e+108)) 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 <= -2.9e+197) || ~((x <= 6.8e+108))) tmp = x * log(y); else tmp = -z - y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -2.9e+197], N[Not[LessEqual[x, 6.8e+108]], $MachinePrecision]], N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision], N[((-z) - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.9 \cdot 10^{+197} \lor \neg \left(x \leq 6.8 \cdot 10^{+108}\right):\\
\;\;\;\;x \cdot \log y\\
\mathbf{else}:\\
\;\;\;\;\left(-z\right) - y\\
\end{array}
\end{array}
if x < -2.90000000000000002e197 or 6.79999999999999992e108 < x Initial program 99.7%
sub-neg99.7%
associate--l+99.7%
*-commutative99.7%
add-cube-cbrt98.5%
associate-*l*98.5%
fma-define98.5%
pow298.5%
Applied egg-rr98.5%
Taylor expanded in x around inf 74.7%
*-commutative74.7%
Simplified74.7%
if -2.90000000000000002e197 < x < 6.79999999999999992e108Initial program 99.9%
Taylor expanded in x around 0 82.4%
neg-mul-182.4%
Simplified82.4%
Final simplification80.6%
(FPCore (x y z) :precision binary64 (if (<= y 3350000.0) (- (* x (log y)) z) (- (- z) y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 3350000.0) {
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 <= 3350000.0d0) 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 <= 3350000.0) {
tmp = (x * Math.log(y)) - z;
} else {
tmp = -z - y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 3350000.0: tmp = (x * math.log(y)) - z else: tmp = -z - y return tmp
function code(x, y, z) tmp = 0.0 if (y <= 3350000.0) 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 <= 3350000.0) tmp = (x * log(y)) - z; else tmp = -z - y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 3350000.0], N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], N[((-z) - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3350000:\\
\;\;\;\;x \cdot \log y - z\\
\mathbf{else}:\\
\;\;\;\;\left(-z\right) - y\\
\end{array}
\end{array}
if y < 3.35e6Initial program 99.8%
Taylor expanded in y around 0 93.5%
if 3.35e6 < y Initial program 99.9%
Taylor expanded in x around 0 82.8%
neg-mul-182.8%
Simplified82.8%
(FPCore (x y z) :precision binary64 (if (<= y 5.3e-11) (- z) (- y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 5.3e-11) {
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 <= 5.3d-11) 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 <= 5.3e-11) {
tmp = -z;
} else {
tmp = -y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 5.3e-11: tmp = -z else: tmp = -y return tmp
function code(x, y, z) tmp = 0.0 if (y <= 5.3e-11) tmp = Float64(-z); else tmp = Float64(-y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 5.3e-11) tmp = -z; else tmp = -y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 5.3e-11], (-z), (-y)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5.3 \cdot 10^{-11}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;-y\\
\end{array}
\end{array}
if y < 5.2999999999999998e-11Initial program 99.8%
sub-neg99.8%
associate--l+99.8%
*-commutative99.8%
add-cube-cbrt99.2%
associate-*l*99.2%
fma-define99.3%
pow299.3%
Applied egg-rr99.3%
Taylor expanded in z around inf 53.0%
mul-1-neg53.0%
Simplified53.0%
if 5.2999999999999998e-11 < y Initial program 99.9%
Taylor expanded in y around inf 62.5%
neg-mul-162.5%
Simplified62.5%
(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 68.8%
neg-mul-168.8%
Simplified68.8%
(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 34.6%
neg-mul-134.6%
Simplified34.6%
(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.8%
sub-neg99.8%
associate--l+99.8%
*-commutative99.8%
add-cube-cbrt99.4%
associate-*l*99.4%
fma-define99.4%
pow299.4%
Applied egg-rr99.4%
add-sqr-sqrt32.8%
pow232.8%
fma-undefine32.8%
+-commutative32.8%
add-sqr-sqrt25.5%
sqrt-unprod20.0%
sqr-neg20.0%
sqrt-unprod7.4%
add-sqr-sqrt14.6%
associate-*r*14.6%
unpow214.6%
add-cube-cbrt14.7%
Applied egg-rr14.7%
Taylor expanded in z around inf 2.1%
herbie shell --seed 2024091
(FPCore (x y z)
:name "Statistics.Distribution.Poisson:$clogProbability from math-functions-0.1.5.2"
:precision binary64
(- (- (* x (log y)) z) y))