Average Error: 31.8 → 0.2
Time: 11.9s
Precision: binary64
\[\frac{x - \sin x}{x - \tan x} \]
\[\begin{array}{l} t_0 := x - \tan x\\ \mathbf{if}\;x \leq -2.646218411575844:\\ \;\;\;\;\mathsf{fma}\left(-1, \frac{\sin x}{x}, \frac{\tan x}{x} + 1\right)\\ \mathbf{elif}\;x \leq 0.02855440944818922:\\ \;\;\;\;\mathsf{fma}\left(0.225, x \cdot x, \mathsf{fma}\left({x}^{4}, -0.009642857142857142, -0.5\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{t_0} - \frac{\sin x}{t_0}\\ \end{array} \]
(FPCore (x) :precision binary64 (/ (- x (sin x)) (- x (tan x))))
(FPCore (x)
 :precision binary64
 (let* ((t_0 (- x (tan x))))
   (if (<= x -2.646218411575844)
     (fma -1.0 (/ (sin x) x) (+ (/ (tan x) x) 1.0))
     (if (<= x 0.02855440944818922)
       (fma 0.225 (* x x) (fma (pow x 4.0) -0.009642857142857142 -0.5))
       (- (/ x t_0) (/ (sin x) t_0))))))
double code(double x) {
	return (x - sin(x)) / (x - tan(x));
}
double code(double x) {
	double t_0 = x - tan(x);
	double tmp;
	if (x <= -2.646218411575844) {
		tmp = fma(-1.0, (sin(x) / x), ((tan(x) / x) + 1.0));
	} else if (x <= 0.02855440944818922) {
		tmp = fma(0.225, (x * x), fma(pow(x, 4.0), -0.009642857142857142, -0.5));
	} else {
		tmp = (x / t_0) - (sin(x) / t_0);
	}
	return tmp;
}
function code(x)
	return Float64(Float64(x - sin(x)) / Float64(x - tan(x)))
end
function code(x)
	t_0 = Float64(x - tan(x))
	tmp = 0.0
	if (x <= -2.646218411575844)
		tmp = fma(-1.0, Float64(sin(x) / x), Float64(Float64(tan(x) / x) + 1.0));
	elseif (x <= 0.02855440944818922)
		tmp = fma(0.225, Float64(x * x), fma((x ^ 4.0), -0.009642857142857142, -0.5));
	else
		tmp = Float64(Float64(x / t_0) - Float64(sin(x) / t_0));
	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[(x - N[Tan[x], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -2.646218411575844], N[(-1.0 * N[(N[Sin[x], $MachinePrecision] / x), $MachinePrecision] + N[(N[(N[Tan[x], $MachinePrecision] / x), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.02855440944818922], N[(0.225 * N[(x * x), $MachinePrecision] + N[(N[Power[x, 4.0], $MachinePrecision] * -0.009642857142857142 + -0.5), $MachinePrecision]), $MachinePrecision], N[(N[(x / t$95$0), $MachinePrecision] - N[(N[Sin[x], $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]]]]
\frac{x - \sin x}{x - \tan x}
\begin{array}{l}
t_0 := x - \tan x\\
\mathbf{if}\;x \leq -2.646218411575844:\\
\;\;\;\;\mathsf{fma}\left(-1, \frac{\sin x}{x}, \frac{\tan x}{x} + 1\right)\\

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

\mathbf{else}:\\
\;\;\;\;\frac{x}{t_0} - \frac{\sin x}{t_0}\\


\end{array}

Error

Bits error versus x

Derivation

  1. Split input into 3 regimes
  2. if x < -2.6462184115758438

    1. Initial program 0.0

      \[\frac{x - \sin x}{x - \tan x} \]
    2. Taylor expanded in x around inf 0.7

      \[\leadsto \color{blue}{\left(\frac{\sin x}{\cos x \cdot x} + 1\right) - \frac{\sin x}{x}} \]
    3. Applied egg-rr0.7

      \[\leadsto \color{blue}{\mathsf{fma}\left(-1, \frac{\sin x}{x}, \frac{\tan x}{x} + 1\right)} \]

    if -2.6462184115758438 < x < 0.0285544094481892212

    1. Initial program 63.2

      \[\frac{x - \sin x}{x - \tan x} \]
    2. Applied egg-rr63.2

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(0.225, x \cdot x, \mathsf{fma}\left({x}^{4}, -0.009642857142857142, -0.5\right)\right)} \]

    if 0.0285544094481892212 < x

    1. Initial program 0.1

      \[\frac{x - \sin x}{x - \tan x} \]
    2. Applied egg-rr0.1

      \[\leadsto \color{blue}{\frac{x}{x - \tan x} - \frac{\sin x}{x - \tan x}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.646218411575844:\\ \;\;\;\;\mathsf{fma}\left(-1, \frac{\sin x}{x}, \frac{\tan x}{x} + 1\right)\\ \mathbf{elif}\;x \leq 0.02855440944818922:\\ \;\;\;\;\mathsf{fma}\left(0.225, x \cdot x, \mathsf{fma}\left({x}^{4}, -0.009642857142857142, -0.5\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{x - \tan x} - \frac{\sin x}{x - \tan x}\\ \end{array} \]

Reproduce

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