
(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 21000000000000.0)
(+
(- (fma (log x) (+ x -0.5) 0.91893853320467) x)
(/
(+
(* z (- (* (+ y 0.0007936500793651) z) 0.0027777777777778))
0.083333333333333)
x))
(+
(* x (+ (log x) -1.0))
(+
(*
z
(+
(* z (+ (* 0.0007936500793651 (/ 1.0 x)) (/ y x)))
(* 0.0027777777777778 (/ -1.0 x))))
(* 0.083333333333333 (/ 1.0 x))))))
double code(double x, double y, double z) {
double tmp;
if (x <= 21000000000000.0) {
tmp = (fma(log(x), (x + -0.5), 0.91893853320467) - x) + (((z * (((y + 0.0007936500793651) * z) - 0.0027777777777778)) + 0.083333333333333) / x);
} else {
tmp = (x * (log(x) + -1.0)) + ((z * ((z * ((0.0007936500793651 * (1.0 / x)) + (y / x))) + (0.0027777777777778 * (-1.0 / x)))) + (0.083333333333333 * (1.0 / x)));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= 21000000000000.0) tmp = Float64(Float64(fma(log(x), Float64(x + -0.5), 0.91893853320467) - x) + Float64(Float64(Float64(z * Float64(Float64(Float64(y + 0.0007936500793651) * z) - 0.0027777777777778)) + 0.083333333333333) / x)); else tmp = Float64(Float64(x * Float64(log(x) + -1.0)) + Float64(Float64(z * Float64(Float64(z * Float64(Float64(0.0007936500793651 * Float64(1.0 / x)) + Float64(y / x))) + Float64(0.0027777777777778 * Float64(-1.0 / x)))) + Float64(0.083333333333333 * Float64(1.0 / x)))); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, 21000000000000.0], N[(N[(N[(N[Log[x], $MachinePrecision] * N[(x + -0.5), $MachinePrecision] + 0.91893853320467), $MachinePrecision] - x), $MachinePrecision] + N[(N[(N[(z * N[(N[(N[(y + 0.0007936500793651), $MachinePrecision] * z), $MachinePrecision] - 0.0027777777777778), $MachinePrecision]), $MachinePrecision] + 0.083333333333333), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], N[(N[(x * N[(N[Log[x], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision] + N[(N[(z * N[(N[(z * N[(N[(0.0007936500793651 * N[(1.0 / x), $MachinePrecision]), $MachinePrecision] + N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.0027777777777778 * N[(-1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.083333333333333 * N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 21000000000000:\\
\;\;\;\;\left(\mathsf{fma}\left(\log x, x + -0.5, 0.91893853320467\right) - x\right) + \frac{z \cdot \left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) + 0.083333333333333}{x}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log x + -1\right) + \left(z \cdot \left(z \cdot \left(0.0007936500793651 \cdot \frac{1}{x} + \frac{y}{x}\right) + 0.0027777777777778 \cdot \frac{-1}{x}\right) + 0.083333333333333 \cdot \frac{1}{x}\right)\\
\end{array}
\end{array}
if x < 2.1e13Initial program 99.7%
Taylor expanded in x around 0 99.7%
sub-neg99.7%
metadata-eval99.7%
distribute-rgt-in99.7%
*-commutative99.7%
neg-mul-199.7%
associate-+l+99.7%
+-commutative99.7%
distribute-rgt-in99.7%
associate-+r+99.7%
sub-neg99.7%
+-commutative99.7%
fma-define99.7%
Simplified99.7%
if 2.1e13 < x Initial program 90.6%
Taylor expanded in x around 0 90.7%
sub-neg90.7%
metadata-eval90.7%
distribute-rgt-in90.6%
*-commutative90.6%
neg-mul-190.6%
associate-+l+90.6%
+-commutative90.6%
distribute-rgt-in90.6%
associate-+r+90.6%
sub-neg90.6%
+-commutative90.6%
fma-define90.6%
Simplified90.6%
Taylor expanded in x around inf 90.7%
sub-neg90.7%
mul-1-neg90.7%
log-rec90.7%
remove-double-neg90.7%
metadata-eval90.7%
Simplified90.7%
Taylor expanded in z around 0 99.6%
Final simplification99.7%
(FPCore (x y z)
:precision binary64
(if (<= x 30500000000000.0)
(+
(/
(+
(* z (- (* (+ y 0.0007936500793651) z) 0.0027777777777778))
0.083333333333333)
x)
(+ 0.91893853320467 (- (* (log x) (- x 0.5)) x)))
(+
(* x (+ (log x) -1.0))
(+
(*
z
(+
(* z (+ (* 0.0007936500793651 (/ 1.0 x)) (/ y x)))
(* 0.0027777777777778 (/ -1.0 x))))
(* 0.083333333333333 (/ 1.0 x))))))
double code(double x, double y, double z) {
double tmp;
if (x <= 30500000000000.0) {
tmp = (((z * (((y + 0.0007936500793651) * z) - 0.0027777777777778)) + 0.083333333333333) / x) + (0.91893853320467 + ((log(x) * (x - 0.5)) - x));
} else {
tmp = (x * (log(x) + -1.0)) + ((z * ((z * ((0.0007936500793651 * (1.0 / x)) + (y / x))) + (0.0027777777777778 * (-1.0 / x)))) + (0.083333333333333 * (1.0 / 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 <= 30500000000000.0d0) then
tmp = (((z * (((y + 0.0007936500793651d0) * z) - 0.0027777777777778d0)) + 0.083333333333333d0) / x) + (0.91893853320467d0 + ((log(x) * (x - 0.5d0)) - x))
else
tmp = (x * (log(x) + (-1.0d0))) + ((z * ((z * ((0.0007936500793651d0 * (1.0d0 / x)) + (y / x))) + (0.0027777777777778d0 * ((-1.0d0) / x)))) + (0.083333333333333d0 * (1.0d0 / x)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= 30500000000000.0) {
tmp = (((z * (((y + 0.0007936500793651) * z) - 0.0027777777777778)) + 0.083333333333333) / x) + (0.91893853320467 + ((Math.log(x) * (x - 0.5)) - x));
} else {
tmp = (x * (Math.log(x) + -1.0)) + ((z * ((z * ((0.0007936500793651 * (1.0 / x)) + (y / x))) + (0.0027777777777778 * (-1.0 / x)))) + (0.083333333333333 * (1.0 / x)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= 30500000000000.0: tmp = (((z * (((y + 0.0007936500793651) * z) - 0.0027777777777778)) + 0.083333333333333) / x) + (0.91893853320467 + ((math.log(x) * (x - 0.5)) - x)) else: tmp = (x * (math.log(x) + -1.0)) + ((z * ((z * ((0.0007936500793651 * (1.0 / x)) + (y / x))) + (0.0027777777777778 * (-1.0 / x)))) + (0.083333333333333 * (1.0 / x))) return tmp
function code(x, y, z) tmp = 0.0 if (x <= 30500000000000.0) tmp = Float64(Float64(Float64(Float64(z * Float64(Float64(Float64(y + 0.0007936500793651) * z) - 0.0027777777777778)) + 0.083333333333333) / x) + Float64(0.91893853320467 + Float64(Float64(log(x) * Float64(x - 0.5)) - x))); else tmp = Float64(Float64(x * Float64(log(x) + -1.0)) + Float64(Float64(z * Float64(Float64(z * Float64(Float64(0.0007936500793651 * Float64(1.0 / x)) + Float64(y / x))) + Float64(0.0027777777777778 * Float64(-1.0 / x)))) + Float64(0.083333333333333 * Float64(1.0 / x)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= 30500000000000.0) tmp = (((z * (((y + 0.0007936500793651) * z) - 0.0027777777777778)) + 0.083333333333333) / x) + (0.91893853320467 + ((log(x) * (x - 0.5)) - x)); else tmp = (x * (log(x) + -1.0)) + ((z * ((z * ((0.0007936500793651 * (1.0 / x)) + (y / x))) + (0.0027777777777778 * (-1.0 / x)))) + (0.083333333333333 * (1.0 / x))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, 30500000000000.0], N[(N[(N[(N[(z * N[(N[(N[(y + 0.0007936500793651), $MachinePrecision] * z), $MachinePrecision] - 0.0027777777777778), $MachinePrecision]), $MachinePrecision] + 0.083333333333333), $MachinePrecision] / x), $MachinePrecision] + N[(0.91893853320467 + N[(N[(N[Log[x], $MachinePrecision] * N[(x - 0.5), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * N[(N[Log[x], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision] + N[(N[(z * N[(N[(z * N[(N[(0.0007936500793651 * N[(1.0 / x), $MachinePrecision]), $MachinePrecision] + N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.0027777777777778 * N[(-1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.083333333333333 * N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 30500000000000:\\
\;\;\;\;\frac{z \cdot \left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) + 0.083333333333333}{x} + \left(0.91893853320467 + \left(\log x \cdot \left(x - 0.5\right) - x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log x + -1\right) + \left(z \cdot \left(z \cdot \left(0.0007936500793651 \cdot \frac{1}{x} + \frac{y}{x}\right) + 0.0027777777777778 \cdot \frac{-1}{x}\right) + 0.083333333333333 \cdot \frac{1}{x}\right)\\
\end{array}
\end{array}
if x < 3.05e13Initial program 99.7%
if 3.05e13 < x Initial program 90.6%
Taylor expanded in x around 0 90.7%
sub-neg90.7%
metadata-eval90.7%
distribute-rgt-in90.6%
*-commutative90.6%
neg-mul-190.6%
associate-+l+90.6%
+-commutative90.6%
distribute-rgt-in90.6%
associate-+r+90.6%
sub-neg90.6%
+-commutative90.6%
fma-define90.6%
Simplified90.6%
Taylor expanded in x around inf 90.7%
sub-neg90.7%
mul-1-neg90.7%
log-rec90.7%
remove-double-neg90.7%
metadata-eval90.7%
Simplified90.7%
Taylor expanded in z around 0 99.6%
Final simplification99.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (+ (log x) -1.0))))
(if (or (<= y -0.0008) (not (<= y 1.22e-26)))
(+ t_0 (/ (+ 0.083333333333333 (* z (- (* y z) 0.0027777777777778))) x))
(+
t_0
(/
(+
0.083333333333333
(* z (- (* 0.0007936500793651 z) 0.0027777777777778)))
x)))))
double code(double x, double y, double z) {
double t_0 = x * (log(x) + -1.0);
double tmp;
if ((y <= -0.0008) || !(y <= 1.22e-26)) {
tmp = t_0 + ((0.083333333333333 + (z * ((y * z) - 0.0027777777777778))) / x);
} else {
tmp = t_0 + ((0.083333333333333 + (z * ((0.0007936500793651 * z) - 0.0027777777777778))) / 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 = x * (log(x) + (-1.0d0))
if ((y <= (-0.0008d0)) .or. (.not. (y <= 1.22d-26))) then
tmp = t_0 + ((0.083333333333333d0 + (z * ((y * z) - 0.0027777777777778d0))) / x)
else
tmp = t_0 + ((0.083333333333333d0 + (z * ((0.0007936500793651d0 * z) - 0.0027777777777778d0))) / x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x * (Math.log(x) + -1.0);
double tmp;
if ((y <= -0.0008) || !(y <= 1.22e-26)) {
tmp = t_0 + ((0.083333333333333 + (z * ((y * z) - 0.0027777777777778))) / x);
} else {
tmp = t_0 + ((0.083333333333333 + (z * ((0.0007936500793651 * z) - 0.0027777777777778))) / x);
}
return tmp;
}
def code(x, y, z): t_0 = x * (math.log(x) + -1.0) tmp = 0 if (y <= -0.0008) or not (y <= 1.22e-26): tmp = t_0 + ((0.083333333333333 + (z * ((y * z) - 0.0027777777777778))) / x) else: tmp = t_0 + ((0.083333333333333 + (z * ((0.0007936500793651 * z) - 0.0027777777777778))) / x) return tmp
function code(x, y, z) t_0 = Float64(x * Float64(log(x) + -1.0)) tmp = 0.0 if ((y <= -0.0008) || !(y <= 1.22e-26)) tmp = Float64(t_0 + Float64(Float64(0.083333333333333 + Float64(z * Float64(Float64(y * z) - 0.0027777777777778))) / x)); else tmp = Float64(t_0 + Float64(Float64(0.083333333333333 + Float64(z * Float64(Float64(0.0007936500793651 * z) - 0.0027777777777778))) / x)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * (log(x) + -1.0); tmp = 0.0; if ((y <= -0.0008) || ~((y <= 1.22e-26))) tmp = t_0 + ((0.083333333333333 + (z * ((y * z) - 0.0027777777777778))) / x); else tmp = t_0 + ((0.083333333333333 + (z * ((0.0007936500793651 * z) - 0.0027777777777778))) / x); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(N[Log[x], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[y, -0.0008], N[Not[LessEqual[y, 1.22e-26]], $MachinePrecision]], N[(t$95$0 + N[(N[(0.083333333333333 + N[(z * N[(N[(y * z), $MachinePrecision] - 0.0027777777777778), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], N[(t$95$0 + N[(N[(0.083333333333333 + N[(z * N[(N[(0.0007936500793651 * z), $MachinePrecision] - 0.0027777777777778), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(\log x + -1\right)\\
\mathbf{if}\;y \leq -0.0008 \lor \neg \left(y \leq 1.22 \cdot 10^{-26}\right):\\
\;\;\;\;t\_0 + \frac{0.083333333333333 + z \cdot \left(y \cdot z - 0.0027777777777778\right)}{x}\\
\mathbf{else}:\\
\;\;\;\;t\_0 + \frac{0.083333333333333 + z \cdot \left(0.0007936500793651 \cdot z - 0.0027777777777778\right)}{x}\\
\end{array}
\end{array}
if y < -8.00000000000000038e-4 or 1.22e-26 < y Initial program 95.9%
Taylor expanded in x around 0 95.9%
sub-neg95.9%
metadata-eval95.9%
distribute-rgt-in95.9%
*-commutative95.9%
neg-mul-195.9%
associate-+l+95.9%
+-commutative95.9%
distribute-rgt-in95.9%
associate-+r+95.9%
sub-neg95.9%
+-commutative95.9%
fma-define95.9%
Simplified95.9%
Taylor expanded in x around inf 94.8%
sub-neg94.8%
mul-1-neg94.8%
log-rec94.8%
remove-double-neg94.8%
metadata-eval94.8%
Simplified94.8%
Taylor expanded in y around inf 94.8%
*-commutative94.8%
Simplified94.8%
if -8.00000000000000038e-4 < y < 1.22e-26Initial program 95.5%
Taylor expanded in x around 0 95.5%
sub-neg95.5%
metadata-eval95.5%
distribute-rgt-in95.5%
*-commutative95.5%
neg-mul-195.5%
associate-+l+95.5%
+-commutative95.5%
distribute-rgt-in95.5%
associate-+r+95.5%
sub-neg95.5%
+-commutative95.5%
fma-define95.5%
Simplified95.5%
Taylor expanded in x around inf 94.1%
sub-neg94.1%
mul-1-neg94.1%
log-rec94.1%
remove-double-neg94.1%
metadata-eval94.1%
Simplified94.1%
Taylor expanded in y around 0 94.1%
Final simplification94.4%
(FPCore (x y z)
:precision binary64
(+
(/
(+
(* z (- (* (+ y 0.0007936500793651) z) 0.0027777777777778))
0.083333333333333)
x)
(+ 0.91893853320467 (- (* (log x) (- x 0.5)) x))))
double code(double x, double y, double z) {
return (((z * (((y + 0.0007936500793651) * z) - 0.0027777777777778)) + 0.083333333333333) / x) + (0.91893853320467 + ((log(x) * (x - 0.5)) - x));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (((z * (((y + 0.0007936500793651d0) * z) - 0.0027777777777778d0)) + 0.083333333333333d0) / x) + (0.91893853320467d0 + ((log(x) * (x - 0.5d0)) - x))
end function
public static double code(double x, double y, double z) {
return (((z * (((y + 0.0007936500793651) * z) - 0.0027777777777778)) + 0.083333333333333) / x) + (0.91893853320467 + ((Math.log(x) * (x - 0.5)) - x));
}
def code(x, y, z): return (((z * (((y + 0.0007936500793651) * z) - 0.0027777777777778)) + 0.083333333333333) / x) + (0.91893853320467 + ((math.log(x) * (x - 0.5)) - x))
function code(x, y, z) return Float64(Float64(Float64(Float64(z * Float64(Float64(Float64(y + 0.0007936500793651) * z) - 0.0027777777777778)) + 0.083333333333333) / x) + Float64(0.91893853320467 + Float64(Float64(log(x) * Float64(x - 0.5)) - x))) end
function tmp = code(x, y, z) tmp = (((z * (((y + 0.0007936500793651) * z) - 0.0027777777777778)) + 0.083333333333333) / x) + (0.91893853320467 + ((log(x) * (x - 0.5)) - x)); end
code[x_, y_, z_] := N[(N[(N[(N[(z * N[(N[(N[(y + 0.0007936500793651), $MachinePrecision] * z), $MachinePrecision] - 0.0027777777777778), $MachinePrecision]), $MachinePrecision] + 0.083333333333333), $MachinePrecision] / x), $MachinePrecision] + N[(0.91893853320467 + N[(N[(N[Log[x], $MachinePrecision] * N[(x - 0.5), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{z \cdot \left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) + 0.083333333333333}{x} + \left(0.91893853320467 + \left(\log x \cdot \left(x - 0.5\right) - x\right)\right)
\end{array}
Initial program 95.7%
Final simplification95.7%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.1e+138) (not (<= z 4.5e+180))) (* x (/ 0.083333333333333 (pow x 2.0))) (+ (* x (+ (log x) -1.0)) (/ 0.083333333333333 x))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.1e+138) || !(z <= 4.5e+180)) {
tmp = x * (0.083333333333333 / pow(x, 2.0));
} else {
tmp = (x * (log(x) + -1.0)) + (0.083333333333333 / x);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z <= (-1.1d+138)) .or. (.not. (z <= 4.5d+180))) then
tmp = x * (0.083333333333333d0 / (x ** 2.0d0))
else
tmp = (x * (log(x) + (-1.0d0))) + (0.083333333333333d0 / x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.1e+138) || !(z <= 4.5e+180)) {
tmp = x * (0.083333333333333 / Math.pow(x, 2.0));
} else {
tmp = (x * (Math.log(x) + -1.0)) + (0.083333333333333 / x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.1e+138) or not (z <= 4.5e+180): tmp = x * (0.083333333333333 / math.pow(x, 2.0)) else: tmp = (x * (math.log(x) + -1.0)) + (0.083333333333333 / x) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.1e+138) || !(z <= 4.5e+180)) tmp = Float64(x * Float64(0.083333333333333 / (x ^ 2.0))); else tmp = Float64(Float64(x * Float64(log(x) + -1.0)) + Float64(0.083333333333333 / x)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.1e+138) || ~((z <= 4.5e+180))) tmp = x * (0.083333333333333 / (x ^ 2.0)); else tmp = (x * (log(x) + -1.0)) + (0.083333333333333 / x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.1e+138], N[Not[LessEqual[z, 4.5e+180]], $MachinePrecision]], N[(x * N[(0.083333333333333 / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * N[(N[Log[x], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision] + N[(0.083333333333333 / x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.1 \cdot 10^{+138} \lor \neg \left(z \leq 4.5 \cdot 10^{+180}\right):\\
\;\;\;\;x \cdot \frac{0.083333333333333}{{x}^{2}}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log x + -1\right) + \frac{0.083333333333333}{x}\\
\end{array}
\end{array}
if z < -1.1e138 or 4.49999999999999981e180 < z Initial program 92.0%
Taylor expanded in z around 0 7.6%
Taylor expanded in x around inf 7.6%
sub-neg7.6%
mul-1-neg7.6%
log-rec7.6%
remove-double-neg7.6%
metadata-eval7.6%
+-commutative7.6%
Simplified7.6%
Taylor expanded in x around inf 32.1%
associate--l+32.1%
mul-1-neg32.1%
log-rec32.1%
remove-double-neg32.1%
sub-neg32.1%
unpow232.1%
sqr-neg32.1%
associate-*r/32.1%
metadata-eval32.1%
sqr-neg32.1%
unpow232.1%
metadata-eval32.1%
Simplified32.1%
Taylor expanded in x around 0 28.2%
if -1.1e138 < z < 4.49999999999999981e180Initial program 96.8%
Taylor expanded in z around 0 71.2%
Taylor expanded in x around inf 69.5%
sub-neg69.5%
mul-1-neg69.5%
log-rec69.5%
remove-double-neg69.5%
metadata-eval69.5%
+-commutative69.5%
Simplified69.5%
Final simplification60.3%
(FPCore (x y z)
:precision binary64
(+
(/
(+
(* z (- (* (+ y 0.0007936500793651) z) 0.0027777777777778))
0.083333333333333)
x)
(* x (+ (log x) -1.0))))
double code(double x, double y, double z) {
return (((z * (((y + 0.0007936500793651) * z) - 0.0027777777777778)) + 0.083333333333333) / x) + (x * (log(x) + -1.0));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (((z * (((y + 0.0007936500793651d0) * z) - 0.0027777777777778d0)) + 0.083333333333333d0) / x) + (x * (log(x) + (-1.0d0)))
end function
public static double code(double x, double y, double z) {
return (((z * (((y + 0.0007936500793651) * z) - 0.0027777777777778)) + 0.083333333333333) / x) + (x * (Math.log(x) + -1.0));
}
def code(x, y, z): return (((z * (((y + 0.0007936500793651) * z) - 0.0027777777777778)) + 0.083333333333333) / x) + (x * (math.log(x) + -1.0))
function code(x, y, z) return Float64(Float64(Float64(Float64(z * Float64(Float64(Float64(y + 0.0007936500793651) * z) - 0.0027777777777778)) + 0.083333333333333) / x) + Float64(x * Float64(log(x) + -1.0))) end
function tmp = code(x, y, z) tmp = (((z * (((y + 0.0007936500793651) * z) - 0.0027777777777778)) + 0.083333333333333) / x) + (x * (log(x) + -1.0)); end
code[x_, y_, z_] := N[(N[(N[(N[(z * N[(N[(N[(y + 0.0007936500793651), $MachinePrecision] * z), $MachinePrecision] - 0.0027777777777778), $MachinePrecision]), $MachinePrecision] + 0.083333333333333), $MachinePrecision] / x), $MachinePrecision] + N[(x * N[(N[Log[x], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{z \cdot \left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) + 0.083333333333333}{x} + x \cdot \left(\log x + -1\right)
\end{array}
Initial program 95.7%
Taylor expanded in x around inf 94.4%
sub-neg55.8%
mul-1-neg55.8%
log-rec55.8%
remove-double-neg55.8%
metadata-eval55.8%
+-commutative55.8%
Simplified94.4%
Final simplification94.4%
(FPCore (x y z)
:precision binary64
(if (<= z 5.1e+106)
(+
(* x (+ (log x) -1.0))
(/ (+ 0.083333333333333 (* z -0.0027777777777778)) x))
(* x (/ 0.083333333333333 (pow x 2.0)))))
double code(double x, double y, double z) {
double tmp;
if (z <= 5.1e+106) {
tmp = (x * (log(x) + -1.0)) + ((0.083333333333333 + (z * -0.0027777777777778)) / x);
} else {
tmp = x * (0.083333333333333 / pow(x, 2.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 (z <= 5.1d+106) then
tmp = (x * (log(x) + (-1.0d0))) + ((0.083333333333333d0 + (z * (-0.0027777777777778d0))) / x)
else
tmp = x * (0.083333333333333d0 / (x ** 2.0d0))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= 5.1e+106) {
tmp = (x * (Math.log(x) + -1.0)) + ((0.083333333333333 + (z * -0.0027777777777778)) / x);
} else {
tmp = x * (0.083333333333333 / Math.pow(x, 2.0));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= 5.1e+106: tmp = (x * (math.log(x) + -1.0)) + ((0.083333333333333 + (z * -0.0027777777777778)) / x) else: tmp = x * (0.083333333333333 / math.pow(x, 2.0)) return tmp
function code(x, y, z) tmp = 0.0 if (z <= 5.1e+106) tmp = Float64(Float64(x * Float64(log(x) + -1.0)) + Float64(Float64(0.083333333333333 + Float64(z * -0.0027777777777778)) / x)); else tmp = Float64(x * Float64(0.083333333333333 / (x ^ 2.0))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= 5.1e+106) tmp = (x * (log(x) + -1.0)) + ((0.083333333333333 + (z * -0.0027777777777778)) / x); else tmp = x * (0.083333333333333 / (x ^ 2.0)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, 5.1e+106], N[(N[(x * N[(N[Log[x], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision] + N[(N[(0.083333333333333 + N[(z * -0.0027777777777778), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], N[(x * N[(0.083333333333333 / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 5.1 \cdot 10^{+106}:\\
\;\;\;\;x \cdot \left(\log x + -1\right) + \frac{0.083333333333333 + z \cdot -0.0027777777777778}{x}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{0.083333333333333}{{x}^{2}}\\
\end{array}
\end{array}
if z < 5.09999999999999971e106Initial program 97.4%
Taylor expanded in x around 0 97.4%
sub-neg97.4%
metadata-eval97.4%
distribute-rgt-in97.4%
*-commutative97.4%
neg-mul-197.4%
associate-+l+97.4%
+-commutative97.4%
distribute-rgt-in97.4%
associate-+r+97.4%
sub-neg97.4%
+-commutative97.4%
fma-define97.4%
Simplified97.4%
Taylor expanded in x around inf 95.8%
sub-neg95.8%
mul-1-neg95.8%
log-rec95.8%
remove-double-neg95.8%
metadata-eval95.8%
Simplified95.8%
Taylor expanded in z around 0 70.7%
*-commutative70.7%
Simplified70.7%
if 5.09999999999999971e106 < z Initial program 87.2%
Taylor expanded in z around 0 15.1%
Taylor expanded in x around inf 15.1%
sub-neg15.1%
mul-1-neg15.1%
log-rec15.1%
remove-double-neg15.1%
metadata-eval15.1%
+-commutative15.1%
Simplified15.1%
Taylor expanded in x around inf 36.9%
associate--l+36.9%
mul-1-neg36.9%
log-rec36.9%
remove-double-neg36.9%
sub-neg36.9%
unpow236.9%
sqr-neg36.9%
associate-*r/36.9%
metadata-eval36.9%
sqr-neg36.9%
unpow236.9%
metadata-eval36.9%
Simplified36.9%
Taylor expanded in x around 0 25.0%
Final simplification63.1%
(FPCore (x y z) :precision binary64 (+ (* x (+ (log x) -1.0)) (/ (+ 0.083333333333333 (* z (- (* 0.0007936500793651 z) 0.0027777777777778))) x)))
double code(double x, double y, double z) {
return (x * (log(x) + -1.0)) + ((0.083333333333333 + (z * ((0.0007936500793651 * 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 = (x * (log(x) + (-1.0d0))) + ((0.083333333333333d0 + (z * ((0.0007936500793651d0 * z) - 0.0027777777777778d0))) / x)
end function
public static double code(double x, double y, double z) {
return (x * (Math.log(x) + -1.0)) + ((0.083333333333333 + (z * ((0.0007936500793651 * z) - 0.0027777777777778))) / x);
}
def code(x, y, z): return (x * (math.log(x) + -1.0)) + ((0.083333333333333 + (z * ((0.0007936500793651 * z) - 0.0027777777777778))) / x)
function code(x, y, z) return Float64(Float64(x * Float64(log(x) + -1.0)) + Float64(Float64(0.083333333333333 + Float64(z * Float64(Float64(0.0007936500793651 * z) - 0.0027777777777778))) / x)) end
function tmp = code(x, y, z) tmp = (x * (log(x) + -1.0)) + ((0.083333333333333 + (z * ((0.0007936500793651 * z) - 0.0027777777777778))) / x); end
code[x_, y_, z_] := N[(N[(x * N[(N[Log[x], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision] + N[(N[(0.083333333333333 + N[(z * N[(N[(0.0007936500793651 * z), $MachinePrecision] - 0.0027777777777778), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(\log x + -1\right) + \frac{0.083333333333333 + z \cdot \left(0.0007936500793651 \cdot z - 0.0027777777777778\right)}{x}
\end{array}
Initial program 95.7%
Taylor expanded in x around 0 95.7%
sub-neg95.7%
metadata-eval95.7%
distribute-rgt-in95.7%
*-commutative95.7%
neg-mul-195.7%
associate-+l+95.7%
+-commutative95.7%
distribute-rgt-in95.7%
associate-+r+95.7%
sub-neg95.7%
+-commutative95.7%
fma-define95.7%
Simplified95.7%
Taylor expanded in x around inf 94.4%
sub-neg94.4%
mul-1-neg94.4%
log-rec94.4%
remove-double-neg94.4%
metadata-eval94.4%
Simplified94.4%
Taylor expanded in y around 0 79.7%
Final simplification79.7%
(FPCore (x y z) :precision binary64 (if (<= x 12.0) (/ 0.083333333333333 x) (* x (+ (log x) -1.0))))
double code(double x, double y, double z) {
double tmp;
if (x <= 12.0) {
tmp = 0.083333333333333 / 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 <= 12.0d0) then
tmp = 0.083333333333333d0 / 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 <= 12.0) {
tmp = 0.083333333333333 / x;
} else {
tmp = x * (Math.log(x) + -1.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= 12.0: tmp = 0.083333333333333 / x else: tmp = x * (math.log(x) + -1.0) return tmp
function code(x, y, z) tmp = 0.0 if (x <= 12.0) tmp = Float64(0.083333333333333 / 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 <= 12.0) tmp = 0.083333333333333 / x; else tmp = x * (log(x) + -1.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, 12.0], N[(0.083333333333333 / x), $MachinePrecision], N[(x * N[(N[Log[x], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 12:\\
\;\;\;\;\frac{0.083333333333333}{x}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log x + -1\right)\\
\end{array}
\end{array}
if x < 12Initial program 99.7%
Taylor expanded in z around 0 46.6%
Taylor expanded in x around inf 44.8%
sub-neg44.8%
mul-1-neg44.8%
log-rec44.8%
remove-double-neg44.8%
metadata-eval44.8%
+-commutative44.8%
Simplified44.8%
Taylor expanded in x around 0 44.9%
if 12 < x Initial program 91.0%
Taylor expanded in z around 0 69.4%
Taylor expanded in x around inf 68.5%
sub-neg68.5%
mul-1-neg68.5%
log-rec68.5%
remove-double-neg68.5%
metadata-eval68.5%
+-commutative68.5%
Simplified68.5%
Taylor expanded in x around inf 68.5%
associate--l+68.5%
mul-1-neg68.5%
log-rec68.5%
remove-double-neg68.5%
sub-neg68.5%
unpow268.5%
sqr-neg68.5%
associate-*r/68.5%
metadata-eval68.5%
sqr-neg68.5%
unpow268.5%
metadata-eval68.5%
Simplified68.5%
Taylor expanded in x around inf 68.5%
sub-neg68.5%
mul-1-neg68.5%
log-rec68.5%
remove-double-neg68.5%
metadata-eval68.5%
Simplified68.5%
Final simplification55.8%
(FPCore (x y z) :precision binary64 (/ 0.083333333333333 x))
double code(double x, double y, double z) {
return 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.083333333333333d0 / x
end function
public static double code(double x, double y, double z) {
return 0.083333333333333 / x;
}
def code(x, y, z): return 0.083333333333333 / x
function code(x, y, z) return Float64(0.083333333333333 / x) end
function tmp = code(x, y, z) tmp = 0.083333333333333 / x; end
code[x_, y_, z_] := N[(0.083333333333333 / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{0.083333333333333}{x}
\end{array}
Initial program 95.7%
Taylor expanded in z around 0 57.1%
Taylor expanded in x around inf 55.8%
sub-neg55.8%
mul-1-neg55.8%
log-rec55.8%
remove-double-neg55.8%
metadata-eval55.8%
+-commutative55.8%
Simplified55.8%
Taylor expanded in x around 0 25.6%
Final simplification25.6%
(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 2024067
(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)))