
(FPCore (x y z) :precision binary64 (- (+ (- x (* (+ y 0.5) (log y))) y) z))
double code(double x, double y, double z) {
return ((x - ((y + 0.5) * log(y))) + y) - z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = ((x - ((y + 0.5d0) * log(y))) + y) - z
end function
public static double code(double x, double y, double z) {
return ((x - ((y + 0.5) * Math.log(y))) + y) - z;
}
def code(x, y, z): return ((x - ((y + 0.5) * math.log(y))) + y) - z
function code(x, y, z) return Float64(Float64(Float64(x - Float64(Float64(y + 0.5) * log(y))) + y) - z) end
function tmp = code(x, y, z) tmp = ((x - ((y + 0.5) * log(y))) + y) - z; end
code[x_, y_, z_] := N[(N[(N[(x - N[(N[(y + 0.5), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (- (+ (- x (* (+ y 0.5) (log y))) y) z))
double code(double x, double y, double z) {
return ((x - ((y + 0.5) * log(y))) + y) - z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = ((x - ((y + 0.5d0) * log(y))) + y) - z
end function
public static double code(double x, double y, double z) {
return ((x - ((y + 0.5) * Math.log(y))) + y) - z;
}
def code(x, y, z): return ((x - ((y + 0.5) * math.log(y))) + y) - z
function code(x, y, z) return Float64(Float64(Float64(x - Float64(Float64(y + 0.5) * log(y))) + y) - z) end
function tmp = code(x, y, z) tmp = ((x - ((y + 0.5) * log(y))) + y) - z; end
code[x_, y_, z_] := N[(N[(N[(x - N[(N[(y + 0.5), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z
\end{array}
(FPCore (x y z) :precision binary64 (+ x (- (fma (log y) (- -0.5 y) y) z)))
double code(double x, double y, double z) {
return x + (fma(log(y), (-0.5 - y), y) - z);
}
function code(x, y, z) return Float64(x + Float64(fma(log(y), Float64(-0.5 - y), y) - z)) end
code[x_, y_, z_] := N[(x + N[(N[(N[Log[y], $MachinePrecision] * N[(-0.5 - y), $MachinePrecision] + y), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\mathsf{fma}\left(\log y, -0.5 - y, y\right) - z\right)
\end{array}
Initial program 99.8%
associate--l+99.8%
sub-neg99.8%
associate-+l+99.8%
associate-+r-99.8%
*-commutative99.8%
distribute-rgt-neg-in99.8%
fma-define99.8%
+-commutative99.8%
distribute-neg-in99.8%
unsub-neg99.8%
metadata-eval99.8%
Simplified99.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (* (log y) -0.5) z))
(t_1 (* y (- 1.0 (log y))))
(t_2 (- (+ x y) z)))
(if (<= y 1.42e-164)
t_0
(if (<= y 4.8e-42)
t_2
(if (<= y 2.8e-18)
t_0
(if (<= y 1.85e+20)
t_2
(if (<= y 1.45e+74)
t_1
(if (<= y 9.2e+110)
(- x z)
(if (<= y 1.25e+183)
(- y (* y (log y)))
(if (<= y 1.3e+183) x t_1))))))))))
double code(double x, double y, double z) {
double t_0 = (log(y) * -0.5) - z;
double t_1 = y * (1.0 - log(y));
double t_2 = (x + y) - z;
double tmp;
if (y <= 1.42e-164) {
tmp = t_0;
} else if (y <= 4.8e-42) {
tmp = t_2;
} else if (y <= 2.8e-18) {
tmp = t_0;
} else if (y <= 1.85e+20) {
tmp = t_2;
} else if (y <= 1.45e+74) {
tmp = t_1;
} else if (y <= 9.2e+110) {
tmp = x - z;
} else if (y <= 1.25e+183) {
tmp = y - (y * log(y));
} else if (y <= 1.3e+183) {
tmp = x;
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = (log(y) * (-0.5d0)) - z
t_1 = y * (1.0d0 - log(y))
t_2 = (x + y) - z
if (y <= 1.42d-164) then
tmp = t_0
else if (y <= 4.8d-42) then
tmp = t_2
else if (y <= 2.8d-18) then
tmp = t_0
else if (y <= 1.85d+20) then
tmp = t_2
else if (y <= 1.45d+74) then
tmp = t_1
else if (y <= 9.2d+110) then
tmp = x - z
else if (y <= 1.25d+183) then
tmp = y - (y * log(y))
else if (y <= 1.3d+183) then
tmp = x
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (Math.log(y) * -0.5) - z;
double t_1 = y * (1.0 - Math.log(y));
double t_2 = (x + y) - z;
double tmp;
if (y <= 1.42e-164) {
tmp = t_0;
} else if (y <= 4.8e-42) {
tmp = t_2;
} else if (y <= 2.8e-18) {
tmp = t_0;
} else if (y <= 1.85e+20) {
tmp = t_2;
} else if (y <= 1.45e+74) {
tmp = t_1;
} else if (y <= 9.2e+110) {
tmp = x - z;
} else if (y <= 1.25e+183) {
tmp = y - (y * Math.log(y));
} else if (y <= 1.3e+183) {
tmp = x;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = (math.log(y) * -0.5) - z t_1 = y * (1.0 - math.log(y)) t_2 = (x + y) - z tmp = 0 if y <= 1.42e-164: tmp = t_0 elif y <= 4.8e-42: tmp = t_2 elif y <= 2.8e-18: tmp = t_0 elif y <= 1.85e+20: tmp = t_2 elif y <= 1.45e+74: tmp = t_1 elif y <= 9.2e+110: tmp = x - z elif y <= 1.25e+183: tmp = y - (y * math.log(y)) elif y <= 1.3e+183: tmp = x else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(Float64(log(y) * -0.5) - z) t_1 = Float64(y * Float64(1.0 - log(y))) t_2 = Float64(Float64(x + y) - z) tmp = 0.0 if (y <= 1.42e-164) tmp = t_0; elseif (y <= 4.8e-42) tmp = t_2; elseif (y <= 2.8e-18) tmp = t_0; elseif (y <= 1.85e+20) tmp = t_2; elseif (y <= 1.45e+74) tmp = t_1; elseif (y <= 9.2e+110) tmp = Float64(x - z); elseif (y <= 1.25e+183) tmp = Float64(y - Float64(y * log(y))); elseif (y <= 1.3e+183) tmp = x; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (log(y) * -0.5) - z; t_1 = y * (1.0 - log(y)); t_2 = (x + y) - z; tmp = 0.0; if (y <= 1.42e-164) tmp = t_0; elseif (y <= 4.8e-42) tmp = t_2; elseif (y <= 2.8e-18) tmp = t_0; elseif (y <= 1.85e+20) tmp = t_2; elseif (y <= 1.45e+74) tmp = t_1; elseif (y <= 9.2e+110) tmp = x - z; elseif (y <= 1.25e+183) tmp = y - (y * log(y)); elseif (y <= 1.3e+183) tmp = x; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[Log[y], $MachinePrecision] * -0.5), $MachinePrecision] - z), $MachinePrecision]}, Block[{t$95$1 = N[(y * N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x + y), $MachinePrecision] - z), $MachinePrecision]}, If[LessEqual[y, 1.42e-164], t$95$0, If[LessEqual[y, 4.8e-42], t$95$2, If[LessEqual[y, 2.8e-18], t$95$0, If[LessEqual[y, 1.85e+20], t$95$2, If[LessEqual[y, 1.45e+74], t$95$1, If[LessEqual[y, 9.2e+110], N[(x - z), $MachinePrecision], If[LessEqual[y, 1.25e+183], N[(y - N[(y * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.3e+183], x, t$95$1]]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \log y \cdot -0.5 - z\\
t_1 := y \cdot \left(1 - \log y\right)\\
t_2 := \left(x + y\right) - z\\
\mathbf{if}\;y \leq 1.42 \cdot 10^{-164}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 4.8 \cdot 10^{-42}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;y \leq 2.8 \cdot 10^{-18}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 1.85 \cdot 10^{+20}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;y \leq 1.45 \cdot 10^{+74}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 9.2 \cdot 10^{+110}:\\
\;\;\;\;x - z\\
\mathbf{elif}\;y \leq 1.25 \cdot 10^{+183}:\\
\;\;\;\;y - y \cdot \log y\\
\mathbf{elif}\;y \leq 1.3 \cdot 10^{+183}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < 1.4200000000000001e-164 or 4.80000000000000005e-42 < y < 2.80000000000000012e-18Initial program 100.0%
Taylor expanded in y around 0 100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in x around 0 78.9%
*-commutative78.9%
Simplified78.9%
if 1.4200000000000001e-164 < y < 4.80000000000000005e-42 or 2.80000000000000012e-18 < y < 1.85e20Initial program 100.0%
Taylor expanded in x around -inf 99.9%
mul-1-neg99.9%
sub-neg99.9%
associate-/l*99.9%
+-commutative99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in x around inf 83.1%
neg-mul-183.1%
Simplified83.1%
if 1.85e20 < y < 1.4500000000000001e74 or 1.3e183 < y Initial program 99.4%
Taylor expanded in z around inf 58.6%
associate--l+58.6%
associate-/l*58.7%
+-commutative58.7%
Simplified58.7%
Taylor expanded in y around inf 58.6%
Taylor expanded in y around inf 57.3%
cancel-sign-sub-inv57.3%
metadata-eval57.3%
log-rec57.3%
distribute-neg-frac57.3%
*-lft-identity57.3%
sub-neg57.3%
div-sub57.4%
Simplified57.4%
clear-num57.4%
un-div-inv57.3%
Applied egg-rr57.3%
associate-/r/57.4%
Simplified57.4%
Taylor expanded in x around 0 83.1%
if 1.4500000000000001e74 < y < 9.2000000000000001e110Initial program 100.0%
Taylor expanded in x around inf 78.1%
if 9.2000000000000001e110 < y < 1.25000000000000002e183Initial program 99.7%
Taylor expanded in x around 0 82.2%
Taylor expanded in y around inf 82.2%
mul-1-neg82.2%
distribute-rgt-neg-in82.2%
log-rec82.2%
remove-double-neg82.2%
Simplified82.2%
Taylor expanded in z around 0 60.1%
if 1.25000000000000002e183 < y < 1.3e183Initial program 100.0%
Taylor expanded in z around inf 100.0%
associate--l+100.0%
associate-/l*100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in x around inf 100.0%
Final simplification79.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (* (log y) -0.5) z)) (t_1 (- (+ x y) z)))
(if (<= y 1.4e-164)
t_0
(if (<= y 5.5e-40)
t_1
(if (<= y 1.2e-17)
t_0
(if (<= y 3.8e+18)
t_1
(if (or (<= y 1.18e+70) (and (not (<= y 5.7e+85)) (<= y 5.4e+119)))
(- (* y (- 1.0 (log y))) z)
(+ x (* y (log (/ E y)))))))))))
double code(double x, double y, double z) {
double t_0 = (log(y) * -0.5) - z;
double t_1 = (x + y) - z;
double tmp;
if (y <= 1.4e-164) {
tmp = t_0;
} else if (y <= 5.5e-40) {
tmp = t_1;
} else if (y <= 1.2e-17) {
tmp = t_0;
} else if (y <= 3.8e+18) {
tmp = t_1;
} else if ((y <= 1.18e+70) || (!(y <= 5.7e+85) && (y <= 5.4e+119))) {
tmp = (y * (1.0 - log(y))) - z;
} else {
tmp = x + (y * log((((double) M_E) / y)));
}
return tmp;
}
public static double code(double x, double y, double z) {
double t_0 = (Math.log(y) * -0.5) - z;
double t_1 = (x + y) - z;
double tmp;
if (y <= 1.4e-164) {
tmp = t_0;
} else if (y <= 5.5e-40) {
tmp = t_1;
} else if (y <= 1.2e-17) {
tmp = t_0;
} else if (y <= 3.8e+18) {
tmp = t_1;
} else if ((y <= 1.18e+70) || (!(y <= 5.7e+85) && (y <= 5.4e+119))) {
tmp = (y * (1.0 - Math.log(y))) - z;
} else {
tmp = x + (y * Math.log((Math.E / y)));
}
return tmp;
}
def code(x, y, z): t_0 = (math.log(y) * -0.5) - z t_1 = (x + y) - z tmp = 0 if y <= 1.4e-164: tmp = t_0 elif y <= 5.5e-40: tmp = t_1 elif y <= 1.2e-17: tmp = t_0 elif y <= 3.8e+18: tmp = t_1 elif (y <= 1.18e+70) or (not (y <= 5.7e+85) and (y <= 5.4e+119)): tmp = (y * (1.0 - math.log(y))) - z else: tmp = x + (y * math.log((math.e / y))) return tmp
function code(x, y, z) t_0 = Float64(Float64(log(y) * -0.5) - z) t_1 = Float64(Float64(x + y) - z) tmp = 0.0 if (y <= 1.4e-164) tmp = t_0; elseif (y <= 5.5e-40) tmp = t_1; elseif (y <= 1.2e-17) tmp = t_0; elseif (y <= 3.8e+18) tmp = t_1; elseif ((y <= 1.18e+70) || (!(y <= 5.7e+85) && (y <= 5.4e+119))) tmp = Float64(Float64(y * Float64(1.0 - log(y))) - z); else tmp = Float64(x + Float64(y * log(Float64(exp(1) / y)))); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (log(y) * -0.5) - z; t_1 = (x + y) - z; tmp = 0.0; if (y <= 1.4e-164) tmp = t_0; elseif (y <= 5.5e-40) tmp = t_1; elseif (y <= 1.2e-17) tmp = t_0; elseif (y <= 3.8e+18) tmp = t_1; elseif ((y <= 1.18e+70) || (~((y <= 5.7e+85)) && (y <= 5.4e+119))) tmp = (y * (1.0 - log(y))) - z; else tmp = x + (y * log((2.71828182845904523536 / y))); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[Log[y], $MachinePrecision] * -0.5), $MachinePrecision] - z), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x + y), $MachinePrecision] - z), $MachinePrecision]}, If[LessEqual[y, 1.4e-164], t$95$0, If[LessEqual[y, 5.5e-40], t$95$1, If[LessEqual[y, 1.2e-17], t$95$0, If[LessEqual[y, 3.8e+18], t$95$1, If[Or[LessEqual[y, 1.18e+70], And[N[Not[LessEqual[y, 5.7e+85]], $MachinePrecision], LessEqual[y, 5.4e+119]]], N[(N[(y * N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], N[(x + N[(y * N[Log[N[(E / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \log y \cdot -0.5 - z\\
t_1 := \left(x + y\right) - z\\
\mathbf{if}\;y \leq 1.4 \cdot 10^{-164}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 5.5 \cdot 10^{-40}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 1.2 \cdot 10^{-17}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 3.8 \cdot 10^{+18}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 1.18 \cdot 10^{+70} \lor \neg \left(y \leq 5.7 \cdot 10^{+85}\right) \land y \leq 5.4 \cdot 10^{+119}:\\
\;\;\;\;y \cdot \left(1 - \log y\right) - z\\
\mathbf{else}:\\
\;\;\;\;x + y \cdot \log \left(\frac{e}{y}\right)\\
\end{array}
\end{array}
if y < 1.4000000000000001e-164 or 5.50000000000000002e-40 < y < 1.19999999999999993e-17Initial program 100.0%
Taylor expanded in y around 0 100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in x around 0 78.9%
*-commutative78.9%
Simplified78.9%
if 1.4000000000000001e-164 < y < 5.50000000000000002e-40 or 1.19999999999999993e-17 < y < 3.8e18Initial program 100.0%
Taylor expanded in x around -inf 99.9%
mul-1-neg99.9%
sub-neg99.9%
associate-/l*99.9%
+-commutative99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in x around inf 83.1%
neg-mul-183.1%
Simplified83.1%
if 3.8e18 < y < 1.18000000000000001e70 or 5.7000000000000002e85 < y < 5.3999999999999997e119Initial program 99.6%
Taylor expanded in x around -inf 79.4%
mul-1-neg79.4%
sub-neg79.4%
associate-/l*79.6%
+-commutative79.6%
metadata-eval79.6%
Simplified79.6%
Taylor expanded in y around inf 89.9%
mul-1-neg89.9%
log-rec89.9%
remove-double-neg89.9%
Simplified89.9%
if 1.18000000000000001e70 < y < 5.7000000000000002e85 or 5.3999999999999997e119 < y Initial program 99.5%
Taylor expanded in z around inf 61.1%
associate--l+61.1%
associate-/l*61.1%
+-commutative61.1%
Simplified61.1%
Taylor expanded in y around inf 61.0%
Taylor expanded in y around inf 57.9%
cancel-sign-sub-inv57.9%
metadata-eval57.9%
log-rec57.9%
distribute-neg-frac57.9%
*-lft-identity57.9%
sub-neg57.9%
div-sub58.0%
Simplified58.0%
Taylor expanded in z around 0 91.4%
+-commutative91.4%
Simplified91.4%
add-log-exp99.6%
exp-diff99.6%
add-exp-log99.6%
Applied egg-rr91.4%
exp-1-e99.6%
Simplified91.4%
Final simplification85.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (* (log y) -0.5) z)))
(if (<= y 1.5e-164)
t_0
(if (<= y 8.2e-40)
(- (+ x y) z)
(if (<= y 3.2e-17) t_0 (+ x (* y (log (/ E y)))))))))
double code(double x, double y, double z) {
double t_0 = (log(y) * -0.5) - z;
double tmp;
if (y <= 1.5e-164) {
tmp = t_0;
} else if (y <= 8.2e-40) {
tmp = (x + y) - z;
} else if (y <= 3.2e-17) {
tmp = t_0;
} else {
tmp = x + (y * log((((double) M_E) / y)));
}
return tmp;
}
public static double code(double x, double y, double z) {
double t_0 = (Math.log(y) * -0.5) - z;
double tmp;
if (y <= 1.5e-164) {
tmp = t_0;
} else if (y <= 8.2e-40) {
tmp = (x + y) - z;
} else if (y <= 3.2e-17) {
tmp = t_0;
} else {
tmp = x + (y * Math.log((Math.E / y)));
}
return tmp;
}
def code(x, y, z): t_0 = (math.log(y) * -0.5) - z tmp = 0 if y <= 1.5e-164: tmp = t_0 elif y <= 8.2e-40: tmp = (x + y) - z elif y <= 3.2e-17: tmp = t_0 else: tmp = x + (y * math.log((math.e / y))) return tmp
function code(x, y, z) t_0 = Float64(Float64(log(y) * -0.5) - z) tmp = 0.0 if (y <= 1.5e-164) tmp = t_0; elseif (y <= 8.2e-40) tmp = Float64(Float64(x + y) - z); elseif (y <= 3.2e-17) tmp = t_0; else tmp = Float64(x + Float64(y * log(Float64(exp(1) / y)))); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (log(y) * -0.5) - z; tmp = 0.0; if (y <= 1.5e-164) tmp = t_0; elseif (y <= 8.2e-40) tmp = (x + y) - z; elseif (y <= 3.2e-17) tmp = t_0; else tmp = x + (y * log((2.71828182845904523536 / y))); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[Log[y], $MachinePrecision] * -0.5), $MachinePrecision] - z), $MachinePrecision]}, If[LessEqual[y, 1.5e-164], t$95$0, If[LessEqual[y, 8.2e-40], N[(N[(x + y), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[y, 3.2e-17], t$95$0, N[(x + N[(y * N[Log[N[(E / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \log y \cdot -0.5 - z\\
\mathbf{if}\;y \leq 1.5 \cdot 10^{-164}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 8.2 \cdot 10^{-40}:\\
\;\;\;\;\left(x + y\right) - z\\
\mathbf{elif}\;y \leq 3.2 \cdot 10^{-17}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;x + y \cdot \log \left(\frac{e}{y}\right)\\
\end{array}
\end{array}
if y < 1.5e-164 or 8.19999999999999926e-40 < y < 3.2000000000000002e-17Initial program 100.0%
Taylor expanded in y around 0 100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in x around 0 78.9%
*-commutative78.9%
Simplified78.9%
if 1.5e-164 < y < 8.19999999999999926e-40Initial program 100.0%
Taylor expanded in x around -inf 99.9%
mul-1-neg99.9%
sub-neg99.9%
associate-/l*99.9%
+-commutative99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in x around inf 83.6%
neg-mul-183.6%
Simplified83.6%
if 3.2000000000000002e-17 < y Initial program 99.6%
Taylor expanded in z around inf 64.9%
associate--l+64.9%
associate-/l*64.9%
+-commutative64.9%
Simplified64.9%
Taylor expanded in y around inf 64.8%
Taylor expanded in y around inf 51.1%
cancel-sign-sub-inv51.1%
metadata-eval51.1%
log-rec51.1%
distribute-neg-frac51.1%
*-lft-identity51.1%
sub-neg51.1%
div-sub51.1%
Simplified51.1%
Taylor expanded in z around 0 82.2%
+-commutative82.2%
Simplified82.2%
add-log-exp97.8%
exp-diff97.8%
add-exp-log97.8%
Applied egg-rr82.2%
exp-1-e97.8%
Simplified82.2%
Final simplification81.5%
(FPCore (x y z)
:precision binary64
(if (<= y 1.85e+20)
(- (+ x y) z)
(if (or (<= y 1.9e+74) (not (<= y 1.02e+111)))
(* y (- 1.0 (log y)))
(- x z))))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.85e+20) {
tmp = (x + y) - z;
} else if ((y <= 1.9e+74) || !(y <= 1.02e+111)) {
tmp = y * (1.0 - log(y));
} else {
tmp = x - z;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= 1.85d+20) then
tmp = (x + y) - z
else if ((y <= 1.9d+74) .or. (.not. (y <= 1.02d+111))) then
tmp = y * (1.0d0 - log(y))
else
tmp = x - z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 1.85e+20) {
tmp = (x + y) - z;
} else if ((y <= 1.9e+74) || !(y <= 1.02e+111)) {
tmp = y * (1.0 - Math.log(y));
} else {
tmp = x - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1.85e+20: tmp = (x + y) - z elif (y <= 1.9e+74) or not (y <= 1.02e+111): tmp = y * (1.0 - math.log(y)) else: tmp = x - z return tmp
function code(x, y, z) tmp = 0.0 if (y <= 1.85e+20) tmp = Float64(Float64(x + y) - z); elseif ((y <= 1.9e+74) || !(y <= 1.02e+111)) tmp = Float64(y * Float64(1.0 - log(y))); else tmp = Float64(x - z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 1.85e+20) tmp = (x + y) - z; elseif ((y <= 1.9e+74) || ~((y <= 1.02e+111))) tmp = y * (1.0 - log(y)); else tmp = x - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1.85e+20], N[(N[(x + y), $MachinePrecision] - z), $MachinePrecision], If[Or[LessEqual[y, 1.9e+74], N[Not[LessEqual[y, 1.02e+111]], $MachinePrecision]], N[(y * N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.85 \cdot 10^{+20}:\\
\;\;\;\;\left(x + y\right) - z\\
\mathbf{elif}\;y \leq 1.9 \cdot 10^{+74} \lor \neg \left(y \leq 1.02 \cdot 10^{+111}\right):\\
\;\;\;\;y \cdot \left(1 - \log y\right)\\
\mathbf{else}:\\
\;\;\;\;x - z\\
\end{array}
\end{array}
if y < 1.85e20Initial program 100.0%
Taylor expanded in x around -inf 99.9%
mul-1-neg99.9%
sub-neg99.9%
associate-/l*99.8%
+-commutative99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in x around inf 75.1%
neg-mul-175.1%
Simplified75.1%
if 1.85e20 < y < 1.8999999999999999e74 or 1.02e111 < y Initial program 99.4%
Taylor expanded in z around inf 61.5%
associate--l+61.5%
associate-/l*61.5%
+-commutative61.5%
Simplified61.5%
Taylor expanded in y around inf 61.4%
Taylor expanded in y around inf 55.4%
cancel-sign-sub-inv55.4%
metadata-eval55.4%
log-rec55.4%
distribute-neg-frac55.4%
*-lft-identity55.4%
sub-neg55.4%
div-sub55.4%
Simplified55.4%
clear-num55.4%
un-div-inv55.4%
Applied egg-rr55.4%
associate-/r/55.4%
Simplified55.4%
Taylor expanded in x around 0 76.5%
if 1.8999999999999999e74 < y < 1.02e111Initial program 100.0%
Taylor expanded in x around inf 78.1%
Final simplification75.7%
(FPCore (x y z) :precision binary64 (if (<= y 1.15e+20) (- (- x (* (log y) 0.5)) z) (if (<= y 3.5e+128) (- (* y (- 1.0 (log y))) z) (+ x (* y (log (/ E y)))))))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.15e+20) {
tmp = (x - (log(y) * 0.5)) - z;
} else if (y <= 3.5e+128) {
tmp = (y * (1.0 - log(y))) - z;
} else {
tmp = x + (y * log((((double) M_E) / y)));
}
return tmp;
}
public static double code(double x, double y, double z) {
double tmp;
if (y <= 1.15e+20) {
tmp = (x - (Math.log(y) * 0.5)) - z;
} else if (y <= 3.5e+128) {
tmp = (y * (1.0 - Math.log(y))) - z;
} else {
tmp = x + (y * Math.log((Math.E / y)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1.15e+20: tmp = (x - (math.log(y) * 0.5)) - z elif y <= 3.5e+128: tmp = (y * (1.0 - math.log(y))) - z else: tmp = x + (y * math.log((math.e / y))) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 1.15e+20) tmp = Float64(Float64(x - Float64(log(y) * 0.5)) - z); elseif (y <= 3.5e+128) tmp = Float64(Float64(y * Float64(1.0 - log(y))) - z); else tmp = Float64(x + Float64(y * log(Float64(exp(1) / y)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 1.15e+20) tmp = (x - (log(y) * 0.5)) - z; elseif (y <= 3.5e+128) tmp = (y * (1.0 - log(y))) - z; else tmp = x + (y * log((2.71828182845904523536 / y))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1.15e+20], N[(N[(x - N[(N[Log[y], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[y, 3.5e+128], N[(N[(y * N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], N[(x + N[(y * N[Log[N[(E / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.15 \cdot 10^{+20}:\\
\;\;\;\;\left(x - \log y \cdot 0.5\right) - z\\
\mathbf{elif}\;y \leq 3.5 \cdot 10^{+128}:\\
\;\;\;\;y \cdot \left(1 - \log y\right) - z\\
\mathbf{else}:\\
\;\;\;\;x + y \cdot \log \left(\frac{e}{y}\right)\\
\end{array}
\end{array}
if y < 1.15e20Initial program 100.0%
Taylor expanded in y around 0 99.3%
*-commutative99.3%
Simplified99.3%
if 1.15e20 < y < 3.49999999999999969e128Initial program 99.6%
Taylor expanded in x around -inf 83.7%
mul-1-neg83.7%
sub-neg83.7%
associate-/l*83.7%
+-commutative83.7%
metadata-eval83.7%
Simplified83.7%
Taylor expanded in y around inf 84.1%
mul-1-neg84.1%
log-rec84.1%
remove-double-neg84.1%
Simplified84.1%
if 3.49999999999999969e128 < y Initial program 99.5%
Taylor expanded in z around inf 58.0%
associate--l+58.0%
associate-/l*58.0%
+-commutative58.0%
Simplified58.0%
Taylor expanded in y around inf 57.9%
Taylor expanded in y around inf 56.8%
cancel-sign-sub-inv56.8%
metadata-eval56.8%
log-rec56.8%
distribute-neg-frac56.8%
*-lft-identity56.8%
sub-neg56.8%
div-sub56.9%
Simplified56.9%
Taylor expanded in z around 0 92.9%
+-commutative92.9%
Simplified92.9%
add-log-exp99.6%
exp-diff99.6%
add-exp-log99.6%
Applied egg-rr92.9%
exp-1-e99.6%
Simplified92.9%
Final simplification95.7%
(FPCore (x y z) :precision binary64 (if (<= y 1.1e-5) (- (- x (* (log y) 0.5)) z) (+ x (- (* y (log (/ E y))) z))))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.1e-5) {
tmp = (x - (log(y) * 0.5)) - z;
} else {
tmp = x + ((y * log((((double) M_E) / y))) - z);
}
return tmp;
}
public static double code(double x, double y, double z) {
double tmp;
if (y <= 1.1e-5) {
tmp = (x - (Math.log(y) * 0.5)) - z;
} else {
tmp = x + ((y * Math.log((Math.E / y))) - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1.1e-5: tmp = (x - (math.log(y) * 0.5)) - z else: tmp = x + ((y * math.log((math.e / y))) - z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 1.1e-5) tmp = Float64(Float64(x - Float64(log(y) * 0.5)) - z); else tmp = Float64(x + Float64(Float64(y * log(Float64(exp(1) / y))) - z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 1.1e-5) tmp = (x - (log(y) * 0.5)) - z; else tmp = x + ((y * log((2.71828182845904523536 / y))) - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1.1e-5], N[(N[(x - N[(N[Log[y], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], N[(x + N[(N[(y * N[Log[N[(E / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.1 \cdot 10^{-5}:\\
\;\;\;\;\left(x - \log y \cdot 0.5\right) - z\\
\mathbf{else}:\\
\;\;\;\;x + \left(y \cdot \log \left(\frac{e}{y}\right) - z\right)\\
\end{array}
\end{array}
if y < 1.1e-5Initial program 100.0%
Taylor expanded in y around 0 99.9%
*-commutative99.9%
Simplified99.9%
if 1.1e-5 < y Initial program 99.6%
associate--l+99.5%
sub-neg99.5%
associate-+l+99.5%
associate-+r-99.6%
*-commutative99.6%
distribute-rgt-neg-in99.6%
fma-define99.6%
+-commutative99.6%
distribute-neg-in99.6%
unsub-neg99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in y around inf 99.4%
log-rec99.4%
sub-neg99.4%
Simplified99.4%
add-log-exp99.4%
exp-diff99.4%
add-exp-log99.4%
Applied egg-rr99.4%
exp-1-e99.4%
Simplified99.4%
(FPCore (x y z) :precision binary64 (- (+ y (- x (* (log y) (+ y 0.5)))) z))
double code(double x, double y, double z) {
return (y + (x - (log(y) * (y + 0.5)))) - z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (y + (x - (log(y) * (y + 0.5d0)))) - z
end function
public static double code(double x, double y, double z) {
return (y + (x - (Math.log(y) * (y + 0.5)))) - z;
}
def code(x, y, z): return (y + (x - (math.log(y) * (y + 0.5)))) - z
function code(x, y, z) return Float64(Float64(y + Float64(x - Float64(log(y) * Float64(y + 0.5)))) - z) end
function tmp = code(x, y, z) tmp = (y + (x - (log(y) * (y + 0.5)))) - z; end
code[x_, y_, z_] := N[(N[(y + N[(x - N[(N[Log[y], $MachinePrecision] * N[(y + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}
\\
\left(y + \left(x - \log y \cdot \left(y + 0.5\right)\right)\right) - z
\end{array}
Initial program 99.8%
Final simplification99.8%
(FPCore (x y z)
:precision binary64
(if (or (<= z -1.1e+88)
(and (not (<= z 1.22e+39)) (or (<= z 7e+66) (not (<= z 1.4e+70)))))
(- z)
x))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.1e+88) || (!(z <= 1.22e+39) && ((z <= 7e+66) || !(z <= 1.4e+70)))) {
tmp = -z;
} else {
tmp = x;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z <= (-1.1d+88)) .or. (.not. (z <= 1.22d+39)) .and. (z <= 7d+66) .or. (.not. (z <= 1.4d+70))) then
tmp = -z
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.1e+88) || (!(z <= 1.22e+39) && ((z <= 7e+66) || !(z <= 1.4e+70)))) {
tmp = -z;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.1e+88) or (not (z <= 1.22e+39) and ((z <= 7e+66) or not (z <= 1.4e+70))): tmp = -z else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.1e+88) || (!(z <= 1.22e+39) && ((z <= 7e+66) || !(z <= 1.4e+70)))) tmp = Float64(-z); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.1e+88) || (~((z <= 1.22e+39)) && ((z <= 7e+66) || ~((z <= 1.4e+70))))) tmp = -z; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.1e+88], And[N[Not[LessEqual[z, 1.22e+39]], $MachinePrecision], Or[LessEqual[z, 7e+66], N[Not[LessEqual[z, 1.4e+70]], $MachinePrecision]]]], (-z), x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.1 \cdot 10^{+88} \lor \neg \left(z \leq 1.22 \cdot 10^{+39}\right) \land \left(z \leq 7 \cdot 10^{+66} \lor \neg \left(z \leq 1.4 \cdot 10^{+70}\right)\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -1.10000000000000004e88 or 1.22e39 < z < 6.9999999999999994e66 or 1.39999999999999995e70 < z Initial program 99.9%
Taylor expanded in x around 0 83.0%
Taylor expanded in z around inf 66.1%
neg-mul-166.1%
Simplified66.1%
if -1.10000000000000004e88 < z < 1.22e39 or 6.9999999999999994e66 < z < 1.39999999999999995e70Initial program 99.7%
Taylor expanded in z around inf 62.8%
associate--l+62.8%
associate-/l*62.7%
+-commutative62.7%
Simplified62.7%
Taylor expanded in x around inf 34.2%
Final simplification47.0%
(FPCore (x y z) :precision binary64 (- x z))
double code(double x, double y, double z) {
return x - z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x - z
end function
public static double code(double x, double y, double z) {
return x - z;
}
def code(x, y, z): return x - z
function code(x, y, z) return Float64(x - z) end
function tmp = code(x, y, z) tmp = x - z; end
code[x_, y_, z_] := N[(x - z), $MachinePrecision]
\begin{array}{l}
\\
x - z
\end{array}
Initial program 99.8%
Taylor expanded in x around inf 57.2%
(FPCore (x y z) :precision binary64 x)
double code(double x, double y, double z) {
return x;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x
end function
public static double code(double x, double y, double z) {
return x;
}
def code(x, y, z): return x
function code(x, y, z) return x end
function tmp = code(x, y, z) tmp = x; end
code[x_, y_, z_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 99.8%
Taylor expanded in z around inf 77.7%
associate--l+77.7%
associate-/l*77.6%
+-commutative77.6%
Simplified77.6%
Taylor expanded in x around inf 27.8%
(FPCore (x y z) :precision binary64 (- (- (+ y x) z) (* (+ y 0.5) (log y))))
double code(double x, double y, double z) {
return ((y + x) - z) - ((y + 0.5) * log(y));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = ((y + x) - z) - ((y + 0.5d0) * log(y))
end function
public static double code(double x, double y, double z) {
return ((y + x) - z) - ((y + 0.5) * Math.log(y));
}
def code(x, y, z): return ((y + x) - z) - ((y + 0.5) * math.log(y))
function code(x, y, z) return Float64(Float64(Float64(y + x) - z) - Float64(Float64(y + 0.5) * log(y))) end
function tmp = code(x, y, z) tmp = ((y + x) - z) - ((y + 0.5) * log(y)); end
code[x_, y_, z_] := N[(N[(N[(y + x), $MachinePrecision] - z), $MachinePrecision] - N[(N[(y + 0.5), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(y + x\right) - z\right) - \left(y + 0.5\right) \cdot \log y
\end{array}
herbie shell --seed 2024107
(FPCore (x y z)
:name "Numeric.SpecFunctions:stirlingError from math-functions-0.1.5.2"
:precision binary64
:alt
(- (- (+ y x) z) (* (+ y 0.5) (log y)))
(- (+ (- x (* (+ y 0.5) (log y))) y) z))