
(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 (fma (log y) (- -0.5 y) (+ y (- x z))))
double code(double x, double y, double z) {
return fma(log(y), (-0.5 - y), (y + (x - z)));
}
function code(x, y, z) return fma(log(y), Float64(-0.5 - y), Float64(y + Float64(x - z))) end
code[x_, y_, z_] := N[(N[Log[y], $MachinePrecision] * N[(-0.5 - y), $MachinePrecision] + N[(y + N[(x - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\log y, -0.5 - y, y + \left(x - z\right)\right)
\end{array}
Initial program 99.8%
associate--l+99.8%
sub-neg99.8%
+-commutative99.8%
associate-+l+99.8%
*-commutative99.8%
distribute-rgt-neg-in99.8%
fma-def99.9%
neg-sub099.9%
+-commutative99.9%
associate--r+99.9%
metadata-eval99.9%
associate-+r-99.9%
+-commutative99.9%
associate-+r-99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* y (- 1.0 (log y)))))
(if (<= x -9.5e+60)
x
(if (<= x -1.15e-239)
(- z)
(if (<= x -1.1e-303)
(* (log y) -0.5)
(if (<= x 5.2e-222)
(- z)
(if (<= x 5e-152)
t_0
(if (<= x 8.6e-86)
(- z)
(if (<= x 0.051) t_0 (if (<= x 1.42e+165) (- z) x))))))))))
double code(double x, double y, double z) {
double t_0 = y * (1.0 - log(y));
double tmp;
if (x <= -9.5e+60) {
tmp = x;
} else if (x <= -1.15e-239) {
tmp = -z;
} else if (x <= -1.1e-303) {
tmp = log(y) * -0.5;
} else if (x <= 5.2e-222) {
tmp = -z;
} else if (x <= 5e-152) {
tmp = t_0;
} else if (x <= 8.6e-86) {
tmp = -z;
} else if (x <= 0.051) {
tmp = t_0;
} else if (x <= 1.42e+165) {
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) :: t_0
real(8) :: tmp
t_0 = y * (1.0d0 - log(y))
if (x <= (-9.5d+60)) then
tmp = x
else if (x <= (-1.15d-239)) then
tmp = -z
else if (x <= (-1.1d-303)) then
tmp = log(y) * (-0.5d0)
else if (x <= 5.2d-222) then
tmp = -z
else if (x <= 5d-152) then
tmp = t_0
else if (x <= 8.6d-86) then
tmp = -z
else if (x <= 0.051d0) then
tmp = t_0
else if (x <= 1.42d+165) then
tmp = -z
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = y * (1.0 - Math.log(y));
double tmp;
if (x <= -9.5e+60) {
tmp = x;
} else if (x <= -1.15e-239) {
tmp = -z;
} else if (x <= -1.1e-303) {
tmp = Math.log(y) * -0.5;
} else if (x <= 5.2e-222) {
tmp = -z;
} else if (x <= 5e-152) {
tmp = t_0;
} else if (x <= 8.6e-86) {
tmp = -z;
} else if (x <= 0.051) {
tmp = t_0;
} else if (x <= 1.42e+165) {
tmp = -z;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): t_0 = y * (1.0 - math.log(y)) tmp = 0 if x <= -9.5e+60: tmp = x elif x <= -1.15e-239: tmp = -z elif x <= -1.1e-303: tmp = math.log(y) * -0.5 elif x <= 5.2e-222: tmp = -z elif x <= 5e-152: tmp = t_0 elif x <= 8.6e-86: tmp = -z elif x <= 0.051: tmp = t_0 elif x <= 1.42e+165: tmp = -z else: tmp = x return tmp
function code(x, y, z) t_0 = Float64(y * Float64(1.0 - log(y))) tmp = 0.0 if (x <= -9.5e+60) tmp = x; elseif (x <= -1.15e-239) tmp = Float64(-z); elseif (x <= -1.1e-303) tmp = Float64(log(y) * -0.5); elseif (x <= 5.2e-222) tmp = Float64(-z); elseif (x <= 5e-152) tmp = t_0; elseif (x <= 8.6e-86) tmp = Float64(-z); elseif (x <= 0.051) tmp = t_0; elseif (x <= 1.42e+165) tmp = Float64(-z); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) t_0 = y * (1.0 - log(y)); tmp = 0.0; if (x <= -9.5e+60) tmp = x; elseif (x <= -1.15e-239) tmp = -z; elseif (x <= -1.1e-303) tmp = log(y) * -0.5; elseif (x <= 5.2e-222) tmp = -z; elseif (x <= 5e-152) tmp = t_0; elseif (x <= 8.6e-86) tmp = -z; elseif (x <= 0.051) tmp = t_0; elseif (x <= 1.42e+165) tmp = -z; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -9.5e+60], x, If[LessEqual[x, -1.15e-239], (-z), If[LessEqual[x, -1.1e-303], N[(N[Log[y], $MachinePrecision] * -0.5), $MachinePrecision], If[LessEqual[x, 5.2e-222], (-z), If[LessEqual[x, 5e-152], t$95$0, If[LessEqual[x, 8.6e-86], (-z), If[LessEqual[x, 0.051], t$95$0, If[LessEqual[x, 1.42e+165], (-z), x]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \left(1 - \log y\right)\\
\mathbf{if}\;x \leq -9.5 \cdot 10^{+60}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq -1.15 \cdot 10^{-239}:\\
\;\;\;\;-z\\
\mathbf{elif}\;x \leq -1.1 \cdot 10^{-303}:\\
\;\;\;\;\log y \cdot -0.5\\
\mathbf{elif}\;x \leq 5.2 \cdot 10^{-222}:\\
\;\;\;\;-z\\
\mathbf{elif}\;x \leq 5 \cdot 10^{-152}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 8.6 \cdot 10^{-86}:\\
\;\;\;\;-z\\
\mathbf{elif}\;x \leq 0.051:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 1.42 \cdot 10^{+165}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -9.49999999999999988e60 or 1.42e165 < x Initial program 99.9%
associate--l+99.9%
Simplified99.9%
Taylor expanded in x around inf 80.1%
if -9.49999999999999988e60 < x < -1.1499999999999999e-239 or -1.10000000000000007e-303 < x < 5.1999999999999997e-222 or 4.9999999999999997e-152 < x < 8.60000000000000026e-86 or 0.0509999999999999967 < x < 1.42e165Initial program 99.8%
associate--l+99.8%
Simplified99.8%
Taylor expanded in z around inf 48.8%
mul-1-neg48.8%
Simplified48.8%
if -1.1499999999999999e-239 < x < -1.10000000000000007e-303Initial program 99.7%
associate--l+99.7%
Simplified99.7%
Taylor expanded in x around 0 99.7%
fma-def99.7%
Simplified99.7%
Taylor expanded in z around 0 88.0%
Taylor expanded in y around 0 53.2%
*-commutative53.2%
Simplified53.2%
if 5.1999999999999997e-222 < x < 4.9999999999999997e-152 or 8.60000000000000026e-86 < x < 0.0509999999999999967Initial program 99.7%
associate--l+99.7%
Simplified99.7%
Taylor expanded in y around inf 55.4%
*-commutative55.4%
log-rec55.4%
cancel-sign-sub55.4%
*-commutative55.4%
neg-mul-155.4%
sub-neg55.4%
Simplified55.4%
Final simplification58.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- x (* (log y) 0.5))) (t_1 (- y (* (log y) (+ y 0.5)))))
(if (<= z -1.9e+128)
(- y z)
(if (<= z -2.4e+71)
t_1
(if (<= z -2.1e-36)
t_0
(if (<= z -9.5e-205)
t_1
(if (<= z 1.4e-53)
t_0
(if (<= z 9e-14) t_1 (if (<= z 7.9e+34) x (- z))))))))))
double code(double x, double y, double z) {
double t_0 = x - (log(y) * 0.5);
double t_1 = y - (log(y) * (y + 0.5));
double tmp;
if (z <= -1.9e+128) {
tmp = y - z;
} else if (z <= -2.4e+71) {
tmp = t_1;
} else if (z <= -2.1e-36) {
tmp = t_0;
} else if (z <= -9.5e-205) {
tmp = t_1;
} else if (z <= 1.4e-53) {
tmp = t_0;
} else if (z <= 9e-14) {
tmp = t_1;
} else if (z <= 7.9e+34) {
tmp = x;
} else {
tmp = -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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = x - (log(y) * 0.5d0)
t_1 = y - (log(y) * (y + 0.5d0))
if (z <= (-1.9d+128)) then
tmp = y - z
else if (z <= (-2.4d+71)) then
tmp = t_1
else if (z <= (-2.1d-36)) then
tmp = t_0
else if (z <= (-9.5d-205)) then
tmp = t_1
else if (z <= 1.4d-53) then
tmp = t_0
else if (z <= 9d-14) then
tmp = t_1
else if (z <= 7.9d+34) then
tmp = x
else
tmp = -z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x - (Math.log(y) * 0.5);
double t_1 = y - (Math.log(y) * (y + 0.5));
double tmp;
if (z <= -1.9e+128) {
tmp = y - z;
} else if (z <= -2.4e+71) {
tmp = t_1;
} else if (z <= -2.1e-36) {
tmp = t_0;
} else if (z <= -9.5e-205) {
tmp = t_1;
} else if (z <= 1.4e-53) {
tmp = t_0;
} else if (z <= 9e-14) {
tmp = t_1;
} else if (z <= 7.9e+34) {
tmp = x;
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): t_0 = x - (math.log(y) * 0.5) t_1 = y - (math.log(y) * (y + 0.5)) tmp = 0 if z <= -1.9e+128: tmp = y - z elif z <= -2.4e+71: tmp = t_1 elif z <= -2.1e-36: tmp = t_0 elif z <= -9.5e-205: tmp = t_1 elif z <= 1.4e-53: tmp = t_0 elif z <= 9e-14: tmp = t_1 elif z <= 7.9e+34: tmp = x else: tmp = -z return tmp
function code(x, y, z) t_0 = Float64(x - Float64(log(y) * 0.5)) t_1 = Float64(y - Float64(log(y) * Float64(y + 0.5))) tmp = 0.0 if (z <= -1.9e+128) tmp = Float64(y - z); elseif (z <= -2.4e+71) tmp = t_1; elseif (z <= -2.1e-36) tmp = t_0; elseif (z <= -9.5e-205) tmp = t_1; elseif (z <= 1.4e-53) tmp = t_0; elseif (z <= 9e-14) tmp = t_1; elseif (z <= 7.9e+34) tmp = x; else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = x - (log(y) * 0.5); t_1 = y - (log(y) * (y + 0.5)); tmp = 0.0; if (z <= -1.9e+128) tmp = y - z; elseif (z <= -2.4e+71) tmp = t_1; elseif (z <= -2.1e-36) tmp = t_0; elseif (z <= -9.5e-205) tmp = t_1; elseif (z <= 1.4e-53) tmp = t_0; elseif (z <= 9e-14) tmp = t_1; elseif (z <= 7.9e+34) tmp = x; else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x - N[(N[Log[y], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(y - N[(N[Log[y], $MachinePrecision] * N[(y + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.9e+128], N[(y - z), $MachinePrecision], If[LessEqual[z, -2.4e+71], t$95$1, If[LessEqual[z, -2.1e-36], t$95$0, If[LessEqual[z, -9.5e-205], t$95$1, If[LessEqual[z, 1.4e-53], t$95$0, If[LessEqual[z, 9e-14], t$95$1, If[LessEqual[z, 7.9e+34], x, (-z)]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x - \log y \cdot 0.5\\
t_1 := y - \log y \cdot \left(y + 0.5\right)\\
\mathbf{if}\;z \leq -1.9 \cdot 10^{+128}:\\
\;\;\;\;y - z\\
\mathbf{elif}\;z \leq -2.4 \cdot 10^{+71}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq -2.1 \cdot 10^{-36}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq -9.5 \cdot 10^{-205}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq 1.4 \cdot 10^{-53}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 9 \cdot 10^{-14}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq 7.9 \cdot 10^{+34}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if z < -1.89999999999999995e128Initial program 100.0%
associate--l+100.0%
Simplified100.0%
Taylor expanded in x around 0 85.7%
fma-def85.8%
Simplified85.8%
Taylor expanded in z around inf 78.3%
if -1.89999999999999995e128 < z < -2.39999999999999981e71 or -2.09999999999999991e-36 < z < -9.49999999999999957e-205 or 1.39999999999999993e-53 < z < 8.9999999999999995e-14Initial program 99.7%
associate--l+99.7%
Simplified99.7%
Taylor expanded in x around 0 86.9%
fma-def86.9%
Simplified86.9%
Taylor expanded in z around 0 85.1%
if -2.39999999999999981e71 < z < -2.09999999999999991e-36 or -9.49999999999999957e-205 < z < 1.39999999999999993e-53Initial program 99.8%
associate--l+99.8%
Simplified99.8%
Taylor expanded in z around 0 94.6%
Taylor expanded in y around 0 70.5%
if 8.9999999999999995e-14 < z < 7.89999999999999997e34Initial program 99.6%
associate--l+99.6%
Simplified99.6%
Taylor expanded in x around inf 59.4%
if 7.89999999999999997e34 < z Initial program 99.9%
associate--l+99.9%
Simplified99.9%
Taylor expanded in z around inf 67.9%
mul-1-neg67.9%
Simplified67.9%
Final simplification73.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (log y) -0.5)))
(if (<= x -2.15e+61)
x
(if (<= x -1.25e-239)
(- z)
(if (<= x -8.2e-306)
t_0
(if (<= x 2.5e-82)
(- z)
(if (<= x 8.8e-41) t_0 (if (<= x 1.28e+165) (- z) x))))))))
double code(double x, double y, double z) {
double t_0 = log(y) * -0.5;
double tmp;
if (x <= -2.15e+61) {
tmp = x;
} else if (x <= -1.25e-239) {
tmp = -z;
} else if (x <= -8.2e-306) {
tmp = t_0;
} else if (x <= 2.5e-82) {
tmp = -z;
} else if (x <= 8.8e-41) {
tmp = t_0;
} else if (x <= 1.28e+165) {
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) :: t_0
real(8) :: tmp
t_0 = log(y) * (-0.5d0)
if (x <= (-2.15d+61)) then
tmp = x
else if (x <= (-1.25d-239)) then
tmp = -z
else if (x <= (-8.2d-306)) then
tmp = t_0
else if (x <= 2.5d-82) then
tmp = -z
else if (x <= 8.8d-41) then
tmp = t_0
else if (x <= 1.28d+165) then
tmp = -z
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = Math.log(y) * -0.5;
double tmp;
if (x <= -2.15e+61) {
tmp = x;
} else if (x <= -1.25e-239) {
tmp = -z;
} else if (x <= -8.2e-306) {
tmp = t_0;
} else if (x <= 2.5e-82) {
tmp = -z;
} else if (x <= 8.8e-41) {
tmp = t_0;
} else if (x <= 1.28e+165) {
tmp = -z;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): t_0 = math.log(y) * -0.5 tmp = 0 if x <= -2.15e+61: tmp = x elif x <= -1.25e-239: tmp = -z elif x <= -8.2e-306: tmp = t_0 elif x <= 2.5e-82: tmp = -z elif x <= 8.8e-41: tmp = t_0 elif x <= 1.28e+165: tmp = -z else: tmp = x return tmp
function code(x, y, z) t_0 = Float64(log(y) * -0.5) tmp = 0.0 if (x <= -2.15e+61) tmp = x; elseif (x <= -1.25e-239) tmp = Float64(-z); elseif (x <= -8.2e-306) tmp = t_0; elseif (x <= 2.5e-82) tmp = Float64(-z); elseif (x <= 8.8e-41) tmp = t_0; elseif (x <= 1.28e+165) tmp = Float64(-z); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) t_0 = log(y) * -0.5; tmp = 0.0; if (x <= -2.15e+61) tmp = x; elseif (x <= -1.25e-239) tmp = -z; elseif (x <= -8.2e-306) tmp = t_0; elseif (x <= 2.5e-82) tmp = -z; elseif (x <= 8.8e-41) tmp = t_0; elseif (x <= 1.28e+165) tmp = -z; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[Log[y], $MachinePrecision] * -0.5), $MachinePrecision]}, If[LessEqual[x, -2.15e+61], x, If[LessEqual[x, -1.25e-239], (-z), If[LessEqual[x, -8.2e-306], t$95$0, If[LessEqual[x, 2.5e-82], (-z), If[LessEqual[x, 8.8e-41], t$95$0, If[LessEqual[x, 1.28e+165], (-z), x]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \log y \cdot -0.5\\
\mathbf{if}\;x \leq -2.15 \cdot 10^{+61}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq -1.25 \cdot 10^{-239}:\\
\;\;\;\;-z\\
\mathbf{elif}\;x \leq -8.2 \cdot 10^{-306}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 2.5 \cdot 10^{-82}:\\
\;\;\;\;-z\\
\mathbf{elif}\;x \leq 8.8 \cdot 10^{-41}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 1.28 \cdot 10^{+165}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -2.1500000000000001e61 or 1.2799999999999999e165 < x Initial program 99.9%
associate--l+99.9%
Simplified99.9%
Taylor expanded in x around inf 80.1%
if -2.1500000000000001e61 < x < -1.25e-239 or -8.19999999999999969e-306 < x < 2.4999999999999999e-82 or 8.7999999999999999e-41 < x < 1.2799999999999999e165Initial program 99.8%
associate--l+99.8%
Simplified99.8%
Taylor expanded in z around inf 44.9%
mul-1-neg44.9%
Simplified44.9%
if -1.25e-239 < x < -8.19999999999999969e-306 or 2.4999999999999999e-82 < x < 8.7999999999999999e-41Initial program 99.7%
associate--l+99.7%
Simplified99.7%
Taylor expanded in x around 0 99.7%
fma-def99.8%
Simplified99.8%
Taylor expanded in z around 0 89.5%
Taylor expanded in y around 0 52.3%
*-commutative52.3%
Simplified52.3%
Final simplification55.7%
(FPCore (x y z)
:precision binary64
(if (<= z -1.8e+127)
(- (+ x (* (log y) -0.5)) z)
(if (<= z 7.2e+65)
(- (+ y x) (* (log y) (+ y 0.5)))
(- (- y z) (* y (log y))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.8e+127) {
tmp = (x + (log(y) * -0.5)) - z;
} else if (z <= 7.2e+65) {
tmp = (y + x) - (log(y) * (y + 0.5));
} else {
tmp = (y - z) - (y * log(y));
}
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.8d+127)) then
tmp = (x + (log(y) * (-0.5d0))) - z
else if (z <= 7.2d+65) then
tmp = (y + x) - (log(y) * (y + 0.5d0))
else
tmp = (y - z) - (y * log(y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -1.8e+127) {
tmp = (x + (Math.log(y) * -0.5)) - z;
} else if (z <= 7.2e+65) {
tmp = (y + x) - (Math.log(y) * (y + 0.5));
} else {
tmp = (y - z) - (y * Math.log(y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.8e+127: tmp = (x + (math.log(y) * -0.5)) - z elif z <= 7.2e+65: tmp = (y + x) - (math.log(y) * (y + 0.5)) else: tmp = (y - z) - (y * math.log(y)) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.8e+127) tmp = Float64(Float64(x + Float64(log(y) * -0.5)) - z); elseif (z <= 7.2e+65) tmp = Float64(Float64(y + x) - Float64(log(y) * Float64(y + 0.5))); else tmp = Float64(Float64(y - z) - Float64(y * log(y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.8e+127) tmp = (x + (log(y) * -0.5)) - z; elseif (z <= 7.2e+65) tmp = (y + x) - (log(y) * (y + 0.5)); else tmp = (y - z) - (y * log(y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.8e+127], N[(N[(x + N[(N[Log[y], $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[z, 7.2e+65], N[(N[(y + x), $MachinePrecision] - N[(N[Log[y], $MachinePrecision] * N[(y + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y - z), $MachinePrecision] - N[(y * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.8 \cdot 10^{+127}:\\
\;\;\;\;\left(x + \log y \cdot -0.5\right) - z\\
\mathbf{elif}\;z \leq 7.2 \cdot 10^{+65}:\\
\;\;\;\;\left(y + x\right) - \log y \cdot \left(y + 0.5\right)\\
\mathbf{else}:\\
\;\;\;\;\left(y - z\right) - y \cdot \log y\\
\end{array}
\end{array}
if z < -1.79999999999999989e127Initial program 100.0%
associate--l+100.0%
sub-neg100.0%
+-commutative100.0%
associate-+l+100.0%
*-commutative100.0%
distribute-rgt-neg-in100.0%
fma-def100.0%
neg-sub0100.0%
+-commutative100.0%
associate--r+100.0%
metadata-eval100.0%
associate-+r-100.0%
+-commutative100.0%
associate-+r-100.0%
Simplified100.0%
Taylor expanded in y around 0 92.5%
if -1.79999999999999989e127 < z < 7.19999999999999957e65Initial program 99.8%
associate--l+99.8%
Simplified99.8%
Taylor expanded in z around 0 94.4%
if 7.19999999999999957e65 < z Initial program 99.9%
associate--l+100.0%
Simplified100.0%
Taylor expanded in y around inf 87.9%
*-commutative87.9%
log-rec87.9%
distribute-lft-neg-in87.9%
distribute-rgt-neg-in87.9%
Simplified87.9%
Final simplification92.8%
(FPCore (x y z)
:precision binary64
(if (<= z -3.8e+133)
(- y z)
(if (<= z -7.3e+71)
(* y (- 1.0 (log y)))
(if (<= z 1e+71) (- x (* (log y) 0.5)) (- z)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -3.8e+133) {
tmp = y - z;
} else if (z <= -7.3e+71) {
tmp = y * (1.0 - log(y));
} else if (z <= 1e+71) {
tmp = x - (log(y) * 0.5);
} else {
tmp = -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 (z <= (-3.8d+133)) then
tmp = y - z
else if (z <= (-7.3d+71)) then
tmp = y * (1.0d0 - log(y))
else if (z <= 1d+71) then
tmp = x - (log(y) * 0.5d0)
else
tmp = -z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -3.8e+133) {
tmp = y - z;
} else if (z <= -7.3e+71) {
tmp = y * (1.0 - Math.log(y));
} else if (z <= 1e+71) {
tmp = x - (Math.log(y) * 0.5);
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -3.8e+133: tmp = y - z elif z <= -7.3e+71: tmp = y * (1.0 - math.log(y)) elif z <= 1e+71: tmp = x - (math.log(y) * 0.5) else: tmp = -z return tmp
function code(x, y, z) tmp = 0.0 if (z <= -3.8e+133) tmp = Float64(y - z); elseif (z <= -7.3e+71) tmp = Float64(y * Float64(1.0 - log(y))); elseif (z <= 1e+71) tmp = Float64(x - Float64(log(y) * 0.5)); else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -3.8e+133) tmp = y - z; elseif (z <= -7.3e+71) tmp = y * (1.0 - log(y)); elseif (z <= 1e+71) tmp = x - (log(y) * 0.5); else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -3.8e+133], N[(y - z), $MachinePrecision], If[LessEqual[z, -7.3e+71], N[(y * N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1e+71], N[(x - N[(N[Log[y], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], (-z)]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.8 \cdot 10^{+133}:\\
\;\;\;\;y - z\\
\mathbf{elif}\;z \leq -7.3 \cdot 10^{+71}:\\
\;\;\;\;y \cdot \left(1 - \log y\right)\\
\mathbf{elif}\;z \leq 10^{+71}:\\
\;\;\;\;x - \log y \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if z < -3.8000000000000002e133Initial program 100.0%
associate--l+100.0%
Simplified100.0%
Taylor expanded in x around 0 85.7%
fma-def85.8%
Simplified85.8%
Taylor expanded in z around inf 78.3%
if -3.8000000000000002e133 < z < -7.29999999999999996e71Initial program 99.6%
associate--l+99.6%
Simplified99.6%
Taylor expanded in y around inf 85.9%
*-commutative85.9%
log-rec85.9%
cancel-sign-sub85.9%
*-commutative85.9%
neg-mul-185.9%
sub-neg85.9%
Simplified85.9%
if -7.29999999999999996e71 < z < 1e71Initial program 99.8%
associate--l+99.8%
Simplified99.8%
Taylor expanded in z around 0 94.8%
Taylor expanded in y around 0 64.3%
if 1e71 < z Initial program 99.9%
associate--l+100.0%
Simplified100.0%
Taylor expanded in z around inf 71.6%
mul-1-neg71.6%
Simplified71.6%
Final simplification68.5%
(FPCore (x y z) :precision binary64 (+ (- x (* (log y) (+ y 0.5))) (- y z)))
double code(double x, double y, double z) {
return (x - (log(y) * (y + 0.5))) + (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 - (log(y) * (y + 0.5d0))) + (y - z)
end function
public static double code(double x, double y, double z) {
return (x - (Math.log(y) * (y + 0.5))) + (y - z);
}
def code(x, y, z): return (x - (math.log(y) * (y + 0.5))) + (y - z)
function code(x, y, z) return Float64(Float64(x - Float64(log(y) * Float64(y + 0.5))) + Float64(y - z)) end
function tmp = code(x, y, z) tmp = (x - (log(y) * (y + 0.5))) + (y - z); end
code[x_, y_, z_] := N[(N[(x - N[(N[Log[y], $MachinePrecision] * N[(y + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(y - z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x - \log y \cdot \left(y + 0.5\right)\right) + \left(y - z\right)
\end{array}
Initial program 99.8%
associate--l+99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (x y z) :precision binary64 (if (<= y 1.22e+148) (- (+ x (* (log y) -0.5)) z) (- y (* (log y) (+ y 0.5)))))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.22e+148) {
tmp = (x + (log(y) * -0.5)) - z;
} else {
tmp = y - (log(y) * (y + 0.5));
}
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.22d+148) then
tmp = (x + (log(y) * (-0.5d0))) - z
else
tmp = y - (log(y) * (y + 0.5d0))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 1.22e+148) {
tmp = (x + (Math.log(y) * -0.5)) - z;
} else {
tmp = y - (Math.log(y) * (y + 0.5));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1.22e+148: tmp = (x + (math.log(y) * -0.5)) - z else: tmp = y - (math.log(y) * (y + 0.5)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 1.22e+148) tmp = Float64(Float64(x + Float64(log(y) * -0.5)) - z); else tmp = Float64(y - Float64(log(y) * Float64(y + 0.5))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 1.22e+148) tmp = (x + (log(y) * -0.5)) - z; else tmp = y - (log(y) * (y + 0.5)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1.22e+148], N[(N[(x + N[(N[Log[y], $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], N[(y - N[(N[Log[y], $MachinePrecision] * N[(y + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.22 \cdot 10^{+148}:\\
\;\;\;\;\left(x + \log y \cdot -0.5\right) - z\\
\mathbf{else}:\\
\;\;\;\;y - \log y \cdot \left(y + 0.5\right)\\
\end{array}
\end{array}
if y < 1.22000000000000007e148Initial program 99.9%
associate--l+99.9%
sub-neg99.9%
+-commutative99.9%
associate-+l+99.9%
*-commutative99.9%
distribute-rgt-neg-in99.9%
fma-def99.9%
neg-sub099.9%
+-commutative99.9%
associate--r+99.9%
metadata-eval99.9%
associate-+r-99.9%
+-commutative99.9%
associate-+r-99.9%
Simplified99.9%
Taylor expanded in y around 0 89.6%
if 1.22000000000000007e148 < y Initial program 99.6%
associate--l+99.7%
Simplified99.7%
Taylor expanded in x around 0 86.8%
fma-def86.8%
Simplified86.8%
Taylor expanded in z around 0 68.4%
Final simplification83.9%
(FPCore (x y z) :precision binary64 (if (<= y 6.8e+52) (- (+ x (* (log y) -0.5)) z) (- (- y z) (* y (log y)))))
double code(double x, double y, double z) {
double tmp;
if (y <= 6.8e+52) {
tmp = (x + (log(y) * -0.5)) - z;
} else {
tmp = (y - z) - (y * log(y));
}
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 <= 6.8d+52) then
tmp = (x + (log(y) * (-0.5d0))) - z
else
tmp = (y - z) - (y * log(y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 6.8e+52) {
tmp = (x + (Math.log(y) * -0.5)) - z;
} else {
tmp = (y - z) - (y * Math.log(y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 6.8e+52: tmp = (x + (math.log(y) * -0.5)) - z else: tmp = (y - z) - (y * math.log(y)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 6.8e+52) tmp = Float64(Float64(x + Float64(log(y) * -0.5)) - z); else tmp = Float64(Float64(y - z) - Float64(y * log(y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 6.8e+52) tmp = (x + (log(y) * -0.5)) - z; else tmp = (y - z) - (y * log(y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 6.8e+52], N[(N[(x + N[(N[Log[y], $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], N[(N[(y - z), $MachinePrecision] - N[(y * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 6.8 \cdot 10^{+52}:\\
\;\;\;\;\left(x + \log y \cdot -0.5\right) - z\\
\mathbf{else}:\\
\;\;\;\;\left(y - z\right) - y \cdot \log y\\
\end{array}
\end{array}
if y < 6.8e52Initial program 99.9%
associate--l+99.9%
sub-neg99.9%
+-commutative99.9%
associate-+l+99.9%
*-commutative99.9%
distribute-rgt-neg-in99.9%
fma-def100.0%
neg-sub0100.0%
+-commutative100.0%
associate--r+100.0%
metadata-eval100.0%
associate-+r-100.0%
+-commutative100.0%
associate-+r-100.0%
Simplified100.0%
Taylor expanded in y around 0 96.5%
if 6.8e52 < y Initial program 99.7%
associate--l+99.7%
Simplified99.7%
Taylor expanded in y around inf 80.5%
*-commutative80.5%
log-rec80.5%
distribute-lft-neg-in80.5%
distribute-rgt-neg-in80.5%
Simplified80.5%
Final simplification89.6%
(FPCore (x y z) :precision binary64 (if (<= x -1.95e+61) x (if (<= x 1.28e+165) (- z) x)))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.95e+61) {
tmp = x;
} else if (x <= 1.28e+165) {
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 (x <= (-1.95d+61)) then
tmp = x
else if (x <= 1.28d+165) 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 (x <= -1.95e+61) {
tmp = x;
} else if (x <= 1.28e+165) {
tmp = -z;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -1.95e+61: tmp = x elif x <= 1.28e+165: tmp = -z else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if (x <= -1.95e+61) tmp = x; elseif (x <= 1.28e+165) tmp = Float64(-z); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -1.95e+61) tmp = x; elseif (x <= 1.28e+165) tmp = -z; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1.95e+61], x, If[LessEqual[x, 1.28e+165], (-z), x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.95 \cdot 10^{+61}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 1.28 \cdot 10^{+165}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -1.94999999999999994e61 or 1.2799999999999999e165 < x Initial program 99.9%
associate--l+99.9%
Simplified99.9%
Taylor expanded in x around inf 80.1%
if -1.94999999999999994e61 < x < 1.2799999999999999e165Initial program 99.8%
associate--l+99.8%
Simplified99.8%
Taylor expanded in z around inf 40.2%
mul-1-neg40.2%
Simplified40.2%
Final simplification51.6%
(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%
associate--l+99.8%
Simplified99.8%
Taylor expanded in x around inf 29.4%
Final simplification29.4%
(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 2023223
(FPCore (x y z)
:name "Numeric.SpecFunctions:stirlingError from math-functions-0.1.5.2"
:precision binary64
:herbie-target
(- (- (+ y x) z) (* (+ y 0.5) (log y)))
(- (+ (- x (* (+ y 0.5) (log y))) y) z))