
(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%
(FPCore (x y z t) :precision binary64 (if (<= y 0.00017) (- (+ (* x (log y)) (log t)) z) (- (log t) (+ y z))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 0.00017) {
tmp = ((x * log(y)) + log(t)) - z;
} 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 (y <= 0.00017d0) then
tmp = ((x * log(y)) + log(t)) - z
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 (y <= 0.00017) {
tmp = ((x * Math.log(y)) + Math.log(t)) - z;
} else {
tmp = Math.log(t) - (y + z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 0.00017: tmp = ((x * math.log(y)) + math.log(t)) - z else: tmp = math.log(t) - (y + z) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 0.00017) tmp = Float64(Float64(Float64(x * log(y)) + log(t)) - z); else tmp = Float64(log(t) - Float64(y + z)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 0.00017) tmp = ((x * log(y)) + log(t)) - z; else tmp = log(t) - (y + z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 0.00017], N[(N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] + N[Log[t], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], N[(N[Log[t], $MachinePrecision] - N[(y + z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 0.00017:\\
\;\;\;\;\left(x \cdot \log y + \log t\right) - z\\
\mathbf{else}:\\
\;\;\;\;\log t - \left(y + z\right)\\
\end{array}
\end{array}
if y < 1.7e-4Initial program 99.8%
sub-neg99.8%
associate--l+99.8%
fma-define99.8%
Simplified99.8%
Taylor expanded in y around 0 99.8%
if 1.7e-4 < y Initial program 99.9%
sub-neg99.9%
associate--l+99.9%
fma-define99.9%
Simplified99.9%
Taylor expanded in x around 0 84.6%
Final simplification91.9%
(FPCore (x y z t) :precision binary64 (if (or (<= x -1.9e+149) (not (<= x 5e+76))) (- (* x (log y)) z) (- (log t) (+ y z))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -1.9e+149) || !(x <= 5e+76)) {
tmp = (x * log(y)) - z;
} 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.9d+149)) .or. (.not. (x <= 5d+76))) then
tmp = (x * log(y)) - z
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.9e+149) || !(x <= 5e+76)) {
tmp = (x * Math.log(y)) - z;
} else {
tmp = Math.log(t) - (y + z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x <= -1.9e+149) or not (x <= 5e+76): tmp = (x * math.log(y)) - z else: tmp = math.log(t) - (y + z) return tmp
function code(x, y, z, t) tmp = 0.0 if ((x <= -1.9e+149) || !(x <= 5e+76)) tmp = Float64(Float64(x * log(y)) - z); 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 <= -1.9e+149) || ~((x <= 5e+76))) tmp = (x * log(y)) - z; else tmp = log(t) - (y + z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[x, -1.9e+149], N[Not[LessEqual[x, 5e+76]], $MachinePrecision]], N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], N[(N[Log[t], $MachinePrecision] - N[(y + z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.9 \cdot 10^{+149} \lor \neg \left(x \leq 5 \cdot 10^{+76}\right):\\
\;\;\;\;x \cdot \log y - z\\
\mathbf{else}:\\
\;\;\;\;\log t - \left(y + z\right)\\
\end{array}
\end{array}
if x < -1.9e149 or 4.99999999999999991e76 < x Initial program 99.6%
associate-+l-99.6%
associate--l-99.6%
Simplified99.6%
Taylor expanded in z around inf 91.5%
if -1.9e149 < x < 4.99999999999999991e76Initial program 100.0%
sub-neg100.0%
associate--l+100.0%
fma-define100.0%
Simplified100.0%
Taylor expanded in x around 0 92.3%
Final simplification92.1%
(FPCore (x y z t) :precision binary64 (if (or (<= x -2.3e+89) (not (<= x 1.6e+33))) (- (* x (log y)) y) (- (log t) (+ y z))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -2.3e+89) || !(x <= 1.6e+33)) {
tmp = (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 <= (-2.3d+89)) .or. (.not. (x <= 1.6d+33))) then
tmp = (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 <= -2.3e+89) || !(x <= 1.6e+33)) {
tmp = (x * Math.log(y)) - y;
} else {
tmp = Math.log(t) - (y + z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x <= -2.3e+89) or not (x <= 1.6e+33): tmp = (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 <= -2.3e+89) || !(x <= 1.6e+33)) tmp = Float64(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 <= -2.3e+89) || ~((x <= 1.6e+33))) tmp = (x * log(y)) - y; else tmp = log(t) - (y + z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[x, -2.3e+89], N[Not[LessEqual[x, 1.6e+33]], $MachinePrecision]], N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision], N[(N[Log[t], $MachinePrecision] - N[(y + z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.3 \cdot 10^{+89} \lor \neg \left(x \leq 1.6 \cdot 10^{+33}\right):\\
\;\;\;\;x \cdot \log y - y\\
\mathbf{else}:\\
\;\;\;\;\log t - \left(y + z\right)\\
\end{array}
\end{array}
if x < -2.2999999999999999e89 or 1.60000000000000009e33 < x Initial program 99.7%
associate-+l-99.7%
associate--l-99.7%
Simplified99.7%
Taylor expanded in y around inf 79.0%
if -2.2999999999999999e89 < x < 1.60000000000000009e33Initial program 100.0%
sub-neg100.0%
associate--l+100.0%
fma-define100.0%
Simplified100.0%
Taylor expanded in x around 0 97.7%
Final simplification90.3%
(FPCore (x y z t) :precision binary64 (if (or (<= x -1.35e+150) (not (<= x 3.2e+131))) (* x (log y)) (- (log t) (+ y z))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -1.35e+150) || !(x <= 3.2e+131)) {
tmp = 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 <= (-1.35d+150)) .or. (.not. (x <= 3.2d+131))) then
tmp = 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 <= -1.35e+150) || !(x <= 3.2e+131)) {
tmp = x * Math.log(y);
} else {
tmp = Math.log(t) - (y + z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x <= -1.35e+150) or not (x <= 3.2e+131): tmp = x * math.log(y) else: tmp = math.log(t) - (y + z) return tmp
function code(x, y, z, t) tmp = 0.0 if ((x <= -1.35e+150) || !(x <= 3.2e+131)) tmp = 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 <= -1.35e+150) || ~((x <= 3.2e+131))) tmp = x * log(y); else tmp = log(t) - (y + z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[x, -1.35e+150], N[Not[LessEqual[x, 3.2e+131]], $MachinePrecision]], N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision], N[(N[Log[t], $MachinePrecision] - N[(y + z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.35 \cdot 10^{+150} \lor \neg \left(x \leq 3.2 \cdot 10^{+131}\right):\\
\;\;\;\;x \cdot \log y\\
\mathbf{else}:\\
\;\;\;\;\log t - \left(y + z\right)\\
\end{array}
\end{array}
if x < -1.35000000000000004e150 or 3.2000000000000002e131 < x Initial program 99.6%
associate-+l-99.6%
associate--l-99.6%
Simplified99.6%
Taylor expanded in y around inf 84.1%
Taylor expanded in x around inf 78.0%
if -1.35000000000000004e150 < x < 3.2000000000000002e131Initial program 100.0%
sub-neg100.0%
associate--l+100.0%
fma-define100.0%
Simplified100.0%
Taylor expanded in x around 0 90.2%
Final simplification87.3%
(FPCore (x y z t) :precision binary64 (if (or (<= z -1.2e+62) (not (<= z 9e+53))) (- z) (- (log t) y)))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -1.2e+62) || !(z <= 9e+53)) {
tmp = -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 ((z <= (-1.2d+62)) .or. (.not. (z <= 9d+53))) then
tmp = -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 ((z <= -1.2e+62) || !(z <= 9e+53)) {
tmp = -z;
} else {
tmp = Math.log(t) - y;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -1.2e+62) or not (z <= 9e+53): tmp = -z else: tmp = math.log(t) - y return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -1.2e+62) || !(z <= 9e+53)) tmp = Float64(-z); else tmp = Float64(log(t) - y); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -1.2e+62) || ~((z <= 9e+53))) tmp = -z; else tmp = log(t) - y; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -1.2e+62], N[Not[LessEqual[z, 9e+53]], $MachinePrecision]], (-z), N[(N[Log[t], $MachinePrecision] - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.2 \cdot 10^{+62} \lor \neg \left(z \leq 9 \cdot 10^{+53}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;\log t - y\\
\end{array}
\end{array}
if z < -1.2e62 or 9.0000000000000004e53 < z Initial program 99.9%
sub-neg99.9%
associate--l+99.9%
fma-define99.9%
Simplified99.9%
Taylor expanded in y around 0 87.9%
Taylor expanded in z around inf 71.3%
neg-mul-171.3%
Simplified71.3%
if -1.2e62 < z < 9.0000000000000004e53Initial program 99.8%
sub-neg99.8%
associate--l+99.8%
fma-define99.8%
Simplified99.8%
Taylor expanded in y around inf 62.2%
mul-1-neg62.2%
Simplified62.2%
Taylor expanded in y around 0 62.2%
mul-1-neg62.2%
sub-neg62.2%
Simplified62.2%
Final simplification66.2%
(FPCore (x y z t) :precision binary64 (if (or (<= z -3.7e+62) (not (<= z 1.9e+50))) (- z) (- y)))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -3.7e+62) || !(z <= 1.9e+50)) {
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 ((z <= (-3.7d+62)) .or. (.not. (z <= 1.9d+50))) 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 ((z <= -3.7e+62) || !(z <= 1.9e+50)) {
tmp = -z;
} else {
tmp = -y;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -3.7e+62) or not (z <= 1.9e+50): tmp = -z else: tmp = -y return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -3.7e+62) || !(z <= 1.9e+50)) tmp = Float64(-z); else tmp = Float64(-y); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -3.7e+62) || ~((z <= 1.9e+50))) tmp = -z; else tmp = -y; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -3.7e+62], N[Not[LessEqual[z, 1.9e+50]], $MachinePrecision]], (-z), (-y)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.7 \cdot 10^{+62} \lor \neg \left(z \leq 1.9 \cdot 10^{+50}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;-y\\
\end{array}
\end{array}
if z < -3.70000000000000014e62 or 1.89999999999999994e50 < z Initial program 99.9%
sub-neg99.9%
associate--l+99.9%
fma-define99.9%
Simplified99.9%
Taylor expanded in y around 0 87.4%
Taylor expanded in z around inf 70.4%
neg-mul-170.4%
Simplified70.4%
if -3.70000000000000014e62 < z < 1.89999999999999994e50Initial program 99.8%
sub-neg99.8%
associate--l+99.8%
fma-define99.8%
Simplified99.8%
Taylor expanded in y around inf 62.7%
mul-1-neg62.7%
Simplified62.7%
Taylor expanded in y around inf 43.1%
mul-1-neg43.1%
Simplified43.1%
Final simplification55.6%
(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%
sub-neg99.9%
associate--l+99.9%
fma-define99.9%
Simplified99.9%
Taylor expanded in y around inf 40.5%
mul-1-neg40.5%
Simplified40.5%
Taylor expanded in y around inf 29.8%
mul-1-neg29.8%
Simplified29.8%
herbie shell --seed 2024181
(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)))