
(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 (- (- (* x (- (log (/ 1.0 y)))) z) y))
double code(double x, double y, double z) {
return ((x * -log((1.0 / 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((1.0d0 / y))) - z) - y
end function
public static double code(double x, double y, double z) {
return ((x * -Math.log((1.0 / y))) - z) - y;
}
def code(x, y, z): return ((x * -math.log((1.0 / y))) - z) - y
function code(x, y, z) return Float64(Float64(Float64(x * Float64(-log(Float64(1.0 / y)))) - z) - y) end
function tmp = code(x, y, z) tmp = ((x * -log((1.0 / y))) - z) - y; end
code[x_, y_, z_] := N[(N[(N[(x * (-N[Log[N[(1.0 / y), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] - z), $MachinePrecision] - y), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot \left(-\log \left(\frac{1}{y}\right)\right) - z\right) - y
\end{array}
Initial program 99.9%
Taylor expanded in y around inf 99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (or (<= z -2e+111) (not (<= z 9.8e+122))) (- (- z) y) (- (* x (log y)) y)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -2e+111) || !(z <= 9.8e+122)) {
tmp = -z - y;
} else {
tmp = (x * log(y)) - 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 <= (-2d+111)) .or. (.not. (z <= 9.8d+122))) then
tmp = -z - y
else
tmp = (x * log(y)) - y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -2e+111) || !(z <= 9.8e+122)) {
tmp = -z - y;
} else {
tmp = (x * Math.log(y)) - y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -2e+111) or not (z <= 9.8e+122): tmp = -z - y else: tmp = (x * math.log(y)) - y return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -2e+111) || !(z <= 9.8e+122)) tmp = Float64(Float64(-z) - y); else tmp = Float64(Float64(x * log(y)) - y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -2e+111) || ~((z <= 9.8e+122))) tmp = -z - y; else tmp = (x * log(y)) - y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -2e+111], N[Not[LessEqual[z, 9.8e+122]], $MachinePrecision]], N[((-z) - y), $MachinePrecision], N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2 \cdot 10^{+111} \lor \neg \left(z \leq 9.8 \cdot 10^{+122}\right):\\
\;\;\;\;\left(-z\right) - y\\
\mathbf{else}:\\
\;\;\;\;x \cdot \log y - y\\
\end{array}
\end{array}
if z < -1.99999999999999991e111 or 9.7999999999999995e122 < z Initial program 100.0%
Taylor expanded in x around 0 85.9%
neg-mul-185.9%
Simplified85.9%
if -1.99999999999999991e111 < z < 9.7999999999999995e122Initial program 99.8%
Taylor expanded in z around 0 90.7%
Final simplification89.1%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (log y))))
(if (<= z -2.1e+111)
(- (- z) y)
(if (<= z 2.75e+119) (- t_0 y) (- t_0 z)))))
double code(double x, double y, double z) {
double t_0 = x * log(y);
double tmp;
if (z <= -2.1e+111) {
tmp = -z - y;
} else if (z <= 2.75e+119) {
tmp = t_0 - y;
} else {
tmp = t_0 - 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) :: t_0
real(8) :: tmp
t_0 = x * log(y)
if (z <= (-2.1d+111)) then
tmp = -z - y
else if (z <= 2.75d+119) then
tmp = t_0 - y
else
tmp = t_0 - z
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 (z <= -2.1e+111) {
tmp = -z - y;
} else if (z <= 2.75e+119) {
tmp = t_0 - y;
} else {
tmp = t_0 - z;
}
return tmp;
}
def code(x, y, z): t_0 = x * math.log(y) tmp = 0 if z <= -2.1e+111: tmp = -z - y elif z <= 2.75e+119: tmp = t_0 - y else: tmp = t_0 - z return tmp
function code(x, y, z) t_0 = Float64(x * log(y)) tmp = 0.0 if (z <= -2.1e+111) tmp = Float64(Float64(-z) - y); elseif (z <= 2.75e+119) tmp = Float64(t_0 - y); else tmp = Float64(t_0 - z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * log(y); tmp = 0.0; if (z <= -2.1e+111) tmp = -z - y; elseif (z <= 2.75e+119) tmp = t_0 - y; else tmp = t_0 - z; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -2.1e+111], N[((-z) - y), $MachinePrecision], If[LessEqual[z, 2.75e+119], N[(t$95$0 - y), $MachinePrecision], N[(t$95$0 - z), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \log y\\
\mathbf{if}\;z \leq -2.1 \cdot 10^{+111}:\\
\;\;\;\;\left(-z\right) - y\\
\mathbf{elif}\;z \leq 2.75 \cdot 10^{+119}:\\
\;\;\;\;t_0 - y\\
\mathbf{else}:\\
\;\;\;\;t_0 - z\\
\end{array}
\end{array}
if z < -2.09999999999999995e111Initial program 100.0%
Taylor expanded in x around 0 83.5%
neg-mul-183.5%
Simplified83.5%
if -2.09999999999999995e111 < z < 2.7500000000000002e119Initial program 99.8%
Taylor expanded in z around 0 90.6%
if 2.7500000000000002e119 < z Initial program 100.0%
associate--l-100.0%
*-commutative100.0%
fma-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
sub-neg100.0%
add-sqr-sqrt0.0%
sqrt-unprod88.0%
sqr-neg88.0%
sqrt-unprod94.0%
add-sqr-sqrt94.0%
Applied egg-rr94.0%
Taylor expanded in y around 0 94.4%
Final simplification90.3%
(FPCore (x y z) :precision binary64 (if (or (<= x -3e+124) (not (<= x 8.2e+136))) (* x (log y)) (- (- z) y)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -3e+124) || !(x <= 8.2e+136)) {
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 <= (-3d+124)) .or. (.not. (x <= 8.2d+136))) 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 <= -3e+124) || !(x <= 8.2e+136)) {
tmp = x * Math.log(y);
} else {
tmp = -z - y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -3e+124) or not (x <= 8.2e+136): tmp = x * math.log(y) else: tmp = -z - y return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -3e+124) || !(x <= 8.2e+136)) 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 <= -3e+124) || ~((x <= 8.2e+136))) tmp = x * log(y); else tmp = -z - y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -3e+124], N[Not[LessEqual[x, 8.2e+136]], $MachinePrecision]], N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision], N[((-z) - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3 \cdot 10^{+124} \lor \neg \left(x \leq 8.2 \cdot 10^{+136}\right):\\
\;\;\;\;x \cdot \log y\\
\mathbf{else}:\\
\;\;\;\;\left(-z\right) - y\\
\end{array}
\end{array}
if x < -3e124 or 8.1999999999999995e136 < x Initial program 99.7%
Taylor expanded in z around 0 89.9%
Taylor expanded in x around inf 81.2%
if -3e124 < x < 8.1999999999999995e136Initial program 100.0%
Taylor expanded in x around 0 85.6%
neg-mul-185.6%
Simplified85.6%
Final simplification84.2%
(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.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (or (<= z -2.9e+106) (not (<= z 3.9e+122))) (- z) (- y)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -2.9e+106) || !(z <= 3.9e+122)) {
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 <= (-2.9d+106)) .or. (.not. (z <= 3.9d+122))) 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 <= -2.9e+106) || !(z <= 3.9e+122)) {
tmp = -z;
} else {
tmp = -y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -2.9e+106) or not (z <= 3.9e+122): tmp = -z else: tmp = -y return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -2.9e+106) || !(z <= 3.9e+122)) tmp = Float64(-z); else tmp = Float64(-y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -2.9e+106) || ~((z <= 3.9e+122))) tmp = -z; else tmp = -y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -2.9e+106], N[Not[LessEqual[z, 3.9e+122]], $MachinePrecision]], (-z), (-y)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.9 \cdot 10^{+106} \lor \neg \left(z \leq 3.9 \cdot 10^{+122}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;-y\\
\end{array}
\end{array}
if z < -2.9000000000000002e106 or 3.8999999999999999e122 < z Initial program 100.0%
associate--l-100.0%
*-commutative100.0%
fma-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
sub-neg100.0%
add-sqr-sqrt0.0%
sqrt-unprod77.9%
sqr-neg77.9%
sqrt-unprod88.6%
add-sqr-sqrt88.6%
Applied egg-rr88.6%
Taylor expanded in z around inf 72.0%
neg-mul-172.0%
Simplified72.0%
if -2.9000000000000002e106 < z < 3.8999999999999999e122Initial program 99.9%
Taylor expanded in y around inf 46.1%
mul-1-neg46.1%
Simplified46.1%
Final simplification55.0%
(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.9%
Taylor expanded in x around 0 64.9%
neg-mul-164.9%
Simplified64.9%
Final simplification64.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 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.9%
Taylor expanded in y around inf 34.5%
mul-1-neg34.5%
Simplified34.5%
Final simplification34.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 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.9%
associate--l-99.9%
*-commutative99.9%
fma-neg99.9%
+-commutative99.9%
distribute-neg-out99.9%
sub-neg99.9%
add-sqr-sqrt0.0%
sqrt-unprod59.9%
sqr-neg59.9%
sqrt-unprod66.6%
add-sqr-sqrt66.6%
Applied egg-rr66.6%
Taylor expanded in y around inf 2.1%
Final simplification2.1%
herbie shell --seed 2024013
(FPCore (x y z)
:name "Statistics.Distribution.Poisson:$clogProbability from math-functions-0.1.5.2"
:precision binary64
(- (- (* x (log y)) z) y))