Average Error: 31.5 → 0.0
Time: 16.6s
Precision: binary64
\[\frac{x - \sin x}{x - \tan x} \]
\[\begin{array}{l} t_0 := \frac{x - \sin x}{x - \tan x}\\ \mathbf{if}\;x \leq -0.03251857343197739:\\ \;\;\;\;\sqrt[3]{{t_0}^{3}}\\ \mathbf{elif}\;x \leq 0.0294829394400758:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\mathsf{fma}\left(0.225, x \cdot x, \mathsf{fma}\left({x}^{4}, -0.009642857142857142, -0.5\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
\frac{x - \sin x}{x - \tan x}
\begin{array}{l}
t_0 := \frac{x - \sin x}{x - \tan x}\\
\mathbf{if}\;x \leq -0.03251857343197739:\\
\;\;\;\;\sqrt[3]{{t_0}^{3}}\\

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

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}
(FPCore (x) :precision binary64 (/ (- x (sin x)) (- x (tan x))))
(FPCore (x)
 :precision binary64
 (let* ((t_0 (/ (- x (sin x)) (- x (tan x)))))
   (if (<= x -0.03251857343197739)
     (cbrt (pow t_0 3.0))
     (if (<= x 0.0294829394400758)
       (log1p
        (expm1
         (fma 0.225 (* x x) (fma (pow x 4.0) -0.009642857142857142 -0.5))))
       t_0))))
double code(double x) {
	return (x - sin(x)) / (x - tan(x));
}
double code(double x) {
	double t_0 = (x - sin(x)) / (x - tan(x));
	double tmp;
	if (x <= -0.03251857343197739) {
		tmp = cbrt(pow(t_0, 3.0));
	} else if (x <= 0.0294829394400758) {
		tmp = log1p(expm1(fma(0.225, (x * x), fma(pow(x, 4.0), -0.009642857142857142, -0.5))));
	} else {
		tmp = t_0;
	}
	return tmp;
}

Error

Bits error versus x

Derivation

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

    1. Initial program 0.1

      \[\frac{x - \sin x}{x - \tan x} \]
    2. Applied add-cbrt-cube_binary640.1

      \[\leadsto \color{blue}{\sqrt[3]{\left(\frac{x - \sin x}{x - \tan x} \cdot \frac{x - \sin x}{x - \tan x}\right) \cdot \frac{x - \sin x}{x - \tan x}}} \]
    3. Simplified0.1

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

    if -0.032518573431977393 < x < 0.0294829394400757984

    1. Initial program 63.3

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

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

      \[\leadsto \color{blue}{0.225 \cdot \left(x \cdot x\right) - \mathsf{fma}\left(0.009642857142857142, {x}^{4}, 0.5\right)} \]
    4. Applied log1p-expm1-u_binary640.0

      \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(0.225 \cdot \left(x \cdot x\right) - \mathsf{fma}\left(0.009642857142857142, {x}^{4}, 0.5\right)\right)\right)} \]
    5. Simplified0.0

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

    if 0.0294829394400757984 < x

    1. Initial program 0.0

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

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

Reproduce

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