
(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%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (- (* x (log y)) y)))
(if (<= t_1 -4e+161)
(* -1.0 y)
(if (<= t_1 -100000000000.0)
(* (fma (- y) (/ -1.0 z) 1.0) (- z))
(if (<= t_1 1e+25) (- (log t) z) (* (log y) x))))))
double code(double x, double y, double z, double t) {
double t_1 = (x * log(y)) - y;
double tmp;
if (t_1 <= -4e+161) {
tmp = -1.0 * y;
} else if (t_1 <= -100000000000.0) {
tmp = fma(-y, (-1.0 / z), 1.0) * -z;
} else if (t_1 <= 1e+25) {
tmp = log(t) - z;
} else {
tmp = log(y) * x;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(Float64(x * log(y)) - y) tmp = 0.0 if (t_1 <= -4e+161) tmp = Float64(-1.0 * y); elseif (t_1 <= -100000000000.0) tmp = Float64(fma(Float64(-y), Float64(-1.0 / z), 1.0) * Float64(-z)); elseif (t_1 <= 1e+25) tmp = Float64(log(t) - z); else tmp = Float64(log(y) * x); end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]}, If[LessEqual[t$95$1, -4e+161], N[(-1.0 * y), $MachinePrecision], If[LessEqual[t$95$1, -100000000000.0], N[(N[((-y) * N[(-1.0 / z), $MachinePrecision] + 1.0), $MachinePrecision] * (-z)), $MachinePrecision], If[LessEqual[t$95$1, 1e+25], N[(N[Log[t], $MachinePrecision] - z), $MachinePrecision], N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x \cdot \log y - y\\
\mathbf{if}\;t\_1 \leq -4 \cdot 10^{+161}:\\
\;\;\;\;-1 \cdot y\\
\mathbf{elif}\;t\_1 \leq -100000000000:\\
\;\;\;\;\mathsf{fma}\left(-y, \frac{-1}{z}, 1\right) \cdot \left(-z\right)\\
\mathbf{elif}\;t\_1 \leq 10^{+25}:\\
\;\;\;\;\log t - z\\
\mathbf{else}:\\
\;\;\;\;\log y \cdot x\\
\end{array}
\end{array}
if (-.f64 (*.f64 x (log.f64 y)) y) < -4.0000000000000002e161Initial program 99.9%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites83.7%
Taylor expanded in y around inf
Applied rewrites66.4%
if -4.0000000000000002e161 < (-.f64 (*.f64 x (log.f64 y)) y) < -1e11Initial program 99.8%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites89.2%
Applied rewrites89.2%
Taylor expanded in z around -inf
Applied rewrites84.1%
Taylor expanded in y around inf
Applied rewrites68.2%
if -1e11 < (-.f64 (*.f64 x (log.f64 y)) y) < 1.00000000000000009e25Initial program 99.9%
Taylor expanded in y around 0
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-log.f64N/A
lower-log.f6497.4
Applied rewrites97.4%
Taylor expanded in x around 0
Applied rewrites96.1%
if 1.00000000000000009e25 < (-.f64 (*.f64 x (log.f64 y)) y) Initial program 99.8%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites73.7%
Applied rewrites73.5%
Taylor expanded in x around inf
Applied rewrites79.1%
(FPCore (x y z t) :precision binary64 (if (or (<= z -4.2e+52) (not (<= z 6e+116))) (- (- (log t) y) z) (- (fma (log y) x (log t)) y)))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -4.2e+52) || !(z <= 6e+116)) {
tmp = (log(t) - y) - z;
} else {
tmp = fma(log(y), x, log(t)) - y;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if ((z <= -4.2e+52) || !(z <= 6e+116)) tmp = Float64(Float64(log(t) - y) - z); else tmp = Float64(fma(log(y), x, log(t)) - y); end return tmp end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -4.2e+52], N[Not[LessEqual[z, 6e+116]], $MachinePrecision]], N[(N[(N[Log[t], $MachinePrecision] - y), $MachinePrecision] - z), $MachinePrecision], N[(N[(N[Log[y], $MachinePrecision] * x + N[Log[t], $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.2 \cdot 10^{+52} \lor \neg \left(z \leq 6 \cdot 10^{+116}\right):\\
\;\;\;\;\left(\log t - y\right) - z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\log y, x, \log t\right) - y\\
\end{array}
\end{array}
if z < -4.2e52 or 5.9999999999999997e116 < z Initial program 100.0%
Taylor expanded in x around 0
associate--r+N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
lower--.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-log.f6491.3
Applied rewrites91.3%
if -4.2e52 < z < 5.9999999999999997e116Initial program 99.8%
Taylor expanded in z around 0
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-log.f64N/A
lower-log.f6492.8
Applied rewrites92.8%
Final simplification92.3%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (fma (log y) x (log t))))
(if (<= z -4.2e+52)
(- (- (log t) y) z)
(if (<= z 4.4e-5) (- t_1 y) (- t_1 z)))))
double code(double x, double y, double z, double t) {
double t_1 = fma(log(y), x, log(t));
double tmp;
if (z <= -4.2e+52) {
tmp = (log(t) - y) - z;
} else if (z <= 4.4e-5) {
tmp = t_1 - y;
} else {
tmp = t_1 - z;
}
return tmp;
}
function code(x, y, z, t) t_1 = fma(log(y), x, log(t)) tmp = 0.0 if (z <= -4.2e+52) tmp = Float64(Float64(log(t) - y) - z); elseif (z <= 4.4e-5) tmp = Float64(t_1 - y); else tmp = Float64(t_1 - z); end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[Log[y], $MachinePrecision] * x + N[Log[t], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -4.2e+52], N[(N[(N[Log[t], $MachinePrecision] - y), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[z, 4.4e-5], N[(t$95$1 - y), $MachinePrecision], N[(t$95$1 - z), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\log y, x, \log t\right)\\
\mathbf{if}\;z \leq -4.2 \cdot 10^{+52}:\\
\;\;\;\;\left(\log t - y\right) - z\\
\mathbf{elif}\;z \leq 4.4 \cdot 10^{-5}:\\
\;\;\;\;t\_1 - y\\
\mathbf{else}:\\
\;\;\;\;t\_1 - z\\
\end{array}
\end{array}
if z < -4.2e52Initial program 100.0%
Taylor expanded in x around 0
associate--r+N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
lower--.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-log.f6490.0
Applied rewrites90.0%
if -4.2e52 < z < 4.3999999999999999e-5Initial program 99.9%
Taylor expanded in z around 0
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-log.f64N/A
lower-log.f6498.5
Applied rewrites98.5%
if 4.3999999999999999e-5 < z Initial program 99.9%
Taylor expanded in y around 0
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-log.f64N/A
lower-log.f6490.2
Applied rewrites90.2%
(FPCore (x y z t) :precision binary64 (if (or (<= x -1.45e+135) (not (<= x 6e+141))) (* (log y) x) (- (- (log t) y) z)))
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -1.45e+135) || !(x <= 6e+141)) {
tmp = log(y) * x;
} 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 <= (-1.45d+135)) .or. (.not. (x <= 6d+141))) then
tmp = log(y) * x
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 <= -1.45e+135) || !(x <= 6e+141)) {
tmp = Math.log(y) * x;
} else {
tmp = (Math.log(t) - y) - z;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x <= -1.45e+135) or not (x <= 6e+141): tmp = math.log(y) * x else: tmp = (math.log(t) - y) - z return tmp
function code(x, y, z, t) tmp = 0.0 if ((x <= -1.45e+135) || !(x <= 6e+141)) tmp = Float64(log(y) * x); else tmp = Float64(Float64(log(t) - y) - z); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x <= -1.45e+135) || ~((x <= 6e+141))) tmp = log(y) * x; else tmp = (log(t) - y) - z; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[x, -1.45e+135], N[Not[LessEqual[x, 6e+141]], $MachinePrecision]], N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision], N[(N[(N[Log[t], $MachinePrecision] - y), $MachinePrecision] - z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.45 \cdot 10^{+135} \lor \neg \left(x \leq 6 \cdot 10^{+141}\right):\\
\;\;\;\;\log y \cdot x\\
\mathbf{else}:\\
\;\;\;\;\left(\log t - y\right) - z\\
\end{array}
\end{array}
if x < -1.4499999999999999e135 or 5.9999999999999998e141 < x Initial program 99.8%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites66.2%
Applied rewrites66.1%
Taylor expanded in x around inf
Applied rewrites75.9%
if -1.4499999999999999e135 < x < 5.9999999999999998e141Initial program 99.9%
Taylor expanded in x around 0
associate--r+N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
lower--.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-log.f6488.2
Applied rewrites88.2%
Final simplification85.1%
(FPCore (x y z t) :precision binary64 (if (or (<= z -410000000.0) (not (<= z 470.0))) (* (fma (- y) (/ -1.0 z) 1.0) (- z)) (- (log t) y)))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -410000000.0) || !(z <= 470.0)) {
tmp = fma(-y, (-1.0 / z), 1.0) * -z;
} else {
tmp = log(t) - y;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if ((z <= -410000000.0) || !(z <= 470.0)) tmp = Float64(fma(Float64(-y), Float64(-1.0 / z), 1.0) * Float64(-z)); else tmp = Float64(log(t) - y); end return tmp end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -410000000.0], N[Not[LessEqual[z, 470.0]], $MachinePrecision]], N[(N[((-y) * N[(-1.0 / z), $MachinePrecision] + 1.0), $MachinePrecision] * (-z)), $MachinePrecision], N[(N[Log[t], $MachinePrecision] - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -410000000 \lor \neg \left(z \leq 470\right):\\
\;\;\;\;\mathsf{fma}\left(-y, \frac{-1}{z}, 1\right) \cdot \left(-z\right)\\
\mathbf{else}:\\
\;\;\;\;\log t - y\\
\end{array}
\end{array}
if z < -4.1e8 or 470 < z Initial program 99.9%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites73.8%
Applied rewrites73.8%
Taylor expanded in z around -inf
Applied rewrites88.7%
Taylor expanded in y around inf
Applied rewrites78.3%
if -4.1e8 < z < 470Initial program 99.9%
Taylor expanded in z around 0
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-log.f64N/A
lower-log.f6499.9
Applied rewrites99.9%
Taylor expanded in x around 0
Applied rewrites66.0%
Final simplification72.0%
(FPCore (x y z t) :precision binary64 (if (or (<= z -410000000.0) (not (<= z 3.25e-111))) (* (fma (- y) (/ -1.0 z) 1.0) (- z)) (* -1.0 y)))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -410000000.0) || !(z <= 3.25e-111)) {
tmp = fma(-y, (-1.0 / z), 1.0) * -z;
} else {
tmp = -1.0 * y;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if ((z <= -410000000.0) || !(z <= 3.25e-111)) tmp = Float64(fma(Float64(-y), Float64(-1.0 / z), 1.0) * Float64(-z)); else tmp = Float64(-1.0 * y); end return tmp end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -410000000.0], N[Not[LessEqual[z, 3.25e-111]], $MachinePrecision]], N[(N[((-y) * N[(-1.0 / z), $MachinePrecision] + 1.0), $MachinePrecision] * (-z)), $MachinePrecision], N[(-1.0 * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -410000000 \lor \neg \left(z \leq 3.25 \cdot 10^{-111}\right):\\
\;\;\;\;\mathsf{fma}\left(-y, \frac{-1}{z}, 1\right) \cdot \left(-z\right)\\
\mathbf{else}:\\
\;\;\;\;-1 \cdot y\\
\end{array}
\end{array}
if z < -4.1e8 or 3.24999999999999987e-111 < z Initial program 99.9%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites75.9%
Applied rewrites75.9%
Taylor expanded in z around -inf
Applied rewrites86.6%
Taylor expanded in y around inf
Applied rewrites72.4%
if -4.1e8 < z < 3.24999999999999987e-111Initial program 99.9%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites90.4%
Taylor expanded in y around inf
Applied rewrites43.9%
Final simplification60.2%
(FPCore (x y z t) :precision binary64 (if (<= y 3e+57) (- z) (* -1.0 y)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 3e+57) {
tmp = -z;
} else {
tmp = -1.0 * 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 <= 3d+57) then
tmp = -z
else
tmp = (-1.0d0) * y
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 3e+57) {
tmp = -z;
} else {
tmp = -1.0 * y;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 3e+57: tmp = -z else: tmp = -1.0 * y return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 3e+57) tmp = Float64(-z); else tmp = Float64(-1.0 * y); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 3e+57) tmp = -z; else tmp = -1.0 * y; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 3e+57], (-z), N[(-1.0 * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3 \cdot 10^{+57}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;-1 \cdot y\\
\end{array}
\end{array}
if y < 3e57Initial program 99.8%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6441.9
Applied rewrites41.9%
if 3e57 < y Initial program 100.0%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.9%
Taylor expanded in y around inf
Applied rewrites67.6%
(FPCore (x y z t) :precision binary64 (- z))
double code(double x, double y, double z, double t) {
return -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 = -z
end function
public static double code(double x, double y, double z, double t) {
return -z;
}
def code(x, y, z, t): return -z
function code(x, y, z, t) return Float64(-z) end
function tmp = code(x, y, z, t) tmp = -z; end
code[x_, y_, z_, t_] := (-z)
\begin{array}{l}
\\
-z
\end{array}
Initial program 99.9%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6431.7
Applied rewrites31.7%
herbie shell --seed 2024337
(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)))