
(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 9 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.9%
Final simplification99.9%
(FPCore (x y z t) :precision binary64 (if (or (<= z -1.12e+18) (not (<= z 3.7e+39))) (- (- z) y) (- (+ (* x (log y)) (log t)) y)))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -1.12e+18) || !(z <= 3.7e+39)) {
tmp = -z - y;
} else {
tmp = ((x * log(y)) + 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 ((z <= (-1.12d+18)) .or. (.not. (z <= 3.7d+39))) then
tmp = -z - y
else
tmp = ((x * log(y)) + log(t)) - y
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -1.12e+18) || !(z <= 3.7e+39)) {
tmp = -z - y;
} else {
tmp = ((x * Math.log(y)) + Math.log(t)) - y;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -1.12e+18) or not (z <= 3.7e+39): tmp = -z - y else: tmp = ((x * math.log(y)) + math.log(t)) - y return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -1.12e+18) || !(z <= 3.7e+39)) tmp = Float64(Float64(-z) - y); else tmp = Float64(Float64(Float64(x * log(y)) + log(t)) - y); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -1.12e+18) || ~((z <= 3.7e+39))) tmp = -z - y; else tmp = ((x * log(y)) + log(t)) - y; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -1.12e+18], N[Not[LessEqual[z, 3.7e+39]], $MachinePrecision]], N[((-z) - y), $MachinePrecision], N[(N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] + N[Log[t], $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.12 \cdot 10^{+18} \lor \neg \left(z \leq 3.7 \cdot 10^{+39}\right):\\
\;\;\;\;\left(-z\right) - y\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot \log y + \log t\right) - y\\
\end{array}
\end{array}
if z < -1.12e18 or 3.70000000000000012e39 < z Initial program 100.0%
associate-+l-100.0%
associate--l-100.0%
+-commutative100.0%
associate--r+100.0%
fma-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
remove-double-neg100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in z around inf 84.4%
mul-1-neg84.4%
Simplified84.4%
if -1.12e18 < z < 3.70000000000000012e39Initial program 99.9%
associate-+l-99.9%
associate--l-99.9%
+-commutative99.9%
associate--r+99.9%
fma-neg99.9%
sub-neg99.9%
distribute-neg-in99.9%
+-commutative99.9%
remove-double-neg99.9%
unsub-neg99.9%
Simplified99.9%
Taylor expanded in z around 0 99.2%
Final simplification92.9%
(FPCore (x y z t) :precision binary64 (if (or (<= x -1.4e+16) (not (<= x 1.4e+75))) (- (/ 1.0 (/ 1.0 (* x (log y)))) y) (- (- (log t) z) y)))
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -1.4e+16) || !(x <= 1.4e+75)) {
tmp = (1.0 / (1.0 / (x * log(y)))) - y;
} else {
tmp = (log(t) - z) - 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 ((x <= (-1.4d+16)) .or. (.not. (x <= 1.4d+75))) then
tmp = (1.0d0 / (1.0d0 / (x * log(y)))) - y
else
tmp = (log(t) - z) - y
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -1.4e+16) || !(x <= 1.4e+75)) {
tmp = (1.0 / (1.0 / (x * Math.log(y)))) - y;
} else {
tmp = (Math.log(t) - z) - y;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x <= -1.4e+16) or not (x <= 1.4e+75): tmp = (1.0 / (1.0 / (x * math.log(y)))) - y else: tmp = (math.log(t) - z) - y return tmp
function code(x, y, z, t) tmp = 0.0 if ((x <= -1.4e+16) || !(x <= 1.4e+75)) tmp = Float64(Float64(1.0 / Float64(1.0 / Float64(x * log(y)))) - y); else tmp = Float64(Float64(log(t) - z) - y); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x <= -1.4e+16) || ~((x <= 1.4e+75))) tmp = (1.0 / (1.0 / (x * log(y)))) - y; else tmp = (log(t) - z) - y; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[x, -1.4e+16], N[Not[LessEqual[x, 1.4e+75]], $MachinePrecision]], N[(N[(1.0 / N[(1.0 / N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision], N[(N[(N[Log[t], $MachinePrecision] - z), $MachinePrecision] - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.4 \cdot 10^{+16} \lor \neg \left(x \leq 1.4 \cdot 10^{+75}\right):\\
\;\;\;\;\frac{1}{\frac{1}{x \cdot \log y}} - y\\
\mathbf{else}:\\
\;\;\;\;\left(\log t - z\right) - y\\
\end{array}
\end{array}
if x < -1.4e16 or 1.40000000000000006e75 < x Initial program 99.9%
associate-+l-99.9%
associate--l-99.9%
+-commutative99.9%
associate--r+99.9%
fma-neg99.9%
sub-neg99.9%
distribute-neg-in99.9%
+-commutative99.9%
remove-double-neg99.9%
unsub-neg99.9%
Simplified99.9%
Taylor expanded in z around 0 85.6%
flip-+32.4%
clear-num32.3%
clear-num32.4%
flip-+85.6%
+-commutative85.6%
fma-udef85.6%
Applied egg-rr85.6%
Taylor expanded in x around inf 85.6%
if -1.4e16 < x < 1.40000000000000006e75Initial program 100.0%
associate-+l-100.0%
associate--l-100.0%
+-commutative100.0%
associate--r+100.0%
fma-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
remove-double-neg100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in x around 0 96.1%
Final simplification91.8%
(FPCore (x y z t) :precision binary64 (if (or (<= z -2100000.0) (not (<= z 2000000000.0))) (- (- z) y) (- (log t) y)))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -2100000.0) || !(z <= 2000000000.0)) {
tmp = -z - y;
} 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 ((z <= (-2100000.0d0)) .or. (.not. (z <= 2000000000.0d0))) then
tmp = -z - y
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 ((z <= -2100000.0) || !(z <= 2000000000.0)) {
tmp = -z - y;
} else {
tmp = Math.log(t) - y;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -2100000.0) or not (z <= 2000000000.0): tmp = -z - y else: tmp = math.log(t) - y return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -2100000.0) || !(z <= 2000000000.0)) tmp = Float64(Float64(-z) - y); else tmp = Float64(log(t) - y); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -2100000.0) || ~((z <= 2000000000.0))) tmp = -z - y; else tmp = log(t) - y; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -2100000.0], N[Not[LessEqual[z, 2000000000.0]], $MachinePrecision]], N[((-z) - y), $MachinePrecision], N[(N[Log[t], $MachinePrecision] - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2100000 \lor \neg \left(z \leq 2000000000\right):\\
\;\;\;\;\left(-z\right) - y\\
\mathbf{else}:\\
\;\;\;\;\log t - y\\
\end{array}
\end{array}
if z < -2.1e6 or 2e9 < z Initial program 100.0%
associate-+l-100.0%
associate--l-100.0%
+-commutative100.0%
associate--r+100.0%
fma-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
remove-double-neg100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in z around inf 82.6%
mul-1-neg82.6%
Simplified82.6%
if -2.1e6 < z < 2e9Initial program 99.9%
associate-+l-99.9%
associate--l-99.9%
+-commutative99.9%
associate--r+99.9%
fma-neg99.9%
sub-neg99.9%
distribute-neg-in99.9%
+-commutative99.9%
remove-double-neg99.9%
unsub-neg99.9%
Simplified99.9%
Taylor expanded in x around 0 60.1%
Taylor expanded in z around 0 59.8%
Final simplification70.0%
(FPCore (x y z t) :precision binary64 (if (<= y 235.0) (- (log t) z) (- (- z) y)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 235.0) {
tmp = log(t) - z;
} else {
tmp = -z - 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 <= 235.0d0) then
tmp = log(t) - z
else
tmp = -z - y
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 235.0) {
tmp = Math.log(t) - z;
} else {
tmp = -z - y;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 235.0: tmp = math.log(t) - z else: tmp = -z - y return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 235.0) tmp = Float64(log(t) - z); else tmp = Float64(Float64(-z) - y); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 235.0) tmp = log(t) - z; else tmp = -z - y; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 235.0], N[(N[Log[t], $MachinePrecision] - z), $MachinePrecision], N[((-z) - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 235:\\
\;\;\;\;\log t - z\\
\mathbf{else}:\\
\;\;\;\;\left(-z\right) - y\\
\end{array}
\end{array}
if y < 235Initial program 99.9%
associate-+l-99.9%
associate--l-99.9%
+-commutative99.9%
associate--r+99.9%
fma-neg99.9%
sub-neg99.9%
distribute-neg-in99.9%
+-commutative99.9%
remove-double-neg99.9%
unsub-neg99.9%
Simplified99.9%
Taylor expanded in x around 0 65.4%
Taylor expanded in y around 0 65.4%
if 235 < y Initial program 100.0%
associate-+l-100.0%
associate--l-100.0%
+-commutative100.0%
associate--r+100.0%
fma-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
remove-double-neg100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in z around inf 72.9%
mul-1-neg72.9%
Simplified72.9%
Final simplification69.1%
(FPCore (x y z t) :precision binary64 (- (- (log t) z) y))
double code(double x, double y, double z, double t) {
return (log(t) - z) - 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 = (log(t) - z) - y
end function
public static double code(double x, double y, double z, double t) {
return (Math.log(t) - z) - y;
}
def code(x, y, z, t): return (math.log(t) - z) - y
function code(x, y, z, t) return Float64(Float64(log(t) - z) - y) end
function tmp = code(x, y, z, t) tmp = (log(t) - z) - y; end
code[x_, y_, z_, t_] := N[(N[(N[Log[t], $MachinePrecision] - z), $MachinePrecision] - y), $MachinePrecision]
\begin{array}{l}
\\
\left(\log t - z\right) - y
\end{array}
Initial program 99.9%
associate-+l-99.9%
associate--l-99.9%
+-commutative99.9%
associate--r+99.9%
fma-neg99.9%
sub-neg99.9%
distribute-neg-in99.9%
+-commutative99.9%
remove-double-neg99.9%
unsub-neg99.9%
Simplified99.9%
Taylor expanded in x around 0 70.1%
Final simplification70.1%
(FPCore (x y z t) :precision binary64 (if (<= y 1.4e+77) (- z) (- y)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.4e+77) {
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 <= 1.4d+77) 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 <= 1.4e+77) {
tmp = -z;
} else {
tmp = -y;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 1.4e+77: tmp = -z else: tmp = -y return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 1.4e+77) tmp = Float64(-z); else tmp = Float64(-y); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 1.4e+77) tmp = -z; else tmp = -y; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 1.4e+77], (-z), (-y)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.4 \cdot 10^{+77}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;-y\\
\end{array}
\end{array}
if y < 1.4e77Initial program 99.9%
associate-+l-99.9%
associate--l-99.9%
+-commutative99.9%
associate--r+99.9%
fma-neg99.9%
sub-neg99.9%
distribute-neg-in99.9%
+-commutative99.9%
remove-double-neg99.9%
unsub-neg99.9%
Simplified99.9%
Taylor expanded in x around 0 62.9%
Taylor expanded in z around inf 37.3%
mul-1-neg37.3%
Simplified37.3%
if 1.4e77 < y Initial program 100.0%
associate-+l-100.0%
associate--l-100.0%
+-commutative100.0%
associate--r+100.0%
fma-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
remove-double-neg100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in x around 0 82.6%
Taylor expanded in y around inf 72.0%
mul-1-neg72.0%
Simplified72.0%
Final simplification50.0%
(FPCore (x y z t) :precision binary64 (- (- z) y))
double code(double x, double y, double z, double t) {
return -z - 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 = -z - y
end function
public static double code(double x, double y, double z, double t) {
return -z - y;
}
def code(x, y, z, t): return -z - y
function code(x, y, z, t) return Float64(Float64(-z) - y) end
function tmp = code(x, y, z, t) tmp = -z - y; end
code[x_, y_, z_, t_] := N[((-z) - y), $MachinePrecision]
\begin{array}{l}
\\
\left(-z\right) - y
\end{array}
Initial program 99.9%
associate-+l-99.9%
associate--l-99.9%
+-commutative99.9%
associate--r+99.9%
fma-neg99.9%
sub-neg99.9%
distribute-neg-in99.9%
+-commutative99.9%
remove-double-neg99.9%
unsub-neg99.9%
Simplified99.9%
Taylor expanded in z around inf 55.5%
mul-1-neg55.5%
Simplified55.5%
Final simplification55.5%
(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.9%
associate-+l-99.9%
associate--l-99.9%
+-commutative99.9%
associate--r+99.9%
fma-neg99.9%
sub-neg99.9%
distribute-neg-in99.9%
+-commutative99.9%
remove-double-neg99.9%
unsub-neg99.9%
Simplified99.9%
Taylor expanded in x around 0 70.1%
Taylor expanded in y around inf 29.7%
mul-1-neg29.7%
Simplified29.7%
Final simplification29.7%
herbie shell --seed 2023297
(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)))