
(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 11 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 (- (fma x (log y) (- (log t) z)) y))
double code(double x, double y, double z, double t) {
return fma(x, log(y), (log(t) - z)) - y;
}
function code(x, y, z, t) return Float64(fma(x, log(y), Float64(log(t) - z)) - y) end
code[x_, y_, z_, t_] := N[(N[(x * N[Log[y], $MachinePrecision] + N[(N[Log[t], $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(x, \log y, \log t - z\right) - y
\end{array}
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (- (* x (log y)) y)))
(if (or (<= t_1 -1e+19) (not (<= t_1 1e-22)))
(- t_1 z)
(- (- (log t) z) y))))
double code(double x, double y, double z, double t) {
double t_1 = (x * log(y)) - y;
double tmp;
if ((t_1 <= -1e+19) || !(t_1 <= 1e-22)) {
tmp = t_1 - z;
} 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) :: t_1
real(8) :: tmp
t_1 = (x * log(y)) - y
if ((t_1 <= (-1d+19)) .or. (.not. (t_1 <= 1d-22))) then
tmp = t_1 - z
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 t_1 = (x * Math.log(y)) - y;
double tmp;
if ((t_1 <= -1e+19) || !(t_1 <= 1e-22)) {
tmp = t_1 - z;
} else {
tmp = (Math.log(t) - z) - y;
}
return tmp;
}
def code(x, y, z, t): t_1 = (x * math.log(y)) - y tmp = 0 if (t_1 <= -1e+19) or not (t_1 <= 1e-22): tmp = t_1 - z else: tmp = (math.log(t) - z) - y return tmp
function code(x, y, z, t) t_1 = Float64(Float64(x * log(y)) - y) tmp = 0.0 if ((t_1 <= -1e+19) || !(t_1 <= 1e-22)) tmp = Float64(t_1 - z); else tmp = Float64(Float64(log(t) - z) - y); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = (x * log(y)) - y; tmp = 0.0; if ((t_1 <= -1e+19) || ~((t_1 <= 1e-22))) tmp = t_1 - z; else tmp = (log(t) - z) - y; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -1e+19], N[Not[LessEqual[t$95$1, 1e-22]], $MachinePrecision]], N[(t$95$1 - z), $MachinePrecision], N[(N[(N[Log[t], $MachinePrecision] - z), $MachinePrecision] - y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x \cdot \log y - y\\
\mathbf{if}\;t_1 \leq -1 \cdot 10^{+19} \lor \neg \left(t_1 \leq 10^{-22}\right):\\
\;\;\;\;t_1 - z\\
\mathbf{else}:\\
\;\;\;\;\left(\log t - z\right) - y\\
\end{array}
\end{array}
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* x (log y))) (t_2 (- t_1 y))) (if (<= t_2 -1000.0) (- t_2 z) (- (+ (log t) t_1) z))))
double code(double x, double y, double z, double t) {
double t_1 = x * log(y);
double t_2 = t_1 - y;
double tmp;
if (t_2 <= -1000.0) {
tmp = t_2 - z;
} else {
tmp = (log(t) + t_1) - 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) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = x * log(y)
t_2 = t_1 - y
if (t_2 <= (-1000.0d0)) then
tmp = t_2 - z
else
tmp = (log(t) + t_1) - z
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = x * Math.log(y);
double t_2 = t_1 - y;
double tmp;
if (t_2 <= -1000.0) {
tmp = t_2 - z;
} else {
tmp = (Math.log(t) + t_1) - z;
}
return tmp;
}
def code(x, y, z, t): t_1 = x * math.log(y) t_2 = t_1 - y tmp = 0 if t_2 <= -1000.0: tmp = t_2 - z else: tmp = (math.log(t) + t_1) - z return tmp
function code(x, y, z, t) t_1 = Float64(x * log(y)) t_2 = Float64(t_1 - y) tmp = 0.0 if (t_2 <= -1000.0) tmp = Float64(t_2 - z); else tmp = Float64(Float64(log(t) + t_1) - z); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = x * log(y); t_2 = t_1 - y; tmp = 0.0; if (t_2 <= -1000.0) tmp = t_2 - z; else tmp = (log(t) + t_1) - z; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 - y), $MachinePrecision]}, If[LessEqual[t$95$2, -1000.0], N[(t$95$2 - z), $MachinePrecision], N[(N[(N[Log[t], $MachinePrecision] + t$95$1), $MachinePrecision] - z), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x \cdot \log y\\
t_2 := t_1 - y\\
\mathbf{if}\;t_2 \leq -1000:\\
\;\;\;\;t_2 - z\\
\mathbf{else}:\\
\;\;\;\;\left(\log t + t_1\right) - z\\
\end{array}
\end{array}
(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}
(FPCore (x y z t) :precision binary64 (if (or (<= z -4.2e+26) (not (<= z 9e+61))) (- (- y) z) (- (* x (log y)) y)))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -4.2e+26) || !(z <= 9e+61)) {
tmp = -y - z;
} else {
tmp = (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 <= (-4.2d+26)) .or. (.not. (z <= 9d+61))) then
tmp = -y - z
else
tmp = (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 <= -4.2e+26) || !(z <= 9e+61)) {
tmp = -y - z;
} else {
tmp = (x * Math.log(y)) - y;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -4.2e+26) or not (z <= 9e+61): tmp = -y - z else: tmp = (x * math.log(y)) - y return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -4.2e+26) || !(z <= 9e+61)) tmp = Float64(Float64(-y) - z); else tmp = Float64(Float64(x * log(y)) - y); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -4.2e+26) || ~((z <= 9e+61))) tmp = -y - z; else tmp = (x * log(y)) - y; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -4.2e+26], N[Not[LessEqual[z, 9e+61]], $MachinePrecision]], N[((-y) - z), $MachinePrecision], N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.2 \cdot 10^{+26} \lor \neg \left(z \leq 9 \cdot 10^{+61}\right):\\
\;\;\;\;\left(-y\right) - z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \log y - y\\
\end{array}
\end{array}
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* x (log y))))
(if (<= x -2.1e+125)
(- t_1 z)
(if (<= x 3.8e+98) (- (- (log t) z) y) (- t_1 y)))))
double code(double x, double y, double z, double t) {
double t_1 = x * log(y);
double tmp;
if (x <= -2.1e+125) {
tmp = t_1 - z;
} else if (x <= 3.8e+98) {
tmp = (log(t) - z) - y;
} 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 = x * log(y)
if (x <= (-2.1d+125)) then
tmp = t_1 - z
else if (x <= 3.8d+98) then
tmp = (log(t) - z) - y
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 = x * Math.log(y);
double tmp;
if (x <= -2.1e+125) {
tmp = t_1 - z;
} else if (x <= 3.8e+98) {
tmp = (Math.log(t) - z) - y;
} else {
tmp = t_1 - y;
}
return tmp;
}
def code(x, y, z, t): t_1 = x * math.log(y) tmp = 0 if x <= -2.1e+125: tmp = t_1 - z elif x <= 3.8e+98: tmp = (math.log(t) - z) - y else: tmp = t_1 - y return tmp
function code(x, y, z, t) t_1 = Float64(x * log(y)) tmp = 0.0 if (x <= -2.1e+125) tmp = Float64(t_1 - z); elseif (x <= 3.8e+98) tmp = Float64(Float64(log(t) - z) - y); else tmp = Float64(t_1 - y); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = x * log(y); tmp = 0.0; if (x <= -2.1e+125) tmp = t_1 - z; elseif (x <= 3.8e+98) tmp = (log(t) - z) - y; else tmp = t_1 - y; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -2.1e+125], N[(t$95$1 - z), $MachinePrecision], If[LessEqual[x, 3.8e+98], N[(N[(N[Log[t], $MachinePrecision] - z), $MachinePrecision] - y), $MachinePrecision], N[(t$95$1 - y), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x \cdot \log y\\
\mathbf{if}\;x \leq -2.1 \cdot 10^{+125}:\\
\;\;\;\;t_1 - z\\
\mathbf{elif}\;x \leq 3.8 \cdot 10^{+98}:\\
\;\;\;\;\left(\log t - z\right) - y\\
\mathbf{else}:\\
\;\;\;\;t_1 - y\\
\end{array}
\end{array}
(FPCore (x y z t) :precision binary64 (if (<= y 1.2e+46) (- (* x (log y)) z) (- (- y) z)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.2e+46) {
tmp = (x * log(y)) - z;
} else {
tmp = -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 (y <= 1.2d+46) then
tmp = (x * log(y)) - z
else
tmp = -y - z
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.2e+46) {
tmp = (x * Math.log(y)) - z;
} else {
tmp = -y - z;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 1.2e+46: tmp = (x * math.log(y)) - z else: tmp = -y - z return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 1.2e+46) tmp = Float64(Float64(x * log(y)) - z); else tmp = Float64(Float64(-y) - z); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 1.2e+46) tmp = (x * log(y)) - z; else tmp = -y - z; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 1.2e+46], N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], N[((-y) - z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.2 \cdot 10^{+46}:\\
\;\;\;\;x \cdot \log y - z\\
\mathbf{else}:\\
\;\;\;\;\left(-y\right) - z\\
\end{array}
\end{array}
(FPCore (x y z t) :precision binary64 (if (<= y 450.0) (- (log t) z) (- (- y) z)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 450.0) {
tmp = log(t) - z;
} else {
tmp = -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 (y <= 450.0d0) then
tmp = log(t) - z
else
tmp = -y - z
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 450.0) {
tmp = Math.log(t) - z;
} else {
tmp = -y - z;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 450.0: tmp = math.log(t) - z else: tmp = -y - z return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 450.0) tmp = Float64(log(t) - z); else tmp = Float64(Float64(-y) - z); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 450.0) tmp = log(t) - z; else tmp = -y - z; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 450.0], N[(N[Log[t], $MachinePrecision] - z), $MachinePrecision], N[((-y) - z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 450:\\
\;\;\;\;\log t - z\\
\mathbf{else}:\\
\;\;\;\;\left(-y\right) - z\\
\end{array}
\end{array}
(FPCore (x y z t) :precision binary64 (if (or (<= y 2.2e+41) (and (not (<= y 3e+79)) (<= y 5.5e+130))) (- z) (- y)))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= 2.2e+41) || (!(y <= 3e+79) && (y <= 5.5e+130))) {
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 <= 2.2d+41) .or. (.not. (y <= 3d+79)) .and. (y <= 5.5d+130)) 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 <= 2.2e+41) || (!(y <= 3e+79) && (y <= 5.5e+130))) {
tmp = -z;
} else {
tmp = -y;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= 2.2e+41) or (not (y <= 3e+79) and (y <= 5.5e+130)): tmp = -z else: tmp = -y return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= 2.2e+41) || (!(y <= 3e+79) && (y <= 5.5e+130))) tmp = Float64(-z); else tmp = Float64(-y); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((y <= 2.2e+41) || (~((y <= 3e+79)) && (y <= 5.5e+130))) tmp = -z; else tmp = -y; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, 2.2e+41], And[N[Not[LessEqual[y, 3e+79]], $MachinePrecision], LessEqual[y, 5.5e+130]]], (-z), (-y)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.2 \cdot 10^{+41} \lor \neg \left(y \leq 3 \cdot 10^{+79}\right) \land y \leq 5.5 \cdot 10^{+130}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;-y\\
\end{array}
\end{array}
(FPCore (x y z t) :precision binary64 (- (- y) z))
double code(double x, double y, double z, double t) {
return -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 = -y - z
end function
public static double code(double x, double y, double z, double t) {
return -y - z;
}
def code(x, y, z, t): return -y - z
function code(x, y, z, t) return Float64(Float64(-y) - z) end
function tmp = code(x, y, z, t) tmp = -y - z; end
code[x_, y_, z_, t_] := N[((-y) - z), $MachinePrecision]
\begin{array}{l}
\\
\left(-y\right) - z
\end{array}
(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}
herbie shell --seed 2024008
(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)))