Average Error: 31.8 → 0.1
Time: 17.3s
Precision: binary64
Cost: 143816
\[\frac{x - \sin x}{x - \tan x} \]
\[\begin{array}{l} t_0 := x - \sin x\\ t_1 := \sqrt[3]{t_0}\\ t_2 := \frac{-1}{t_1}\\ t_3 := \tan x \cdot \sqrt[3]{{t_0}^{-2}}\\ \mathbf{if}\;x \leq -32.497782839238596:\\ \;\;\;\;\frac{1}{\frac{x - \tan x}{t_0}}\\ \mathbf{elif}\;x \leq 0.0008580944808595899:\\ \;\;\;\;\left(x \cdot x\right) \cdot \left(0.225 + x \cdot \left(x \cdot -0.009642857142857142\right)\right) + -0.5\\ \mathbf{else}:\\ \;\;\;\;{\left(\mathsf{fma}\left(1, \frac{x}{t_0}, t_3 \cdot t_2\right) + \mathsf{fma}\left(t_2, t_3, \frac{1}{t_1} \cdot t_3\right)\right)}^{-1}\\ \end{array} \]
(FPCore (x) :precision binary64 (/ (- x (sin x)) (- x (tan x))))
(FPCore (x)
 :precision binary64
 (let* ((t_0 (- x (sin x)))
        (t_1 (cbrt t_0))
        (t_2 (/ -1.0 t_1))
        (t_3 (* (tan x) (cbrt (pow t_0 -2.0)))))
   (if (<= x -32.497782839238596)
     (/ 1.0 (/ (- x (tan x)) t_0))
     (if (<= x 0.0008580944808595899)
       (+ (* (* x x) (+ 0.225 (* x (* x -0.009642857142857142)))) -0.5)
       (pow
        (+ (fma 1.0 (/ x t_0) (* t_3 t_2)) (fma t_2 t_3 (* (/ 1.0 t_1) t_3)))
        -1.0)))))
double code(double x) {
	return (x - sin(x)) / (x - tan(x));
}
double code(double x) {
	double t_0 = x - sin(x);
	double t_1 = cbrt(t_0);
	double t_2 = -1.0 / t_1;
	double t_3 = tan(x) * cbrt(pow(t_0, -2.0));
	double tmp;
	if (x <= -32.497782839238596) {
		tmp = 1.0 / ((x - tan(x)) / t_0);
	} else if (x <= 0.0008580944808595899) {
		tmp = ((x * x) * (0.225 + (x * (x * -0.009642857142857142)))) + -0.5;
	} else {
		tmp = pow((fma(1.0, (x / t_0), (t_3 * t_2)) + fma(t_2, t_3, ((1.0 / t_1) * t_3))), -1.0);
	}
	return tmp;
}
function code(x)
	return Float64(Float64(x - sin(x)) / Float64(x - tan(x)))
