
(FPCore (x) :precision binary64 (* x (log x)))
double code(double x) {
return x * log(x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = x * log(x)
end function
public static double code(double x) {
return x * Math.log(x);
}
def code(x): return x * math.log(x)
function code(x) return Float64(x * log(x)) end
function tmp = code(x) tmp = x * log(x); end
code[x_] := N[(x * N[Log[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \log x
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 2 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 (* x (log x)))
double code(double x) {
return x * log(x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = x * log(x)
end function
public static double code(double x) {
return x * Math.log(x);
}
def code(x): return x * math.log(x)
function code(x) return Float64(x * log(x)) end
function tmp = code(x) tmp = x * log(x); end
code[x_] := N[(x * N[Log[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \log x
\end{array}
(FPCore (x) :precision binary64 (+ (* x (* 2.0 (log (pow x 0.3333333333333333)))) (* x (log (cbrt x)))))
double code(double x) {
return (x * (2.0 * log(pow(x, 0.3333333333333333)))) + (x * log(cbrt(x)));
}
public static double code(double x) {
return (x * (2.0 * Math.log(Math.pow(x, 0.3333333333333333)))) + (x * Math.log(Math.cbrt(x)));
}
function code(x) return Float64(Float64(x * Float64(2.0 * log((x ^ 0.3333333333333333)))) + Float64(x * log(cbrt(x)))) end
code[x_] := N[(N[(x * N[(2.0 * N[Log[N[Power[x, 0.3333333333333333], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x * N[Log[N[Power[x, 1/3], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(2 \cdot \log \left({x}^{0.3333333333333333}\right)\right) + x \cdot \log \left(\sqrt[3]{x}\right)
\end{array}
(FPCore (x) :precision binary64 (* x (log x)))
double code(double x) {
return x * log(x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = x * log(x)
end function
public static double code(double x) {
return x * Math.log(x);
}
def code(x): return x * math.log(x)
function code(x) return Float64(x * log(x)) end
function tmp = code(x) tmp = x * log(x); end
code[x_] := N[(x * N[Log[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \log x
\end{array}
herbie shell --seed 2023343
(FPCore (x)
:name "Statistics.Distribution.Binomial:directEntropy from math-functions-0.1.5.2"
:precision binary64
(* x (log x)))