
(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 10 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 (- (- (* 3.0 (* x (log (cbrt y)))) z) y))
double code(double x, double y, double z) {
return ((3.0 * (x * log(cbrt(y)))) - z) - y;
}
public static double code(double x, double y, double z) {
return ((3.0 * (x * Math.log(Math.cbrt(y)))) - z) - y;
}
function code(x, y, z) return Float64(Float64(Float64(3.0 * Float64(x * log(cbrt(y)))) - z) - y) end
code[x_, y_, z_] := N[(N[(N[(3.0 * N[(x * N[Log[N[Power[y, 1/3], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision] - y), $MachinePrecision]
\begin{array}{l}
\\
\left(3 \cdot \left(x \cdot \log \left(\sqrt[3]{y}\right)\right) - z\right) - y
\end{array}
Initial program 99.8%
add-cube-cbrt99.8%
log-prod99.8%
pow299.8%
Applied egg-rr99.8%
distribute-lft-in99.8%
*-commutative99.8%
log-pow99.8%
associate-*l*99.8%
*-commutative99.8%
Applied egg-rr99.8%
distribute-lft1-in99.8%
metadata-eval99.8%
Simplified99.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (- z) y)) (t_1 (* x (log y))))
(if (<= z -1.55e+72)
t_0
(if (<= z 8.4e+14) (- t_1 y) (if (<= z 8.8e+126) t_0 (- t_1 z))))))
double code(double x, double y, double z) {
double t_0 = -z - y;
double t_1 = x * log(y);
double tmp;
if (z <= -1.55e+72) {
tmp = t_0;
} else if (z <= 8.4e+14) {
tmp = t_1 - y;
} else if (z <= 8.8e+126) {
tmp = t_0;
} else {
tmp = t_1 - 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) :: t_1
real(8) :: tmp
t_0 = -z - y
t_1 = x * log(y)
if (z <= (-1.55d+72)) then
tmp = t_0
else if (z <= 8.4d+14) then
tmp = t_1 - y
else if (z <= 8.8d+126) then
tmp = t_0
else
tmp = t_1 - z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = -z - y;
double t_1 = x * Math.log(y);
double tmp;
if (z <= -1.55e+72) {
tmp = t_0;
} else if (z <= 8.4e+14) {
tmp = t_1 - y;
} else if (z <= 8.8e+126) {
tmp = t_0;
} else {
tmp = t_1 - z;
}
return tmp;
}
def code(x, y, z): t_0 = -z - y t_1 = x * math.log(y) tmp = 0 if z <= -1.55e+72: tmp = t_0 elif z <= 8.4e+14: tmp = t_1 - y elif z <= 8.8e+126: tmp = t_0 else: tmp = t_1 - z return tmp
function code(x, y, z) t_0 = Float64(Float64(-z) - y) t_1 = Float64(x * log(y)) tmp = 0.0 if (z <= -1.55e+72) tmp = t_0; elseif (z <= 8.4e+14) tmp = Float64(t_1 - y); elseif (z <= 8.8e+126) tmp = t_0; else tmp = Float64(t_1 - z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = -z - y; t_1 = x * log(y); tmp = 0.0; if (z <= -1.55e+72) tmp = t_0; elseif (z <= 8.4e+14) tmp = t_1 - y; elseif (z <= 8.8e+126) tmp = t_0; else tmp = t_1 - z; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[((-z) - y), $MachinePrecision]}, Block[{t$95$1 = N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.55e+72], t$95$0, If[LessEqual[z, 8.4e+14], N[(t$95$1 - y), $MachinePrecision], If[LessEqual[z, 8.8e+126], t$95$0, N[(t$95$1 - z), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(-z\right) - y\\
t_1 := x \cdot \log y\\
\mathbf{if}\;z \leq -1.55 \cdot 10^{+72}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 8.4 \cdot 10^{+14}:\\
\;\;\;\;t\_1 - y\\
\mathbf{elif}\;z \leq 8.8 \cdot 10^{+126}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1 - z\\
\end{array}
\end{array}
if z < -1.54999999999999994e72 or 8.4e14 < z < 8.79999999999999994e126Initial program 99.9%
Taylor expanded in x around 0 84.3%
neg-mul-184.3%
+-commutative84.3%
distribute-neg-in84.3%
sub-neg84.3%
Simplified84.3%
if -1.54999999999999994e72 < z < 8.4e14Initial program 99.8%
Taylor expanded in z around 0 94.7%
if 8.79999999999999994e126 < z Initial program 99.8%
Taylor expanded in y around 0 96.6%
(FPCore (x y z) :precision binary64 (if (or (<= z -4.5e+72) (not (<= z 1.4e+14))) (- (- z) y) (- (* x (log y)) y)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -4.5e+72) || !(z <= 1.4e+14)) {
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 <= (-4.5d+72)) .or. (.not. (z <= 1.4d+14))) 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 <= -4.5e+72) || !(z <= 1.4e+14)) {
tmp = -z - y;
} else {
tmp = (x * Math.log(y)) - y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -4.5e+72) or not (z <= 1.4e+14): tmp = -z - y else: tmp = (x * math.log(y)) - y return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -4.5e+72) || !(z <= 1.4e+14)) 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 <= -4.5e+72) || ~((z <= 1.4e+14))) tmp = -z - y; else tmp = (x * log(y)) - y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -4.5e+72], N[Not[LessEqual[z, 1.4e+14]], $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 -4.5 \cdot 10^{+72} \lor \neg \left(z \leq 1.4 \cdot 10^{+14}\right):\\
\;\;\;\;\left(-z\right) - y\\
\mathbf{else}:\\
\;\;\;\;x \cdot \log y - y\\
\end{array}
\end{array}
if z < -4.4999999999999998e72 or 1.4e14 < z Initial program 99.9%
Taylor expanded in x around 0 81.7%
neg-mul-181.7%
+-commutative81.7%
distribute-neg-in81.7%
sub-neg81.7%
Simplified81.7%
if -4.4999999999999998e72 < z < 1.4e14Initial program 99.8%
Taylor expanded in z around 0 94.7%
Final simplification89.2%
(FPCore (x y z) :precision binary64 (if (or (<= x -1.2e+134) (not (<= x 1.35e+126))) (* x (log y)) (- (- z) y)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1.2e+134) || !(x <= 1.35e+126)) {
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 <= (-1.2d+134)) .or. (.not. (x <= 1.35d+126))) 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 <= -1.2e+134) || !(x <= 1.35e+126)) {
tmp = x * Math.log(y);
} else {
tmp = -z - y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -1.2e+134) or not (x <= 1.35e+126): tmp = x * math.log(y) else: tmp = -z - y return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -1.2e+134) || !(x <= 1.35e+126)) 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 <= -1.2e+134) || ~((x <= 1.35e+126))) tmp = x * log(y); else tmp = -z - y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -1.2e+134], N[Not[LessEqual[x, 1.35e+126]], $MachinePrecision]], N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision], N[((-z) - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.2 \cdot 10^{+134} \lor \neg \left(x \leq 1.35 \cdot 10^{+126}\right):\\
\;\;\;\;x \cdot \log y\\
\mathbf{else}:\\
\;\;\;\;\left(-z\right) - y\\
\end{array}
\end{array}
if x < -1.20000000000000003e134 or 1.35000000000000001e126 < x Initial program 99.6%
Taylor expanded in y around inf 62.5%
sub-neg62.5%
mul-1-neg62.5%
log-rec62.5%
mul-1-neg62.5%
associate-/l*62.5%
distribute-rgt-neg-in62.5%
mul-1-neg62.5%
distribute-frac-neg62.5%
remove-double-neg62.5%
distribute-neg-in62.5%
metadata-eval62.5%
unsub-neg62.5%
Simplified62.5%
Taylor expanded in x around inf 73.0%
if -1.20000000000000003e134 < x < 1.35000000000000001e126Initial program 99.9%
Taylor expanded in x around 0 85.4%
neg-mul-185.4%
+-commutative85.4%
distribute-neg-in85.4%
sub-neg85.4%
Simplified85.4%
Final simplification81.7%
(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 (<= z -1e+62) (not (<= z 1.6e+34))) (- z) (- y)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1e+62) || !(z <= 1.6e+34)) {
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 <= (-1d+62)) .or. (.not. (z <= 1.6d+34))) 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 <= -1e+62) || !(z <= 1.6e+34)) {
tmp = -z;
} else {
tmp = -y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1e+62) or not (z <= 1.6e+34): tmp = -z else: tmp = -y return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1e+62) || !(z <= 1.6e+34)) tmp = Float64(-z); else tmp = Float64(-y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1e+62) || ~((z <= 1.6e+34))) tmp = -z; else tmp = -y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1e+62], N[Not[LessEqual[z, 1.6e+34]], $MachinePrecision]], (-z), (-y)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \cdot 10^{+62} \lor \neg \left(z \leq 1.6 \cdot 10^{+34}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;-y\\
\end{array}
\end{array}
if z < -1.00000000000000004e62 or 1.5999999999999999e34 < z Initial program 99.9%
Taylor expanded in z around inf 61.8%
neg-mul-161.8%
Simplified61.8%
if -1.00000000000000004e62 < z < 1.5999999999999999e34Initial program 99.8%
Taylor expanded in y around inf 53.6%
neg-mul-153.6%
Simplified53.6%
Final simplification57.1%
(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 67.5%
neg-mul-167.5%
+-commutative67.5%
distribute-neg-in67.5%
sub-neg67.5%
Simplified67.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 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 39.4%
neg-mul-139.4%
Simplified39.4%
(FPCore (x y z) :precision binary64 z)
double code(double x, double y, double z) {
return z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = z
end function
public static double code(double x, double y, double z) {
return z;
}
def code(x, y, z): return z
function code(x, y, z) return z end
function tmp = code(x, y, z) tmp = z; end
code[x_, y_, z_] := z
\begin{array}{l}
\\
z
\end{array}
Initial program 99.8%
Taylor expanded in z around inf 30.2%
neg-mul-130.2%
Simplified30.2%
neg-sub030.2%
sub-neg30.2%
add-sqr-sqrt13.7%
sqrt-unprod6.4%
sqr-neg6.4%
sqrt-unprod1.0%
add-sqr-sqrt2.5%
Applied egg-rr2.5%
+-lft-identity2.5%
Simplified2.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.8%
Taylor expanded in y around inf 39.4%
neg-mul-139.4%
Simplified39.4%
neg-sub039.4%
sub-neg39.4%
add-sqr-sqrt0.0%
sqrt-unprod2.1%
sqr-neg2.1%
sqrt-unprod2.2%
add-sqr-sqrt2.2%
Applied egg-rr2.2%
+-lft-identity2.2%
Simplified2.2%
herbie shell --seed 2024135
(FPCore (x y z)
:name "Statistics.Distribution.Poisson:$clogProbability from math-functions-0.1.5.2"
:precision binary64
(- (- (* x (log y)) z) y))