end
function code(x)
	t_0 = Float64(x - sin(x))
	t_1 = cbrt(t_0)
	t_2 = Float64(-1.0 / t_1)
	t_3 = Float64(tan(x) * cbrt((t_0 ^ -2.0)))
	tmp = 0.0
	if (x <= -32.497782839238596)
		tmp = Float64(1.0 / Float64(Float64(x - tan(x)) / t_0));
	elseif (x <= 0.0008580944808595899)
		tmp = Float64(Float64(Float64(x * x) * Float64(0.225 + Float64(x * Float64(x * -0.009642857142857142)))) + -0.5);
	else
		tmp = Float64(fma(1.0, Float64(x / t_0), Float64(t_3 * t_2)) + fma(t_2, t_3, Float64(Float64(1.0 / t_1) * t_3))) ^ -1.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[Sin[x], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Power[t$95$0, 1/3], $MachinePrecision]}, Block[{t$95$2 = N[(-1.0 / t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[(N[Tan[x], $MachinePrecision] * N[Power[N[Power[t$95$0, -2.0], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -32.497782839238596], N[(1.0 / N[(N[(x - N[Tan[x], $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.0008580944808595899], N[(N[(N[(x * x), $MachinePrecision] * N[(0.225 + N[(x * N[(x * -0.009642857142857142), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -0.5), $MachinePrecision], N[Power[N[(N[(1.0 * N[(x / t$95$0), $MachinePrecision] + N[(t$95$3 * t$95$2), $MachinePrecision]), $MachinePrecision] + N[(t$95$2 * t$95$3 + N[(N[(1.0 / t$95$1), $MachinePrecision] * t$95$3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision]]]]]]]
\frac{x - \sin x}{x - \tan x}
\begin{array}{l}
t_0 := x - \sin x\\
t_1 := \sqrt[3]{t_0}\\
t_2 := \frac{-1}{t_1}\\
t_3 := \tan x \cdot \sqrt[3]{{t_0}^{-2}}\\
\mathbf{if}\;x \leq -32.497782839238596:\\
\;\;\;\;\frac{1}{\frac{x - \tan x}{t_0}}\\

\mathbf{elif}\;x \leq 0.0008580944808595899:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(0.225 + x \cdot \left(x \cdot -0.009642857142857142\right)\right) + -0.5\\

\mathbf{else}:\\
\;\;\;\;{\left(\mathsf{fma}\left(1, \frac{x}{t_0}, t_3 \cdot t_2\right) + \mathsf{fma}\left(t_2, t_3, \frac{1}{t_1} \cdot t_3\right)\right)}^{-1}\\


\end{array}

Error

Derivation

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

    1. Initial program 0.0

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

      \[\leadsto \color{blue}{{\left(\frac{x - \tan x}{x - \sin x}\right)}^{-1}} \]
    3. Applied egg-rr0.0

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

    if -32.497782839238596 < x < 8.58094480859589886e-4

    1. Initial program 63.1

      \[\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} + -0.009642857142857142 \cdot {x}^{4}\right) - 0.5} \]
    3. Taylor expanded in x around 0 0.1

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

      \[\leadsto \color{blue}{\left(x \cdot x\right) \cdot \mathsf{fma}\left(x, x \cdot -0.009642857142857142, 0.225\right)} - 0.5 \]
    5. Applied egg-rr0.1

      \[\leadsto \left(x \cdot x\right) \cdot \color{blue}{\left(0.225 + x \cdot \left(x \cdot -0.009642857142857142\right)\right)} - 0.5 \]

    if 8.58094480859589886e-4 < x

    1. Initial program 0.1

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

      \[\leadsto \color{blue}{{\left(\frac{x - \tan x}{x - \sin x}\right)}^{-1}} \]
    3. Applied egg-rr0.2

      \[\leadsto {\color{blue}{\left(\mathsf{fma}\left(x, \frac{1}{x - \sin x}, -\frac{\tan x}{x - \sin x}\right)\right)}}^{-1} \]
    4. Applied egg-rr0.1

      \[\leadsto {\color{blue}{\left(\mathsf{fma}\left(1, \frac{x}{x - \sin x}, -\frac{1}{\sqrt[3]{x - \sin x}} \cdot \left(\tan x \cdot \sqrt[3]{{\left(x - \sin x\right)}^{-2}}\right)\right) + \mathsf{fma}\left(-\frac{1}{\sqrt[3]{x - \sin x}}, \tan x \cdot \sqrt[3]{{\left(x - \sin x\right)}^{-2}}, \frac{1}{\sqrt[3]{x - \sin x}} \cdot \left(\tan x \cdot \sqrt[3]{{\left(x - \sin x\right)}^{-2}}\right)\right)\right)}}^{-1} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.1

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

Alternatives

Alternative 1
Error0.1
Cost45640
\[\begin{array}{l} t_0 := x - \sin x\\ t_1 := \sqrt[3]{\tan x}\\ \mathbf{if}\;x \leq -32.497782839238596:\\ \;\;\;\;\frac{1}{\frac{x - \tan x}{t_0}}\\ \mathbf{elif}\;x \leq 0.0008580944808595899:\\ \;\;\;\;\left(x \cdot x\right) \cdot \left(0.225 + x \cdot \left(x \cdot -0.009642857142857142\right)\right) + -0.5\\ \mathbf{else}:\\ \;\;\;\;\frac{t_0}{\mathsf{fma}\left(-{t_1}^{2}, t_1, x\right)}\\ \end{array} \]
Alternative 2
Error0.1
Cost13512
\[\begin{array}{l} t_0 := \frac{x - \sin x}{x - \tan x}\\ \mathbf{if}\;x \leq -32.497782839238596:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 0.0008580944808595899:\\ \;\;\;\;\left(x \cdot x\right) \cdot \left(0.225 + x \cdot \left(x \cdot -0.009642857142857142\right)\right) + -0.5\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error0.1
Cost13512
\[\begin{array}{l} t_0 := x - \tan x\\ t_1 := x - \sin x\\ \mathbf{if}\;x \leq -32.497782839238596:\\ \;\;\;\;\frac{1}{\frac{t_0}{t_1}}\\ \mathbf{elif}\;x \leq 0.0008580944808595899:\\ \;\;\;\;\left(x \cdot x\right) \cdot \left(0.225 + x \cdot \left(x \cdot -0.009642857142857142\right)\right) + -0.5\\ \mathbf{else}:\\ \;\;\;\;\frac{t_1}{t_0}\\ \end{array} \]
Alternative 4
Error0.6
Cost7624
\[\begin{array}{l} \mathbf{if}\;x \leq -32.497782839238596:\\ \;\;\;\;\frac{x}{x - \tan x}\\ \mathbf{elif}\;x \leq 0.9302757541789467:\\ \;\;\;\;\left(x \cdot x\right) \cdot \left(-1 + \left(1 + \mathsf{fma}\left(x, x \cdot -0.009642857142857142, 0.225\right)\right)\right) + -0.5\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 5
Error0.6
Cost6852
\[\begin{array}{l} \mathbf{if}\;x \leq -32.497782839238596:\\ \;\;\;\;\frac{x}{x - \tan x}\\ \mathbf{elif}\;x \leq 0.9302757541789467:\\ \;\;\;\;\left(x \cdot x\right) \cdot \left(0.225 + x \cdot \left(x \cdot -0.009642857142857142\right)\right) + -0.5\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 6
Error0.6
Cost1096
\[\begin{array}{l} \mathbf{if}\;x \leq -32.497782839238596:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 0.9302757541789467:\\ \;\;\;\;\left(x \cdot x\right) \cdot \left(0.225 + x \cdot \left(x \cdot -0.009642857142857142\right)\right) + -0.5\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 7
Error0.7
Cost712
\[\begin{array}{l} \mathbf{if}\;x \leq -32.497782839238596:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 0.9302757541789467:\\ \;\;\;\;-0.5 + x \cdot \left(x \cdot 0.225\right)\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 8
Error0.8
Cost328
\[\begin{array}{l} \mathbf{if}\;x \leq -32.497782839238596:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 0.9302757541789467:\\ \;\;\;\;-0.5\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 9
Error32.4
Cost64
\[1 \]

Error

Reproduce

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