
(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 16 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 (- z 1.0) (log1p (- y)) (- (* (log y) (- x 1.0)) t)))
double code(double x, double y, double z, double t) {
return fma((z - 1.0), log1p(-y), ((log(y) * (x - 1.0)) - t));
}
function code(x, y, z, t) return fma(Float64(z - 1.0), log1p(Float64(-y)), Float64(Float64(log(y) * Float64(x - 1.0)) - t)) end
code[x_, y_, z_, t_] := N[(N[(z - 1.0), $MachinePrecision] * N[Log[1 + (-y)], $MachinePrecision] + N[(N[(N[Log[y], $MachinePrecision] * N[(x - 1.0), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(z - 1, \mathsf{log1p}\left(-y\right), \log y \cdot \left(x - 1\right) - t\right)
\end{array}
Initial program 86.9%
lift--.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate--l+N/A
lift-*.f64N/A
lower-fma.f64N/A
lift-log.f64N/A
unpow1N/A
unpow1N/A
lift--.f64N/A
*-lft-identityN/A
fp-cancel-sub-sign-invN/A
distribute-lft-neg-inN/A
*-lft-identityN/A
lower-log1p.f64N/A
lower-neg.f64N/A
lower--.f6499.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.9
Applied rewrites99.9%
(FPCore (x y z t) :precision binary64 (- (fma (+ -1.0 x) (log y) (* (fma (* (- z 1.0) (fma -0.3333333333333333 y -0.5)) y (- (- z 1.0))) y)) t))
double code(double x, double y, double z, double t) {
return fma((-1.0 + x), log(y), (fma(((z - 1.0) * fma(-0.3333333333333333, y, -0.5)), y, -(z - 1.0)) * y)) - t;
}
function code(x, y, z, t) return Float64(fma(Float64(-1.0 + x), log(y), Float64(fma(Float64(Float64(z - 1.0) * fma(-0.3333333333333333, y, -0.5)), y, Float64(-Float64(z - 1.0))) * y)) - t) end
code[x_, y_, z_, t_] := N[(N[(N[(-1.0 + x), $MachinePrecision] * N[Log[y], $MachinePrecision] + N[(N[(N[(N[(z - 1.0), $MachinePrecision] * N[(-0.3333333333333333 * y + -0.5), $MachinePrecision]), $MachinePrecision] * y + (-N[(z - 1.0), $MachinePrecision])), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(-1 + x, \log y, \mathsf{fma}\left(\left(z - 1\right) \cdot \mathsf{fma}\left(-0.3333333333333333, y, -0.5\right), y, -\left(z - 1\right)\right) \cdot y\right) - t
\end{array}
Initial program 86.9%
Taylor expanded in y around 0
+-commutativeN/A
Applied rewrites99.7%
(FPCore (x y z t) :precision binary64 (- (fma (+ -1.0 x) (log y) (* (* (- z 1.0) 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 - 1.0) * 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(Float64(z - 1.0) * 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[(N[(z - 1.0), $MachinePrecision] * y), $MachinePrecision] * N[(-0.5 * y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(-1 + x, \log y, \left(\left(z - 1\right) \cdot y\right) \cdot \mathsf{fma}\left(-0.5, y, -1\right)\right) - t
\end{array}
Initial program 86.9%
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.6%
(FPCore (x y z t) :precision binary64 (if (or (<= x -2e+37) (not (<= x 6.5e+15))) (fma (+ -1.0 x) (log y) (- t)) (fma (- z 1.0) (- y) (- (- (log y)) t))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -2e+37) || !(x <= 6.5e+15)) {
tmp = fma((-1.0 + x), log(y), -t);
} else {
tmp = fma((z - 1.0), -y, (-log(y) - t));
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if ((x <= -2e+37) || !(x <= 6.5e+15)) tmp = fma(Float64(-1.0 + x), log(y), Float64(-t)); else tmp = fma(Float64(z - 1.0), Float64(-y), Float64(Float64(-log(y)) - t)); end return tmp end
code[x_, y_, z_, t_] := If[Or[LessEqual[x, -2e+37], N[Not[LessEqual[x, 6.5e+15]], $MachinePrecision]], N[(N[(-1.0 + x), $MachinePrecision] * N[Log[y], $MachinePrecision] + (-t)), $MachinePrecision], N[(N[(z - 1.0), $MachinePrecision] * (-y) + N[((-N[Log[y], $MachinePrecision]) - t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2 \cdot 10^{+37} \lor \neg \left(x \leq 6.5 \cdot 10^{+15}\right):\\
\;\;\;\;\mathsf{fma}\left(-1 + x, \log y, -t\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z - 1, -y, \left(-\log y\right) - t\right)\\
\end{array}
\end{array}
if x < -1.99999999999999991e37 or 6.5e15 < x Initial program 95.5%
Taylor expanded in y around 0
remove-double-negN/A
distribute-lft-neg-outN/A
log-recN/A
mul-1-negN/A
mul-1-negN/A
log-recN/A
distribute-lft-neg-outN/A
remove-double-negN/A
*-rgt-identityN/A
fp-cancel-sub-sign-invN/A
Applied rewrites94.8%
if -1.99999999999999991e37 < x < 6.5e15Initial program 80.8%
lift--.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate--l+N/A
lift-*.f64N/A
lower-fma.f64N/A
lift-log.f64N/A
unpow1N/A
unpow1N/A
lift--.f64N/A
*-lft-identityN/A
fp-cancel-sub-sign-invN/A
distribute-lft-neg-inN/A
*-lft-identityN/A
lower-log1p.f64N/A
lower-neg.f64N/A
lower--.f64100.0
lift-*.f64N/A
*-commutativeN/A
lower-*.f64100.0
Applied rewrites100.0%
Taylor expanded in y around 0
mul-1-negN/A
lower-neg.f6498.9
Applied rewrites98.9%
Taylor expanded in x around 0
remove-double-negN/A
log-recN/A
mul-1-negN/A
mul-1-negN/A
lower-neg.f64N/A
mul-1-negN/A
log-recN/A
remove-double-negN/A
lower-log.f6496.3
Applied rewrites96.3%
Final simplification95.7%
(FPCore (x y z t) :precision binary64 (if (or (<= x -2e+37) (not (<= x 6.5e+15))) (fma (+ -1.0 x) (log y) (- t)) (- (fma (- 1.0 z) y (- (log y))) t)))
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -2e+37) || !(x <= 6.5e+15)) {
tmp = fma((-1.0 + x), log(y), -t);
} else {
tmp = fma((1.0 - z), y, -log(y)) - t;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if ((x <= -2e+37) || !(x <= 6.5e+15)) tmp = fma(Float64(-1.0 + x), log(y), Float64(-t)); else tmp = Float64(fma(Float64(1.0 - z), y, Float64(-log(y))) - t); end return tmp end
code[x_, y_, z_, t_] := If[Or[LessEqual[x, -2e+37], N[Not[LessEqual[x, 6.5e+15]], $MachinePrecision]], N[(N[(-1.0 + x), $MachinePrecision] * N[Log[y], $MachinePrecision] + (-t)), $MachinePrecision], N[(N[(N[(1.0 - z), $MachinePrecision] * y + (-N[Log[y], $MachinePrecision])), $MachinePrecision] - t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2 \cdot 10^{+37} \lor \neg \left(x \leq 6.5 \cdot 10^{+15}\right):\\
\;\;\;\;\mathsf{fma}\left(-1 + x, \log y, -t\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(1 - z, y, -\log y\right) - t\\
\end{array}
\end{array}
if x < -1.99999999999999991e37 or 6.5e15 < x Initial program 95.5%
Taylor expanded in y around 0
remove-double-negN/A
distribute-lft-neg-outN/A
log-recN/A
mul-1-negN/A
mul-1-negN/A
log-recN/A
distribute-lft-neg-outN/A
remove-double-negN/A
*-rgt-identityN/A
fp-cancel-sub-sign-invN/A
Applied rewrites94.8%
if -1.99999999999999991e37 < x < 6.5e15Initial program 80.8%
Taylor expanded in y around 0
+-commutativeN/A
Applied rewrites99.7%
Taylor expanded in y around 0
Applied rewrites98.9%
Taylor expanded in x around 0
Applied rewrites96.3%
Final simplification95.7%
(FPCore (x y z t)
:precision binary64
(if (or (<= (- x 1.0) -1e+35) (not (<= (- x 1.0) 1e+14)))
(- (* (log y) x) t)
(-
(*
(fma (fma (* z (fma -0.25 y -0.3333333333333333)) y (* -0.5 z)) y (- z))
y)
t)))
double code(double x, double y, double z, double t) {
double tmp;
if (((x - 1.0) <= -1e+35) || !((x - 1.0) <= 1e+14)) {
tmp = (log(y) * x) - t;
} else {
tmp = (fma(fma((z * fma(-0.25, y, -0.3333333333333333)), y, (-0.5 * z)), y, -z) * y) - t;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if ((Float64(x - 1.0) <= -1e+35) || !(Float64(x - 1.0) <= 1e+14)) tmp = Float64(Float64(log(y) * x) - t); else tmp = Float64(Float64(fma(fma(Float64(z * fma(-0.25, y, -0.3333333333333333)), y, Float64(-0.5 * z)), y, Float64(-z)) * y) - t); end return tmp end
code[x_, y_, z_, t_] := If[Or[LessEqual[N[(x - 1.0), $MachinePrecision], -1e+35], N[Not[LessEqual[N[(x - 1.0), $MachinePrecision], 1e+14]], $MachinePrecision]], N[(N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision] - t), $MachinePrecision], N[(N[(N[(N[(N[(z * N[(-0.25 * y + -0.3333333333333333), $MachinePrecision]), $MachinePrecision] * y + N[(-0.5 * z), $MachinePrecision]), $MachinePrecision] * y + (-z)), $MachinePrecision] * y), $MachinePrecision] - t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x - 1 \leq -1 \cdot 10^{+35} \lor \neg \left(x - 1 \leq 10^{+14}\right):\\
\;\;\;\;\log y \cdot x - t\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(z \cdot \mathsf{fma}\left(-0.25, y, -0.3333333333333333\right), y, -0.5 \cdot z\right), y, -z\right) \cdot y - t\\
\end{array}
\end{array}
if (-.f64 x #s(literal 1 binary64)) < -9.9999999999999997e34 or 1e14 < (-.f64 x #s(literal 1 binary64)) Initial program 94.7%
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.f6494.0
Applied rewrites94.0%
if -9.9999999999999997e34 < (-.f64 x #s(literal 1 binary64)) < 1e14Initial program 81.2%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower-log.f64N/A
lower--.f6454.4
Applied rewrites54.4%
Taylor expanded in y around 0
Applied rewrites72.6%
Final simplification81.7%
(FPCore (x y z t)
:precision binary64
(if (<= z -5e+144)
(-
(*
(fma (fma (* z (fma -0.25 y -0.3333333333333333)) y (* -0.5 z)) y (- z))
y)
t)
(if (<= z 9e+237) (fma (+ -1.0 x) (log y) (- t)) (- (* (- 1.0 z) y) t))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -5e+144) {
tmp = (fma(fma((z * fma(-0.25, y, -0.3333333333333333)), y, (-0.5 * z)), y, -z) * y) - t;
} else if (z <= 9e+237) {
tmp = fma((-1.0 + x), log(y), -t);
} else {
tmp = ((1.0 - z) * y) - t;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (z <= -5e+144) tmp = Float64(Float64(fma(fma(Float64(z * fma(-0.25, y, -0.3333333333333333)), y, Float64(-0.5 * z)), y, Float64(-z)) * y) - t); elseif (z <= 9e+237) tmp = fma(Float64(-1.0 + x), log(y), Float64(-t)); else tmp = Float64(Float64(Float64(1.0 - z) * y) - t); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[z, -5e+144], N[(N[(N[(N[(N[(z * N[(-0.25 * y + -0.3333333333333333), $MachinePrecision]), $MachinePrecision] * y + N[(-0.5 * z), $MachinePrecision]), $MachinePrecision] * y + (-z)), $MachinePrecision] * y), $MachinePrecision] - t), $MachinePrecision], If[LessEqual[z, 9e+237], N[(N[(-1.0 + x), $MachinePrecision] * N[Log[y], $MachinePrecision] + (-t)), $MachinePrecision], N[(N[(N[(1.0 - z), $MachinePrecision] * y), $MachinePrecision] - t), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5 \cdot 10^{+144}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(z \cdot \mathsf{fma}\left(-0.25, y, -0.3333333333333333\right), y, -0.5 \cdot z\right), y, -z\right) \cdot y - t\\
\mathbf{elif}\;z \leq 9 \cdot 10^{+237}:\\
\;\;\;\;\mathsf{fma}\left(-1 + x, \log y, -t\right)\\
\mathbf{else}:\\
\;\;\;\;\left(1 - z\right) \cdot y - t\\
\end{array}
\end{array}
if z < -4.9999999999999999e144Initial program 61.0%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower-log.f64N/A
lower--.f6445.9
Applied rewrites45.9%
Taylor expanded in y around 0
Applied rewrites83.1%
if -4.9999999999999999e144 < z < 8.99999999999999928e237Initial program 95.7%
Taylor expanded in y around 0
remove-double-negN/A
distribute-lft-neg-outN/A
log-recN/A
mul-1-negN/A
mul-1-negN/A
log-recN/A
distribute-lft-neg-outN/A
remove-double-negN/A
*-rgt-identityN/A
fp-cancel-sub-sign-invN/A
Applied rewrites95.1%
if 8.99999999999999928e237 < z Initial program 22.7%
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 rewrites100.0%
Taylor expanded in y around inf
Applied rewrites16.3%
Taylor expanded in y around 0
Applied rewrites93.2%
Final simplification93.3%
(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 86.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
remove-double-negN/A
distribute-lft-neg-outN/A
log-recN/A
mul-1-negN/A
mul-1-negN/A
log-recN/A
distribute-lft-neg-outN/A
remove-double-negN/A
*-rgt-identityN/A
fp-cancel-sub-sign-invN/A
Applied rewrites99.1%
Final simplification99.1%
(FPCore (x y z t) :precision binary64 (- (fma (- 1.0 z) y (* (log y) (- x 1.0))) t))
double code(double x, double y, double z, double t) {
return fma((1.0 - z), y, (log(y) * (x - 1.0))) - t;
}
function code(x, y, z, t) return Float64(fma(Float64(1.0 - z), y, Float64(log(y) * Float64(x - 1.0))) - t) end
code[x_, y_, z_, t_] := N[(N[(N[(1.0 - z), $MachinePrecision] * y + N[(N[Log[y], $MachinePrecision] * N[(x - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(1 - z, y, \log y \cdot \left(x - 1\right)\right) - t
\end{array}
Initial program 86.9%
Taylor expanded in y around 0
+-commutativeN/A
Applied rewrites99.7%
Taylor expanded in y around 0
Applied rewrites99.1%
(FPCore (x y z t)
:precision binary64
(if (or (<= x -3.1e+39) (not (<= x 1.6e+16)))
(* (log y) x)
(-
(*
(fma (fma (* z (fma -0.25 y -0.3333333333333333)) y (* -0.5 z)) y (- z))
y)
t)))
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -3.1e+39) || !(x <= 1.6e+16)) {
tmp = log(y) * x;
} else {
tmp = (fma(fma((z * fma(-0.25, y, -0.3333333333333333)), y, (-0.5 * z)), y, -z) * y) - t;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if ((x <= -3.1e+39) || !(x <= 1.6e+16)) tmp = Float64(log(y) * x); else tmp = Float64(Float64(fma(fma(Float64(z * fma(-0.25, y, -0.3333333333333333)), y, Float64(-0.5 * z)), y, Float64(-z)) * y) - t); end return tmp end
code[x_, y_, z_, t_] := If[Or[LessEqual[x, -3.1e+39], N[Not[LessEqual[x, 1.6e+16]], $MachinePrecision]], N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision], N[(N[(N[(N[(N[(z * N[(-0.25 * y + -0.3333333333333333), $MachinePrecision]), $MachinePrecision] * y + N[(-0.5 * z), $MachinePrecision]), $MachinePrecision] * y + (-z)), $MachinePrecision] * y), $MachinePrecision] - t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.1 \cdot 10^{+39} \lor \neg \left(x \leq 1.6 \cdot 10^{+16}\right):\\
\;\;\;\;\log y \cdot x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(z \cdot \mathsf{fma}\left(-0.25, y, -0.3333333333333333\right), y, -0.5 \cdot z\right), y, -z\right) \cdot y - t\\
\end{array}
\end{array}
if x < -3.1000000000000003e39 or 1.6e16 < x Initial program 95.5%
lift--.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate--l+N/A
lift-*.f64N/A
lower-fma.f64N/A
lift-log.f64N/A
unpow1N/A
unpow1N/A
lift--.f64N/A
*-lft-identityN/A
fp-cancel-sub-sign-invN/A
distribute-lft-neg-inN/A
*-lft-identityN/A
lower-log1p.f64N/A
lower-neg.f64N/A
lower--.f6499.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.7
Applied rewrites99.7%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower-log.f6474.0
Applied rewrites74.0%
if -3.1000000000000003e39 < x < 1.6e16Initial program 80.8%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower-log.f64N/A
lower--.f6453.7
Applied rewrites53.7%
Taylor expanded in y around 0
Applied rewrites72.3%
Final simplification73.0%
(FPCore (x y z t) :precision binary64 (- (* (fma (* -0.5 (- z 1.0)) y (- 1.0 z)) y) t))
double code(double x, double y, double z, double t) {
return (fma((-0.5 * (z - 1.0)), y, (1.0 - z)) * y) - t;
}
function code(x, y, z, t) return Float64(Float64(fma(Float64(-0.5 * Float64(z - 1.0)), y, Float64(1.0 - z)) * y) - t) end
code[x_, y_, z_, t_] := N[(N[(N[(N[(-0.5 * N[(z - 1.0), $MachinePrecision]), $MachinePrecision] * y + N[(1.0 - z), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(-0.5 \cdot \left(z - 1\right), y, 1 - z\right) \cdot y - t
\end{array}
Initial program 86.9%
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.6%
Taylor expanded in y around inf
Applied rewrites35.5%
Taylor expanded in y around 0
Applied rewrites52.9%
(FPCore (x y z t) :precision binary64 (- (* (fma (* z y) -0.5 (- z)) y) t))
double code(double x, double y, double z, double t) {
return (fma((z * y), -0.5, -z) * y) - t;
}
function code(x, y, z, t) return Float64(Float64(fma(Float64(z * y), -0.5, Float64(-z)) * y) - t) end
code[x_, y_, z_, t_] := N[(N[(N[(N[(z * y), $MachinePrecision] * -0.5 + (-z)), $MachinePrecision] * y), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(z \cdot y, -0.5, -z\right) \cdot y - t
\end{array}
Initial program 86.9%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower-log.f64N/A
lower--.f6440.4
Applied rewrites40.4%
Taylor expanded in y around 0
Applied rewrites52.7%
Applied rewrites52.7%
(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 86.9%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower-log.f64N/A
lower--.f6440.4
Applied rewrites40.4%
Taylor expanded in y around 0
Applied rewrites52.7%
(FPCore (x y z t) :precision binary64 (- (* (- 1.0 z) y) t))
double code(double x, double y, double z, double t) {
return ((1.0 - z) * 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 = ((1.0d0 - z) * y) - t
end function
public static double code(double x, double y, double z, double t) {
return ((1.0 - z) * y) - t;
}
def code(x, y, z, t): return ((1.0 - z) * y) - t
function code(x, y, z, t) return Float64(Float64(Float64(1.0 - z) * y) - t) end
function tmp = code(x, y, z, t) tmp = ((1.0 - z) * y) - t; end
code[x_, y_, z_, t_] := N[(N[(N[(1.0 - z), $MachinePrecision] * y), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\left(1 - z\right) \cdot y - t
\end{array}
Initial program 86.9%
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.6%
Taylor expanded in y around inf
Applied rewrites35.5%
Taylor expanded in y around 0
Applied rewrites52.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 86.9%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower-log.f64N/A
lower--.f6440.4
Applied rewrites40.4%
Taylor expanded in y around 0
Applied rewrites52.2%
(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 86.9%
Taylor expanded in t around inf
mul-1-negN/A
lower-neg.f6439.3
Applied rewrites39.3%
Final simplification39.3%
herbie shell --seed 2024342
(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))