(FPCore (x) :precision binary64 (/ (- x (sin x)) (tan x)))
(FPCore (x)
:precision binary64
(let* ((t_0 (* (* 0.16666666666666666 x) x))
(t_1
(fma
-0.00023644179894179894
(pow x 8.0)
(fma
-0.0007275132275132275
(pow x 6.0)
(* (pow x 4.0) -0.06388888888888888)))))
(if (!= t_0 0.0)
(* t_0 (+ 1.0 (/ t_1 t_0)))
(fma 0.16666666666666666 (pow x 2.0) t_1))))double code(double x) {
return (x - sin(x)) / tan(x);
}
double code(double x) {
double t_0 = (0.16666666666666666 * x) * x;
double t_1 = fma(-0.00023644179894179894, pow(x, 8.0), fma(-0.0007275132275132275, pow(x, 6.0), (pow(x, 4.0) * -0.06388888888888888)));
double tmp;
if (t_0 != 0.0) {
tmp = t_0 * (1.0 + (t_1 / t_0));
} else {
tmp = fma(0.16666666666666666, pow(x, 2.0), t_1);
}
return tmp;
}
function code(x) return Float64(Float64(x - sin(x)) / tan(x)) end
function code(x) t_0 = Float64(Float64(0.16666666666666666 * x) * x) t_1 = fma(-0.00023644179894179894, (x ^ 8.0), fma(-0.0007275132275132275, (x ^ 6.0), Float64((x ^ 4.0) * -0.06388888888888888))) tmp = 0.0 if (t_0 != 0.0) tmp = Float64(t_0 * Float64(1.0 + Float64(t_1 / t_0))); else tmp = fma(0.16666666666666666, (x ^ 2.0), t_1); end return tmp end
code[x_] := N[(N[(x - N[Sin[x], $MachinePrecision]), $MachinePrecision] / N[Tan[x], $MachinePrecision]), $MachinePrecision]
code[x_] := Block[{t$95$0 = N[(N[(0.16666666666666666 * x), $MachinePrecision] * x), $MachinePrecision]}, Block[{t$95$1 = N[(-0.00023644179894179894 * N[Power[x, 8.0], $MachinePrecision] + N[(-0.0007275132275132275 * N[Power[x, 6.0], $MachinePrecision] + N[(N[Power[x, 4.0], $MachinePrecision] * -0.06388888888888888), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Unequal[t$95$0, 0.0], N[(t$95$0 * N[(1.0 + N[(t$95$1 / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.16666666666666666 * N[Power[x, 2.0], $MachinePrecision] + t$95$1), $MachinePrecision]]]]
\frac{x - \sin x}{\tan x}
\begin{array}{l}
t_0 := \left(0.16666666666666666 \cdot x\right) \cdot x\\
t_1 := \mathsf{fma}\left(-0.00023644179894179894, {x}^{8}, \mathsf{fma}\left(-0.0007275132275132275, {x}^{6}, {x}^{4} \cdot -0.06388888888888888\right)\right)\\
\mathbf{if}\;t_0 \ne 0:\\
\;\;\;\;t_0 \cdot \left(1 + \frac{t_1}{t_0}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(0.16666666666666666, {x}^{2}, t_1\right)\\
\end{array}
| Original | 47.57% |
|---|---|
| Target | 1.39% |
| Herbie | 0.48% |
Initial program 47.57
Taylor expanded in x around 0 0.51
Simplified0.51
Applied egg-rr0.48
herbie shell --seed 2023136
(FPCore (x)
:name "ENA, Section 1.4, Exercise 4a"
:precision binary64
:pre (and (<= -1.0 x) (<= x 1.0))
:herbie-target
(* 0.16666666666666666 (* x x))
(/ (- x (sin x)) (tan x)))