
(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) (- (- y) z)) (log t)))
double code(double x, double y, double z, double t) {
return fma(x, log(y), (-y - z)) + log(t);
}
function code(x, y, z, t) return Float64(fma(x, log(y), Float64(Float64(-y) - z)) + log(t)) end
code[x_, y_, z_, t_] := N[(N[(x * N[Log[y], $MachinePrecision] + N[((-y) - z), $MachinePrecision]), $MachinePrecision] + N[Log[t], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(x, \log y, \left(-y\right) - z\right) + \log t
\end{array}
Initial program 99.9%
sub-neg99.9%
associate--l+99.9%
fma-def99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (- (* x (log y)) y)))
(if (or (<= t_1 -500000000000.0) (not (<= t_1 1e-6)))
(- (fma (log y) x (- y)) z)
(- (log t) (+ y z)))))
double code(double x, double y, double z, double t) {
double t_1 = (x * log(y)) - y;
double tmp;
if ((t_1 <= -500000000000.0) || !(t_1 <= 1e-6)) {
tmp = fma(log(y), x, -y) - z;
} else {
tmp = log(t) - (y + z);
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(Float64(x * log(y)) - y) tmp = 0.0 if ((t_1 <= -500000000000.0) || !(t_1 <= 1e-6)) tmp = Float64(fma(log(y), x, Float64(-y)) - z); else tmp = Float64(log(t) - Float64(y + z)); end return 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, -500000000000.0], N[Not[LessEqual[t$95$1, 1e-6]], $MachinePrecision]], N[(N[(N[Log[y], $MachinePrecision] * x + (-y)), $MachinePrecision] - z), $MachinePrecision], N[(N[Log[t], $MachinePrecision] - N[(y + z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x \cdot \log y - y\\
\mathbf{if}\;t\_1 \leq -500000000000 \lor \neg \left(t\_1 \leq 10^{-6}\right):\\
\;\;\;\;\mathsf{fma}\left(\log y, x, -y\right) - z\\
\mathbf{else}:\\
\;\;\;\;\log t - \left(y + z\right)\\
\end{array}
\end{array}
if (-.f64 (*.f64 x (log.f64 y)) y) < -5e11 or 9.99999999999999955e-7 < (-.f64 (*.f64 x (log.f64 y)) y) Initial program 99.8%
associate-+l-99.8%
Simplified99.8%
add-cube-cbrt99.2%
pow399.2%
Applied egg-rr99.2%
Taylor expanded in z around inf 99.0%
Taylor expanded in y around 0 99.6%
neg-mul-199.6%
+-commutative99.6%
pow-base-199.6%
*-commutative99.6%
*-lft-identity99.6%
fma-def99.7%
Simplified99.7%
if -5e11 < (-.f64 (*.f64 x (log.f64 y)) y) < 9.99999999999999955e-7Initial program 100.0%
sub-neg100.0%
associate--l+100.0%
fma-def100.0%
Simplified100.0%
Taylor expanded in x around 0 98.2%
Final simplification99.3%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (- (* x (log y)) y)))
(if (or (<= t_1 -500000000000.0) (not (<= t_1 1e-6)))
(- t_1 z)
(- (log t) (+ y z)))))
double code(double x, double y, double z, double t) {
double t_1 = (x * log(y)) - y;
double tmp;
if ((t_1 <= -500000000000.0) || !(t_1 <= 1e-6)) {
tmp = t_1 - 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) :: t_1
real(8) :: tmp
t_1 = (x * log(y)) - y
if ((t_1 <= (-500000000000.0d0)) .or. (.not. (t_1 <= 1d-6))) then
tmp = t_1 - 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 t_1 = (x * Math.log(y)) - y;
double tmp;
if ((t_1 <= -500000000000.0) || !(t_1 <= 1e-6)) {
tmp = t_1 - z;
} else {
tmp = Math.log(t) - (y + z);
}
return tmp;
}
def code(x, y, z, t): t_1 = (x * math.log(y)) - y tmp = 0 if (t_1 <= -500000000000.0) or not (t_1 <= 1e-6): tmp = t_1 - z else: tmp = math.log(t) - (y + z) return tmp
function code(x, y, z, t) t_1 = Float64(Float64(x * log(y)) - y) tmp = 0.0 if ((t_1 <= -500000000000.0) || !(t_1 <= 1e-6)) tmp = Float64(t_1 - z); else tmp = Float64(log(t) - Float64(y + z)); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = (x * log(y)) - y; tmp = 0.0; if ((t_1 <= -500000000000.0) || ~((t_1 <= 1e-6))) tmp = t_1 - z; else tmp = log(t) - (y + z); 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, -500000000000.0], N[Not[LessEqual[t$95$1, 1e-6]], $MachinePrecision]], N[(t$95$1 - z), $MachinePrecision], N[(N[Log[t], $MachinePrecision] - N[(y + z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x \cdot \log y - y\\
\mathbf{if}\;t\_1 \leq -500000000000 \lor \neg \left(t\_1 \leq 10^{-6}\right):\\
\;\;\;\;t\_1 - z\\
\mathbf{else}:\\
\;\;\;\;\log t - \left(y + z\right)\\
\end{array}
\end{array}
if (-.f64 (*.f64 x (log.f64 y)) y) < -5e11 or 9.99999999999999955e-7 < (-.f64 (*.f64 x (log.f64 y)) y) Initial program 99.8%
associate-+l-99.8%
Simplified99.8%
Taylor expanded in z around inf 99.6%
if -5e11 < (-.f64 (*.f64 x (log.f64 y)) y) < 9.99999999999999955e-7Initial program 100.0%
sub-neg100.0%
associate--l+100.0%
fma-def100.0%
Simplified100.0%
Taylor expanded in x around 0 98.2%
Final simplification99.3%
(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 -3.2e+19) (not (<= z 3.5e-6))) (- (- y) z) (- (log t) y)))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -3.2e+19) || !(z <= 3.5e-6)) {
tmp = -y - 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 <= (-3.2d+19)) .or. (.not. (z <= 3.5d-6))) then
tmp = -y - 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 <= -3.2e+19) || !(z <= 3.5e-6)) {
tmp = -y - z;
} else {
tmp = Math.log(t) - y;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -3.2e+19) or not (z <= 3.5e-6): tmp = -y - z else: tmp = math.log(t) - y return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -3.2e+19) || !(z <= 3.5e-6)) tmp = Float64(Float64(-y) - z); else tmp = Float64(log(t) - y); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -3.2e+19) || ~((z <= 3.5e-6))) tmp = -y - z; else tmp = log(t) - y; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -3.2e+19], N[Not[LessEqual[z, 3.5e-6]], $MachinePrecision]], N[((-y) - z), $MachinePrecision], N[(N[Log[t], $MachinePrecision] - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.2 \cdot 10^{+19} \lor \neg \left(z \leq 3.5 \cdot 10^{-6}\right):\\
\;\;\;\;\left(-y\right) - z\\
\mathbf{else}:\\
\;\;\;\;\log t - y\\
\end{array}
\end{array}
if z < -3.2e19 or 3.49999999999999995e-6 < z Initial program 99.9%
associate-+l-99.9%
Simplified99.9%
add-cube-cbrt99.6%
pow399.6%
Applied egg-rr99.6%
Taylor expanded in z around inf 98.6%
Taylor expanded in x around 0 82.0%
neg-mul-182.0%
Simplified82.0%
if -3.2e19 < z < 3.49999999999999995e-6Initial program 99.8%
sub-neg99.8%
associate--l+99.8%
fma-def99.8%
Simplified99.8%
Taylor expanded in y around inf 54.8%
mul-1-neg54.8%
Simplified54.8%
Taylor expanded in y around 0 54.8%
mul-1-neg54.8%
sub-neg54.8%
Simplified54.8%
Final simplification67.9%
(FPCore (x y z t) :precision binary64 (if (<= y 2.1e+15) (- (log t) z) (- (- y) z)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 2.1e+15) {
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 <= 2.1d+15) 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 <= 2.1e+15) {
tmp = Math.log(t) - z;
} else {
tmp = -y - z;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 2.1e+15: tmp = math.log(t) - z else: tmp = -y - z return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 2.1e+15) 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 <= 2.1e+15) tmp = log(t) - z; else tmp = -y - z; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 2.1e+15], N[(N[Log[t], $MachinePrecision] - z), $MachinePrecision], N[((-y) - z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.1 \cdot 10^{+15}:\\
\;\;\;\;\log t - z\\
\mathbf{else}:\\
\;\;\;\;\left(-y\right) - z\\
\end{array}
\end{array}
if y < 2.1e15Initial program 99.8%
sub-neg99.8%
associate--l+99.8%
fma-def99.8%
Simplified99.8%
Taylor expanded in x around 0 60.3%
Taylor expanded in y around 0 59.8%
if 2.1e15 < y Initial program 99.9%
associate-+l-99.9%
Simplified99.9%
add-cube-cbrt99.5%
pow399.5%
Applied egg-rr99.5%
Taylor expanded in z around inf 99.5%
Taylor expanded in x around 0 76.4%
neg-mul-176.4%
Simplified76.4%
Final simplification68.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%
sub-neg99.9%
associate--l+99.9%
fma-def99.9%
Simplified99.9%
Taylor expanded in x around 0 68.5%
Final simplification68.5%
(FPCore (x y z t) :precision binary64 (if (<= y 2.35e+31) (- z) (- y)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 2.35e+31) {
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.35d+31) 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.35e+31) {
tmp = -z;
} else {
tmp = -y;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 2.35e+31: tmp = -z else: tmp = -y return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 2.35e+31) 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.35e+31) tmp = -z; else tmp = -y; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 2.35e+31], (-z), (-y)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.35 \cdot 10^{+31}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;-y\\
\end{array}
\end{array}
if y < 2.3500000000000001e31Initial program 99.8%
sub-neg99.8%
associate--l+99.8%
fma-def99.8%
Simplified99.8%
Taylor expanded in x around 0 60.1%
Taylor expanded in z around inf 33.9%
neg-mul-133.9%
Simplified33.9%
if 2.3500000000000001e31 < y Initial program 99.9%
sub-neg99.9%
associate--l+99.9%
fma-def99.9%
Simplified99.9%
Taylor expanded in y around inf 56.0%
mul-1-neg56.0%
Simplified56.0%
Taylor expanded in y around inf 56.0%
mul-1-neg56.0%
Simplified56.0%
Final simplification44.8%
(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}
Initial program 99.9%
associate-+l-99.9%
Simplified99.9%
add-cube-cbrt99.3%
pow399.4%
Applied egg-rr99.4%
Taylor expanded in z around inf 85.8%
Taylor expanded in x around 0 55.3%
neg-mul-155.3%
Simplified55.3%
Final simplification55.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 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-def99.9%
Simplified99.9%
Taylor expanded in y around inf 41.8%
mul-1-neg41.8%
Simplified41.8%
Taylor expanded in y around inf 29.1%
mul-1-neg29.1%
Simplified29.1%
Final simplification29.1%
herbie shell --seed 2024031
(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)))