
(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 8 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 (+ (- (- (* 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}
Initial program 99.8%
Final simplification99.8%
(FPCore (x y z t) :precision binary64 (if (or (<= x -8.8e+61) (not (<= x 6.5e+40))) (- (+ (log t) (* x (log y))) y) (- (log t) (+ y z))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -8.8e+61) || !(x <= 6.5e+40)) {
tmp = (log(t) + (x * log(y))) - 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 <= (-8.8d+61)) .or. (.not. (x <= 6.5d+40))) then
tmp = (log(t) + (x * log(y))) - 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 <= -8.8e+61) || !(x <= 6.5e+40)) {
tmp = (Math.log(t) + (x * Math.log(y))) - y;
} else {
tmp = Math.log(t) - (y + z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x <= -8.8e+61) or not (x <= 6.5e+40): tmp = (math.log(t) + (x * math.log(y))) - y else: tmp = math.log(t) - (y + z) return tmp
function code(x, y, z, t) tmp = 0.0 if ((x <= -8.8e+61) || !(x <= 6.5e+40)) tmp = Float64(Float64(log(t) + Float64(x * log(y))) - 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 <= -8.8e+61) || ~((x <= 6.5e+40))) tmp = (log(t) + (x * log(y))) - y; else tmp = log(t) - (y + z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[x, -8.8e+61], N[Not[LessEqual[x, 6.5e+40]], $MachinePrecision]], N[(N[(N[Log[t], $MachinePrecision] + N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision], N[(N[Log[t], $MachinePrecision] - N[(y + z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -8.8 \cdot 10^{+61} \lor \neg \left(x \leq 6.5 \cdot 10^{+40}\right):\\
\;\;\;\;\left(\log t + x \cdot \log y\right) - y\\
\mathbf{else}:\\
\;\;\;\;\log t - \left(y + z\right)\\
\end{array}
\end{array}
if x < -8.8000000000000001e61 or 6.5000000000000001e40 < x Initial program 99.7%
Taylor expanded in z around 0 90.2%
if -8.8000000000000001e61 < x < 6.5000000000000001e40Initial program 100.0%
Taylor expanded in x around 0 94.6%
Final simplification92.9%
(FPCore (x y z t) :precision binary64 (if (or (<= x -6.1e+66) (not (<= x 7.6e+105))) (+ (log t) (* x (log y))) (- (log t) (+ y z))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -6.1e+66) || !(x <= 7.6e+105)) {
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 <= (-6.1d+66)) .or. (.not. (x <= 7.6d+105))) 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 <= -6.1e+66) || !(x <= 7.6e+105)) {
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 <= -6.1e+66) or not (x <= 7.6e+105): 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 <= -6.1e+66) || !(x <= 7.6e+105)) 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 <= -6.1e+66) || ~((x <= 7.6e+105))) 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, -6.1e+66], N[Not[LessEqual[x, 7.6e+105]], $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 -6.1 \cdot 10^{+66} \lor \neg \left(x \leq 7.6 \cdot 10^{+105}\right):\\
\;\;\;\;\log t + x \cdot \log y\\
\mathbf{else}:\\
\;\;\;\;\log t - \left(y + z\right)\\
\end{array}
\end{array}
if x < -6.10000000000000021e66 or 7.6e105 < x Initial program 99.6%
Taylor expanded in z around 0 91.7%
Taylor expanded in y around 0 77.9%
if -6.10000000000000021e66 < x < 7.6e105Initial program 100.0%
Taylor expanded in x around 0 93.6%
Final simplification87.9%
(FPCore (x y z t) :precision binary64 (if (<= z -3.5e+113) (- z) (if (<= z 1.95e+37) (- (log t) y) (- z))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -3.5e+113) {
tmp = -z;
} else if (z <= 1.95e+37) {
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.5d+113)) then
tmp = -z
else if (z <= 1.95d+37) 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.5e+113) {
tmp = -z;
} else if (z <= 1.95e+37) {
tmp = Math.log(t) - y;
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -3.5e+113: tmp = -z elif z <= 1.95e+37: tmp = math.log(t) - y else: tmp = -z return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -3.5e+113) tmp = Float64(-z); elseif (z <= 1.95e+37) 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.5e+113) tmp = -z; elseif (z <= 1.95e+37) tmp = log(t) - y; else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -3.5e+113], (-z), If[LessEqual[z, 1.95e+37], N[(N[Log[t], $MachinePrecision] - y), $MachinePrecision], (-z)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.5 \cdot 10^{+113}:\\
\;\;\;\;-z\\
\mathbf{elif}\;z \leq 1.95 \cdot 10^{+37}:\\
\;\;\;\;\log t - y\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if z < -3.5000000000000001e113 or 1.9499999999999999e37 < z Initial program 99.9%
Taylor expanded in z around inf 59.7%
mul-1-neg59.7%
Simplified59.7%
if -3.5000000000000001e113 < z < 1.9499999999999999e37Initial program 99.8%
Taylor expanded in x around 0 58.9%
Taylor expanded in z around 0 53.5%
Final simplification56.0%
(FPCore (x y z t) :precision binary64 (if (<= y 8.2e+68) (- (log t) z) (- y)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 8.2e+68) {
tmp = log(t) - z;
} else {
tmp = -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 <= 8.2d+68) then
tmp = log(t) - z
else
tmp = -y
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 8.2e+68) {
tmp = Math.log(t) - z;
} else {
tmp = -y;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 8.2e+68: tmp = math.log(t) - z else: tmp = -y return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 8.2e+68) tmp = Float64(log(t) - z); else tmp = Float64(-y); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 8.2e+68) tmp = log(t) - z; else tmp = -y; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 8.2e+68], N[(N[Log[t], $MachinePrecision] - z), $MachinePrecision], (-y)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 8.2 \cdot 10^{+68}:\\
\;\;\;\;\log t - z\\
\mathbf{else}:\\
\;\;\;\;-y\\
\end{array}
\end{array}
if y < 8.1999999999999998e68Initial program 99.8%
Taylor expanded in x around 0 60.2%
Taylor expanded in y around 0 54.7%
if 8.1999999999999998e68 < y Initial program 99.9%
Taylor expanded in y around inf 66.1%
neg-mul-166.1%
Simplified66.1%
Final simplification59.1%
(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 67.7%
Final simplification67.7%
(FPCore (x y z t) :precision binary64 (if (<= y 6.2e+66) (- z) (- y)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 6.2e+66) {
tmp = -z;
} else {
tmp = -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 <= 6.2d+66) then
tmp = -z
else
tmp = -y
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 6.2e+66) {
tmp = -z;
} else {
tmp = -y;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 6.2e+66: tmp = -z else: tmp = -y return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 6.2e+66) tmp = Float64(-z); else tmp = Float64(-y); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 6.2e+66) tmp = -z; else tmp = -y; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 6.2e+66], (-z), (-y)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 6.2 \cdot 10^{+66}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;-y\\
\end{array}
\end{array}
if y < 6.20000000000000037e66Initial program 99.8%
Taylor expanded in z around inf 37.0%
mul-1-neg37.0%
Simplified37.0%
if 6.20000000000000037e66 < y Initial program 99.9%
Taylor expanded in y around inf 66.1%
neg-mul-166.1%
Simplified66.1%
Final simplification48.3%
(FPCore (x y z t) :precision binary64 (- y))
double code(double x, double y, double z, double t) {
return -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 = -y
end function
public static double code(double x, double y, double z, double t) {
return -y;
}
def code(x, y, z, t): return -y
function code(x, y, z, t) return Float64(-y) end
function tmp = code(x, y, z, t) tmp = -y; end
code[x_, y_, z_, t_] := (-y)
\begin{array}{l}
\\
-y
\end{array}
Initial program 99.8%
Taylor expanded in y around inf 29.3%
neg-mul-129.3%
Simplified29.3%
Final simplification29.3%
herbie shell --seed 2023242
(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)))