
(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 14 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%
Final simplification99.8%
(FPCore (x y z)
:precision binary64
(if (<= z -7e+115)
(- x z)
(if (<= z -7000000000000.0)
(- y (+ z (* y (log y))))
(if (<= z 4.2e+21)
(+ x (- y (* (log y) (+ y 0.5))))
(- (* y (- 1.0 (log y))) z)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -7e+115) {
tmp = x - z;
} else if (z <= -7000000000000.0) {
tmp = y - (z + (y * log(y)));
} else if (z <= 4.2e+21) {
tmp = x + (y - (log(y) * (y + 0.5)));
} else {
tmp = (y * (1.0 - 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) :: tmp
if (z <= (-7d+115)) then
tmp = x - z
else if (z <= (-7000000000000.0d0)) then
tmp = y - (z + (y * log(y)))
else if (z <= 4.2d+21) then
tmp = x + (y - (log(y) * (y + 0.5d0)))
else
tmp = (y * (1.0d0 - log(y))) - z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -7e+115) {
tmp = x - z;
} else if (z <= -7000000000000.0) {
tmp = y - (z + (y * Math.log(y)));
} else if (z <= 4.2e+21) {
tmp = x + (y - (Math.log(y) * (y + 0.5)));
} else {
tmp = (y * (1.0 - Math.log(y))) - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -7e+115: tmp = x - z elif z <= -7000000000000.0: tmp = y - (z + (y * math.log(y))) elif z <= 4.2e+21: tmp = x + (y - (math.log(y) * (y + 0.5))) else: tmp = (y * (1.0 - math.log(y))) - z return tmp
function code(x, y, z) tmp = 0.0 if (z <= -7e+115) tmp = Float64(x - z); elseif (z <= -7000000000000.0) tmp = Float64(y - Float64(z + Float64(y * log(y)))); elseif (z <= 4.2e+21) tmp = Float64(x + Float64(y - Float64(log(y) * Float64(y + 0.5)))); else tmp = Float64(Float64(y * Float64(1.0 - log(y))) - z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -7e+115) tmp = x - z; elseif (z <= -7000000000000.0) tmp = y - (z + (y * log(y))); elseif (z <= 4.2e+21) tmp = x + (y - (log(y) * (y + 0.5))); else tmp = (y * (1.0 - log(y))) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -7e+115], N[(x - z), $MachinePrecision], If[LessEqual[z, -7000000000000.0], N[(y - N[(z + N[(y * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 4.2e+21], N[(x + N[(y - N[(N[Log[y], $MachinePrecision] * N[(y + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y * N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -7 \cdot 10^{+115}:\\
\;\;\;\;x - z\\
\mathbf{elif}\;z \leq -7000000000000:\\
\;\;\;\;y - \left(z + y \cdot \log y\right)\\
\mathbf{elif}\;z \leq 4.2 \cdot 10^{+21}:\\
\;\;\;\;x + \left(y - \log y \cdot \left(y + 0.5\right)\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(1 - \log y\right) - z\\
\end{array}
\end{array}
if z < -7.00000000000000011e115Initial program 100.0%
associate--l+100.0%
sub-neg100.0%
associate-+l+100.0%
associate-+r-100.0%
*-commutative100.0%
distribute-rgt-neg-in100.0%
fma-define100.0%
+-commutative100.0%
distribute-neg-in100.0%
unsub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 93.8%
Taylor expanded in x around inf 93.8%
if -7.00000000000000011e115 < z < -7e12Initial program 99.7%
associate--l+99.7%
Simplified99.7%
Taylor expanded in y around inf 98.4%
mul-1-neg98.4%
distribute-rgt-neg-in98.4%
log-rec98.4%
remove-double-neg98.4%
Simplified98.4%
Taylor expanded in x around 0 98.4%
if -7e12 < z < 4.2e21Initial program 99.8%
Taylor expanded in y around 0 99.8%
Taylor expanded in z around 0 99.0%
sub-neg99.0%
sub-neg99.0%
distribute-lft-in99.0%
*-rgt-identity99.0%
distribute-rgt-neg-in99.0%
neg-mul-199.0%
associate-+r+99.0%
associate-+r+99.0%
neg-mul-199.0%
distribute-neg-in99.0%
+-commutative99.0%
distribute-rgt-in99.0%
sub-neg99.0%
associate--l+99.0%
+-commutative99.0%
Simplified99.0%
if 4.2e21 < z Initial program 99.8%
Taylor expanded in y around inf 91.7%
*-commutative91.7%
log-rec91.7%
distribute-lft-neg-in91.7%
distribute-rgt-neg-in91.7%
Simplified91.7%
Taylor expanded in y around 0 91.7%
neg-mul-191.7%
+-commutative91.7%
neg-mul-191.7%
sub-neg91.7%
sub-neg91.7%
Simplified91.7%
Final simplification96.5%
(FPCore (x y z)
:precision binary64
(if (<= z -5.5e+114)
(- x z)
(if (or (<= z -39000000.0) (not (<= z 0.47)))
(- y (+ z (* y (log y))))
(- x (* (log y) 0.5)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -5.5e+114) {
tmp = x - z;
} else if ((z <= -39000000.0) || !(z <= 0.47)) {
tmp = y - (z + (y * log(y)));
} else {
tmp = x - (log(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 (z <= (-5.5d+114)) then
tmp = x - z
else if ((z <= (-39000000.0d0)) .or. (.not. (z <= 0.47d0))) then
tmp = y - (z + (y * log(y)))
else
tmp = x - (log(y) * 0.5d0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -5.5e+114) {
tmp = x - z;
} else if ((z <= -39000000.0) || !(z <= 0.47)) {
tmp = y - (z + (y * Math.log(y)));
} else {
tmp = x - (Math.log(y) * 0.5);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -5.5e+114: tmp = x - z elif (z <= -39000000.0) or not (z <= 0.47): tmp = y - (z + (y * math.log(y))) else: tmp = x - (math.log(y) * 0.5) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -5.5e+114) tmp = Float64(x - z); elseif ((z <= -39000000.0) || !(z <= 0.47)) tmp = Float64(y - Float64(z + Float64(y * log(y)))); else tmp = Float64(x - Float64(log(y) * 0.5)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -5.5e+114) tmp = x - z; elseif ((z <= -39000000.0) || ~((z <= 0.47))) tmp = y - (z + (y * log(y))); else tmp = x - (log(y) * 0.5); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -5.5e+114], N[(x - z), $MachinePrecision], If[Or[LessEqual[z, -39000000.0], N[Not[LessEqual[z, 0.47]], $MachinePrecision]], N[(y - N[(z + N[(y * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[Log[y], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.5 \cdot 10^{+114}:\\
\;\;\;\;x - z\\
\mathbf{elif}\;z \leq -39000000 \lor \neg \left(z \leq 0.47\right):\\
\;\;\;\;y - \left(z + y \cdot \log y\right)\\
\mathbf{else}:\\
\;\;\;\;x - \log y \cdot 0.5\\
\end{array}
\end{array}
if z < -5.5000000000000001e114Initial program 100.0%
associate--l+100.0%
sub-neg100.0%
associate-+l+100.0%
associate-+r-100.0%
*-commutative100.0%
distribute-rgt-neg-in100.0%
fma-define100.0%
+-commutative100.0%
distribute-neg-in100.0%
unsub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 93.8%
Taylor expanded in x around inf 93.8%
if -5.5000000000000001e114 < z < -3.9e7 or 0.46999999999999997 < z Initial program 99.8%
associate--l+99.8%
Simplified99.8%
Taylor expanded in y around inf 99.5%
mul-1-neg99.5%
distribute-rgt-neg-in99.5%
log-rec99.5%
remove-double-neg99.5%
Simplified99.5%
Taylor expanded in x around 0 90.4%
if -3.9e7 < z < 0.46999999999999997Initial program 99.8%
Taylor expanded in y around 0 99.9%
Taylor expanded in z around 0 99.0%
Taylor expanded in y around 0 72.2%
Final simplification81.1%
(FPCore (x y z) :precision binary64 (if (or (<= y 1.7e+135) (and (not (<= y 2.8e+202)) (<= y 1.95e+222))) (- x z) (* y (- 1.0 (log y)))))
double code(double x, double y, double z) {
double tmp;
if ((y <= 1.7e+135) || (!(y <= 2.8e+202) && (y <= 1.95e+222))) {
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.7d+135) .or. (.not. (y <= 2.8d+202)) .and. (y <= 1.95d+222)) 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.7e+135) || (!(y <= 2.8e+202) && (y <= 1.95e+222))) {
tmp = x - z;
} else {
tmp = y * (1.0 - Math.log(y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= 1.7e+135) or (not (y <= 2.8e+202) and (y <= 1.95e+222)): tmp = x - z else: tmp = y * (1.0 - math.log(y)) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= 1.7e+135) || (!(y <= 2.8e+202) && (y <= 1.95e+222))) 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.7e+135) || (~((y <= 2.8e+202)) && (y <= 1.95e+222))) tmp = x - z; else tmp = y * (1.0 - log(y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, 1.7e+135], And[N[Not[LessEqual[y, 2.8e+202]], $MachinePrecision], LessEqual[y, 1.95e+222]]], 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.7 \cdot 10^{+135} \lor \neg \left(y \leq 2.8 \cdot 10^{+202}\right) \land y \leq 1.95 \cdot 10^{+222}:\\
\;\;\;\;x - z\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(1 - \log y\right)\\
\end{array}
\end{array}
if y < 1.70000000000000005e135 or 2.80000000000000016e202 < y < 1.9499999999999999e222Initial program 99.9%
associate--l+99.9%
sub-neg99.9%
associate-+l+99.9%
associate-+r-99.9%
*-commutative99.9%
distribute-rgt-neg-in99.9%
fma-define99.9%
+-commutative99.9%
distribute-neg-in99.9%
unsub-neg99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in y around 0 91.9%
Taylor expanded in x around inf 73.8%
if 1.70000000000000005e135 < y < 2.80000000000000016e202 or 1.9499999999999999e222 < y Initial program 99.6%
Taylor expanded in y around 0 99.6%
Taylor expanded in z around 0 90.4%
Taylor expanded in x around 0 77.2%
cancel-sign-sub-inv77.2%
sub-neg77.2%
distribute-lft-in77.2%
*-rgt-identity77.2%
distribute-rgt-neg-out77.2%
distribute-lft-neg-out77.2%
metadata-eval77.2%
associate-+l+77.2%
+-commutative77.2%
distribute-rgt-in77.2%
sub-neg77.2%
Simplified77.2%
Taylor expanded in y around inf 77.2%
log-rec77.2%
sub-neg77.2%
Simplified77.2%
Final simplification74.7%
(FPCore (x y z)
:precision binary64
(if (<= x -0.084)
(- x z)
(if (<= x -8.5e-91)
(* y (- 1.0 (log y)))
(if (<= x 0.92) (- (* (log y) -0.5) z) (- x z)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -0.084) {
tmp = x - z;
} else if (x <= -8.5e-91) {
tmp = y * (1.0 - log(y));
} else if (x <= 0.92) {
tmp = (log(y) * -0.5) - z;
} 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 (x <= (-0.084d0)) then
tmp = x - z
else if (x <= (-8.5d-91)) then
tmp = y * (1.0d0 - log(y))
else if (x <= 0.92d0) then
tmp = (log(y) * (-0.5d0)) - z
else
tmp = x - z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -0.084) {
tmp = x - z;
} else if (x <= -8.5e-91) {
tmp = y * (1.0 - Math.log(y));
} else if (x <= 0.92) {
tmp = (Math.log(y) * -0.5) - z;
} else {
tmp = x - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -0.084: tmp = x - z elif x <= -8.5e-91: tmp = y * (1.0 - math.log(y)) elif x <= 0.92: tmp = (math.log(y) * -0.5) - z else: tmp = x - z return tmp
function code(x, y, z) tmp = 0.0 if (x <= -0.084) tmp = Float64(x - z); elseif (x <= -8.5e-91) tmp = Float64(y * Float64(1.0 - log(y))); elseif (x <= 0.92) tmp = Float64(Float64(log(y) * -0.5) - z); else tmp = Float64(x - z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -0.084) tmp = x - z; elseif (x <= -8.5e-91) tmp = y * (1.0 - log(y)); elseif (x <= 0.92) tmp = (log(y) * -0.5) - z; else tmp = x - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -0.084], N[(x - z), $MachinePrecision], If[LessEqual[x, -8.5e-91], N[(y * N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.92], N[(N[(N[Log[y], $MachinePrecision] * -0.5), $MachinePrecision] - z), $MachinePrecision], N[(x - z), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.084:\\
\;\;\;\;x - z\\
\mathbf{elif}\;x \leq -8.5 \cdot 10^{-91}:\\
\;\;\;\;y \cdot \left(1 - \log y\right)\\
\mathbf{elif}\;x \leq 0.92:\\
\;\;\;\;\log y \cdot -0.5 - z\\
\mathbf{else}:\\
\;\;\;\;x - z\\
\end{array}
\end{array}
if x < -0.0840000000000000052 or 0.92000000000000004 < x Initial program 99.9%
associate--l+99.9%
sub-neg99.9%
associate-+l+99.9%
associate-+r-99.9%
*-commutative99.9%
distribute-rgt-neg-in99.9%
fma-define99.9%
+-commutative99.9%
distribute-neg-in99.9%
unsub-neg99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in y around 0 80.2%
Taylor expanded in x around inf 79.9%
if -0.0840000000000000052 < x < -8.49999999999999985e-91Initial program 99.4%
Taylor expanded in y around 0 99.3%
Taylor expanded in z around 0 89.3%
Taylor expanded in x around 0 89.0%
cancel-sign-sub-inv89.0%
sub-neg89.0%
distribute-lft-in89.0%
*-rgt-identity89.0%
distribute-rgt-neg-out89.0%
distribute-lft-neg-out89.0%
metadata-eval89.0%
associate-+l+89.0%
+-commutative89.0%
distribute-rgt-in89.1%
sub-neg89.1%
Simplified89.1%
Taylor expanded in y around inf 62.8%
log-rec62.8%
sub-neg62.8%
Simplified62.8%
if -8.49999999999999985e-91 < x < 0.92000000000000004Initial program 99.9%
associate--l+99.8%
sub-neg99.8%
associate-+l+99.8%
associate-+r-99.9%
*-commutative99.9%
distribute-rgt-neg-in99.9%
fma-define99.8%
+-commutative99.8%
distribute-neg-in99.8%
unsub-neg99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around 0 72.4%
Taylor expanded in x around 0 72.4%
*-commutative72.4%
Simplified72.4%
Final simplification75.5%
(FPCore (x y z)
:precision binary64
(if (<= x -200.0)
(- x z)
(if (<= x -7e-101)
(+ y (* (log y) (- -0.5 y)))
(if (<= x 0.92) (- (* (log y) -0.5) z) (- x z)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -200.0) {
tmp = x - z;
} else if (x <= -7e-101) {
tmp = y + (log(y) * (-0.5 - y));
} else if (x <= 0.92) {
tmp = (log(y) * -0.5) - z;
} 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 (x <= (-200.0d0)) then
tmp = x - z
else if (x <= (-7d-101)) then
tmp = y + (log(y) * ((-0.5d0) - y))
else if (x <= 0.92d0) then
tmp = (log(y) * (-0.5d0)) - z
else
tmp = x - z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -200.0) {
tmp = x - z;
} else if (x <= -7e-101) {
tmp = y + (Math.log(y) * (-0.5 - y));
} else if (x <= 0.92) {
tmp = (Math.log(y) * -0.5) - z;
} else {
tmp = x - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -200.0: tmp = x - z elif x <= -7e-101: tmp = y + (math.log(y) * (-0.5 - y)) elif x <= 0.92: tmp = (math.log(y) * -0.5) - z else: tmp = x - z return tmp
function code(x, y, z) tmp = 0.0 if (x <= -200.0) tmp = Float64(x - z); elseif (x <= -7e-101) tmp = Float64(y + Float64(log(y) * Float64(-0.5 - y))); elseif (x <= 0.92) tmp = Float64(Float64(log(y) * -0.5) - z); else tmp = Float64(x - z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -200.0) tmp = x - z; elseif (x <= -7e-101) tmp = y + (log(y) * (-0.5 - y)); elseif (x <= 0.92) tmp = (log(y) * -0.5) - z; else tmp = x - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -200.0], N[(x - z), $MachinePrecision], If[LessEqual[x, -7e-101], N[(y + N[(N[Log[y], $MachinePrecision] * N[(-0.5 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.92], N[(N[(N[Log[y], $MachinePrecision] * -0.5), $MachinePrecision] - z), $MachinePrecision], N[(x - z), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -200:\\
\;\;\;\;x - z\\
\mathbf{elif}\;x \leq -7 \cdot 10^{-101}:\\
\;\;\;\;y + \log y \cdot \left(-0.5 - y\right)\\
\mathbf{elif}\;x \leq 0.92:\\
\;\;\;\;\log y \cdot -0.5 - z\\
\mathbf{else}:\\
\;\;\;\;x - z\\
\end{array}
\end{array}
if x < -200 or 0.92000000000000004 < x Initial program 99.9%
associate--l+99.9%
sub-neg99.9%
associate-+l+99.9%
associate-+r-99.9%
*-commutative99.9%
distribute-rgt-neg-in99.9%
fma-define99.9%
+-commutative99.9%
distribute-neg-in99.9%
unsub-neg99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in y around 0 80.2%
Taylor expanded in x around inf 79.9%
if -200 < x < -6.99999999999999989e-101Initial program 99.4%
Taylor expanded in y around 0 99.3%
Taylor expanded in z around 0 89.3%
Taylor expanded in x around 0 89.0%
cancel-sign-sub-inv89.0%
sub-neg89.0%
distribute-lft-in89.0%
*-rgt-identity89.0%
distribute-rgt-neg-out89.0%
distribute-lft-neg-out89.0%
metadata-eval89.0%
associate-+l+89.0%
+-commutative89.0%
distribute-rgt-in89.1%
sub-neg89.1%
Simplified89.1%
if -6.99999999999999989e-101 < x < 0.92000000000000004Initial program 99.9%
associate--l+99.8%
sub-neg99.8%
associate-+l+99.8%
associate-+r-99.9%
*-commutative99.9%
distribute-rgt-neg-in99.9%
fma-define99.8%
+-commutative99.8%
distribute-neg-in99.8%
unsub-neg99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around 0 72.4%
Taylor expanded in x around 0 72.4%
*-commutative72.4%
Simplified72.4%
Final simplification77.5%
(FPCore (x y z) :precision binary64 (if (<= y 6.2e-262) (- (* (log y) -0.5) z) (if (<= y 24000000000.0) (- x z) (- (+ x y) (* y (log y))))))
double code(double x, double y, double z) {
double tmp;
if (y <= 6.2e-262) {
tmp = (log(y) * -0.5) - z;
} else if (y <= 24000000000.0) {
tmp = x - z;
} else {
tmp = (x + y) - (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.2d-262) then
tmp = (log(y) * (-0.5d0)) - z
else if (y <= 24000000000.0d0) then
tmp = x - z
else
tmp = (x + y) - (y * log(y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 6.2e-262) {
tmp = (Math.log(y) * -0.5) - z;
} else if (y <= 24000000000.0) {
tmp = x - z;
} else {
tmp = (x + y) - (y * Math.log(y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 6.2e-262: tmp = (math.log(y) * -0.5) - z elif y <= 24000000000.0: tmp = x - z else: tmp = (x + y) - (y * math.log(y)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 6.2e-262) tmp = Float64(Float64(log(y) * -0.5) - z); elseif (y <= 24000000000.0) tmp = Float64(x - z); else tmp = Float64(Float64(x + y) - Float64(y * log(y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 6.2e-262) tmp = (log(y) * -0.5) - z; elseif (y <= 24000000000.0) tmp = x - z; else tmp = (x + y) - (y * log(y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 6.2e-262], N[(N[(N[Log[y], $MachinePrecision] * -0.5), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[y, 24000000000.0], N[(x - z), $MachinePrecision], N[(N[(x + y), $MachinePrecision] - N[(y * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 6.2 \cdot 10^{-262}:\\
\;\;\;\;\log y \cdot -0.5 - z\\
\mathbf{elif}\;y \leq 24000000000:\\
\;\;\;\;x - z\\
\mathbf{else}:\\
\;\;\;\;\left(x + y\right) - y \cdot \log y\\
\end{array}
\end{array}
if y < 6.1999999999999997e-262Initial program 100.0%
associate--l+100.0%
sub-neg100.0%
associate-+l+100.0%
associate-+r-100.0%
*-commutative100.0%
distribute-rgt-neg-in100.0%
fma-define100.0%
+-commutative100.0%
distribute-neg-in100.0%
unsub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 100.0%
Taylor expanded in x around 0 80.9%
*-commutative80.9%
Simplified80.9%
if 6.1999999999999997e-262 < y < 2.4e10Initial program 100.0%
associate--l+100.0%
sub-neg100.0%
associate-+l+100.0%
associate-+r-100.0%
*-commutative100.0%
distribute-rgt-neg-in100.0%
fma-define100.0%
+-commutative100.0%
distribute-neg-in100.0%
unsub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 99.3%
Taylor expanded in x around inf 78.9%
if 2.4e10 < y Initial program 99.6%
associate--l+99.6%
Simplified99.6%
Taylor expanded in y around inf 99.4%
mul-1-neg99.4%
distribute-rgt-neg-in99.4%
log-rec99.4%
remove-double-neg99.4%
Simplified99.4%
Taylor expanded in z around 0 83.8%
Final simplification81.3%
(FPCore (x y z) :precision binary64 (if (or (<= z -33500000.0) (not (<= z 165.0))) (- x z) (- x (* (log y) 0.5))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -33500000.0) || !(z <= 165.0)) {
tmp = x - z;
} else {
tmp = x - (log(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 ((z <= (-33500000.0d0)) .or. (.not. (z <= 165.0d0))) then
tmp = x - z
else
tmp = x - (log(y) * 0.5d0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -33500000.0) || !(z <= 165.0)) {
tmp = x - z;
} else {
tmp = x - (Math.log(y) * 0.5);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -33500000.0) or not (z <= 165.0): tmp = x - z else: tmp = x - (math.log(y) * 0.5) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -33500000.0) || !(z <= 165.0)) tmp = Float64(x - z); else tmp = Float64(x - Float64(log(y) * 0.5)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -33500000.0) || ~((z <= 165.0))) tmp = x - z; else tmp = x - (log(y) * 0.5); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -33500000.0], N[Not[LessEqual[z, 165.0]], $MachinePrecision]], N[(x - z), $MachinePrecision], N[(x - N[(N[Log[y], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -33500000 \lor \neg \left(z \leq 165\right):\\
\;\;\;\;x - z\\
\mathbf{else}:\\
\;\;\;\;x - \log y \cdot 0.5\\
\end{array}
\end{array}
if z < -3.35e7 or 165 < z Initial program 99.8%
associate--l+99.8%
sub-neg99.8%
associate-+l+99.8%
associate-+r-99.9%
*-commutative99.9%
distribute-rgt-neg-in99.9%
fma-define99.8%
+-commutative99.8%
distribute-neg-in99.8%
unsub-neg99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around 0 75.6%
Taylor expanded in x around inf 75.4%
if -3.35e7 < z < 165Initial program 99.8%
Taylor expanded in y around 0 99.8%
Taylor expanded in z around 0 98.9%
Taylor expanded in y around 0 71.7%
Final simplification73.4%
(FPCore (x y z) :precision binary64 (if (<= y 4e-8) (- (+ x (* (log y) -0.5)) z) (+ x (- (* y (- 1.0 (log y))) z))))
double code(double x, double y, double z) {
double tmp;
if (y <= 4e-8) {
tmp = (x + (log(y) * -0.5)) - z;
} else {
tmp = x + ((y * (1.0 - 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) :: tmp
if (y <= 4d-8) then
tmp = (x + (log(y) * (-0.5d0))) - z
else
tmp = x + ((y * (1.0d0 - log(y))) - z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 4e-8) {
tmp = (x + (Math.log(y) * -0.5)) - z;
} else {
tmp = x + ((y * (1.0 - Math.log(y))) - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 4e-8: tmp = (x + (math.log(y) * -0.5)) - z else: tmp = x + ((y * (1.0 - math.log(y))) - z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 4e-8) tmp = Float64(Float64(x + Float64(log(y) * -0.5)) - z); else tmp = Float64(x + Float64(Float64(y * Float64(1.0 - log(y))) - z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 4e-8) tmp = (x + (log(y) * -0.5)) - z; else tmp = x + ((y * (1.0 - log(y))) - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 4e-8], N[(N[(x + N[(N[Log[y], $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], N[(x + N[(N[(y * N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4 \cdot 10^{-8}:\\
\;\;\;\;\left(x + \log y \cdot -0.5\right) - z\\
\mathbf{else}:\\
\;\;\;\;x + \left(y \cdot \left(1 - \log y\right) - z\right)\\
\end{array}
\end{array}
if y < 4.0000000000000001e-8Initial program 100.0%
associate--l+100.0%
sub-neg100.0%
associate-+l+100.0%
associate-+r-100.0%
*-commutative100.0%
distribute-rgt-neg-in100.0%
fma-define100.0%
+-commutative100.0%
distribute-neg-in100.0%
unsub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 100.0%
if 4.0000000000000001e-8 < y Initial program 99.7%
associate--l+99.7%
sub-neg99.7%
associate-+l+99.7%
associate-+r-99.7%
*-commutative99.7%
distribute-rgt-neg-in99.7%
fma-define99.7%
+-commutative99.7%
distribute-neg-in99.7%
unsub-neg99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in y around inf 99.1%
log-rec99.1%
sub-neg99.1%
Simplified99.1%
Final simplification99.6%
(FPCore (x y z) :precision binary64 (if (<= y 11000000000.0) (- (+ x (* (log y) -0.5)) z) (- (+ x y) (* y (log y)))))
double code(double x, double y, double z) {
double tmp;
if (y <= 11000000000.0) {
tmp = (x + (log(y) * -0.5)) - z;
} else {
tmp = (x + y) - (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 <= 11000000000.0d0) then
tmp = (x + (log(y) * (-0.5d0))) - z
else
tmp = (x + y) - (y * log(y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 11000000000.0) {
tmp = (x + (Math.log(y) * -0.5)) - z;
} else {
tmp = (x + y) - (y * Math.log(y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 11000000000.0: tmp = (x + (math.log(y) * -0.5)) - z else: tmp = (x + y) - (y * math.log(y)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 11000000000.0) tmp = Float64(Float64(x + Float64(log(y) * -0.5)) - z); else tmp = Float64(Float64(x + y) - Float64(y * log(y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 11000000000.0) tmp = (x + (log(y) * -0.5)) - z; else tmp = (x + y) - (y * log(y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 11000000000.0], N[(N[(x + N[(N[Log[y], $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], N[(N[(x + y), $MachinePrecision] - N[(y * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 11000000000:\\
\;\;\;\;\left(x + \log y \cdot -0.5\right) - z\\
\mathbf{else}:\\
\;\;\;\;\left(x + y\right) - y \cdot \log y\\
\end{array}
\end{array}
if y < 1.1e10Initial program 100.0%
associate--l+100.0%
sub-neg100.0%
associate-+l+100.0%
associate-+r-100.0%
*-commutative100.0%
distribute-rgt-neg-in100.0%
fma-define100.0%
+-commutative100.0%
distribute-neg-in100.0%
unsub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 99.4%
if 1.1e10 < y Initial program 99.6%
associate--l+99.6%
Simplified99.6%
Taylor expanded in y around inf 99.4%
mul-1-neg99.4%
distribute-rgt-neg-in99.4%
log-rec99.4%
remove-double-neg99.4%
Simplified99.4%
Taylor expanded in z around 0 83.8%
Final simplification92.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(y + Float64(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[(y + N[(N[(x - N[(N[Log[y], $MachinePrecision] * N[(y + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
y + \left(\left(x - \log y \cdot \left(y + 0.5\right)\right) - z\right)
\end{array}
Initial program 99.8%
+-commutative99.8%
associate--l+99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (x y z) :precision binary64 (if (or (<= z -6700000000000.0) (not (<= z 1.16e+26))) (- z) x))
double code(double x, double y, double z) {
double tmp;
if ((z <= -6700000000000.0) || !(z <= 1.16e+26)) {
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 <= (-6700000000000.0d0)) .or. (.not. (z <= 1.16d+26))) 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 <= -6700000000000.0) || !(z <= 1.16e+26)) {
tmp = -z;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -6700000000000.0) or not (z <= 1.16e+26): tmp = -z else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -6700000000000.0) || !(z <= 1.16e+26)) tmp = Float64(-z); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -6700000000000.0) || ~((z <= 1.16e+26))) tmp = -z; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -6700000000000.0], N[Not[LessEqual[z, 1.16e+26]], $MachinePrecision]], (-z), x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -6700000000000 \lor \neg \left(z \leq 1.16 \cdot 10^{+26}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -6.7e12 or 1.15999999999999996e26 < z 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%
Taylor expanded in z around inf 63.7%
neg-mul-163.7%
Simplified63.7%
if -6.7e12 < z < 1.15999999999999996e26Initial 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%
Taylor expanded in x around inf 48.1%
Final simplification55.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%
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%
Taylor expanded in y around 0 74.0%
Taylor expanded in x around inf 60.5%
Final simplification60.5%
(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%
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%
Taylor expanded in x around inf 33.0%
Final simplification33.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 2024039
(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))