
(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 (* (- z 1.0) y) (fma -0.5 y -1.0) (* (log y) (- x 1.0))) t))
double code(double x, double y, double z, double t) {
return fma(((z - 1.0) * y), fma(-0.5, y, -1.0), (log(y) * (x - 1.0))) - t;
}
function code(x, y, z, t) return Float64(fma(Float64(Float64(z - 1.0) * y), fma(-0.5, y, -1.0), Float64(log(y) * Float64(x - 1.0))) - t) end
code[x_, y_, z_, t_] := N[(N[(N[(N[(z - 1.0), $MachinePrecision] * y), $MachinePrecision] * N[(-0.5 * y + -1.0), $MachinePrecision] + N[(N[Log[y], $MachinePrecision] * N[(x - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\left(z - 1\right) \cdot y, \mathsf{fma}\left(-0.5, y, -1\right), \log y \cdot \left(x - 1\right)\right) - t
\end{array}
Initial program 89.7%
Taylor expanded in y around 0
associate-*r*N/A
distribute-rgt-outN/A
+-commutativeN/A
metadata-evalN/A
sub-negN/A
associate-*r*N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
sub-negN/A
metadata-evalN/A
lower-fma.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
(let* ((t_1 (- (+ (* (log (- 1.0 y)) (- z 1.0)) (* (log y) (- x 1.0))) t)))
(if (<= t_1 20.0)
(- (fma (- x 1.0) (log y) y) t)
(if (<= t_1 600.0)
(fma (- 1.0 z) y (- (log y)))
(fma (- x 1.0) (log y) (- t))))))
double code(double x, double y, double z, double t) {
double t_1 = ((log((1.0 - y)) * (z - 1.0)) + (log(y) * (x - 1.0))) - t;
double tmp;
if (t_1 <= 20.0) {
tmp = fma((x - 1.0), log(y), y) - t;
} else if (t_1 <= 600.0) {
tmp = fma((1.0 - z), y, -log(y));
} else {
tmp = fma((x - 1.0), log(y), -t);
}
return tmp;
}
function code(x, y, z, t) t_1 = 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_1 <= 20.0) tmp = Float64(fma(Float64(x - 1.0), log(y), y) - t); elseif (t_1 <= 600.0) tmp = fma(Float64(1.0 - z), y, Float64(-log(y))); else tmp = fma(Float64(x - 1.0), log(y), Float64(-t)); end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = 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$1, 20.0], N[(N[(N[(x - 1.0), $MachinePrecision] * N[Log[y], $MachinePrecision] + y), $MachinePrecision] - t), $MachinePrecision], If[LessEqual[t$95$1, 600.0], N[(N[(1.0 - z), $MachinePrecision] * y + (-N[Log[y], $MachinePrecision])), $MachinePrecision], N[(N[(x - 1.0), $MachinePrecision] * N[Log[y], $MachinePrecision] + (-t)), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(\log \left(1 - y\right) \cdot \left(z - 1\right) + \log y \cdot \left(x - 1\right)\right) - t\\
\mathbf{if}\;t\_1 \leq 20:\\
\;\;\;\;\mathsf{fma}\left(x - 1, \log y, y\right) - t\\
\mathbf{elif}\;t\_1 \leq 600:\\
\;\;\;\;\mathsf{fma}\left(1 - z, y, -\log y\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x - 1, \log y, -t\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) < 20Initial program 94.5%
Taylor expanded in y around 0
associate--l+N/A
*-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
sub-negN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-log.f64N/A
lower-neg.f6499.6
Applied rewrites99.6%
Taylor expanded in z around 0
Applied rewrites94.1%
if 20 < (-.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) < 600Initial program 64.9%
Taylor expanded in y around 0
associate--l+N/A
*-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
sub-negN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-log.f64N/A
lower-neg.f64100.0
Applied rewrites100.0%
Taylor expanded in t around 0
Applied rewrites98.6%
Taylor expanded in x around 0
Applied rewrites96.3%
if 600 < (-.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.2%
Taylor expanded in y around 0
sub-negN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-log.f64N/A
lower-neg.f6495.9
Applied rewrites95.9%
Final simplification95.2%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (fma (- x 1.0) (log y) (- t)))
(t_2 (- (+ (* (log (- 1.0 y)) (- z 1.0)) (* (log y) (- x 1.0))) t)))
(if (<= t_2 -5e+15)
t_1
(if (<= t_2 600.0) (fma (- 1.0 z) y (- (log y))) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = fma((x - 1.0), log(y), -t);
double t_2 = ((log((1.0 - y)) * (z - 1.0)) + (log(y) * (x - 1.0))) - t;
double tmp;
if (t_2 <= -5e+15) {
tmp = t_1;
} else if (t_2 <= 600.0) {
tmp = fma((1.0 - z), y, -log(y));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = fma(Float64(x - 1.0), log(y), Float64(-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 <= -5e+15) tmp = t_1; elseif (t_2 <= 600.0) tmp = fma(Float64(1.0 - z), y, Float64(-log(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] + (-t)), $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, -5e+15], t$95$1, If[LessEqual[t$95$2, 600.0], N[(N[(1.0 - z), $MachinePrecision] * y + (-N[Log[y], $MachinePrecision])), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(x - 1, \log 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 -5 \cdot 10^{+15}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 600:\\
\;\;\;\;\mathsf{fma}\left(1 - z, y, -\log y\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) < -5e15 or 600 < (-.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 95.3%
Taylor expanded in y around 0
sub-negN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-log.f64N/A
lower-neg.f6495.0
Applied rewrites95.0%
if -5e15 < (-.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) < 600Initial program 65.6%
Taylor expanded in y around 0
associate--l+N/A
*-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
sub-negN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-log.f64N/A
lower-neg.f6499.6
Applied rewrites99.6%
Taylor expanded in t around 0
Applied rewrites98.3%
Taylor expanded in x around 0
Applied rewrites96.1%
Final simplification95.2%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (- (* (log y) x) t))
(t_2 (- (+ (* (log (- 1.0 y)) (- z 1.0)) (* (log y) (- x 1.0))) t)))
(if (<= t_2 -5e+15)
t_1
(if (<= t_2 1000.0) (fma (- 1.0 z) y (- (log y))) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = (log(y) * x) - t;
double t_2 = ((log((1.0 - y)) * (z - 1.0)) + (log(y) * (x - 1.0))) - t;
double tmp;
if (t_2 <= -5e+15) {
tmp = t_1;
} else if (t_2 <= 1000.0) {
tmp = fma((1.0 - z), y, -log(y));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(Float64(log(y) * x) - 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 <= -5e+15) tmp = t_1; elseif (t_2 <= 1000.0) tmp = fma(Float64(1.0 - z), y, Float64(-log(y))); 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]}, 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, -5e+15], t$95$1, If[LessEqual[t$95$2, 1000.0], N[(N[(1.0 - z), $MachinePrecision] * y + (-N[Log[y], $MachinePrecision])), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \log y \cdot x - t\\
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 -5 \cdot 10^{+15}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 1000:\\
\;\;\;\;\mathsf{fma}\left(1 - z, y, -\log y\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) < -5e15 or 1e3 < (-.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 95.1%
Taylor expanded in x around inf
lower-*.f64N/A
lower-log.f6494.2
Applied rewrites94.2%
if -5e15 < (-.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) < 1e3Initial program 69.5%
Taylor expanded in y around 0
associate--l+N/A
*-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
sub-negN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-log.f64N/A
lower-neg.f6499.7
Applied rewrites99.7%
Taylor expanded in t around 0
Applied rewrites98.4%
Taylor expanded in x around 0
Applied rewrites96.4%
Final simplification94.7%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (fma (- x 1.0) (log y) (- t))))
(if (<= (- x 1.0) -200000.0)
t_1
(if (<= (- x 1.0) -0.9999998) (fma (- 1.0 z) y (- (+ t (log y)))) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = fma((x - 1.0), log(y), -t);
double tmp;
if ((x - 1.0) <= -200000.0) {
tmp = t_1;
} else if ((x - 1.0) <= -0.9999998) {
tmp = fma((1.0 - z), y, -(t + log(y)));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = fma(Float64(x - 1.0), log(y), Float64(-t)) tmp = 0.0 if (Float64(x - 1.0) <= -200000.0) tmp = t_1; elseif (Float64(x - 1.0) <= -0.9999998) tmp = fma(Float64(1.0 - z), y, Float64(-Float64(t + log(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] + (-t)), $MachinePrecision]}, If[LessEqual[N[(x - 1.0), $MachinePrecision], -200000.0], t$95$1, If[LessEqual[N[(x - 1.0), $MachinePrecision], -0.9999998], N[(N[(1.0 - z), $MachinePrecision] * y + (-N[(t + N[Log[y], $MachinePrecision]), $MachinePrecision])), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(x - 1, \log y, -t\right)\\
\mathbf{if}\;x - 1 \leq -200000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x - 1 \leq -0.9999998:\\
\;\;\;\;\mathsf{fma}\left(1 - z, y, -\left(t + \log y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (-.f64 x #s(literal 1 binary64)) < -2e5 or -0.999999799999999994 < (-.f64 x #s(literal 1 binary64)) Initial program 94.9%
Taylor expanded in y around 0
sub-negN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-log.f64N/A
lower-neg.f6494.9
Applied rewrites94.9%
if -2e5 < (-.f64 x #s(literal 1 binary64)) < -0.999999799999999994Initial program 84.2%
Taylor expanded in y around 0
associate--l+N/A
*-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
sub-negN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-log.f64N/A
lower-neg.f6499.7
Applied rewrites99.7%
Taylor expanded in x around 0
Applied rewrites99.7%
(FPCore (x y z t)
:precision binary64
(if (<= t -7.5e-10)
(- (fma (- x 1.0) (log y) y) t)
(if (<= t 1.35e-8)
(fma (- 1.0 z) y (* (log y) (- x 1.0)))
(fma (- x 1.0) (log y) (- t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= -7.5e-10) {
tmp = fma((x - 1.0), log(y), y) - t;
} else if (t <= 1.35e-8) {
tmp = fma((1.0 - z), y, (log(y) * (x - 1.0)));
} else {
tmp = fma((x - 1.0), log(y), -t);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (t <= -7.5e-10) tmp = Float64(fma(Float64(x - 1.0), log(y), y) - t); elseif (t <= 1.35e-8) tmp = fma(Float64(1.0 - z), y, Float64(log(y) * Float64(x - 1.0))); else tmp = fma(Float64(x - 1.0), log(y), Float64(-t)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[t, -7.5e-10], N[(N[(N[(x - 1.0), $MachinePrecision] * N[Log[y], $MachinePrecision] + y), $MachinePrecision] - t), $MachinePrecision], If[LessEqual[t, 1.35e-8], N[(N[(1.0 - z), $MachinePrecision] * y + N[(N[Log[y], $MachinePrecision] * N[(x - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x - 1.0), $MachinePrecision] * N[Log[y], $MachinePrecision] + (-t)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -7.5 \cdot 10^{-10}:\\
\;\;\;\;\mathsf{fma}\left(x - 1, \log y, y\right) - t\\
\mathbf{elif}\;t \leq 1.35 \cdot 10^{-8}:\\
\;\;\;\;\mathsf{fma}\left(1 - z, y, \log y \cdot \left(x - 1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x - 1, \log y, -t\right)\\
\end{array}
\end{array}
if t < -7.49999999999999995e-10Initial program 98.2%
Taylor expanded in y around 0
associate--l+N/A
*-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
sub-negN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-log.f64N/A
lower-neg.f6499.9
Applied rewrites99.9%
Taylor expanded in z around 0
Applied rewrites98.2%
if -7.49999999999999995e-10 < t < 1.35000000000000001e-8Initial program 80.5%
Taylor expanded in y around 0
associate--l+N/A
*-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
sub-negN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-log.f64N/A
lower-neg.f6499.6
Applied rewrites99.6%
Taylor expanded in t around 0
Applied rewrites99.6%
if 1.35000000000000001e-8 < t Initial program 97.5%
Taylor expanded in y around 0
sub-negN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-log.f64N/A
lower-neg.f6497.2
Applied rewrites97.2%
Final simplification98.6%
(FPCore (x y z t)
:precision binary64
(if (<= t -7.5e-10)
(- (fma (- x 1.0) (log y) y) t)
(if (<= t 1.35e-8)
(fma (- z) y (* (log y) (- x 1.0)))
(fma (- x 1.0) (log y) (- t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= -7.5e-10) {
tmp = fma((x - 1.0), log(y), y) - t;
} else if (t <= 1.35e-8) {
tmp = fma(-z, y, (log(y) * (x - 1.0)));
} else {
tmp = fma((x - 1.0), log(y), -t);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (t <= -7.5e-10) tmp = Float64(fma(Float64(x - 1.0), log(y), y) - t); elseif (t <= 1.35e-8) tmp = fma(Float64(-z), y, Float64(log(y) * Float64(x - 1.0))); else tmp = fma(Float64(x - 1.0), log(y), Float64(-t)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[t, -7.5e-10], N[(N[(N[(x - 1.0), $MachinePrecision] * N[Log[y], $MachinePrecision] + y), $MachinePrecision] - t), $MachinePrecision], If[LessEqual[t, 1.35e-8], N[((-z) * y + N[(N[Log[y], $MachinePrecision] * N[(x - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x - 1.0), $MachinePrecision] * N[Log[y], $MachinePrecision] + (-t)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -7.5 \cdot 10^{-10}:\\
\;\;\;\;\mathsf{fma}\left(x - 1, \log y, y\right) - t\\
\mathbf{elif}\;t \leq 1.35 \cdot 10^{-8}:\\
\;\;\;\;\mathsf{fma}\left(-z, y, \log y \cdot \left(x - 1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x - 1, \log y, -t\right)\\
\end{array}
\end{array}
if t < -7.49999999999999995e-10Initial program 98.2%
Taylor expanded in y around 0
associate--l+N/A
*-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
sub-negN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-log.f64N/A
lower-neg.f6499.9
Applied rewrites99.9%
Taylor expanded in z around 0
Applied rewrites98.2%
if -7.49999999999999995e-10 < t < 1.35000000000000001e-8Initial program 80.5%
Taylor expanded in y around 0
associate--l+N/A
*-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
sub-negN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-log.f64N/A
lower-neg.f6499.6
Applied rewrites99.6%
Taylor expanded in t around 0
Applied rewrites99.6%
Taylor expanded in z around inf
Applied rewrites99.3%
if 1.35000000000000001e-8 < t Initial program 97.5%
Taylor expanded in y around 0
sub-negN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-log.f64N/A
lower-neg.f6497.2
Applied rewrites97.2%
Final simplification98.4%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (- (* (log y) x) t))) (if (<= x -5500.0) t_1 (if (<= x 15000.0) (fma (- 1.0 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 <= -5500.0) {
tmp = t_1;
} else if (x <= 15000.0) {
tmp = fma((1.0 - 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 <= -5500.0) tmp = t_1; elseif (x <= 15000.0) tmp = fma(Float64(1.0 - z), y, Float64(-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, -5500.0], t$95$1, If[LessEqual[x, 15000.0], N[(N[(1.0 - z), $MachinePrecision] * y + (-t)), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \log y \cdot x - t\\
\mathbf{if}\;x \leq -5500:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 15000:\\
\;\;\;\;\mathsf{fma}\left(1 - z, y, -t\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -5500 or 15000 < x Initial program 94.9%
Taylor expanded in x around inf
lower-*.f64N/A
lower-log.f6494.3
Applied rewrites94.3%
if -5500 < x < 15000Initial program 84.4%
Taylor expanded in y around 0
associate--l+N/A
*-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
sub-negN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-log.f64N/A
lower-neg.f6499.7
Applied rewrites99.7%
Taylor expanded in t around inf
Applied rewrites70.2%
Final simplification82.3%
(FPCore (x y z t) :precision binary64 (fma (- 1.0 z) y (fma (- x 1.0) (log y) (- t))))
double code(double x, double y, double z, double t) {
return fma((1.0 - z), y, fma((x - 1.0), log(y), -t));
}
function code(x, y, z, t) return fma(Float64(1.0 - z), y, fma(Float64(x - 1.0), log(y), Float64(-t))) end
code[x_, y_, z_, t_] := N[(N[(1.0 - z), $MachinePrecision] * y + N[(N[(x - 1.0), $MachinePrecision] * N[Log[y], $MachinePrecision] + (-t)), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(1 - z, y, \mathsf{fma}\left(x - 1, \log y, -t\right)\right)
\end{array}
Initial program 89.7%
Taylor expanded in y around 0
associate--l+N/A
*-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
sub-negN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-log.f64N/A
lower-neg.f6499.7
Applied rewrites99.7%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* (log y) x))) (if (<= x -290000.0) t_1 (if (<= x 1.06e+69) (fma (- 1.0 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 <= -290000.0) {
tmp = t_1;
} else if (x <= 1.06e+69) {
tmp = fma((1.0 - 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 (x <= -290000.0) tmp = t_1; elseif (x <= 1.06e+69) tmp = fma(Float64(1.0 - z), y, Float64(-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[x, -290000.0], t$95$1, If[LessEqual[x, 1.06e+69], N[(N[(1.0 - z), $MachinePrecision] * y + (-t)), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \log y \cdot x\\
\mathbf{if}\;x \leq -290000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 1.06 \cdot 10^{+69}:\\
\;\;\;\;\mathsf{fma}\left(1 - z, y, -t\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -2.9e5 or 1.06000000000000004e69 < x Initial program 96.0%
Taylor expanded in x around inf
lower-*.f64N/A
lower-log.f6480.4
Applied rewrites80.4%
if -2.9e5 < x < 1.06000000000000004e69Initial program 84.8%
Taylor expanded in y around 0
associate--l+N/A
*-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
sub-negN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-log.f64N/A
lower-neg.f6499.8
Applied rewrites99.8%
Taylor expanded in t around inf
Applied rewrites68.8%
Final simplification73.9%
(FPCore (x y z t) :precision binary64 (if (<= t -9e-10) (- t) (if (<= t 1.15e+31) (* (- 1.0 z) y) (- t))))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= -9e-10) {
tmp = -t;
} else if (t <= 1.15e+31) {
tmp = (1.0 - z) * y;
} 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 <= (-9d-10)) then
tmp = -t
else if (t <= 1.15d+31) then
tmp = (1.0d0 - z) * y
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 <= -9e-10) {
tmp = -t;
} else if (t <= 1.15e+31) {
tmp = (1.0 - z) * y;
} else {
tmp = -t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if t <= -9e-10: tmp = -t elif t <= 1.15e+31: tmp = (1.0 - z) * y else: tmp = -t return tmp
function code(x, y, z, t) tmp = 0.0 if (t <= -9e-10) tmp = Float64(-t); elseif (t <= 1.15e+31) tmp = Float64(Float64(1.0 - z) * y); else tmp = Float64(-t); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (t <= -9e-10) tmp = -t; elseif (t <= 1.15e+31) tmp = (1.0 - z) * y; else tmp = -t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[t, -9e-10], (-t), If[LessEqual[t, 1.15e+31], N[(N[(1.0 - z), $MachinePrecision] * y), $MachinePrecision], (-t)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -9 \cdot 10^{-10}:\\
\;\;\;\;-t\\
\mathbf{elif}\;t \leq 1.15 \cdot 10^{+31}:\\
\;\;\;\;\left(1 - z\right) \cdot y\\
\mathbf{else}:\\
\;\;\;\;-t\\
\end{array}
\end{array}
if t < -8.9999999999999999e-10 or 1.15e31 < t Initial program 97.7%
Taylor expanded in t around inf
mul-1-negN/A
lower-neg.f6470.6
Applied rewrites70.6%
if -8.9999999999999999e-10 < t < 1.15e31Initial program 81.4%
Taylor expanded in y around 0
associate--l+N/A
*-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
sub-negN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-log.f64N/A
lower-neg.f6499.6
Applied rewrites99.6%
Taylor expanded in y around inf
Applied rewrites20.4%
(FPCore (x y z t) :precision binary64 (if (<= t -9e-10) (- t) (if (<= t 1.15e+31) (* (- y) z) (- t))))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= -9e-10) {
tmp = -t;
} else if (t <= 1.15e+31) {
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 <= (-9d-10)) then
tmp = -t
else if (t <= 1.15d+31) 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 <= -9e-10) {
tmp = -t;
} else if (t <= 1.15e+31) {
tmp = -y * z;
} else {
tmp = -t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if t <= -9e-10: tmp = -t elif t <= 1.15e+31: tmp = -y * z else: tmp = -t return tmp
function code(x, y, z, t) tmp = 0.0 if (t <= -9e-10) tmp = Float64(-t); elseif (t <= 1.15e+31) 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 <= -9e-10) tmp = -t; elseif (t <= 1.15e+31) tmp = -y * z; else tmp = -t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[t, -9e-10], (-t), If[LessEqual[t, 1.15e+31], N[((-y) * z), $MachinePrecision], (-t)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -9 \cdot 10^{-10}:\\
\;\;\;\;-t\\
\mathbf{elif}\;t \leq 1.15 \cdot 10^{+31}:\\
\;\;\;\;\left(-y\right) \cdot z\\
\mathbf{else}:\\
\;\;\;\;-t\\
\end{array}
\end{array}
if t < -8.9999999999999999e-10 or 1.15e31 < t Initial program 97.7%
Taylor expanded in t around inf
mul-1-negN/A
lower-neg.f6470.6
Applied rewrites70.6%
if -8.9999999999999999e-10 < t < 1.15e31Initial program 81.4%
Taylor expanded in y around 0
associate--l+N/A
*-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
sub-negN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-log.f64N/A
lower-neg.f6499.6
Applied rewrites99.6%
Taylor expanded in z around inf
Applied rewrites19.9%
(FPCore (x y z t) :precision binary64 (fma (- 1.0 z) y (- t)))
double code(double x, double y, double z, double t) {
return fma((1.0 - z), y, -t);
}
function code(x, y, z, t) return fma(Float64(1.0 - z), y, Float64(-t)) end
code[x_, y_, z_, t_] := N[(N[(1.0 - z), $MachinePrecision] * y + (-t)), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(1 - z, y, -t\right)
\end{array}
Initial program 89.7%
Taylor expanded in y around 0
associate--l+N/A
*-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
sub-negN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-log.f64N/A
lower-neg.f6499.7
Applied rewrites99.7%
Taylor expanded in t around inf
Applied rewrites46.9%
(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 89.7%
Taylor expanded in z around inf
lower-*.f64N/A
sub-negN/A
lower-log1p.f64N/A
lower-neg.f6446.8
Applied rewrites46.8%
Taylor expanded in y around 0
Applied rewrites46.8%
Final simplification46.8%
(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 89.7%
Taylor expanded in t around inf
mul-1-negN/A
lower-neg.f6437.1
Applied rewrites37.1%
herbie shell --seed 2024243
(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))