| Alternative 1 | |
|---|---|
| Accuracy | 52.6% |
| Cost | 320 |
\[x \cdot \left(0.16666666666666666 \cdot x\right)
\]

(FPCore (x) :precision binary64 (log (/ (sinh x) x)))
(FPCore (x) :precision binary64 (* x (* 0.16666666666666666 x)))
double code(double x) {
return log((sinh(x) / x));
}
double code(double x) {
return x * (0.16666666666666666 * x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = log((sinh(x) / x))
end function
real(8) function code(x)
real(8), intent (in) :: x
code = x * (0.16666666666666666d0 * x)
end function
public static double code(double x) {
return Math.log((Math.sinh(x) / x));
}
public static double code(double x) {
return x * (0.16666666666666666 * x);
}
def code(x): return math.log((math.sinh(x) / x))
def code(x): return x * (0.16666666666666666 * x)
function code(x) return log(Float64(sinh(x) / x)) end
function code(x) return Float64(x * Float64(0.16666666666666666 * x)) end
function tmp = code(x) tmp = log((sinh(x) / x)); end
function tmp = code(x) tmp = x * (0.16666666666666666 * x); end
code[x_] := N[Log[N[(N[Sinh[x], $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision]
code[x_] := N[(x * N[(0.16666666666666666 * x), $MachinePrecision]), $MachinePrecision]
\log \left(\frac{\sinh x}{x}\right)
x \cdot \left(0.16666666666666666 \cdot x\right)
Herbie found 3 alternatives:
| Alternative | Accuracy | Speedup |
|---|
Results
| Original | 30.0% |
|---|---|
| Target | 52.6% |
| Herbie | 52.6% |
Initial program 30.2%
Taylor expanded in x around 0 55.9%
Simplified55.9%
[Start]55.9% | \[ 0.16666666666666666 \cdot {x}^{2}
\] |
|---|---|
unpow2 [=>]55.9% | \[ 0.16666666666666666 \cdot \color{blue}{\left(x \cdot x\right)}
\] |
Applied egg-rr55.9%
[Start]55.9% | \[ 0.16666666666666666 \cdot \left(x \cdot x\right)
\] |
|---|---|
expm1-log1p-u [=>]55.9% | \[ \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(0.16666666666666666 \cdot \left(x \cdot x\right)\right)\right)}
\] |
Applied egg-rr55.9%
[Start]55.9% | \[ \mathsf{expm1}\left(\mathsf{log1p}\left(0.16666666666666666 \cdot \left(x \cdot x\right)\right)\right)
\] |
|---|---|
expm1-log1p-u [<=]55.9% | \[ \color{blue}{0.16666666666666666 \cdot \left(x \cdot x\right)}
\] |
associate-*r* [=>]55.9% | \[ \color{blue}{\left(0.16666666666666666 \cdot x\right) \cdot x}
\] |
Final simplification55.9%
| Alternative 1 | |
|---|---|
| Accuracy | 52.6% |
| Cost | 320 |
| Alternative 2 | |
|---|---|
| Accuracy | 52.6% |
| Cost | 320 |
| Alternative 3 | |
|---|---|
| Accuracy | 27.3% |
| Cost | 64 |
herbie shell --seed 2023271
(FPCore (x)
:name "bug500, discussion (missed optimization)"
:precision binary64
:herbie-target
(if (< (fabs x) 0.085) (* (* x x) (fma (fma (fma -2.6455026455026456e-5 (* x x) 0.0003527336860670194) (* x x) -0.005555555555555556) (* x x) 0.16666666666666666)) (log (/ (sinh x) x)))
(log (/ (sinh x) x)))