
(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 (or (<= x -4e+60)
(not (or (<= x -0.00021) (and (not (<= x -7.1e-69)) (<= x 1.1e+30)))))
(- (* x (log y)) y)
(- (- z) y)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -4e+60) || !((x <= -0.00021) || (!(x <= -7.1e-69) && (x <= 1.1e+30)))) {
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 <= (-4d+60)) .or. (.not. (x <= (-0.00021d0)) .or. (.not. (x <= (-7.1d-69))) .and. (x <= 1.1d+30))) 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 <= -4e+60) || !((x <= -0.00021) || (!(x <= -7.1e-69) && (x <= 1.1e+30)))) {
tmp = (x * Math.log(y)) - y;
} else {
tmp = -z - y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -4e+60) or not ((x <= -0.00021) or (not (x <= -7.1e-69) and (x <= 1.1e+30))): tmp = (x * math.log(y)) - y else: tmp = -z - y return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -4e+60) || !((x <= -0.00021) || (!(x <= -7.1e-69) && (x <= 1.1e+30)))) 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 <= -4e+60) || ~(((x <= -0.00021) || (~((x <= -7.1e-69)) && (x <= 1.1e+30))))) tmp = (x * log(y)) - y; else tmp = -z - y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -4e+60], N[Not[Or[LessEqual[x, -0.00021], And[N[Not[LessEqual[x, -7.1e-69]], $MachinePrecision], LessEqual[x, 1.1e+30]]]], $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 -4 \cdot 10^{+60} \lor \neg \left(x \leq -0.00021 \lor \neg \left(x \leq -7.1 \cdot 10^{-69}\right) \land x \leq 1.1 \cdot 10^{+30}\right):\\
\;\;\;\;x \cdot \log y - y\\
\mathbf{else}:\\
\;\;\;\;\left(-z\right) - y\\
\end{array}
\end{array}
if x < -3.9999999999999998e60 or -2.1000000000000001e-4 < x < -7.0999999999999998e-69 or 1.1e30 < x Initial program 99.7%
Taylor expanded in z around 0 90.6%
if -3.9999999999999998e60 < x < -2.1000000000000001e-4 or -7.0999999999999998e-69 < x < 1.1e30Initial program 100.0%
Taylor expanded in x around 0 93.5%
neg-mul-193.5%
+-commutative93.5%
distribute-neg-in93.5%
sub-neg93.5%
Simplified93.5%
Final simplification92.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (log y))) (t_1 (- t_0 y)))
(if (<= x -6.2e+59)
t_1
(if (<= x -0.00024)
(- t_0 z)
(if (or (<= x -7.7e-69) (not (<= x 7e+30))) t_1 (- (- z) y))))))
double code(double x, double y, double z) {
double t_0 = x * log(y);
double t_1 = t_0 - y;
double tmp;
if (x <= -6.2e+59) {
tmp = t_1;
} else if (x <= -0.00024) {
tmp = t_0 - z;
} else if ((x <= -7.7e-69) || !(x <= 7e+30)) {
tmp = t_1;
} 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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = x * log(y)
t_1 = t_0 - y
if (x <= (-6.2d+59)) then
tmp = t_1
else if (x <= (-0.00024d0)) then
tmp = t_0 - z
else if ((x <= (-7.7d-69)) .or. (.not. (x <= 7d+30))) then
tmp = t_1
else
tmp = -z - 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 t_1 = t_0 - y;
double tmp;
if (x <= -6.2e+59) {
tmp = t_1;
} else if (x <= -0.00024) {
tmp = t_0 - z;
} else if ((x <= -7.7e-69) || !(x <= 7e+30)) {
tmp = t_1;
} else {
tmp = -z - y;
}
return tmp;
}
def code(x, y, z): t_0 = x * math.log(y) t_1 = t_0 - y tmp = 0 if x <= -6.2e+59: tmp = t_1 elif x <= -0.00024: tmp = t_0 - z elif (x <= -7.7e-69) or not (x <= 7e+30): tmp = t_1 else: tmp = -z - y return tmp
function code(x, y, z) t_0 = Float64(x * log(y)) t_1 = Float64(t_0 - y) tmp = 0.0 if (x <= -6.2e+59) tmp = t_1; elseif (x <= -0.00024) tmp = Float64(t_0 - z); elseif ((x <= -7.7e-69) || !(x <= 7e+30)) tmp = t_1; else tmp = Float64(Float64(-z) - y); end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * log(y); t_1 = t_0 - y; tmp = 0.0; if (x <= -6.2e+59) tmp = t_1; elseif (x <= -0.00024) tmp = t_0 - z; elseif ((x <= -7.7e-69) || ~((x <= 7e+30))) tmp = t_1; else tmp = -z - y; 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[(t$95$0 - y), $MachinePrecision]}, If[LessEqual[x, -6.2e+59], t$95$1, If[LessEqual[x, -0.00024], N[(t$95$0 - z), $MachinePrecision], If[Or[LessEqual[x, -7.7e-69], N[Not[LessEqual[x, 7e+30]], $MachinePrecision]], t$95$1, N[((-z) - y), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \log y\\
t_1 := t\_0 - y\\
\mathbf{if}\;x \leq -6.2 \cdot 10^{+59}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq -0.00024:\\
\;\;\;\;t\_0 - z\\
\mathbf{elif}\;x \leq -7.7 \cdot 10^{-69} \lor \neg \left(x \leq 7 \cdot 10^{+30}\right):\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\left(-z\right) - y\\
\end{array}
\end{array}
if x < -6.20000000000000029e59 or -2.40000000000000006e-4 < x < -7.70000000000000008e-69 or 7.00000000000000042e30 < x Initial program 99.7%
Taylor expanded in z around 0 90.6%
if -6.20000000000000029e59 < x < -2.40000000000000006e-4Initial program 99.8%
Taylor expanded in y around 0 80.7%
if -7.70000000000000008e-69 < x < 7.00000000000000042e30Initial program 100.0%
Taylor expanded in x around 0 95.1%
neg-mul-195.1%
+-commutative95.1%
distribute-neg-in95.1%
sub-neg95.1%
Simplified95.1%
Final simplification92.1%
(FPCore (x y z) :precision binary64 (if (or (<= x -7e+133) (not (<= x 1.45e+32))) (* x (log y)) (- (- z) y)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -7e+133) || !(x <= 1.45e+32)) {
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 <= (-7d+133)) .or. (.not. (x <= 1.45d+32))) 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 <= -7e+133) || !(x <= 1.45e+32)) {
tmp = x * Math.log(y);
} else {
tmp = -z - y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -7e+133) or not (x <= 1.45e+32): tmp = x * math.log(y) else: tmp = -z - y return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -7e+133) || !(x <= 1.45e+32)) 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 <= -7e+133) || ~((x <= 1.45e+32))) tmp = x * log(y); else tmp = -z - y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -7e+133], N[Not[LessEqual[x, 1.45e+32]], $MachinePrecision]], N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision], N[((-z) - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -7 \cdot 10^{+133} \lor \neg \left(x \leq 1.45 \cdot 10^{+32}\right):\\
\;\;\;\;x \cdot \log y\\
\mathbf{else}:\\
\;\;\;\;\left(-z\right) - y\\
\end{array}
\end{array}
if x < -6.9999999999999997e133 or 1.45000000000000001e32 < x Initial program 99.6%
sub-neg99.6%
associate--l+99.6%
*-commutative99.6%
add-cube-cbrt98.5%
associate-*r*98.4%
fma-define98.4%
pow298.4%
Applied egg-rr98.4%
Taylor expanded in x around inf 76.6%
if -6.9999999999999997e133 < x < 1.45000000000000001e32Initial program 99.9%
Taylor expanded in x around 0 87.6%
neg-mul-187.6%
+-commutative87.6%
distribute-neg-in87.6%
sub-neg87.6%
Simplified87.6%
Final simplification83.5%
(FPCore (x y z) :precision binary64 (if (or (<= y 5.6e-7) (and (not (<= y 2.8e+15)) (<= y 9.6e+86))) (- z) (- y)))
double code(double x, double y, double z) {
double tmp;
if ((y <= 5.6e-7) || (!(y <= 2.8e+15) && (y <= 9.6e+86))) {
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.6d-7) .or. (.not. (y <= 2.8d+15)) .and. (y <= 9.6d+86)) 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.6e-7) || (!(y <= 2.8e+15) && (y <= 9.6e+86))) {
tmp = -z;
} else {
tmp = -y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= 5.6e-7) or (not (y <= 2.8e+15) and (y <= 9.6e+86)): tmp = -z else: tmp = -y return tmp
function code(x, y, z) tmp = 0.0 if ((y <= 5.6e-7) || (!(y <= 2.8e+15) && (y <= 9.6e+86))) tmp = Float64(-z); else tmp = Float64(-y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= 5.6e-7) || (~((y <= 2.8e+15)) && (y <= 9.6e+86))) tmp = -z; else tmp = -y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, 5.6e-7], And[N[Not[LessEqual[y, 2.8e+15]], $MachinePrecision], LessEqual[y, 9.6e+86]]], (-z), (-y)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5.6 \cdot 10^{-7} \lor \neg \left(y \leq 2.8 \cdot 10^{+15}\right) \land y \leq 9.6 \cdot 10^{+86}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;-y\\
\end{array}
\end{array}
if y < 5.60000000000000038e-7 or 2.8e15 < y < 9.6000000000000001e86Initial program 99.8%
Taylor expanded in z around inf 42.1%
neg-mul-142.1%
Simplified42.1%
if 5.60000000000000038e-7 < y < 2.8e15 or 9.6000000000000001e86 < y Initial program 99.9%
Taylor expanded in y around inf 72.8%
neg-mul-172.8%
Simplified72.8%
Final simplification52.9%
(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 63.4%
neg-mul-163.4%
+-commutative63.4%
distribute-neg-in63.4%
sub-neg63.4%
Simplified63.4%
Final simplification63.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 33.9%
neg-mul-133.9%
Simplified33.9%
Final simplification33.9%
herbie shell --seed 2024059
(FPCore (x y z)
:name "Statistics.Distribution.Poisson:$clogProbability from math-functions-0.1.5.2"
:precision binary64
(- (- (* x (log y)) z) y))