
(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 12 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 (+ y 0.5) (log y) (- z y))))
double code(double x, double y, double z) {
return x - fma((y + 0.5), log(y), (z - y));
}
function code(x, y, z) return Float64(x - fma(Float64(y + 0.5), log(y), Float64(z - y))) end
code[x_, y_, z_] := N[(x - N[(N[(y + 0.5), $MachinePrecision] * N[Log[y], $MachinePrecision] + N[(z - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \mathsf{fma}\left(y + 0.5, \log y, z - y\right)
\end{array}
Initial program 99.8%
associate--l+99.8%
associate-+l-99.8%
fma-neg99.9%
sub-neg99.9%
+-commutative99.9%
distribute-neg-out99.9%
remove-double-neg99.9%
sub-neg99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(if (<= y 2.7e-104)
(- x z)
(if (<= y 2.1e-62)
(- (* (log y) -0.5) z)
(if (<= y 1.9e+42) (- x z) (+ x (* y (- 1.0 (log y))))))))
double code(double x, double y, double z) {
double tmp;
if (y <= 2.7e-104) {
tmp = x - z;
} else if (y <= 2.1e-62) {
tmp = (log(y) * -0.5) - z;
} else if (y <= 1.9e+42) {
tmp = x - z;
} else {
tmp = x + (y * (1.0 - 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 <= 2.7d-104) then
tmp = x - z
else if (y <= 2.1d-62) then
tmp = (log(y) * (-0.5d0)) - z
else if (y <= 1.9d+42) then
tmp = x - z
else
tmp = x + (y * (1.0d0 - log(y)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 2.7e-104) {
tmp = x - z;
} else if (y <= 2.1e-62) {
tmp = (Math.log(y) * -0.5) - z;
} else if (y <= 1.9e+42) {
tmp = x - z;
} else {
tmp = x + (y * (1.0 - Math.log(y)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 2.7e-104: tmp = x - z elif y <= 2.1e-62: tmp = (math.log(y) * -0.5) - z elif y <= 1.9e+42: tmp = x - z else: tmp = x + (y * (1.0 - math.log(y))) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 2.7e-104) tmp = Float64(x - z); elseif (y <= 2.1e-62) tmp = Float64(Float64(log(y) * -0.5) - z); elseif (y <= 1.9e+42) tmp = Float64(x - z); else tmp = Float64(x + Float64(y * Float64(1.0 - log(y)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 2.7e-104) tmp = x - z; elseif (y <= 2.1e-62) tmp = (log(y) * -0.5) - z; elseif (y <= 1.9e+42) tmp = x - z; else tmp = x + (y * (1.0 - log(y))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 2.7e-104], N[(x - z), $MachinePrecision], If[LessEqual[y, 2.1e-62], N[(N[(N[Log[y], $MachinePrecision] * -0.5), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[y, 1.9e+42], N[(x - z), $MachinePrecision], N[(x + N[(y * N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.7 \cdot 10^{-104}:\\
\;\;\;\;x - z\\
\mathbf{elif}\;y \leq 2.1 \cdot 10^{-62}:\\
\;\;\;\;\log y \cdot -0.5 - z\\
\mathbf{elif}\;y \leq 1.9 \cdot 10^{+42}:\\
\;\;\;\;x - z\\
\mathbf{else}:\\
\;\;\;\;x + y \cdot \left(1 - \log y\right)\\
\end{array}
\end{array}
if y < 2.6999999999999998e-104 or 2.0999999999999999e-62 < y < 1.8999999999999999e42Initial program 100.0%
associate--l+100.0%
associate-+l-100.0%
fma-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in z around inf 84.8%
if 2.6999999999999998e-104 < y < 2.0999999999999999e-62Initial program 100.0%
Taylor expanded in y around 0 100.0%
Taylor expanded in x around 0 75.6%
*-commutative75.6%
Simplified75.6%
if 1.8999999999999999e42 < y Initial program 99.7%
associate--l+99.7%
associate-+l-99.6%
fma-neg99.7%
sub-neg99.7%
+-commutative99.7%
distribute-neg-out99.7%
remove-double-neg99.7%
sub-neg99.7%
Simplified99.7%
Taylor expanded in y around inf 83.5%
sub-neg83.5%
metadata-eval83.5%
+-commutative83.5%
log-rec83.5%
neg-mul-183.5%
associate-*r*83.5%
metadata-eval83.5%
Simplified83.5%
Taylor expanded in y around 0 83.5%
Final simplification83.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* y (- 1.0 (log y)))) (t_1 (- t_0 z)))
(if (<= z -3.4e+47)
t_1
(if (<= z 2.8e+91) (+ x t_0) (if (<= z 1.3e+134) t_1 (- x z))))))
double code(double x, double y, double z) {
double t_0 = y * (1.0 - log(y));
double t_1 = t_0 - z;
double tmp;
if (z <= -3.4e+47) {
tmp = t_1;
} else if (z <= 2.8e+91) {
tmp = x + t_0;
} else if (z <= 1.3e+134) {
tmp = t_1;
} 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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = y * (1.0d0 - log(y))
t_1 = t_0 - z
if (z <= (-3.4d+47)) then
tmp = t_1
else if (z <= 2.8d+91) then
tmp = x + t_0
else if (z <= 1.3d+134) then
tmp = t_1
else
tmp = x - z
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 t_1 = t_0 - z;
double tmp;
if (z <= -3.4e+47) {
tmp = t_1;
} else if (z <= 2.8e+91) {
tmp = x + t_0;
} else if (z <= 1.3e+134) {
tmp = t_1;
} else {
tmp = x - z;
}
return tmp;
}
def code(x, y, z): t_0 = y * (1.0 - math.log(y)) t_1 = t_0 - z tmp = 0 if z <= -3.4e+47: tmp = t_1 elif z <= 2.8e+91: tmp = x + t_0 elif z <= 1.3e+134: tmp = t_1 else: tmp = x - z return tmp
function code(x, y, z) t_0 = Float64(y * Float64(1.0 - log(y))) t_1 = Float64(t_0 - z) tmp = 0.0 if (z <= -3.4e+47) tmp = t_1; elseif (z <= 2.8e+91) tmp = Float64(x + t_0); elseif (z <= 1.3e+134) tmp = t_1; else tmp = Float64(x - z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = y * (1.0 - log(y)); t_1 = t_0 - z; tmp = 0.0; if (z <= -3.4e+47) tmp = t_1; elseif (z <= 2.8e+91) tmp = x + t_0; elseif (z <= 1.3e+134) tmp = t_1; else tmp = x - z; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 - z), $MachinePrecision]}, If[LessEqual[z, -3.4e+47], t$95$1, If[LessEqual[z, 2.8e+91], N[(x + t$95$0), $MachinePrecision], If[LessEqual[z, 1.3e+134], t$95$1, N[(x - z), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \left(1 - \log y\right)\\
t_1 := t_0 - z\\
\mathbf{if}\;z \leq -3.4 \cdot 10^{+47}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq 2.8 \cdot 10^{+91}:\\
\;\;\;\;x + t_0\\
\mathbf{elif}\;z \leq 1.3 \cdot 10^{+134}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;x - z\\
\end{array}
\end{array}
if z < -3.3999999999999998e47 or 2.7999999999999999e91 < z < 1.3000000000000001e134Initial program 99.9%
Taylor expanded in y around inf 86.6%
log-rec86.6%
Simplified86.6%
Taylor expanded in y around 0 86.6%
mul-1-neg86.6%
log-rec86.6%
log-div86.6%
metadata-eval86.6%
associate-+r-86.6%
metadata-eval86.6%
Simplified86.6%
if -3.3999999999999998e47 < z < 2.7999999999999999e91Initial program 99.8%
associate--l+99.8%
associate-+l-99.8%
fma-neg99.8%
sub-neg99.8%
+-commutative99.8%
distribute-neg-out99.8%
remove-double-neg99.8%
sub-neg99.8%
Simplified99.8%
Taylor expanded in y around inf 79.0%
sub-neg79.0%
metadata-eval79.0%
+-commutative79.0%
log-rec79.0%
neg-mul-179.0%
associate-*r*79.0%
metadata-eval79.0%
Simplified79.0%
Taylor expanded in y around 0 79.0%
if 1.3000000000000001e134 < z Initial program 100.0%
associate--l+100.0%
associate-+l-100.0%
fma-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in z around inf 96.2%
Final simplification83.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* y (- 1.0 (log y)))) (t_1 (- (- x (* 0.5 (log y))) z)))
(if (<= y 4.8e+42)
t_1
(if (<= y 1.7e+113) (+ x t_0) (if (<= y 2.2e+141) t_1 (- t_0 z))))))
double code(double x, double y, double z) {
double t_0 = y * (1.0 - log(y));
double t_1 = (x - (0.5 * log(y))) - z;
double tmp;
if (y <= 4.8e+42) {
tmp = t_1;
} else if (y <= 1.7e+113) {
tmp = x + t_0;
} else if (y <= 2.2e+141) {
tmp = t_1;
} else {
tmp = t_0 - 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 = y * (1.0d0 - log(y))
t_1 = (x - (0.5d0 * log(y))) - z
if (y <= 4.8d+42) then
tmp = t_1
else if (y <= 1.7d+113) then
tmp = x + t_0
else if (y <= 2.2d+141) then
tmp = t_1
else
tmp = t_0 - z
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 t_1 = (x - (0.5 * Math.log(y))) - z;
double tmp;
if (y <= 4.8e+42) {
tmp = t_1;
} else if (y <= 1.7e+113) {
tmp = x + t_0;
} else if (y <= 2.2e+141) {
tmp = t_1;
} else {
tmp = t_0 - z;
}
return tmp;
}
def code(x, y, z): t_0 = y * (1.0 - math.log(y)) t_1 = (x - (0.5 * math.log(y))) - z tmp = 0 if y <= 4.8e+42: tmp = t_1 elif y <= 1.7e+113: tmp = x + t_0 elif y <= 2.2e+141: tmp = t_1 else: tmp = t_0 - z return tmp
function code(x, y, z) t_0 = Float64(y * Float64(1.0 - log(y))) t_1 = Float64(Float64(x - Float64(0.5 * log(y))) - z) tmp = 0.0 if (y <= 4.8e+42) tmp = t_1; elseif (y <= 1.7e+113) tmp = Float64(x + t_0); elseif (y <= 2.2e+141) tmp = t_1; else tmp = Float64(t_0 - z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = y * (1.0 - log(y)); t_1 = (x - (0.5 * log(y))) - z; tmp = 0.0; if (y <= 4.8e+42) tmp = t_1; elseif (y <= 1.7e+113) tmp = x + t_0; elseif (y <= 2.2e+141) tmp = t_1; else tmp = t_0 - z; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x - N[(0.5 * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]}, If[LessEqual[y, 4.8e+42], t$95$1, If[LessEqual[y, 1.7e+113], N[(x + t$95$0), $MachinePrecision], If[LessEqual[y, 2.2e+141], t$95$1, N[(t$95$0 - z), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \left(1 - \log y\right)\\
t_1 := \left(x - 0.5 \cdot \log y\right) - z\\
\mathbf{if}\;y \leq 4.8 \cdot 10^{+42}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq 1.7 \cdot 10^{+113}:\\
\;\;\;\;x + t_0\\
\mathbf{elif}\;y \leq 2.2 \cdot 10^{+141}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0 - z\\
\end{array}
\end{array}
if y < 4.7999999999999997e42 or 1.70000000000000009e113 < y < 2.2e141Initial program 100.0%
Taylor expanded in y around 0 97.2%
if 4.7999999999999997e42 < y < 1.70000000000000009e113Initial program 99.8%
associate--l+99.8%
associate-+l-99.8%
fma-neg99.8%
sub-neg99.8%
+-commutative99.8%
distribute-neg-out99.8%
remove-double-neg99.8%
sub-neg99.8%
Simplified99.8%
Taylor expanded in y around inf 82.1%
sub-neg82.1%
metadata-eval82.1%
+-commutative82.1%
log-rec82.1%
neg-mul-182.1%
associate-*r*82.1%
metadata-eval82.1%
Simplified82.1%
Taylor expanded in y around 0 82.1%
if 2.2e141 < y Initial program 99.6%
Taylor expanded in y around inf 90.0%
log-rec90.0%
Simplified90.0%
Taylor expanded in y around 0 90.0%
mul-1-neg90.0%
log-rec90.0%
log-div90.0%
metadata-eval90.0%
associate-+r-90.0%
metadata-eval90.0%
Simplified90.0%
Final simplification93.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (- x (* 0.5 (log y))) z)))
(if (<= y 1.2e+43)
t_0
(if (<= y 6e+113)
(+ x (* y (- 1.0 (log y))))
(if (<= y 1.6e+141) t_0 (- (- y (* y (log y))) z))))))
double code(double x, double y, double z) {
double t_0 = (x - (0.5 * log(y))) - z;
double tmp;
if (y <= 1.2e+43) {
tmp = t_0;
} else if (y <= 6e+113) {
tmp = x + (y * (1.0 - log(y)));
} else if (y <= 1.6e+141) {
tmp = t_0;
} else {
tmp = (y - (y * log(y))) - 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) :: tmp
t_0 = (x - (0.5d0 * log(y))) - z
if (y <= 1.2d+43) then
tmp = t_0
else if (y <= 6d+113) then
tmp = x + (y * (1.0d0 - log(y)))
else if (y <= 1.6d+141) then
tmp = t_0
else
tmp = (y - (y * log(y))) - z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (x - (0.5 * Math.log(y))) - z;
double tmp;
if (y <= 1.2e+43) {
tmp = t_0;
} else if (y <= 6e+113) {
tmp = x + (y * (1.0 - Math.log(y)));
} else if (y <= 1.6e+141) {
tmp = t_0;
} else {
tmp = (y - (y * Math.log(y))) - z;
}
return tmp;
}
def code(x, y, z): t_0 = (x - (0.5 * math.log(y))) - z tmp = 0 if y <= 1.2e+43: tmp = t_0 elif y <= 6e+113: tmp = x + (y * (1.0 - math.log(y))) elif y <= 1.6e+141: tmp = t_0 else: tmp = (y - (y * math.log(y))) - z return tmp
function code(x, y, z) t_0 = Float64(Float64(x - Float64(0.5 * log(y))) - z) tmp = 0.0 if (y <= 1.2e+43) tmp = t_0; elseif (y <= 6e+113) tmp = Float64(x + Float64(y * Float64(1.0 - log(y)))); elseif (y <= 1.6e+141) tmp = t_0; else tmp = Float64(Float64(y - Float64(y * log(y))) - z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (x - (0.5 * log(y))) - z; tmp = 0.0; if (y <= 1.2e+43) tmp = t_0; elseif (y <= 6e+113) tmp = x + (y * (1.0 - log(y))); elseif (y <= 1.6e+141) tmp = t_0; else tmp = (y - (y * log(y))) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x - N[(0.5 * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]}, If[LessEqual[y, 1.2e+43], t$95$0, If[LessEqual[y, 6e+113], N[(x + N[(y * N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.6e+141], t$95$0, N[(N[(y - N[(y * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x - 0.5 \cdot \log y\right) - z\\
\mathbf{if}\;y \leq 1.2 \cdot 10^{+43}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 6 \cdot 10^{+113}:\\
\;\;\;\;x + y \cdot \left(1 - \log y\right)\\
\mathbf{elif}\;y \leq 1.6 \cdot 10^{+141}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\left(y - y \cdot \log y\right) - z\\
\end{array}
\end{array}
if y < 1.20000000000000012e43 or 6e113 < y < 1.60000000000000009e141Initial program 100.0%
Taylor expanded in y around 0 97.2%
if 1.20000000000000012e43 < y < 6e113Initial program 99.8%
associate--l+99.8%
associate-+l-99.8%
fma-neg99.8%
sub-neg99.8%
+-commutative99.8%
distribute-neg-out99.8%
remove-double-neg99.8%
sub-neg99.8%
Simplified99.8%
Taylor expanded in y around inf 82.1%
sub-neg82.1%
metadata-eval82.1%
+-commutative82.1%
log-rec82.1%
neg-mul-182.1%
associate-*r*82.1%
metadata-eval82.1%
Simplified82.1%
Taylor expanded in y around 0 82.1%
if 1.60000000000000009e141 < y Initial program 99.6%
flip3--0.3%
clear-num0.3%
*-un-lft-identity0.3%
associate-/l*0.3%
flip3--99.4%
cancel-sign-sub-inv99.4%
*-commutative99.4%
neg-sub099.4%
+-commutative99.4%
associate--r+99.4%
metadata-eval99.4%
Applied egg-rr99.4%
Taylor expanded in y around inf 89.8%
*-commutative89.8%
associate-/r*89.8%
log-rec89.8%
mul-1-neg89.8%
associate-/r*89.8%
metadata-eval89.8%
Simplified89.8%
associate-/r/89.9%
distribute-lft1-in89.9%
+-commutative89.9%
associate-/r/90.0%
metadata-eval90.0%
metadata-eval90.0%
cancel-sign-sub-inv90.0%
*-un-lft-identity90.0%
Applied egg-rr90.0%
*-commutative90.0%
distribute-rgt-out--90.0%
*-un-lft-identity90.0%
*-commutative90.0%
Applied egg-rr90.0%
Final simplification93.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (- y (* y (log y))) z)))
(if (<= z -7.2e+60)
t_0
(if (<= z 1.5e+91)
(+ y (- x (* (+ y 0.5) (log y))))
(if (<= z 1.9e+133) t_0 (- x z))))))
double code(double x, double y, double z) {
double t_0 = (y - (y * log(y))) - z;
double tmp;
if (z <= -7.2e+60) {
tmp = t_0;
} else if (z <= 1.5e+91) {
tmp = y + (x - ((y + 0.5) * log(y)));
} else if (z <= 1.9e+133) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = (y - (y * log(y))) - z
if (z <= (-7.2d+60)) then
tmp = t_0
else if (z <= 1.5d+91) then
tmp = y + (x - ((y + 0.5d0) * log(y)))
else if (z <= 1.9d+133) then
tmp = t_0
else
tmp = x - z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (y - (y * Math.log(y))) - z;
double tmp;
if (z <= -7.2e+60) {
tmp = t_0;
} else if (z <= 1.5e+91) {
tmp = y + (x - ((y + 0.5) * Math.log(y)));
} else if (z <= 1.9e+133) {
tmp = t_0;
} else {
tmp = x - z;
}
return tmp;
}
def code(x, y, z): t_0 = (y - (y * math.log(y))) - z tmp = 0 if z <= -7.2e+60: tmp = t_0 elif z <= 1.5e+91: tmp = y + (x - ((y + 0.5) * math.log(y))) elif z <= 1.9e+133: tmp = t_0 else: tmp = x - z return tmp
function code(x, y, z) t_0 = Float64(Float64(y - Float64(y * log(y))) - z) tmp = 0.0 if (z <= -7.2e+60) tmp = t_0; elseif (z <= 1.5e+91) tmp = Float64(y + Float64(x - Float64(Float64(y + 0.5) * log(y)))); elseif (z <= 1.9e+133) tmp = t_0; else tmp = Float64(x - z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (y - (y * log(y))) - z; tmp = 0.0; if (z <= -7.2e+60) tmp = t_0; elseif (z <= 1.5e+91) tmp = y + (x - ((y + 0.5) * log(y))); elseif (z <= 1.9e+133) tmp = t_0; else tmp = x - z; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(y - N[(y * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]}, If[LessEqual[z, -7.2e+60], t$95$0, If[LessEqual[z, 1.5e+91], N[(y + N[(x - N[(N[(y + 0.5), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.9e+133], t$95$0, N[(x - z), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(y - y \cdot \log y\right) - z\\
\mathbf{if}\;z \leq -7.2 \cdot 10^{+60}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 1.5 \cdot 10^{+91}:\\
\;\;\;\;y + \left(x - \left(y + 0.5\right) \cdot \log y\right)\\
\mathbf{elif}\;z \leq 1.9 \cdot 10^{+133}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;x - z\\
\end{array}
\end{array}
if z < -7.19999999999999935e60 or 1.50000000000000003e91 < z < 1.9000000000000001e133Initial program 99.9%
flip3--41.8%
clear-num41.8%
*-un-lft-identity41.8%
associate-/l*41.8%
flip3--99.8%
cancel-sign-sub-inv99.8%
*-commutative99.8%
neg-sub099.8%
+-commutative99.8%
associate--r+99.8%
metadata-eval99.8%
Applied egg-rr99.8%
Taylor expanded in y around inf 87.6%
*-commutative87.6%
associate-/r*87.6%
log-rec87.6%
mul-1-neg87.6%
associate-/r*87.6%
metadata-eval87.6%
Simplified87.6%
associate-/r/87.6%
distribute-lft1-in87.6%
+-commutative87.6%
associate-/r/87.6%
metadata-eval87.6%
metadata-eval87.6%
cancel-sign-sub-inv87.6%
*-un-lft-identity87.6%
Applied egg-rr87.6%
*-commutative87.6%
distribute-rgt-out--87.7%
*-un-lft-identity87.7%
*-commutative87.7%
Applied egg-rr87.7%
if -7.19999999999999935e60 < z < 1.50000000000000003e91Initial program 99.8%
associate--l+99.8%
associate-+l-99.8%
fma-neg99.8%
sub-neg99.8%
+-commutative99.8%
distribute-neg-out99.8%
remove-double-neg99.8%
sub-neg99.8%
Simplified99.8%
Taylor expanded in z around 0 95.5%
+-commutative95.5%
+-commutative95.5%
*-commutative95.5%
associate--l+95.5%
*-commutative95.5%
+-commutative95.5%
Simplified95.5%
if 1.9000000000000001e133 < z Initial program 100.0%
associate--l+100.0%
associate-+l-100.0%
fma-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in z around inf 96.2%
Final simplification93.6%
(FPCore (x y z)
:precision binary64
(if (<= y 2.4e-104)
(- x z)
(if (<= y 5.4e-62)
(- (* (log y) -0.5) z)
(if (<= y 2.45e+146) (- (+ x -1.0) z) (* y (- 1.0 (log y)))))))
double code(double x, double y, double z) {
double tmp;
if (y <= 2.4e-104) {
tmp = x - z;
} else if (y <= 5.4e-62) {
tmp = (log(y) * -0.5) - z;
} else if (y <= 2.45e+146) {
tmp = (x + -1.0) - z;
} else {
tmp = y * (1.0 - 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 <= 2.4d-104) then
tmp = x - z
else if (y <= 5.4d-62) then
tmp = (log(y) * (-0.5d0)) - z
else if (y <= 2.45d+146) then
tmp = (x + (-1.0d0)) - z
else
tmp = y * (1.0d0 - log(y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 2.4e-104) {
tmp = x - z;
} else if (y <= 5.4e-62) {
tmp = (Math.log(y) * -0.5) - z;
} else if (y <= 2.45e+146) {
tmp = (x + -1.0) - z;
} else {
tmp = y * (1.0 - Math.log(y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 2.4e-104: tmp = x - z elif y <= 5.4e-62: tmp = (math.log(y) * -0.5) - z elif y <= 2.45e+146: tmp = (x + -1.0) - z else: tmp = y * (1.0 - math.log(y)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 2.4e-104) tmp = Float64(x - z); elseif (y <= 5.4e-62) tmp = Float64(Float64(log(y) * -0.5) - z); elseif (y <= 2.45e+146) tmp = Float64(Float64(x + -1.0) - z); else tmp = Float64(y * Float64(1.0 - log(y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 2.4e-104) tmp = x - z; elseif (y <= 5.4e-62) tmp = (log(y) * -0.5) - z; elseif (y <= 2.45e+146) tmp = (x + -1.0) - z; else tmp = y * (1.0 - log(y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 2.4e-104], N[(x - z), $MachinePrecision], If[LessEqual[y, 5.4e-62], N[(N[(N[Log[y], $MachinePrecision] * -0.5), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[y, 2.45e+146], N[(N[(x + -1.0), $MachinePrecision] - z), $MachinePrecision], N[(y * N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.4 \cdot 10^{-104}:\\
\;\;\;\;x - z\\
\mathbf{elif}\;y \leq 5.4 \cdot 10^{-62}:\\
\;\;\;\;\log y \cdot -0.5 - z\\
\mathbf{elif}\;y \leq 2.45 \cdot 10^{+146}:\\
\;\;\;\;\left(x + -1\right) - z\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(1 - \log y\right)\\
\end{array}
\end{array}
if y < 2.4000000000000001e-104Initial program 100.0%
associate--l+100.0%
associate-+l-100.0%
fma-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in z around inf 83.5%
if 2.4000000000000001e-104 < y < 5.40000000000000039e-62Initial program 100.0%
Taylor expanded in y around 0 100.0%
Taylor expanded in x around 0 75.6%
*-commutative75.6%
Simplified75.6%
if 5.40000000000000039e-62 < y < 2.4500000000000001e146Initial program 99.9%
expm1-log1p-u99.9%
expm1-udef99.9%
associate-+r-99.9%
cancel-sign-sub-inv99.9%
*-commutative99.9%
neg-sub099.9%
+-commutative99.9%
associate--r+99.9%
metadata-eval99.9%
Applied egg-rr99.9%
Taylor expanded in x around inf 75.9%
if 2.4500000000000001e146 < y Initial program 99.6%
associate--l+99.5%
associate-+l-99.5%
fma-neg99.6%
sub-neg99.6%
+-commutative99.6%
distribute-neg-out99.6%
remove-double-neg99.6%
sub-neg99.6%
Simplified99.6%
Taylor expanded in y around inf 80.0%
cancel-sign-sub-inv80.0%
metadata-eval80.0%
log-rec80.0%
neg-mul-180.0%
associate-*r*80.0%
metadata-eval80.0%
neg-mul-180.0%
sub-neg80.0%
Simplified80.0%
Final simplification79.5%
(FPCore (x y z) :precision binary64 (- (+ y (- x (* (+ y 0.5) (log y)))) z))
double code(double x, double y, double z) {
return (y + (x - ((y + 0.5) * log(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 = (y + (x - ((y + 0.5d0) * log(y)))) - z
end function
public static double code(double x, double y, double z) {
return (y + (x - ((y + 0.5) * Math.log(y)))) - z;
}
def code(x, y, z): return (y + (x - ((y + 0.5) * math.log(y)))) - z
function code(x, y, z) return Float64(Float64(y + Float64(x - Float64(Float64(y + 0.5) * log(y)))) - z) end
function tmp = code(x, y, z) tmp = (y + (x - ((y + 0.5) * log(y)))) - z; end
code[x_, y_, z_] := N[(N[(y + N[(x - N[(N[(y + 0.5), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}
\\
\left(y + \left(x - \left(y + 0.5\right) \cdot \log y\right)\right) - z
\end{array}
Initial program 99.8%
Final simplification99.8%
(FPCore (x y z) :precision binary64 (if (<= y 1.85e+146) (- x z) (* y (- 1.0 (log y)))))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.85e+146) {
tmp = x - z;
} else {
tmp = y * (1.0 - 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 <= 1.85d+146) then
tmp = x - z
else
tmp = y * (1.0d0 - log(y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 1.85e+146) {
tmp = x - z;
} else {
tmp = y * (1.0 - Math.log(y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1.85e+146: tmp = x - z else: tmp = y * (1.0 - math.log(y)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 1.85e+146) tmp = Float64(x - z); else tmp = Float64(y * Float64(1.0 - log(y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 1.85e+146) tmp = x - z; else tmp = y * (1.0 - log(y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1.85e+146], N[(x - z), $MachinePrecision], N[(y * N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.85 \cdot 10^{+146}:\\
\;\;\;\;x - z\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(1 - \log y\right)\\
\end{array}
\end{array}
if y < 1.85000000000000002e146Initial program 99.9%
associate--l+99.9%
associate-+l-99.9%
fma-neg99.9%
sub-neg99.9%
+-commutative99.9%
distribute-neg-out99.9%
remove-double-neg99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in z around inf 76.9%
if 1.85000000000000002e146 < y Initial program 99.6%
associate--l+99.5%
associate-+l-99.5%
fma-neg99.6%
sub-neg99.6%
+-commutative99.6%
distribute-neg-out99.6%
remove-double-neg99.6%
sub-neg99.6%
Simplified99.6%
Taylor expanded in y around inf 80.0%
cancel-sign-sub-inv80.0%
metadata-eval80.0%
log-rec80.0%
neg-mul-180.0%
associate-*r*80.0%
metadata-eval80.0%
neg-mul-180.0%
sub-neg80.0%
Simplified80.0%
Final simplification77.8%
(FPCore (x y z) :precision binary64 (if (or (<= z -9.8e+17) (not (<= z 1.9e+89))) (- z) x))
double code(double x, double y, double z) {
double tmp;
if ((z <= -9.8e+17) || !(z <= 1.9e+89)) {
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 <= (-9.8d+17)) .or. (.not. (z <= 1.9d+89))) 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 <= -9.8e+17) || !(z <= 1.9e+89)) {
tmp = -z;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -9.8e+17) or not (z <= 1.9e+89): tmp = -z else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -9.8e+17) || !(z <= 1.9e+89)) tmp = Float64(-z); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -9.8e+17) || ~((z <= 1.9e+89))) tmp = -z; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -9.8e+17], N[Not[LessEqual[z, 1.9e+89]], $MachinePrecision]], (-z), x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -9.8 \cdot 10^{+17} \lor \neg \left(z \leq 1.9 \cdot 10^{+89}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -9.8e17 or 1.90000000000000012e89 < z Initial program 99.9%
associate--l+99.9%
associate-+l-99.9%
fma-neg99.9%
sub-neg99.9%
+-commutative99.9%
distribute-neg-out99.9%
remove-double-neg99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in z around inf 63.9%
mul-1-neg63.9%
Simplified63.9%
if -9.8e17 < z < 1.90000000000000012e89Initial program 99.8%
associate--l+99.8%
associate-+l-99.8%
fma-neg99.8%
sub-neg99.8%
+-commutative99.8%
distribute-neg-out99.8%
remove-double-neg99.8%
sub-neg99.8%
Simplified99.8%
Taylor expanded in x around inf 42.1%
Final simplification51.5%
(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%
associate--l+99.8%
associate-+l-99.8%
fma-neg99.9%
sub-neg99.9%
+-commutative99.9%
distribute-neg-out99.9%
remove-double-neg99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in z around inf 60.3%
Final simplification60.3%
(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%
associate-+l-99.8%
fma-neg99.9%
sub-neg99.9%
+-commutative99.9%
distribute-neg-out99.9%
remove-double-neg99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in x around inf 31.0%
Final simplification31.0%
(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 2023301
(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))