
(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 9 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 x (log y) (- (- y) z)))
double code(double x, double y, double z) {
return fma(x, log(y), (-y - z));
}
function code(x, y, z) return fma(x, log(y), Float64(Float64(-y) - z)) end
code[x_, y_, z_] := N[(x * N[Log[y], $MachinePrecision] + N[((-y) - z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(x, \log y, \left(-y\right) - z\right)
\end{array}
Initial program 99.8%
associate--l-99.8%
fma-neg99.8%
distribute-neg-in99.8%
+-commutative99.8%
sub-neg99.8%
Simplified99.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (log y))) (t_1 (- (- y) z)))
(if (<= x -2.15e+55)
t_0
(if (<= x 4.5e-5)
t_1
(if (or (<= x 5.8e+19)
(not
(or (<= x 2.6e+112)
(and (not (<= x 3e+202)) (<= x 1.1e+216)))))
t_0
(* x (/ t_1 x)))))))
double code(double x, double y, double z) {
double t_0 = x * log(y);
double t_1 = -y - z;
double tmp;
if (x <= -2.15e+55) {
tmp = t_0;
} else if (x <= 4.5e-5) {
tmp = t_1;
} else if ((x <= 5.8e+19) || !((x <= 2.6e+112) || (!(x <= 3e+202) && (x <= 1.1e+216)))) {
tmp = t_0;
} else {
tmp = x * (t_1 / x);
}
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) :: t_1
real(8) :: tmp
t_0 = x * log(y)
t_1 = -y - z
if (x <= (-2.15d+55)) then
tmp = t_0
else if (x <= 4.5d-5) then
tmp = t_1
else if ((x <= 5.8d+19) .or. (.not. (x <= 2.6d+112) .or. (.not. (x <= 3d+202)) .and. (x <= 1.1d+216))) then
tmp = t_0
else
tmp = x * (t_1 / x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x * Math.log(y);
double t_1 = -y - z;
double tmp;
if (x <= -2.15e+55) {
tmp = t_0;
} else if (x <= 4.5e-5) {
tmp = t_1;
} else if ((x <= 5.8e+19) || !((x <= 2.6e+112) || (!(x <= 3e+202) && (x <= 1.1e+216)))) {
tmp = t_0;
} else {
tmp = x * (t_1 / x);
}
return tmp;
}
def code(x, y, z): t_0 = x * math.log(y) t_1 = -y - z tmp = 0 if x <= -2.15e+55: tmp = t_0 elif x <= 4.5e-5: tmp = t_1 elif (x <= 5.8e+19) or not ((x <= 2.6e+112) or (not (x <= 3e+202) and (x <= 1.1e+216))): tmp = t_0 else: tmp = x * (t_1 / x) return tmp
function code(x, y, z) t_0 = Float64(x * log(y)) t_1 = Float64(Float64(-y) - z) tmp = 0.0 if (x <= -2.15e+55) tmp = t_0; elseif (x <= 4.5e-5) tmp = t_1; elseif ((x <= 5.8e+19) || !((x <= 2.6e+112) || (!(x <= 3e+202) && (x <= 1.1e+216)))) tmp = t_0; else tmp = Float64(x * Float64(t_1 / x)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * log(y); t_1 = -y - z; tmp = 0.0; if (x <= -2.15e+55) tmp = t_0; elseif (x <= 4.5e-5) tmp = t_1; elseif ((x <= 5.8e+19) || ~(((x <= 2.6e+112) || (~((x <= 3e+202)) && (x <= 1.1e+216))))) tmp = t_0; else tmp = x * (t_1 / x); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[((-y) - z), $MachinePrecision]}, If[LessEqual[x, -2.15e+55], t$95$0, If[LessEqual[x, 4.5e-5], t$95$1, If[Or[LessEqual[x, 5.8e+19], N[Not[Or[LessEqual[x, 2.6e+112], And[N[Not[LessEqual[x, 3e+202]], $MachinePrecision], LessEqual[x, 1.1e+216]]]], $MachinePrecision]], t$95$0, N[(x * N[(t$95$1 / x), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \log y\\
t_1 := \left(-y\right) - z\\
\mathbf{if}\;x \leq -2.15 \cdot 10^{+55}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 4.5 \cdot 10^{-5}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 5.8 \cdot 10^{+19} \lor \neg \left(x \leq 2.6 \cdot 10^{+112} \lor \neg \left(x \leq 3 \cdot 10^{+202}\right) \land x \leq 1.1 \cdot 10^{+216}\right):\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{t\_1}{x}\\
\end{array}
\end{array}
if x < -2.1499999999999999e55 or 4.50000000000000028e-5 < x < 5.8e19 or 2.6000000000000001e112 < x < 3.0000000000000001e202 or 1.1e216 < x Initial program 99.7%
Taylor expanded in x around inf 72.7%
if -2.1499999999999999e55 < x < 4.50000000000000028e-5Initial program 99.9%
Taylor expanded in x around 0 89.7%
mul-1-neg89.7%
+-commutative89.7%
distribute-neg-in89.7%
sub-neg89.7%
Simplified89.7%
if 5.8e19 < x < 2.6000000000000001e112 or 3.0000000000000001e202 < x < 1.1e216Initial program 99.8%
Taylor expanded in x around inf 99.8%
mul-1-neg99.8%
unsub-neg99.8%
Simplified99.8%
Taylor expanded in x around 0 73.7%
associate-*r/73.7%
+-commutative73.7%
distribute-lft-in73.7%
mul-1-neg73.7%
sub-neg73.7%
mul-1-neg73.7%
Simplified73.7%
Final simplification81.4%
(FPCore (x y z) :precision binary64 (if (or (<= x -8.5e-71) (not (<= x 5.8e-6))) (- (* x (log y)) y) (- (- y) z)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -8.5e-71) || !(x <= 5.8e-6)) {
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 ((x <= (-8.5d-71)) .or. (.not. (x <= 5.8d-6))) 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 ((x <= -8.5e-71) || !(x <= 5.8e-6)) {
tmp = (x * Math.log(y)) - y;
} else {
tmp = -y - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -8.5e-71) or not (x <= 5.8e-6): tmp = (x * math.log(y)) - y else: tmp = -y - z return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -8.5e-71) || !(x <= 5.8e-6)) 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 ((x <= -8.5e-71) || ~((x <= 5.8e-6))) tmp = (x * log(y)) - y; else tmp = -y - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -8.5e-71], N[Not[LessEqual[x, 5.8e-6]], $MachinePrecision]], N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision], N[((-y) - z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -8.5 \cdot 10^{-71} \lor \neg \left(x \leq 5.8 \cdot 10^{-6}\right):\\
\;\;\;\;x \cdot \log y - y\\
\mathbf{else}:\\
\;\;\;\;\left(-y\right) - z\\
\end{array}
\end{array}
if x < -8.49999999999999988e-71 or 5.8000000000000004e-6 < x Initial program 99.7%
Taylor expanded in z around 0 79.3%
if -8.49999999999999988e-71 < x < 5.8000000000000004e-6Initial program 100.0%
Taylor expanded in x around 0 94.9%
mul-1-neg94.9%
+-commutative94.9%
distribute-neg-in94.9%
sub-neg94.9%
Simplified94.9%
Final simplification86.1%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* x (log y)))) (if (<= y 1.55e+95) (- 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.55e+95) {
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.55d+95) 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.55e+95) {
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.55e+95: 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.55e+95) 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.55e+95) 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.55e+95], 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.55 \cdot 10^{+95}:\\
\;\;\;\;t\_0 - z\\
\mathbf{else}:\\
\;\;\;\;t\_0 - y\\
\end{array}
\end{array}
if y < 1.5500000000000001e95Initial program 99.8%
Taylor expanded in y around 0 89.5%
if 1.5500000000000001e95 < y Initial program 99.9%
Taylor expanded in z around 0 85.4%
(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 (<= y 8e+94) (- z) (- y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 8e+94) {
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 <= 8d+94) 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 <= 8e+94) {
tmp = -z;
} else {
tmp = -y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 8e+94: tmp = -z else: tmp = -y return tmp
function code(x, y, z) tmp = 0.0 if (y <= 8e+94) tmp = Float64(-z); else tmp = Float64(-y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 8e+94) tmp = -z; else tmp = -y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 8e+94], (-z), (-y)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 8 \cdot 10^{+94}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;-y\\
\end{array}
\end{array}
if y < 8.0000000000000002e94Initial program 99.8%
Taylor expanded in z around inf 42.9%
neg-mul-142.9%
Simplified42.9%
if 8.0000000000000002e94 < y Initial program 99.9%
Taylor expanded in y around inf 68.0%
mul-1-neg68.0%
Simplified68.0%
(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\right) - z
\end{array}
Initial program 99.8%
Taylor expanded in x around 0 63.0%
mul-1-neg63.0%
+-commutative63.0%
distribute-neg-in63.0%
sub-neg63.0%
Simplified63.0%
Final simplification63.0%
(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 31.2%
mul-1-neg31.2%
Simplified31.2%
(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 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%
associate--l-99.8%
fma-neg99.8%
+-commutative99.8%
distribute-neg-out99.8%
sub-neg99.8%
add-cube-cbrt97.9%
pow397.9%
Applied egg-rr67.8%
Taylor expanded in y around inf 2.4%
herbie shell --seed 2024097
(FPCore (x y z)
:name "Statistics.Distribution.Poisson:$clogProbability from math-functions-0.1.5.2"
:precision binary64
(- (- (* x (log y)) z) y))