
(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 10 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) (+ y z))))
double code(double x, double y, double z, double t) {
return fma(x, log(y), (log(t) - (y + z)));
}
function code(x, y, z, t) return fma(x, log(y), Float64(log(t) - Float64(y + z))) end
code[x_, y_, z_, t_] := N[(x * N[Log[y], $MachinePrecision] + N[(N[Log[t], $MachinePrecision] - N[(y + z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(x, \log y, \log t - \left(y + z\right)\right)
\end{array}
Initial program 99.9%
+-commutative99.9%
associate--l-99.9%
associate-+r-99.9%
+-commutative99.9%
associate--l+99.9%
fma-def99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y z t) :precision binary64 (if (or (<= z -3.05e+56) (not (<= z 1.3e+25))) (- (log t) (+ y z)) (- (+ (log t) (* x (log y))) y)))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -3.05e+56) || !(z <= 1.3e+25)) {
tmp = log(t) - (y + z);
} else {
tmp = (log(t) + (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 <= (-3.05d+56)) .or. (.not. (z <= 1.3d+25))) then
tmp = log(t) - (y + z)
else
tmp = (log(t) + (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 <= -3.05e+56) || !(z <= 1.3e+25)) {
tmp = Math.log(t) - (y + z);
} else {
tmp = (Math.log(t) + (x * Math.log(y))) - y;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -3.05e+56) or not (z <= 1.3e+25): tmp = math.log(t) - (y + z) else: tmp = (math.log(t) + (x * math.log(y))) - y return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -3.05e+56) || !(z <= 1.3e+25)) tmp = Float64(log(t) - Float64(y + z)); else tmp = Float64(Float64(log(t) + Float64(x * log(y))) - y); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -3.05e+56) || ~((z <= 1.3e+25))) tmp = log(t) - (y + z); else tmp = (log(t) + (x * log(y))) - y; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -3.05e+56], N[Not[LessEqual[z, 1.3e+25]], $MachinePrecision]], N[(N[Log[t], $MachinePrecision] - N[(y + z), $MachinePrecision]), $MachinePrecision], N[(N[(N[Log[t], $MachinePrecision] + N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.05 \cdot 10^{+56} \lor \neg \left(z \leq 1.3 \cdot 10^{+25}\right):\\
\;\;\;\;\log t - \left(y + z\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\log t + x \cdot \log y\right) - y\\
\end{array}
\end{array}
if z < -3.0500000000000001e56 or 1.2999999999999999e25 < z Initial program 100.0%
+-commutative100.0%
associate--l-100.0%
associate-+r-100.0%
+-commutative100.0%
associate--l+100.0%
fma-def100.0%
Simplified100.0%
Taylor expanded in x around 0 82.6%
if -3.0500000000000001e56 < z < 1.2999999999999999e25Initial program 99.8%
+-commutative99.8%
associate--l-99.8%
associate-+r-99.8%
+-commutative99.8%
associate--l+99.8%
fma-def99.8%
Simplified99.8%
Taylor expanded in z around 0 97.4%
Final simplification91.4%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (+ (log t) (* x (log y)))))
(if (<= z -3e+56)
(- (log t) (+ y z))
(if (<= z 3.5e-21) (- t_1 y) (- t_1 z)))))
double code(double x, double y, double z, double t) {
double t_1 = log(t) + (x * log(y));
double tmp;
if (z <= -3e+56) {
tmp = log(t) - (y + z);
} else if (z <= 3.5e-21) {
tmp = t_1 - y;
} else {
tmp = 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) :: tmp
t_1 = log(t) + (x * log(y))
if (z <= (-3d+56)) then
tmp = log(t) - (y + z)
else if (z <= 3.5d-21) then
tmp = t_1 - y
else
tmp = t_1 - z
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 <= -3e+56) {
tmp = Math.log(t) - (y + z);
} else if (z <= 3.5e-21) {
tmp = t_1 - y;
} else {
tmp = t_1 - z;
}
return tmp;
}
def code(x, y, z, t): t_1 = math.log(t) + (x * math.log(y)) tmp = 0 if z <= -3e+56: tmp = math.log(t) - (y + z) elif z <= 3.5e-21: tmp = t_1 - y else: tmp = t_1 - z return tmp
function code(x, y, z, t) t_1 = Float64(log(t) + Float64(x * log(y))) tmp = 0.0 if (z <= -3e+56) tmp = Float64(log(t) - Float64(y + z)); elseif (z <= 3.5e-21) tmp = Float64(t_1 - y); else tmp = Float64(t_1 - z); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = log(t) + (x * log(y)); tmp = 0.0; if (z <= -3e+56) tmp = log(t) - (y + z); elseif (z <= 3.5e-21) tmp = t_1 - y; else tmp = t_1 - z; 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[LessEqual[z, -3e+56], N[(N[Log[t], $MachinePrecision] - N[(y + z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 3.5e-21], N[(t$95$1 - y), $MachinePrecision], N[(t$95$1 - z), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \log t + x \cdot \log y\\
\mathbf{if}\;z \leq -3 \cdot 10^{+56}:\\
\;\;\;\;\log t - \left(y + z\right)\\
\mathbf{elif}\;z \leq 3.5 \cdot 10^{-21}:\\
\;\;\;\;t_1 - y\\
\mathbf{else}:\\
\;\;\;\;t_1 - z\\
\end{array}
\end{array}
if z < -3.00000000000000006e56Initial program 100.0%
+-commutative100.0%
associate--l-100.0%
associate-+r-100.0%
+-commutative100.0%
associate--l+100.0%
fma-def100.0%
Simplified100.0%
Taylor expanded in x around 0 87.3%
if -3.00000000000000006e56 < z < 3.5000000000000003e-21Initial program 99.8%
+-commutative99.8%
associate--l-99.8%
associate-+r-99.8%
+-commutative99.8%
associate--l+99.8%
fma-def99.8%
Simplified99.8%
Taylor expanded in z around 0 97.4%
if 3.5000000000000003e-21 < z Initial program 99.9%
+-commutative99.9%
associate--l-99.9%
associate-+r-99.9%
+-commutative99.9%
associate--l+99.9%
fma-def99.9%
Simplified99.9%
Taylor expanded in y around 0 86.3%
Final simplification92.8%
(FPCore (x y z t) :precision binary64 (if (or (<= x -6.2e+127) (not (<= x 2.55e+151))) (+ (log t) (* x (log y))) (- (log t) (+ y z))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -6.2e+127) || !(x <= 2.55e+151)) {
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 <= (-6.2d+127)) .or. (.not. (x <= 2.55d+151))) 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 <= -6.2e+127) || !(x <= 2.55e+151)) {
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 <= -6.2e+127) or not (x <= 2.55e+151): 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 <= -6.2e+127) || !(x <= 2.55e+151)) 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 <= -6.2e+127) || ~((x <= 2.55e+151))) 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, -6.2e+127], N[Not[LessEqual[x, 2.55e+151]], $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 -6.2 \cdot 10^{+127} \lor \neg \left(x \leq 2.55 \cdot 10^{+151}\right):\\
\;\;\;\;\log t + x \cdot \log y\\
\mathbf{else}:\\
\;\;\;\;\log t - \left(y + z\right)\\
\end{array}
\end{array}
if x < -6.2000000000000005e127 or 2.54999999999999998e151 < x Initial program 99.7%
associate--l-99.7%
add-cube-cbrt98.4%
associate-*r*98.6%
fma-neg98.6%
pow298.6%
Applied egg-rr98.6%
Taylor expanded in x around inf 80.9%
pow-base-180.9%
*-lft-identity80.9%
Simplified80.9%
if -6.2000000000000005e127 < x < 2.54999999999999998e151Initial program 100.0%
+-commutative100.0%
associate--l-100.0%
associate-+r-100.0%
+-commutative100.0%
associate--l+100.0%
fma-def100.0%
Simplified100.0%
Taylor expanded in x around 0 90.1%
Final simplification87.0%
(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}
Initial program 99.9%
Final simplification99.9%
(FPCore (x y z t) :precision binary64 (if (or (<= z -0.029) (not (<= z 2.4e-9))) (- (log t) z) (- (log t) y)))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -0.029) || !(z <= 2.4e-9)) {
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 ((z <= (-0.029d0)) .or. (.not. (z <= 2.4d-9))) 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 ((z <= -0.029) || !(z <= 2.4e-9)) {
tmp = Math.log(t) - z;
} else {
tmp = Math.log(t) - y;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -0.029) or not (z <= 2.4e-9): tmp = math.log(t) - z else: tmp = math.log(t) - y return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -0.029) || !(z <= 2.4e-9)) 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 ((z <= -0.029) || ~((z <= 2.4e-9))) tmp = log(t) - z; else tmp = log(t) - y; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -0.029], N[Not[LessEqual[z, 2.4e-9]], $MachinePrecision]], N[(N[Log[t], $MachinePrecision] - z), $MachinePrecision], N[(N[Log[t], $MachinePrecision] - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.029 \lor \neg \left(z \leq 2.4 \cdot 10^{-9}\right):\\
\;\;\;\;\log t - z\\
\mathbf{else}:\\
\;\;\;\;\log t - y\\
\end{array}
\end{array}
if z < -0.0290000000000000015 or 2.4e-9 < z Initial program 99.9%
Taylor expanded in z around inf 62.7%
neg-mul-162.7%
Simplified62.7%
if -0.0290000000000000015 < z < 2.4e-9Initial program 99.8%
Taylor expanded in y around inf 56.2%
neg-mul-156.2%
Simplified56.2%
Taylor expanded in y around 0 56.2%
+-commutative56.2%
mul-1-neg56.2%
sub-neg56.2%
Simplified56.2%
Final simplification59.2%
(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%
+-commutative99.9%
associate--l-99.9%
associate-+r-99.9%
+-commutative99.9%
associate--l+99.9%
fma-def99.9%
Simplified99.9%
Taylor expanded in x around 0 66.3%
Final simplification66.3%
(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.9%
Taylor expanded in y around inf 38.5%
neg-mul-138.5%
Simplified38.5%
Taylor expanded in y around 0 38.5%
+-commutative38.5%
mul-1-neg38.5%
sub-neg38.5%
Simplified38.5%
Final simplification38.5%
(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.9%
Taylor expanded in y around inf 38.5%
neg-mul-138.5%
Simplified38.5%
Taylor expanded in y around 0 15.3%
Final simplification15.3%
(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 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 38.5%
neg-mul-138.5%
Simplified38.5%
expm1-log1p-u4.3%
expm1-udef4.3%
add-sqr-sqrt0.0%
sqrt-unprod5.3%
sqr-neg5.3%
sqrt-unprod5.3%
add-sqr-sqrt5.3%
Applied egg-rr5.3%
expm1-def5.3%
expm1-log1p14.9%
Simplified14.9%
Taylor expanded in y around inf 2.2%
Final simplification2.2%
herbie shell --seed 2023192
(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)))