
(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 (<= x -1300000.0) (not (<= x 1.95e+63))) (- (+ (log t) (* x (log y))) y) (- (log t) (+ y z))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -1300000.0) || !(x <= 1.95e+63)) {
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 <= (-1300000.0d0)) .or. (.not. (x <= 1.95d+63))) 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 <= -1300000.0) || !(x <= 1.95e+63)) {
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 <= -1300000.0) or not (x <= 1.95e+63): 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 <= -1300000.0) || !(x <= 1.95e+63)) 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 <= -1300000.0) || ~((x <= 1.95e+63))) 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, -1300000.0], N[Not[LessEqual[x, 1.95e+63]], $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 -1300000 \lor \neg \left(x \leq 1.95 \cdot 10^{+63}\right):\\
\;\;\;\;\left(\log t + x \cdot \log y\right) - y\\
\mathbf{else}:\\
\;\;\;\;\log t - \left(y + z\right)\\
\end{array}
\end{array}
if x < -1.3e6 or 1.95e63 < x Initial program 99.7%
Taylor expanded in z around 0 83.7%
if -1.3e6 < x < 1.95e63Initial program 100.0%
Taylor expanded in x around 0 98.5%
Final simplification91.9%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (+ (log t) (* x (log y))))) (if (or (<= z -7.5e+132) (not (<= z 1.45e+83))) (- 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 <= -7.5e+132) || !(z <= 1.45e+83)) {
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 <= (-7.5d+132)) .or. (.not. (z <= 1.45d+83))) 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 <= -7.5e+132) || !(z <= 1.45e+83)) {
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 <= -7.5e+132) or not (z <= 1.45e+83): 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 <= -7.5e+132) || !(z <= 1.45e+83)) 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 <= -7.5e+132) || ~((z <= 1.45e+83))) 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, -7.5e+132], N[Not[LessEqual[z, 1.45e+83]], $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 -7.5 \cdot 10^{+132} \lor \neg \left(z \leq 1.45 \cdot 10^{+83}\right):\\
\;\;\;\;t_1 - z\\
\mathbf{else}:\\
\;\;\;\;t_1 - y\\
\end{array}
\end{array}
if z < -7.50000000000000017e132 or 1.45e83 < z Initial program 99.9%
Taylor expanded in y around 0 91.5%
if -7.50000000000000017e132 < z < 1.45e83Initial program 99.8%
Taylor expanded in z around 0 94.7%
Final simplification93.5%
(FPCore (x y z t) :precision binary64 (if (or (<= x -7e+101) (not (<= x 8e+127))) (+ (log t) (* x (log y))) (- (log t) (+ y z))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -7e+101) || !(x <= 8e+127)) {
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 <= (-7d+101)) .or. (.not. (x <= 8d+127))) 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 <= -7e+101) || !(x <= 8e+127)) {
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 <= -7e+101) or not (x <= 8e+127): 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 <= -7e+101) || !(x <= 8e+127)) 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 <= -7e+101) || ~((x <= 8e+127))) 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, -7e+101], N[Not[LessEqual[x, 8e+127]], $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 -7 \cdot 10^{+101} \lor \neg \left(x \leq 8 \cdot 10^{+127}\right):\\
\;\;\;\;\log t + x \cdot \log y\\
\mathbf{else}:\\
\;\;\;\;\log t - \left(y + z\right)\\
\end{array}
\end{array}
if x < -7.00000000000000046e101 or 7.99999999999999964e127 < x Initial program 99.6%
Taylor expanded in z around 0 87.6%
Taylor expanded in y around 0 78.3%
if -7.00000000000000046e101 < x < 7.99999999999999964e127Initial program 100.0%
Taylor expanded in x around 0 93.4%
Final simplification88.7%
(FPCore (x y z t) :precision binary64 (if (<= z -3.35e+133) (- z) (if (<= z 4.6e+83) (- (log t) y) (- z))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -3.35e+133) {
tmp = -z;
} else if (z <= 4.6e+83) {
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.35d+133)) then
tmp = -z
else if (z <= 4.6d+83) 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.35e+133) {
tmp = -z;
} else if (z <= 4.6e+83) {
tmp = Math.log(t) - y;
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -3.35e+133: tmp = -z elif z <= 4.6e+83: tmp = math.log(t) - y else: tmp = -z return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -3.35e+133) tmp = Float64(-z); elseif (z <= 4.6e+83) 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.35e+133) tmp = -z; elseif (z <= 4.6e+83) tmp = log(t) - y; else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -3.35e+133], (-z), If[LessEqual[z, 4.6e+83], N[(N[Log[t], $MachinePrecision] - y), $MachinePrecision], (-z)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.35 \cdot 10^{+133}:\\
\;\;\;\;-z\\
\mathbf{elif}\;z \leq 4.6 \cdot 10^{+83}:\\
\;\;\;\;\log t - y\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if z < -3.35000000000000015e133 or 4.5999999999999999e83 < z Initial program 99.9%
Taylor expanded in z around inf 73.5%
mul-1-neg73.5%
Simplified73.5%
if -3.35000000000000015e133 < z < 4.5999999999999999e83Initial program 99.8%
+-commutative99.8%
add-log-exp20.5%
sum-log20.5%
associate--l-20.5%
exp-diff19.7%
*-commutative19.7%
exp-to-pow19.7%
Applied egg-rr19.7%
Taylor expanded in x around 0 19.5%
Taylor expanded in z around 0 19.3%
log-div19.3%
rem-log-exp60.3%
Simplified60.3%
Final simplification65.0%
(FPCore (x y z t) :precision binary64 (if (<= y 1.2e+86) (- (log t) z) (- y)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.2e+86) {
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 <= 1.2d+86) 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 <= 1.2e+86) {
tmp = Math.log(t) - z;
} else {
tmp = -y;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 1.2e+86: tmp = math.log(t) - z else: tmp = -y return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 1.2e+86) 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 <= 1.2e+86) tmp = log(t) - z; else tmp = -y; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 1.2e+86], N[(N[Log[t], $MachinePrecision] - z), $MachinePrecision], (-y)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.2 \cdot 10^{+86}:\\
\;\;\;\;\log t - z\\
\mathbf{else}:\\
\;\;\;\;-y\\
\end{array}
\end{array}
if y < 1.2e86Initial program 99.8%
Taylor expanded in y around 0 93.1%
+-commutative93.1%
*-commutative93.1%
log-pow45.0%
log-prod45.0%
Simplified45.0%
Taylor expanded in x around 0 59.2%
if 1.2e86 < y Initial program 99.9%
Taylor expanded in y around inf 69.9%
neg-mul-169.9%
Simplified69.9%
Final simplification63.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.9%
Taylor expanded in x around 0 71.2%
Final simplification71.2%
(FPCore (x y z t) :precision binary64 (if (<= y 9.2e+85) (- z) (- y)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 9.2e+85) {
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 <= 9.2d+85) 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 <= 9.2e+85) {
tmp = -z;
} else {
tmp = -y;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 9.2e+85: tmp = -z else: tmp = -y return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 9.2e+85) tmp = Float64(-z); else tmp = Float64(-y); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 9.2e+85) tmp = -z; else tmp = -y; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 9.2e+85], (-z), (-y)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 9.2 \cdot 10^{+85}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;-y\\
\end{array}
\end{array}
if y < 9.1999999999999996e85Initial program 99.8%
Taylor expanded in z around inf 43.4%
mul-1-neg43.4%
Simplified43.4%
if 9.1999999999999996e85 < y Initial program 99.9%
Taylor expanded in y around inf 69.9%
neg-mul-169.9%
Simplified69.9%
Final simplification53.9%
(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%
Taylor expanded in y around inf 32.6%
neg-mul-132.6%
Simplified32.6%
Final simplification32.6%
herbie shell --seed 2023174
(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)))