Average Error: 31.4 → 0.0
Time: 16.6s
Precision: binary64
\[\frac{x - \sin x}{x - \tan x} \]
\[\begin{array}{l} t_0 := \sqrt[3]{\tan x}\\ t_1 := \frac{\sin x - x}{\mathsf{fma}\left({t_0}^{2}, t_0, -x\right)}\\ \mathbf{if}\;x \leq -0.08068580892332364:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 0.018354480817908324:\\ \;\;\;\;\mathsf{fma}\left(x, x \cdot 0.225, \mathsf{fma}\left(-0.009642857142857142, {x}^{4}, \mathsf{fma}\left(0.00024107142857142857, {x}^{6}, -0.5\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
(FPCore (x) :precision binary64 (/ (- x (sin x)) (- x (tan x))))
(FPCore (x)
 :precision binary64
 (let* ((t_0 (cbrt (tan x)))
        (t_1 (/ (- (sin x) x) (fma (pow t_0 2.0) t_0 (- x)))))
   (if (<= x -0.08068580892332364)
     t_1
     (if (<= x 0.018354480817908324)
       (fma
        x
        (* x 0.225)
        (fma
         -0.009642857142857142
         (pow x 4.0)
         (fma 0.00024107142857142857 (pow x 6.0) -0.5)))
       t_1))))
double code(double x) {
	return (x - sin(x)) / (x - tan(x));
}
double code(double x) {
	double t_0 = cbrt(tan(x));
	double t_1 = (sin(x) - x) / fma(pow(t_0, 2.0), t_0, -x);
	double tmp;
	if (x <= -0.08068580892332364) {
		tmp = t_1;
	} else if (x <= 0.018354480817908324) {
		tmp = fma(x, (x * 0.225), fma(-0.009642857142857142, pow(x, 4.0), fma(0.00024107142857142857, pow(x, 6.0), -0.5)));
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(x)
	return Float64(Float64(x - sin(x)) / Float64(x - tan(x)))
end
function code(x)
	t_0 = cbrt(tan(x))
	t_1 = Float64(Float64(sin(x) - x) / fma((t_0 ^ 2.0), t_0, Float64(-x)))
	tmp = 0.0
	if (x <= -0.08068580892332364)
		tmp = t_1;
	elseif (x <= 0.018354480817908324)
		tmp = fma(x, Float64(x * 0.225), fma(-0.009642857142857142, (x ^ 4.0), fma(0.00024107142857142857, (x ^ 6.0), -0.5)));
	else
		tmp = t_1;
	end
	return tmp
end
code[x_] := N[(N[(x - N[Sin[x], $MachinePrecision]), $MachinePrecision] / N[(x - N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_] := Block[{t$95$0 = N[Power[N[Tan[x], $MachinePrecision], 1/3], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Sin[x], $MachinePrecision] - x), $MachinePrecision] / N[(N[Power[t$95$0, 2.0], $MachinePrecision] * t$95$0 + (-x)), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -0.08068580892332364], t$95$1, If[LessEqual[x, 0.018354480817908324], N[(x * N[(x * 0.225), $MachinePrecision] + N[(-0.009642857142857142 * N[Power[x, 4.0], $MachinePrecision] + N[(0.00024107142857142857 * N[Power[x, 6.0], $MachinePrecision] + -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\frac{x - \sin x}{x - \tan x}
\begin{array}{l}
t_0 := \sqrt[3]{\tan x}\\
t_1 := \frac{\sin x - x}{\mathsf{fma}\left({t_0}^{2}, t_0, -x\right)}\\
\mathbf{if}\;x \leq -0.08068580892332364:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq 0.018354480817908324:\\
\;\;\;\;\mathsf{fma}\left(x, x \cdot 0.225, \mathsf{fma}\left(-0.009642857142857142, {x}^{4}, \mathsf{fma}\left(0.00024107142857142857, {x}^{6}, -0.5\right)\right)\right)\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}

Error

Derivation

  1. Split input into 2 regimes
  2. if x < -0.080685808923323638 or 0.018354480817908324 < x

    1. Initial program 0.1

      \[\frac{x - \sin x}{x - \tan x} \]
    2. Simplified0.1

      \[\leadsto \color{blue}{\frac{\sin x - x}{\tan x - x}} \]
    3. Applied egg-rr0.1

      \[\leadsto \frac{\sin x - x}{\color{blue}{\mathsf{fma}\left({\left(\sqrt[3]{\tan x}\right)}^{2}, \sqrt[3]{\tan x}, -x\right)}} \]

    if -0.080685808923323638 < x < 0.018354480817908324

    1. Initial program 63.0

      \[\frac{x - \sin x}{x - \tan x} \]
    2. Simplified63.0

      \[\leadsto \color{blue}{\frac{\sin x - x}{\tan x - x}} \]
    3. Taylor expanded in x around 0 0.0

      \[\leadsto \color{blue}{\left(0.225 \cdot {x}^{2} + \left(-0.009642857142857142 \cdot {x}^{4} + 0.00024107142857142857 \cdot {x}^{6}\right)\right) - 0.5} \]
    4. Simplified0.0

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, x \cdot 0.225, \mathsf{fma}\left(-0.009642857142857142, {x}^{4}, \mathsf{fma}\left(0.00024107142857142857, {x}^{6}, -0.5\right)\right)\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -0.08068580892332364:\\ \;\;\;\;\frac{\sin x - x}{\mathsf{fma}\left({\left(\sqrt[3]{\tan x}\right)}^{2}, \sqrt[3]{\tan x}, -x\right)}\\ \mathbf{elif}\;x \leq 0.018354480817908324:\\ \;\;\;\;\mathsf{fma}\left(x, x \cdot 0.225, \mathsf{fma}\left(-0.009642857142857142, {x}^{4}, \mathsf{fma}\left(0.00024107142857142857, {x}^{6}, -0.5\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\sin x - x}{\mathsf{fma}\left({\left(\sqrt[3]{\tan x}\right)}^{2}, \sqrt[3]{\tan x}, -x\right)}\\ \end{array} \]

Reproduce

herbie shell --seed 2022210 
(FPCore (x)
  :name "sintan (problem 3.4.5)"
  :precision binary64
  (/ (- x (sin x)) (- x (tan x))))