
(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)) y)))
(if (<= x -1.35e+200)
t_0
(if (<= x 6.1e+26)
(- (- z) y)
(if (or (<= x 1.3e+47) (not (<= x 7.6e+57))) t_0 (/ 1.0 (/ -1.0 z)))))))
double code(double x, double y, double z) {
double t_0 = (x * log(y)) - y;
double tmp;
if (x <= -1.35e+200) {
tmp = t_0;
} else if (x <= 6.1e+26) {
tmp = -z - y;
} else if ((x <= 1.3e+47) || !(x <= 7.6e+57)) {
tmp = t_0;
} else {
tmp = 1.0 / (-1.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)) - y
if (x <= (-1.35d+200)) then
tmp = t_0
else if (x <= 6.1d+26) then
tmp = -z - y
else if ((x <= 1.3d+47) .or. (.not. (x <= 7.6d+57))) then
tmp = t_0
else
tmp = 1.0d0 / ((-1.0d0) / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (x * Math.log(y)) - y;
double tmp;
if (x <= -1.35e+200) {
tmp = t_0;
} else if (x <= 6.1e+26) {
tmp = -z - y;
} else if ((x <= 1.3e+47) || !(x <= 7.6e+57)) {
tmp = t_0;
} else {
tmp = 1.0 / (-1.0 / z);
}
return tmp;
}
def code(x, y, z): t_0 = (x * math.log(y)) - y tmp = 0 if x <= -1.35e+200: tmp = t_0 elif x <= 6.1e+26: tmp = -z - y elif (x <= 1.3e+47) or not (x <= 7.6e+57): tmp = t_0 else: tmp = 1.0 / (-1.0 / z) return tmp
function code(x, y, z) t_0 = Float64(Float64(x * log(y)) - y) tmp = 0.0 if (x <= -1.35e+200) tmp = t_0; elseif (x <= 6.1e+26) tmp = Float64(Float64(-z) - y); elseif ((x <= 1.3e+47) || !(x <= 7.6e+57)) tmp = t_0; else tmp = Float64(1.0 / Float64(-1.0 / z)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (x * log(y)) - y; tmp = 0.0; if (x <= -1.35e+200) tmp = t_0; elseif (x <= 6.1e+26) tmp = -z - y; elseif ((x <= 1.3e+47) || ~((x <= 7.6e+57))) tmp = t_0; else tmp = 1.0 / (-1.0 / z); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]}, If[LessEqual[x, -1.35e+200], t$95$0, If[LessEqual[x, 6.1e+26], N[((-z) - y), $MachinePrecision], If[Or[LessEqual[x, 1.3e+47], N[Not[LessEqual[x, 7.6e+57]], $MachinePrecision]], t$95$0, N[(1.0 / N[(-1.0 / z), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \log y - y\\
\mathbf{if}\;x \leq -1.35 \cdot 10^{+200}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 6.1 \cdot 10^{+26}:\\
\;\;\;\;\left(-z\right) - y\\
\mathbf{elif}\;x \leq 1.3 \cdot 10^{+47} \lor \neg \left(x \leq 7.6 \cdot 10^{+57}\right):\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{-1}{z}}\\
\end{array}
\end{array}
if x < -1.35000000000000008e200 or 6.1000000000000003e26 < x < 1.30000000000000002e47 or 7.5999999999999997e57 < x Initial program 99.6%
Taylor expanded in z around 0 90.5%
if -1.35000000000000008e200 < x < 6.1000000000000003e26Initial program 100.0%
Taylor expanded in x around 0 85.2%
neg-mul-185.2%
+-commutative85.2%
distribute-neg-in85.2%
sub-neg85.2%
Simplified85.2%
if 1.30000000000000002e47 < x < 7.5999999999999997e57Initial program 100.0%
Taylor expanded in y around inf 66.1%
associate-*r/66.1%
log-rec66.1%
mul-1-neg66.1%
associate-*r*66.1%
associate-*r*66.1%
neg-mul-166.1%
mul-1-neg66.1%
Simplified66.1%
Taylor expanded in z around inf 51.6%
associate-*r/51.6%
mul-1-neg51.6%
Simplified51.6%
associate-*r/51.8%
clear-num51.8%
add-sqr-sqrt0.4%
sqrt-unprod1.1%
sqr-neg1.1%
sqrt-unprod0.7%
add-sqr-sqrt4.7%
Applied egg-rr4.7%
div-inv4.7%
associate-*r/4.7%
*-commutative4.7%
*-un-lft-identity4.7%
add-sqr-sqrt4.7%
sqrt-unprod1.9%
*-un-lft-identity1.9%
metadata-eval1.9%
swap-sqr1.9%
metadata-eval1.9%
associate-/r/1.9%
metadata-eval1.9%
associate-/r/1.9%
sqrt-unprod0.0%
add-sqr-sqrt51.8%
associate-/r/51.8%
metadata-eval51.8%
neg-mul-151.8%
distribute-neg-frac51.8%
neg-sub051.8%
associate-/r*51.8%
*-inverses51.8%
Applied egg-rr51.8%
neg-sub051.8%
distribute-neg-frac51.8%
metadata-eval51.8%
Simplified51.8%
Final simplification86.4%
(FPCore (x y z)
:precision binary64
(if (or (<= x -1.24e+281)
(not (or (<= x 1.16e+27) (and (not (<= x 5.8e+45)) (<= x 1.45e+87)))))
(* x (log y))
(- (- z) y)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1.24e+281) || !((x <= 1.16e+27) || (!(x <= 5.8e+45) && (x <= 1.45e+87)))) {
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.24d+281)) .or. (.not. (x <= 1.16d+27) .or. (.not. (x <= 5.8d+45)) .and. (x <= 1.45d+87))) 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.24e+281) || !((x <= 1.16e+27) || (!(x <= 5.8e+45) && (x <= 1.45e+87)))) {
tmp = x * Math.log(y);
} else {
tmp = -z - y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -1.24e+281) or not ((x <= 1.16e+27) or (not (x <= 5.8e+45) and (x <= 1.45e+87))): tmp = x * math.log(y) else: tmp = -z - y return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -1.24e+281) || !((x <= 1.16e+27) || (!(x <= 5.8e+45) && (x <= 1.45e+87)))) 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.24e+281) || ~(((x <= 1.16e+27) || (~((x <= 5.8e+45)) && (x <= 1.45e+87))))) tmp = x * log(y); else tmp = -z - y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -1.24e+281], N[Not[Or[LessEqual[x, 1.16e+27], And[N[Not[LessEqual[x, 5.8e+45]], $MachinePrecision], LessEqual[x, 1.45e+87]]]], $MachinePrecision]], N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision], N[((-z) - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.24 \cdot 10^{+281} \lor \neg \left(x \leq 1.16 \cdot 10^{+27} \lor \neg \left(x \leq 5.8 \cdot 10^{+45}\right) \land x \leq 1.45 \cdot 10^{+87}\right):\\
\;\;\;\;x \cdot \log y\\
\mathbf{else}:\\
\;\;\;\;\left(-z\right) - y\\
\end{array}
\end{array}
if x < -1.24e281 or 1.16e27 < x < 5.7999999999999994e45 or 1.4499999999999999e87 < 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 87.7%
if -1.24e281 < x < 1.16e27 or 5.7999999999999994e45 < x < 1.4499999999999999e87Initial program 99.9%
Taylor expanded in x around 0 82.2%
neg-mul-182.2%
+-commutative82.2%
distribute-neg-in82.2%
sub-neg82.2%
Simplified82.2%
Final simplification83.3%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* x (log y)))) (if (<= y 1.65e+19) (- t_0 z) (if (<= y 7.5e+128) (- (- 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 <= 7.5e+128) {
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 <= 7.5d+128) 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 <= 7.5e+128) {
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 <= 7.5e+128: 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 <= 7.5e+128) 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 <= 7.5e+128) 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, 7.5e+128], 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 7.5 \cdot 10^{+128}:\\
\;\;\;\;\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 < 7.50000000000000076e128Initial 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 7.50000000000000076e128 < y Initial program 99.9%
Taylor expanded in z around 0 93.0%
(FPCore (x y z) :precision binary64 (if (or (<= y 1.85e-19) (and (not (<= y 5.1e+73)) (<= y 7e+86))) (- z) (- y)))
double code(double x, double y, double z) {
double tmp;
if ((y <= 1.85e-19) || (!(y <= 5.1e+73) && (y <= 7e+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 <= 1.85d-19) .or. (.not. (y <= 5.1d+73)) .and. (y <= 7d+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 <= 1.85e-19) || (!(y <= 5.1e+73) && (y <= 7e+86))) {
tmp = -z;
} else {
tmp = -y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= 1.85e-19) or (not (y <= 5.1e+73) and (y <= 7e+86)): tmp = -z else: tmp = -y return tmp
function code(x, y, z) tmp = 0.0 if ((y <= 1.85e-19) || (!(y <= 5.1e+73) && (y <= 7e+86))) tmp = Float64(-z); else tmp = Float64(-y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= 1.85e-19) || (~((y <= 5.1e+73)) && (y <= 7e+86))) tmp = -z; else tmp = -y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, 1.85e-19], And[N[Not[LessEqual[y, 5.1e+73]], $MachinePrecision], LessEqual[y, 7e+86]]], (-z), (-y)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.85 \cdot 10^{-19} \lor \neg \left(y \leq 5.1 \cdot 10^{+73}\right) \land y \leq 7 \cdot 10^{+86}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;-y\\
\end{array}
\end{array}
if y < 1.85000000000000003e-19 or 5.10000000000000024e73 < y < 7.00000000000000038e86Initial program 99.8%
Taylor expanded in z around inf 51.0%
neg-mul-151.0%
Simplified51.0%
if 1.85000000000000003e-19 < y < 5.10000000000000024e73 or 7.00000000000000038e86 < y Initial program 99.9%
Taylor expanded in y around inf 65.7%
neg-mul-165.7%
Simplified65.7%
Final simplification57.3%
(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%
(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 x around inf 79.4%
mul-1-neg79.4%
unsub-neg79.4%
Simplified79.4%
Taylor expanded in y around inf 24.9%
mul-1-neg24.9%
distribute-neg-frac224.9%
Simplified24.9%
clear-num24.8%
un-div-inv25.3%
add-sqr-sqrt12.3%
sqrt-unprod9.8%
sqr-neg9.8%
sqrt-unprod1.2%
add-sqr-sqrt2.2%
Applied egg-rr2.2%
associate-/r/2.3%
*-inverses2.3%
*-lft-identity2.3%
Simplified2.3%
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))