
(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 17 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 (- (fma (+ -1.0 x) (log y) (* (* z y) (fma -0.5 y -1.0))) t))
double code(double x, double y, double z, double t) {
return fma((-1.0 + x), log(y), ((z * y) * fma(-0.5, y, -1.0))) - t;
}
function code(x, y, z, t) return Float64(fma(Float64(-1.0 + x), log(y), Float64(Float64(z * y) * fma(-0.5, y, -1.0))) - t) end
code[x_, y_, z_, t_] := N[(N[(N[(-1.0 + x), $MachinePrecision] * N[Log[y], $MachinePrecision] + N[(N[(z * y), $MachinePrecision] * N[(-0.5 * y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(-1 + x, \log y, \left(z \cdot y\right) \cdot \mathsf{fma}\left(-0.5, y, -1\right)\right) - t
\end{array}
Initial program 87.3%
Taylor expanded in y around 0
+-commutativeN/A
remove-double-negN/A
distribute-lft-neg-outN/A
log-recN/A
mul-1-negN/A
Applied rewrites99.5%
Taylor expanded in z around inf
Applied rewrites99.5%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (- (+ (* (- x 1.0) (log y)) (* (- z 1.0) (log (- 1.0 y)))) t)))
(if (or (<= t_1 -100000.0) (not (<= t_1 1000000000.0)))
(- (* (+ -1.0 x) (log y)) t)
(- (fma (- z 1.0) y (log y))))))
double code(double x, double y, double z, double t) {
double t_1 = (((x - 1.0) * log(y)) + ((z - 1.0) * log((1.0 - y)))) - t;
double tmp;
if ((t_1 <= -100000.0) || !(t_1 <= 1000000000.0)) {
tmp = ((-1.0 + x) * log(y)) - t;
} else {
tmp = -fma((z - 1.0), y, log(y));
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(Float64(Float64(Float64(x - 1.0) * log(y)) + Float64(Float64(z - 1.0) * log(Float64(1.0 - y)))) - t) tmp = 0.0 if ((t_1 <= -100000.0) || !(t_1 <= 1000000000.0)) tmp = Float64(Float64(Float64(-1.0 + x) * log(y)) - t); else tmp = Float64(-fma(Float64(z - 1.0), y, log(y))); end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = 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]}, If[Or[LessEqual[t$95$1, -100000.0], N[Not[LessEqual[t$95$1, 1000000000.0]], $MachinePrecision]], N[(N[(N[(-1.0 + x), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision], (-N[(N[(z - 1.0), $MachinePrecision] * y + N[Log[y], $MachinePrecision]), $MachinePrecision])]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(\left(x - 1\right) \cdot \log y + \left(z - 1\right) \cdot \log \left(1 - y\right)\right) - t\\
\mathbf{if}\;t\_1 \leq -100000 \lor \neg \left(t\_1 \leq 1000000000\right):\\
\;\;\;\;\left(-1 + x\right) \cdot \log y - t\\
\mathbf{else}:\\
\;\;\;\;-\mathsf{fma}\left(z - 1, y, \log y\right)\\
\end{array}
\end{array}
if (-.f64 (+.f64 (*.f64 (-.f64 x #s(literal 1 binary64)) (log.f64 y)) (*.f64 (-.f64 z #s(literal 1 binary64)) (log.f64 (-.f64 #s(literal 1 binary64) y)))) t) < -1e5 or 1e9 < (-.f64 (+.f64 (*.f64 (-.f64 x #s(literal 1 binary64)) (log.f64 y)) (*.f64 (-.f64 z #s(literal 1 binary64)) (log.f64 (-.f64 #s(literal 1 binary64) y)))) t) Initial program 93.3%
Taylor expanded in y around 0
remove-double-negN/A
log-recN/A
mul-1-negN/A
distribute-rgt-out--N/A
mul-1-negN/A
log-recN/A
remove-double-negN/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
mul-1-negN/A
log-recN/A
remove-double-negN/A
+-commutativeN/A
distribute-rgt-outN/A
remove-double-negN/A
log-recN/A
mul-1-negN/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f64N/A
mul-1-negN/A
log-recN/A
Applied rewrites92.5%
if -1e5 < (-.f64 (+.f64 (*.f64 (-.f64 x #s(literal 1 binary64)) (log.f64 y)) (*.f64 (-.f64 z #s(literal 1 binary64)) (log.f64 (-.f64 #s(literal 1 binary64) y)))) t) < 1e9Initial program 74.5%
Taylor expanded in y around 0
associate--l+N/A
associate-*r*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-neg.f64N/A
lower--.f64N/A
*-rgt-identityN/A
fp-cancel-sub-sign-invN/A
Applied rewrites99.9%
Taylor expanded in x around 0
Applied rewrites98.4%
Taylor expanded in t around 0
Applied rewrites96.5%
Final simplification93.8%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (- (+ (* (- x 1.0) (log y)) (* (- z 1.0) (log (- 1.0 y)))) t)))
(if (or (<= t_1 -2e+20) (not (<= t_1 1000000000.0)))
(- (* (log y) x) t)
(- (fma (- z 1.0) y (log y))))))
double code(double x, double y, double z, double t) {
double t_1 = (((x - 1.0) * log(y)) + ((z - 1.0) * log((1.0 - y)))) - t;
double tmp;
if ((t_1 <= -2e+20) || !(t_1 <= 1000000000.0)) {
tmp = (log(y) * x) - t;
} else {
tmp = -fma((z - 1.0), y, log(y));
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(Float64(Float64(Float64(x - 1.0) * log(y)) + Float64(Float64(z - 1.0) * log(Float64(1.0 - y)))) - t) tmp = 0.0 if ((t_1 <= -2e+20) || !(t_1 <= 1000000000.0)) tmp = Float64(Float64(log(y) * x) - t); else tmp = Float64(-fma(Float64(z - 1.0), y, log(y))); end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = 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]}, If[Or[LessEqual[t$95$1, -2e+20], N[Not[LessEqual[t$95$1, 1000000000.0]], $MachinePrecision]], N[(N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision] - t), $MachinePrecision], (-N[(N[(z - 1.0), $MachinePrecision] * y + N[Log[y], $MachinePrecision]), $MachinePrecision])]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(\left(x - 1\right) \cdot \log y + \left(z - 1\right) \cdot \log \left(1 - y\right)\right) - t\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{+20} \lor \neg \left(t\_1 \leq 1000000000\right):\\
\;\;\;\;\log y \cdot x - t\\
\mathbf{else}:\\
\;\;\;\;-\mathsf{fma}\left(z - 1, y, \log y\right)\\
\end{array}
\end{array}
if (-.f64 (+.f64 (*.f64 (-.f64 x #s(literal 1 binary64)) (log.f64 y)) (*.f64 (-.f64 z #s(literal 1 binary64)) (log.f64 (-.f64 #s(literal 1 binary64) y)))) t) < -2e20 or 1e9 < (-.f64 (+.f64 (*.f64 (-.f64 x #s(literal 1 binary64)) (log.f64 y)) (*.f64 (-.f64 z #s(literal 1 binary64)) (log.f64 (-.f64 #s(literal 1 binary64) y)))) t) Initial program 94.8%
Taylor expanded in x around inf
*-commutativeN/A
remove-double-negN/A
log-recN/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
log-recN/A
remove-double-negN/A
lower-log.f6493.8
Applied rewrites93.8%
if -2e20 < (-.f64 (+.f64 (*.f64 (-.f64 x #s(literal 1 binary64)) (log.f64 y)) (*.f64 (-.f64 z #s(literal 1 binary64)) (log.f64 (-.f64 #s(literal 1 binary64) y)))) t) < 1e9Initial program 73.0%
Taylor expanded in y around 0
associate--l+N/A
associate-*r*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-neg.f64N/A
lower--.f64N/A
*-rgt-identityN/A
fp-cancel-sub-sign-invN/A
Applied rewrites99.9%
Taylor expanded in x around 0
Applied rewrites96.3%
Taylor expanded in t around 0
Applied rewrites93.4%
Final simplification93.7%
(FPCore (x y z t) :precision binary64 (if (or (<= x -2.8e-7) (not (<= x 2e-15))) (- (* (+ -1.0 x) (log y)) t) (fma (- y) (- z 1.0) (- (+ (log y) t)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -2.8e-7) || !(x <= 2e-15)) {
tmp = ((-1.0 + x) * log(y)) - t;
} else {
tmp = fma(-y, (z - 1.0), -(log(y) + t));
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if ((x <= -2.8e-7) || !(x <= 2e-15)) tmp = Float64(Float64(Float64(-1.0 + x) * log(y)) - t); else tmp = fma(Float64(-y), Float64(z - 1.0), Float64(-Float64(log(y) + t))); end return tmp end
code[x_, y_, z_, t_] := If[Or[LessEqual[x, -2.8e-7], N[Not[LessEqual[x, 2e-15]], $MachinePrecision]], N[(N[(N[(-1.0 + x), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision], N[((-y) * N[(z - 1.0), $MachinePrecision] + (-N[(N[Log[y], $MachinePrecision] + t), $MachinePrecision])), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.8 \cdot 10^{-7} \lor \neg \left(x \leq 2 \cdot 10^{-15}\right):\\
\;\;\;\;\left(-1 + x\right) \cdot \log y - t\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-y, z - 1, -\left(\log y + t\right)\right)\\
\end{array}
\end{array}
if x < -2.80000000000000019e-7 or 2.0000000000000002e-15 < x Initial program 93.3%
Taylor expanded in y around 0
remove-double-negN/A
log-recN/A
mul-1-negN/A
distribute-rgt-out--N/A
mul-1-negN/A
log-recN/A
remove-double-negN/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
mul-1-negN/A
log-recN/A
remove-double-negN/A
+-commutativeN/A
distribute-rgt-outN/A
remove-double-negN/A
log-recN/A
mul-1-negN/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f64N/A
mul-1-negN/A
log-recN/A
Applied rewrites92.4%
if -2.80000000000000019e-7 < x < 2.0000000000000002e-15Initial program 82.0%
Taylor expanded in y around 0
associate--l+N/A
associate-*r*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-neg.f64N/A
lower--.f64N/A
*-rgt-identityN/A
fp-cancel-sub-sign-invN/A
Applied rewrites99.9%
Taylor expanded in x around 0
Applied rewrites99.9%
Final simplification96.4%
(FPCore (x y z t) :precision binary64 (if (or (<= (- x 1.0) -20000000000000.0) (not (<= (- x 1.0) -0.5))) (- (* (log y) x) t) (- (+ (log y) t))))
double code(double x, double y, double z, double t) {
double tmp;
if (((x - 1.0) <= -20000000000000.0) || !((x - 1.0) <= -0.5)) {
tmp = (log(y) * x) - t;
} else {
tmp = -(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) <= (-20000000000000.0d0)) .or. (.not. ((x - 1.0d0) <= (-0.5d0)))) then
tmp = (log(y) * x) - t
else
tmp = -(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) <= -20000000000000.0) || !((x - 1.0) <= -0.5)) {
tmp = (Math.log(y) * x) - t;
} else {
tmp = -(Math.log(y) + t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if ((x - 1.0) <= -20000000000000.0) or not ((x - 1.0) <= -0.5): tmp = (math.log(y) * x) - t else: tmp = -(math.log(y) + t) return tmp
function code(x, y, z, t) tmp = 0.0 if ((Float64(x - 1.0) <= -20000000000000.0) || !(Float64(x - 1.0) <= -0.5)) tmp = Float64(Float64(log(y) * x) - t); else tmp = Float64(-Float64(log(y) + t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (((x - 1.0) <= -20000000000000.0) || ~(((x - 1.0) <= -0.5))) tmp = (log(y) * x) - t; else tmp = -(log(y) + t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[N[(x - 1.0), $MachinePrecision], -20000000000000.0], N[Not[LessEqual[N[(x - 1.0), $MachinePrecision], -0.5]], $MachinePrecision]], N[(N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision] - t), $MachinePrecision], (-N[(N[Log[y], $MachinePrecision] + t), $MachinePrecision])]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x - 1 \leq -20000000000000 \lor \neg \left(x - 1 \leq -0.5\right):\\
\;\;\;\;\log y \cdot x - t\\
\mathbf{else}:\\
\;\;\;\;-\left(\log y + t\right)\\
\end{array}
\end{array}
if (-.f64 x #s(literal 1 binary64)) < -2e13 or -0.5 < (-.f64 x #s(literal 1 binary64)) Initial program 93.0%
Taylor expanded in x around inf
*-commutativeN/A
remove-double-negN/A
log-recN/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
log-recN/A
remove-double-negN/A
lower-log.f6490.9
Applied rewrites90.9%
if -2e13 < (-.f64 x #s(literal 1 binary64)) < -0.5Initial program 82.7%
Taylor expanded in y around 0
associate--l+N/A
associate-*r*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-neg.f64N/A
lower--.f64N/A
*-rgt-identityN/A
fp-cancel-sub-sign-invN/A
Applied rewrites99.9%
Taylor expanded in x around 0
Applied rewrites99.0%
Taylor expanded in y around 0
Applied rewrites81.7%
Final simplification85.8%
(FPCore (x y z t) :precision binary64 (if (or (<= x -2.8e-7) (not (<= x 2e-15))) (- (* (+ -1.0 x) (log y)) t) (- (- y (fma y z (log y))) t)))
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -2.8e-7) || !(x <= 2e-15)) {
tmp = ((-1.0 + x) * log(y)) - t;
} else {
tmp = (y - fma(y, z, log(y))) - t;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if ((x <= -2.8e-7) || !(x <= 2e-15)) tmp = Float64(Float64(Float64(-1.0 + x) * log(y)) - t); else tmp = Float64(Float64(y - fma(y, z, log(y))) - t); end return tmp end
code[x_, y_, z_, t_] := If[Or[LessEqual[x, -2.8e-7], N[Not[LessEqual[x, 2e-15]], $MachinePrecision]], N[(N[(N[(-1.0 + x), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision], N[(N[(y - N[(y * z + N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.8 \cdot 10^{-7} \lor \neg \left(x \leq 2 \cdot 10^{-15}\right):\\
\;\;\;\;\left(-1 + x\right) \cdot \log y - t\\
\mathbf{else}:\\
\;\;\;\;\left(y - \mathsf{fma}\left(y, z, \log y\right)\right) - t\\
\end{array}
\end{array}
if x < -2.80000000000000019e-7 or 2.0000000000000002e-15 < x Initial program 93.3%
Taylor expanded in y around 0
remove-double-negN/A
log-recN/A
mul-1-negN/A
distribute-rgt-out--N/A
mul-1-negN/A
log-recN/A
remove-double-negN/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
mul-1-negN/A
log-recN/A
remove-double-negN/A
+-commutativeN/A
distribute-rgt-outN/A
remove-double-negN/A
log-recN/A
mul-1-negN/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f64N/A
mul-1-negN/A
log-recN/A
Applied rewrites92.4%
if -2.80000000000000019e-7 < x < 2.0000000000000002e-15Initial program 82.0%
Taylor expanded in y around 0
associate--l+N/A
associate-*r*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-neg.f64N/A
lower--.f64N/A
*-rgt-identityN/A
fp-cancel-sub-sign-invN/A
Applied rewrites99.9%
Taylor expanded in z around 0
Applied rewrites99.9%
Taylor expanded in x around 0
Applied rewrites99.9%
Final simplification96.4%
(FPCore (x y z t) :precision binary64 (if (or (<= (- x 1.0) -1e+47) (not (<= (- x 1.0) 2e+74))) (* (log y) x) (- (+ (log y) t))))
double code(double x, double y, double z, double t) {
double tmp;
if (((x - 1.0) <= -1e+47) || !((x - 1.0) <= 2e+74)) {
tmp = log(y) * x;
} else {
tmp = -(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) <= (-1d+47)) .or. (.not. ((x - 1.0d0) <= 2d+74))) then
tmp = log(y) * x
else
tmp = -(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) <= -1e+47) || !((x - 1.0) <= 2e+74)) {
tmp = Math.log(y) * x;
} else {
tmp = -(Math.log(y) + t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if ((x - 1.0) <= -1e+47) or not ((x - 1.0) <= 2e+74): tmp = math.log(y) * x else: tmp = -(math.log(y) + t) return tmp
function code(x, y, z, t) tmp = 0.0 if ((Float64(x - 1.0) <= -1e+47) || !(Float64(x - 1.0) <= 2e+74)) tmp = Float64(log(y) * x); else tmp = Float64(-Float64(log(y) + t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (((x - 1.0) <= -1e+47) || ~(((x - 1.0) <= 2e+74))) tmp = log(y) * x; else tmp = -(log(y) + t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[N[(x - 1.0), $MachinePrecision], -1e+47], N[Not[LessEqual[N[(x - 1.0), $MachinePrecision], 2e+74]], $MachinePrecision]], N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision], (-N[(N[Log[y], $MachinePrecision] + t), $MachinePrecision])]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x - 1 \leq -1 \cdot 10^{+47} \lor \neg \left(x - 1 \leq 2 \cdot 10^{+74}\right):\\
\;\;\;\;\log y \cdot x\\
\mathbf{else}:\\
\;\;\;\;-\left(\log y + t\right)\\
\end{array}
\end{array}
if (-.f64 x #s(literal 1 binary64)) < -1e47 or 1.9999999999999999e74 < (-.f64 x #s(literal 1 binary64)) Initial program 93.1%
Taylor expanded in y around 0
+-commutativeN/A
remove-double-negN/A
distribute-lft-neg-outN/A
log-recN/A
mul-1-negN/A
Applied rewrites98.7%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower-log.f6474.8
Applied rewrites74.8%
if -1e47 < (-.f64 x #s(literal 1 binary64)) < 1.9999999999999999e74Initial program 84.2%
Taylor expanded in y around 0
associate--l+N/A
associate-*r*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-neg.f64N/A
lower--.f64N/A
*-rgt-identityN/A
fp-cancel-sub-sign-invN/A
Applied rewrites99.9%
Taylor expanded in x around 0
Applied rewrites94.6%
Taylor expanded in y around 0
Applied rewrites78.8%
Final simplification77.4%
(FPCore (x y z t)
:precision binary64
(if (<= (- z 1.0) -4e+142)
(-
(* (* (- (* (- (* (- (* -0.25 y) 0.3333333333333333) y) 0.5) y) 1.0) y) z)
t)
(if (<= (- z 1.0) 2e+127)
(- (+ (log y) t))
(- (* (* (- (* -0.5 y) 1.0) y) z) t))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z - 1.0) <= -4e+142) {
tmp = ((((((((-0.25 * y) - 0.3333333333333333) * y) - 0.5) * y) - 1.0) * y) * z) - t;
} else if ((z - 1.0) <= 2e+127) {
tmp = -(log(y) + t);
} else {
tmp = ((((-0.5 * y) - 1.0) * y) * z) - 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 ((z - 1.0d0) <= (-4d+142)) then
tmp = (((((((((-0.25d0) * y) - 0.3333333333333333d0) * y) - 0.5d0) * y) - 1.0d0) * y) * z) - t
else if ((z - 1.0d0) <= 2d+127) then
tmp = -(log(y) + t)
else
tmp = (((((-0.5d0) * y) - 1.0d0) * y) * z) - t
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z - 1.0) <= -4e+142) {
tmp = ((((((((-0.25 * y) - 0.3333333333333333) * y) - 0.5) * y) - 1.0) * y) * z) - t;
} else if ((z - 1.0) <= 2e+127) {
tmp = -(Math.log(y) + t);
} else {
tmp = ((((-0.5 * y) - 1.0) * y) * z) - t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z - 1.0) <= -4e+142: tmp = ((((((((-0.25 * y) - 0.3333333333333333) * y) - 0.5) * y) - 1.0) * y) * z) - t elif (z - 1.0) <= 2e+127: tmp = -(math.log(y) + t) else: tmp = ((((-0.5 * y) - 1.0) * y) * z) - t return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(z - 1.0) <= -4e+142) tmp = Float64(Float64(Float64(Float64(Float64(Float64(Float64(Float64(Float64(-0.25 * y) - 0.3333333333333333) * y) - 0.5) * y) - 1.0) * y) * z) - t); elseif (Float64(z - 1.0) <= 2e+127) tmp = Float64(-Float64(log(y) + t)); else tmp = Float64(Float64(Float64(Float64(Float64(-0.5 * y) - 1.0) * y) * z) - t); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z - 1.0) <= -4e+142) tmp = ((((((((-0.25 * y) - 0.3333333333333333) * y) - 0.5) * y) - 1.0) * y) * z) - t; elseif ((z - 1.0) <= 2e+127) tmp = -(log(y) + t); else tmp = ((((-0.5 * y) - 1.0) * y) * z) - t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(z - 1.0), $MachinePrecision], -4e+142], N[(N[(N[(N[(N[(N[(N[(N[(N[(-0.25 * y), $MachinePrecision] - 0.3333333333333333), $MachinePrecision] * y), $MachinePrecision] - 0.5), $MachinePrecision] * y), $MachinePrecision] - 1.0), $MachinePrecision] * y), $MachinePrecision] * z), $MachinePrecision] - t), $MachinePrecision], If[LessEqual[N[(z - 1.0), $MachinePrecision], 2e+127], (-N[(N[Log[y], $MachinePrecision] + t), $MachinePrecision]), N[(N[(N[(N[(N[(-0.5 * y), $MachinePrecision] - 1.0), $MachinePrecision] * y), $MachinePrecision] * z), $MachinePrecision] - t), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z - 1 \leq -4 \cdot 10^{+142}:\\
\;\;\;\;\left(\left(\left(\left(-0.25 \cdot y - 0.3333333333333333\right) \cdot y - 0.5\right) \cdot y - 1\right) \cdot y\right) \cdot z - t\\
\mathbf{elif}\;z - 1 \leq 2 \cdot 10^{+127}:\\
\;\;\;\;-\left(\log y + t\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(-0.5 \cdot y - 1\right) \cdot y\right) \cdot z - t\\
\end{array}
\end{array}
if (-.f64 z #s(literal 1 binary64)) < -4.0000000000000002e142Initial program 63.4%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower-log.f64N/A
lower--.f6427.9
Applied rewrites27.9%
Taylor expanded in y around 0
Applied rewrites61.4%
if -4.0000000000000002e142 < (-.f64 z #s(literal 1 binary64)) < 1.99999999999999991e127Initial program 98.6%
Taylor expanded in y around 0
associate--l+N/A
associate-*r*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-neg.f64N/A
lower--.f64N/A
*-rgt-identityN/A
fp-cancel-sub-sign-invN/A
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites67.1%
Taylor expanded in y around 0
Applied rewrites65.8%
if 1.99999999999999991e127 < (-.f64 z #s(literal 1 binary64)) Initial program 57.7%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower-log.f64N/A
lower--.f6436.6
Applied rewrites36.6%
Taylor expanded in y around 0
Applied rewrites74.0%
Final simplification66.4%
(FPCore (x y z t) :precision binary64 (fma (- y) (- z 1.0) (fma (+ -1.0 x) (log y) (- t))))
double code(double x, double y, double z, double t) {
return fma(-y, (z - 1.0), fma((-1.0 + x), log(y), -t));
}
function code(x, y, z, t) return fma(Float64(-y), Float64(z - 1.0), fma(Float64(-1.0 + x), log(y), Float64(-t))) end
code[x_, y_, z_, t_] := N[((-y) * N[(z - 1.0), $MachinePrecision] + N[(N[(-1.0 + x), $MachinePrecision] * N[Log[y], $MachinePrecision] + (-t)), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(-y, z - 1, \mathsf{fma}\left(-1 + x, \log y, -t\right)\right)
\end{array}
Initial program 87.3%
Taylor expanded in y around 0
associate--l+N/A
associate-*r*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-neg.f64N/A
lower--.f64N/A
*-rgt-identityN/A
fp-cancel-sub-sign-invN/A
Applied rewrites99.5%
(FPCore (x y z t) :precision binary64 (- (fma (- z) y (fma (log y) (- x 1.0) y)) t))
double code(double x, double y, double z, double t) {
return fma(-z, y, fma(log(y), (x - 1.0), y)) - t;
}
function code(x, y, z, t) return Float64(fma(Float64(-z), y, fma(log(y), Float64(x - 1.0), y)) - t) end
code[x_, y_, z_, t_] := N[(N[((-z) * y + N[(N[Log[y], $MachinePrecision] * N[(x - 1.0), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(-z, y, \mathsf{fma}\left(\log y, x - 1, y\right)\right) - t
\end{array}
Initial program 87.3%
Taylor expanded in y around 0
associate--l+N/A
associate-*r*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-neg.f64N/A
lower--.f64N/A
*-rgt-identityN/A
fp-cancel-sub-sign-invN/A
Applied rewrites99.5%
Taylor expanded in z around 0
Applied rewrites99.5%
(FPCore (x y z t) :precision binary64 (- (* (* (- (* (- (* (- (* -0.25 y) 0.3333333333333333) y) 0.5) y) 1.0) y) z) t))
double code(double x, double y, double z, double t) {
return ((((((((-0.25 * y) - 0.3333333333333333) * y) - 0.5) * y) - 1.0) * 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 = (((((((((-0.25d0) * y) - 0.3333333333333333d0) * y) - 0.5d0) * y) - 1.0d0) * y) * z) - t
end function
public static double code(double x, double y, double z, double t) {
return ((((((((-0.25 * y) - 0.3333333333333333) * y) - 0.5) * y) - 1.0) * y) * z) - t;
}
def code(x, y, z, t): return ((((((((-0.25 * y) - 0.3333333333333333) * y) - 0.5) * y) - 1.0) * y) * z) - t
function code(x, y, z, t) return Float64(Float64(Float64(Float64(Float64(Float64(Float64(Float64(Float64(-0.25 * y) - 0.3333333333333333) * y) - 0.5) * y) - 1.0) * y) * z) - t) end
function tmp = code(x, y, z, t) tmp = ((((((((-0.25 * y) - 0.3333333333333333) * y) - 0.5) * y) - 1.0) * y) * z) - t; end
code[x_, y_, z_, t_] := N[(N[(N[(N[(N[(N[(N[(N[(N[(-0.25 * y), $MachinePrecision] - 0.3333333333333333), $MachinePrecision] * y), $MachinePrecision] - 0.5), $MachinePrecision] * y), $MachinePrecision] - 1.0), $MachinePrecision] * y), $MachinePrecision] * z), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(\left(\left(-0.25 \cdot y - 0.3333333333333333\right) \cdot y - 0.5\right) \cdot y - 1\right) \cdot y\right) \cdot z - t
\end{array}
Initial program 87.3%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower-log.f64N/A
lower--.f6436.2
Applied rewrites36.2%
Taylor expanded in y around 0
Applied rewrites47.4%
(FPCore (x y z t) :precision binary64 (- (* (* (- (* -0.5 y) 1.0) y) z) t))
double code(double x, double y, double z, double t) {
return ((((-0.5 * y) - 1.0) * 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 = (((((-0.5d0) * y) - 1.0d0) * y) * z) - t
end function
public static double code(double x, double y, double z, double t) {
return ((((-0.5 * y) - 1.0) * y) * z) - t;
}
def code(x, y, z, t): return ((((-0.5 * y) - 1.0) * y) * z) - t
function code(x, y, z, t) return Float64(Float64(Float64(Float64(Float64(-0.5 * y) - 1.0) * y) * z) - t) end
function tmp = code(x, y, z, t) tmp = ((((-0.5 * y) - 1.0) * y) * z) - t; end
code[x_, y_, z_, t_] := N[(N[(N[(N[(N[(-0.5 * y), $MachinePrecision] - 1.0), $MachinePrecision] * y), $MachinePrecision] * z), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(-0.5 \cdot y - 1\right) \cdot y\right) \cdot z - t
\end{array}
Initial program 87.3%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower-log.f64N/A
lower--.f6436.2
Applied rewrites36.2%
Taylor expanded in y around 0
Applied rewrites47.4%
(FPCore (x y z t) :precision binary64 (if (or (<= t -940000000.0) (not (<= t 78000000000000.0))) (- t) (* (- 1.0 z) y)))
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -940000000.0) || !(t <= 78000000000000.0)) {
tmp = -t;
} else {
tmp = (1.0 - z) * 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 ((t <= (-940000000.0d0)) .or. (.not. (t <= 78000000000000.0d0))) then
tmp = -t
else
tmp = (1.0d0 - z) * y
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -940000000.0) || !(t <= 78000000000000.0)) {
tmp = -t;
} else {
tmp = (1.0 - z) * y;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (t <= -940000000.0) or not (t <= 78000000000000.0): tmp = -t else: tmp = (1.0 - z) * y return tmp
function code(x, y, z, t) tmp = 0.0 if ((t <= -940000000.0) || !(t <= 78000000000000.0)) tmp = Float64(-t); else tmp = Float64(Float64(1.0 - z) * y); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((t <= -940000000.0) || ~((t <= 78000000000000.0))) tmp = -t; else tmp = (1.0 - z) * y; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[t, -940000000.0], N[Not[LessEqual[t, 78000000000000.0]], $MachinePrecision]], (-t), N[(N[(1.0 - z), $MachinePrecision] * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -940000000 \lor \neg \left(t \leq 78000000000000\right):\\
\;\;\;\;-t\\
\mathbf{else}:\\
\;\;\;\;\left(1 - z\right) \cdot y\\
\end{array}
\end{array}
if t < -9.4e8 or 7.8e13 < t Initial program 97.4%
Taylor expanded in t around inf
mul-1-negN/A
lower-neg.f6474.1
Applied rewrites74.1%
if -9.4e8 < t < 7.8e13Initial program 78.9%
Taylor expanded in y around 0
associate--l+N/A
associate-*r*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-neg.f64N/A
lower--.f64N/A
*-rgt-identityN/A
fp-cancel-sub-sign-invN/A
Applied rewrites99.2%
Taylor expanded in x around 0
Applied rewrites65.8%
Taylor expanded in y around inf
Applied rewrites23.3%
Final simplification46.3%
(FPCore (x y z t) :precision binary64 (if (or (<= t -940000000.0) (not (<= t 78000000000000.0))) (- t) (* (- y) z)))
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -940000000.0) || !(t <= 78000000000000.0)) {
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 <= (-940000000.0d0)) .or. (.not. (t <= 78000000000000.0d0))) 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 <= -940000000.0) || !(t <= 78000000000000.0)) {
tmp = -t;
} else {
tmp = -y * z;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (t <= -940000000.0) or not (t <= 78000000000000.0): tmp = -t else: tmp = -y * z return tmp
function code(x, y, z, t) tmp = 0.0 if ((t <= -940000000.0) || !(t <= 78000000000000.0)) tmp = Float64(-t); else tmp = Float64(Float64(-y) * z); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((t <= -940000000.0) || ~((t <= 78000000000000.0))) tmp = -t; else tmp = -y * z; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[t, -940000000.0], N[Not[LessEqual[t, 78000000000000.0]], $MachinePrecision]], (-t), N[((-y) * z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -940000000 \lor \neg \left(t \leq 78000000000000\right):\\
\;\;\;\;-t\\
\mathbf{else}:\\
\;\;\;\;\left(-y\right) \cdot z\\
\end{array}
\end{array}
if t < -9.4e8 or 7.8e13 < t Initial program 97.4%
Taylor expanded in t around inf
mul-1-negN/A
lower-neg.f6474.1
Applied rewrites74.1%
if -9.4e8 < t < 7.8e13Initial program 78.9%
Taylor expanded in y around 0
associate--l+N/A
associate-*r*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-neg.f64N/A
lower--.f64N/A
*-rgt-identityN/A
fp-cancel-sub-sign-invN/A
Applied rewrites99.2%
Taylor expanded in z around 0
Applied rewrites99.2%
Taylor expanded in z around inf
Applied rewrites22.9%
Final simplification46.1%
(FPCore (x y z t) :precision binary64 (- (* (* z (fma -0.5 y -1.0)) y) t))
double code(double x, double y, double z, double t) {
return ((z * fma(-0.5, y, -1.0)) * y) - t;
}
function code(x, y, z, t) return Float64(Float64(Float64(z * fma(-0.5, y, -1.0)) * y) - t) end
code[x_, y_, z_, t_] := N[(N[(N[(z * N[(-0.5 * y + -1.0), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\left(z \cdot \mathsf{fma}\left(-0.5, y, -1\right)\right) \cdot y - t
\end{array}
Initial program 87.3%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower-log.f64N/A
lower--.f6436.2
Applied rewrites36.2%
Taylor expanded in y around 0
Applied rewrites47.4%
(FPCore (x y z t) :precision binary64 (- (* (- y) z) t))
double code(double x, double y, double z, double t) {
return (-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 = (-y * z) - t
end function
public static double code(double x, double y, double z, double t) {
return (-y * z) - t;
}
def code(x, y, z, t): return (-y * z) - t
function code(x, y, z, t) return Float64(Float64(Float64(-y) * z) - t) end
function tmp = code(x, y, z, t) tmp = (-y * z) - t; end
code[x_, y_, z_, t_] := N[(N[((-y) * z), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\left(-y\right) \cdot z - t
\end{array}
Initial program 87.3%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower-log.f64N/A
lower--.f6436.2
Applied rewrites36.2%
Taylor expanded in y around 0
Applied rewrites47.4%
(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 87.3%
Taylor expanded in t around inf
mul-1-negN/A
lower-neg.f6435.6
Applied rewrites35.6%
herbie shell --seed 2024338
(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))