
(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 (fma (log y) x (- (log t) (+ y z))))
double code(double x, double y, double z, double t) {
return fma(log(y), x, (log(t) - (y + z)));
}
function code(x, y, z, t) return fma(log(y), x, Float64(log(t) - Float64(y + z))) end
code[x_, y_, z_, t_] := N[(N[Log[y], $MachinePrecision] * x + N[(N[Log[t], $MachinePrecision] - N[(y + z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\log y, x, \log t - \left(y + z\right)\right)
\end{array}
Initial program 99.8%
Taylor expanded in x around 0 99.8%
associate--l+99.8%
+-commutative99.8%
associate--l-99.8%
fma-def99.8%
associate--l-99.8%
+-commutative99.8%
Simplified99.8%
Final simplification99.8%
(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}
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%
Final simplification99.8%
(FPCore (x y z t) :precision binary64 (+ (log t) (- (- (* (log y) x) y) z)))
double code(double x, double y, double z, double t) {
return log(t) + (((log(y) * x) - 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) + (((log(y) * x) - y) - z)
end function
public static double code(double x, double y, double z, double t) {
return Math.log(t) + (((Math.log(y) * x) - y) - z);
}
def code(x, y, z, t): return math.log(t) + (((math.log(y) * x) - y) - z)
function code(x, y, z, t) return Float64(log(t) + Float64(Float64(Float64(log(y) * x) - y) - z)) end
function tmp = code(x, y, z, t) tmp = log(t) + (((log(y) * x) - y) - z); end
code[x_, y_, z_, t_] := N[(N[Log[t], $MachinePrecision] + N[(N[(N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision] - y), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\log t + \left(\left(\log y \cdot x - y\right) - z\right)
\end{array}
Initial program 99.8%
Final simplification99.8%
(FPCore (x y z t) :precision binary64 (if (or (<= x -5.5e+36) (not (<= x 2.7e+62))) (fma (log y) x (- y)) (- (- (log t) z) y)))
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -5.5e+36) || !(x <= 2.7e+62)) {
tmp = fma(log(y), x, -y);
} else {
tmp = (log(t) - z) - y;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if ((x <= -5.5e+36) || !(x <= 2.7e+62)) tmp = fma(log(y), x, Float64(-y)); else tmp = Float64(Float64(log(t) - z) - y); end return tmp end
code[x_, y_, z_, t_] := If[Or[LessEqual[x, -5.5e+36], N[Not[LessEqual[x, 2.7e+62]], $MachinePrecision]], N[(N[Log[y], $MachinePrecision] * x + (-y)), $MachinePrecision], N[(N[(N[Log[t], $MachinePrecision] - z), $MachinePrecision] - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.5 \cdot 10^{+36} \lor \neg \left(x \leq 2.7 \cdot 10^{+62}\right):\\
\;\;\;\;\mathsf{fma}\left(\log y, x, -y\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\log t - z\right) - y\\
\end{array}
\end{array}
if x < -5.5000000000000002e36 or 2.7e62 < x Initial program 99.6%
Taylor expanded in x around 0 99.6%
associate--l+99.6%
+-commutative99.6%
associate--l-99.6%
fma-def99.7%
associate--l-99.7%
+-commutative99.7%
Simplified99.7%
Taylor expanded in y around inf 82.1%
neg-mul-182.1%
Simplified82.1%
if -5.5000000000000002e36 < x < 2.7e62Initial program 100.0%
Taylor expanded in x around 0 97.7%
+-commutative97.7%
associate--l-97.7%
Simplified97.7%
Final simplification90.9%
(FPCore (x y z t) :precision binary64 (if (<= x -3.9e+36) (fma (log y) x (- y)) (if (<= x 1.35e+42) (- (- (log t) z) y) (fma (log y) x (- z)))))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -3.9e+36) {
tmp = fma(log(y), x, -y);
} else if (x <= 1.35e+42) {
tmp = (log(t) - z) - y;
} else {
tmp = fma(log(y), x, -z);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (x <= -3.9e+36) tmp = fma(log(y), x, Float64(-y)); elseif (x <= 1.35e+42) tmp = Float64(Float64(log(t) - z) - y); else tmp = fma(log(y), x, Float64(-z)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[x, -3.9e+36], N[(N[Log[y], $MachinePrecision] * x + (-y)), $MachinePrecision], If[LessEqual[x, 1.35e+42], N[(N[(N[Log[t], $MachinePrecision] - z), $MachinePrecision] - y), $MachinePrecision], N[(N[Log[y], $MachinePrecision] * x + (-z)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.9 \cdot 10^{+36}:\\
\;\;\;\;\mathsf{fma}\left(\log y, x, -y\right)\\
\mathbf{elif}\;x \leq 1.35 \cdot 10^{+42}:\\
\;\;\;\;\left(\log t - z\right) - y\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\log y, x, -z\right)\\
\end{array}
\end{array}
if x < -3.90000000000000021e36Initial program 99.7%
Taylor expanded in x around 0 99.7%
associate--l+99.7%
+-commutative99.7%
associate--l-99.7%
fma-def99.7%
associate--l-99.7%
+-commutative99.7%
Simplified99.7%
Taylor expanded in y around inf 80.7%
neg-mul-180.7%
Simplified80.7%
if -3.90000000000000021e36 < x < 1.35e42Initial program 100.0%
Taylor expanded in x around 0 98.0%
+-commutative98.0%
associate--l-98.0%
Simplified98.0%
if 1.35e42 < x Initial program 99.6%
Taylor expanded in x around 0 99.6%
associate--l+99.6%
+-commutative99.6%
associate--l-99.6%
fma-def99.6%
associate--l-99.6%
+-commutative99.6%
Simplified99.6%
Taylor expanded in z around inf 91.5%
mul-1-neg91.5%
Simplified91.5%
Final simplification92.3%
(FPCore (x y z t) :precision binary64 (if (<= y 4.3e+39) (- (log t) z) (- (log t) y)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 4.3e+39) {
tmp = log(t) - z;
} 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 (y <= 4.3d+39) then
tmp = log(t) - z
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 (y <= 4.3e+39) {
tmp = Math.log(t) - z;
} else {
tmp = Math.log(t) - y;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 4.3e+39: tmp = math.log(t) - z else: tmp = math.log(t) - y return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 4.3e+39) tmp = Float64(log(t) - z); else tmp = Float64(log(t) - y); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 4.3e+39) tmp = log(t) - z; else tmp = log(t) - y; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 4.3e+39], N[(N[Log[t], $MachinePrecision] - z), $MachinePrecision], N[(N[Log[t], $MachinePrecision] - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.3 \cdot 10^{+39}:\\
\;\;\;\;\log t - z\\
\mathbf{else}:\\
\;\;\;\;\log t - y\\
\end{array}
\end{array}
if y < 4.3e39Initial program 99.8%
Taylor expanded in z around inf 61.7%
neg-mul-161.7%
Simplified61.7%
if 4.3e39 < y Initial program 99.9%
Taylor expanded in x around 0 78.2%
+-commutative78.2%
associate--l-78.2%
Simplified78.2%
Taylor expanded in z around 0 64.4%
Final simplification63.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.8%
Taylor expanded in x around 0 71.0%
+-commutative71.0%
associate--l-71.0%
Simplified71.0%
Final simplification71.0%
(FPCore (x y z t) :precision binary64 (- (log t) y))
double code(double x, double y, double z, double t) {
return log(t) - 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) - y
end function
public static double code(double x, double y, double z, double t) {
return Math.log(t) - y;
}
def code(x, y, z, t): return math.log(t) - y
function code(x, y, z, t) return Float64(log(t) - y) end
function tmp = code(x, y, z, t) tmp = log(t) - y; end
code[x_, y_, z_, t_] := N[(N[Log[t], $MachinePrecision] - y), $MachinePrecision]
\begin{array}{l}
\\
\log t - y
\end{array}
Initial program 99.8%
Taylor expanded in x around 0 71.0%
+-commutative71.0%
associate--l-71.0%
Simplified71.0%
Taylor expanded in z around 0 47.8%
Final simplification47.8%
(FPCore (x y z t) :precision binary64 (log t))
double code(double x, double y, double z, double t) {
return 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 = log(t)
end function
public static double code(double x, double y, double z, double t) {
return Math.log(t);
}
def code(x, y, z, t): return math.log(t)
function code(x, y, z, t) return log(t) end
function tmp = code(x, y, z, t) tmp = log(t); end
code[x_, y_, z_, t_] := N[Log[t], $MachinePrecision]
\begin{array}{l}
\\
\log t
\end{array}
Initial program 99.8%
Taylor expanded in z around inf 38.7%
neg-mul-138.7%
Simplified38.7%
Taylor expanded in z around 0 16.0%
Final simplification16.0%
herbie shell --seed 2023279
(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)))