
(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 7 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%
Final simplification99.9%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* x (log y)))) (if (<= y 2.55e-8) (- (+ t_1 (log t)) z) (- t_1 (+ y z)))))
double code(double x, double y, double z, double t) {
double t_1 = x * log(y);
double tmp;
if (y <= 2.55e-8) {
tmp = (t_1 + log(t)) - z;
} else {
tmp = t_1 - (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)
if (y <= 2.55d-8) then
tmp = (t_1 + log(t)) - z
else
tmp = t_1 - (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);
double tmp;
if (y <= 2.55e-8) {
tmp = (t_1 + Math.log(t)) - z;
} else {
tmp = t_1 - (y + z);
}
return tmp;
}
def code(x, y, z, t): t_1 = x * math.log(y) tmp = 0 if y <= 2.55e-8: tmp = (t_1 + math.log(t)) - z else: tmp = t_1 - (y + z) return tmp
function code(x, y, z, t) t_1 = Float64(x * log(y)) tmp = 0.0 if (y <= 2.55e-8) tmp = Float64(Float64(t_1 + log(t)) - z); else tmp = Float64(t_1 - Float64(y + z)); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = x * log(y); tmp = 0.0; if (y <= 2.55e-8) tmp = (t_1 + log(t)) - z; else tmp = t_1 - (y + z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, 2.55e-8], N[(N[(t$95$1 + N[Log[t], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], N[(t$95$1 - N[(y + z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x \cdot \log y\\
\mathbf{if}\;y \leq 2.55 \cdot 10^{-8}:\\
\;\;\;\;\left(t_1 + \log t\right) - z\\
\mathbf{else}:\\
\;\;\;\;t_1 - \left(y + z\right)\\
\end{array}
\end{array}
if y < 2.55e-8Initial program 99.8%
Taylor expanded in y around 0 99.5%
if 2.55e-8 < y Initial program 99.9%
Taylor expanded in x around 0 99.9%
log-pow54.2%
log-prod54.2%
Simplified54.2%
*-commutative54.2%
log-prod54.2%
pow-to-exp54.2%
rem-log-exp99.9%
add-cube-cbrt99.6%
unpow299.6%
associate-*l*99.6%
fma-def99.6%
Applied egg-rr99.6%
Taylor expanded in x around inf 99.8%
pow-base-199.8%
associate-*r*99.8%
*-lft-identity99.8%
Simplified99.8%
Final simplification99.6%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* x (log y))))
(if (<= y 1.6e-251)
(- z)
(if (<= y 2.95e-210)
t_1
(if (<= y 2.6e-120)
(- z)
(if (<= y 5.5e-75)
t_1
(if (<= y 3.5e-57)
(- z)
(if (<= y 2.5e-33)
t_1
(if (<= y 3400000000000.0)
(- z)
(if (<= y 6.1e+28)
t_1
(if (<= y 1.6e+104) (- z) (- y))))))))))))
double code(double x, double y, double z, double t) {
double t_1 = x * log(y);
double tmp;
if (y <= 1.6e-251) {
tmp = -z;
} else if (y <= 2.95e-210) {
tmp = t_1;
} else if (y <= 2.6e-120) {
tmp = -z;
} else if (y <= 5.5e-75) {
tmp = t_1;
} else if (y <= 3.5e-57) {
tmp = -z;
} else if (y <= 2.5e-33) {
tmp = t_1;
} else if (y <= 3400000000000.0) {
tmp = -z;
} else if (y <= 6.1e+28) {
tmp = t_1;
} else if (y <= 1.6e+104) {
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) :: t_1
real(8) :: tmp
t_1 = x * log(y)
if (y <= 1.6d-251) then
tmp = -z
else if (y <= 2.95d-210) then
tmp = t_1
else if (y <= 2.6d-120) then
tmp = -z
else if (y <= 5.5d-75) then
tmp = t_1
else if (y <= 3.5d-57) then
tmp = -z
else if (y <= 2.5d-33) then
tmp = t_1
else if (y <= 3400000000000.0d0) then
tmp = -z
else if (y <= 6.1d+28) then
tmp = t_1
else if (y <= 1.6d+104) 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 t_1 = x * Math.log(y);
double tmp;
if (y <= 1.6e-251) {
tmp = -z;
} else if (y <= 2.95e-210) {
tmp = t_1;
} else if (y <= 2.6e-120) {
tmp = -z;
} else if (y <= 5.5e-75) {
tmp = t_1;
} else if (y <= 3.5e-57) {
tmp = -z;
} else if (y <= 2.5e-33) {
tmp = t_1;
} else if (y <= 3400000000000.0) {
tmp = -z;
} else if (y <= 6.1e+28) {
tmp = t_1;
} else if (y <= 1.6e+104) {
tmp = -z;
} else {
tmp = -y;
}
return tmp;
}
def code(x, y, z, t): t_1 = x * math.log(y) tmp = 0 if y <= 1.6e-251: tmp = -z elif y <= 2.95e-210: tmp = t_1 elif y <= 2.6e-120: tmp = -z elif y <= 5.5e-75: tmp = t_1 elif y <= 3.5e-57: tmp = -z elif y <= 2.5e-33: tmp = t_1 elif y <= 3400000000000.0: tmp = -z elif y <= 6.1e+28: tmp = t_1 elif y <= 1.6e+104: tmp = -z else: tmp = -y return tmp
function code(x, y, z, t) t_1 = Float64(x * log(y)) tmp = 0.0 if (y <= 1.6e-251) tmp = Float64(-z); elseif (y <= 2.95e-210) tmp = t_1; elseif (y <= 2.6e-120) tmp = Float64(-z); elseif (y <= 5.5e-75) tmp = t_1; elseif (y <= 3.5e-57) tmp = Float64(-z); elseif (y <= 2.5e-33) tmp = t_1; elseif (y <= 3400000000000.0) tmp = Float64(-z); elseif (y <= 6.1e+28) tmp = t_1; elseif (y <= 1.6e+104) tmp = Float64(-z); else tmp = Float64(-y); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = x * log(y); tmp = 0.0; if (y <= 1.6e-251) tmp = -z; elseif (y <= 2.95e-210) tmp = t_1; elseif (y <= 2.6e-120) tmp = -z; elseif (y <= 5.5e-75) tmp = t_1; elseif (y <= 3.5e-57) tmp = -z; elseif (y <= 2.5e-33) tmp = t_1; elseif (y <= 3400000000000.0) tmp = -z; elseif (y <= 6.1e+28) tmp = t_1; elseif (y <= 1.6e+104) tmp = -z; else tmp = -y; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, 1.6e-251], (-z), If[LessEqual[y, 2.95e-210], t$95$1, If[LessEqual[y, 2.6e-120], (-z), If[LessEqual[y, 5.5e-75], t$95$1, If[LessEqual[y, 3.5e-57], (-z), If[LessEqual[y, 2.5e-33], t$95$1, If[LessEqual[y, 3400000000000.0], (-z), If[LessEqual[y, 6.1e+28], t$95$1, If[LessEqual[y, 1.6e+104], (-z), (-y)]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x \cdot \log y\\
\mathbf{if}\;y \leq 1.6 \cdot 10^{-251}:\\
\;\;\;\;-z\\
\mathbf{elif}\;y \leq 2.95 \cdot 10^{-210}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq 2.6 \cdot 10^{-120}:\\
\;\;\;\;-z\\
\mathbf{elif}\;y \leq 5.5 \cdot 10^{-75}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq 3.5 \cdot 10^{-57}:\\
\;\;\;\;-z\\
\mathbf{elif}\;y \leq 2.5 \cdot 10^{-33}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq 3400000000000:\\
\;\;\;\;-z\\
\mathbf{elif}\;y \leq 6.1 \cdot 10^{+28}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq 1.6 \cdot 10^{+104}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;-y\\
\end{array}
\end{array}
if y < 1.59999999999999991e-251 or 2.9499999999999999e-210 < y < 2.6000000000000001e-120 or 5.50000000000000026e-75 < y < 3.49999999999999991e-57 or 2.50000000000000014e-33 < y < 3.4e12 or 6.1000000000000002e28 < y < 1.6e104Initial program 99.9%
Taylor expanded in z around inf 54.3%
neg-mul-154.3%
Simplified54.3%
if 1.59999999999999991e-251 < y < 2.9499999999999999e-210 or 2.6000000000000001e-120 < y < 5.50000000000000026e-75 or 3.49999999999999991e-57 < y < 2.50000000000000014e-33 or 3.4e12 < y < 6.1000000000000002e28Initial program 99.7%
Taylor expanded in x around inf 53.2%
if 1.6e104 < y Initial program 99.9%
Taylor expanded in y around inf 72.9%
neg-mul-172.9%
Simplified72.9%
Final simplification59.9%
(FPCore (x y z t) :precision binary64 (if (or (<= x -1.52e+47) (not (<= x 2.4))) (- (* x (log y)) (+ y z)) (- (log t) (+ y z))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -1.52e+47) || !(x <= 2.4)) {
tmp = (x * log(y)) - (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.52d+47)) .or. (.not. (x <= 2.4d0))) then
tmp = (x * log(y)) - (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.52e+47) || !(x <= 2.4)) {
tmp = (x * Math.log(y)) - (y + z);
} else {
tmp = Math.log(t) - (y + z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x <= -1.52e+47) or not (x <= 2.4): tmp = (x * math.log(y)) - (y + z) else: tmp = math.log(t) - (y + z) return tmp
function code(x, y, z, t) tmp = 0.0 if ((x <= -1.52e+47) || !(x <= 2.4)) tmp = Float64(Float64(x * log(y)) - Float64(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.52e+47) || ~((x <= 2.4))) tmp = (x * log(y)) - (y + z); else tmp = log(t) - (y + z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[x, -1.52e+47], N[Not[LessEqual[x, 2.4]], $MachinePrecision]], N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - N[(y + z), $MachinePrecision]), $MachinePrecision], N[(N[Log[t], $MachinePrecision] - N[(y + z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.52 \cdot 10^{+47} \lor \neg \left(x \leq 2.4\right):\\
\;\;\;\;x \cdot \log y - \left(y + z\right)\\
\mathbf{else}:\\
\;\;\;\;\log t - \left(y + z\right)\\
\end{array}
\end{array}
if x < -1.52e47 or 2.39999999999999991 < x Initial program 99.8%
Taylor expanded in x around 0 99.8%
log-pow5.7%
log-prod5.7%
Simplified5.7%
*-commutative5.7%
log-prod5.7%
pow-to-exp5.7%
rem-log-exp99.8%
add-cube-cbrt98.8%
unpow298.8%
associate-*l*98.9%
fma-def98.9%
Applied egg-rr98.9%
Taylor expanded in x around inf 99.3%
pow-base-199.3%
associate-*r*99.3%
*-lft-identity99.3%
Simplified99.3%
if -1.52e47 < x < 2.39999999999999991Initial program 99.9%
Taylor expanded in x around 0 99.6%
Final simplification99.4%
(FPCore (x y z t) :precision binary64 (if (or (<= x -8.2e+145) (not (<= x 6.2e+176))) (* x (log y)) (- (log t) (+ y z))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -8.2e+145) || !(x <= 6.2e+176)) {
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 <= (-8.2d+145)) .or. (.not. (x <= 6.2d+176))) 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 <= -8.2e+145) || !(x <= 6.2e+176)) {
tmp = x * Math.log(y);
} else {
tmp = Math.log(t) - (y + z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x <= -8.2e+145) or not (x <= 6.2e+176): 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 <= -8.2e+145) || !(x <= 6.2e+176)) 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 <= -8.2e+145) || ~((x <= 6.2e+176))) tmp = x * log(y); else tmp = log(t) - (y + z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[x, -8.2e+145], N[Not[LessEqual[x, 6.2e+176]], $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 -8.2 \cdot 10^{+145} \lor \neg \left(x \leq 6.2 \cdot 10^{+176}\right):\\
\;\;\;\;x \cdot \log y\\
\mathbf{else}:\\
\;\;\;\;\log t - \left(y + z\right)\\
\end{array}
\end{array}
if x < -8.2000000000000003e145 or 6.1999999999999998e176 < x Initial program 99.6%
Taylor expanded in x around inf 76.0%
if -8.2000000000000003e145 < x < 6.1999999999999998e176Initial program 99.9%
Taylor expanded in x around 0 91.6%
Final simplification88.1%
(FPCore (x y z t) :precision binary64 (if (<= y 2.8e+103) (- z) (- y)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 2.8e+103) {
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.8d+103) 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.8e+103) {
tmp = -z;
} else {
tmp = -y;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 2.8e+103: tmp = -z else: tmp = -y return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 2.8e+103) 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.8e+103) tmp = -z; else tmp = -y; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 2.8e+103], (-z), (-y)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.8 \cdot 10^{+103}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;-y\\
\end{array}
\end{array}
if y < 2.80000000000000008e103Initial program 99.8%
Taylor expanded in z around inf 40.1%
neg-mul-140.1%
Simplified40.1%
if 2.80000000000000008e103 < y Initial program 99.9%
Taylor expanded in y around inf 72.9%
neg-mul-172.9%
Simplified72.9%
Final simplification50.5%
(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%
Taylor expanded in y around inf 28.9%
neg-mul-128.9%
Simplified28.9%
Final simplification28.9%
herbie shell --seed 2023310
(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)))