
(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 15 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 (- x 1.0) (log y) (fma (log1p (- y)) (- z 1.0) (- t))))
double code(double x, double y, double z, double t) {
return fma((x - 1.0), log(y), fma(log1p(-y), (z - 1.0), -t));
}
function code(x, y, z, t) return fma(Float64(x - 1.0), log(y), fma(log1p(Float64(-y)), Float64(z - 1.0), Float64(-t))) end
code[x_, y_, z_, t_] := N[(N[(x - 1.0), $MachinePrecision] * N[Log[y], $MachinePrecision] + N[(N[Log[1 + (-y)], $MachinePrecision] * N[(z - 1.0), $MachinePrecision] + (-t)), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(x - 1, \log y, \mathsf{fma}\left(\mathsf{log1p}\left(-y\right), z - 1, -t\right)\right)
\end{array}
Initial program 90.4%
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
lift-*.f64N/A
lower-fma.f64N/A
sub-negN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-log.f64N/A
lift--.f64N/A
sub-negN/A
lower-log1p.f64N/A
lower-neg.f64N/A
lower-neg.f6499.8
Applied rewrites99.8%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (fma (- x 1.0) (log y) (- y t)))
(t_2 (- (+ (* (log (- 1.0 y)) (- z 1.0)) (* (log y) (- x 1.0))) t)))
(if (<= t_2 40.0)
t_1
(if (<= t_2 624.5) (fma -1.0 (log y) (* z (- y))) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = fma((x - 1.0), log(y), (y - t));
double t_2 = ((log((1.0 - y)) * (z - 1.0)) + (log(y) * (x - 1.0))) - t;
double tmp;
if (t_2 <= 40.0) {
tmp = t_1;
} else if (t_2 <= 624.5) {
tmp = fma(-1.0, log(y), (z * -y));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = fma(Float64(x - 1.0), log(y), Float64(y - t)) t_2 = Float64(Float64(Float64(log(Float64(1.0 - y)) * Float64(z - 1.0)) + Float64(log(y) * Float64(x - 1.0))) - t) tmp = 0.0 if (t_2 <= 40.0) tmp = t_1; elseif (t_2 <= 624.5) tmp = fma(-1.0, log(y), Float64(z * Float64(-y))); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(x - 1.0), $MachinePrecision] * N[Log[y], $MachinePrecision] + N[(y - t), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(N[Log[N[(1.0 - y), $MachinePrecision]], $MachinePrecision] * N[(z - 1.0), $MachinePrecision]), $MachinePrecision] + N[(N[Log[y], $MachinePrecision] * N[(x - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]}, If[LessEqual[t$95$2, 40.0], t$95$1, If[LessEqual[t$95$2, 624.5], N[(-1.0 * N[Log[y], $MachinePrecision] + N[(z * (-y)), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(x - 1, \log y, y - t\right)\\
t_2 := \left(\log \left(1 - y\right) \cdot \left(z - 1\right) + \log y \cdot \left(x - 1\right)\right) - t\\
\mathbf{if}\;t\_2 \leq 40:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 624.5:\\
\;\;\;\;\mathsf{fma}\left(-1, \log y, z \cdot \left(-y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\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) < 40 or 624.5 < (-.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 96.1%
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
lift-*.f64N/A
lower-fma.f64N/A
sub-negN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-log.f64N/A
lift--.f64N/A
sub-negN/A
lower-log1p.f64N/A
lower-neg.f64N/A
lower-neg.f6499.8
Applied rewrites99.8%
Taylor expanded in y around 0
lower--.f64N/A
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-inN/A
sub-negN/A
metadata-evalN/A
distribute-neg-inN/A
metadata-evalN/A
+-commutativeN/A
sub-negN/A
lower-*.f64N/A
lower--.f6499.7
Applied rewrites99.7%
Taylor expanded in z around 0
Applied rewrites95.9%
if 40 < (-.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) < 624.5Initial program 68.6%
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
lift-*.f64N/A
lower-fma.f64N/A
sub-negN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-log.f64N/A
lift--.f64N/A
sub-negN/A
lower-log1p.f64N/A
lower-neg.f64N/A
lower-neg.f64100.0
Applied rewrites100.0%
Taylor expanded in y around 0
lower--.f64N/A
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-inN/A
sub-negN/A
metadata-evalN/A
distribute-neg-inN/A
metadata-evalN/A
+-commutativeN/A
sub-negN/A
lower-*.f64N/A
lower--.f64100.0
Applied rewrites100.0%
Taylor expanded in z around inf
Applied rewrites99.7%
Taylor expanded in x around 0
Applied rewrites96.2%
Final simplification96.0%
(FPCore (x y z t)
:precision binary64
(if (<= (- x 1.0) -1.000002)
(fma (- x 1.0) (log y) (- t))
(if (<= (- x 1.0) -0.99999999999995)
(- (fma (- 1.0 z) y (- (log y))) t)
(fma (- x 1.0) (log y) (- y t)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x - 1.0) <= -1.000002) {
tmp = fma((x - 1.0), log(y), -t);
} else if ((x - 1.0) <= -0.99999999999995) {
tmp = fma((1.0 - z), y, -log(y)) - t;
} else {
tmp = fma((x - 1.0), log(y), (y - t));
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (Float64(x - 1.0) <= -1.000002) tmp = fma(Float64(x - 1.0), log(y), Float64(-t)); elseif (Float64(x - 1.0) <= -0.99999999999995) tmp = Float64(fma(Float64(1.0 - z), y, Float64(-log(y))) - t); else tmp = fma(Float64(x - 1.0), log(y), Float64(y - t)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[(x - 1.0), $MachinePrecision], -1.000002], N[(N[(x - 1.0), $MachinePrecision] * N[Log[y], $MachinePrecision] + (-t)), $MachinePrecision], If[LessEqual[N[(x - 1.0), $MachinePrecision], -0.99999999999995], N[(N[(N[(1.0 - z), $MachinePrecision] * y + (-N[Log[y], $MachinePrecision])), $MachinePrecision] - t), $MachinePrecision], N[(N[(x - 1.0), $MachinePrecision] * N[Log[y], $MachinePrecision] + N[(y - t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x - 1 \leq -1.000002:\\
\;\;\;\;\mathsf{fma}\left(x - 1, \log y, -t\right)\\
\mathbf{elif}\;x - 1 \leq -0.99999999999995:\\
\;\;\;\;\mathsf{fma}\left(1 - z, y, -\log y\right) - t\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x - 1, \log y, y - t\right)\\
\end{array}
\end{array}
if (-.f64 x #s(literal 1 binary64)) < -1.00000200000000006Initial program 96.7%
Taylor expanded in y around 0
sub-negN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-log.f64N/A
lower-neg.f6496.7
Applied rewrites96.7%
if -1.00000200000000006 < (-.f64 x #s(literal 1 binary64)) < -0.99999999999995004Initial program 85.0%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
flip3--N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
clear-numN/A
flip3--N/A
lift--.f64N/A
lower-/.f6485.0
Applied rewrites85.0%
Taylor expanded in y around 0
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-inN/A
sub-negN/A
metadata-evalN/A
distribute-neg-inN/A
metadata-evalN/A
+-commutativeN/A
sub-negN/A
lower-fma.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-log.f6499.9
Applied rewrites99.9%
Taylor expanded in x around 0
Applied rewrites99.9%
if -0.99999999999995004 < (-.f64 x #s(literal 1 binary64)) Initial program 94.0%
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
lift-*.f64N/A
lower-fma.f64N/A
sub-negN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-log.f64N/A
lift--.f64N/A
sub-negN/A
lower-log1p.f64N/A
lower-neg.f64N/A
lower-neg.f6499.6
Applied rewrites99.6%
Taylor expanded in y around 0
lower--.f64N/A
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-inN/A
sub-negN/A
metadata-evalN/A
distribute-neg-inN/A
metadata-evalN/A
+-commutativeN/A
sub-negN/A
lower-*.f64N/A
lower--.f6499.6
Applied rewrites99.6%
Taylor expanded in z around 0
Applied rewrites94.0%
(FPCore (x y z t)
:precision binary64
(if (<= t -430000000.0)
(- (fma (- 1.0 z) y (* (log y) x)) t)
(if (<= t 2e-27)
(fma (- x 1.0) (log y) (* z (- y)))
(fma (- x 1.0) (log y) (- y t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= -430000000.0) {
tmp = fma((1.0 - z), y, (log(y) * x)) - t;
} else if (t <= 2e-27) {
tmp = fma((x - 1.0), log(y), (z * -y));
} else {
tmp = fma((x - 1.0), log(y), (y - t));
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (t <= -430000000.0) tmp = Float64(fma(Float64(1.0 - z), y, Float64(log(y) * x)) - t); elseif (t <= 2e-27) tmp = fma(Float64(x - 1.0), log(y), Float64(z * Float64(-y))); else tmp = fma(Float64(x - 1.0), log(y), Float64(y - t)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[t, -430000000.0], N[(N[(N[(1.0 - z), $MachinePrecision] * y + N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision], If[LessEqual[t, 2e-27], N[(N[(x - 1.0), $MachinePrecision] * N[Log[y], $MachinePrecision] + N[(z * (-y)), $MachinePrecision]), $MachinePrecision], N[(N[(x - 1.0), $MachinePrecision] * N[Log[y], $MachinePrecision] + N[(y - t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -430000000:\\
\;\;\;\;\mathsf{fma}\left(1 - z, y, \log y \cdot x\right) - t\\
\mathbf{elif}\;t \leq 2 \cdot 10^{-27}:\\
\;\;\;\;\mathsf{fma}\left(x - 1, \log y, z \cdot \left(-y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x - 1, \log y, y - t\right)\\
\end{array}
\end{array}
if t < -4.3e8Initial program 96.5%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
flip3--N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
clear-numN/A
flip3--N/A
lift--.f64N/A
lower-/.f6496.4
Applied rewrites96.4%
Taylor expanded in y around 0
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-inN/A
sub-negN/A
metadata-evalN/A
distribute-neg-inN/A
metadata-evalN/A
+-commutativeN/A
sub-negN/A
lower-fma.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-log.f6499.9
Applied rewrites99.9%
Taylor expanded in x around inf
Applied rewrites99.9%
if -4.3e8 < t < 2.0000000000000001e-27Initial program 83.5%
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
lift-*.f64N/A
lower-fma.f64N/A
sub-negN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-log.f64N/A
lift--.f64N/A
sub-negN/A
lower-log1p.f64N/A
lower-neg.f64N/A
lower-neg.f6499.8
Applied rewrites99.8%
Taylor expanded in y around 0
lower--.f64N/A
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-inN/A
sub-negN/A
metadata-evalN/A
distribute-neg-inN/A
metadata-evalN/A
+-commutativeN/A
sub-negN/A
lower-*.f64N/A
lower--.f6499.7
Applied rewrites99.7%
Taylor expanded in z around inf
Applied rewrites99.2%
if 2.0000000000000001e-27 < t Initial program 97.4%
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
lift-*.f64N/A
lower-fma.f64N/A
sub-negN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-log.f64N/A
lift--.f64N/A
sub-negN/A
lower-log1p.f64N/A
lower-neg.f64N/A
lower-neg.f6499.8
Applied rewrites99.8%
Taylor expanded in y around 0
lower--.f64N/A
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-inN/A
sub-negN/A
metadata-evalN/A
distribute-neg-inN/A
metadata-evalN/A
+-commutativeN/A
sub-negN/A
lower-*.f64N/A
lower--.f6499.8
Applied rewrites99.8%
Taylor expanded in z around 0
Applied rewrites97.4%
Final simplification98.8%
(FPCore (x y z t)
:precision binary64
(if (<= t -1.2e-12)
(fma (- x 1.0) (log y) (- t))
(if (<= t 2e-27)
(fma (- x 1.0) (log y) (* z (- y)))
(fma (- x 1.0) (log y) (- y t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= -1.2e-12) {
tmp = fma((x - 1.0), log(y), -t);
} else if (t <= 2e-27) {
tmp = fma((x - 1.0), log(y), (z * -y));
} else {
tmp = fma((x - 1.0), log(y), (y - t));
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (t <= -1.2e-12) tmp = fma(Float64(x - 1.0), log(y), Float64(-t)); elseif (t <= 2e-27) tmp = fma(Float64(x - 1.0), log(y), Float64(z * Float64(-y))); else tmp = fma(Float64(x - 1.0), log(y), Float64(y - t)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[t, -1.2e-12], N[(N[(x - 1.0), $MachinePrecision] * N[Log[y], $MachinePrecision] + (-t)), $MachinePrecision], If[LessEqual[t, 2e-27], N[(N[(x - 1.0), $MachinePrecision] * N[Log[y], $MachinePrecision] + N[(z * (-y)), $MachinePrecision]), $MachinePrecision], N[(N[(x - 1.0), $MachinePrecision] * N[Log[y], $MachinePrecision] + N[(y - t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.2 \cdot 10^{-12}:\\
\;\;\;\;\mathsf{fma}\left(x - 1, \log y, -t\right)\\
\mathbf{elif}\;t \leq 2 \cdot 10^{-27}:\\
\;\;\;\;\mathsf{fma}\left(x - 1, \log y, z \cdot \left(-y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x - 1, \log y, y - t\right)\\
\end{array}
\end{array}
if t < -1.19999999999999994e-12Initial program 96.7%
Taylor expanded in y around 0
sub-negN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-log.f64N/A
lower-neg.f6496.7
Applied rewrites96.7%
if -1.19999999999999994e-12 < t < 2.0000000000000001e-27Initial program 82.8%
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
lift-*.f64N/A
lower-fma.f64N/A
sub-negN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-log.f64N/A
lift--.f64N/A
sub-negN/A
lower-log1p.f64N/A
lower-neg.f64N/A
lower-neg.f6499.8
Applied rewrites99.8%
Taylor expanded in y around 0
lower--.f64N/A
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-inN/A
sub-negN/A
metadata-evalN/A
distribute-neg-inN/A
metadata-evalN/A
+-commutativeN/A
sub-negN/A
lower-*.f64N/A
lower--.f6499.7
Applied rewrites99.7%
Taylor expanded in z around inf
Applied rewrites99.3%
if 2.0000000000000001e-27 < t Initial program 97.4%
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
lift-*.f64N/A
lower-fma.f64N/A
sub-negN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-log.f64N/A
lift--.f64N/A
sub-negN/A
lower-log1p.f64N/A
lower-neg.f64N/A
lower-neg.f6499.8
Applied rewrites99.8%
Taylor expanded in y around 0
lower--.f64N/A
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-inN/A
sub-negN/A
metadata-evalN/A
distribute-neg-inN/A
metadata-evalN/A
+-commutativeN/A
sub-negN/A
lower-*.f64N/A
lower--.f6499.8
Applied rewrites99.8%
Taylor expanded in z around 0
Applied rewrites97.4%
Final simplification98.1%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* (log y) x)))
(if (<= (- x 1.0) -2e+64)
t_1
(if (<= (- x 1.0) 1e+16) (- (fma (- y) z y) t) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = log(y) * x;
double tmp;
if ((x - 1.0) <= -2e+64) {
tmp = t_1;
} else if ((x - 1.0) <= 1e+16) {
tmp = fma(-y, z, y) - t;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(log(y) * x) tmp = 0.0 if (Float64(x - 1.0) <= -2e+64) tmp = t_1; elseif (Float64(x - 1.0) <= 1e+16) tmp = Float64(fma(Float64(-y), z, y) - t); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[N[(x - 1.0), $MachinePrecision], -2e+64], t$95$1, If[LessEqual[N[(x - 1.0), $MachinePrecision], 1e+16], N[(N[((-y) * z + y), $MachinePrecision] - t), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \log y \cdot x\\
\mathbf{if}\;x - 1 \leq -2 \cdot 10^{+64}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x - 1 \leq 10^{+16}:\\
\;\;\;\;\mathsf{fma}\left(-y, z, y\right) - t\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (-.f64 x #s(literal 1 binary64)) < -2.00000000000000004e64 or 1e16 < (-.f64 x #s(literal 1 binary64)) Initial program 96.0%
Taylor expanded in x around inf
lower-*.f64N/A
lower-log.f6480.2
Applied rewrites80.2%
if -2.00000000000000004e64 < (-.f64 x #s(literal 1 binary64)) < 1e16Initial program 86.2%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
flip3--N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
clear-numN/A
flip3--N/A
lift--.f64N/A
lower-/.f6486.2
Applied rewrites86.2%
Taylor expanded in y around 0
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-inN/A
sub-negN/A
metadata-evalN/A
distribute-neg-inN/A
metadata-evalN/A
+-commutativeN/A
sub-negN/A
lower-fma.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-log.f6499.8
Applied rewrites99.8%
Taylor expanded in y around inf
Applied rewrites63.1%
Final simplification70.4%
(FPCore (x y z t) :precision binary64 (if (<= (- z 1.0) 2e+206) (fma (- x 1.0) (log y) (- y t)) (- (* (- y) z) t)))
double code(double x, double y, double z, double t) {
double tmp;
if ((z - 1.0) <= 2e+206) {
tmp = fma((x - 1.0), log(y), (y - t));
} else {
tmp = (-y * z) - t;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (Float64(z - 1.0) <= 2e+206) tmp = fma(Float64(x - 1.0), log(y), Float64(y - t)); else tmp = Float64(Float64(Float64(-y) * z) - t); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[(z - 1.0), $MachinePrecision], 2e+206], N[(N[(x - 1.0), $MachinePrecision] * N[Log[y], $MachinePrecision] + N[(y - t), $MachinePrecision]), $MachinePrecision], N[(N[((-y) * z), $MachinePrecision] - t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z - 1 \leq 2 \cdot 10^{+206}:\\
\;\;\;\;\mathsf{fma}\left(x - 1, \log y, y - t\right)\\
\mathbf{else}:\\
\;\;\;\;\left(-y\right) \cdot z - t\\
\end{array}
\end{array}
if (-.f64 z #s(literal 1 binary64)) < 2.0000000000000001e206Initial program 94.1%
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
lift-*.f64N/A
lower-fma.f64N/A
sub-negN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-log.f64N/A
lift--.f64N/A
sub-negN/A
lower-log1p.f64N/A
lower-neg.f64N/A
lower-neg.f6499.8
Applied rewrites99.8%
Taylor expanded in y around 0
lower--.f64N/A
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-inN/A
sub-negN/A
metadata-evalN/A
distribute-neg-inN/A
metadata-evalN/A
+-commutativeN/A
sub-negN/A
lower-*.f64N/A
lower--.f6499.8
Applied rewrites99.8%
Taylor expanded in z around 0
Applied rewrites94.0%
if 2.0000000000000001e206 < (-.f64 z #s(literal 1 binary64)) Initial program 43.9%
Taylor expanded in z around inf
lower-*.f64N/A
sub-negN/A
lower-log1p.f64N/A
lower-neg.f6489.7
Applied rewrites89.7%
Taylor expanded in y around 0
Applied rewrites89.7%
Final simplification93.7%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (- (* (log y) x) t))) (if (<= x -1.66e-6) t_1 (if (<= x 11.5) (- (fma (- y) z y) t) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = (log(y) * x) - t;
double tmp;
if (x <= -1.66e-6) {
tmp = t_1;
} else if (x <= 11.5) {
tmp = fma(-y, z, y) - t;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(Float64(log(y) * x) - t) tmp = 0.0 if (x <= -1.66e-6) tmp = t_1; elseif (x <= 11.5) tmp = Float64(fma(Float64(-y), z, y) - t); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision] - t), $MachinePrecision]}, If[LessEqual[x, -1.66e-6], t$95$1, If[LessEqual[x, 11.5], N[(N[((-y) * z + y), $MachinePrecision] - t), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \log y \cdot x - t\\
\mathbf{if}\;x \leq -1.66 \cdot 10^{-6}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 11.5:\\
\;\;\;\;\mathsf{fma}\left(-y, z, y\right) - t\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -1.65999999999999999e-6 or 11.5 < x Initial program 95.1%
Taylor expanded in x around inf
lower-*.f64N/A
lower-log.f6492.5
Applied rewrites92.5%
if -1.65999999999999999e-6 < x < 11.5Initial program 85.4%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
flip3--N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
clear-numN/A
flip3--N/A
lift--.f64N/A
lower-/.f6485.4
Applied rewrites85.4%
Taylor expanded in y around 0
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-inN/A
sub-negN/A
metadata-evalN/A
distribute-neg-inN/A
metadata-evalN/A
+-commutativeN/A
sub-negN/A
lower-fma.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-log.f6499.9
Applied rewrites99.9%
Taylor expanded in y around inf
Applied rewrites65.0%
Final simplification79.1%
(FPCore (x y z t) :precision binary64 (if (<= (- z 1.0) 2e+206) (fma (- x 1.0) (log y) (- t)) (- (* (- y) z) t)))
double code(double x, double y, double z, double t) {
double tmp;
if ((z - 1.0) <= 2e+206) {
tmp = fma((x - 1.0), log(y), -t);
} else {
tmp = (-y * z) - t;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (Float64(z - 1.0) <= 2e+206) tmp = fma(Float64(x - 1.0), log(y), Float64(-t)); else tmp = Float64(Float64(Float64(-y) * z) - t); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[(z - 1.0), $MachinePrecision], 2e+206], N[(N[(x - 1.0), $MachinePrecision] * N[Log[y], $MachinePrecision] + (-t)), $MachinePrecision], N[(N[((-y) * z), $MachinePrecision] - t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z - 1 \leq 2 \cdot 10^{+206}:\\
\;\;\;\;\mathsf{fma}\left(x - 1, \log y, -t\right)\\
\mathbf{else}:\\
\;\;\;\;\left(-y\right) \cdot z - t\\
\end{array}
\end{array}
if (-.f64 z #s(literal 1 binary64)) < 2.0000000000000001e206Initial program 94.1%
Taylor expanded in y around 0
sub-negN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-log.f64N/A
lower-neg.f6493.8
Applied rewrites93.8%
if 2.0000000000000001e206 < (-.f64 z #s(literal 1 binary64)) Initial program 43.9%
Taylor expanded in z around inf
lower-*.f64N/A
sub-negN/A
lower-log1p.f64N/A
lower-neg.f6489.7
Applied rewrites89.7%
Taylor expanded in y around 0
Applied rewrites89.7%
Final simplification93.5%
(FPCore (x y z t) :precision binary64 (fma (- x 1.0) (log y) (- (* (- 1.0 z) y) t)))
double code(double x, double y, double z, double t) {
return fma((x - 1.0), log(y), (((1.0 - z) * y) - t));
}
function code(x, y, z, t) return fma(Float64(x - 1.0), log(y), Float64(Float64(Float64(1.0 - z) * y) - t)) end
code[x_, y_, z_, t_] := N[(N[(x - 1.0), $MachinePrecision] * N[Log[y], $MachinePrecision] + N[(N[(N[(1.0 - z), $MachinePrecision] * y), $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(x - 1, \log y, \left(1 - z\right) \cdot y - t\right)
\end{array}
Initial program 90.4%
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
lift-*.f64N/A
lower-fma.f64N/A
sub-negN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-log.f64N/A
lift--.f64N/A
sub-negN/A
lower-log1p.f64N/A
lower-neg.f64N/A
lower-neg.f6499.8
Applied rewrites99.8%
Taylor expanded in y around 0
lower--.f64N/A
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-inN/A
sub-negN/A
metadata-evalN/A
distribute-neg-inN/A
metadata-evalN/A
+-commutativeN/A
sub-negN/A
lower-*.f64N/A
lower--.f6499.8
Applied rewrites99.8%
(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 90.4%
Taylor expanded in y around 0
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
mul-1-negN/A
neg-sub0N/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
associate--r+N/A
metadata-evalN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-log.f6499.8
Applied rewrites99.8%
Final simplification99.8%
(FPCore (x y z t) :precision binary64 (if (<= t -115000.0) (- t) (if (<= t 62000.0) (* (- y) z) (- t))))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= -115000.0) {
tmp = -t;
} else if (t <= 62000.0) {
tmp = -y * z;
} else {
tmp = -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 (t <= (-115000.0d0)) then
tmp = -t
else if (t <= 62000.0d0) then
tmp = -y * z
else
tmp = -t
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (t <= -115000.0) {
tmp = -t;
} else if (t <= 62000.0) {
tmp = -y * z;
} else {
tmp = -t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if t <= -115000.0: tmp = -t elif t <= 62000.0: tmp = -y * z else: tmp = -t return tmp
function code(x, y, z, t) tmp = 0.0 if (t <= -115000.0) tmp = Float64(-t); elseif (t <= 62000.0) tmp = Float64(Float64(-y) * z); else tmp = Float64(-t); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (t <= -115000.0) tmp = -t; elseif (t <= 62000.0) tmp = -y * z; else tmp = -t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[t, -115000.0], (-t), If[LessEqual[t, 62000.0], N[((-y) * z), $MachinePrecision], (-t)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -115000:\\
\;\;\;\;-t\\
\mathbf{elif}\;t \leq 62000:\\
\;\;\;\;\left(-y\right) \cdot z\\
\mathbf{else}:\\
\;\;\;\;-t\\
\end{array}
\end{array}
if t < -115000 or 62000 < t Initial program 96.9%
Taylor expanded in t around inf
mul-1-negN/A
lower-neg.f6468.7
Applied rewrites68.7%
if -115000 < t < 62000Initial program 84.0%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
flip3--N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
clear-numN/A
flip3--N/A
lift--.f64N/A
lower-/.f6483.9
Applied rewrites83.9%
Taylor expanded in z around inf
lower-*.f64N/A
sub-negN/A
lower-log1p.f64N/A
lower-neg.f6417.2
Applied rewrites17.2%
Taylor expanded in y around 0
Applied rewrites17.1%
Final simplification42.7%
(FPCore (x y z t) :precision binary64 (- (fma (- y) z y) t))
double code(double x, double y, double z, double t) {
return fma(-y, z, y) - t;
}
function code(x, y, z, t) return Float64(fma(Float64(-y), z, y) - t) end
code[x_, y_, z_, t_] := N[(N[((-y) * z + y), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(-y, z, y\right) - t
\end{array}
Initial program 90.4%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
flip3--N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
clear-numN/A
flip3--N/A
lift--.f64N/A
lower-/.f6490.3
Applied rewrites90.3%
Taylor expanded in y around 0
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-inN/A
sub-negN/A
metadata-evalN/A
distribute-neg-inN/A
metadata-evalN/A
+-commutativeN/A
sub-negN/A
lower-fma.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-log.f6499.8
Applied rewrites99.8%
Taylor expanded in y around inf
Applied rewrites44.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 90.4%
Taylor expanded in z around inf
lower-*.f64N/A
sub-negN/A
lower-log1p.f64N/A
lower-neg.f6444.2
Applied rewrites44.2%
Taylor expanded in y around 0
Applied rewrites44.2%
Final simplification44.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 90.4%
Taylor expanded in t around inf
mul-1-negN/A
lower-neg.f6435.6
Applied rewrites35.6%
herbie shell --seed 2024249
(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))