
(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
(let* ((t_0 (* x (log y))))
(if (<= y 3.3e-13)
(- t_0 z)
(if (or (<= y 4.1e+58) (not (<= y 1.1e+147))) (- (- z) y) (- t_0 y)))))
double code(double x, double y, double z) {
double t_0 = x * log(y);
double tmp;
if (y <= 3.3e-13) {
tmp = t_0 - z;
} else if ((y <= 4.1e+58) || !(y <= 1.1e+147)) {
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 <= 3.3d-13) then
tmp = t_0 - z
else if ((y <= 4.1d+58) .or. (.not. (y <= 1.1d+147))) 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 <= 3.3e-13) {
tmp = t_0 - z;
} else if ((y <= 4.1e+58) || !(y <= 1.1e+147)) {
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 <= 3.3e-13: tmp = t_0 - z elif (y <= 4.1e+58) or not (y <= 1.1e+147): 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 <= 3.3e-13) tmp = Float64(t_0 - z); elseif ((y <= 4.1e+58) || !(y <= 1.1e+147)) 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 <= 3.3e-13) tmp = t_0 - z; elseif ((y <= 4.1e+58) || ~((y <= 1.1e+147))) 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, 3.3e-13], N[(t$95$0 - z), $MachinePrecision], If[Or[LessEqual[y, 4.1e+58], N[Not[LessEqual[y, 1.1e+147]], $MachinePrecision]], 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 3.3 \cdot 10^{-13}:\\
\;\;\;\;t\_0 - z\\
\mathbf{elif}\;y \leq 4.1 \cdot 10^{+58} \lor \neg \left(y \leq 1.1 \cdot 10^{+147}\right):\\
\;\;\;\;\left(-z\right) - y\\
\mathbf{else}:\\
\;\;\;\;t\_0 - y\\
\end{array}
\end{array}
if y < 3.3000000000000001e-13Initial program 99.8%
Taylor expanded in y around 0 95.4%
if 3.3000000000000001e-13 < y < 4.1e58 or 1.1000000000000001e147 < y Initial program 99.9%
Taylor expanded in x around 0 88.3%
neg-mul-188.3%
+-commutative88.3%
distribute-neg-in88.3%
sub-neg88.3%
Simplified88.3%
if 4.1e58 < y < 1.1000000000000001e147Initial program 99.8%
Taylor expanded in z around 0 85.2%
Final simplification91.4%
(FPCore (x y z) :precision binary64 (if (or (<= x -2.5e+84) (not (<= x 1.6e+99))) (- (* x (log y)) y) (- (- z) y)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -2.5e+84) || !(x <= 1.6e+99)) {
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 <= (-2.5d+84)) .or. (.not. (x <= 1.6d+99))) 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 <= -2.5e+84) || !(x <= 1.6e+99)) {
tmp = (x * Math.log(y)) - y;
} else {
tmp = -z - y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -2.5e+84) or not (x <= 1.6e+99): tmp = (x * math.log(y)) - y else: tmp = -z - y return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -2.5e+84) || !(x <= 1.6e+99)) 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 <= -2.5e+84) || ~((x <= 1.6e+99))) tmp = (x * log(y)) - y; else tmp = -z - y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -2.5e+84], N[Not[LessEqual[x, 1.6e+99]], $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 -2.5 \cdot 10^{+84} \lor \neg \left(x \leq 1.6 \cdot 10^{+99}\right):\\
\;\;\;\;x \cdot \log y - y\\
\mathbf{else}:\\
\;\;\;\;\left(-z\right) - y\\
\end{array}
\end{array}
if x < -2.5e84 or 1.6e99 < x Initial program 99.7%
Taylor expanded in z around 0 80.7%
if -2.5e84 < x < 1.6e99Initial program 99.9%
Taylor expanded in x around 0 88.4%
neg-mul-188.4%
+-commutative88.4%
distribute-neg-in88.4%
sub-neg88.4%
Simplified88.4%
Final simplification85.5%
(FPCore (x y z) :precision binary64 (if (or (<= x -2.7e+123) (not (<= x 4.5e+122))) (* x (log y)) (- (- z) y)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -2.7e+123) || !(x <= 4.5e+122)) {
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.7d+123)) .or. (.not. (x <= 4.5d+122))) 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.7e+123) || !(x <= 4.5e+122)) {
tmp = x * Math.log(y);
} else {
tmp = -z - y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -2.7e+123) or not (x <= 4.5e+122): tmp = x * math.log(y) else: tmp = -z - y return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -2.7e+123) || !(x <= 4.5e+122)) 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.7e+123) || ~((x <= 4.5e+122))) tmp = x * log(y); else tmp = -z - y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -2.7e+123], N[Not[LessEqual[x, 4.5e+122]], $MachinePrecision]], N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision], N[((-z) - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.7 \cdot 10^{+123} \lor \neg \left(x \leq 4.5 \cdot 10^{+122}\right):\\
\;\;\;\;x \cdot \log y\\
\mathbf{else}:\\
\;\;\;\;\left(-z\right) - y\\
\end{array}
\end{array}
if x < -2.70000000000000013e123 or 4.49999999999999997e122 < x Initial program 99.6%
Taylor expanded in x around inf 74.4%
if -2.70000000000000013e123 < x < 4.49999999999999997e122Initial program 99.9%
Taylor expanded in x around 0 86.1%
neg-mul-186.1%
+-commutative86.1%
distribute-neg-in86.1%
sub-neg86.1%
Simplified86.1%
Final simplification82.3%
(FPCore (x y z) :precision binary64 (if (or (<= z -500000000000.0) (not (<= z 8.2e-5))) (- z) (- y)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -500000000000.0) || !(z <= 8.2e-5)) {
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 ((z <= (-500000000000.0d0)) .or. (.not. (z <= 8.2d-5))) 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 ((z <= -500000000000.0) || !(z <= 8.2e-5)) {
tmp = -z;
} else {
tmp = -y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -500000000000.0) or not (z <= 8.2e-5): tmp = -z else: tmp = -y return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -500000000000.0) || !(z <= 8.2e-5)) tmp = Float64(-z); else tmp = Float64(-y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -500000000000.0) || ~((z <= 8.2e-5))) tmp = -z; else tmp = -y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -500000000000.0], N[Not[LessEqual[z, 8.2e-5]], $MachinePrecision]], (-z), (-y)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -500000000000 \lor \neg \left(z \leq 8.2 \cdot 10^{-5}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;-y\\
\end{array}
\end{array}
if z < -5e11 or 8.20000000000000009e-5 < z Initial program 99.9%
Taylor expanded in z around inf 62.2%
neg-mul-162.2%
Simplified62.2%
if -5e11 < z < 8.20000000000000009e-5Initial program 99.8%
Taylor expanded in y around inf 49.0%
neg-mul-149.0%
Simplified49.0%
Final simplification56.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 66.0%
neg-mul-166.0%
+-commutative66.0%
distribute-neg-in66.0%
sub-neg66.0%
Simplified66.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 29.9%
neg-mul-129.9%
Simplified29.9%
(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%
Taylor expanded in y around inf 29.9%
neg-mul-129.9%
Simplified29.9%
neg-sub029.9%
sub-neg29.9%
add-sqr-sqrt0.0%
sqrt-unprod2.4%
sqr-neg2.4%
sqrt-unprod2.4%
add-sqr-sqrt2.4%
Applied egg-rr2.4%
+-lft-identity2.4%
Simplified2.4%
herbie shell --seed 2024132
(FPCore (x y z)
:name "Statistics.Distribution.Poisson:$clogProbability from math-functions-0.1.5.2"
:precision binary64
(- (- (* x (log y)) z) y))