
(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 10 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) (+ -1.0 x))) t))
double code(double x, double y, double z, double t) {
return fma((z + -1.0), log1p(-y), (log(y) * (-1.0 + x))) - t;
}
function code(x, y, z, t) return Float64(fma(Float64(z + -1.0), log1p(Float64(-y)), Float64(log(y) * Float64(-1.0 + x))) - t) end
code[x_, y_, z_, t_] := N[(N[(N[(z + -1.0), $MachinePrecision] * N[Log[1 + (-y)], $MachinePrecision] + N[(N[Log[y], $MachinePrecision] * N[(-1.0 + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(z + -1, \mathsf{log1p}\left(-y\right), \log y \cdot \left(-1 + x\right)\right) - t
\end{array}
Initial program 89.8%
+-commutative89.8%
fma-def89.8%
sub-neg89.8%
metadata-eval89.8%
sub-neg89.8%
log1p-def99.8%
sub-neg99.8%
metadata-eval99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (x y z t) :precision binary64 (- (+ (- (* -0.5 (* (+ z -1.0) (pow y 2.0))) (* y (+ z -1.0))) (* (log y) (+ -1.0 x))) t))
double code(double x, double y, double z, double t) {
return (((-0.5 * ((z + -1.0) * pow(y, 2.0))) - (y * (z + -1.0))) + (log(y) * (-1.0 + x))) - 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) * ((z + (-1.0d0)) * (y ** 2.0d0))) - (y * (z + (-1.0d0)))) + (log(y) * ((-1.0d0) + x))) - t
end function
public static double code(double x, double y, double z, double t) {
return (((-0.5 * ((z + -1.0) * Math.pow(y, 2.0))) - (y * (z + -1.0))) + (Math.log(y) * (-1.0 + x))) - t;
}
def code(x, y, z, t): return (((-0.5 * ((z + -1.0) * math.pow(y, 2.0))) - (y * (z + -1.0))) + (math.log(y) * (-1.0 + x))) - t
function code(x, y, z, t) return Float64(Float64(Float64(Float64(-0.5 * Float64(Float64(z + -1.0) * (y ^ 2.0))) - Float64(y * Float64(z + -1.0))) + Float64(log(y) * Float64(-1.0 + x))) - t) end
function tmp = code(x, y, z, t) tmp = (((-0.5 * ((z + -1.0) * (y ^ 2.0))) - (y * (z + -1.0))) + (log(y) * (-1.0 + x))) - t; end
code[x_, y_, z_, t_] := N[(N[(N[(N[(-0.5 * N[(N[(z + -1.0), $MachinePrecision] * N[Power[y, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(y * N[(z + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Log[y], $MachinePrecision] * N[(-1.0 + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(-0.5 \cdot \left(\left(z + -1\right) \cdot {y}^{2}\right) - y \cdot \left(z + -1\right)\right) + \log y \cdot \left(-1 + x\right)\right) - t
\end{array}
Initial program 89.8%
Taylor expanded in y around 0 99.7%
Final simplification99.7%
(FPCore (x y z t) :precision binary64 (if (or (<= (+ -1.0 x) -100000000000.0) (not (<= (+ -1.0 x) -0.995))) (- (* (log y) (+ -1.0 x)) t) (- (- (* (- y) (+ z -1.0)) (log y)) t)))
double code(double x, double y, double z, double t) {
double tmp;
if (((-1.0 + x) <= -100000000000.0) || !((-1.0 + x) <= -0.995)) {
tmp = (log(y) * (-1.0 + x)) - t;
} else {
tmp = ((-y * (z + -1.0)) - 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 ((((-1.0d0) + x) <= (-100000000000.0d0)) .or. (.not. (((-1.0d0) + x) <= (-0.995d0)))) then
tmp = (log(y) * ((-1.0d0) + x)) - t
else
tmp = ((-y * (z + (-1.0d0))) - log(y)) - t
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (((-1.0 + x) <= -100000000000.0) || !((-1.0 + x) <= -0.995)) {
tmp = (Math.log(y) * (-1.0 + x)) - t;
} else {
tmp = ((-y * (z + -1.0)) - Math.log(y)) - t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if ((-1.0 + x) <= -100000000000.0) or not ((-1.0 + x) <= -0.995): tmp = (math.log(y) * (-1.0 + x)) - t else: tmp = ((-y * (z + -1.0)) - math.log(y)) - t return tmp
function code(x, y, z, t) tmp = 0.0 if ((Float64(-1.0 + x) <= -100000000000.0) || !(Float64(-1.0 + x) <= -0.995)) tmp = Float64(Float64(log(y) * Float64(-1.0 + x)) - t); else tmp = Float64(Float64(Float64(Float64(-y) * Float64(z + -1.0)) - log(y)) - t); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (((-1.0 + x) <= -100000000000.0) || ~(((-1.0 + x) <= -0.995))) tmp = (log(y) * (-1.0 + x)) - t; else tmp = ((-y * (z + -1.0)) - log(y)) - t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[N[(-1.0 + x), $MachinePrecision], -100000000000.0], N[Not[LessEqual[N[(-1.0 + x), $MachinePrecision], -0.995]], $MachinePrecision]], N[(N[(N[Log[y], $MachinePrecision] * N[(-1.0 + x), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision], N[(N[(N[((-y) * N[(z + -1.0), $MachinePrecision]), $MachinePrecision] - N[Log[y], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;-1 + x \leq -100000000000 \lor \neg \left(-1 + x \leq -0.995\right):\\
\;\;\;\;\log y \cdot \left(-1 + x\right) - t\\
\mathbf{else}:\\
\;\;\;\;\left(\left(-y\right) \cdot \left(z + -1\right) - \log y\right) - t\\
\end{array}
\end{array}
if (-.f64 x 1) < -1e11 or -0.994999999999999996 < (-.f64 x 1) Initial program 96.0%
+-commutative96.0%
fma-def96.0%
sub-neg96.0%
metadata-eval96.0%
sub-neg96.0%
log1p-def99.7%
sub-neg99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in y around 0 95.2%
if -1e11 < (-.f64 x 1) < -0.994999999999999996Initial program 83.6%
Taylor expanded in x around 0 83.6%
+-commutative83.6%
sub-neg83.6%
metadata-eval83.6%
fma-def83.6%
sub-neg83.6%
mul-1-neg83.6%
log1p-def99.9%
mul-1-neg99.9%
+-commutative99.9%
mul-1-neg99.9%
Simplified99.9%
Taylor expanded in y around 0 99.7%
mul-1-neg99.7%
+-commutative99.7%
unsub-neg99.7%
sub-neg99.7%
metadata-eval99.7%
associate-*r*99.7%
mul-1-neg99.7%
+-commutative99.7%
Simplified99.7%
Final simplification97.4%
(FPCore (x y z t)
:precision binary64
(if (<= z -3.9e+282)
(- (* x (log y)) t)
(if (or (<= z -1.6e+221) (not (<= z 4.7e+250)))
(- (* z (log1p (- y))) t)
(- (* (log y) (+ -1.0 x)) t))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -3.9e+282) {
tmp = (x * log(y)) - t;
} else if ((z <= -1.6e+221) || !(z <= 4.7e+250)) {
tmp = (z * log1p(-y)) - t;
} else {
tmp = (log(y) * (-1.0 + x)) - t;
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -3.9e+282) {
tmp = (x * Math.log(y)) - t;
} else if ((z <= -1.6e+221) || !(z <= 4.7e+250)) {
tmp = (z * Math.log1p(-y)) - t;
} else {
tmp = (Math.log(y) * (-1.0 + x)) - t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -3.9e+282: tmp = (x * math.log(y)) - t elif (z <= -1.6e+221) or not (z <= 4.7e+250): tmp = (z * math.log1p(-y)) - t else: tmp = (math.log(y) * (-1.0 + x)) - t return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -3.9e+282) tmp = Float64(Float64(x * log(y)) - t); elseif ((z <= -1.6e+221) || !(z <= 4.7e+250)) tmp = Float64(Float64(z * log1p(Float64(-y))) - t); else tmp = Float64(Float64(log(y) * Float64(-1.0 + x)) - t); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[z, -3.9e+282], N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision], If[Or[LessEqual[z, -1.6e+221], N[Not[LessEqual[z, 4.7e+250]], $MachinePrecision]], N[(N[(z * N[Log[1 + (-y)], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision], N[(N[(N[Log[y], $MachinePrecision] * N[(-1.0 + x), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.9 \cdot 10^{+282}:\\
\;\;\;\;x \cdot \log y - t\\
\mathbf{elif}\;z \leq -1.6 \cdot 10^{+221} \lor \neg \left(z \leq 4.7 \cdot 10^{+250}\right):\\
\;\;\;\;z \cdot \mathsf{log1p}\left(-y\right) - t\\
\mathbf{else}:\\
\;\;\;\;\log y \cdot \left(-1 + x\right) - t\\
\end{array}
\end{array}
if z < -3.8999999999999998e282Initial program 99.6%
Taylor expanded in y around 0 99.6%
Taylor expanded in x around inf 99.6%
*-commutative99.6%
Simplified99.6%
if -3.8999999999999998e282 < z < -1.6e221 or 4.6999999999999999e250 < z Initial program 35.8%
Taylor expanded in z around inf 21.3%
*-commutative21.3%
sub-neg21.3%
mul-1-neg21.3%
log1p-def83.3%
mul-1-neg83.3%
Simplified83.3%
if -1.6e221 < z < 4.6999999999999999e250Initial program 96.1%
+-commutative96.1%
fma-def96.1%
sub-neg96.1%
metadata-eval96.1%
sub-neg96.1%
log1p-def99.8%
sub-neg99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around 0 95.2%
Final simplification94.1%
(FPCore (x y z t) :precision binary64 (- (- (* (log y) (+ -1.0 x)) (* y (+ z -1.0))) t))
double code(double x, double y, double z, double t) {
return ((log(y) * (-1.0 + x)) - (y * (z + -1.0))) - 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 = ((log(y) * ((-1.0d0) + x)) - (y * (z + (-1.0d0)))) - t
end function
public static double code(double x, double y, double z, double t) {
return ((Math.log(y) * (-1.0 + x)) - (y * (z + -1.0))) - t;
}
def code(x, y, z, t): return ((math.log(y) * (-1.0 + x)) - (y * (z + -1.0))) - t
function code(x, y, z, t) return Float64(Float64(Float64(log(y) * Float64(-1.0 + x)) - Float64(y * Float64(z + -1.0))) - t) end
function tmp = code(x, y, z, t) tmp = ((log(y) * (-1.0 + x)) - (y * (z + -1.0))) - t; end
code[x_, y_, z_, t_] := N[(N[(N[(N[Log[y], $MachinePrecision] * N[(-1.0 + x), $MachinePrecision]), $MachinePrecision] - N[(y * N[(z + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\left(\log y \cdot \left(-1 + x\right) - y \cdot \left(z + -1\right)\right) - t
\end{array}
Initial program 89.8%
Taylor expanded in y around 0 99.4%
+-commutative99.4%
sub-neg99.4%
metadata-eval99.4%
*-commutative99.4%
mul-1-neg99.4%
unsub-neg99.4%
*-commutative99.4%
+-commutative99.4%
sub-neg99.4%
metadata-eval99.4%
+-commutative99.4%
Simplified99.4%
Final simplification99.4%
(FPCore (x y z t) :precision binary64 (if (or (<= x -16200000.0) (not (<= x 1.0))) (- (* x (log y)) t) (- (log (/ (+ y 1.0) y)) t)))
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -16200000.0) || !(x <= 1.0)) {
tmp = (x * log(y)) - t;
} else {
tmp = log(((y + 1.0) / 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 <= (-16200000.0d0)) .or. (.not. (x <= 1.0d0))) then
tmp = (x * log(y)) - t
else
tmp = log(((y + 1.0d0) / y)) - t
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -16200000.0) || !(x <= 1.0)) {
tmp = (x * Math.log(y)) - t;
} else {
tmp = Math.log(((y + 1.0) / y)) - t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x <= -16200000.0) or not (x <= 1.0): tmp = (x * math.log(y)) - t else: tmp = math.log(((y + 1.0) / y)) - t return tmp
function code(x, y, z, t) tmp = 0.0 if ((x <= -16200000.0) || !(x <= 1.0)) tmp = Float64(Float64(x * log(y)) - t); else tmp = Float64(log(Float64(Float64(y + 1.0) / y)) - t); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x <= -16200000.0) || ~((x <= 1.0))) tmp = (x * log(y)) - t; else tmp = log(((y + 1.0) / y)) - t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[x, -16200000.0], N[Not[LessEqual[x, 1.0]], $MachinePrecision]], N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision], N[(N[Log[N[(N[(y + 1.0), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision] - t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -16200000 \lor \neg \left(x \leq 1\right):\\
\;\;\;\;x \cdot \log y - t\\
\mathbf{else}:\\
\;\;\;\;\log \left(\frac{y + 1}{y}\right) - t\\
\end{array}
\end{array}
if x < -1.62e7 or 1 < x Initial program 96.0%
Taylor expanded in y around 0 99.5%
Taylor expanded in x around inf 95.0%
*-commutative95.0%
Simplified95.0%
if -1.62e7 < x < 1Initial program 83.7%
Taylor expanded in x around 0 83.1%
+-commutative83.1%
sub-neg83.1%
metadata-eval83.1%
fma-def83.1%
sub-neg83.1%
mul-1-neg83.1%
log1p-def99.4%
mul-1-neg99.4%
+-commutative99.4%
mul-1-neg99.4%
Simplified99.4%
Taylor expanded in z around 0 82.5%
mul-1-neg82.5%
sub-neg82.5%
mul-1-neg82.5%
log1p-def82.5%
mul-1-neg82.5%
Simplified82.5%
add-log-exp82.5%
diff-log82.6%
add-sqr-sqrt82.6%
sqrt-unprod82.6%
sqr-neg82.6%
sqrt-unprod0.0%
add-sqr-sqrt82.0%
log1p-udef82.0%
add-exp-log82.0%
add-sqr-sqrt0.0%
sqrt-unprod82.5%
sqr-neg82.5%
sqrt-unprod82.5%
add-sqr-sqrt82.5%
Applied egg-rr82.5%
Final simplification88.7%
(FPCore (x y z t) :precision binary64 (if (or (<= x -16200000.0) (not (<= x 1.0))) (- (* x (log y)) t) (- (- (log y)) t)))
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -16200000.0) || !(x <= 1.0)) {
tmp = (x * log(y)) - t;
} 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 <= (-16200000.0d0)) .or. (.not. (x <= 1.0d0))) then
tmp = (x * log(y)) - t
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 <= -16200000.0) || !(x <= 1.0)) {
tmp = (x * Math.log(y)) - t;
} else {
tmp = -Math.log(y) - t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x <= -16200000.0) or not (x <= 1.0): tmp = (x * math.log(y)) - t else: tmp = -math.log(y) - t return tmp
function code(x, y, z, t) tmp = 0.0 if ((x <= -16200000.0) || !(x <= 1.0)) tmp = Float64(Float64(x * log(y)) - t); else tmp = Float64(Float64(-log(y)) - t); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x <= -16200000.0) || ~((x <= 1.0))) tmp = (x * log(y)) - t; else tmp = -log(y) - t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[x, -16200000.0], N[Not[LessEqual[x, 1.0]], $MachinePrecision]], N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision], N[((-N[Log[y], $MachinePrecision]) - t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -16200000 \lor \neg \left(x \leq 1\right):\\
\;\;\;\;x \cdot \log y - t\\
\mathbf{else}:\\
\;\;\;\;\left(-\log y\right) - t\\
\end{array}
\end{array}
if x < -1.62e7 or 1 < x Initial program 96.0%
Taylor expanded in y around 0 99.5%
Taylor expanded in x around inf 95.0%
*-commutative95.0%
Simplified95.0%
if -1.62e7 < x < 1Initial program 83.7%
+-commutative83.7%
fma-def83.7%
sub-neg83.7%
metadata-eval83.7%
sub-neg83.7%
log1p-def99.9%
sub-neg99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in y around 0 82.5%
fma-neg82.5%
sub-neg82.5%
metadata-eval82.5%
+-commutative82.5%
Simplified82.5%
Taylor expanded in x around 0 82.0%
mul-1-neg82.0%
Simplified82.0%
Final simplification88.5%
(FPCore (x y z t) :precision binary64 (if (or (<= x -16200000.0) (not (<= x 1.0))) (- (* x (log y)) t) (- (- y (log y)) t)))
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -16200000.0) || !(x <= 1.0)) {
tmp = (x * log(y)) - 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 <= (-16200000.0d0)) .or. (.not. (x <= 1.0d0))) then
tmp = (x * log(y)) - 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 <= -16200000.0) || !(x <= 1.0)) {
tmp = (x * Math.log(y)) - t;
} else {
tmp = (y - Math.log(y)) - t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x <= -16200000.0) or not (x <= 1.0): tmp = (x * math.log(y)) - t else: tmp = (y - math.log(y)) - t return tmp
function code(x, y, z, t) tmp = 0.0 if ((x <= -16200000.0) || !(x <= 1.0)) tmp = Float64(Float64(x * log(y)) - 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 <= -16200000.0) || ~((x <= 1.0))) tmp = (x * log(y)) - t; else tmp = (y - log(y)) - t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[x, -16200000.0], N[Not[LessEqual[x, 1.0]], $MachinePrecision]], N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision], N[(N[(y - N[Log[y], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -16200000 \lor \neg \left(x \leq 1\right):\\
\;\;\;\;x \cdot \log y - t\\
\mathbf{else}:\\
\;\;\;\;\left(y - \log y\right) - t\\
\end{array}
\end{array}
if x < -1.62e7 or 1 < x Initial program 96.0%
Taylor expanded in y around 0 99.5%
Taylor expanded in x around inf 95.0%
*-commutative95.0%
Simplified95.0%
if -1.62e7 < x < 1Initial program 83.7%
Taylor expanded in x around 0 83.1%
+-commutative83.1%
sub-neg83.1%
metadata-eval83.1%
fma-def83.1%
sub-neg83.1%
mul-1-neg83.1%
log1p-def99.4%
mul-1-neg99.4%
+-commutative99.4%
mul-1-neg99.4%
Simplified99.4%
Taylor expanded in z around 0 82.5%
mul-1-neg82.5%
sub-neg82.5%
mul-1-neg82.5%
log1p-def82.5%
mul-1-neg82.5%
Simplified82.5%
Taylor expanded in y around 0 82.5%
neg-mul-182.5%
unsub-neg82.5%
Simplified82.5%
Final simplification88.7%
(FPCore (x y z t) :precision binary64 (- (- (log y)) t))
double code(double x, double y, double z, double t) {
return -log(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 = -log(y) - t
end function
public static double code(double x, double y, double z, double t) {
return -Math.log(y) - t;
}
def code(x, y, z, t): return -math.log(y) - t
function code(x, y, z, t) return Float64(Float64(-log(y)) - t) end
function tmp = code(x, y, z, t) tmp = -log(y) - t; end
code[x_, y_, z_, t_] := N[((-N[Log[y], $MachinePrecision]) - t), $MachinePrecision]
\begin{array}{l}
\\
\left(-\log y\right) - t
\end{array}
Initial program 89.8%
+-commutative89.8%
fma-def89.8%
sub-neg89.8%
metadata-eval89.8%
sub-neg89.8%
log1p-def99.8%
sub-neg99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around 0 88.9%
fma-neg88.9%
sub-neg88.9%
metadata-eval88.9%
+-commutative88.9%
Simplified88.9%
Taylor expanded in x around 0 53.1%
mul-1-neg53.1%
Simplified53.1%
Final simplification53.1%
(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.8%
+-commutative89.8%
fma-def89.8%
sub-neg89.8%
metadata-eval89.8%
sub-neg89.8%
log1p-def99.8%
sub-neg99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in t around inf 33.6%
neg-mul-133.6%
Simplified33.6%
Final simplification33.6%
herbie shell --seed 2024010
(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))