
(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 5 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)) t))
double code(double x, double y, double z, double t) {
return ((x - 1.0) * 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 = ((x - 1.0d0) * log(y)) - t
end function
public static double code(double x, double y, double z, double t) {
return ((x - 1.0) * Math.log(y)) - t;
}
def code(x, y, z, t): return ((x - 1.0) * math.log(y)) - t
function code(x, y, z, t) return Float64(Float64(Float64(x - 1.0) * log(y)) - t) end
function tmp = code(x, y, z, t) tmp = ((x - 1.0) * log(y)) - t; end
code[x_, y_, z_, t_] := N[(N[(N[(x - 1.0), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\left(x - 1\right) \cdot \log y - t
\end{array}
Initial program 90.7%
Taylor expanded in x around 0
Applied rewrites90.7%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (- (log y) t))) (if (<= t -1.2e+90) t_1 (if (<= t 5e+86) (* (- x 1.0) (log y)) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = log(y) - t;
double tmp;
if (t <= -1.2e+90) {
tmp = t_1;
} else if (t <= 5e+86) {
tmp = (x - 1.0) * 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 = log(y) - t
if (t <= (-1.2d+90)) then
tmp = t_1
else if (t <= 5d+86) then
tmp = (x - 1.0d0) * 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) - t;
double tmp;
if (t <= -1.2e+90) {
tmp = t_1;
} else if (t <= 5e+86) {
tmp = (x - 1.0) * Math.log(y);
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = math.log(y) - t tmp = 0 if t <= -1.2e+90: tmp = t_1 elif t <= 5e+86: tmp = (x - 1.0) * math.log(y) else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(log(y) - t) tmp = 0.0 if (t <= -1.2e+90) tmp = t_1; elseif (t <= 5e+86) tmp = Float64(Float64(x - 1.0) * log(y)); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = log(y) - t; tmp = 0.0; if (t <= -1.2e+90) tmp = t_1; elseif (t <= 5e+86) tmp = (x - 1.0) * 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] - t), $MachinePrecision]}, If[LessEqual[t, -1.2e+90], t$95$1, If[LessEqual[t, 5e+86], N[(N[(x - 1.0), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \log y - t\\
\mathbf{if}\;t \leq -1.2 \cdot 10^{+90}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 5 \cdot 10^{+86}:\\
\;\;\;\;\left(x - 1\right) \cdot \log y\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -1.20000000000000005e90 or 4.9999999999999998e86 < t Initial program 98.2%
Taylor expanded in x around 0
Applied rewrites19.2%
Taylor expanded in x around 0
Applied rewrites19.2%
Taylor expanded in x around 0
Applied rewrites17.1%
Taylor expanded in y around 0
Applied rewrites80.3%
if -1.20000000000000005e90 < t < 4.9999999999999998e86Initial program 84.5%
Taylor expanded in x around 0
Applied rewrites78.3%
Taylor expanded in x around 0
Applied rewrites78.3%
(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(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}
\\
\log y - t
\end{array}
Initial program 90.7%
Taylor expanded in x around 0
Applied rewrites51.5%
Taylor expanded in x around 0
Applied rewrites51.5%
Taylor expanded in x around 0
Applied rewrites50.4%
Taylor expanded in y around 0
Applied rewrites40.9%
(FPCore (x y z t) :precision binary64 (- (- x 1.0) t))
double code(double x, double y, double z, double t) {
return (x - 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 = (x - 1.0d0) - t
end function
public static double code(double x, double y, double z, double t) {
return (x - 1.0) - t;
}
def code(x, y, z, t): return (x - 1.0) - t
function code(x, y, z, t) return Float64(Float64(x - 1.0) - t) end
function tmp = code(x, y, z, t) tmp = (x - 1.0) - t; end
code[x_, y_, z_, t_] := N[(N[(x - 1.0), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}
\\
\left(x - 1\right) - t
\end{array}
Initial program 90.7%
Taylor expanded in x around 0
Applied rewrites40.0%
(FPCore (x y z t) :precision binary64 (- 1.0 y))
double code(double x, double y, double z, double t) {
return 1.0 - y;
}
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 - y
end function
public static double code(double x, double y, double z, double t) {
return 1.0 - y;
}
def code(x, y, z, t): return 1.0 - y
function code(x, y, z, t) return Float64(1.0 - y) end
function tmp = code(x, y, z, t) tmp = 1.0 - y; end
code[x_, y_, z_, t_] := N[(1.0 - y), $MachinePrecision]
\begin{array}{l}
\\
1 - y
\end{array}
Initial program 90.7%
Taylor expanded in x around 0
Applied rewrites51.5%
Taylor expanded in x around 0
Applied rewrites51.5%
Taylor expanded in x around -inf
Applied rewrites4.3%
herbie shell --seed 2024313
(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))