
(FPCore (x y z t) :precision binary64 (- (+ (* (- x 1.0) (log y)) (* (- z 1.0) (log (- 1.0 y)))) t))
double code(double x, double y, double z, double t) {
return (((x - 1.0) * log(y)) + ((z - 1.0) * log((1.0 - y)))) - t;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = (((x - 1.0d0) * log(y)) + ((z - 1.0d0) * log((1.0d0 - y)))) - t
end function
public static double code(double x, double y, double z, double t) {
return (((x - 1.0) * Math.log(y)) + ((z - 1.0) * Math.log((1.0 - y)))) - t;
}
def code(x, y, z, t): return (((x - 1.0) * math.log(y)) + ((z - 1.0) * math.log((1.0 - y)))) - t
function code(x, y, z, t) return Float64(Float64(Float64(Float64(x - 1.0) * log(y)) + Float64(Float64(z - 1.0) * log(Float64(1.0 - y)))) - t) end
function tmp = code(x, y, z, t) tmp = (((x - 1.0) * log(y)) + ((z - 1.0) * log((1.0 - y)))) - t; end
code[x_, y_, z_, t_] := N[(N[(N[(N[(x - 1.0), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision] + N[(N[(z - 1.0), $MachinePrecision] * N[Log[N[(1.0 - y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x - 1\right) \cdot \log y + \left(z - 1\right) \cdot \log \left(1 - y\right)\right) - t
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 16 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (- (+ (* (- x 1.0) (log y)) (* (- z 1.0) (log (- 1.0 y)))) t))
double code(double x, double y, double z, double t) {
return (((x - 1.0) * log(y)) + ((z - 1.0) * log((1.0 - y)))) - t;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = (((x - 1.0d0) * log(y)) + ((z - 1.0d0) * log((1.0d0 - y)))) - t
end function
public static double code(double x, double y, double z, double t) {
return (((x - 1.0) * Math.log(y)) + ((z - 1.0) * Math.log((1.0 - y)))) - t;
}
def code(x, y, z, t): return (((x - 1.0) * math.log(y)) + ((z - 1.0) * math.log((1.0 - y)))) - t
function code(x, y, z, t) return Float64(Float64(Float64(Float64(x - 1.0) * log(y)) + Float64(Float64(z - 1.0) * log(Float64(1.0 - y)))) - t) end
function tmp = code(x, y, z, t) tmp = (((x - 1.0) * log(y)) + ((z - 1.0) * log((1.0 - y)))) - t; end
code[x_, y_, z_, t_] := N[(N[(N[(N[(x - 1.0), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision] + N[(N[(z - 1.0), $MachinePrecision] * N[Log[N[(1.0 - y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x - 1\right) \cdot \log y + \left(z - 1\right) \cdot \log \left(1 - y\right)\right) - t
\end{array}
(FPCore (x y z t) :precision binary64 (fma (- z 1.0) (log1p (- y)) (- (* (log y) (- x 1.0)) t)))
double code(double x, double y, double z, double t) {
return fma((z - 1.0), log1p(-y), ((log(y) * (x - 1.0)) - t));
}
function code(x, y, z, t) return fma(Float64(z - 1.0), log1p(Float64(-y)), Float64(Float64(log(y) * Float64(x - 1.0)) - t)) end
code[x_, y_, z_, t_] := N[(N[(z - 1.0), $MachinePrecision] * N[Log[1 + (-y)], $MachinePrecision] + N[(N[(N[Log[y], $MachinePrecision] * N[(x - 1.0), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(z - 1, \mathsf{log1p}\left(-y\right), \log y \cdot \left(x - 1\right) - t\right)
\end{array}
Initial program 89.5%
lift--.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate--l+N/A
lift-*.f64N/A
lower-fma.f64N/A
lift-log.f64N/A
lift--.f64N/A
*-lft-identityN/A
fp-cancel-sub-sign-invN/A
distribute-lft-neg-inN/A
*-lft-identityN/A
lower-log1p.f64N/A
lower-neg.f64N/A
lower--.f6499.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.8
Applied rewrites99.8%
(FPCore (x y z t) :precision binary64 (- (fma (+ -1.0 x) (log y) (* (fma (* (- z 1.0) (fma -0.3333333333333333 y -0.5)) y (- (- z 1.0))) y)) t))
double code(double x, double y, double z, double t) {
return fma((-1.0 + x), log(y), (fma(((z - 1.0) * fma(-0.3333333333333333, y, -0.5)), y, -(z - 1.0)) * y)) - t;
}
function code(x, y, z, t) return Float64(fma(Float64(-1.0 + x), log(y), Float64(fma(Float64(Float64(z - 1.0) * fma(-0.3333333333333333, y, -0.5)), y, Float64(-Float64(z - 1.0))) * y)) - t) end
code[x_, y_, z_, t_] := N[(N[(N[(-1.0 + x), $MachinePrecision] * N[Log[y], $MachinePrecision] + N[(N[(N[(N[(z - 1.0), $MachinePrecision] * N[(-0.3333333333333333 * y + -0.5), $MachinePrecision]), $MachinePrecision] * y + (-N[(z - 1.0), $MachinePrecision])), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(-1 + x, \log y, \mathsf{fma}\left(\left(z - 1\right) \cdot \mathsf{fma}\left(-0.3333333333333333, y, -0.5\right), y, -\left(z - 1\right)\right) \cdot y\right) - t
\end{array}
Initial program 89.5%
Taylor expanded in y around 0
+-commutativeN/A
Applied rewrites98.9%
(FPCore (x y z t) :precision binary64 (fma (- z 1.0) (* (- (* (- (* -0.3333333333333333 y) 0.5) y) 1.0) y) (- (* (log y) (- x 1.0)) t)))
double code(double x, double y, double z, double t) {
return fma((z - 1.0), (((((-0.3333333333333333 * y) - 0.5) * y) - 1.0) * y), ((log(y) * (x - 1.0)) - t));
}
function code(x, y, z, t) return fma(Float64(z - 1.0), Float64(Float64(Float64(Float64(Float64(-0.3333333333333333 * y) - 0.5) * y) - 1.0) * y), Float64(Float64(log(y) * Float64(x - 1.0)) - t)) end
code[x_, y_, z_, t_] := N[(N[(z - 1.0), $MachinePrecision] * N[(N[(N[(N[(N[(-0.3333333333333333 * y), $MachinePrecision] - 0.5), $MachinePrecision] * y), $MachinePrecision] - 1.0), $MachinePrecision] * y), $MachinePrecision] + N[(N[(N[Log[y], $MachinePrecision] * N[(x - 1.0), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(z - 1, \left(\left(-0.3333333333333333 \cdot y - 0.5\right) \cdot y - 1\right) \cdot y, \log y \cdot \left(x - 1\right) - t\right)
\end{array}
Initial program 89.5%
lift--.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate--l+N/A
lift-*.f64N/A
lower-fma.f64N/A
lift-log.f64N/A
lift--.f64N/A
*-lft-identityN/A
fp-cancel-sub-sign-invN/A
distribute-lft-neg-inN/A
*-lft-identityN/A
lower-log1p.f64N/A
lower-neg.f64N/A
lower--.f6499.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.8
Applied rewrites99.8%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f6498.9
Applied rewrites98.9%
(FPCore (x y z t) :precision binary64 (- (fma (log y) (- x 1.0) (* (* (- z 1.0) (fma -0.5 y -1.0)) y)) t))
double code(double x, double y, double z, double t) {
return fma(log(y), (x - 1.0), (((z - 1.0) * fma(-0.5, y, -1.0)) * y)) - t;
}
function code(x, y, z, t) return Float64(fma(log(y), Float64(x - 1.0), Float64(Float64(Float64(z - 1.0) * fma(-0.5, y, -1.0)) * y)) - t) end
code[x_, y_, z_, t_] := N[(N[(N[Log[y], $MachinePrecision] * N[(x - 1.0), $MachinePrecision] + N[(N[(N[(z - 1.0), $MachinePrecision] * N[(-0.5 * y + -1.0), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\log y, x - 1, \left(\left(z - 1\right) \cdot \mathsf{fma}\left(-0.5, y, -1\right)\right) \cdot y\right) - t
\end{array}
Initial program 89.5%
Taylor expanded in y around 0
+-commutativeN/A
remove-double-negN/A
log-recN/A
mul-1-negN/A
Applied rewrites98.5%
Taylor expanded in y around 0
+-commutativeN/A
remove-double-negN/A
log-recN/A
log-recN/A
mul-1-negN/A
distribute-rgt-neg-inN/A
log-recN/A
lower-fma.f64N/A
log-recN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
remove-double-negN/A
lower-log.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites98.8%
(FPCore (x y z t)
:precision binary64
(if (<= x -2.85e+17)
(- (* (log y) x) t)
(if (<= x 8.5e+36)
(- (- (fma (- z 1.0) y (log y))) t)
(fma (+ -1.0 x) (log y) (- t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -2.85e+17) {
tmp = (log(y) * x) - t;
} else if (x <= 8.5e+36) {
tmp = -fma((z - 1.0), y, log(y)) - t;
} else {
tmp = fma((-1.0 + x), log(y), -t);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (x <= -2.85e+17) tmp = Float64(Float64(log(y) * x) - t); elseif (x <= 8.5e+36) tmp = Float64(Float64(-fma(Float64(z - 1.0), y, log(y))) - t); else tmp = fma(Float64(-1.0 + x), log(y), Float64(-t)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[x, -2.85e+17], N[(N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision] - t), $MachinePrecision], If[LessEqual[x, 8.5e+36], N[((-N[(N[(z - 1.0), $MachinePrecision] * y + N[Log[y], $MachinePrecision]), $MachinePrecision]) - t), $MachinePrecision], N[(N[(-1.0 + x), $MachinePrecision] * N[Log[y], $MachinePrecision] + (-t)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.85 \cdot 10^{+17}:\\
\;\;\;\;\log y \cdot x - t\\
\mathbf{elif}\;x \leq 8.5 \cdot 10^{+36}:\\
\;\;\;\;\left(-\mathsf{fma}\left(z - 1, y, \log y\right)\right) - t\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-1 + x, \log y, -t\right)\\
\end{array}
\end{array}
if x < -2.85e17Initial program 93.0%
Taylor expanded in x around inf
*-commutativeN/A
remove-double-negN/A
log-recN/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
log-recN/A
remove-double-negN/A
lower-log.f6489.2
Applied rewrites89.2%
if -2.85e17 < x < 8.50000000000000014e36Initial program 86.0%
Taylor expanded in y around 0
+-commutativeN/A
remove-double-negN/A
log-recN/A
mul-1-negN/A
Applied rewrites98.5%
Taylor expanded in x around 0
Applied rewrites97.5%
if 8.50000000000000014e36 < x Initial program 95.7%
Taylor expanded in y around 0
*-rgt-identityN/A
fp-cancel-sub-sign-invN/A
Applied rewrites95.8%
(FPCore (x y z t) :precision binary64 (if (or (<= z -2.15e+273) (not (<= z 9.8e+185))) (- (* (* (- (* -0.5 y) 1.0) z) y) t) (- (fma (log y) (- x 1.0) y) t)))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -2.15e+273) || !(z <= 9.8e+185)) {
tmp = ((((-0.5 * y) - 1.0) * z) * y) - t;
} else {
tmp = fma(log(y), (x - 1.0), y) - t;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if ((z <= -2.15e+273) || !(z <= 9.8e+185)) tmp = Float64(Float64(Float64(Float64(Float64(-0.5 * y) - 1.0) * z) * y) - t); else tmp = Float64(fma(log(y), Float64(x - 1.0), y) - t); end return tmp end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -2.15e+273], N[Not[LessEqual[z, 9.8e+185]], $MachinePrecision]], N[(N[(N[(N[(N[(-0.5 * y), $MachinePrecision] - 1.0), $MachinePrecision] * z), $MachinePrecision] * y), $MachinePrecision] - t), $MachinePrecision], N[(N[(N[Log[y], $MachinePrecision] * N[(x - 1.0), $MachinePrecision] + y), $MachinePrecision] - t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.15 \cdot 10^{+273} \lor \neg \left(z \leq 9.8 \cdot 10^{+185}\right):\\
\;\;\;\;\left(\left(-0.5 \cdot y - 1\right) \cdot z\right) \cdot y - t\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\log y, x - 1, y\right) - t\\
\end{array}
\end{array}
if z < -2.15000000000000008e273 or 9.79999999999999968e185 < z Initial program 44.3%
Taylor expanded in y around 0
+-commutativeN/A
remove-double-negN/A
log-recN/A
mul-1-negN/A
Applied rewrites90.5%
Taylor expanded in z around inf
Applied rewrites74.1%
Taylor expanded in y around 0
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
lower-*.f64N/A
lower--.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower--.f6492.6
Applied rewrites92.6%
Taylor expanded in z around inf
Applied rewrites76.2%
if -2.15000000000000008e273 < z < 9.79999999999999968e185Initial program 95.3%
Taylor expanded in y around 0
+-commutativeN/A
remove-double-negN/A
log-recN/A
mul-1-negN/A
Applied rewrites99.5%
Taylor expanded in z around 0
Applied rewrites94.7%
Final simplification92.6%
(FPCore (x y z t) :precision binary64 (if (or (<= z -2.15e+273) (not (<= z 9.8e+185))) (- (* (* (- (* -0.5 y) 1.0) z) y) t) (fma (+ -1.0 x) (log y) (- t))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -2.15e+273) || !(z <= 9.8e+185)) {
tmp = ((((-0.5 * y) - 1.0) * z) * y) - t;
} else {
tmp = fma((-1.0 + x), log(y), -t);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if ((z <= -2.15e+273) || !(z <= 9.8e+185)) tmp = Float64(Float64(Float64(Float64(Float64(-0.5 * y) - 1.0) * z) * y) - t); else tmp = fma(Float64(-1.0 + x), log(y), Float64(-t)); end return tmp end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -2.15e+273], N[Not[LessEqual[z, 9.8e+185]], $MachinePrecision]], N[(N[(N[(N[(N[(-0.5 * y), $MachinePrecision] - 1.0), $MachinePrecision] * z), $MachinePrecision] * y), $MachinePrecision] - t), $MachinePrecision], N[(N[(-1.0 + x), $MachinePrecision] * N[Log[y], $MachinePrecision] + (-t)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.15 \cdot 10^{+273} \lor \neg \left(z \leq 9.8 \cdot 10^{+185}\right):\\
\;\;\;\;\left(\left(-0.5 \cdot y - 1\right) \cdot z\right) \cdot y - t\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-1 + x, \log y, -t\right)\\
\end{array}
\end{array}
if z < -2.15000000000000008e273 or 9.79999999999999968e185 < z Initial program 44.3%
Taylor expanded in y around 0
+-commutativeN/A
remove-double-negN/A
log-recN/A
mul-1-negN/A
Applied rewrites90.5%
Taylor expanded in z around inf
Applied rewrites74.1%
Taylor expanded in y around 0
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
lower-*.f64N/A
lower--.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower--.f6492.6
Applied rewrites92.6%
Taylor expanded in z around inf
Applied rewrites76.2%
if -2.15000000000000008e273 < z < 9.79999999999999968e185Initial program 95.3%
Taylor expanded in y around 0
*-rgt-identityN/A
fp-cancel-sub-sign-invN/A
Applied rewrites94.6%
Final simplification92.5%
(FPCore (x y z t) :precision binary64 (if (or (<= x -1800.0) (not (<= x 8.5e+36))) (- (* (log y) x) t) (- (- y (log y)) t)))
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -1800.0) || !(x <= 8.5e+36)) {
tmp = (log(y) * x) - t;
} else {
tmp = (y - log(y)) - 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 ((x <= (-1800.0d0)) .or. (.not. (x <= 8.5d+36))) then
tmp = (log(y) * x) - t
else
tmp = (y - log(y)) - t
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -1800.0) || !(x <= 8.5e+36)) {
tmp = (Math.log(y) * x) - t;
} else {
tmp = (y - Math.log(y)) - t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x <= -1800.0) or not (x <= 8.5e+36): tmp = (math.log(y) * x) - t else: tmp = (y - math.log(y)) - t return tmp
function code(x, y, z, t) tmp = 0.0 if ((x <= -1800.0) || !(x <= 8.5e+36)) tmp = Float64(Float64(log(y) * x) - t); else tmp = Float64(Float64(y - log(y)) - t); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x <= -1800.0) || ~((x <= 8.5e+36))) tmp = (log(y) * x) - t; else tmp = (y - log(y)) - t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[x, -1800.0], N[Not[LessEqual[x, 8.5e+36]], $MachinePrecision]], N[(N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision] - t), $MachinePrecision], N[(N[(y - N[Log[y], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1800 \lor \neg \left(x \leq 8.5 \cdot 10^{+36}\right):\\
\;\;\;\;\log y \cdot x - t\\
\mathbf{else}:\\
\;\;\;\;\left(y - \log y\right) - t\\
\end{array}
\end{array}
if x < -1800 or 8.50000000000000014e36 < x Initial program 93.7%
Taylor expanded in x around inf
*-commutativeN/A
remove-double-negN/A
log-recN/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
log-recN/A
remove-double-negN/A
lower-log.f6491.3
Applied rewrites91.3%
if -1800 < x < 8.50000000000000014e36Initial program 86.2%
Taylor expanded in y around 0
+-commutativeN/A
remove-double-negN/A
log-recN/A
mul-1-negN/A
Applied rewrites98.5%
Taylor expanded in z around 0
Applied rewrites84.1%
Taylor expanded in x around 0
Applied rewrites83.7%
Final simplification87.0%
(FPCore (x y z t) :precision binary64 (- (fma (+ -1.0 x) (log y) (fma (- y) z y)) t))
double code(double x, double y, double z, double t) {
return fma((-1.0 + x), log(y), fma(-y, z, y)) - t;
}
function code(x, y, z, t) return Float64(fma(Float64(-1.0 + x), log(y), fma(Float64(-y), z, y)) - t) end
code[x_, y_, z_, t_] := N[(N[(N[(-1.0 + x), $MachinePrecision] * N[Log[y], $MachinePrecision] + N[((-y) * z + y), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(-1 + x, \log y, \mathsf{fma}\left(-y, z, y\right)\right) - t
\end{array}
Initial program 89.5%
Taylor expanded in y around 0
+-commutativeN/A
remove-double-negN/A
log-recN/A
mul-1-negN/A
Applied rewrites98.5%
Taylor expanded in z around 0
Applied rewrites98.5%
(FPCore (x y z t) :precision binary64 (if (or (<= x -2.25e+18) (not (<= x 9.4e+36))) (* (log y) x) (- (- y (log y)) t)))
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -2.25e+18) || !(x <= 9.4e+36)) {
tmp = log(y) * x;
} else {
tmp = (y - log(y)) - 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 ((x <= (-2.25d+18)) .or. (.not. (x <= 9.4d+36))) then
tmp = log(y) * x
else
tmp = (y - log(y)) - t
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -2.25e+18) || !(x <= 9.4e+36)) {
tmp = Math.log(y) * x;
} else {
tmp = (y - Math.log(y)) - t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x <= -2.25e+18) or not (x <= 9.4e+36): tmp = math.log(y) * x else: tmp = (y - math.log(y)) - t return tmp
function code(x, y, z, t) tmp = 0.0 if ((x <= -2.25e+18) || !(x <= 9.4e+36)) tmp = Float64(log(y) * x); else tmp = Float64(Float64(y - log(y)) - t); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x <= -2.25e+18) || ~((x <= 9.4e+36))) tmp = log(y) * x; else tmp = (y - log(y)) - t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[x, -2.25e+18], N[Not[LessEqual[x, 9.4e+36]], $MachinePrecision]], N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision], N[(N[(y - N[Log[y], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.25 \cdot 10^{+18} \lor \neg \left(x \leq 9.4 \cdot 10^{+36}\right):\\
\;\;\;\;\log y \cdot x\\
\mathbf{else}:\\
\;\;\;\;\left(y - \log y\right) - t\\
\end{array}
\end{array}
if x < -2.25e18 or 9.39999999999999978e36 < x Initial program 94.3%
lift--.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate--l+N/A
lift-*.f64N/A
lower-fma.f64N/A
lift-log.f64N/A
lift--.f64N/A
*-lft-identityN/A
fp-cancel-sub-sign-invN/A
distribute-lft-neg-inN/A
*-lft-identityN/A
lower-log1p.f64N/A
lower-neg.f64N/A
lower--.f6499.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.7
Applied rewrites99.7%
Taylor expanded in x around inf
*-commutativeN/A
remove-double-negN/A
mul-1-negN/A
distribute-rgt-neg-inN/A
log-recN/A
lower-*.f64N/A
log-recN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
remove-double-negN/A
lower-log.f6474.9
Applied rewrites74.9%
if -2.25e18 < x < 9.39999999999999978e36Initial program 86.0%
Taylor expanded in y around 0
+-commutativeN/A
remove-double-negN/A
log-recN/A
mul-1-negN/A
Applied rewrites98.5%
Taylor expanded in z around 0
Applied rewrites84.0%
Taylor expanded in x around 0
Applied rewrites83.0%
Final simplification79.6%
(FPCore (x y z t) :precision binary64 (if (or (<= x -2.25e+18) (not (<= x 9.4e+36))) (* (log y) x) (- (+ (log y) t))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -2.25e+18) || !(x <= 9.4e+36)) {
tmp = log(y) * x;
} else {
tmp = -(log(y) + 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 ((x <= (-2.25d+18)) .or. (.not. (x <= 9.4d+36))) then
tmp = log(y) * x
else
tmp = -(log(y) + t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -2.25e+18) || !(x <= 9.4e+36)) {
tmp = Math.log(y) * x;
} else {
tmp = -(Math.log(y) + t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x <= -2.25e+18) or not (x <= 9.4e+36): tmp = math.log(y) * x else: tmp = -(math.log(y) + t) return tmp
function code(x, y, z, t) tmp = 0.0 if ((x <= -2.25e+18) || !(x <= 9.4e+36)) tmp = Float64(log(y) * x); else tmp = Float64(-Float64(log(y) + t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x <= -2.25e+18) || ~((x <= 9.4e+36))) tmp = log(y) * x; else tmp = -(log(y) + t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[x, -2.25e+18], N[Not[LessEqual[x, 9.4e+36]], $MachinePrecision]], N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision], (-N[(N[Log[y], $MachinePrecision] + t), $MachinePrecision])]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.25 \cdot 10^{+18} \lor \neg \left(x \leq 9.4 \cdot 10^{+36}\right):\\
\;\;\;\;\log y \cdot x\\
\mathbf{else}:\\
\;\;\;\;-\left(\log y + t\right)\\
\end{array}
\end{array}
if x < -2.25e18 or 9.39999999999999978e36 < x Initial program 94.3%
lift--.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate--l+N/A
lift-*.f64N/A
lower-fma.f64N/A
lift-log.f64N/A
lift--.f64N/A
*-lft-identityN/A
fp-cancel-sub-sign-invN/A
distribute-lft-neg-inN/A
*-lft-identityN/A
lower-log1p.f64N/A
lower-neg.f64N/A
lower--.f6499.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.7
Applied rewrites99.7%
Taylor expanded in x around inf
*-commutativeN/A
remove-double-negN/A
mul-1-negN/A
distribute-rgt-neg-inN/A
log-recN/A
lower-*.f64N/A
log-recN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
remove-double-negN/A
lower-log.f6474.9
Applied rewrites74.9%
if -2.25e18 < x < 9.39999999999999978e36Initial program 86.0%
Taylor expanded in y around 0
*-rgt-identityN/A
fp-cancel-sub-sign-invN/A
Applied rewrites83.7%
Taylor expanded in x around 0
Applied rewrites82.7%
Final simplification79.4%
(FPCore (x y z t) :precision binary64 (if (or (<= x -4.35e+18) (not (<= x 3e+37))) (* (log y) x) (- (* (* (- (* -0.5 y) 1.0) z) y) t)))
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -4.35e+18) || !(x <= 3e+37)) {
tmp = log(y) * x;
} else {
tmp = ((((-0.5 * y) - 1.0) * z) * y) - 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 ((x <= (-4.35d+18)) .or. (.not. (x <= 3d+37))) then
tmp = log(y) * x
else
tmp = (((((-0.5d0) * y) - 1.0d0) * z) * y) - t
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -4.35e+18) || !(x <= 3e+37)) {
tmp = Math.log(y) * x;
} else {
tmp = ((((-0.5 * y) - 1.0) * z) * y) - t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x <= -4.35e+18) or not (x <= 3e+37): tmp = math.log(y) * x else: tmp = ((((-0.5 * y) - 1.0) * z) * y) - t return tmp
function code(x, y, z, t) tmp = 0.0 if ((x <= -4.35e+18) || !(x <= 3e+37)) tmp = Float64(log(y) * x); else tmp = Float64(Float64(Float64(Float64(Float64(-0.5 * y) - 1.0) * z) * y) - t); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x <= -4.35e+18) || ~((x <= 3e+37))) tmp = log(y) * x; else tmp = ((((-0.5 * y) - 1.0) * z) * y) - t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[x, -4.35e+18], N[Not[LessEqual[x, 3e+37]], $MachinePrecision]], N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision], N[(N[(N[(N[(N[(-0.5 * y), $MachinePrecision] - 1.0), $MachinePrecision] * z), $MachinePrecision] * y), $MachinePrecision] - t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.35 \cdot 10^{+18} \lor \neg \left(x \leq 3 \cdot 10^{+37}\right):\\
\;\;\;\;\log y \cdot x\\
\mathbf{else}:\\
\;\;\;\;\left(\left(-0.5 \cdot y - 1\right) \cdot z\right) \cdot y - t\\
\end{array}
\end{array}
if x < -4.35e18 or 3.00000000000000022e37 < x Initial program 94.3%
lift--.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate--l+N/A
lift-*.f64N/A
lower-fma.f64N/A
lift-log.f64N/A
lift--.f64N/A
*-lft-identityN/A
fp-cancel-sub-sign-invN/A
distribute-lft-neg-inN/A
*-lft-identityN/A
lower-log1p.f64N/A
lower-neg.f64N/A
lower--.f6499.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.7
Applied rewrites99.7%
Taylor expanded in x around inf
*-commutativeN/A
remove-double-negN/A
mul-1-negN/A
distribute-rgt-neg-inN/A
log-recN/A
lower-*.f64N/A
log-recN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
remove-double-negN/A
lower-log.f6474.9
Applied rewrites74.9%
if -4.35e18 < x < 3.00000000000000022e37Initial program 86.0%
Taylor expanded in y around 0
+-commutativeN/A
remove-double-negN/A
log-recN/A
mul-1-negN/A
Applied rewrites98.5%
Taylor expanded in z around inf
Applied rewrites65.3%
Taylor expanded in y around 0
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
lower-*.f64N/A
lower--.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower--.f6499.0
Applied rewrites99.0%
Taylor expanded in z around inf
Applied rewrites65.7%
Final simplification69.6%
(FPCore (x y z t) :precision binary64 (- (* (* (- (* -0.5 y) 1.0) z) y) t))
double code(double x, double y, double z, double t) {
return ((((-0.5 * y) - 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 = (((((-0.5d0) * y) - 1.0d0) * z) * y) - t
end function
public static double code(double x, double y, double z, double t) {
return ((((-0.5 * y) - 1.0) * z) * y) - t;
}
def code(x, y, z, t): return ((((-0.5 * y) - 1.0) * z) * y) - t
function code(x, y, z, t) return Float64(Float64(Float64(Float64(Float64(-0.5 * y) - 1.0) * z) * y) - t) end
function tmp = code(x, y, z, t) tmp = ((((-0.5 * y) - 1.0) * z) * y) - t; end
code[x_, y_, z_, t_] := N[(N[(N[(N[(N[(-0.5 * y), $MachinePrecision] - 1.0), $MachinePrecision] * z), $MachinePrecision] * y), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(-0.5 \cdot y - 1\right) \cdot z\right) \cdot y - t
\end{array}
Initial program 89.5%
Taylor expanded in y around 0
+-commutativeN/A
remove-double-negN/A
log-recN/A
mul-1-negN/A
Applied rewrites98.5%
Taylor expanded in z around inf
Applied rewrites47.5%
Taylor expanded in y around 0
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
lower-*.f64N/A
lower--.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower--.f6498.8
Applied rewrites98.8%
Taylor expanded in z around inf
Applied rewrites47.9%
(FPCore (x y z t) :precision binary64 (- (fma (- y) z y) t))
double code(double x, double y, double z, double t) {
return fma(-y, z, y) - t;
}
function code(x, y, z, t) return Float64(fma(Float64(-y), z, y) - t) end
code[x_, y_, z_, t_] := N[(N[((-y) * z + y), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(-y, z, y\right) - t
\end{array}
Initial program 89.5%
Taylor expanded in y around 0
+-commutativeN/A
remove-double-negN/A
log-recN/A
mul-1-negN/A
Applied rewrites98.5%
Taylor expanded in z around inf
Applied rewrites47.5%
Taylor expanded in y around inf
Applied rewrites47.8%
Taylor expanded in z around 0
Applied rewrites47.8%
(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.5%
Taylor expanded in y around 0
+-commutativeN/A
remove-double-negN/A
log-recN/A
mul-1-negN/A
Applied rewrites98.5%
Taylor expanded in z around inf
Applied rewrites47.5%
(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.5%
Taylor expanded in t around inf
mul-1-negN/A
lower-neg.f6437.5
Applied rewrites37.5%
herbie shell --seed 2024339
(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))