
(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.8%
Final simplification99.8%
(FPCore (x y z)
:precision binary64
(if (<= z -3.1e+202)
(- z)
(if (or (<= z -1.5e+165) (and (not (<= z -3.3e+41)) (<= z 1.08e+58)))
(- (* x (log y)) y)
(- (+ y z)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -3.1e+202) {
tmp = -z;
} else if ((z <= -1.5e+165) || (!(z <= -3.3e+41) && (z <= 1.08e+58))) {
tmp = (x * log(y)) - y;
} else {
tmp = -(y + 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 (z <= (-3.1d+202)) then
tmp = -z
else if ((z <= (-1.5d+165)) .or. (.not. (z <= (-3.3d+41))) .and. (z <= 1.08d+58)) then
tmp = (x * log(y)) - y
else
tmp = -(y + z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -3.1e+202) {
tmp = -z;
} else if ((z <= -1.5e+165) || (!(z <= -3.3e+41) && (z <= 1.08e+58))) {
tmp = (x * Math.log(y)) - y;
} else {
tmp = -(y + z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -3.1e+202: tmp = -z elif (z <= -1.5e+165) or (not (z <= -3.3e+41) and (z <= 1.08e+58)): tmp = (x * math.log(y)) - y else: tmp = -(y + z) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -3.1e+202) tmp = Float64(-z); elseif ((z <= -1.5e+165) || (!(z <= -3.3e+41) && (z <= 1.08e+58))) tmp = Float64(Float64(x * log(y)) - y); else tmp = Float64(-Float64(y + z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -3.1e+202) tmp = -z; elseif ((z <= -1.5e+165) || (~((z <= -3.3e+41)) && (z <= 1.08e+58))) tmp = (x * log(y)) - y; else tmp = -(y + z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -3.1e+202], (-z), If[Or[LessEqual[z, -1.5e+165], And[N[Not[LessEqual[z, -3.3e+41]], $MachinePrecision], LessEqual[z, 1.08e+58]]], N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision], (-N[(y + z), $MachinePrecision])]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.1 \cdot 10^{+202}:\\
\;\;\;\;-z\\
\mathbf{elif}\;z \leq -1.5 \cdot 10^{+165} \lor \neg \left(z \leq -3.3 \cdot 10^{+41}\right) \land z \leq 1.08 \cdot 10^{+58}:\\
\;\;\;\;x \cdot \log y - y\\
\mathbf{else}:\\
\;\;\;\;-\left(y + z\right)\\
\end{array}
\end{array}
if z < -3.09999999999999991e202Initial program 99.9%
Taylor expanded in y around 0 99.9%
Taylor expanded in x around 0 89.2%
neg-mul-189.2%
Simplified89.2%
if -3.09999999999999991e202 < z < -1.49999999999999995e165 or -3.3e41 < z < 1.0799999999999999e58Initial program 99.7%
Taylor expanded in z around 0 89.4%
if -1.49999999999999995e165 < z < -3.3e41 or 1.0799999999999999e58 < z Initial program 99.9%
Taylor expanded in x around 0 89.5%
neg-mul-167.3%
Simplified89.5%
Final simplification89.4%
(FPCore (x y z) :precision binary64 (if (or (<= x -5.9e+82) (not (<= x 1.04e+61))) (* x (log y)) (- (+ y z))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -5.9e+82) || !(x <= 1.04e+61)) {
tmp = x * log(y);
} else {
tmp = -(y + 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 <= (-5.9d+82)) .or. (.not. (x <= 1.04d+61))) then
tmp = x * log(y)
else
tmp = -(y + z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -5.9e+82) || !(x <= 1.04e+61)) {
tmp = x * Math.log(y);
} else {
tmp = -(y + z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -5.9e+82) or not (x <= 1.04e+61): tmp = x * math.log(y) else: tmp = -(y + z) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -5.9e+82) || !(x <= 1.04e+61)) tmp = Float64(x * log(y)); else tmp = Float64(-Float64(y + z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -5.9e+82) || ~((x <= 1.04e+61))) tmp = x * log(y); else tmp = -(y + z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -5.9e+82], N[Not[LessEqual[x, 1.04e+61]], $MachinePrecision]], N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision], (-N[(y + z), $MachinePrecision])]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.9 \cdot 10^{+82} \lor \neg \left(x \leq 1.04 \cdot 10^{+61}\right):\\
\;\;\;\;x \cdot \log y\\
\mathbf{else}:\\
\;\;\;\;-\left(y + z\right)\\
\end{array}
\end{array}
if x < -5.8999999999999997e82 or 1.04000000000000003e61 < x Initial program 99.6%
Taylor expanded in y around inf 72.4%
associate-*r/72.4%
mul-1-neg72.4%
log-rec72.4%
Simplified72.4%
add-sqr-sqrt40.7%
sqrt-unprod19.1%
sqr-neg19.1%
sqrt-unprod5.3%
add-sqr-sqrt16.5%
*-commutative16.5%
associate-/l*16.5%
add-sqr-sqrt0.5%
sqrt-unprod53.9%
sqr-neg53.9%
sqrt-unprod53.2%
add-sqr-sqrt72.4%
Applied egg-rr72.4%
Taylor expanded in x around inf 54.2%
*-commutative54.2%
associate-*r/54.2%
Simplified54.2%
Taylor expanded in y around 0 74.6%
if -5.8999999999999997e82 < x < 1.04000000000000003e61Initial program 99.9%
Taylor expanded in x around 0 85.5%
neg-mul-149.5%
Simplified85.5%
Final simplification81.3%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* x (log y)))) (if (<= y 1.15e+116) (- t_0 z) (- t_0 y))))
double code(double x, double y, double z) {
double t_0 = x * log(y);
double tmp;
if (y <= 1.15e+116) {
tmp = t_0 - z;
} else {
tmp = t_0 - 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) :: t_0
real(8) :: tmp
t_0 = x * log(y)
if (y <= 1.15d+116) then
tmp = t_0 - z
else
tmp = t_0 - y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x * Math.log(y);
double tmp;
if (y <= 1.15e+116) {
tmp = t_0 - z;
} else {
tmp = t_0 - y;
}
return tmp;
}
def code(x, y, z): t_0 = x * math.log(y) tmp = 0 if y <= 1.15e+116: tmp = t_0 - z else: tmp = t_0 - y return tmp
function code(x, y, z) t_0 = Float64(x * log(y)) tmp = 0.0 if (y <= 1.15e+116) tmp = Float64(t_0 - z); else tmp = Float64(t_0 - y); end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * log(y); tmp = 0.0; if (y <= 1.15e+116) tmp = t_0 - z; else tmp = t_0 - y; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, 1.15e+116], N[(t$95$0 - z), $MachinePrecision], N[(t$95$0 - y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \log y\\
\mathbf{if}\;y \leq 1.15 \cdot 10^{+116}:\\
\;\;\;\;t\_0 - z\\
\mathbf{else}:\\
\;\;\;\;t\_0 - y\\
\end{array}
\end{array}
if y < 1.14999999999999997e116Initial program 99.7%
Taylor expanded in y around 0 90.9%
if 1.14999999999999997e116 < y Initial program 99.9%
Taylor expanded in z around 0 83.8%
Final simplification88.7%
(FPCore (x y z) :precision binary64 (if (<= y 2.9e+119) (- z) (- y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 2.9e+119) {
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 <= 2.9d+119) 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 <= 2.9e+119) {
tmp = -z;
} else {
tmp = -y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 2.9e+119: tmp = -z else: tmp = -y return tmp
function code(x, y, z) tmp = 0.0 if (y <= 2.9e+119) tmp = Float64(-z); else tmp = Float64(-y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 2.9e+119) tmp = -z; else tmp = -y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 2.9e+119], (-z), (-y)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.9 \cdot 10^{+119}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;-y\\
\end{array}
\end{array}
if y < 2.90000000000000007e119Initial program 99.7%
Taylor expanded in y around 0 90.9%
Taylor expanded in x around 0 45.8%
neg-mul-145.8%
Simplified45.8%
if 2.90000000000000007e119 < y Initial program 99.9%
Taylor expanded in y around inf 64.2%
neg-mul-164.2%
Simplified64.2%
Final simplification51.4%
(FPCore (x y z) :precision binary64 (- (+ y z)))
double code(double x, double y, double z) {
return -(y + z);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = -(y + z)
end function
public static double code(double x, double y, double z) {
return -(y + z);
}
def code(x, y, z): return -(y + z)
function code(x, y, z) return Float64(-Float64(y + z)) end
function tmp = code(x, y, z) tmp = -(y + z); end
code[x_, y_, z_] := (-N[(y + z), $MachinePrecision])
\begin{array}{l}
\\
-\left(y + z\right)
\end{array}
Initial program 99.8%
Taylor expanded in x around 0 62.5%
neg-mul-137.0%
Simplified62.5%
Final simplification62.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 27.5%
neg-mul-127.5%
Simplified27.5%
Final simplification27.5%
herbie shell --seed 2024077
(FPCore (x y z)
:name "Statistics.Distribution.Poisson:$clogProbability from math-functions-0.1.5.2"
:precision binary64
(- (- (* x (log y)) z) y))