
(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 (log1p (- y)) (- z 1.0) (* (log y) x)) (log y)) t))
double code(double x, double y, double z, double t) {
return (fma(log1p(-y), (z - 1.0), (log(y) * x)) - log(y)) - t;
}
function code(x, y, z, t) return Float64(Float64(fma(log1p(Float64(-y)), Float64(z - 1.0), Float64(log(y) * x)) - log(y)) - t) end
code[x_, y_, z_, t_] := N[(N[(N[(N[Log[1 + (-y)], $MachinePrecision] * N[(z - 1.0), $MachinePrecision] + N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] - N[Log[y], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\left(\mathsf{fma}\left(\mathsf{log1p}\left(-y\right), z - 1, \log y \cdot x\right) - \log y\right) - t
\end{array}
Initial program 90.1%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
sub-negN/A
distribute-rgt-inN/A
associate-+r+N/A
lower-+.f64N/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-*.f64N/A
metadata-evalN/A
mul-1-negN/A
lower-neg.f6499.8
Applied rewrites99.8%
Final simplification99.8%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (- (* (log y) x) t))
(t_2 (+ (* (log (- 1.0 y)) (- z 1.0)) (* (- x 1.0) (log y)))))
(if (<= t_2 -40000.0)
t_1
(if (<= t_2 310.0)
(- (* (- 1.0 z) y) t)
(if (<= t_2 1000.0) (- (+ t (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)) + ((x - 1.0) * log(y));
double tmp;
if (t_2 <= -40000.0) {
tmp = t_1;
} else if (t_2 <= 310.0) {
tmp = ((1.0 - z) * y) - t;
} else if (t_2 <= 1000.0) {
tmp = -(t + log(y));
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = (log(y) * x) - t
t_2 = (log((1.0d0 - y)) * (z - 1.0d0)) + ((x - 1.0d0) * log(y))
if (t_2 <= (-40000.0d0)) then
tmp = t_1
else if (t_2 <= 310.0d0) then
tmp = ((1.0d0 - z) * y) - t
else if (t_2 <= 1000.0d0) then
tmp = -(t + log(y))
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = (Math.log(y) * x) - t;
double t_2 = (Math.log((1.0 - y)) * (z - 1.0)) + ((x - 1.0) * Math.log(y));
double tmp;
if (t_2 <= -40000.0) {
tmp = t_1;
} else if (t_2 <= 310.0) {
tmp = ((1.0 - z) * y) - t;
} else if (t_2 <= 1000.0) {
tmp = -(t + Math.log(y));
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = (math.log(y) * x) - t t_2 = (math.log((1.0 - y)) * (z - 1.0)) + ((x - 1.0) * math.log(y)) tmp = 0 if t_2 <= -40000.0: tmp = t_1 elif t_2 <= 310.0: tmp = ((1.0 - z) * y) - t elif t_2 <= 1000.0: tmp = -(t + math.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(log(Float64(1.0 - y)) * Float64(z - 1.0)) + Float64(Float64(x - 1.0) * log(y))) tmp = 0.0 if (t_2 <= -40000.0) tmp = t_1; elseif (t_2 <= 310.0) tmp = Float64(Float64(Float64(1.0 - z) * y) - t); elseif (t_2 <= 1000.0) tmp = Float64(-Float64(t + log(y))); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = (log(y) * x) - t; t_2 = (log((1.0 - y)) * (z - 1.0)) + ((x - 1.0) * log(y)); tmp = 0.0; if (t_2 <= -40000.0) tmp = t_1; elseif (t_2 <= 310.0) tmp = ((1.0 - z) * y) - t; elseif (t_2 <= 1000.0) tmp = -(t + log(y)); else tmp = t_1; end tmp_2 = 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[Log[N[(1.0 - y), $MachinePrecision]], $MachinePrecision] * N[(z - 1.0), $MachinePrecision]), $MachinePrecision] + N[(N[(x - 1.0), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -40000.0], t$95$1, If[LessEqual[t$95$2, 310.0], N[(N[(N[(1.0 - z), $MachinePrecision] * y), $MachinePrecision] - t), $MachinePrecision], If[LessEqual[t$95$2, 1000.0], (-N[(t + N[Log[y], $MachinePrecision]), $MachinePrecision]), t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \log y \cdot x - t\\
t_2 := \log \left(1 - y\right) \cdot \left(z - 1\right) + \left(x - 1\right) \cdot \log y\\
\mathbf{if}\;t\_2 \leq -40000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 310:\\
\;\;\;\;\left(1 - z\right) \cdot y - t\\
\mathbf{elif}\;t\_2 \leq 1000:\\
\;\;\;\;-\left(t + \log y\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (+.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)))) < -4e4 or 1e3 < (+.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)))) Initial program 95.7%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower-log.f6491.3
Applied rewrites91.3%
if -4e4 < (+.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)))) < 310Initial program 71.1%
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.f6498.3
Applied rewrites98.3%
Taylor expanded in y around inf
Applied rewrites76.1%
if 310 < (+.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)))) < 1e3Initial program 94.5%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
sub-negN/A
distribute-rgt-inN/A
associate-+r+N/A
lower-+.f64N/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-*.f64N/A
metadata-evalN/A
mul-1-negN/A
lower-neg.f6499.9
Applied rewrites99.9%
Taylor expanded in y around 0
+-commutativeN/A
associate--r+N/A
sub-negN/A
mul-1-negN/A
distribute-rgt-inN/A
metadata-evalN/A
sub-negN/A
sub-negN/A
sub-negN/A
metadata-evalN/A
distribute-rgt-inN/A
+-commutativeN/A
distribute-rgt-outN/A
lower-fma.f64N/A
lower-log.f64N/A
lower-+.f64N/A
lower-neg.f6494.5
Applied rewrites94.5%
Taylor expanded in x around 0
Applied rewrites93.4%
Final simplification88.6%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* (log y) x))
(t_2 (+ (* (log (- 1.0 y)) (- z 1.0)) (* (- x 1.0) (log y)))))
(if (<= t_2 -4e+73)
t_1
(if (<= t_2 310.0)
(- (* (- 1.0 z) y) t)
(if (<= t_2 200000.0) (- (+ t (log y))) t_1)))))
double code(double x, double y, double z, double t) {
double t_1 = log(y) * x;
double t_2 = (log((1.0 - y)) * (z - 1.0)) + ((x - 1.0) * log(y));
double tmp;
if (t_2 <= -4e+73) {
tmp = t_1;
} else if (t_2 <= 310.0) {
tmp = ((1.0 - z) * y) - t;
} else if (t_2 <= 200000.0) {
tmp = -(t + log(y));
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = log(y) * x
t_2 = (log((1.0d0 - y)) * (z - 1.0d0)) + ((x - 1.0d0) * log(y))
if (t_2 <= (-4d+73)) then
tmp = t_1
else if (t_2 <= 310.0d0) then
tmp = ((1.0d0 - z) * y) - t
else if (t_2 <= 200000.0d0) then
tmp = -(t + log(y))
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = Math.log(y) * x;
double t_2 = (Math.log((1.0 - y)) * (z - 1.0)) + ((x - 1.0) * Math.log(y));
double tmp;
if (t_2 <= -4e+73) {
tmp = t_1;
} else if (t_2 <= 310.0) {
tmp = ((1.0 - z) * y) - t;
} else if (t_2 <= 200000.0) {
tmp = -(t + Math.log(y));
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = math.log(y) * x t_2 = (math.log((1.0 - y)) * (z - 1.0)) + ((x - 1.0) * math.log(y)) tmp = 0 if t_2 <= -4e+73: tmp = t_1 elif t_2 <= 310.0: tmp = ((1.0 - z) * y) - t elif t_2 <= 200000.0: tmp = -(t + math.log(y)) else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(log(y) * x) t_2 = Float64(Float64(log(Float64(1.0 - y)) * Float64(z - 1.0)) + Float64(Float64(x - 1.0) * log(y))) tmp = 0.0 if (t_2 <= -4e+73) tmp = t_1; elseif (t_2 <= 310.0) tmp = Float64(Float64(Float64(1.0 - z) * y) - t); elseif (t_2 <= 200000.0) tmp = Float64(-Float64(t + log(y))); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = log(y) * x; t_2 = (log((1.0 - y)) * (z - 1.0)) + ((x - 1.0) * log(y)); tmp = 0.0; if (t_2 <= -4e+73) tmp = t_1; elseif (t_2 <= 310.0) tmp = ((1.0 - z) * y) - t; elseif (t_2 <= 200000.0) tmp = -(t + log(y)); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[Log[N[(1.0 - y), $MachinePrecision]], $MachinePrecision] * N[(z - 1.0), $MachinePrecision]), $MachinePrecision] + N[(N[(x - 1.0), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -4e+73], t$95$1, If[LessEqual[t$95$2, 310.0], N[(N[(N[(1.0 - z), $MachinePrecision] * y), $MachinePrecision] - t), $MachinePrecision], If[LessEqual[t$95$2, 200000.0], (-N[(t + N[Log[y], $MachinePrecision]), $MachinePrecision]), t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \log y \cdot x\\
t_2 := \log \left(1 - y\right) \cdot \left(z - 1\right) + \left(x - 1\right) \cdot \log y\\
\mathbf{if}\;t\_2 \leq -4 \cdot 10^{+73}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 310:\\
\;\;\;\;\left(1 - z\right) \cdot y - t\\
\mathbf{elif}\;t\_2 \leq 200000:\\
\;\;\;\;-\left(t + \log y\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (+.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)))) < -3.99999999999999993e73 or 2e5 < (+.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)))) Initial program 96.0%
lift--.f64N/A
flip--N/A
div-invN/A
difference-of-squaresN/A
lift--.f64N/A
associate-*l*N/A
Applied rewrites99.4%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower-log.f6473.8
Applied rewrites73.8%
if -3.99999999999999993e73 < (+.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)))) < 310Initial program 74.9%
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.f6498.6
Applied rewrites98.6%
Taylor expanded in y around inf
Applied rewrites75.6%
if 310 < (+.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)))) < 2e5Initial program 94.7%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
sub-negN/A
distribute-rgt-inN/A
associate-+r+N/A
lower-+.f64N/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-*.f64N/A
metadata-evalN/A
mul-1-negN/A
lower-neg.f6499.9
Applied rewrites99.9%
Taylor expanded in y around 0
+-commutativeN/A
associate--r+N/A
sub-negN/A
mul-1-negN/A
distribute-rgt-inN/A
metadata-evalN/A
sub-negN/A
sub-negN/A
sub-negN/A
metadata-evalN/A
distribute-rgt-inN/A
+-commutativeN/A
distribute-rgt-outN/A
lower-fma.f64N/A
lower-log.f64N/A
lower-+.f64N/A
lower-neg.f6494.7
Applied rewrites94.7%
Taylor expanded in x around 0
Applied rewrites92.8%
Final simplification79.5%
(FPCore (x y z t) :precision binary64 (- (+ (/ (log1p (- y)) (/ 1.0 (- z 1.0))) (* (- x 1.0) (log y))) t))
double code(double x, double y, double z, double t) {
return ((log1p(-y) / (1.0 / (z - 1.0))) + ((x - 1.0) * log(y))) - t;
}
public static double code(double x, double y, double z, double t) {
return ((Math.log1p(-y) / (1.0 / (z - 1.0))) + ((x - 1.0) * Math.log(y))) - t;
}
def code(x, y, z, t): return ((math.log1p(-y) / (1.0 / (z - 1.0))) + ((x - 1.0) * math.log(y))) - t
function code(x, y, z, t) return Float64(Float64(Float64(log1p(Float64(-y)) / Float64(1.0 / Float64(z - 1.0))) + Float64(Float64(x - 1.0) * log(y))) - t) end
code[x_, y_, z_, t_] := N[(N[(N[(N[Log[1 + (-y)], $MachinePrecision] / N[(1.0 / N[(z - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(x - 1.0), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\left(\frac{\mathsf{log1p}\left(-y\right)}{\frac{1}{z - 1}} + \left(x - 1\right) \cdot \log y\right) - t
\end{array}
Initial program 90.1%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
flip--N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
lift-log.f64N/A
lift--.f64N/A
sub-negN/A
lower-log1p.f64N/A
lower-neg.f64N/A
clear-numN/A
flip--N/A
lift--.f64N/A
lower-/.f6499.7
Applied rewrites99.7%
Final simplification99.7%
(FPCore (x y z t)
:precision binary64
(-
(+
(*
(* (fma (fma (fma -0.25 y -0.3333333333333333) y -0.5) y -1.0) y)
(- z 1.0))
(* (- x 1.0) (log y)))
t))
double code(double x, double y, double z, double t) {
return (((fma(fma(fma(-0.25, y, -0.3333333333333333), y, -0.5), y, -1.0) * y) * (z - 1.0)) + ((x - 1.0) * log(y))) - t;
}
function code(x, y, z, t) return Float64(Float64(Float64(Float64(fma(fma(fma(-0.25, y, -0.3333333333333333), y, -0.5), y, -1.0) * y) * Float64(z - 1.0)) + Float64(Float64(x - 1.0) * log(y))) - t) end
code[x_, y_, z_, t_] := N[(N[(N[(N[(N[(N[(N[(-0.25 * y + -0.3333333333333333), $MachinePrecision] * y + -0.5), $MachinePrecision] * y + -1.0), $MachinePrecision] * y), $MachinePrecision] * N[(z - 1.0), $MachinePrecision]), $MachinePrecision] + N[(N[(x - 1.0), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.25, y, -0.3333333333333333\right), y, -0.5\right), y, -1\right) \cdot y\right) \cdot \left(z - 1\right) + \left(x - 1\right) \cdot \log y\right) - t
\end{array}
Initial program 90.1%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
sub-negN/A
*-commutativeN/A
metadata-evalN/A
lower-fma.f64N/A
sub-negN/A
*-commutativeN/A
metadata-evalN/A
lower-fma.f64N/A
sub-negN/A
metadata-evalN/A
lower-fma.f6499.4
Applied rewrites99.4%
Final simplification99.4%
(FPCore (x y z t) :precision binary64 (- (+ (* (* (fma (fma -0.3333333333333333 y -0.5) y -1.0) y) (- z 1.0)) (* (- x 1.0) (log y))) t))
double code(double x, double y, double z, double t) {
return (((fma(fma(-0.3333333333333333, y, -0.5), y, -1.0) * y) * (z - 1.0)) + ((x - 1.0) * log(y))) - t;
}
function code(x, y, z, t) return Float64(Float64(Float64(Float64(fma(fma(-0.3333333333333333, y, -0.5), y, -1.0) * y) * Float64(z - 1.0)) + Float64(Float64(x - 1.0) * log(y))) - t) end
code[x_, y_, z_, t_] := N[(N[(N[(N[(N[(N[(-0.3333333333333333 * y + -0.5), $MachinePrecision] * y + -1.0), $MachinePrecision] * y), $MachinePrecision] * N[(z - 1.0), $MachinePrecision]), $MachinePrecision] + N[(N[(x - 1.0), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.3333333333333333, y, -0.5\right), y, -1\right) \cdot y\right) \cdot \left(z - 1\right) + \left(x - 1\right) \cdot \log y\right) - t
\end{array}
Initial program 90.1%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
sub-negN/A
*-commutativeN/A
metadata-evalN/A
lower-fma.f64N/A
sub-negN/A
metadata-evalN/A
lower-fma.f6499.4
Applied rewrites99.4%
Final simplification99.4%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (fma (- x 1.0) (log y) (- t))))
(if (<= (- x 1.0) -1.02)
t_1
(if (<= (- x 1.0) -0.999999) (- (fma (- 1.0 z) y (- (log y))) t) 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) <= -1.02) {
tmp = t_1;
} else if ((x - 1.0) <= -0.999999) {
tmp = fma((1.0 - z), y, -log(y)) - t;
} 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) <= -1.02) tmp = t_1; elseif (Float64(x - 1.0) <= -0.999999) tmp = Float64(fma(Float64(1.0 - z), y, Float64(-log(y))) - t); 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], -1.02], t$95$1, If[LessEqual[N[(x - 1.0), $MachinePrecision], -0.999999], N[(N[(N[(1.0 - z), $MachinePrecision] * y + (-N[Log[y], $MachinePrecision])), $MachinePrecision] - t), $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 -1.02:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x - 1 \leq -0.999999:\\
\;\;\;\;\mathsf{fma}\left(1 - z, y, -\log y\right) - t\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (-.f64 x #s(literal 1 binary64)) < -1.02 or -0.999998999999999971 < (-.f64 x #s(literal 1 binary64)) Initial program 97.4%
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%
if -1.02 < (-.f64 x #s(literal 1 binary64)) < -0.999998999999999971Initial program 82.7%
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.f6497.5
Applied rewrites97.5%
Taylor expanded in x around 0
Applied rewrites97.5%
(FPCore (x y z t) :precision binary64 (- (fma (* (- z 1.0) y) (fma -0.5 y -1.0) (* (- x 1.0) (log y))) t))
double code(double x, double y, double z, double t) {
return fma(((z - 1.0) * y), fma(-0.5, y, -1.0), ((x - 1.0) * log(y))) - t;
}
function code(x, y, z, t) return Float64(fma(Float64(Float64(z - 1.0) * y), fma(-0.5, y, -1.0), Float64(Float64(x - 1.0) * log(y))) - 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[(x - 1.0), $MachinePrecision] * N[Log[y], $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), \left(x - 1\right) \cdot \log y\right) - t
\end{array}
Initial program 90.1%
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.2
Applied rewrites99.2%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* (log y) x)))
(if (<= (- x 1.0) -100000000.0)
t_1
(if (<= (- x 1.0) 5e+63) (- (* (* (fma -0.5 y -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 - 1.0) <= -100000000.0) {
tmp = t_1;
} else if ((x - 1.0) <= 5e+63) {
tmp = ((fma(-0.5, y, -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 (Float64(x - 1.0) <= -100000000.0) tmp = t_1; elseif (Float64(x - 1.0) <= 5e+63) tmp = Float64(Float64(Float64(fma(-0.5, y, -1.0) * 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], -100000000.0], t$95$1, If[LessEqual[N[(x - 1.0), $MachinePrecision], 5e+63], N[(N[(N[(N[(-0.5 * y + -1.0), $MachinePrecision] * z), $MachinePrecision] * y), $MachinePrecision] - t), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \log y \cdot x\\
\mathbf{if}\;x - 1 \leq -100000000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x - 1 \leq 5 \cdot 10^{+63}:\\
\;\;\;\;\left(\mathsf{fma}\left(-0.5, y, -1\right) \cdot z\right) \cdot y - t\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (-.f64 x #s(literal 1 binary64)) < -1e8 or 5.00000000000000011e63 < (-.f64 x #s(literal 1 binary64)) Initial program 97.8%
lift--.f64N/A
flip--N/A
div-invN/A
difference-of-squaresN/A
lift--.f64N/A
associate-*l*N/A
Applied rewrites99.3%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower-log.f6478.4
Applied rewrites78.4%
if -1e8 < (-.f64 x #s(literal 1 binary64)) < 5.00000000000000011e63Initial program 84.2%
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.f6498.9
Applied rewrites98.9%
Taylor expanded in z around inf
Applied rewrites67.1%
(FPCore (x y z t) :precision binary64 (if (<= (- z 1.0) 5e+171) (- (fma (log y) (- x 1.0) y) t) (- (* (* z y) (fma -0.5 y -1.0)) t)))
double code(double x, double y, double z, double t) {
double tmp;
if ((z - 1.0) <= 5e+171) {
tmp = fma(log(y), (x - 1.0), y) - t;
} else {
tmp = ((z * y) * fma(-0.5, y, -1.0)) - t;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (Float64(z - 1.0) <= 5e+171) tmp = Float64(fma(log(y), Float64(x - 1.0), y) - t); else tmp = Float64(Float64(Float64(z * y) * fma(-0.5, y, -1.0)) - t); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[(z - 1.0), $MachinePrecision], 5e+171], N[(N[(N[Log[y], $MachinePrecision] * N[(x - 1.0), $MachinePrecision] + y), $MachinePrecision] - t), $MachinePrecision], N[(N[(N[(z * y), $MachinePrecision] * N[(-0.5 * y + -1.0), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z - 1 \leq 5 \cdot 10^{+171}:\\
\;\;\;\;\mathsf{fma}\left(\log y, x - 1, y\right) - t\\
\mathbf{else}:\\
\;\;\;\;\left(z \cdot y\right) \cdot \mathsf{fma}\left(-0.5, y, -1\right) - t\\
\end{array}
\end{array}
if (-.f64 z #s(literal 1 binary64)) < 5.0000000000000004e171Initial program 94.2%
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.f6498.5
Applied rewrites98.5%
Taylor expanded in z around 0
Applied rewrites92.5%
if 5.0000000000000004e171 < (-.f64 z #s(literal 1 binary64)) Initial program 44.3%
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.f64100.0
Applied rewrites100.0%
Taylor expanded in z around inf
Applied rewrites74.5%
Applied rewrites74.6%
Final simplification91.1%
(FPCore (x y z t) :precision binary64 (if (<= (- z 1.0) 5e+171) (fma (- x 1.0) (log y) (- t)) (- (* (* z y) (fma -0.5 y -1.0)) t)))
double code(double x, double y, double z, double t) {
double tmp;
if ((z - 1.0) <= 5e+171) {
tmp = fma((x - 1.0), log(y), -t);
} else {
tmp = ((z * y) * fma(-0.5, y, -1.0)) - t;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (Float64(z - 1.0) <= 5e+171) tmp = fma(Float64(x - 1.0), log(y), Float64(-t)); else tmp = Float64(Float64(Float64(z * y) * fma(-0.5, y, -1.0)) - t); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[(z - 1.0), $MachinePrecision], 5e+171], N[(N[(x - 1.0), $MachinePrecision] * N[Log[y], $MachinePrecision] + (-t)), $MachinePrecision], N[(N[(N[(z * y), $MachinePrecision] * N[(-0.5 * y + -1.0), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z - 1 \leq 5 \cdot 10^{+171}:\\
\;\;\;\;\mathsf{fma}\left(x - 1, \log y, -t\right)\\
\mathbf{else}:\\
\;\;\;\;\left(z \cdot y\right) \cdot \mathsf{fma}\left(-0.5, y, -1\right) - t\\
\end{array}
\end{array}
if (-.f64 z #s(literal 1 binary64)) < 5.0000000000000004e171Initial program 94.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.f6492.4
Applied rewrites92.4%
if 5.0000000000000004e171 < (-.f64 z #s(literal 1 binary64)) Initial program 44.3%
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.f64100.0
Applied rewrites100.0%
Taylor expanded in z around inf
Applied rewrites74.5%
Applied rewrites74.6%
Final simplification91.0%
(FPCore (x y z t) :precision binary64 (- (fma (- 1.0 z) y (* (- x 1.0) (log y))) t))
double code(double x, double y, double z, double t) {
return fma((1.0 - z), y, ((x - 1.0) * log(y))) - t;
}
function code(x, y, z, t) return Float64(fma(Float64(1.0 - z), y, Float64(Float64(x - 1.0) * log(y))) - t) end
code[x_, y_, z_, t_] := N[(N[(N[(1.0 - z), $MachinePrecision] * y + N[(N[(x - 1.0), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(1 - z, y, \left(x - 1\right) \cdot \log y\right) - t
\end{array}
Initial program 90.1%
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.f6498.5
Applied rewrites98.5%
(FPCore (x y z t) :precision binary64 (- (* (* (fma -0.5 y -1.0) z) y) t))
double code(double x, double y, double z, double t) {
return ((fma(-0.5, y, -1.0) * z) * y) - t;
}
function code(x, y, z, t) return Float64(Float64(Float64(fma(-0.5, y, -1.0) * z) * y) - t) end
code[x_, y_, z_, t_] := N[(N[(N[(N[(-0.5 * y + -1.0), $MachinePrecision] * z), $MachinePrecision] * y), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\left(\mathsf{fma}\left(-0.5, y, -1\right) \cdot z\right) \cdot y - t
\end{array}
Initial program 90.1%
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.2
Applied rewrites99.2%
Taylor expanded in z around inf
Applied rewrites47.0%
(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 90.1%
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.f6498.5
Applied rewrites98.5%
Taylor expanded in y around inf
Applied rewrites46.6%
(FPCore (x y z t) :precision binary64 (- (* (- z) y) t))
double code(double x, double y, double z, double t) {
return (-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 = (-z * y) - t
end function
public static double code(double x, double y, double z, double t) {
return (-z * y) - t;
}
def code(x, y, z, t): return (-z * y) - t
function code(x, y, z, t) return Float64(Float64(Float64(-z) * y) - t) end
function tmp = code(x, y, z, t) tmp = (-z * y) - t; end
code[x_, y_, z_, t_] := N[(N[((-z) * y), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\left(-z\right) \cdot y - t
\end{array}
Initial program 90.1%
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.2
Applied rewrites99.2%
Taylor expanded in z around inf
Applied rewrites47.0%
Taylor expanded in y around 0
Applied rewrites46.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 90.1%
Taylor expanded in t around inf
mul-1-negN/A
lower-neg.f6436.8
Applied rewrites36.8%
herbie shell --seed 2024288
(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))