
(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
(-
(+
(* (+ x -1.0) (log y))
(*
(+ z -1.0)
(* y (fma y (fma y (fma y -0.25 -0.3333333333333333) -0.5) -1.0))))
t))
double code(double x, double y, double z, double t) {
return (((x + -1.0) * log(y)) + ((z + -1.0) * (y * fma(y, fma(y, fma(y, -0.25, -0.3333333333333333), -0.5), -1.0)))) - t;
}
function code(x, y, z, t) return Float64(Float64(Float64(Float64(x + -1.0) * log(y)) + Float64(Float64(z + -1.0) * Float64(y * fma(y, fma(y, fma(y, -0.25, -0.3333333333333333), -0.5), -1.0)))) - 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[(y * N[(y * N[(y * N[(y * -0.25 + -0.3333333333333333), $MachinePrecision] + -0.5), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x + -1\right) \cdot \log y + \left(z + -1\right) \cdot \left(y \cdot \mathsf{fma}\left(y, \mathsf{fma}\left(y, \mathsf{fma}\left(y, -0.25, -0.3333333333333333\right), -0.5\right), -1\right)\right)\right) - t
\end{array}
Initial program 91.4%
Taylor expanded in y around 0
lower-*.f64N/A
sub-negN/A
metadata-evalN/A
lower-fma.f64N/A
sub-negN/A
metadata-evalN/A
lower-fma.f64N/A
sub-negN/A
*-commutativeN/A
metadata-evalN/A
lower-fma.f6499.8
Applied rewrites99.8%
Final simplification99.8%
(FPCore (x y z t) :precision binary64 (- (+ (* (+ x -1.0) (log y)) (* (+ z -1.0) (* y (fma y (fma y -0.3333333333333333 -0.5) -1.0)))) t))
double code(double x, double y, double z, double t) {
return (((x + -1.0) * log(y)) + ((z + -1.0) * (y * fma(y, fma(y, -0.3333333333333333, -0.5), -1.0)))) - t;
}
function code(x, y, z, t) return Float64(Float64(Float64(Float64(x + -1.0) * log(y)) + Float64(Float64(z + -1.0) * Float64(y * fma(y, fma(y, -0.3333333333333333, -0.5), -1.0)))) - 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[(y * N[(y * N[(y * -0.3333333333333333 + -0.5), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x + -1\right) \cdot \log y + \left(z + -1\right) \cdot \left(y \cdot \mathsf{fma}\left(y, \mathsf{fma}\left(y, -0.3333333333333333, -0.5\right), -1\right)\right)\right) - t
\end{array}
Initial program 91.4%
Taylor expanded in y around 0
lower-*.f64N/A
sub-negN/A
metadata-evalN/A
lower-fma.f64N/A
sub-negN/A
*-commutativeN/A
metadata-evalN/A
lower-fma.f6499.7
Applied rewrites99.7%
Final simplification99.7%
(FPCore (x y z t) :precision binary64 (- (fma y (* (+ z -1.0) (fma y -0.5 -1.0)) (* (+ x -1.0) (log y))) t))
double code(double x, double y, double z, double t) {
return fma(y, ((z + -1.0) * fma(y, -0.5, -1.0)), ((x + -1.0) * log(y))) - t;
}
function code(x, y, z, t) return Float64(fma(y, Float64(Float64(z + -1.0) * fma(y, -0.5, -1.0)), Float64(Float64(x + -1.0) * log(y))) - t) end
code[x_, y_, z_, t_] := N[(N[(y * N[(N[(z + -1.0), $MachinePrecision] * N[(y * -0.5 + -1.0), $MachinePrecision]), $MachinePrecision] + N[(N[(x + -1.0), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(y, \left(z + -1\right) \cdot \mathsf{fma}\left(y, -0.5, -1\right), \left(x + -1\right) \cdot \log y\right) - t
\end{array}
Initial program 91.4%
Taylor expanded in y around 0
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites99.7%
Final simplification99.7%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (fma (log y) (+ x -1.0) y)))
(if (<= t -9.5)
(- t_1 t)
(if (<= t 1.5e-15) (fma y (- z) t_1) (fma (log y) (+ x -1.0) (- t))))))
double code(double x, double y, double z, double t) {
double t_1 = fma(log(y), (x + -1.0), y);
double tmp;
if (t <= -9.5) {
tmp = t_1 - t;
} else if (t <= 1.5e-15) {
tmp = fma(y, -z, t_1);
} else {
tmp = fma(log(y), (x + -1.0), -t);
}
return tmp;
}
function code(x, y, z, t) t_1 = fma(log(y), Float64(x + -1.0), y) tmp = 0.0 if (t <= -9.5) tmp = Float64(t_1 - t); elseif (t <= 1.5e-15) tmp = fma(y, Float64(-z), t_1); else tmp = fma(log(y), Float64(x + -1.0), Float64(-t)); end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[Log[y], $MachinePrecision] * N[(x + -1.0), $MachinePrecision] + y), $MachinePrecision]}, If[LessEqual[t, -9.5], N[(t$95$1 - t), $MachinePrecision], If[LessEqual[t, 1.5e-15], N[(y * (-z) + t$95$1), $MachinePrecision], N[(N[Log[y], $MachinePrecision] * N[(x + -1.0), $MachinePrecision] + (-t)), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\log y, x + -1, y\right)\\
\mathbf{if}\;t \leq -9.5:\\
\;\;\;\;t\_1 - t\\
\mathbf{elif}\;t \leq 1.5 \cdot 10^{-15}:\\
\;\;\;\;\mathsf{fma}\left(y, -z, t\_1\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\log y, x + -1, -t\right)\\
\end{array}
\end{array}
if t < -9.5Initial program 96.7%
Taylor expanded in y around 0
mul-1-negN/A
distribute-rgt-neg-inN/A
mul-1-negN/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
lower-*.f64N/A
lower-log.f64N/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
lower-+.f6499.8
Applied rewrites99.8%
Taylor expanded in z around 0
lower--.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower-log.f64N/A
sub-negN/A
metadata-evalN/A
lower-+.f6496.7
Applied rewrites96.7%
if -9.5 < t < 1.5e-15Initial program 85.8%
Taylor expanded in y around 0
mul-1-negN/A
distribute-rgt-neg-inN/A
mul-1-negN/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
lower-*.f64N/A
lower-log.f64N/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
lower-+.f6499.4
Applied rewrites99.4%
Taylor expanded in t around 0
sub-negN/A
mul-1-negN/A
distribute-lft-inN/A
*-rgt-identityN/A
mul-1-negN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
associate-+r+N/A
+-commutativeN/A
associate-+l+N/A
+-commutativeN/A
mul-1-negN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower-log.f64N/A
sub-negN/A
metadata-evalN/A
lower-+.f6499.4
Applied rewrites99.4%
if 1.5e-15 < t Initial program 95.9%
Taylor expanded in y around 0
sub-negN/A
lower-fma.f64N/A
lower-log.f64N/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
lower-+.f64N/A
lower-neg.f6495.9
Applied rewrites95.9%
Final simplification97.7%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (- (* x (log y)) t)))
(if (<= (+ x -1.0) -20.0)
t_1
(if (<= (+ x -1.0) -1.0) (- (- t) (log y)) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = (x * log(y)) - t;
double tmp;
if ((x + -1.0) <= -20.0) {
tmp = t_1;
} else if ((x + -1.0) <= -1.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) :: tmp
t_1 = (x * log(y)) - t
if ((x + (-1.0d0)) <= (-20.0d0)) then
tmp = t_1
else if ((x + (-1.0d0)) <= (-1.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 = (x * Math.log(y)) - t;
double tmp;
if ((x + -1.0) <= -20.0) {
tmp = t_1;
} else if ((x + -1.0) <= -1.0) {
tmp = -t - Math.log(y);
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = (x * math.log(y)) - t tmp = 0 if (x + -1.0) <= -20.0: tmp = t_1 elif (x + -1.0) <= -1.0: tmp = -t - math.log(y) else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(Float64(x * log(y)) - t) tmp = 0.0 if (Float64(x + -1.0) <= -20.0) tmp = t_1; elseif (Float64(x + -1.0) <= -1.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 = (x * log(y)) - t; tmp = 0.0; if ((x + -1.0) <= -20.0) tmp = t_1; elseif ((x + -1.0) <= -1.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[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]}, If[LessEqual[N[(x + -1.0), $MachinePrecision], -20.0], t$95$1, If[LessEqual[N[(x + -1.0), $MachinePrecision], -1.0], N[((-t) - N[Log[y], $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x \cdot \log y - t\\
\mathbf{if}\;x + -1 \leq -20:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x + -1 \leq -1:\\
\;\;\;\;\left(-t\right) - \log y\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (-.f64 x #s(literal 1 binary64)) < -20 or -1 < (-.f64 x #s(literal 1 binary64)) Initial program 94.7%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower-log.f6494.0
Applied rewrites94.0%
if -20 < (-.f64 x #s(literal 1 binary64)) < -1Initial program 87.3%
Taylor expanded in y around 0
lower-*.f64N/A
sub-negN/A
metadata-evalN/A
lower-fma.f64N/A
sub-negN/A
metadata-evalN/A
lower-fma.f64N/A
sub-negN/A
*-commutativeN/A
metadata-evalN/A
lower-fma.f64100.0
Applied rewrites100.0%
Taylor expanded in y around 0
sub-negN/A
lower-fma.f64N/A
lower-log.f64N/A
sub-negN/A
metadata-evalN/A
lower-+.f64N/A
lower-neg.f6486.7
Applied rewrites86.7%
Taylor expanded in x around 0
sub-negN/A
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-neg.f64N/A
lower-log.f6486.3
Applied rewrites86.3%
Final simplification90.5%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* x (log y))))
(if (<= (+ x -1.0) -2e+24)
t_1
(if (<= (+ x -1.0) 1e+19) (- (- t) (log y)) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = x * log(y);
double tmp;
if ((x + -1.0) <= -2e+24) {
tmp = t_1;
} else if ((x + -1.0) <= 1e+19) {
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) :: tmp
t_1 = x * log(y)
if ((x + (-1.0d0)) <= (-2d+24)) then
tmp = t_1
else if ((x + (-1.0d0)) <= 1d+19) 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 = x * Math.log(y);
double tmp;
if ((x + -1.0) <= -2e+24) {
tmp = t_1;
} else if ((x + -1.0) <= 1e+19) {
tmp = -t - Math.log(y);
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = x * math.log(y) tmp = 0 if (x + -1.0) <= -2e+24: tmp = t_1 elif (x + -1.0) <= 1e+19: tmp = -t - math.log(y) else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(x * log(y)) tmp = 0.0 if (Float64(x + -1.0) <= -2e+24) tmp = t_1; elseif (Float64(x + -1.0) <= 1e+19) tmp = Float64(Float64(-t) - log(y)); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = x * log(y); tmp = 0.0; if ((x + -1.0) <= -2e+24) tmp = t_1; elseif ((x + -1.0) <= 1e+19) tmp = -t - log(y); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x + -1.0), $MachinePrecision], -2e+24], t$95$1, If[LessEqual[N[(x + -1.0), $MachinePrecision], 1e+19], N[((-t) - N[Log[y], $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x \cdot \log y\\
\mathbf{if}\;x + -1 \leq -2 \cdot 10^{+24}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x + -1 \leq 10^{+19}:\\
\;\;\;\;\left(-t\right) - \log y\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (-.f64 x #s(literal 1 binary64)) < -2e24 or 1e19 < (-.f64 x #s(literal 1 binary64)) Initial program 98.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower-log.f6475.8
Applied rewrites75.8%
if -2e24 < (-.f64 x #s(literal 1 binary64)) < 1e19Initial program 84.6%
Taylor expanded in y around 0
lower-*.f64N/A
sub-negN/A
metadata-evalN/A
lower-fma.f64N/A
sub-negN/A
metadata-evalN/A
lower-fma.f64N/A
sub-negN/A
*-commutativeN/A
metadata-evalN/A
lower-fma.f64100.0
Applied rewrites100.0%
Taylor expanded in y around 0
sub-negN/A
lower-fma.f64N/A
lower-log.f64N/A
sub-negN/A
metadata-evalN/A
lower-+.f64N/A
lower-neg.f6484.1
Applied rewrites84.1%
Taylor expanded in x around 0
sub-negN/A
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-neg.f64N/A
lower-log.f6482.4
Applied rewrites82.4%
Final simplification79.1%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* x (log y))))
(if (<= (+ x -1.0) -2e+24)
t_1
(if (<= (+ x -1.0) 1e+19) (- (fma y (- z) y) t) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = x * log(y);
double tmp;
if ((x + -1.0) <= -2e+24) {
tmp = t_1;
} else if ((x + -1.0) <= 1e+19) {
tmp = fma(y, -z, y) - t;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(x * log(y)) tmp = 0.0 if (Float64(x + -1.0) <= -2e+24) tmp = t_1; elseif (Float64(x + -1.0) <= 1e+19) tmp = Float64(fma(y, Float64(-z), y) - t); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x + -1.0), $MachinePrecision], -2e+24], t$95$1, If[LessEqual[N[(x + -1.0), $MachinePrecision], 1e+19], N[(N[(y * (-z) + y), $MachinePrecision] - t), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x \cdot \log y\\
\mathbf{if}\;x + -1 \leq -2 \cdot 10^{+24}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x + -1 \leq 10^{+19}:\\
\;\;\;\;\mathsf{fma}\left(y, -z, y\right) - t\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (-.f64 x #s(literal 1 binary64)) < -2e24 or 1e19 < (-.f64 x #s(literal 1 binary64)) Initial program 98.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower-log.f6475.8
Applied rewrites75.8%
if -2e24 < (-.f64 x #s(literal 1 binary64)) < 1e19Initial program 84.6%
Taylor expanded in y around 0
mul-1-negN/A
distribute-rgt-neg-inN/A
mul-1-negN/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
lower-*.f64N/A
lower-log.f64N/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
lower-+.f6499.6
Applied rewrites99.6%
Taylor expanded in y around inf
sub-negN/A
mul-1-negN/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f6463.3
Applied rewrites63.3%
Final simplification69.6%
(FPCore (x y z t) :precision binary64 (if (<= (+ z -1.0) 5e+244) (- (fma (log y) (+ x -1.0) y) t) (- (fma y (- z) y) t)))
double code(double x, double y, double z, double t) {
double tmp;
if ((z + -1.0) <= 5e+244) {
tmp = fma(log(y), (x + -1.0), y) - t;
} else {
tmp = fma(y, -z, y) - t;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (Float64(z + -1.0) <= 5e+244) tmp = Float64(fma(log(y), Float64(x + -1.0), y) - t); else tmp = Float64(fma(y, Float64(-z), y) - t); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[(z + -1.0), $MachinePrecision], 5e+244], N[(N[(N[Log[y], $MachinePrecision] * N[(x + -1.0), $MachinePrecision] + y), $MachinePrecision] - t), $MachinePrecision], N[(N[(y * (-z) + y), $MachinePrecision] - t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z + -1 \leq 5 \cdot 10^{+244}:\\
\;\;\;\;\mathsf{fma}\left(\log y, x + -1, y\right) - t\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, -z, y\right) - t\\
\end{array}
\end{array}
if (-.f64 z #s(literal 1 binary64)) < 5.00000000000000022e244Initial program 94.2%
Taylor expanded in y around 0
mul-1-negN/A
distribute-rgt-neg-inN/A
mul-1-negN/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
lower-*.f64N/A
lower-log.f64N/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
lower-+.f6499.6
Applied rewrites99.6%
Taylor expanded in z around 0
lower--.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower-log.f64N/A
sub-negN/A
metadata-evalN/A
lower-+.f6494.0
Applied rewrites94.0%
if 5.00000000000000022e244 < (-.f64 z #s(literal 1 binary64)) Initial program 28.1%
Taylor expanded in y around 0
mul-1-negN/A
distribute-rgt-neg-inN/A
mul-1-negN/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
lower-*.f64N/A
lower-log.f64N/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
lower-+.f64100.0
Applied rewrites100.0%
Taylor expanded in y around inf
sub-negN/A
mul-1-negN/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f6488.3
Applied rewrites88.3%
Final simplification93.8%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (- (fma y z t)))) (if (<= t -2.5e+52) t_1 (if (<= t 1.22e+58) (* (+ x -1.0) (log y)) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = -fma(y, z, t);
double tmp;
if (t <= -2.5e+52) {
tmp = t_1;
} else if (t <= 1.22e+58) {
tmp = (x + -1.0) * log(y);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(-fma(y, z, t)) tmp = 0.0 if (t <= -2.5e+52) tmp = t_1; elseif (t <= 1.22e+58) tmp = Float64(Float64(x + -1.0) * log(y)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = (-N[(y * z + t), $MachinePrecision])}, If[LessEqual[t, -2.5e+52], t$95$1, If[LessEqual[t, 1.22e+58], N[(N[(x + -1.0), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := -\mathsf{fma}\left(y, z, t\right)\\
\mathbf{if}\;t \leq -2.5 \cdot 10^{+52}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 1.22 \cdot 10^{+58}:\\
\;\;\;\;\left(x + -1\right) \cdot \log y\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -2.5e52 or 1.21999999999999995e58 < t Initial program 98.0%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
sub-negN/A
lower-log1p.f64N/A
lower-neg.f6479.9
Applied rewrites79.9%
Taylor expanded in y around 0
sub-negN/A
mul-1-negN/A
distribute-neg-outN/A
lower-neg.f64N/A
lower-fma.f6479.9
Applied rewrites79.9%
if -2.5e52 < t < 1.21999999999999995e58Initial program 86.6%
Taylor expanded in y around 0
lower-*.f64N/A
sub-negN/A
metadata-evalN/A
lower-fma.f64N/A
sub-negN/A
metadata-evalN/A
lower-fma.f64N/A
sub-negN/A
*-commutativeN/A
metadata-evalN/A
lower-fma.f6499.7
Applied rewrites99.7%
Taylor expanded in y around 0
sub-negN/A
lower-fma.f64N/A
lower-log.f64N/A
sub-negN/A
metadata-evalN/A
lower-+.f64N/A
lower-neg.f6486.1
Applied rewrites86.1%
Taylor expanded in t around 0
lower-*.f64N/A
lower-log.f64N/A
sub-negN/A
metadata-evalN/A
lower-+.f6482.2
Applied rewrites82.2%
Final simplification81.3%
(FPCore (x y z t) :precision binary64 (if (<= (+ z -1.0) 5e+244) (fma (log y) (+ x -1.0) (- t)) (- (fma y (- z) y) t)))
double code(double x, double y, double z, double t) {
double tmp;
if ((z + -1.0) <= 5e+244) {
tmp = fma(log(y), (x + -1.0), -t);
} else {
tmp = fma(y, -z, y) - t;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (Float64(z + -1.0) <= 5e+244) tmp = fma(log(y), Float64(x + -1.0), Float64(-t)); else tmp = Float64(fma(y, Float64(-z), y) - t); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[(z + -1.0), $MachinePrecision], 5e+244], N[(N[Log[y], $MachinePrecision] * N[(x + -1.0), $MachinePrecision] + (-t)), $MachinePrecision], N[(N[(y * (-z) + y), $MachinePrecision] - t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z + -1 \leq 5 \cdot 10^{+244}:\\
\;\;\;\;\mathsf{fma}\left(\log y, x + -1, -t\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, -z, y\right) - t\\
\end{array}
\end{array}
if (-.f64 z #s(literal 1 binary64)) < 5.00000000000000022e244Initial program 94.2%
Taylor expanded in y around 0
sub-negN/A
lower-fma.f64N/A
lower-log.f64N/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
lower-+.f64N/A
lower-neg.f6493.9
Applied rewrites93.9%
if 5.00000000000000022e244 < (-.f64 z #s(literal 1 binary64)) Initial program 28.1%
Taylor expanded in y around 0
mul-1-negN/A
distribute-rgt-neg-inN/A
mul-1-negN/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
lower-*.f64N/A
lower-log.f64N/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
lower-+.f64100.0
Applied rewrites100.0%
Taylor expanded in y around inf
sub-negN/A
mul-1-negN/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f6488.3
Applied rewrites88.3%
Final simplification93.7%
(FPCore (x y z t) :precision binary64 (- (fma y (- 1.0 z) (* (+ x -1.0) (log y))) t))
double code(double x, double y, double z, double t) {
return fma(y, (1.0 - z), ((x + -1.0) * log(y))) - t;
}
function code(x, y, z, t) return Float64(fma(y, Float64(1.0 - z), Float64(Float64(x + -1.0) * log(y))) - t) end
code[x_, y_, z_, t_] := N[(N[(y * N[(1.0 - z), $MachinePrecision] + N[(N[(x + -1.0), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(y, 1 - z, \left(x + -1\right) \cdot \log y\right) - t
\end{array}
Initial program 91.4%
Taylor expanded in y around 0
mul-1-negN/A
distribute-rgt-neg-inN/A
mul-1-negN/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
lower-*.f64N/A
lower-log.f64N/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
lower-+.f6499.6
Applied rewrites99.6%
Final simplification99.6%
(FPCore (x y z t) :precision binary64 (if (<= t -1.8e+33) (- t) (if (<= t 2.5e+60) (* y (- z)) (- t))))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= -1.8e+33) {
tmp = -t;
} else if (t <= 2.5e+60) {
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 <= (-1.8d+33)) then
tmp = -t
else if (t <= 2.5d+60) 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 <= -1.8e+33) {
tmp = -t;
} else if (t <= 2.5e+60) {
tmp = y * -z;
} else {
tmp = -t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if t <= -1.8e+33: tmp = -t elif t <= 2.5e+60: tmp = y * -z else: tmp = -t return tmp
function code(x, y, z, t) tmp = 0.0 if (t <= -1.8e+33) tmp = Float64(-t); elseif (t <= 2.5e+60) tmp = Float64(y * Float64(-z)); else tmp = Float64(-t); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (t <= -1.8e+33) tmp = -t; elseif (t <= 2.5e+60) tmp = y * -z; else tmp = -t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[t, -1.8e+33], (-t), If[LessEqual[t, 2.5e+60], N[(y * (-z)), $MachinePrecision], (-t)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.8 \cdot 10^{+33}:\\
\;\;\;\;-t\\
\mathbf{elif}\;t \leq 2.5 \cdot 10^{+60}:\\
\;\;\;\;y \cdot \left(-z\right)\\
\mathbf{else}:\\
\;\;\;\;-t\\
\end{array}
\end{array}
if t < -1.8000000000000001e33 or 2.49999999999999987e60 < t Initial program 99.0%
Taylor expanded in t around inf
mul-1-negN/A
lower-neg.f6476.9
Applied rewrites76.9%
if -1.8000000000000001e33 < t < 2.49999999999999987e60Initial program 85.6%
Taylor expanded in y around 0
mul-1-negN/A
distribute-rgt-neg-inN/A
mul-1-negN/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
lower-*.f64N/A
lower-log.f64N/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
lower-+.f6499.4
Applied rewrites99.4%
Taylor expanded in z around inf
mul-1-negN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6416.5
Applied rewrites16.5%
(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(y, Float64(-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 91.4%
Taylor expanded in y around 0
mul-1-negN/A
distribute-rgt-neg-inN/A
mul-1-negN/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
lower-*.f64N/A
lower-log.f64N/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
lower-+.f6499.6
Applied rewrites99.6%
Taylor expanded in y around inf
sub-negN/A
mul-1-negN/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f6444.0
Applied rewrites44.0%
(FPCore (x y z t) :precision binary64 (- (fma y z t)))
double code(double x, double y, double z, double t) {
return -fma(y, z, t);
}
function code(x, y, z, t) return Float64(-fma(y, z, t)) end
code[x_, y_, z_, t_] := (-N[(y * z + t), $MachinePrecision])
\begin{array}{l}
\\
-\mathsf{fma}\left(y, z, t\right)
\end{array}
Initial program 91.4%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
sub-negN/A
lower-log1p.f64N/A
lower-neg.f6443.8
Applied rewrites43.8%
Taylor expanded in y around 0
sub-negN/A
mul-1-negN/A
distribute-neg-outN/A
lower-neg.f64N/A
lower-fma.f6443.8
Applied rewrites43.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 91.4%
Taylor expanded in t around inf
mul-1-negN/A
lower-neg.f6435.5
Applied rewrites35.5%
herbie shell --seed 2024219
(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))