
(FPCore (x y z t) :precision binary64 (- (+ (* (- x 1.0) (log y)) (* (- z 1.0) (log (- 1.0 y)))) t))
double code(double x, double y, double z, double t) {
return (((x - 1.0) * log(y)) + ((z - 1.0) * log((1.0 - y)))) - t;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = (((x - 1.0d0) * log(y)) + ((z - 1.0d0) * log((1.0d0 - y)))) - t
end function
public static double code(double x, double y, double z, double t) {
return (((x - 1.0) * Math.log(y)) + ((z - 1.0) * Math.log((1.0 - y)))) - t;
}
def code(x, y, z, t): return (((x - 1.0) * math.log(y)) + ((z - 1.0) * math.log((1.0 - y)))) - t
function code(x, y, z, t) return Float64(Float64(Float64(Float64(x - 1.0) * log(y)) + Float64(Float64(z - 1.0) * log(Float64(1.0 - y)))) - t) end
function tmp = code(x, y, z, t) tmp = (((x - 1.0) * log(y)) + ((z - 1.0) * log((1.0 - y)))) - t; end
code[x_, y_, z_, t_] := N[(N[(N[(N[(x - 1.0), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision] + N[(N[(z - 1.0), $MachinePrecision] * N[Log[N[(1.0 - y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x - 1\right) \cdot \log y + \left(z - 1\right) \cdot \log \left(1 - y\right)\right) - t
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (- (+ (* (- x 1.0) (log y)) (* (- z 1.0) (log (- 1.0 y)))) t))
double code(double x, double y, double z, double t) {
return (((x - 1.0) * log(y)) + ((z - 1.0) * log((1.0 - y)))) - t;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = (((x - 1.0d0) * log(y)) + ((z - 1.0d0) * log((1.0d0 - y)))) - t
end function
public static double code(double x, double y, double z, double t) {
return (((x - 1.0) * Math.log(y)) + ((z - 1.0) * Math.log((1.0 - y)))) - t;
}
def code(x, y, z, t): return (((x - 1.0) * math.log(y)) + ((z - 1.0) * math.log((1.0 - y)))) - t
function code(x, y, z, t) return Float64(Float64(Float64(Float64(x - 1.0) * log(y)) + Float64(Float64(z - 1.0) * log(Float64(1.0 - y)))) - t) end
function tmp = code(x, y, z, t) tmp = (((x - 1.0) * log(y)) + ((z - 1.0) * log((1.0 - y)))) - t; end
code[x_, y_, z_, t_] := N[(N[(N[(N[(x - 1.0), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision] + N[(N[(z - 1.0), $MachinePrecision] * N[Log[N[(1.0 - y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x - 1\right) \cdot \log y + \left(z - 1\right) \cdot \log \left(1 - y\right)\right) - t
\end{array}
(FPCore (x y z t) :precision binary64 (- (+ (* (log1p (- y)) z) (* (+ x -1.0) (log y))) t))
double code(double x, double y, double z, double t) {
return ((log1p(-y) * z) + ((x + -1.0) * log(y))) - t;
}
public static double code(double x, double y, double z, double t) {
return ((Math.log1p(-y) * z) + ((x + -1.0) * Math.log(y))) - t;
}
def code(x, y, z, t): return ((math.log1p(-y) * z) + ((x + -1.0) * math.log(y))) - t
function code(x, y, z, t) return Float64(Float64(Float64(log1p(Float64(-y)) * z) + Float64(Float64(x + -1.0) * log(y))) - t) end
code[x_, y_, z_, t_] := N[(N[(N[(N[Log[1 + (-y)], $MachinePrecision] * z), $MachinePrecision] + N[(N[(x + -1.0), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\left(\mathsf{log1p}\left(-y\right) \cdot z + \left(x + -1\right) \cdot \log y\right) - t
\end{array}
Initial program 88.4%
Taylor expanded in z around inf 88.4%
*-commutative88.4%
sub-neg88.4%
mul-1-neg88.4%
log1p-def99.8%
mul-1-neg99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (x y z t) :precision binary64 (+ (fma y (- 1.0 z) (- t)) (* (log y) (+ x -1.0))))
double code(double x, double y, double z, double t) {
return fma(y, (1.0 - z), -t) + (log(y) * (x + -1.0));
}
function code(x, y, z, t) return Float64(fma(y, Float64(1.0 - z), Float64(-t)) + Float64(log(y) * Float64(x + -1.0))) end
code[x_, y_, z_, t_] := N[(N[(y * N[(1.0 - z), $MachinePrecision] + (-t)), $MachinePrecision] + N[(N[Log[y], $MachinePrecision] * N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(y, 1 - z, -t\right) + \log y \cdot \left(x + -1\right)
\end{array}
Initial program 88.4%
Taylor expanded in y around 0 99.3%
mul-1-neg99.3%
sub-neg99.3%
metadata-eval99.3%
distribute-rgt-neg-in99.3%
mul-1-neg99.3%
+-commutative99.3%
distribute-lft-in99.3%
metadata-eval99.3%
neg-mul-199.3%
unsub-neg99.3%
Simplified99.3%
associate--l+99.3%
+-commutative99.3%
fma-neg99.4%
sub-neg99.4%
metadata-eval99.4%
Applied egg-rr99.4%
Final simplification99.4%
(FPCore (x y z t) :precision binary64 (if (or (<= (+ x -1.0) -4000000000.0) (not (<= (+ x -1.0) -1.0))) (- (* (+ x -1.0) (log y)) t) (- (- (* y (- z)) (log y)) t)))
double code(double x, double y, double z, double t) {
double tmp;
if (((x + -1.0) <= -4000000000.0) || !((x + -1.0) <= -1.0)) {
tmp = ((x + -1.0) * log(y)) - t;
} else {
tmp = ((y * -z) - log(y)) - t;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (((x + (-1.0d0)) <= (-4000000000.0d0)) .or. (.not. ((x + (-1.0d0)) <= (-1.0d0)))) then
tmp = ((x + (-1.0d0)) * log(y)) - t
else
tmp = ((y * -z) - log(y)) - t
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (((x + -1.0) <= -4000000000.0) || !((x + -1.0) <= -1.0)) {
tmp = ((x + -1.0) * Math.log(y)) - t;
} else {
tmp = ((y * -z) - Math.log(y)) - t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if ((x + -1.0) <= -4000000000.0) or not ((x + -1.0) <= -1.0): tmp = ((x + -1.0) * math.log(y)) - t else: tmp = ((y * -z) - math.log(y)) - t return tmp
function code(x, y, z, t) tmp = 0.0 if ((Float64(x + -1.0) <= -4000000000.0) || !(Float64(x + -1.0) <= -1.0)) tmp = Float64(Float64(Float64(x + -1.0) * log(y)) - t); else tmp = Float64(Float64(Float64(y * Float64(-z)) - log(y)) - t); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (((x + -1.0) <= -4000000000.0) || ~(((x + -1.0) <= -1.0))) tmp = ((x + -1.0) * log(y)) - t; else tmp = ((y * -z) - log(y)) - t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[N[(x + -1.0), $MachinePrecision], -4000000000.0], N[Not[LessEqual[N[(x + -1.0), $MachinePrecision], -1.0]], $MachinePrecision]], N[(N[(N[(x + -1.0), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision], N[(N[(N[(y * (-z)), $MachinePrecision] - N[Log[y], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x + -1 \leq -4000000000 \lor \neg \left(x + -1 \leq -1\right):\\
\;\;\;\;\left(x + -1\right) \cdot \log y - t\\
\mathbf{else}:\\
\;\;\;\;\left(y \cdot \left(-z\right) - \log y\right) - t\\
\end{array}
\end{array}
if (-.f64 x 1) < -4e9 or -1 < (-.f64 x 1) Initial program 96.6%
+-commutative96.6%
fma-def96.6%
sub-neg96.6%
metadata-eval96.6%
sub-neg96.6%
log1p-def99.7%
sub-neg99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in y around 0 96.4%
if -4e9 < (-.f64 x 1) < -1Initial program 79.9%
Taylor expanded in z around inf 79.9%
*-commutative79.9%
sub-neg79.9%
mul-1-neg79.9%
log1p-def100.0%
mul-1-neg100.0%
Simplified100.0%
Taylor expanded in x around 0 79.8%
neg-mul-179.8%
+-commutative79.8%
unsub-neg79.8%
sub-neg79.8%
log1p-def99.4%
Simplified99.4%
Taylor expanded in y around 0 98.4%
neg-mul-198.4%
+-commutative98.4%
unsub-neg98.4%
mul-1-neg98.4%
distribute-rgt-neg-in98.4%
Simplified98.4%
Final simplification97.4%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (- (- t) (log y))) (t_2 (- (* x (log y)) t)))
(if (<= x -62.0)
t_2
(if (<= x 4.05e-113)
t_1
(if (<= x 9e-109) (* y (- z)) (if (<= x 1.72e-13) t_1 t_2))))))
double code(double x, double y, double z, double t) {
double t_1 = -t - log(y);
double t_2 = (x * log(y)) - t;
double tmp;
if (x <= -62.0) {
tmp = t_2;
} else if (x <= 4.05e-113) {
tmp = t_1;
} else if (x <= 9e-109) {
tmp = y * -z;
} else if (x <= 1.72e-13) {
tmp = t_1;
} else {
tmp = t_2;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = -t - log(y)
t_2 = (x * log(y)) - t
if (x <= (-62.0d0)) then
tmp = t_2
else if (x <= 4.05d-113) then
tmp = t_1
else if (x <= 9d-109) then
tmp = y * -z
else if (x <= 1.72d-13) then
tmp = t_1
else
tmp = t_2
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = -t - Math.log(y);
double t_2 = (x * Math.log(y)) - t;
double tmp;
if (x <= -62.0) {
tmp = t_2;
} else if (x <= 4.05e-113) {
tmp = t_1;
} else if (x <= 9e-109) {
tmp = y * -z;
} else if (x <= 1.72e-13) {
tmp = t_1;
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z, t): t_1 = -t - math.log(y) t_2 = (x * math.log(y)) - t tmp = 0 if x <= -62.0: tmp = t_2 elif x <= 4.05e-113: tmp = t_1 elif x <= 9e-109: tmp = y * -z elif x <= 1.72e-13: tmp = t_1 else: tmp = t_2 return tmp
function code(x, y, z, t) t_1 = Float64(Float64(-t) - log(y)) t_2 = Float64(Float64(x * log(y)) - t) tmp = 0.0 if (x <= -62.0) tmp = t_2; elseif (x <= 4.05e-113) tmp = t_1; elseif (x <= 9e-109) tmp = Float64(y * Float64(-z)); elseif (x <= 1.72e-13) tmp = t_1; else tmp = t_2; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = -t - log(y); t_2 = (x * log(y)) - t; tmp = 0.0; if (x <= -62.0) tmp = t_2; elseif (x <= 4.05e-113) tmp = t_1; elseif (x <= 9e-109) tmp = y * -z; elseif (x <= 1.72e-13) tmp = t_1; else tmp = t_2; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[((-t) - N[Log[y], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]}, If[LessEqual[x, -62.0], t$95$2, If[LessEqual[x, 4.05e-113], t$95$1, If[LessEqual[x, 9e-109], N[(y * (-z)), $MachinePrecision], If[LessEqual[x, 1.72e-13], t$95$1, t$95$2]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(-t\right) - \log y\\
t_2 := x \cdot \log y - t\\
\mathbf{if}\;x \leq -62:\\
\;\;\;\;t_2\\
\mathbf{elif}\;x \leq 4.05 \cdot 10^{-113}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 9 \cdot 10^{-109}:\\
\;\;\;\;y \cdot \left(-z\right)\\
\mathbf{elif}\;x \leq 1.72 \cdot 10^{-13}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\end{array}
if x < -62 or 1.71999999999999999e-13 < x Initial program 96.0%
Taylor expanded in z around inf 96.0%
*-commutative96.0%
sub-neg96.0%
mul-1-neg96.0%
log1p-def99.7%
mul-1-neg99.7%
Simplified99.7%
Taylor expanded in x around inf 95.1%
*-commutative95.1%
Simplified95.1%
if -62 < x < 4.05000000000000022e-113 or 9.0000000000000002e-109 < x < 1.71999999999999999e-13Initial program 82.5%
Taylor expanded in z around inf 82.5%
*-commutative82.5%
sub-neg82.5%
mul-1-neg82.5%
log1p-def100.0%
mul-1-neg100.0%
Simplified100.0%
Taylor expanded in x around 0 82.5%
neg-mul-182.5%
+-commutative82.5%
unsub-neg82.5%
sub-neg82.5%
log1p-def100.0%
Simplified100.0%
Taylor expanded in z around 0 82.0%
neg-mul-182.0%
Simplified82.0%
if 4.05000000000000022e-113 < x < 9.0000000000000002e-109Initial program 28.2%
Taylor expanded in z around inf 28.2%
*-commutative28.2%
sub-neg28.2%
mul-1-neg28.2%
log1p-def100.0%
mul-1-neg100.0%
Simplified100.0%
Taylor expanded in y around 0 83.9%
+-commutative83.9%
sub-neg83.9%
metadata-eval83.9%
*-commutative83.9%
mul-1-neg83.9%
unsub-neg83.9%
*-commutative83.9%
+-commutative83.9%
Simplified83.9%
Taylor expanded in y around inf 83.9%
associate-*r*83.9%
neg-mul-183.9%
*-commutative83.9%
Simplified83.9%
Final simplification88.7%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (- (- t) (log y))) (t_2 (- (* x (log y)) t)))
(if (<= x -62.0)
t_2
(if (<= x 4.1e-155)
t_1
(if (<= x 9e-109)
(- (* y (- z)) (log y))
(if (<= x 1.72e-13) t_1 t_2))))))
double code(double x, double y, double z, double t) {
double t_1 = -t - log(y);
double t_2 = (x * log(y)) - t;
double tmp;
if (x <= -62.0) {
tmp = t_2;
} else if (x <= 4.1e-155) {
tmp = t_1;
} else if (x <= 9e-109) {
tmp = (y * -z) - log(y);
} else if (x <= 1.72e-13) {
tmp = t_1;
} else {
tmp = t_2;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = -t - log(y)
t_2 = (x * log(y)) - t
if (x <= (-62.0d0)) then
tmp = t_2
else if (x <= 4.1d-155) then
tmp = t_1
else if (x <= 9d-109) then
tmp = (y * -z) - log(y)
else if (x <= 1.72d-13) then
tmp = t_1
else
tmp = t_2
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = -t - Math.log(y);
double t_2 = (x * Math.log(y)) - t;
double tmp;
if (x <= -62.0) {
tmp = t_2;
} else if (x <= 4.1e-155) {
tmp = t_1;
} else if (x <= 9e-109) {
tmp = (y * -z) - Math.log(y);
} else if (x <= 1.72e-13) {
tmp = t_1;
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z, t): t_1 = -t - math.log(y) t_2 = (x * math.log(y)) - t tmp = 0 if x <= -62.0: tmp = t_2 elif x <= 4.1e-155: tmp = t_1 elif x <= 9e-109: tmp = (y * -z) - math.log(y) elif x <= 1.72e-13: tmp = t_1 else: tmp = t_2 return tmp
function code(x, y, z, t) t_1 = Float64(Float64(-t) - log(y)) t_2 = Float64(Float64(x * log(y)) - t) tmp = 0.0 if (x <= -62.0) tmp = t_2; elseif (x <= 4.1e-155) tmp = t_1; elseif (x <= 9e-109) tmp = Float64(Float64(y * Float64(-z)) - log(y)); elseif (x <= 1.72e-13) tmp = t_1; else tmp = t_2; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = -t - log(y); t_2 = (x * log(y)) - t; tmp = 0.0; if (x <= -62.0) tmp = t_2; elseif (x <= 4.1e-155) tmp = t_1; elseif (x <= 9e-109) tmp = (y * -z) - log(y); elseif (x <= 1.72e-13) tmp = t_1; else tmp = t_2; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[((-t) - N[Log[y], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]}, If[LessEqual[x, -62.0], t$95$2, If[LessEqual[x, 4.1e-155], t$95$1, If[LessEqual[x, 9e-109], N[(N[(y * (-z)), $MachinePrecision] - N[Log[y], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.72e-13], t$95$1, t$95$2]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(-t\right) - \log y\\
t_2 := x \cdot \log y - t\\
\mathbf{if}\;x \leq -62:\\
\;\;\;\;t_2\\
\mathbf{elif}\;x \leq 4.1 \cdot 10^{-155}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 9 \cdot 10^{-109}:\\
\;\;\;\;y \cdot \left(-z\right) - \log y\\
\mathbf{elif}\;x \leq 1.72 \cdot 10^{-13}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\end{array}
if x < -62 or 1.71999999999999999e-13 < x Initial program 96.0%
Taylor expanded in z around inf 96.0%
*-commutative96.0%
sub-neg96.0%
mul-1-neg96.0%
log1p-def99.7%
mul-1-neg99.7%
Simplified99.7%
Taylor expanded in x around inf 95.1%
*-commutative95.1%
Simplified95.1%
if -62 < x < 4.0999999999999998e-155 or 9.0000000000000002e-109 < x < 1.71999999999999999e-13Initial program 82.2%
Taylor expanded in z around inf 82.2%
*-commutative82.2%
sub-neg82.2%
mul-1-neg82.2%
log1p-def100.0%
mul-1-neg100.0%
Simplified100.0%
Taylor expanded in x around 0 82.2%
neg-mul-182.2%
+-commutative82.2%
unsub-neg82.2%
sub-neg82.2%
log1p-def100.0%
Simplified100.0%
Taylor expanded in z around 0 81.7%
neg-mul-181.7%
Simplified81.7%
if 4.0999999999999998e-155 < x < 9.0000000000000002e-109Initial program 48.7%
Taylor expanded in z around inf 48.7%
*-commutative48.7%
sub-neg48.7%
mul-1-neg48.7%
log1p-def100.0%
mul-1-neg100.0%
Simplified100.0%
Taylor expanded in x around 0 48.7%
neg-mul-148.7%
+-commutative48.7%
unsub-neg48.7%
sub-neg48.7%
log1p-def100.0%
Simplified100.0%
Taylor expanded in y around 0 88.5%
distribute-lft-out88.5%
mul-1-neg88.5%
+-commutative88.5%
fma-def88.5%
Simplified88.5%
Taylor expanded in t around 0 88.5%
Final simplification88.7%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (- (- t) (log y))) (t_2 (- (* x (log y)) t)))
(if (<= x -62.0)
t_2
(if (<= x 1.65e-114)
t_1
(if (<= x 4.9e-108)
(- (* (log1p (- y)) z) t)
(if (<= x 1.72e-13) t_1 t_2))))))
double code(double x, double y, double z, double t) {
double t_1 = -t - log(y);
double t_2 = (x * log(y)) - t;
double tmp;
if (x <= -62.0) {
tmp = t_2;
} else if (x <= 1.65e-114) {
tmp = t_1;
} else if (x <= 4.9e-108) {
tmp = (log1p(-y) * z) - t;
} else if (x <= 1.72e-13) {
tmp = t_1;
} else {
tmp = t_2;
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double t_1 = -t - Math.log(y);
double t_2 = (x * Math.log(y)) - t;
double tmp;
if (x <= -62.0) {
tmp = t_2;
} else if (x <= 1.65e-114) {
tmp = t_1;
} else if (x <= 4.9e-108) {
tmp = (Math.log1p(-y) * z) - t;
} else if (x <= 1.72e-13) {
tmp = t_1;
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z, t): t_1 = -t - math.log(y) t_2 = (x * math.log(y)) - t tmp = 0 if x <= -62.0: tmp = t_2 elif x <= 1.65e-114: tmp = t_1 elif x <= 4.9e-108: tmp = (math.log1p(-y) * z) - t elif x <= 1.72e-13: tmp = t_1 else: tmp = t_2 return tmp
function code(x, y, z, t) t_1 = Float64(Float64(-t) - log(y)) t_2 = Float64(Float64(x * log(y)) - t) tmp = 0.0 if (x <= -62.0) tmp = t_2; elseif (x <= 1.65e-114) tmp = t_1; elseif (x <= 4.9e-108) tmp = Float64(Float64(log1p(Float64(-y)) * z) - t); elseif (x <= 1.72e-13) tmp = t_1; else tmp = t_2; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[((-t) - N[Log[y], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]}, If[LessEqual[x, -62.0], t$95$2, If[LessEqual[x, 1.65e-114], t$95$1, If[LessEqual[x, 4.9e-108], N[(N[(N[Log[1 + (-y)], $MachinePrecision] * z), $MachinePrecision] - t), $MachinePrecision], If[LessEqual[x, 1.72e-13], t$95$1, t$95$2]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(-t\right) - \log y\\
t_2 := x \cdot \log y - t\\
\mathbf{if}\;x \leq -62:\\
\;\;\;\;t_2\\
\mathbf{elif}\;x \leq 1.65 \cdot 10^{-114}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 4.9 \cdot 10^{-108}:\\
\;\;\;\;\mathsf{log1p}\left(-y\right) \cdot z - t\\
\mathbf{elif}\;x \leq 1.72 \cdot 10^{-13}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\end{array}
if x < -62 or 1.71999999999999999e-13 < x Initial program 96.0%
Taylor expanded in z around inf 96.0%
*-commutative96.0%
sub-neg96.0%
mul-1-neg96.0%
log1p-def99.7%
mul-1-neg99.7%
Simplified99.7%
Taylor expanded in x around inf 95.1%
*-commutative95.1%
Simplified95.1%
if -62 < x < 1.65000000000000017e-114 or 4.8999999999999998e-108 < x < 1.71999999999999999e-13Initial program 82.5%
Taylor expanded in z around inf 82.5%
*-commutative82.5%
sub-neg82.5%
mul-1-neg82.5%
log1p-def100.0%
mul-1-neg100.0%
Simplified100.0%
Taylor expanded in x around 0 82.5%
neg-mul-182.5%
+-commutative82.5%
unsub-neg82.5%
sub-neg82.5%
log1p-def100.0%
Simplified100.0%
Taylor expanded in z around 0 82.0%
neg-mul-182.0%
Simplified82.0%
if 1.65000000000000017e-114 < x < 4.8999999999999998e-108Initial program 28.2%
Taylor expanded in z around inf 28.2%
*-commutative28.2%
sub-neg28.2%
mul-1-neg28.2%
log1p-def100.0%
mul-1-neg100.0%
Simplified100.0%
Taylor expanded in x around 0 28.2%
neg-mul-128.2%
+-commutative28.2%
unsub-neg28.2%
sub-neg28.2%
log1p-def100.0%
Simplified100.0%
Taylor expanded in z around inf 28.4%
sub-neg28.4%
log1p-def100.0%
Simplified100.0%
Final simplification89.0%
(FPCore (x y z t) :precision binary64 (- (- (* (+ x -1.0) (log y)) (* y z)) t))
double code(double x, double y, double z, double t) {
return (((x + -1.0) * log(y)) - (y * z)) - t;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = (((x + (-1.0d0)) * log(y)) - (y * z)) - t
end function
public static double code(double x, double y, double z, double t) {
return (((x + -1.0) * Math.log(y)) - (y * z)) - t;
}
def code(x, y, z, t): return (((x + -1.0) * math.log(y)) - (y * z)) - t
function code(x, y, z, t) return Float64(Float64(Float64(Float64(x + -1.0) * log(y)) - Float64(y * z)) - t) end
function tmp = code(x, y, z, t) tmp = (((x + -1.0) * log(y)) - (y * z)) - t; end
code[x_, y_, z_, t_] := N[(N[(N[(N[(x + -1.0), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision] - N[(y * z), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x + -1\right) \cdot \log y - y \cdot z\right) - t
\end{array}
Initial program 88.4%
Taylor expanded in z around inf 88.4%
*-commutative88.4%
sub-neg88.4%
mul-1-neg88.4%
log1p-def99.8%
mul-1-neg99.8%
Simplified99.8%
Taylor expanded in y around 0 99.3%
+-commutative99.3%
sub-neg99.3%
metadata-eval99.3%
*-commutative99.3%
mul-1-neg99.3%
unsub-neg99.3%
*-commutative99.3%
+-commutative99.3%
Simplified99.3%
Final simplification99.3%
(FPCore (x y z t) :precision binary64 (if (<= z 3.15e+171) (- (* (+ x -1.0) (log y)) t) (- (* (log1p (- y)) z) t)))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= 3.15e+171) {
tmp = ((x + -1.0) * log(y)) - t;
} else {
tmp = (log1p(-y) * z) - t;
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= 3.15e+171) {
tmp = ((x + -1.0) * Math.log(y)) - t;
} else {
tmp = (Math.log1p(-y) * z) - t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= 3.15e+171: tmp = ((x + -1.0) * math.log(y)) - t else: tmp = (math.log1p(-y) * z) - t return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= 3.15e+171) tmp = Float64(Float64(Float64(x + -1.0) * log(y)) - t); else tmp = Float64(Float64(log1p(Float64(-y)) * z) - t); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[z, 3.15e+171], N[(N[(N[(x + -1.0), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision], N[(N[(N[Log[1 + (-y)], $MachinePrecision] * z), $MachinePrecision] - t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 3.15 \cdot 10^{+171}:\\
\;\;\;\;\left(x + -1\right) \cdot \log y - t\\
\mathbf{else}:\\
\;\;\;\;\mathsf{log1p}\left(-y\right) \cdot z - t\\
\end{array}
\end{array}
if z < 3.1500000000000002e171Initial program 93.3%
+-commutative93.3%
fma-def93.3%
sub-neg93.3%
metadata-eval93.3%
sub-neg93.3%
log1p-def99.9%
sub-neg99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in y around 0 92.8%
if 3.1500000000000002e171 < z Initial program 40.5%
Taylor expanded in z around inf 40.5%
*-commutative40.5%
sub-neg40.5%
mul-1-neg40.5%
log1p-def99.8%
mul-1-neg99.8%
Simplified99.8%
Taylor expanded in x around 0 22.0%
neg-mul-122.0%
+-commutative22.0%
unsub-neg22.0%
sub-neg22.0%
log1p-def81.3%
Simplified81.3%
Taylor expanded in z around inf 22.3%
sub-neg22.3%
log1p-def76.4%
Simplified76.4%
Final simplification91.3%
(FPCore (x y z t) :precision binary64 (if (or (<= z -1.25e+241) (not (<= z 1.8e+174))) (* y (- z)) (- (- t) (log y))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -1.25e+241) || !(z <= 1.8e+174)) {
tmp = y * -z;
} else {
tmp = -t - log(y);
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if ((z <= (-1.25d+241)) .or. (.not. (z <= 1.8d+174))) then
tmp = y * -z
else
tmp = -t - log(y)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -1.25e+241) || !(z <= 1.8e+174)) {
tmp = y * -z;
} else {
tmp = -t - Math.log(y);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -1.25e+241) or not (z <= 1.8e+174): tmp = y * -z else: tmp = -t - math.log(y) return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -1.25e+241) || !(z <= 1.8e+174)) tmp = Float64(y * Float64(-z)); else tmp = Float64(Float64(-t) - log(y)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -1.25e+241) || ~((z <= 1.8e+174))) tmp = y * -z; else tmp = -t - log(y); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -1.25e+241], N[Not[LessEqual[z, 1.8e+174]], $MachinePrecision]], N[(y * (-z)), $MachinePrecision], N[((-t) - N[Log[y], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.25 \cdot 10^{+241} \lor \neg \left(z \leq 1.8 \cdot 10^{+174}\right):\\
\;\;\;\;y \cdot \left(-z\right)\\
\mathbf{else}:\\
\;\;\;\;\left(-t\right) - \log y\\
\end{array}
\end{array}
if z < -1.25000000000000006e241 or 1.8000000000000001e174 < z Initial program 46.7%
Taylor expanded in z around inf 46.7%
*-commutative46.7%
sub-neg46.7%
mul-1-neg46.7%
log1p-def99.8%
mul-1-neg99.8%
Simplified99.8%
Taylor expanded in y around 0 98.6%
+-commutative98.6%
sub-neg98.6%
metadata-eval98.6%
*-commutative98.6%
mul-1-neg98.6%
unsub-neg98.6%
*-commutative98.6%
+-commutative98.6%
Simplified98.6%
Taylor expanded in y around inf 50.6%
associate-*r*50.6%
neg-mul-150.6%
*-commutative50.6%
Simplified50.6%
if -1.25000000000000006e241 < z < 1.8000000000000001e174Initial program 96.3%
Taylor expanded in z around inf 96.3%
*-commutative96.3%
sub-neg96.3%
mul-1-neg96.3%
log1p-def99.9%
mul-1-neg99.9%
Simplified99.9%
Taylor expanded in x around 0 60.6%
neg-mul-160.6%
+-commutative60.6%
unsub-neg60.6%
sub-neg60.6%
log1p-def63.8%
Simplified63.8%
Taylor expanded in z around 0 60.1%
neg-mul-160.1%
Simplified60.1%
Final simplification58.5%
(FPCore (x y z t) :precision binary64 (if (or (<= t -80000000000000.0) (not (<= t 0.3))) (- t) (* y (- z))))
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -80000000000000.0) || !(t <= 0.3)) {
tmp = -t;
} else {
tmp = y * -z;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if ((t <= (-80000000000000.0d0)) .or. (.not. (t <= 0.3d0))) then
tmp = -t
else
tmp = y * -z
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -80000000000000.0) || !(t <= 0.3)) {
tmp = -t;
} else {
tmp = y * -z;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (t <= -80000000000000.0) or not (t <= 0.3): tmp = -t else: tmp = y * -z return tmp
function code(x, y, z, t) tmp = 0.0 if ((t <= -80000000000000.0) || !(t <= 0.3)) tmp = Float64(-t); else tmp = Float64(y * Float64(-z)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((t <= -80000000000000.0) || ~((t <= 0.3))) tmp = -t; else tmp = y * -z; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[t, -80000000000000.0], N[Not[LessEqual[t, 0.3]], $MachinePrecision]], (-t), N[(y * (-z)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -80000000000000 \lor \neg \left(t \leq 0.3\right):\\
\;\;\;\;-t\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(-z\right)\\
\end{array}
\end{array}
if t < -8e13 or 0.299999999999999989 < t Initial program 94.1%
+-commutative94.1%
fma-def94.1%
sub-neg94.1%
metadata-eval94.1%
sub-neg94.1%
log1p-def99.9%
sub-neg99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in t around inf 70.1%
neg-mul-170.1%
Simplified70.1%
if -8e13 < t < 0.299999999999999989Initial program 82.0%
Taylor expanded in z around inf 82.0%
*-commutative82.0%
sub-neg82.0%
mul-1-neg82.0%
log1p-def99.8%
mul-1-neg99.8%
Simplified99.8%
Taylor expanded in y around 0 99.5%
+-commutative99.5%
sub-neg99.5%
metadata-eval99.5%
*-commutative99.5%
mul-1-neg99.5%
unsub-neg99.5%
*-commutative99.5%
+-commutative99.5%
Simplified99.5%
Taylor expanded in y around inf 18.8%
associate-*r*18.8%
neg-mul-118.8%
*-commutative18.8%
Simplified18.8%
Final simplification45.9%
(FPCore (x y z t) :precision binary64 (- t))
double code(double x, double y, double z, double t) {
return -t;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = -t
end function
public static double code(double x, double y, double z, double t) {
return -t;
}
def code(x, y, z, t): return -t
function code(x, y, z, t) return Float64(-t) end
function tmp = code(x, y, z, t) tmp = -t; end
code[x_, y_, z_, t_] := (-t)
\begin{array}{l}
\\
-t
\end{array}
Initial program 88.4%
+-commutative88.4%
fma-def88.4%
sub-neg88.4%
metadata-eval88.4%
sub-neg88.4%
log1p-def99.8%
sub-neg99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in t around inf 38.4%
neg-mul-138.4%
Simplified38.4%
Final simplification38.4%
herbie shell --seed 2024013
(FPCore (x y z t)
:name "Statistics.Distribution.Beta:$cdensity from math-functions-0.1.5.2"
:precision binary64
(- (+ (* (- x 1.0) (log y)) (* (- z 1.0) (log (- 1.0 y)))) t))