
(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%
(FPCore (x y z)
:precision binary64
(if (or (<= x -4e+249)
(and (not (<= x 1.16e+27)) (or (<= x 9.5e+59) (not (<= x 3.5e+141)))))
(* x (log y))
(- (- z) y)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -4e+249) || (!(x <= 1.16e+27) && ((x <= 9.5e+59) || !(x <= 3.5e+141)))) {
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 <= (-4d+249)) .or. (.not. (x <= 1.16d+27)) .and. (x <= 9.5d+59) .or. (.not. (x <= 3.5d+141))) 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 <= -4e+249) || (!(x <= 1.16e+27) && ((x <= 9.5e+59) || !(x <= 3.5e+141)))) {
tmp = x * Math.log(y);
} else {
tmp = -z - y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -4e+249) or (not (x <= 1.16e+27) and ((x <= 9.5e+59) or not (x <= 3.5e+141))): tmp = x * math.log(y) else: tmp = -z - y return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -4e+249) || (!(x <= 1.16e+27) && ((x <= 9.5e+59) || !(x <= 3.5e+141)))) 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 <= -4e+249) || (~((x <= 1.16e+27)) && ((x <= 9.5e+59) || ~((x <= 3.5e+141))))) tmp = x * log(y); else tmp = -z - y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -4e+249], And[N[Not[LessEqual[x, 1.16e+27]], $MachinePrecision], Or[LessEqual[x, 9.5e+59], N[Not[LessEqual[x, 3.5e+141]], $MachinePrecision]]]], N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision], N[((-z) - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4 \cdot 10^{+249} \lor \neg \left(x \leq 1.16 \cdot 10^{+27}\right) \land \left(x \leq 9.5 \cdot 10^{+59} \lor \neg \left(x \leq 3.5 \cdot 10^{+141}\right)\right):\\
\;\;\;\;x \cdot \log y\\
\mathbf{else}:\\
\;\;\;\;\left(-z\right) - y\\
\end{array}
\end{array}
if x < -3.9999999999999997e249 or 1.16e27 < x < 9.50000000000000023e59 or 3.5e141 < x Initial program 99.5%
Taylor expanded in x around inf 99.5%
mul-1-neg99.5%
unsub-neg99.5%
Simplified99.5%
Taylor expanded in x around inf 91.2%
if -3.9999999999999997e249 < x < 1.16e27 or 9.50000000000000023e59 < x < 3.5e141Initial program 99.9%
Taylor expanded in x around 0 83.7%
neg-mul-183.7%
+-commutative83.7%
distribute-neg-in83.7%
sub-neg83.7%
Simplified83.7%
Final simplification85.3%
(FPCore (x y z) :precision binary64 (if (or (<= x -9.2e-14) (not (<= x 8.6e+26))) (- (* x (log y)) y) (- (- z) y)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -9.2e-14) || !(x <= 8.6e+26)) {
tmp = (x * log(y)) - 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.2d-14)) .or. (.not. (x <= 8.6d+26))) then
tmp = (x * log(y)) - 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.2e-14) || !(x <= 8.6e+26)) {
tmp = (x * Math.log(y)) - y;
} else {
tmp = -z - y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -9.2e-14) or not (x <= 8.6e+26): tmp = (x * math.log(y)) - y else: tmp = -z - y return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -9.2e-14) || !(x <= 8.6e+26)) tmp = Float64(Float64(x * log(y)) - y); else tmp = Float64(Float64(-z) - y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -9.2e-14) || ~((x <= 8.6e+26))) tmp = (x * log(y)) - y; else tmp = -z - y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -9.2e-14], N[Not[LessEqual[x, 8.6e+26]], $MachinePrecision]], N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision], N[((-z) - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9.2 \cdot 10^{-14} \lor \neg \left(x \leq 8.6 \cdot 10^{+26}\right):\\
\;\;\;\;x \cdot \log y - y\\
\mathbf{else}:\\
\;\;\;\;\left(-z\right) - y\\
\end{array}
\end{array}
if x < -9.19999999999999993e-14 or 8.5999999999999996e26 < x Initial program 99.7%
Taylor expanded in z around 0 81.3%
if -9.19999999999999993e-14 < x < 8.5999999999999996e26Initial program 100.0%
Taylor expanded in x around 0 92.6%
neg-mul-192.6%
+-commutative92.6%
distribute-neg-in92.6%
sub-neg92.6%
Simplified92.6%
Final simplification87.4%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* x (log y)))) (if (<= y 1.65e+19) (- t_0 z) (if (<= y 5.5e+157) (- (- z) y) (- t_0 y)))))
double code(double x, double y, double z) {
double t_0 = x * log(y);
double tmp;
if (y <= 1.65e+19) {
tmp = t_0 - z;
} else if (y <= 5.5e+157) {
tmp = -z - y;
} 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.65d+19) then
tmp = t_0 - z
else if (y <= 5.5d+157) then
tmp = -z - y
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.65e+19) {
tmp = t_0 - z;
} else if (y <= 5.5e+157) {
tmp = -z - y;
} else {
tmp = t_0 - y;
}
return tmp;
}
def code(x, y, z): t_0 = x * math.log(y) tmp = 0 if y <= 1.65e+19: tmp = t_0 - z elif y <= 5.5e+157: tmp = -z - y else: tmp = t_0 - y return tmp
function code(x, y, z) t_0 = Float64(x * log(y)) tmp = 0.0 if (y <= 1.65e+19) tmp = Float64(t_0 - z); elseif (y <= 5.5e+157) tmp = Float64(Float64(-z) - y); 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.65e+19) tmp = t_0 - z; elseif (y <= 5.5e+157) tmp = -z - y; 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.65e+19], N[(t$95$0 - z), $MachinePrecision], If[LessEqual[y, 5.5e+157], N[((-z) - y), $MachinePrecision], N[(t$95$0 - y), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \log y\\
\mathbf{if}\;y \leq 1.65 \cdot 10^{+19}:\\
\;\;\;\;t\_0 - z\\
\mathbf{elif}\;y \leq 5.5 \cdot 10^{+157}:\\
\;\;\;\;\left(-z\right) - y\\
\mathbf{else}:\\
\;\;\;\;t\_0 - y\\
\end{array}
\end{array}
if y < 1.65e19Initial program 99.8%
Taylor expanded in y around 0 90.5%
if 1.65e19 < y < 5.5000000000000003e157Initial program 99.9%
Taylor expanded in x around 0 83.2%
neg-mul-183.2%
+-commutative83.2%
distribute-neg-in83.2%
sub-neg83.2%
Simplified83.2%
if 5.5000000000000003e157 < y Initial program 99.9%
Taylor expanded in z around 0 95.1%
(FPCore (x y z) :precision binary64 (if (<= y 290.0) (- z) (- y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 290.0) {
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 <= 290.0d0) 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 <= 290.0) {
tmp = -z;
} else {
tmp = -y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 290.0: tmp = -z else: tmp = -y return tmp
function code(x, y, z) tmp = 0.0 if (y <= 290.0) tmp = Float64(-z); else tmp = Float64(-y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 290.0) tmp = -z; else tmp = -y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 290.0], (-z), (-y)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 290:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;-y\\
\end{array}
\end{array}
if y < 290Initial program 99.8%
Taylor expanded in z around inf 50.6%
neg-mul-150.6%
Simplified50.6%
if 290 < y Initial program 99.9%
Taylor expanded in y around inf 65.2%
neg-mul-165.2%
Simplified65.2%
(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.4%
neg-mul-168.4%
+-commutative68.4%
distribute-neg-in68.4%
sub-neg68.4%
Simplified68.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.8%
Taylor expanded in y around inf 34.6%
neg-mul-134.6%
Simplified34.6%
herbie shell --seed 2024107
(FPCore (x y z)
:name "Statistics.Distribution.Poisson:$clogProbability from math-functions-0.1.5.2"
:precision binary64
(- (- (* x (log y)) z) y))