
(FPCore (x y z)
:precision binary64
(+
(+ (- (* (- x 0.5) (log x)) x) 0.91893853320467)
(/
(+
(* (- (* (+ y 0.0007936500793651) z) 0.0027777777777778) z)
0.083333333333333)
x)))
double code(double x, double y, double z) {
return ((((x - 0.5) * log(x)) - x) + 0.91893853320467) + ((((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / 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 - 0.5d0) * log(x)) - x) + 0.91893853320467d0) + ((((((y + 0.0007936500793651d0) * z) - 0.0027777777777778d0) * z) + 0.083333333333333d0) / x)
end function
public static double code(double x, double y, double z) {
return ((((x - 0.5) * Math.log(x)) - x) + 0.91893853320467) + ((((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x);
}
def code(x, y, z): return ((((x - 0.5) * math.log(x)) - x) + 0.91893853320467) + ((((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x)
function code(x, y, z) return Float64(Float64(Float64(Float64(Float64(x - 0.5) * log(x)) - x) + 0.91893853320467) + Float64(Float64(Float64(Float64(Float64(Float64(y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x)) end
function tmp = code(x, y, z) tmp = ((((x - 0.5) * log(x)) - x) + 0.91893853320467) + ((((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x); end
code[x_, y_, z_] := N[(N[(N[(N[(N[(x - 0.5), $MachinePrecision] * N[Log[x], $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision] + 0.91893853320467), $MachinePrecision] + N[(N[(N[(N[(N[(N[(y + 0.0007936500793651), $MachinePrecision] * z), $MachinePrecision] - 0.0027777777777778), $MachinePrecision] * z), $MachinePrecision] + 0.083333333333333), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z)
:precision binary64
(+
(+ (- (* (- x 0.5) (log x)) x) 0.91893853320467)
(/
(+
(* (- (* (+ y 0.0007936500793651) z) 0.0027777777777778) z)
0.083333333333333)
x)))
double code(double x, double y, double z) {
return ((((x - 0.5) * log(x)) - x) + 0.91893853320467) + ((((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / 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 - 0.5d0) * log(x)) - x) + 0.91893853320467d0) + ((((((y + 0.0007936500793651d0) * z) - 0.0027777777777778d0) * z) + 0.083333333333333d0) / x)
end function
public static double code(double x, double y, double z) {
return ((((x - 0.5) * Math.log(x)) - x) + 0.91893853320467) + ((((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x);
}
def code(x, y, z): return ((((x - 0.5) * math.log(x)) - x) + 0.91893853320467) + ((((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x)
function code(x, y, z) return Float64(Float64(Float64(Float64(Float64(x - 0.5) * log(x)) - x) + 0.91893853320467) + Float64(Float64(Float64(Float64(Float64(Float64(y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x)) end
function tmp = code(x, y, z) tmp = ((((x - 0.5) * log(x)) - x) + 0.91893853320467) + ((((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x); end
code[x_, y_, z_] := N[(N[(N[(N[(N[(x - 0.5), $MachinePrecision] * N[Log[x], $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision] + 0.91893853320467), $MachinePrecision] + N[(N[(N[(N[(N[(N[(y + 0.0007936500793651), $MachinePrecision] * z), $MachinePrecision] - 0.0027777777777778), $MachinePrecision] * z), $MachinePrecision] + 0.083333333333333), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x}
\end{array}
(FPCore (x y z)
:precision binary64
(if (<= x 1.45e-29)
(-
(+
0.91893853320467
(+
(/ 0.083333333333333 x)
(/ (* z (- (* z (+ 0.0007936500793651 y)) 0.0027777777777778)) x)))
x)
(-
(+
0.91893853320467
(+
(/ 0.083333333333333 x)
(+
(*
z
(-
(* y (+ (* 0.0007936500793651 (/ z (* x y))) (/ z x)))
(/ 0.0027777777777778 x)))
(* (log x) (+ x -0.5)))))
x)))
double code(double x, double y, double z) {
double tmp;
if (x <= 1.45e-29) {
tmp = (0.91893853320467 + ((0.083333333333333 / x) + ((z * ((z * (0.0007936500793651 + y)) - 0.0027777777777778)) / x))) - x;
} else {
tmp = (0.91893853320467 + ((0.083333333333333 / x) + ((z * ((y * ((0.0007936500793651 * (z / (x * y))) + (z / x))) - (0.0027777777777778 / x))) + (log(x) * (x + -0.5))))) - 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.45d-29) then
tmp = (0.91893853320467d0 + ((0.083333333333333d0 / x) + ((z * ((z * (0.0007936500793651d0 + y)) - 0.0027777777777778d0)) / x))) - x
else
tmp = (0.91893853320467d0 + ((0.083333333333333d0 / x) + ((z * ((y * ((0.0007936500793651d0 * (z / (x * y))) + (z / x))) - (0.0027777777777778d0 / x))) + (log(x) * (x + (-0.5d0)))))) - x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= 1.45e-29) {
tmp = (0.91893853320467 + ((0.083333333333333 / x) + ((z * ((z * (0.0007936500793651 + y)) - 0.0027777777777778)) / x))) - x;
} else {
tmp = (0.91893853320467 + ((0.083333333333333 / x) + ((z * ((y * ((0.0007936500793651 * (z / (x * y))) + (z / x))) - (0.0027777777777778 / x))) + (Math.log(x) * (x + -0.5))))) - x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= 1.45e-29: tmp = (0.91893853320467 + ((0.083333333333333 / x) + ((z * ((z * (0.0007936500793651 + y)) - 0.0027777777777778)) / x))) - x else: tmp = (0.91893853320467 + ((0.083333333333333 / x) + ((z * ((y * ((0.0007936500793651 * (z / (x * y))) + (z / x))) - (0.0027777777777778 / x))) + (math.log(x) * (x + -0.5))))) - x return tmp
function code(x, y, z) tmp = 0.0 if (x <= 1.45e-29) tmp = Float64(Float64(0.91893853320467 + Float64(Float64(0.083333333333333 / x) + Float64(Float64(z * Float64(Float64(z * Float64(0.0007936500793651 + y)) - 0.0027777777777778)) / x))) - x); else tmp = Float64(Float64(0.91893853320467 + Float64(Float64(0.083333333333333 / x) + Float64(Float64(z * Float64(Float64(y * Float64(Float64(0.0007936500793651 * Float64(z / Float64(x * y))) + Float64(z / x))) - Float64(0.0027777777777778 / x))) + Float64(log(x) * Float64(x + -0.5))))) - x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= 1.45e-29) tmp = (0.91893853320467 + ((0.083333333333333 / x) + ((z * ((z * (0.0007936500793651 + y)) - 0.0027777777777778)) / x))) - x; else tmp = (0.91893853320467 + ((0.083333333333333 / x) + ((z * ((y * ((0.0007936500793651 * (z / (x * y))) + (z / x))) - (0.0027777777777778 / x))) + (log(x) * (x + -0.5))))) - x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, 1.45e-29], N[(N[(0.91893853320467 + N[(N[(0.083333333333333 / x), $MachinePrecision] + N[(N[(z * N[(N[(z * N[(0.0007936500793651 + y), $MachinePrecision]), $MachinePrecision] - 0.0027777777777778), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision], N[(N[(0.91893853320467 + N[(N[(0.083333333333333 / x), $MachinePrecision] + N[(N[(z * N[(N[(y * N[(N[(0.0007936500793651 * N[(z / N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(z / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(0.0027777777777778 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Log[x], $MachinePrecision] * N[(x + -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.45 \cdot 10^{-29}:\\
\;\;\;\;\left(0.91893853320467 + \left(\frac{0.083333333333333}{x} + \frac{z \cdot \left(z \cdot \left(0.0007936500793651 + y\right) - 0.0027777777777778\right)}{x}\right)\right) - x\\
\mathbf{else}:\\
\;\;\;\;\left(0.91893853320467 + \left(\frac{0.083333333333333}{x} + \left(z \cdot \left(y \cdot \left(0.0007936500793651 \cdot \frac{z}{x \cdot y} + \frac{z}{x}\right) - \frac{0.0027777777777778}{x}\right) + \log x \cdot \left(x + -0.5\right)\right)\right)\right) - x\\
\end{array}
\end{array}
if x < 1.45000000000000012e-29Initial program 99.7%
Taylor expanded in z around 0 92.7%
Simplified92.8%
Taylor expanded in x around 0 99.8%
if 1.45000000000000012e-29 < x Initial program 89.6%
Taylor expanded in z around 0 98.6%
Simplified98.7%
fma-undefine98.7%
Applied egg-rr98.7%
Taylor expanded in y around inf 98.7%
Final simplification99.3%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (- (* z (+ 0.0007936500793651 y)) 0.0027777777777778))))
(if (<= t_0 -0.001)
(-
(+ 0.91893853320467 (+ (/ 0.083333333333333 x) (* y (/ (pow z 2.0) x))))
x)
(if (<= t_0 1e-35)
(+
(/ 0.083333333333333 x)
(- (+ 0.91893853320467 (* (log x) (+ x -0.5))) x))
(-
(+
0.91893853320467
(+
(/ 0.083333333333333 x)
(* z (/ (fma z (+ 0.0007936500793651 y) -0.0027777777777778) x))))
x)))))
double code(double x, double y, double z) {
double t_0 = z * ((z * (0.0007936500793651 + y)) - 0.0027777777777778);
double tmp;
if (t_0 <= -0.001) {
tmp = (0.91893853320467 + ((0.083333333333333 / x) + (y * (pow(z, 2.0) / x)))) - x;
} else if (t_0 <= 1e-35) {
tmp = (0.083333333333333 / x) + ((0.91893853320467 + (log(x) * (x + -0.5))) - x);
} else {
tmp = (0.91893853320467 + ((0.083333333333333 / x) + (z * (fma(z, (0.0007936500793651 + y), -0.0027777777777778) / x)))) - x;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(z * Float64(Float64(z * Float64(0.0007936500793651 + y)) - 0.0027777777777778)) tmp = 0.0 if (t_0 <= -0.001) tmp = Float64(Float64(0.91893853320467 + Float64(Float64(0.083333333333333 / x) + Float64(y * Float64((z ^ 2.0) / x)))) - x); elseif (t_0 <= 1e-35) tmp = Float64(Float64(0.083333333333333 / x) + Float64(Float64(0.91893853320467 + Float64(log(x) * Float64(x + -0.5))) - x)); else tmp = Float64(Float64(0.91893853320467 + Float64(Float64(0.083333333333333 / x) + Float64(z * Float64(fma(z, Float64(0.0007936500793651 + y), -0.0027777777777778) / x)))) - x); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * N[(N[(z * N[(0.0007936500793651 + y), $MachinePrecision]), $MachinePrecision] - 0.0027777777777778), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -0.001], N[(N[(0.91893853320467 + N[(N[(0.083333333333333 / x), $MachinePrecision] + N[(y * N[(N[Power[z, 2.0], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision], If[LessEqual[t$95$0, 1e-35], N[(N[(0.083333333333333 / x), $MachinePrecision] + N[(N[(0.91893853320467 + N[(N[Log[x], $MachinePrecision] * N[(x + -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision], N[(N[(0.91893853320467 + N[(N[(0.083333333333333 / x), $MachinePrecision] + N[(z * N[(N[(z * N[(0.0007936500793651 + y), $MachinePrecision] + -0.0027777777777778), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \left(z \cdot \left(0.0007936500793651 + y\right) - 0.0027777777777778\right)\\
\mathbf{if}\;t\_0 \leq -0.001:\\
\;\;\;\;\left(0.91893853320467 + \left(\frac{0.083333333333333}{x} + y \cdot \frac{{z}^{2}}{x}\right)\right) - x\\
\mathbf{elif}\;t\_0 \leq 10^{-35}:\\
\;\;\;\;\frac{0.083333333333333}{x} + \left(\left(0.91893853320467 + \log x \cdot \left(x + -0.5\right)\right) - x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(0.91893853320467 + \left(\frac{0.083333333333333}{x} + z \cdot \frac{\mathsf{fma}\left(z, 0.0007936500793651 + y, -0.0027777777777778\right)}{x}\right)\right) - x\\
\end{array}
\end{array}
if (*.f64 (-.f64 (*.f64 (+.f64 y #s(literal 7936500793651/10000000000000000 binary64)) z) #s(literal 13888888888889/5000000000000000 binary64)) z) < -1e-3Initial program 89.1%
Taylor expanded in z around 0 92.5%
Simplified92.5%
Taylor expanded in y around inf 79.3%
associate-/l*83.3%
Simplified83.3%
if -1e-3 < (*.f64 (-.f64 (*.f64 (+.f64 y #s(literal 7936500793651/10000000000000000 binary64)) z) #s(literal 13888888888889/5000000000000000 binary64)) z) < 1.00000000000000001e-35Initial program 99.5%
sub-neg99.5%
associate-+l+99.5%
+-commutative99.5%
sub-neg99.5%
associate-+r-99.5%
sub-neg99.5%
metadata-eval99.5%
Applied egg-rr99.5%
Taylor expanded in z around 0 99.5%
if 1.00000000000000001e-35 < (*.f64 (-.f64 (*.f64 (+.f64 y #s(literal 7936500793651/10000000000000000 binary64)) z) #s(literal 13888888888889/5000000000000000 binary64)) z) Initial program 91.7%
Taylor expanded in z around 0 97.3%
Simplified97.3%
Taylor expanded in x around 0 87.4%
associate-/l*88.6%
fmm-def88.6%
metadata-eval88.6%
Simplified88.6%
Final simplification93.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (log x) (+ x -0.5))))
(if (<= x 220.0)
(+
(- (+ 0.91893853320467 t_0) x)
(/
(+
0.083333333333333
(* z (- (* z (+ 0.0007936500793651 y)) 0.0027777777777778)))
x))
(-
(+
0.91893853320467
(+
(/ 0.083333333333333 x)
(+
t_0
(*
z
(-
(* z (+ (/ 0.0007936500793651 x) (/ y x)))
(/ 0.0027777777777778 x))))))
x))))
double code(double x, double y, double z) {
double t_0 = log(x) * (x + -0.5);
double tmp;
if (x <= 220.0) {
tmp = ((0.91893853320467 + t_0) - x) + ((0.083333333333333 + (z * ((z * (0.0007936500793651 + y)) - 0.0027777777777778))) / x);
} else {
tmp = (0.91893853320467 + ((0.083333333333333 / x) + (t_0 + (z * ((z * ((0.0007936500793651 / x) + (y / x))) - (0.0027777777777778 / x)))))) - 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(x) * (x + (-0.5d0))
if (x <= 220.0d0) then
tmp = ((0.91893853320467d0 + t_0) - x) + ((0.083333333333333d0 + (z * ((z * (0.0007936500793651d0 + y)) - 0.0027777777777778d0))) / x)
else
tmp = (0.91893853320467d0 + ((0.083333333333333d0 / x) + (t_0 + (z * ((z * ((0.0007936500793651d0 / x) + (y / x))) - (0.0027777777777778d0 / x)))))) - x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = Math.log(x) * (x + -0.5);
double tmp;
if (x <= 220.0) {
tmp = ((0.91893853320467 + t_0) - x) + ((0.083333333333333 + (z * ((z * (0.0007936500793651 + y)) - 0.0027777777777778))) / x);
} else {
tmp = (0.91893853320467 + ((0.083333333333333 / x) + (t_0 + (z * ((z * ((0.0007936500793651 / x) + (y / x))) - (0.0027777777777778 / x)))))) - x;
}
return tmp;
}
def code(x, y, z): t_0 = math.log(x) * (x + -0.5) tmp = 0 if x <= 220.0: tmp = ((0.91893853320467 + t_0) - x) + ((0.083333333333333 + (z * ((z * (0.0007936500793651 + y)) - 0.0027777777777778))) / x) else: tmp = (0.91893853320467 + ((0.083333333333333 / x) + (t_0 + (z * ((z * ((0.0007936500793651 / x) + (y / x))) - (0.0027777777777778 / x)))))) - x return tmp
function code(x, y, z) t_0 = Float64(log(x) * Float64(x + -0.5)) tmp = 0.0 if (x <= 220.0) tmp = Float64(Float64(Float64(0.91893853320467 + t_0) - x) + Float64(Float64(0.083333333333333 + Float64(z * Float64(Float64(z * Float64(0.0007936500793651 + y)) - 0.0027777777777778))) / x)); else tmp = Float64(Float64(0.91893853320467 + Float64(Float64(0.083333333333333 / x) + Float64(t_0 + Float64(z * Float64(Float64(z * Float64(Float64(0.0007936500793651 / x) + Float64(y / x))) - Float64(0.0027777777777778 / x)))))) - x); end return tmp end
function tmp_2 = code(x, y, z) t_0 = log(x) * (x + -0.5); tmp = 0.0; if (x <= 220.0) tmp = ((0.91893853320467 + t_0) - x) + ((0.083333333333333 + (z * ((z * (0.0007936500793651 + y)) - 0.0027777777777778))) / x); else tmp = (0.91893853320467 + ((0.083333333333333 / x) + (t_0 + (z * ((z * ((0.0007936500793651 / x) + (y / x))) - (0.0027777777777778 / x)))))) - x; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[Log[x], $MachinePrecision] * N[(x + -0.5), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 220.0], N[(N[(N[(0.91893853320467 + t$95$0), $MachinePrecision] - x), $MachinePrecision] + N[(N[(0.083333333333333 + N[(z * N[(N[(z * N[(0.0007936500793651 + y), $MachinePrecision]), $MachinePrecision] - 0.0027777777777778), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], N[(N[(0.91893853320467 + N[(N[(0.083333333333333 / x), $MachinePrecision] + N[(t$95$0 + N[(z * N[(N[(z * N[(N[(0.0007936500793651 / x), $MachinePrecision] + N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(0.0027777777777778 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \log x \cdot \left(x + -0.5\right)\\
\mathbf{if}\;x \leq 220:\\
\;\;\;\;\left(\left(0.91893853320467 + t\_0\right) - x\right) + \frac{0.083333333333333 + z \cdot \left(z \cdot \left(0.0007936500793651 + y\right) - 0.0027777777777778\right)}{x}\\
\mathbf{else}:\\
\;\;\;\;\left(0.91893853320467 + \left(\frac{0.083333333333333}{x} + \left(t\_0 + z \cdot \left(z \cdot \left(\frac{0.0007936500793651}{x} + \frac{y}{x}\right) - \frac{0.0027777777777778}{x}\right)\right)\right)\right) - x\\
\end{array}
\end{array}
if x < 220Initial program 99.7%
sub-neg99.7%
associate-+l+99.7%
+-commutative99.7%
sub-neg99.7%
associate-+r-99.7%
sub-neg99.7%
metadata-eval99.7%
Applied egg-rr99.7%
if 220 < x Initial program 88.5%
Taylor expanded in z around 0 98.6%
Simplified98.6%
fma-undefine98.6%
Applied egg-rr98.6%
Final simplification99.3%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ 0.91893853320467 (- (* (log x) (- x 0.5)) x))))
(if (<= x 7.7e+236)
(+
(/
(+
0.083333333333333
(* z (- (* z (+ 0.0007936500793651 y)) 0.0027777777777778)))
x)
t_0)
(+ (/ 0.083333333333333 x) t_0))))
double code(double x, double y, double z) {
double t_0 = 0.91893853320467 + ((log(x) * (x - 0.5)) - x);
double tmp;
if (x <= 7.7e+236) {
tmp = ((0.083333333333333 + (z * ((z * (0.0007936500793651 + y)) - 0.0027777777777778))) / x) + t_0;
} else {
tmp = (0.083333333333333 / x) + t_0;
}
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 = 0.91893853320467d0 + ((log(x) * (x - 0.5d0)) - x)
if (x <= 7.7d+236) then
tmp = ((0.083333333333333d0 + (z * ((z * (0.0007936500793651d0 + y)) - 0.0027777777777778d0))) / x) + t_0
else
tmp = (0.083333333333333d0 / x) + t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = 0.91893853320467 + ((Math.log(x) * (x - 0.5)) - x);
double tmp;
if (x <= 7.7e+236) {
tmp = ((0.083333333333333 + (z * ((z * (0.0007936500793651 + y)) - 0.0027777777777778))) / x) + t_0;
} else {
tmp = (0.083333333333333 / x) + t_0;
}
return tmp;
}
def code(x, y, z): t_0 = 0.91893853320467 + ((math.log(x) * (x - 0.5)) - x) tmp = 0 if x <= 7.7e+236: tmp = ((0.083333333333333 + (z * ((z * (0.0007936500793651 + y)) - 0.0027777777777778))) / x) + t_0 else: tmp = (0.083333333333333 / x) + t_0 return tmp
function code(x, y, z) t_0 = Float64(0.91893853320467 + Float64(Float64(log(x) * Float64(x - 0.5)) - x)) tmp = 0.0 if (x <= 7.7e+236) tmp = Float64(Float64(Float64(0.083333333333333 + Float64(z * Float64(Float64(z * Float64(0.0007936500793651 + y)) - 0.0027777777777778))) / x) + t_0); else tmp = Float64(Float64(0.083333333333333 / x) + t_0); end return tmp end
function tmp_2 = code(x, y, z) t_0 = 0.91893853320467 + ((log(x) * (x - 0.5)) - x); tmp = 0.0; if (x <= 7.7e+236) tmp = ((0.083333333333333 + (z * ((z * (0.0007936500793651 + y)) - 0.0027777777777778))) / x) + t_0; else tmp = (0.083333333333333 / x) + t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(0.91893853320467 + N[(N[(N[Log[x], $MachinePrecision] * N[(x - 0.5), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 7.7e+236], N[(N[(N[(0.083333333333333 + N[(z * N[(N[(z * N[(0.0007936500793651 + y), $MachinePrecision]), $MachinePrecision] - 0.0027777777777778), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] + t$95$0), $MachinePrecision], N[(N[(0.083333333333333 / x), $MachinePrecision] + t$95$0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.91893853320467 + \left(\log x \cdot \left(x - 0.5\right) - x\right)\\
\mathbf{if}\;x \leq 7.7 \cdot 10^{+236}:\\
\;\;\;\;\frac{0.083333333333333 + z \cdot \left(z \cdot \left(0.0007936500793651 + y\right) - 0.0027777777777778\right)}{x} + t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{0.083333333333333}{x} + t\_0\\
\end{array}
\end{array}
if x < 7.70000000000000035e236Initial program 97.2%
if 7.70000000000000035e236 < x Initial program 75.7%
Taylor expanded in z around 0 95.8%
Final simplification97.1%
(FPCore (x y z)
:precision binary64
(if (<= x 4e+237)
(+
(- (+ 0.91893853320467 (* (log x) (+ x -0.5))) x)
(/
(+
0.083333333333333
(* z (- (* z (+ 0.0007936500793651 y)) 0.0027777777777778)))
x))
(+
(/ 0.083333333333333 x)
(+ 0.91893853320467 (- (* (log x) (- x 0.5)) x)))))
double code(double x, double y, double z) {
double tmp;
if (x <= 4e+237) {
tmp = ((0.91893853320467 + (log(x) * (x + -0.5))) - x) + ((0.083333333333333 + (z * ((z * (0.0007936500793651 + y)) - 0.0027777777777778))) / x);
} else {
tmp = (0.083333333333333 / x) + (0.91893853320467 + ((log(x) * (x - 0.5)) - 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 <= 4d+237) then
tmp = ((0.91893853320467d0 + (log(x) * (x + (-0.5d0)))) - x) + ((0.083333333333333d0 + (z * ((z * (0.0007936500793651d0 + y)) - 0.0027777777777778d0))) / x)
else
tmp = (0.083333333333333d0 / x) + (0.91893853320467d0 + ((log(x) * (x - 0.5d0)) - x))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= 4e+237) {
tmp = ((0.91893853320467 + (Math.log(x) * (x + -0.5))) - x) + ((0.083333333333333 + (z * ((z * (0.0007936500793651 + y)) - 0.0027777777777778))) / x);
} else {
tmp = (0.083333333333333 / x) + (0.91893853320467 + ((Math.log(x) * (x - 0.5)) - x));
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= 4e+237: tmp = ((0.91893853320467 + (math.log(x) * (x + -0.5))) - x) + ((0.083333333333333 + (z * ((z * (0.0007936500793651 + y)) - 0.0027777777777778))) / x) else: tmp = (0.083333333333333 / x) + (0.91893853320467 + ((math.log(x) * (x - 0.5)) - x)) return tmp
function code(x, y, z) tmp = 0.0 if (x <= 4e+237) tmp = Float64(Float64(Float64(0.91893853320467 + Float64(log(x) * Float64(x + -0.5))) - x) + Float64(Float64(0.083333333333333 + Float64(z * Float64(Float64(z * Float64(0.0007936500793651 + y)) - 0.0027777777777778))) / x)); else tmp = Float64(Float64(0.083333333333333 / x) + Float64(0.91893853320467 + Float64(Float64(log(x) * Float64(x - 0.5)) - x))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= 4e+237) tmp = ((0.91893853320467 + (log(x) * (x + -0.5))) - x) + ((0.083333333333333 + (z * ((z * (0.0007936500793651 + y)) - 0.0027777777777778))) / x); else tmp = (0.083333333333333 / x) + (0.91893853320467 + ((log(x) * (x - 0.5)) - x)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, 4e+237], N[(N[(N[(0.91893853320467 + N[(N[Log[x], $MachinePrecision] * N[(x + -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision] + N[(N[(0.083333333333333 + N[(z * N[(N[(z * N[(0.0007936500793651 + y), $MachinePrecision]), $MachinePrecision] - 0.0027777777777778), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], N[(N[(0.083333333333333 / x), $MachinePrecision] + N[(0.91893853320467 + N[(N[(N[Log[x], $MachinePrecision] * N[(x - 0.5), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 4 \cdot 10^{+237}:\\
\;\;\;\;\left(\left(0.91893853320467 + \log x \cdot \left(x + -0.5\right)\right) - x\right) + \frac{0.083333333333333 + z \cdot \left(z \cdot \left(0.0007936500793651 + y\right) - 0.0027777777777778\right)}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.083333333333333}{x} + \left(0.91893853320467 + \left(\log x \cdot \left(x - 0.5\right) - x\right)\right)\\
\end{array}
\end{array}
if x < 3.99999999999999976e237Initial program 97.2%
sub-neg97.2%
associate-+l+97.2%
+-commutative97.2%
sub-neg97.2%
associate-+r-97.2%
sub-neg97.2%
metadata-eval97.2%
Applied egg-rr97.2%
if 3.99999999999999976e237 < x Initial program 75.7%
Taylor expanded in z around 0 95.8%
Final simplification97.1%
(FPCore (x y z)
:precision binary64
(if (<= x 3.8e+61)
(/
(+
0.083333333333333
(* z (- (* z (+ 0.0007936500793651 y)) 0.0027777777777778)))
x)
(* x (+ (log x) -1.0))))
double code(double x, double y, double z) {
double tmp;
if (x <= 3.8e+61) {
tmp = (0.083333333333333 + (z * ((z * (0.0007936500793651 + y)) - 0.0027777777777778))) / x;
} else {
tmp = x * (log(x) + -1.0);
}
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 <= 3.8d+61) then
tmp = (0.083333333333333d0 + (z * ((z * (0.0007936500793651d0 + y)) - 0.0027777777777778d0))) / x
else
tmp = x * (log(x) + (-1.0d0))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= 3.8e+61) {
tmp = (0.083333333333333 + (z * ((z * (0.0007936500793651 + y)) - 0.0027777777777778))) / x;
} else {
tmp = x * (Math.log(x) + -1.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= 3.8e+61: tmp = (0.083333333333333 + (z * ((z * (0.0007936500793651 + y)) - 0.0027777777777778))) / x else: tmp = x * (math.log(x) + -1.0) return tmp
function code(x, y, z) tmp = 0.0 if (x <= 3.8e+61) tmp = Float64(Float64(0.083333333333333 + Float64(z * Float64(Float64(z * Float64(0.0007936500793651 + y)) - 0.0027777777777778))) / x); else tmp = Float64(x * Float64(log(x) + -1.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= 3.8e+61) tmp = (0.083333333333333 + (z * ((z * (0.0007936500793651 + y)) - 0.0027777777777778))) / x; else tmp = x * (log(x) + -1.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, 3.8e+61], N[(N[(0.083333333333333 + N[(z * N[(N[(z * N[(0.0007936500793651 + y), $MachinePrecision]), $MachinePrecision] - 0.0027777777777778), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], N[(x * N[(N[Log[x], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.8 \cdot 10^{+61}:\\
\;\;\;\;\frac{0.083333333333333 + z \cdot \left(z \cdot \left(0.0007936500793651 + y\right) - 0.0027777777777778\right)}{x}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log x + -1\right)\\
\end{array}
\end{array}
if x < 3.79999999999999995e61Initial program 99.7%
sub-neg99.7%
associate-+l+99.7%
+-commutative99.7%
sub-neg99.7%
associate-+r-99.7%
sub-neg99.7%
metadata-eval99.7%
Applied egg-rr99.7%
Taylor expanded in x around 0 93.3%
if 3.79999999999999995e61 < x Initial program 85.4%
Taylor expanded in x around inf 80.1%
sub-neg80.1%
mul-1-neg80.1%
log-rec80.1%
remove-double-neg80.1%
metadata-eval80.1%
+-commutative80.1%
Simplified80.1%
Final simplification88.9%
(FPCore (x y z) :precision binary64 (+ 0.91893853320467 (/ (+ 0.083333333333333 (* z (- (* z 0.0007936500793651) 0.0027777777777778))) x)))
double code(double x, double y, double z) {
return 0.91893853320467 + ((0.083333333333333 + (z * ((z * 0.0007936500793651) - 0.0027777777777778))) / x);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 0.91893853320467d0 + ((0.083333333333333d0 + (z * ((z * 0.0007936500793651d0) - 0.0027777777777778d0))) / x)
end function
public static double code(double x, double y, double z) {
return 0.91893853320467 + ((0.083333333333333 + (z * ((z * 0.0007936500793651) - 0.0027777777777778))) / x);
}
def code(x, y, z): return 0.91893853320467 + ((0.083333333333333 + (z * ((z * 0.0007936500793651) - 0.0027777777777778))) / x)
function code(x, y, z) return Float64(0.91893853320467 + Float64(Float64(0.083333333333333 + Float64(z * Float64(Float64(z * 0.0007936500793651) - 0.0027777777777778))) / x)) end
function tmp = code(x, y, z) tmp = 0.91893853320467 + ((0.083333333333333 + (z * ((z * 0.0007936500793651) - 0.0027777777777778))) / x); end
code[x_, y_, z_] := N[(0.91893853320467 + N[(N[(0.083333333333333 + N[(z * N[(N[(z * 0.0007936500793651), $MachinePrecision] - 0.0027777777777778), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.91893853320467 + \frac{0.083333333333333 + z \cdot \left(z \cdot 0.0007936500793651 - 0.0027777777777778\right)}{x}
\end{array}
Initial program 95.0%
Taylor expanded in y around 0 81.3%
associate--l+81.3%
associate-*r/81.4%
metadata-eval81.4%
fma-define81.4%
sub-neg81.4%
metadata-eval81.4%
associate-/l*83.9%
fmm-def83.9%
metadata-eval83.9%
Simplified83.9%
Taylor expanded in x around 0 53.5%
Final simplification53.5%
(FPCore (x y z) :precision binary64 (/ (+ 0.083333333333333 (* z (- (* z (+ 0.0007936500793651 y)) 0.0027777777777778))) x))
double code(double x, double y, double z) {
return (0.083333333333333 + (z * ((z * (0.0007936500793651 + y)) - 0.0027777777777778))) / x;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (0.083333333333333d0 + (z * ((z * (0.0007936500793651d0 + y)) - 0.0027777777777778d0))) / x
end function
public static double code(double x, double y, double z) {
return (0.083333333333333 + (z * ((z * (0.0007936500793651 + y)) - 0.0027777777777778))) / x;
}
def code(x, y, z): return (0.083333333333333 + (z * ((z * (0.0007936500793651 + y)) - 0.0027777777777778))) / x
function code(x, y, z) return Float64(Float64(0.083333333333333 + Float64(z * Float64(Float64(z * Float64(0.0007936500793651 + y)) - 0.0027777777777778))) / x) end
function tmp = code(x, y, z) tmp = (0.083333333333333 + (z * ((z * (0.0007936500793651 + y)) - 0.0027777777777778))) / x; end
code[x_, y_, z_] := N[(N[(0.083333333333333 + N[(z * N[(N[(z * N[(0.0007936500793651 + y), $MachinePrecision]), $MachinePrecision] - 0.0027777777777778), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{0.083333333333333 + z \cdot \left(z \cdot \left(0.0007936500793651 + y\right) - 0.0027777777777778\right)}{x}
\end{array}
Initial program 95.0%
sub-neg95.0%
associate-+l+95.0%
+-commutative95.0%
sub-neg95.0%
associate-+r-95.0%
sub-neg95.0%
metadata-eval95.0%
Applied egg-rr95.0%
Taylor expanded in x around 0 67.3%
Final simplification67.3%
(FPCore (x y z) :precision binary64 (+ 0.91893853320467 (/ (+ 0.083333333333333 (* z -0.0027777777777778)) x)))
double code(double x, double y, double z) {
return 0.91893853320467 + ((0.083333333333333 + (z * -0.0027777777777778)) / x);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 0.91893853320467d0 + ((0.083333333333333d0 + (z * (-0.0027777777777778d0))) / x)
end function
public static double code(double x, double y, double z) {
return 0.91893853320467 + ((0.083333333333333 + (z * -0.0027777777777778)) / x);
}
def code(x, y, z): return 0.91893853320467 + ((0.083333333333333 + (z * -0.0027777777777778)) / x)
function code(x, y, z) return Float64(0.91893853320467 + Float64(Float64(0.083333333333333 + Float64(z * -0.0027777777777778)) / x)) end
function tmp = code(x, y, z) tmp = 0.91893853320467 + ((0.083333333333333 + (z * -0.0027777777777778)) / x); end
code[x_, y_, z_] := N[(0.91893853320467 + N[(N[(0.083333333333333 + N[(z * -0.0027777777777778), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.91893853320467 + \frac{0.083333333333333 + z \cdot -0.0027777777777778}{x}
\end{array}
Initial program 95.0%
Taylor expanded in y around 0 81.3%
associate--l+81.3%
associate-*r/81.4%
metadata-eval81.4%
fma-define81.4%
sub-neg81.4%
metadata-eval81.4%
associate-/l*83.9%
fmm-def83.9%
metadata-eval83.9%
Simplified83.9%
Taylor expanded in x around 0 53.5%
Taylor expanded in z around 0 32.3%
Final simplification32.3%
(FPCore (x y z) :precision binary64 (+ 0.91893853320467 (/ 0.083333333333333 x)))
double code(double x, double y, double z) {
return 0.91893853320467 + (0.083333333333333 / x);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 0.91893853320467d0 + (0.083333333333333d0 / x)
end function
public static double code(double x, double y, double z) {
return 0.91893853320467 + (0.083333333333333 / x);
}
def code(x, y, z): return 0.91893853320467 + (0.083333333333333 / x)
function code(x, y, z) return Float64(0.91893853320467 + Float64(0.083333333333333 / x)) end
function tmp = code(x, y, z) tmp = 0.91893853320467 + (0.083333333333333 / x); end
code[x_, y_, z_] := N[(0.91893853320467 + N[(0.083333333333333 / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.91893853320467 + \frac{0.083333333333333}{x}
\end{array}
Initial program 95.0%
Taylor expanded in y around 0 81.3%
associate--l+81.3%
associate-*r/81.4%
metadata-eval81.4%
fma-define81.4%
sub-neg81.4%
metadata-eval81.4%
associate-/l*83.9%
fmm-def83.9%
metadata-eval83.9%
Simplified83.9%
Taylor expanded in x around 0 53.5%
Taylor expanded in z around 0 24.5%
Final simplification24.5%
(FPCore (x y z) :precision binary64 (+ (+ (+ (* (- x 0.5) (log x)) (- 0.91893853320467 x)) (/ 0.083333333333333 x)) (* (/ z x) (- (* z (+ y 0.0007936500793651)) 0.0027777777777778))))
double code(double x, double y, double z) {
return ((((x - 0.5) * log(x)) + (0.91893853320467 - x)) + (0.083333333333333 / x)) + ((z / x) * ((z * (y + 0.0007936500793651)) - 0.0027777777777778));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = ((((x - 0.5d0) * log(x)) + (0.91893853320467d0 - x)) + (0.083333333333333d0 / x)) + ((z / x) * ((z * (y + 0.0007936500793651d0)) - 0.0027777777777778d0))
end function
public static double code(double x, double y, double z) {
return ((((x - 0.5) * Math.log(x)) + (0.91893853320467 - x)) + (0.083333333333333 / x)) + ((z / x) * ((z * (y + 0.0007936500793651)) - 0.0027777777777778));
}
def code(x, y, z): return ((((x - 0.5) * math.log(x)) + (0.91893853320467 - x)) + (0.083333333333333 / x)) + ((z / x) * ((z * (y + 0.0007936500793651)) - 0.0027777777777778))
function code(x, y, z) return Float64(Float64(Float64(Float64(Float64(x - 0.5) * log(x)) + Float64(0.91893853320467 - x)) + Float64(0.083333333333333 / x)) + Float64(Float64(z / x) * Float64(Float64(z * Float64(y + 0.0007936500793651)) - 0.0027777777777778))) end
function tmp = code(x, y, z) tmp = ((((x - 0.5) * log(x)) + (0.91893853320467 - x)) + (0.083333333333333 / x)) + ((z / x) * ((z * (y + 0.0007936500793651)) - 0.0027777777777778)); end
code[x_, y_, z_] := N[(N[(N[(N[(N[(x - 0.5), $MachinePrecision] * N[Log[x], $MachinePrecision]), $MachinePrecision] + N[(0.91893853320467 - x), $MachinePrecision]), $MachinePrecision] + N[(0.083333333333333 / x), $MachinePrecision]), $MachinePrecision] + N[(N[(z / x), $MachinePrecision] * N[(N[(z * N[(y + 0.0007936500793651), $MachinePrecision]), $MachinePrecision] - 0.0027777777777778), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(\left(x - 0.5\right) \cdot \log x + \left(0.91893853320467 - x\right)\right) + \frac{0.083333333333333}{x}\right) + \frac{z}{x} \cdot \left(z \cdot \left(y + 0.0007936500793651\right) - 0.0027777777777778\right)
\end{array}
herbie shell --seed 2024115
(FPCore (x y z)
:name "Numeric.SpecFunctions:$slogFactorial from math-functions-0.1.5.2, B"
:precision binary64
:alt
(+ (+ (+ (* (- x 0.5) (log x)) (- 0.91893853320467 x)) (/ 0.083333333333333 x)) (* (/ z x) (- (* z (+ y 0.0007936500793651)) 0.0027777777777778)))
(+ (+ (- (* (- x 0.5) (log x)) x) 0.91893853320467) (/ (+ (* (- (* (+ y 0.0007936500793651) z) 0.0027777777777778) z) 0.083333333333333) x)))