
(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.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%
neg-sub0100.0%
associate-+l-100.0%
neg-sub0100.0%
+-commutative100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in z around inf 84.4%
neg-mul-184.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%
neg-sub099.9%
associate-+l-99.9%
neg-sub099.9%
+-commutative99.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 (<= x -1.4e+16)
(- (* 0.3333333333333333 (* (* x (log y)) 3.0)) y)
(if (<= x 1.4e+75)
(- (- (log t) z) y)
(- (* 0.3333333333333333 (* (* x -3.0) (- (log y)))) y))))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -1.4e+16) {
tmp = (0.3333333333333333 * ((x * log(y)) * 3.0)) - y;
} else if (x <= 1.4e+75) {
tmp = (log(t) - z) - y;
} else {
tmp = (0.3333333333333333 * ((x * -3.0) * -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 (x <= (-1.4d+16)) then
tmp = (0.3333333333333333d0 * ((x * log(y)) * 3.0d0)) - y
else if (x <= 1.4d+75) then
tmp = (log(t) - z) - y
else
tmp = (0.3333333333333333d0 * ((x * (-3.0d0)) * -log(y))) - 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) {
tmp = (0.3333333333333333 * ((x * Math.log(y)) * 3.0)) - y;
} else if (x <= 1.4e+75) {
tmp = (Math.log(t) - z) - y;
} else {
tmp = (0.3333333333333333 * ((x * -3.0) * -Math.log(y))) - y;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= -1.4e+16: tmp = (0.3333333333333333 * ((x * math.log(y)) * 3.0)) - y elif x <= 1.4e+75: tmp = (math.log(t) - z) - y else: tmp = (0.3333333333333333 * ((x * -3.0) * -math.log(y))) - y return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= -1.4e+16) tmp = Float64(Float64(0.3333333333333333 * Float64(Float64(x * log(y)) * 3.0)) - y); elseif (x <= 1.4e+75) tmp = Float64(Float64(log(t) - z) - y); else tmp = Float64(Float64(0.3333333333333333 * Float64(Float64(x * -3.0) * Float64(-log(y)))) - y); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (x <= -1.4e+16) tmp = (0.3333333333333333 * ((x * log(y)) * 3.0)) - y; elseif (x <= 1.4e+75) tmp = (log(t) - z) - y; else tmp = (0.3333333333333333 * ((x * -3.0) * -log(y))) - y; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, -1.4e+16], N[(N[(0.3333333333333333 * N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] * 3.0), $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision], If[LessEqual[x, 1.4e+75], N[(N[(N[Log[t], $MachinePrecision] - z), $MachinePrecision] - y), $MachinePrecision], N[(N[(0.3333333333333333 * N[(N[(x * -3.0), $MachinePrecision] * (-N[Log[y], $MachinePrecision])), $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.4 \cdot 10^{+16}:\\
\;\;\;\;0.3333333333333333 \cdot \left(\left(x \cdot \log y\right) \cdot 3\right) - y\\
\mathbf{elif}\;x \leq 1.4 \cdot 10^{+75}:\\
\;\;\;\;\left(\log t - z\right) - y\\
\mathbf{else}:\\
\;\;\;\;0.3333333333333333 \cdot \left(\left(x \cdot -3\right) \cdot \left(-\log y\right)\right) - y\\
\end{array}
\end{array}
if x < -1.4e16Initial program 99.9%
associate-+l-99.9%
associate--l-99.9%
+-commutative99.9%
associate--r+99.9%
fma-neg99.9%
neg-sub099.9%
associate-+l-99.9%
neg-sub099.9%
+-commutative99.9%
unsub-neg99.9%
Simplified99.9%
Taylor expanded in z around 0 87.6%
log-pow9.0%
log-prod9.0%
Simplified9.0%
add-cbrt-cube9.0%
pow1/39.0%
log-pow9.0%
pow39.0%
log-pow9.0%
log-prod9.0%
log-pow87.4%
+-commutative87.4%
fma-def87.4%
Applied egg-rr87.4%
Taylor expanded in x around inf 87.4%
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%
neg-sub0100.0%
associate-+l-100.0%
neg-sub0100.0%
+-commutative100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in x around 0 96.1%
if 1.40000000000000006e75 < x Initial program 99.8%
associate-+l-99.8%
associate--l-99.8%
+-commutative99.8%
associate--r+99.8%
fma-neg99.8%
neg-sub099.8%
associate-+l-99.8%
neg-sub099.8%
+-commutative99.8%
unsub-neg99.8%
Simplified99.8%
Taylor expanded in z around 0 81.5%
log-pow10.5%
log-prod10.5%
Simplified10.5%
add-cbrt-cube10.5%
pow1/310.5%
log-pow10.5%
pow310.5%
log-pow10.5%
log-prod10.5%
log-pow81.4%
+-commutative81.4%
fma-def81.4%
Applied egg-rr81.4%
Taylor expanded in x around inf 81.4%
Taylor expanded in y around inf 81.4%
associate-*r*81.4%
log-rec81.4%
Simplified81.4%
Final simplification91.7%
(FPCore (x y z t) :precision binary64 (if (or (<= x -7.2e+17) (not (<= x 1.2e+74))) (- (* 0.3333333333333333 (* (* x (log y)) 3.0)) y) (- (- (log t) z) y)))
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -7.2e+17) || !(x <= 1.2e+74)) {
tmp = (0.3333333333333333 * ((x * log(y)) * 3.0)) - 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 <= (-7.2d+17)) .or. (.not. (x <= 1.2d+74))) then
tmp = (0.3333333333333333d0 * ((x * log(y)) * 3.0d0)) - 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 <= -7.2e+17) || !(x <= 1.2e+74)) {
tmp = (0.3333333333333333 * ((x * Math.log(y)) * 3.0)) - y;
} else {
tmp = (Math.log(t) - z) - y;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x <= -7.2e+17) or not (x <= 1.2e+74): tmp = (0.3333333333333333 * ((x * math.log(y)) * 3.0)) - y else: tmp = (math.log(t) - z) - y return tmp
function code(x, y, z, t) tmp = 0.0 if ((x <= -7.2e+17) || !(x <= 1.2e+74)) tmp = Float64(Float64(0.3333333333333333 * Float64(Float64(x * log(y)) * 3.0)) - 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 <= -7.2e+17) || ~((x <= 1.2e+74))) tmp = (0.3333333333333333 * ((x * log(y)) * 3.0)) - y; else tmp = (log(t) - z) - y; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[x, -7.2e+17], N[Not[LessEqual[x, 1.2e+74]], $MachinePrecision]], N[(N[(0.3333333333333333 * N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] * 3.0), $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision], N[(N[(N[Log[t], $MachinePrecision] - z), $MachinePrecision] - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -7.2 \cdot 10^{+17} \lor \neg \left(x \leq 1.2 \cdot 10^{+74}\right):\\
\;\;\;\;0.3333333333333333 \cdot \left(\left(x \cdot \log y\right) \cdot 3\right) - y\\
\mathbf{else}:\\
\;\;\;\;\left(\log t - z\right) - y\\
\end{array}
\end{array}
if x < -7.2e17 or 1.20000000000000004e74 < x Initial program 99.9%
associate-+l-99.9%
associate--l-99.9%
+-commutative99.9%
associate--r+99.9%
fma-neg99.9%
neg-sub099.9%
associate-+l-99.9%
neg-sub099.9%
+-commutative99.9%
unsub-neg99.9%
Simplified99.9%
Taylor expanded in z around 0 85.6%
log-pow9.5%
log-prod9.5%
Simplified9.5%
add-cbrt-cube9.5%
pow1/39.5%
log-pow9.5%
pow39.5%
log-pow9.5%
log-prod9.5%
log-pow85.5%
+-commutative85.5%
fma-def85.5%
Applied egg-rr85.5%
Taylor expanded in x around inf 85.5%
if -7.2e17 < x < 1.20000000000000004e74Initial program 100.0%
associate-+l-100.0%
associate--l-100.0%
+-commutative100.0%
associate--r+100.0%
fma-neg100.0%
neg-sub0100.0%
associate-+l-100.0%
neg-sub0100.0%
+-commutative100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in x around 0 96.1%
Final simplification91.7%
(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%
neg-sub0100.0%
associate-+l-100.0%
neg-sub0100.0%
+-commutative100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in z around inf 82.6%
neg-mul-182.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%
neg-sub099.9%
associate-+l-99.9%
neg-sub099.9%
+-commutative99.9%
unsub-neg99.9%
Simplified99.9%
Taylor expanded in z around 0 99.6%
log-pow54.0%
log-prod54.0%
Simplified54.0%
Taylor expanded in x around 0 59.8%
Final simplification70.0%
(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%
neg-sub099.9%
associate-+l-99.9%
neg-sub099.9%
+-commutative99.9%
unsub-neg99.9%
Simplified99.9%
Taylor expanded in x around 0 70.1%
Final simplification70.1%
(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%
neg-sub099.9%
associate-+l-99.9%
neg-sub099.9%
+-commutative99.9%
unsub-neg99.9%
Simplified99.9%
Taylor expanded in z around inf 55.5%
neg-mul-155.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%
neg-sub099.9%
associate-+l-99.9%
neg-sub099.9%
+-commutative99.9%
unsub-neg99.9%
Simplified99.9%
Taylor expanded in z around 0 73.0%
log-pow36.8%
log-prod36.8%
Simplified36.8%
Taylor expanded in x around 0 44.4%
Taylor expanded in y around inf 29.7%
neg-mul-129.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)))