Average Error: 30.5 → 0.2
Time: 11.3s
Precision: binary64
\[\frac{x - \sin x}{x - \tan x} \]
\[\begin{array}{l} t_0 := x - \tan x\\ t_1 := \frac{x}{t_0} - \frac{\sin x}{t_0}\\ \mathbf{if}\;x \leq -12.952388770360225:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 2.0288157605164016 \cdot 10^{-8}:\\ \;\;\;\;\left(0.225 \cdot {x}^{2} + \log \left(e^{\mathsf{fma}\left(-0.009642857142857142, {x}^{4}, 0.00024107142857142857 \cdot {x}^{6}\right)}\right)\right) + -0.5\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
(FPCore (x) :precision binary64 (/ (- x (sin x)) (- x (tan x))))
(FPCore (x)
 :precision binary64
 (let* ((t_0 (- x (tan x))) (t_1 (- (/ x t_0) (/ (sin x) t_0))))
   (if (<= x -12.952388770360225)
     t_1
     (if (<= x 2.0288157605164016e-8)
       (+
        (+
         (* 0.225 (pow x 2.0))
         (log
          (exp
           (fma
            -0.009642857142857142
            (pow x 4.0)
            (* 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 = x - tan(x);
	double t_1 = (x / t_0) - (sin(x) / t_0);
	double tmp;
	if (x <= -12.952388770360225) {
		tmp = t_1;
	} else if (x <= 2.0288157605164016e-8) {
		tmp = ((0.225 * pow(x, 2.0)) + log(exp(fma(-0.009642857142857142, pow(x, 4.0), (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 = Float64(x - tan(x))
	t_1 = Float64(Float64(x / t_0) - Float64(sin(x) / t_0))
	tmp = 0.0
	if (x <= -12.952388770360225)
		tmp = t_1;
	elseif (x <= 2.0288157605164016e-8)
		tmp = Float64(Float64(Float64(0.225 * (x ^ 2.0)) + log(exp(fma(-0.009642857142857142, (x ^ 4.0), Float64(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[(x - N[Tan[x], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x / t$95$0), $MachinePrecision] - N[(N[Sin[x], $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -12.952388770360225], t$95$1, If[LessEqual[x, 2.0288157605164016e-8], N[(N[(N[(0.225 * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision] + N[Log[N[Exp[N[(-0.009642857142857142 * N[Power[x, 4.0], $MachinePrecision] + N[(0.00024107142857142857 * N[Power[x, 6.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + -0.5), $MachinePrecision], t$95$1]]]]
\frac{x - \sin x}{x - \tan x}
\begin{array}{l}
t_0 := x - \tan x\\
t_1 := \frac{x}{t_0} - \frac{\sin x}{t_0}\\
\mathbf{if}\;x \leq -12.952388770360225:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq 2.0288157605164016 \cdot 10^{-8}:\\
\;\;\;\;\left(0.225 \cdot {x}^{2} + \log \left(e^{\mathsf{fma}\left(-0.009642857142857142, {x}^{4}, 0.00024107142857142857 \cdot {x}^{6}\right)}\right)\right) + -0.5\\

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


\end{array}

Error

Derivation

  1. Split input into 2 regimes
  2. if x < -12.9523887703602245 or 2.0288157605164016e-8 < x

    1. Initial program 0.3

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

      \[\leadsto \color{blue}{\frac{x}{x - \tan x} - \frac{\sin x}{x - \tan x}} \]

    if -12.9523887703602245 < x < 2.0288157605164016e-8

    1. Initial program 63.3

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

      \[\leadsto \color{blue}{\left(0.225 \cdot {x}^{2} + \left(-0.009642857142857142 \cdot {x}^{4} + 0.00024107142857142857 \cdot {x}^{6}\right)\right) - 0.5} \]
    3. Applied egg-rr0.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -12.952388770360225:\\ \;\;\;\;\frac{x}{x - \tan x} - \frac{\sin x}{x - \tan x}\\ \mathbf{elif}\;x \leq 2.0288157605164016 \cdot 10^{-8}:\\ \;\;\;\;\left(0.225 \cdot {x}^{2} + \log \left(e^{\mathsf{fma}\left(-0.009642857142857142, {x}^{4}, 0.00024107142857142857 \cdot {x}^{6}\right)}\right)\right) + -0.5\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{x - \tan x} - \frac{\sin x}{x - \tan x}\\ \end{array} \]

Reproduce

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