| Alternative 1 | |
|---|---|
| Error | 0.3 |
| Cost | 20288 |
\[x \cdot \frac{x \cdot 0.1111111111111111}{\mathsf{fma}\left(x, 0.3333333333333333, {x}^{3} \cdot -0.022222222222222223\right)} + {x}^{5} \cdot -0.0014814814814814814
\]
(FPCore (x) :precision binary64 (- (/ 1.0 x) (/ 1.0 (tan x))))
(FPCore (x)
:precision binary64
(let* ((t_0 (fma x 0.3333333333333333 (* (pow x 3.0) -0.022222222222222223))))
(+
(/ x (/ t_0 (* x 0.1111111111111111)))
(* (pow x 6.0) (/ -0.0004938271604938272 t_0)))))double code(double x) {
return (1.0 / x) - (1.0 / tan(x));
}
double code(double x) {
double t_0 = fma(x, 0.3333333333333333, (pow(x, 3.0) * -0.022222222222222223));
return (x / (t_0 / (x * 0.1111111111111111))) + (pow(x, 6.0) * (-0.0004938271604938272 / t_0));
}
function code(x) return Float64(Float64(1.0 / x) - Float64(1.0 / tan(x))) end
function code(x) t_0 = fma(x, 0.3333333333333333, Float64((x ^ 3.0) * -0.022222222222222223)) return Float64(Float64(x / Float64(t_0 / Float64(x * 0.1111111111111111))) + Float64((x ^ 6.0) * Float64(-0.0004938271604938272 / t_0))) end
code[x_] := N[(N[(1.0 / x), $MachinePrecision] - N[(1.0 / N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_] := Block[{t$95$0 = N[(x * 0.3333333333333333 + N[(N[Power[x, 3.0], $MachinePrecision] * -0.022222222222222223), $MachinePrecision]), $MachinePrecision]}, N[(N[(x / N[(t$95$0 / N[(x * 0.1111111111111111), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Power[x, 6.0], $MachinePrecision] * N[(-0.0004938271604938272 / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\frac{1}{x} - \frac{1}{\tan x}
\begin{array}{l}
t_0 := \mathsf{fma}\left(x, 0.3333333333333333, {x}^{3} \cdot -0.022222222222222223\right)\\
\frac{x}{\frac{t_0}{x \cdot 0.1111111111111111}} + {x}^{6} \cdot \frac{-0.0004938271604938272}{t_0}
\end{array}
| Original | 60.0 |
|---|---|
| Target | 0.1 |
| Herbie | 0.2 |
Initial program 60.0
Taylor expanded in x around 0 0.4
Applied egg-rr29.0
Applied egg-rr29.0
Simplified0.3
Applied egg-rr0.2
Final simplification0.2
| Alternative 1 | |
|---|---|
| Error | 0.3 |
| Cost | 20288 |
| Alternative 2 | |
|---|---|
| Error | 0.4 |
| Cost | 19904 |
| Alternative 3 | |
|---|---|
| Error | 0.4 |
| Cost | 13632 |
| Alternative 4 | |
|---|---|
| Error | 0.6 |
| Cost | 320 |
| Alternative 5 | |
|---|---|
| Error | 0.7 |
| Cost | 192 |
herbie shell --seed 2022335
(FPCore (x)
:name "invcot (example 3.9)"
:precision binary64
:pre (and (< -0.026 x) (< x 0.026))
:herbie-target
(if (< (fabs x) 0.026) (* (/ x 3.0) (+ 1.0 (/ (* x x) 15.0))) (- (/ 1.0 x) (/ 1.0 (tan x))))
(- (/ 1.0 x) (/ 1.0 (tan x))))