
(FPCore (x y z t) :precision binary64 (+ (- (- (* x (log y)) y) z) (log t)))
double code(double x, double y, double z, double t) {
return (((x * log(y)) - y) - z) + log(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 * log(y)) - y) - z) + log(t)
end function
public static double code(double x, double y, double z, double t) {
return (((x * Math.log(y)) - y) - z) + Math.log(t);
}
def code(x, y, z, t): return (((x * math.log(y)) - y) - z) + math.log(t)
function code(x, y, z, t) return Float64(Float64(Float64(Float64(x * log(y)) - y) - z) + log(t)) end
function tmp = code(x, y, z, t) tmp = (((x * log(y)) - y) - z) + log(t); end
code[x_, y_, z_, t_] := N[(N[(N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision] - z), $MachinePrecision] + N[Log[t], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x \cdot \log y - y\right) - z\right) + \log t
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (+ (- (- (* x (log y)) y) z) (log t)))
double code(double x, double y, double z, double t) {
return (((x * log(y)) - y) - z) + log(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 * log(y)) - y) - z) + log(t)
end function
public static double code(double x, double y, double z, double t) {
return (((x * Math.log(y)) - y) - z) + Math.log(t);
}
def code(x, y, z, t): return (((x * math.log(y)) - y) - z) + math.log(t)
function code(x, y, z, t) return Float64(Float64(Float64(Float64(x * log(y)) - y) - z) + log(t)) end
function tmp = code(x, y, z, t) tmp = (((x * log(y)) - y) - z) + log(t); end
code[x_, y_, z_, t_] := N[(N[(N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision] - z), $MachinePrecision] + N[Log[t], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x \cdot \log y - y\right) - z\right) + \log t
\end{array}
(FPCore (x y z t) :precision binary64 (- (log t) (+ z (+ y (* (log (/ 1.0 y)) x)))))
double code(double x, double y, double z, double t) {
return log(t) - (z + (y + (log((1.0 / y)) * x)));
}
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(t) - (z + (y + (log((1.0d0 / y)) * x)))
end function
public static double code(double x, double y, double z, double t) {
return Math.log(t) - (z + (y + (Math.log((1.0 / y)) * x)));
}
def code(x, y, z, t): return math.log(t) - (z + (y + (math.log((1.0 / y)) * x)))
function code(x, y, z, t) return Float64(log(t) - Float64(z + Float64(y + Float64(log(Float64(1.0 / y)) * x)))) end
function tmp = code(x, y, z, t) tmp = log(t) - (z + (y + (log((1.0 / y)) * x))); end
code[x_, y_, z_, t_] := N[(N[Log[t], $MachinePrecision] - N[(z + N[(y + N[(N[Log[N[(1.0 / y), $MachinePrecision]], $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\log t - \left(z + \left(y + \log \left(\frac{1}{y}\right) \cdot x\right)\right)
\end{array}
Initial program 99.8%
Taylor expanded in y around inf 99.9%
Final simplification99.9%
(FPCore (x y z t) :precision binary64 (if (or (<= z -2.55e+39) (not (<= z 1.65e+15))) (- (log t) (+ y z)) (- (+ (log t) (* x (log y))) y)))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -2.55e+39) || !(z <= 1.65e+15)) {
tmp = log(t) - (y + z);
} else {
tmp = (log(t) + (x * log(y))) - y;
}
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 ((z <= (-2.55d+39)) .or. (.not. (z <= 1.65d+15))) then
tmp = log(t) - (y + z)
else
tmp = (log(t) + (x * log(y))) - y
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -2.55e+39) || !(z <= 1.65e+15)) {
tmp = Math.log(t) - (y + z);
} else {
tmp = (Math.log(t) + (x * Math.log(y))) - y;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -2.55e+39) or not (z <= 1.65e+15): tmp = math.log(t) - (y + z) else: tmp = (math.log(t) + (x * math.log(y))) - y return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -2.55e+39) || !(z <= 1.65e+15)) tmp = Float64(log(t) - Float64(y + z)); else tmp = Float64(Float64(log(t) + Float64(x * log(y))) - y); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -2.55e+39) || ~((z <= 1.65e+15))) tmp = log(t) - (y + z); else tmp = (log(t) + (x * log(y))) - y; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -2.55e+39], N[Not[LessEqual[z, 1.65e+15]], $MachinePrecision]], N[(N[Log[t], $MachinePrecision] - N[(y + z), $MachinePrecision]), $MachinePrecision], N[(N[(N[Log[t], $MachinePrecision] + N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.55 \cdot 10^{+39} \lor \neg \left(z \leq 1.65 \cdot 10^{+15}\right):\\
\;\;\;\;\log t - \left(y + z\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\log t + x \cdot \log y\right) - y\\
\end{array}
\end{array}
if z < -2.5499999999999999e39 or 1.65e15 < z Initial program 99.9%
Taylor expanded in x around 0 82.7%
if -2.5499999999999999e39 < z < 1.65e15Initial program 99.8%
Taylor expanded in z around 0 96.8%
Final simplification90.8%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (+ (log t) (* x (log y))))) (if (or (<= z -0.00172) (not (<= z 1300000.0))) (- t_1 z) (- t_1 y))))
double code(double x, double y, double z, double t) {
double t_1 = log(t) + (x * log(y));
double tmp;
if ((z <= -0.00172) || !(z <= 1300000.0)) {
tmp = t_1 - z;
} else {
tmp = t_1 - y;
}
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(t) + (x * log(y))
if ((z <= (-0.00172d0)) .or. (.not. (z <= 1300000.0d0))) then
tmp = t_1 - z
else
tmp = t_1 - y
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = Math.log(t) + (x * Math.log(y));
double tmp;
if ((z <= -0.00172) || !(z <= 1300000.0)) {
tmp = t_1 - z;
} else {
tmp = t_1 - y;
}
return tmp;
}
def code(x, y, z, t): t_1 = math.log(t) + (x * math.log(y)) tmp = 0 if (z <= -0.00172) or not (z <= 1300000.0): tmp = t_1 - z else: tmp = t_1 - y return tmp
function code(x, y, z, t) t_1 = Float64(log(t) + Float64(x * log(y))) tmp = 0.0 if ((z <= -0.00172) || !(z <= 1300000.0)) tmp = Float64(t_1 - z); else tmp = Float64(t_1 - y); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = log(t) + (x * log(y)); tmp = 0.0; if ((z <= -0.00172) || ~((z <= 1300000.0))) tmp = t_1 - z; else tmp = t_1 - y; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[Log[t], $MachinePrecision] + N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[z, -0.00172], N[Not[LessEqual[z, 1300000.0]], $MachinePrecision]], N[(t$95$1 - z), $MachinePrecision], N[(t$95$1 - y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \log t + x \cdot \log y\\
\mathbf{if}\;z \leq -0.00172 \lor \neg \left(z \leq 1300000\right):\\
\;\;\;\;t_1 - z\\
\mathbf{else}:\\
\;\;\;\;t_1 - y\\
\end{array}
\end{array}
if z < -0.00171999999999999996 or 1.3e6 < z Initial program 99.9%
Taylor expanded in y around 0 84.4%
if -0.00171999999999999996 < z < 1.3e6Initial program 99.8%
Taylor expanded in z around 0 99.8%
Final simplification92.5%
(FPCore (x y z t) :precision binary64 (if (or (<= x -1.55e+83) (not (<= x 1.25e+136))) (+ (log t) (* x (log y))) (- (log t) (+ y z))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -1.55e+83) || !(x <= 1.25e+136)) {
tmp = log(t) + (x * log(y));
} else {
tmp = log(t) - (y + z);
}
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 <= (-1.55d+83)) .or. (.not. (x <= 1.25d+136))) then
tmp = log(t) + (x * log(y))
else
tmp = log(t) - (y + z)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -1.55e+83) || !(x <= 1.25e+136)) {
tmp = Math.log(t) + (x * Math.log(y));
} else {
tmp = Math.log(t) - (y + z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x <= -1.55e+83) or not (x <= 1.25e+136): tmp = math.log(t) + (x * math.log(y)) else: tmp = math.log(t) - (y + z) return tmp
function code(x, y, z, t) tmp = 0.0 if ((x <= -1.55e+83) || !(x <= 1.25e+136)) tmp = Float64(log(t) + Float64(x * log(y))); else tmp = Float64(log(t) - Float64(y + z)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x <= -1.55e+83) || ~((x <= 1.25e+136))) tmp = log(t) + (x * log(y)); else tmp = log(t) - (y + z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[x, -1.55e+83], N[Not[LessEqual[x, 1.25e+136]], $MachinePrecision]], N[(N[Log[t], $MachinePrecision] + N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Log[t], $MachinePrecision] - N[(y + z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.55 \cdot 10^{+83} \lor \neg \left(x \leq 1.25 \cdot 10^{+136}\right):\\
\;\;\;\;\log t + x \cdot \log y\\
\mathbf{else}:\\
\;\;\;\;\log t - \left(y + z\right)\\
\end{array}
\end{array}
if x < -1.54999999999999996e83 or 1.25e136 < x Initial program 99.6%
Taylor expanded in y around 0 88.9%
Taylor expanded in z around 0 76.8%
if -1.54999999999999996e83 < x < 1.25e136Initial program 99.9%
Taylor expanded in x around 0 89.4%
Final simplification85.6%
(FPCore (x y z t) :precision binary64 (+ (log t) (- (- (* x (log y)) y) z)))
double code(double x, double y, double z, double t) {
return log(t) + (((x * log(y)) - y) - z);
}
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(t) + (((x * log(y)) - y) - z)
end function
public static double code(double x, double y, double z, double t) {
return Math.log(t) + (((x * Math.log(y)) - y) - z);
}
def code(x, y, z, t): return math.log(t) + (((x * math.log(y)) - y) - z)
function code(x, y, z, t) return Float64(log(t) + Float64(Float64(Float64(x * log(y)) - y) - z)) end
function tmp = code(x, y, z, t) tmp = log(t) + (((x * log(y)) - y) - z); end
code[x_, y_, z_, t_] := N[(N[Log[t], $MachinePrecision] + N[(N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\log t + \left(\left(x \cdot \log y - y\right) - z\right)
\end{array}
Initial program 99.8%
Final simplification99.8%
(FPCore (x y z t) :precision binary64 (if (or (<= y 1700000000000.0) (and (not (<= y 4.8e+77)) (<= y 1.45e+96))) (- (log t) z) (- (log t) y)))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= 1700000000000.0) || (!(y <= 4.8e+77) && (y <= 1.45e+96))) {
tmp = log(t) - z;
} else {
tmp = log(t) - y;
}
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 ((y <= 1700000000000.0d0) .or. (.not. (y <= 4.8d+77)) .and. (y <= 1.45d+96)) then
tmp = log(t) - z
else
tmp = log(t) - y
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((y <= 1700000000000.0) || (!(y <= 4.8e+77) && (y <= 1.45e+96))) {
tmp = Math.log(t) - z;
} else {
tmp = Math.log(t) - y;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= 1700000000000.0) or (not (y <= 4.8e+77) and (y <= 1.45e+96)): tmp = math.log(t) - z else: tmp = math.log(t) - y return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= 1700000000000.0) || (!(y <= 4.8e+77) && (y <= 1.45e+96))) tmp = Float64(log(t) - z); else tmp = Float64(log(t) - y); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((y <= 1700000000000.0) || (~((y <= 4.8e+77)) && (y <= 1.45e+96))) tmp = log(t) - z; else tmp = log(t) - y; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, 1700000000000.0], And[N[Not[LessEqual[y, 4.8e+77]], $MachinePrecision], LessEqual[y, 1.45e+96]]], N[(N[Log[t], $MachinePrecision] - z), $MachinePrecision], N[(N[Log[t], $MachinePrecision] - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1700000000000 \lor \neg \left(y \leq 4.8 \cdot 10^{+77}\right) \land y \leq 1.45 \cdot 10^{+96}:\\
\;\;\;\;\log t - z\\
\mathbf{else}:\\
\;\;\;\;\log t - y\\
\end{array}
\end{array}
if y < 1.7e12 or 4.7999999999999997e77 < y < 1.44999999999999989e96Initial program 99.8%
Taylor expanded in y around 0 98.6%
Taylor expanded in x around 0 60.8%
if 1.7e12 < y < 4.7999999999999997e77 or 1.44999999999999989e96 < y Initial program 99.9%
Taylor expanded in z around 0 86.1%
Taylor expanded in x around 0 67.9%
Final simplification63.4%
(FPCore (x y z t) :precision binary64 (if (<= z -3.9) (- z) (if (<= z 230000000.0) (- (log t) y) (- z))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -3.9) {
tmp = -z;
} else if (z <= 230000000.0) {
tmp = log(t) - y;
} else {
tmp = -z;
}
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 (z <= (-3.9d0)) then
tmp = -z
else if (z <= 230000000.0d0) then
tmp = log(t) - y
else
tmp = -z
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -3.9) {
tmp = -z;
} else if (z <= 230000000.0) {
tmp = Math.log(t) - y;
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -3.9: tmp = -z elif z <= 230000000.0: tmp = math.log(t) - y else: tmp = -z return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -3.9) tmp = Float64(-z); elseif (z <= 230000000.0) tmp = Float64(log(t) - y); else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -3.9) tmp = -z; elseif (z <= 230000000.0) tmp = log(t) - y; else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -3.9], (-z), If[LessEqual[z, 230000000.0], N[(N[Log[t], $MachinePrecision] - y), $MachinePrecision], (-z)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.9:\\
\;\;\;\;-z\\
\mathbf{elif}\;z \leq 230000000:\\
\;\;\;\;\log t - y\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if z < -3.89999999999999991 or 2.3e8 < z Initial program 99.9%
Taylor expanded in z around inf 63.2%
neg-mul-163.2%
Simplified63.2%
if -3.89999999999999991 < z < 2.3e8Initial program 99.8%
Taylor expanded in z around 0 99.4%
Taylor expanded in x around 0 59.3%
Final simplification61.2%
(FPCore (x y z t) :precision binary64 (if (<= z -3.9) (- z) (if (<= z 102.0) (log t) (- z))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -3.9) {
tmp = -z;
} else if (z <= 102.0) {
tmp = log(t);
} else {
tmp = -z;
}
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 (z <= (-3.9d0)) then
tmp = -z
else if (z <= 102.0d0) then
tmp = log(t)
else
tmp = -z
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -3.9) {
tmp = -z;
} else if (z <= 102.0) {
tmp = Math.log(t);
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -3.9: tmp = -z elif z <= 102.0: tmp = math.log(t) else: tmp = -z return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -3.9) tmp = Float64(-z); elseif (z <= 102.0) tmp = log(t); else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -3.9) tmp = -z; elseif (z <= 102.0) tmp = log(t); else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -3.9], (-z), If[LessEqual[z, 102.0], N[Log[t], $MachinePrecision], (-z)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.9:\\
\;\;\;\;-z\\
\mathbf{elif}\;z \leq 102:\\
\;\;\;\;\log t\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if z < -3.89999999999999991 or 102 < z Initial program 99.9%
Taylor expanded in z around inf 63.2%
neg-mul-163.2%
Simplified63.2%
if -3.89999999999999991 < z < 102Initial program 99.8%
Taylor expanded in y around 0 64.8%
Taylor expanded in x around 0 26.0%
Taylor expanded in z around 0 25.6%
Final simplification43.4%
(FPCore (x y z t) :precision binary64 (- (log t) (+ y z)))
double code(double x, double y, double z, double t) {
return log(t) - (y + z);
}
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(t) - (y + z)
end function
public static double code(double x, double y, double z, double t) {
return Math.log(t) - (y + z);
}
def code(x, y, z, t): return math.log(t) - (y + z)
function code(x, y, z, t) return Float64(log(t) - Float64(y + z)) end
function tmp = code(x, y, z, t) tmp = log(t) - (y + z); end
code[x_, y_, z_, t_] := N[(N[Log[t], $MachinePrecision] - N[(y + z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\log t - \left(y + z\right)
\end{array}
Initial program 99.8%
Taylor expanded in x around 0 68.8%
Final simplification68.8%
(FPCore (x y z t) :precision binary64 (- z))
double code(double x, double y, double z, double t) {
return -z;
}
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
end function
public static double code(double x, double y, double z, double t) {
return -z;
}
def code(x, y, z, t): return -z
function code(x, y, z, t) return Float64(-z) end
function tmp = code(x, y, z, t) tmp = -z; end
code[x_, y_, z_, t_] := (-z)
\begin{array}{l}
\\
-z
\end{array}
Initial program 99.8%
Taylor expanded in z around inf 31.3%
neg-mul-131.3%
Simplified31.3%
Final simplification31.3%
herbie shell --seed 2023257
(FPCore (x y z t)
:name "Numeric.SpecFunctions:incompleteGamma from math-functions-0.1.5.2, A"
:precision binary64
(+ (- (- (* x (log y)) y) z) (log t)))