
(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 4 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 (fma (* x 0.3333333333333333) (log x) (* (log (cbrt x)) (* x 2.0))))
double code(double x) {
return fma((x * 0.3333333333333333), log(x), (log(cbrt(x)) * (x * 2.0)));
}
function code(x) return fma(Float64(x * 0.3333333333333333), log(x), Float64(log(cbrt(x)) * Float64(x * 2.0))) end
code[x_] := N[(N[(x * 0.3333333333333333), $MachinePrecision] * N[Log[x], $MachinePrecision] + N[(N[Log[N[Power[x, 1/3], $MachinePrecision]], $MachinePrecision] * N[(x * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(x \cdot 0.3333333333333333, \log x, \log \left(\sqrt[3]{x}\right) \cdot \left(x \cdot 2\right)\right)
\end{array}
Initial program 99.6%
add-sqr-sqrt99.6%
pow299.6%
log-pow99.6%
Applied egg-rr99.6%
add-cube-cbrt99.6%
pow399.6%
log-pow99.4%
pow199.4%
metadata-eval99.4%
pow-pow99.4%
pow299.4%
cbrt-prod99.4%
add-sqr-sqrt99.4%
pow1/399.2%
pow-pow99.2%
metadata-eval99.2%
Applied egg-rr99.2%
Taylor expanded in x around 0 99.3%
associate-*r*99.3%
*-commutative99.3%
*-lft-identity99.3%
exp-to-pow99.2%
*-commutative99.2%
rem-log-exp99.2%
associate-*l*99.2%
Simplified99.2%
associate-*r*99.6%
metadata-eval99.6%
*-un-lft-identity99.6%
add-cube-cbrt99.6%
pow299.6%
exp-to-pow99.6%
*-commutative99.6%
pow1/399.5%
pow-to-exp99.5%
*-commutative99.5%
sum-log99.5%
add-log-exp99.5%
add-log-exp99.5%
+-commutative99.5%
distribute-rgt-out99.6%
*-commutative99.6%
associate-*r*99.6%
fma-define99.6%
Applied egg-rr99.6%
Final simplification99.6%
(FPCore (x) :precision binary64 (* x (* 2.0 (log (sqrt x)))))
double code(double x) {
return x * (2.0 * log(sqrt(x)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = x * (2.0d0 * log(sqrt(x)))
end function
public static double code(double x) {
return x * (2.0 * Math.log(Math.sqrt(x)));
}
def code(x): return x * (2.0 * math.log(math.sqrt(x)))
function code(x) return Float64(x * Float64(2.0 * log(sqrt(x)))) end
function tmp = code(x) tmp = x * (2.0 * log(sqrt(x))); end
code[x_] := N[(x * N[(2.0 * N[Log[N[Sqrt[x], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(2 \cdot \log \left(\sqrt{x}\right)\right)
\end{array}
Initial program 99.6%
add-sqr-sqrt99.6%
pow299.6%
log-pow99.6%
Applied egg-rr99.6%
(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}
Initial program 99.6%
(FPCore (x) :precision binary64 0.0)
double code(double x) {
return 0.0;
}
real(8) function code(x)
real(8), intent (in) :: x
code = 0.0d0
end function
public static double code(double x) {
return 0.0;
}
def code(x): return 0.0
function code(x) return 0.0 end
function tmp = code(x) tmp = 0.0; end
code[x_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 99.6%
add-sqr-sqrt99.6%
pow299.6%
log-pow99.6%
Applied egg-rr99.6%
log-pow99.6%
pow299.6%
add-sqr-sqrt99.6%
add-sqr-sqrt47.6%
sqrt-unprod49.7%
sqr-neg49.7%
log-rec49.7%
log-rec49.7%
sqrt-unprod1.9%
add-sqr-sqrt2.2%
add-sqr-sqrt2.2%
associate-/r*2.2%
Applied egg-rr3.8%
+-inverses3.8%
Simplified3.8%
Taylor expanded in x around 0 3.8%
herbie shell --seed 2024165
(FPCore (x)
:name "Statistics.Distribution.Binomial:directEntropy from math-functions-0.1.5.2"
:precision binary64
(* x (log x)))