sintan (problem 3.4.5)

Percentage Accurate: 50.4% → 99.5%
Time: 19.8s
Alternatives: 8
Speedup: 207.0×

Specification

?
\[\begin{array}{l} \\ \frac{x - \sin x}{x - \tan x} \end{array} \]
(FPCore (x) :precision binary64 (/ (- x (sin x)) (- x (tan x))))
double code(double x) {
	return (x - sin(x)) / (x - tan(x));
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = (x - sin(x)) / (x - tan(x))
end function
public static double code(double x) {
	return (x - Math.sin(x)) / (x - Math.tan(x));
}
def code(x):
	return (x - math.sin(x)) / (x - math.tan(x))
function code(x)
	return Float64(Float64(x - sin(x)) / Float64(x - tan(x)))
end
function tmp = code(x)
	tmp = (x - sin(x)) / (x - tan(x));
end
code[x_] := N[(N[(x - N[Sin[x], $MachinePrecision]), $MachinePrecision] / N[(x - N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{x - \sin x}{x - \tan x}
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 8 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 50.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{x - \sin x}{x - \tan x} \end{array} \]
(FPCore (x) :precision binary64 (/ (- x (sin x)) (- x (tan x))))
double code(double x) {
	return (x - sin(x)) / (x - tan(x));
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = (x - sin(x)) / (x - tan(x))
end function
public static double code(double x) {
	return (x - Math.sin(x)) / (x - Math.tan(x));
}
def code(x):
	return (x - math.sin(x)) / (x - math.tan(x))
function code(x)
	return Float64(Float64(x - sin(x)) / Float64(x - tan(x)))
end
function tmp = code(x)
	tmp = (x - sin(x)) / (x - tan(x));
end
code[x_] := N[(N[(x - N[Sin[x], $MachinePrecision]), $MachinePrecision] / N[(x - N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{x - \sin x}{x - \tan x}
\end{array}

Alternative 1: 99.5% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{x - \sin x}{x - \tan x} \leq 2:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\sin x - x}{\tan x - x}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;-0.5\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= (/ (- x (sin x)) (- x (tan x))) 2.0)
   (log1p (expm1 (/ (- (sin x) x) (- (tan x) x))))
   -0.5))
double code(double x) {
	double tmp;
	if (((x - sin(x)) / (x - tan(x))) <= 2.0) {
		tmp = log1p(expm1(((sin(x) - x) / (tan(x) - x))));
	} else {
		tmp = -0.5;
	}
	return tmp;
}
public static double code(double x) {
	double tmp;
	if (((x - Math.sin(x)) / (x - Math.tan(x))) <= 2.0) {
		tmp = Math.log1p(Math.expm1(((Math.sin(x) - x) / (Math.tan(x) - x))));
	} else {
		tmp = -0.5;
	}
	return tmp;
}
def code(x):
	tmp = 0
	if ((x - math.sin(x)) / (x - math.tan(x))) <= 2.0:
		tmp = math.log1p(math.expm1(((math.sin(x) - x) / (math.tan(x) - x))))
	else:
		tmp = -0.5
	return tmp
function code(x)
	tmp = 0.0
	if (Float64(Float64(x - sin(x)) / Float64(x - tan(x))) <= 2.0)
		tmp = log1p(expm1(Float64(Float64(sin(x) - x) / Float64(tan(x) - x))));
	else
		tmp = -0.5;
	end
	return tmp
end
code[x_] := If[LessEqual[N[(N[(x - N[Sin[x], $MachinePrecision]), $MachinePrecision] / N[(x - N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], N[Log[1 + N[(Exp[N[(N[(N[Sin[x], $MachinePrecision] - x), $MachinePrecision] / N[(N[Tan[x], $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision], -0.5]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\frac{x - \sin x}{x - \tan x} \leq 2:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\sin x - x}{\tan x - x}\right)\right)\\

\mathbf{else}:\\
\;\;\;\;-0.5\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (-.f64 x (sin.f64 x)) (-.f64 x (tan.f64 x))) < 2

    1. Initial program 99.4%

      \[\frac{x - \sin x}{x - \tan x} \]
    2. Step-by-step derivation
      1. sub-neg99.4%

        \[\leadsto \frac{\color{blue}{x + \left(-\sin x\right)}}{x - \tan x} \]
      2. +-commutative99.4%

        \[\leadsto \frac{\color{blue}{\left(-\sin x\right) + x}}{x - \tan x} \]
      3. neg-sub099.4%

        \[\leadsto \frac{\color{blue}{\left(0 - \sin x\right)} + x}{x - \tan x} \]
      4. associate-+l-99.4%

        \[\leadsto \frac{\color{blue}{0 - \left(\sin x - x\right)}}{x - \tan x} \]
      5. sub0-neg99.4%

        \[\leadsto \frac{\color{blue}{-\left(\sin x - x\right)}}{x - \tan x} \]
      6. neg-mul-199.4%

        \[\leadsto \frac{\color{blue}{-1 \cdot \left(\sin x - x\right)}}{x - \tan x} \]
      7. sub-neg99.4%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{x + \left(-\tan x\right)}} \]
      8. +-commutative99.4%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{\left(-\tan x\right) + x}} \]
      9. neg-sub099.4%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{\left(0 - \tan x\right)} + x} \]
      10. associate-+l-99.4%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{0 - \left(\tan x - x\right)}} \]
      11. sub0-neg99.4%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{-\left(\tan x - x\right)}} \]
      12. neg-mul-199.4%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{-1 \cdot \left(\tan x - x\right)}} \]
      13. times-frac99.4%

        \[\leadsto \color{blue}{\frac{-1}{-1} \cdot \frac{\sin x - x}{\tan x - x}} \]
      14. metadata-eval99.4%

        \[\leadsto \color{blue}{1} \cdot \frac{\sin x - x}{\tan x - x} \]
      15. *-lft-identity99.4%

        \[\leadsto \color{blue}{\frac{\sin x - x}{\tan x - x}} \]
    3. Simplified99.4%

      \[\leadsto \color{blue}{\frac{\sin x - x}{\tan x - x}} \]
    4. Step-by-step derivation
      1. log1p-expm1-u99.4%

        \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\sin x - x}{\tan x - x}\right)\right)} \]
    5. Applied egg-rr99.4%

      \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\sin x - x}{\tan x - x}\right)\right)} \]

    if 2 < (/.f64 (-.f64 x (sin.f64 x)) (-.f64 x (tan.f64 x)))

    1. Initial program 0.0%

      \[\frac{x - \sin x}{x - \tan x} \]
    2. Step-by-step derivation
      1. sub-neg0.0%

        \[\leadsto \frac{\color{blue}{x + \left(-\sin x\right)}}{x - \tan x} \]
      2. +-commutative0.0%

        \[\leadsto \frac{\color{blue}{\left(-\sin x\right) + x}}{x - \tan x} \]
      3. neg-sub00.0%

        \[\leadsto \frac{\color{blue}{\left(0 - \sin x\right)} + x}{x - \tan x} \]
      4. associate-+l-0.0%

        \[\leadsto \frac{\color{blue}{0 - \left(\sin x - x\right)}}{x - \tan x} \]
      5. sub0-neg0.0%

        \[\leadsto \frac{\color{blue}{-\left(\sin x - x\right)}}{x - \tan x} \]
      6. neg-mul-10.0%

        \[\leadsto \frac{\color{blue}{-1 \cdot \left(\sin x - x\right)}}{x - \tan x} \]
      7. sub-neg0.0%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{x + \left(-\tan x\right)}} \]
      8. +-commutative0.0%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{\left(-\tan x\right) + x}} \]
      9. neg-sub00.0%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{\left(0 - \tan x\right)} + x} \]
      10. associate-+l-0.0%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{0 - \left(\tan x - x\right)}} \]
      11. sub0-neg0.0%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{-\left(\tan x - x\right)}} \]
      12. neg-mul-10.0%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{-1 \cdot \left(\tan x - x\right)}} \]
      13. times-frac0.0%

        \[\leadsto \color{blue}{\frac{-1}{-1} \cdot \frac{\sin x - x}{\tan x - x}} \]
      14. metadata-eval0.0%

        \[\leadsto \color{blue}{1} \cdot \frac{\sin x - x}{\tan x - x} \]
      15. *-lft-identity0.0%

        \[\leadsto \color{blue}{\frac{\sin x - x}{\tan x - x}} \]
    3. Simplified0.0%

      \[\leadsto \color{blue}{\frac{\sin x - x}{\tan x - x}} \]
    4. Taylor expanded in x around 0 100.0%

      \[\leadsto \color{blue}{-0.5} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x - \sin x}{x - \tan x} \leq 2:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\sin x - x}{\tan x - x}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;-0.5\\ \end{array} \]

Alternative 2: 99.5% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{x - \sin x}{x - \tan x} \leq 2:\\ \;\;\;\;\frac{1}{\frac{\tan x - x}{\sin x - x}}\\ \mathbf{else}:\\ \;\;\;\;-0.5\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= (/ (- x (sin x)) (- x (tan x))) 2.0)
   (/ 1.0 (/ (- (tan x) x) (- (sin x) x)))
   -0.5))
double code(double x) {
	double tmp;
	if (((x - sin(x)) / (x - tan(x))) <= 2.0) {
		tmp = 1.0 / ((tan(x) - x) / (sin(x) - x));
	} else {
		tmp = -0.5;
	}
	return tmp;
}
real(8) function code(x)
    real(8), intent (in) :: x
    real(8) :: tmp
    if (((x - sin(x)) / (x - tan(x))) <= 2.0d0) then
        tmp = 1.0d0 / ((tan(x) - x) / (sin(x) - x))
    else
        tmp = -0.5d0
    end if
    code = tmp
end function
public static double code(double x) {
	double tmp;
	if (((x - Math.sin(x)) / (x - Math.tan(x))) <= 2.0) {
		tmp = 1.0 / ((Math.tan(x) - x) / (Math.sin(x) - x));
	} else {
		tmp = -0.5;
	}
	return tmp;
}
def code(x):
	tmp = 0
	if ((x - math.sin(x)) / (x - math.tan(x))) <= 2.0:
		tmp = 1.0 / ((math.tan(x) - x) / (math.sin(x) - x))
	else:
		tmp = -0.5
	return tmp
function code(x)
	tmp = 0.0
	if (Float64(Float64(x - sin(x)) / Float64(x - tan(x))) <= 2.0)
		tmp = Float64(1.0 / Float64(Float64(tan(x) - x) / Float64(sin(x) - x)));
	else
		tmp = -0.5;
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = 0.0;
	if (((x - sin(x)) / (x - tan(x))) <= 2.0)
		tmp = 1.0 / ((tan(x) - x) / (sin(x) - x));
	else
		tmp = -0.5;
	end
	tmp_2 = tmp;
end
code[x_] := If[LessEqual[N[(N[(x - N[Sin[x], $MachinePrecision]), $MachinePrecision] / N[(x - N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], N[(1.0 / N[(N[(N[Tan[x], $MachinePrecision] - x), $MachinePrecision] / N[(N[Sin[x], $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -0.5]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\frac{x - \sin x}{x - \tan x} \leq 2:\\
\;\;\;\;\frac{1}{\frac{\tan x - x}{\sin x - x}}\\

\mathbf{else}:\\
\;\;\;\;-0.5\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (-.f64 x (sin.f64 x)) (-.f64 x (tan.f64 x))) < 2

    1. Initial program 99.4%

      \[\frac{x - \sin x}{x - \tan x} \]
    2. Step-by-step derivation
      1. sub-neg99.4%

        \[\leadsto \frac{\color{blue}{x + \left(-\sin x\right)}}{x - \tan x} \]
      2. +-commutative99.4%

        \[\leadsto \frac{\color{blue}{\left(-\sin x\right) + x}}{x - \tan x} \]
      3. neg-sub099.4%

        \[\leadsto \frac{\color{blue}{\left(0 - \sin x\right)} + x}{x - \tan x} \]
      4. associate-+l-99.4%

        \[\leadsto \frac{\color{blue}{0 - \left(\sin x - x\right)}}{x - \tan x} \]
      5. sub0-neg99.4%

        \[\leadsto \frac{\color{blue}{-\left(\sin x - x\right)}}{x - \tan x} \]
      6. neg-mul-199.4%

        \[\leadsto \frac{\color{blue}{-1 \cdot \left(\sin x - x\right)}}{x - \tan x} \]
      7. sub-neg99.4%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{x + \left(-\tan x\right)}} \]
      8. +-commutative99.4%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{\left(-\tan x\right) + x}} \]
      9. neg-sub099.4%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{\left(0 - \tan x\right)} + x} \]
      10. associate-+l-99.4%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{0 - \left(\tan x - x\right)}} \]
      11. sub0-neg99.4%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{-\left(\tan x - x\right)}} \]
      12. neg-mul-199.4%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{-1 \cdot \left(\tan x - x\right)}} \]
      13. times-frac99.4%

        \[\leadsto \color{blue}{\frac{-1}{-1} \cdot \frac{\sin x - x}{\tan x - x}} \]
      14. metadata-eval99.4%

        \[\leadsto \color{blue}{1} \cdot \frac{\sin x - x}{\tan x - x} \]
      15. *-lft-identity99.4%

        \[\leadsto \color{blue}{\frac{\sin x - x}{\tan x - x}} \]
    3. Simplified99.4%

      \[\leadsto \color{blue}{\frac{\sin x - x}{\tan x - x}} \]
    4. Step-by-step derivation
      1. clear-num99.4%

        \[\leadsto \color{blue}{\frac{1}{\frac{\tan x - x}{\sin x - x}}} \]
      2. inv-pow99.4%

        \[\leadsto \color{blue}{{\left(\frac{\tan x - x}{\sin x - x}\right)}^{-1}} \]
    5. Applied egg-rr99.4%

      \[\leadsto \color{blue}{{\left(\frac{\tan x - x}{\sin x - x}\right)}^{-1}} \]
    6. Step-by-step derivation
      1. unpow-199.4%

        \[\leadsto \color{blue}{\frac{1}{\frac{\tan x - x}{\sin x - x}}} \]
    7. Applied egg-rr99.4%

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

    if 2 < (/.f64 (-.f64 x (sin.f64 x)) (-.f64 x (tan.f64 x)))

    1. Initial program 0.0%

      \[\frac{x - \sin x}{x - \tan x} \]
    2. Step-by-step derivation
      1. sub-neg0.0%

        \[\leadsto \frac{\color{blue}{x + \left(-\sin x\right)}}{x - \tan x} \]
      2. +-commutative0.0%

        \[\leadsto \frac{\color{blue}{\left(-\sin x\right) + x}}{x - \tan x} \]
      3. neg-sub00.0%

        \[\leadsto \frac{\color{blue}{\left(0 - \sin x\right)} + x}{x - \tan x} \]
      4. associate-+l-0.0%

        \[\leadsto \frac{\color{blue}{0 - \left(\sin x - x\right)}}{x - \tan x} \]
      5. sub0-neg0.0%

        \[\leadsto \frac{\color{blue}{-\left(\sin x - x\right)}}{x - \tan x} \]
      6. neg-mul-10.0%

        \[\leadsto \frac{\color{blue}{-1 \cdot \left(\sin x - x\right)}}{x - \tan x} \]
      7. sub-neg0.0%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{x + \left(-\tan x\right)}} \]
      8. +-commutative0.0%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{\left(-\tan x\right) + x}} \]
      9. neg-sub00.0%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{\left(0 - \tan x\right)} + x} \]
      10. associate-+l-0.0%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{0 - \left(\tan x - x\right)}} \]
      11. sub0-neg0.0%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{-\left(\tan x - x\right)}} \]
      12. neg-mul-10.0%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{-1 \cdot \left(\tan x - x\right)}} \]
      13. times-frac0.0%

        \[\leadsto \color{blue}{\frac{-1}{-1} \cdot \frac{\sin x - x}{\tan x - x}} \]
      14. metadata-eval0.0%

        \[\leadsto \color{blue}{1} \cdot \frac{\sin x - x}{\tan x - x} \]
      15. *-lft-identity0.0%

        \[\leadsto \color{blue}{\frac{\sin x - x}{\tan x - x}} \]
    3. Simplified0.0%

      \[\leadsto \color{blue}{\frac{\sin x - x}{\tan x - x}} \]
    4. Taylor expanded in x around 0 100.0%

      \[\leadsto \color{blue}{-0.5} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x - \sin x}{x - \tan x} \leq 2:\\ \;\;\;\;\frac{1}{\frac{\tan x - x}{\sin x - x}}\\ \mathbf{else}:\\ \;\;\;\;-0.5\\ \end{array} \]

Alternative 3: 99.5% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{x - \sin x}{x - \tan x}\\ \mathbf{if}\;t_0 \leq 2:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;-0.5\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (let* ((t_0 (/ (- x (sin x)) (- x (tan x))))) (if (<= t_0 2.0) t_0 -0.5)))
double code(double x) {
	double t_0 = (x - sin(x)) / (x - tan(x));
	double tmp;
	if (t_0 <= 2.0) {
		tmp = t_0;
	} else {
		tmp = -0.5;
	}
	return tmp;
}
real(8) function code(x)
    real(8), intent (in) :: x
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (x - sin(x)) / (x - tan(x))
    if (t_0 <= 2.0d0) then
        tmp = t_0
    else
        tmp = -0.5d0
    end if
    code = tmp
end function
public static double code(double x) {
	double t_0 = (x - Math.sin(x)) / (x - Math.tan(x));
	double tmp;
	if (t_0 <= 2.0) {
		tmp = t_0;
	} else {
		tmp = -0.5;
	}
	return tmp;
}
def code(x):
	t_0 = (x - math.sin(x)) / (x - math.tan(x))
	tmp = 0
	if t_0 <= 2.0:
		tmp = t_0
	else:
		tmp = -0.5
	return tmp
function code(x)
	t_0 = Float64(Float64(x - sin(x)) / Float64(x - tan(x)))
	tmp = 0.0
	if (t_0 <= 2.0)
		tmp = t_0;
	else
		tmp = -0.5;
	end
	return tmp
end
function tmp_2 = code(x)
	t_0 = (x - sin(x)) / (x - tan(x));
	tmp = 0.0;
	if (t_0 <= 2.0)
		tmp = t_0;
	else
		tmp = -0.5;
	end
	tmp_2 = tmp;
end
code[x_] := Block[{t$95$0 = N[(N[(x - N[Sin[x], $MachinePrecision]), $MachinePrecision] / N[(x - N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 2.0], t$95$0, -0.5]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{x - \sin x}{x - \tan x}\\
\mathbf{if}\;t_0 \leq 2:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;-0.5\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (-.f64 x (sin.f64 x)) (-.f64 x (tan.f64 x))) < 2

    1. Initial program 99.4%

      \[\frac{x - \sin x}{x - \tan x} \]

    if 2 < (/.f64 (-.f64 x (sin.f64 x)) (-.f64 x (tan.f64 x)))

    1. Initial program 0.0%

      \[\frac{x - \sin x}{x - \tan x} \]
    2. Step-by-step derivation
      1. sub-neg0.0%

        \[\leadsto \frac{\color{blue}{x + \left(-\sin x\right)}}{x - \tan x} \]
      2. +-commutative0.0%

        \[\leadsto \frac{\color{blue}{\left(-\sin x\right) + x}}{x - \tan x} \]
      3. neg-sub00.0%

        \[\leadsto \frac{\color{blue}{\left(0 - \sin x\right)} + x}{x - \tan x} \]
      4. associate-+l-0.0%

        \[\leadsto \frac{\color{blue}{0 - \left(\sin x - x\right)}}{x - \tan x} \]
      5. sub0-neg0.0%

        \[\leadsto \frac{\color{blue}{-\left(\sin x - x\right)}}{x - \tan x} \]
      6. neg-mul-10.0%

        \[\leadsto \frac{\color{blue}{-1 \cdot \left(\sin x - x\right)}}{x - \tan x} \]
      7. sub-neg0.0%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{x + \left(-\tan x\right)}} \]
      8. +-commutative0.0%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{\left(-\tan x\right) + x}} \]
      9. neg-sub00.0%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{\left(0 - \tan x\right)} + x} \]
      10. associate-+l-0.0%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{0 - \left(\tan x - x\right)}} \]
      11. sub0-neg0.0%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{-\left(\tan x - x\right)}} \]
      12. neg-mul-10.0%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{-1 \cdot \left(\tan x - x\right)}} \]
      13. times-frac0.0%

        \[\leadsto \color{blue}{\frac{-1}{-1} \cdot \frac{\sin x - x}{\tan x - x}} \]
      14. metadata-eval0.0%

        \[\leadsto \color{blue}{1} \cdot \frac{\sin x - x}{\tan x - x} \]
      15. *-lft-identity0.0%

        \[\leadsto \color{blue}{\frac{\sin x - x}{\tan x - x}} \]
    3. Simplified0.0%

      \[\leadsto \color{blue}{\frac{\sin x - x}{\tan x - x}} \]
    4. Taylor expanded in x around 0 100.0%

      \[\leadsto \color{blue}{-0.5} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x - \sin x}{x - \tan x} \leq 2:\\ \;\;\;\;\frac{x - \sin x}{x - \tan x}\\ \mathbf{else}:\\ \;\;\;\;-0.5\\ \end{array} \]

Alternative 4: 98.9% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -2.6:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 2.8:\\ \;\;\;\;-0.5 + 0.225 \cdot \left(x \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{3}{x \cdot x} - \frac{x}{\tan x - x}\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= x -2.6)
   1.0
   (if (<= x 2.8)
     (+ -0.5 (* 0.225 (* x x)))
     (- (/ 3.0 (* x x)) (/ x (- (tan x) x))))))
double code(double x) {
	double tmp;
	if (x <= -2.6) {
		tmp = 1.0;
	} else if (x <= 2.8) {
		tmp = -0.5 + (0.225 * (x * x));
	} else {
		tmp = (3.0 / (x * x)) - (x / (tan(x) - x));
	}
	return tmp;
}
real(8) function code(x)
    real(8), intent (in) :: x
    real(8) :: tmp
    if (x <= (-2.6d0)) then
        tmp = 1.0d0
    else if (x <= 2.8d0) then
        tmp = (-0.5d0) + (0.225d0 * (x * x))
    else
        tmp = (3.0d0 / (x * x)) - (x / (tan(x) - x))
    end if
    code = tmp
end function
public static double code(double x) {
	double tmp;
	if (x <= -2.6) {
		tmp = 1.0;
	} else if (x <= 2.8) {
		tmp = -0.5 + (0.225 * (x * x));
	} else {
		tmp = (3.0 / (x * x)) - (x / (Math.tan(x) - x));
	}
	return tmp;
}
def code(x):
	tmp = 0
	if x <= -2.6:
		tmp = 1.0
	elif x <= 2.8:
		tmp = -0.5 + (0.225 * (x * x))
	else:
		tmp = (3.0 / (x * x)) - (x / (math.tan(x) - x))
	return tmp
function code(x)
	tmp = 0.0
	if (x <= -2.6)
		tmp = 1.0;
	elseif (x <= 2.8)
		tmp = Float64(-0.5 + Float64(0.225 * Float64(x * x)));
	else
		tmp = Float64(Float64(3.0 / Float64(x * x)) - Float64(x / Float64(tan(x) - x)));
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = 0.0;
	if (x <= -2.6)
		tmp = 1.0;
	elseif (x <= 2.8)
		tmp = -0.5 + (0.225 * (x * x));
	else
		tmp = (3.0 / (x * x)) - (x / (tan(x) - x));
	end
	tmp_2 = tmp;
end
code[x_] := If[LessEqual[x, -2.6], 1.0, If[LessEqual[x, 2.8], N[(-0.5 + N[(0.225 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(3.0 / N[(x * x), $MachinePrecision]), $MachinePrecision] - N[(x / N[(N[Tan[x], $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.6:\\
\;\;\;\;1\\

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

\mathbf{else}:\\
\;\;\;\;\frac{3}{x \cdot x} - \frac{x}{\tan x - x}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -2.60000000000000009

    1. Initial program 100.0%

      \[\frac{x - \sin x}{x - \tan x} \]
    2. Step-by-step derivation
      1. sub-neg100.0%

        \[\leadsto \frac{\color{blue}{x + \left(-\sin x\right)}}{x - \tan x} \]
      2. +-commutative100.0%

        \[\leadsto \frac{\color{blue}{\left(-\sin x\right) + x}}{x - \tan x} \]
      3. neg-sub0100.0%

        \[\leadsto \frac{\color{blue}{\left(0 - \sin x\right)} + x}{x - \tan x} \]
      4. associate-+l-100.0%

        \[\leadsto \frac{\color{blue}{0 - \left(\sin x - x\right)}}{x - \tan x} \]
      5. sub0-neg100.0%

        \[\leadsto \frac{\color{blue}{-\left(\sin x - x\right)}}{x - \tan x} \]
      6. neg-mul-1100.0%

        \[\leadsto \frac{\color{blue}{-1 \cdot \left(\sin x - x\right)}}{x - \tan x} \]
      7. sub-neg100.0%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{x + \left(-\tan x\right)}} \]
      8. +-commutative100.0%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{\left(-\tan x\right) + x}} \]
      9. neg-sub0100.0%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{\left(0 - \tan x\right)} + x} \]
      10. associate-+l-100.0%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{0 - \left(\tan x - x\right)}} \]
      11. sub0-neg100.0%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{-\left(\tan x - x\right)}} \]
      12. neg-mul-1100.0%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{-1 \cdot \left(\tan x - x\right)}} \]
      13. times-frac100.0%

        \[\leadsto \color{blue}{\frac{-1}{-1} \cdot \frac{\sin x - x}{\tan x - x}} \]
      14. metadata-eval100.0%

        \[\leadsto \color{blue}{1} \cdot \frac{\sin x - x}{\tan x - x} \]
      15. *-lft-identity100.0%

        \[\leadsto \color{blue}{\frac{\sin x - x}{\tan x - x}} \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\frac{\sin x - x}{\tan x - x}} \]
    4. Taylor expanded in x around inf 98.8%

      \[\leadsto \color{blue}{1} \]

    if -2.60000000000000009 < x < 2.7999999999999998

    1. Initial program 3.3%

      \[\frac{x - \sin x}{x - \tan x} \]
    2. Step-by-step derivation
      1. sub-neg3.3%

        \[\leadsto \frac{\color{blue}{x + \left(-\sin x\right)}}{x - \tan x} \]
      2. +-commutative3.3%

        \[\leadsto \frac{\color{blue}{\left(-\sin x\right) + x}}{x - \tan x} \]
      3. neg-sub03.3%

        \[\leadsto \frac{\color{blue}{\left(0 - \sin x\right)} + x}{x - \tan x} \]
      4. associate-+l-3.3%

        \[\leadsto \frac{\color{blue}{0 - \left(\sin x - x\right)}}{x - \tan x} \]
      5. sub0-neg3.3%

        \[\leadsto \frac{\color{blue}{-\left(\sin x - x\right)}}{x - \tan x} \]
      6. neg-mul-13.3%

        \[\leadsto \frac{\color{blue}{-1 \cdot \left(\sin x - x\right)}}{x - \tan x} \]
      7. sub-neg3.3%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{x + \left(-\tan x\right)}} \]
      8. +-commutative3.3%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{\left(-\tan x\right) + x}} \]
      9. neg-sub03.3%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{\left(0 - \tan x\right)} + x} \]
      10. associate-+l-3.3%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{0 - \left(\tan x - x\right)}} \]
      11. sub0-neg3.3%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{-\left(\tan x - x\right)}} \]
      12. neg-mul-13.3%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{-1 \cdot \left(\tan x - x\right)}} \]
      13. times-frac3.3%

        \[\leadsto \color{blue}{\frac{-1}{-1} \cdot \frac{\sin x - x}{\tan x - x}} \]
      14. metadata-eval3.3%

        \[\leadsto \color{blue}{1} \cdot \frac{\sin x - x}{\tan x - x} \]
      15. *-lft-identity3.3%

        \[\leadsto \color{blue}{\frac{\sin x - x}{\tan x - x}} \]
    3. Simplified3.3%

      \[\leadsto \color{blue}{\frac{\sin x - x}{\tan x - x}} \]
    4. Taylor expanded in x around 0 98.9%

      \[\leadsto \color{blue}{0.225 \cdot {x}^{2} - 0.5} \]
    5. Step-by-step derivation
      1. fma-neg98.9%

        \[\leadsto \color{blue}{\mathsf{fma}\left(0.225, {x}^{2}, -0.5\right)} \]
      2. unpow298.9%

        \[\leadsto \mathsf{fma}\left(0.225, \color{blue}{x \cdot x}, -0.5\right) \]
      3. metadata-eval98.9%

        \[\leadsto \mathsf{fma}\left(0.225, x \cdot x, \color{blue}{-0.5}\right) \]
    6. Simplified98.9%

      \[\leadsto \color{blue}{\mathsf{fma}\left(0.225, x \cdot x, -0.5\right)} \]
    7. Step-by-step derivation
      1. fma-udef98.9%

        \[\leadsto \color{blue}{0.225 \cdot \left(x \cdot x\right) + -0.5} \]
    8. Applied egg-rr98.9%

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

    if 2.7999999999999998 < x

    1. Initial program 100.0%

      \[\frac{x - \sin x}{x - \tan x} \]
    2. Step-by-step derivation
      1. sub-neg100.0%

        \[\leadsto \frac{\color{blue}{x + \left(-\sin x\right)}}{x - \tan x} \]
      2. +-commutative100.0%

        \[\leadsto \frac{\color{blue}{\left(-\sin x\right) + x}}{x - \tan x} \]
      3. neg-sub0100.0%

        \[\leadsto \frac{\color{blue}{\left(0 - \sin x\right)} + x}{x - \tan x} \]
      4. associate-+l-100.0%

        \[\leadsto \frac{\color{blue}{0 - \left(\sin x - x\right)}}{x - \tan x} \]
      5. sub0-neg100.0%

        \[\leadsto \frac{\color{blue}{-\left(\sin x - x\right)}}{x - \tan x} \]
      6. neg-mul-1100.0%

        \[\leadsto \frac{\color{blue}{-1 \cdot \left(\sin x - x\right)}}{x - \tan x} \]
      7. sub-neg100.0%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{x + \left(-\tan x\right)}} \]
      8. +-commutative100.0%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{\left(-\tan x\right) + x}} \]
      9. neg-sub0100.0%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{\left(0 - \tan x\right)} + x} \]
      10. associate-+l-100.0%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{0 - \left(\tan x - x\right)}} \]
      11. sub0-neg100.0%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{-\left(\tan x - x\right)}} \]
      12. neg-mul-1100.0%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{-1 \cdot \left(\tan x - x\right)}} \]
      13. times-frac100.0%

        \[\leadsto \color{blue}{\frac{-1}{-1} \cdot \frac{\sin x - x}{\tan x - x}} \]
      14. metadata-eval100.0%

        \[\leadsto \color{blue}{1} \cdot \frac{\sin x - x}{\tan x - x} \]
      15. *-lft-identity100.0%

        \[\leadsto \color{blue}{\frac{\sin x - x}{\tan x - x}} \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\frac{\sin x - x}{\tan x - x}} \]
    4. Step-by-step derivation
      1. div-sub100.0%

        \[\leadsto \color{blue}{\frac{\sin x}{\tan x - x} - \frac{x}{\tan x - x}} \]
    5. Applied egg-rr100.0%

      \[\leadsto \color{blue}{\frac{\sin x}{\tan x - x} - \frac{x}{\tan x - x}} \]
    6. Taylor expanded in x around 0 97.9%

      \[\leadsto \color{blue}{\frac{3}{{x}^{2}}} - \frac{x}{\tan x - x} \]
    7. Step-by-step derivation
      1. unpow297.9%

        \[\leadsto \frac{3}{\color{blue}{x \cdot x}} - \frac{x}{\tan x - x} \]
    8. Simplified97.9%

      \[\leadsto \color{blue}{\frac{3}{x \cdot x}} - \frac{x}{\tan x - x} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification98.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.6:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 2.8:\\ \;\;\;\;-0.5 + 0.225 \cdot \left(x \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{3}{x \cdot x} - \frac{x}{\tan x - x}\\ \end{array} \]

Alternative 5: 98.9% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -2.6:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 1.45:\\ \;\;\;\;-0.5 + 0.225 \cdot \left(x \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{-x}{\tan x - x}\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= x -2.6)
   1.0
   (if (<= x 1.45) (+ -0.5 (* 0.225 (* x x))) (/ (- x) (- (tan x) x)))))
double code(double x) {
	double tmp;
	if (x <= -2.6) {
		tmp = 1.0;
	} else if (x <= 1.45) {
		tmp = -0.5 + (0.225 * (x * x));
	} else {
		tmp = -x / (tan(x) - x);
	}
	return tmp;
}
real(8) function code(x)
    real(8), intent (in) :: x
    real(8) :: tmp
    if (x <= (-2.6d0)) then
        tmp = 1.0d0
    else if (x <= 1.45d0) then
        tmp = (-0.5d0) + (0.225d0 * (x * x))
    else
        tmp = -x / (tan(x) - x)
    end if
    code = tmp
end function
public static double code(double x) {
	double tmp;
	if (x <= -2.6) {
		tmp = 1.0;
	} else if (x <= 1.45) {
		tmp = -0.5 + (0.225 * (x * x));
	} else {
		tmp = -x / (Math.tan(x) - x);
	}
	return tmp;
}
def code(x):
	tmp = 0
	if x <= -2.6:
		tmp = 1.0
	elif x <= 1.45:
		tmp = -0.5 + (0.225 * (x * x))
	else:
		tmp = -x / (math.tan(x) - x)
	return tmp
function code(x)
	tmp = 0.0
	if (x <= -2.6)
		tmp = 1.0;
	elseif (x <= 1.45)
		tmp = Float64(-0.5 + Float64(0.225 * Float64(x * x)));
	else
		tmp = Float64(Float64(-x) / Float64(tan(x) - x));
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = 0.0;
	if (x <= -2.6)
		tmp = 1.0;
	elseif (x <= 1.45)
		tmp = -0.5 + (0.225 * (x * x));
	else
		tmp = -x / (tan(x) - x);
	end
	tmp_2 = tmp;
end
code[x_] := If[LessEqual[x, -2.6], 1.0, If[LessEqual[x, 1.45], N[(-0.5 + N[(0.225 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-x) / N[(N[Tan[x], $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.6:\\
\;\;\;\;1\\

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

\mathbf{else}:\\
\;\;\;\;\frac{-x}{\tan x - x}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -2.60000000000000009

    1. Initial program 100.0%

      \[\frac{x - \sin x}{x - \tan x} \]
    2. Step-by-step derivation
      1. sub-neg100.0%

        \[\leadsto \frac{\color{blue}{x + \left(-\sin x\right)}}{x - \tan x} \]
      2. +-commutative100.0%

        \[\leadsto \frac{\color{blue}{\left(-\sin x\right) + x}}{x - \tan x} \]
      3. neg-sub0100.0%

        \[\leadsto \frac{\color{blue}{\left(0 - \sin x\right)} + x}{x - \tan x} \]
      4. associate-+l-100.0%

        \[\leadsto \frac{\color{blue}{0 - \left(\sin x - x\right)}}{x - \tan x} \]
      5. sub0-neg100.0%

        \[\leadsto \frac{\color{blue}{-\left(\sin x - x\right)}}{x - \tan x} \]
      6. neg-mul-1100.0%

        \[\leadsto \frac{\color{blue}{-1 \cdot \left(\sin x - x\right)}}{x - \tan x} \]
      7. sub-neg100.0%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{x + \left(-\tan x\right)}} \]
      8. +-commutative100.0%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{\left(-\tan x\right) + x}} \]
      9. neg-sub0100.0%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{\left(0 - \tan x\right)} + x} \]
      10. associate-+l-100.0%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{0 - \left(\tan x - x\right)}} \]
      11. sub0-neg100.0%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{-\left(\tan x - x\right)}} \]
      12. neg-mul-1100.0%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{-1 \cdot \left(\tan x - x\right)}} \]
      13. times-frac100.0%

        \[\leadsto \color{blue}{\frac{-1}{-1} \cdot \frac{\sin x - x}{\tan x - x}} \]
      14. metadata-eval100.0%

        \[\leadsto \color{blue}{1} \cdot \frac{\sin x - x}{\tan x - x} \]
      15. *-lft-identity100.0%

        \[\leadsto \color{blue}{\frac{\sin x - x}{\tan x - x}} \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\frac{\sin x - x}{\tan x - x}} \]
    4. Taylor expanded in x around inf 98.8%

      \[\leadsto \color{blue}{1} \]

    if -2.60000000000000009 < x < 1.44999999999999996

    1. Initial program 3.3%

      \[\frac{x - \sin x}{x - \tan x} \]
    2. Step-by-step derivation
      1. sub-neg3.3%

        \[\leadsto \frac{\color{blue}{x + \left(-\sin x\right)}}{x - \tan x} \]
      2. +-commutative3.3%

        \[\leadsto \frac{\color{blue}{\left(-\sin x\right) + x}}{x - \tan x} \]
      3. neg-sub03.3%

        \[\leadsto \frac{\color{blue}{\left(0 - \sin x\right)} + x}{x - \tan x} \]
      4. associate-+l-3.3%

        \[\leadsto \frac{\color{blue}{0 - \left(\sin x - x\right)}}{x - \tan x} \]
      5. sub0-neg3.3%

        \[\leadsto \frac{\color{blue}{-\left(\sin x - x\right)}}{x - \tan x} \]
      6. neg-mul-13.3%

        \[\leadsto \frac{\color{blue}{-1 \cdot \left(\sin x - x\right)}}{x - \tan x} \]
      7. sub-neg3.3%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{x + \left(-\tan x\right)}} \]
      8. +-commutative3.3%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{\left(-\tan x\right) + x}} \]
      9. neg-sub03.3%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{\left(0 - \tan x\right)} + x} \]
      10. associate-+l-3.3%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{0 - \left(\tan x - x\right)}} \]
      11. sub0-neg3.3%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{-\left(\tan x - x\right)}} \]
      12. neg-mul-13.3%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{-1 \cdot \left(\tan x - x\right)}} \]
      13. times-frac3.3%

        \[\leadsto \color{blue}{\frac{-1}{-1} \cdot \frac{\sin x - x}{\tan x - x}} \]
      14. metadata-eval3.3%

        \[\leadsto \color{blue}{1} \cdot \frac{\sin x - x}{\tan x - x} \]
      15. *-lft-identity3.3%

        \[\leadsto \color{blue}{\frac{\sin x - x}{\tan x - x}} \]
    3. Simplified3.3%

      \[\leadsto \color{blue}{\frac{\sin x - x}{\tan x - x}} \]
    4. Taylor expanded in x around 0 98.9%

      \[\leadsto \color{blue}{0.225 \cdot {x}^{2} - 0.5} \]
    5. Step-by-step derivation
      1. fma-neg98.9%

        \[\leadsto \color{blue}{\mathsf{fma}\left(0.225, {x}^{2}, -0.5\right)} \]
      2. unpow298.9%

        \[\leadsto \mathsf{fma}\left(0.225, \color{blue}{x \cdot x}, -0.5\right) \]
      3. metadata-eval98.9%

        \[\leadsto \mathsf{fma}\left(0.225, x \cdot x, \color{blue}{-0.5}\right) \]
    6. Simplified98.9%

      \[\leadsto \color{blue}{\mathsf{fma}\left(0.225, x \cdot x, -0.5\right)} \]
    7. Step-by-step derivation
      1. fma-udef98.9%

        \[\leadsto \color{blue}{0.225 \cdot \left(x \cdot x\right) + -0.5} \]
    8. Applied egg-rr98.9%

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

    if 1.44999999999999996 < x

    1. Initial program 100.0%

      \[\frac{x - \sin x}{x - \tan x} \]
    2. Step-by-step derivation
      1. sub-neg100.0%

        \[\leadsto \frac{\color{blue}{x + \left(-\sin x\right)}}{x - \tan x} \]
      2. +-commutative100.0%

        \[\leadsto \frac{\color{blue}{\left(-\sin x\right) + x}}{x - \tan x} \]
      3. neg-sub0100.0%

        \[\leadsto \frac{\color{blue}{\left(0 - \sin x\right)} + x}{x - \tan x} \]
      4. associate-+l-100.0%

        \[\leadsto \frac{\color{blue}{0 - \left(\sin x - x\right)}}{x - \tan x} \]
      5. sub0-neg100.0%

        \[\leadsto \frac{\color{blue}{-\left(\sin x - x\right)}}{x - \tan x} \]
      6. neg-mul-1100.0%

        \[\leadsto \frac{\color{blue}{-1 \cdot \left(\sin x - x\right)}}{x - \tan x} \]
      7. sub-neg100.0%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{x + \left(-\tan x\right)}} \]
      8. +-commutative100.0%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{\left(-\tan x\right) + x}} \]
      9. neg-sub0100.0%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{\left(0 - \tan x\right)} + x} \]
      10. associate-+l-100.0%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{0 - \left(\tan x - x\right)}} \]
      11. sub0-neg100.0%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{-\left(\tan x - x\right)}} \]
      12. neg-mul-1100.0%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{-1 \cdot \left(\tan x - x\right)}} \]
      13. times-frac100.0%

        \[\leadsto \color{blue}{\frac{-1}{-1} \cdot \frac{\sin x - x}{\tan x - x}} \]
      14. metadata-eval100.0%

        \[\leadsto \color{blue}{1} \cdot \frac{\sin x - x}{\tan x - x} \]
      15. *-lft-identity100.0%

        \[\leadsto \color{blue}{\frac{\sin x - x}{\tan x - x}} \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\frac{\sin x - x}{\tan x - x}} \]
    4. Step-by-step derivation
      1. flip--47.3%

        \[\leadsto \frac{\color{blue}{\frac{\sin x \cdot \sin x - x \cdot x}{\sin x + x}}}{\tan x - x} \]
      2. div-inv47.1%

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

        \[\leadsto \frac{\left(\color{blue}{{\sin x}^{2}} - x \cdot x\right) \cdot \frac{1}{\sin x + x}}{\tan x - x} \]
      4. +-commutative47.1%

        \[\leadsto \frac{\left({\sin x}^{2} - x \cdot x\right) \cdot \frac{1}{\color{blue}{x + \sin x}}}{\tan x - x} \]
    5. Applied egg-rr47.1%

      \[\leadsto \frac{\color{blue}{\left({\sin x}^{2} - x \cdot x\right) \cdot \frac{1}{x + \sin x}}}{\tan x - x} \]
    6. Step-by-step derivation
      1. associate-*r/47.3%

        \[\leadsto \frac{\color{blue}{\frac{\left({\sin x}^{2} - x \cdot x\right) \cdot 1}{x + \sin x}}}{\tan x - x} \]
      2. *-rgt-identity47.3%

        \[\leadsto \frac{\frac{\color{blue}{{\sin x}^{2} - x \cdot x}}{x + \sin x}}{\tan x - x} \]
    7. Simplified47.3%

      \[\leadsto \frac{\color{blue}{\frac{{\sin x}^{2} - x \cdot x}{x + \sin x}}}{\tan x - x} \]
    8. Taylor expanded in x around inf 97.9%

      \[\leadsto \frac{\color{blue}{-1 \cdot x}}{\tan x - x} \]
    9. Step-by-step derivation
      1. neg-mul-197.9%

        \[\leadsto \frac{\color{blue}{-x}}{\tan x - x} \]
    10. Simplified97.9%

      \[\leadsto \frac{\color{blue}{-x}}{\tan x - x} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification98.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.6:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 1.45:\\ \;\;\;\;-0.5 + 0.225 \cdot \left(x \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{-x}{\tan x - x}\\ \end{array} \]

Alternative 6: 98.8% accurate, 18.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -2.6:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 2.5:\\ \;\;\;\;-0.5 + 0.225 \cdot \left(x \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= x -2.6) 1.0 (if (<= x 2.5) (+ -0.5 (* 0.225 (* x x))) 1.0)))
double code(double x) {
	double tmp;
	if (x <= -2.6) {
		tmp = 1.0;
	} else if (x <= 2.5) {
		tmp = -0.5 + (0.225 * (x * x));
	} else {
		tmp = 1.0;
	}
	return tmp;
}
real(8) function code(x)
    real(8), intent (in) :: x
    real(8) :: tmp
    if (x <= (-2.6d0)) then
        tmp = 1.0d0
    else if (x <= 2.5d0) then
        tmp = (-0.5d0) + (0.225d0 * (x * x))
    else
        tmp = 1.0d0
    end if
    code = tmp
end function
public static double code(double x) {
	double tmp;
	if (x <= -2.6) {
		tmp = 1.0;
	} else if (x <= 2.5) {
		tmp = -0.5 + (0.225 * (x * x));
	} else {
		tmp = 1.0;
	}
	return tmp;
}
def code(x):
	tmp = 0
	if x <= -2.6:
		tmp = 1.0
	elif x <= 2.5:
		tmp = -0.5 + (0.225 * (x * x))
	else:
		tmp = 1.0
	return tmp
function code(x)
	tmp = 0.0
	if (x <= -2.6)
		tmp = 1.0;
	elseif (x <= 2.5)
		tmp = Float64(-0.5 + Float64(0.225 * Float64(x * x)));
	else
		tmp = 1.0;
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = 0.0;
	if (x <= -2.6)
		tmp = 1.0;
	elseif (x <= 2.5)
		tmp = -0.5 + (0.225 * (x * x));
	else
		tmp = 1.0;
	end
	tmp_2 = tmp;
end
code[x_] := If[LessEqual[x, -2.6], 1.0, If[LessEqual[x, 2.5], N[(-0.5 + N[(0.225 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1.0]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.6:\\
\;\;\;\;1\\

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

\mathbf{else}:\\
\;\;\;\;1\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -2.60000000000000009 or 2.5 < x

    1. Initial program 100.0%

      \[\frac{x - \sin x}{x - \tan x} \]
    2. Step-by-step derivation
      1. sub-neg100.0%

        \[\leadsto \frac{\color{blue}{x + \left(-\sin x\right)}}{x - \tan x} \]
      2. +-commutative100.0%

        \[\leadsto \frac{\color{blue}{\left(-\sin x\right) + x}}{x - \tan x} \]
      3. neg-sub0100.0%

        \[\leadsto \frac{\color{blue}{\left(0 - \sin x\right)} + x}{x - \tan x} \]
      4. associate-+l-100.0%

        \[\leadsto \frac{\color{blue}{0 - \left(\sin x - x\right)}}{x - \tan x} \]
      5. sub0-neg100.0%

        \[\leadsto \frac{\color{blue}{-\left(\sin x - x\right)}}{x - \tan x} \]
      6. neg-mul-1100.0%

        \[\leadsto \frac{\color{blue}{-1 \cdot \left(\sin x - x\right)}}{x - \tan x} \]
      7. sub-neg100.0%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{x + \left(-\tan x\right)}} \]
      8. +-commutative100.0%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{\left(-\tan x\right) + x}} \]
      9. neg-sub0100.0%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{\left(0 - \tan x\right)} + x} \]
      10. associate-+l-100.0%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{0 - \left(\tan x - x\right)}} \]
      11. sub0-neg100.0%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{-\left(\tan x - x\right)}} \]
      12. neg-mul-1100.0%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{-1 \cdot \left(\tan x - x\right)}} \]
      13. times-frac100.0%

        \[\leadsto \color{blue}{\frac{-1}{-1} \cdot \frac{\sin x - x}{\tan x - x}} \]
      14. metadata-eval100.0%

        \[\leadsto \color{blue}{1} \cdot \frac{\sin x - x}{\tan x - x} \]
      15. *-lft-identity100.0%

        \[\leadsto \color{blue}{\frac{\sin x - x}{\tan x - x}} \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\frac{\sin x - x}{\tan x - x}} \]
    4. Taylor expanded in x around inf 98.3%

      \[\leadsto \color{blue}{1} \]

    if -2.60000000000000009 < x < 2.5

    1. Initial program 3.3%

      \[\frac{x - \sin x}{x - \tan x} \]
    2. Step-by-step derivation
      1. sub-neg3.3%

        \[\leadsto \frac{\color{blue}{x + \left(-\sin x\right)}}{x - \tan x} \]
      2. +-commutative3.3%

        \[\leadsto \frac{\color{blue}{\left(-\sin x\right) + x}}{x - \tan x} \]
      3. neg-sub03.3%

        \[\leadsto \frac{\color{blue}{\left(0 - \sin x\right)} + x}{x - \tan x} \]
      4. associate-+l-3.3%

        \[\leadsto \frac{\color{blue}{0 - \left(\sin x - x\right)}}{x - \tan x} \]
      5. sub0-neg3.3%

        \[\leadsto \frac{\color{blue}{-\left(\sin x - x\right)}}{x - \tan x} \]
      6. neg-mul-13.3%

        \[\leadsto \frac{\color{blue}{-1 \cdot \left(\sin x - x\right)}}{x - \tan x} \]
      7. sub-neg3.3%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{x + \left(-\tan x\right)}} \]
      8. +-commutative3.3%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{\left(-\tan x\right) + x}} \]
      9. neg-sub03.3%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{\left(0 - \tan x\right)} + x} \]
      10. associate-+l-3.3%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{0 - \left(\tan x - x\right)}} \]
      11. sub0-neg3.3%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{-\left(\tan x - x\right)}} \]
      12. neg-mul-13.3%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{-1 \cdot \left(\tan x - x\right)}} \]
      13. times-frac3.3%

        \[\leadsto \color{blue}{\frac{-1}{-1} \cdot \frac{\sin x - x}{\tan x - x}} \]
      14. metadata-eval3.3%

        \[\leadsto \color{blue}{1} \cdot \frac{\sin x - x}{\tan x - x} \]
      15. *-lft-identity3.3%

        \[\leadsto \color{blue}{\frac{\sin x - x}{\tan x - x}} \]
    3. Simplified3.3%

      \[\leadsto \color{blue}{\frac{\sin x - x}{\tan x - x}} \]
    4. Taylor expanded in x around 0 98.9%

      \[\leadsto \color{blue}{0.225 \cdot {x}^{2} - 0.5} \]
    5. Step-by-step derivation
      1. fma-neg98.9%

        \[\leadsto \color{blue}{\mathsf{fma}\left(0.225, {x}^{2}, -0.5\right)} \]
      2. unpow298.9%

        \[\leadsto \mathsf{fma}\left(0.225, \color{blue}{x \cdot x}, -0.5\right) \]
      3. metadata-eval98.9%

        \[\leadsto \mathsf{fma}\left(0.225, x \cdot x, \color{blue}{-0.5}\right) \]
    6. Simplified98.9%

      \[\leadsto \color{blue}{\mathsf{fma}\left(0.225, x \cdot x, -0.5\right)} \]
    7. Step-by-step derivation
      1. fma-udef98.9%

        \[\leadsto \color{blue}{0.225 \cdot \left(x \cdot x\right) + -0.5} \]
    8. Applied egg-rr98.9%

      \[\leadsto \color{blue}{0.225 \cdot \left(x \cdot x\right) + -0.5} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification98.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.6:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 2.5:\\ \;\;\;\;-0.5 + 0.225 \cdot \left(x \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]

Alternative 7: 98.5% accurate, 40.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1.6:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 1.6:\\ \;\;\;\;-0.5\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \end{array} \]
(FPCore (x) :precision binary64 (if (<= x -1.6) 1.0 (if (<= x 1.6) -0.5 1.0)))
double code(double x) {
	double tmp;
	if (x <= -1.6) {
		tmp = 1.0;
	} else if (x <= 1.6) {
		tmp = -0.5;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
real(8) function code(x)
    real(8), intent (in) :: x
    real(8) :: tmp
    if (x <= (-1.6d0)) then
        tmp = 1.0d0
    else if (x <= 1.6d0) then
        tmp = -0.5d0
    else
        tmp = 1.0d0
    end if
    code = tmp
end function
public static double code(double x) {
	double tmp;
	if (x <= -1.6) {
		tmp = 1.0;
	} else if (x <= 1.6) {
		tmp = -0.5;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
def code(x):
	tmp = 0
	if x <= -1.6:
		tmp = 1.0
	elif x <= 1.6:
		tmp = -0.5
	else:
		tmp = 1.0
	return tmp
function code(x)
	tmp = 0.0
	if (x <= -1.6)
		tmp = 1.0;
	elseif (x <= 1.6)
		tmp = -0.5;
	else
		tmp = 1.0;
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = 0.0;
	if (x <= -1.6)
		tmp = 1.0;
	elseif (x <= 1.6)
		tmp = -0.5;
	else
		tmp = 1.0;
	end
	tmp_2 = tmp;
end
code[x_] := If[LessEqual[x, -1.6], 1.0, If[LessEqual[x, 1.6], -0.5, 1.0]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.6:\\
\;\;\;\;1\\

\mathbf{elif}\;x \leq 1.6:\\
\;\;\;\;-0.5\\

\mathbf{else}:\\
\;\;\;\;1\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.6000000000000001 or 1.6000000000000001 < x

    1. Initial program 100.0%

      \[\frac{x - \sin x}{x - \tan x} \]
    2. Step-by-step derivation
      1. sub-neg100.0%

        \[\leadsto \frac{\color{blue}{x + \left(-\sin x\right)}}{x - \tan x} \]
      2. +-commutative100.0%

        \[\leadsto \frac{\color{blue}{\left(-\sin x\right) + x}}{x - \tan x} \]
      3. neg-sub0100.0%

        \[\leadsto \frac{\color{blue}{\left(0 - \sin x\right)} + x}{x - \tan x} \]
      4. associate-+l-100.0%

        \[\leadsto \frac{\color{blue}{0 - \left(\sin x - x\right)}}{x - \tan x} \]
      5. sub0-neg100.0%

        \[\leadsto \frac{\color{blue}{-\left(\sin x - x\right)}}{x - \tan x} \]
      6. neg-mul-1100.0%

        \[\leadsto \frac{\color{blue}{-1 \cdot \left(\sin x - x\right)}}{x - \tan x} \]
      7. sub-neg100.0%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{x + \left(-\tan x\right)}} \]
      8. +-commutative100.0%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{\left(-\tan x\right) + x}} \]
      9. neg-sub0100.0%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{\left(0 - \tan x\right)} + x} \]
      10. associate-+l-100.0%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{0 - \left(\tan x - x\right)}} \]
      11. sub0-neg100.0%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{-\left(\tan x - x\right)}} \]
      12. neg-mul-1100.0%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{-1 \cdot \left(\tan x - x\right)}} \]
      13. times-frac100.0%

        \[\leadsto \color{blue}{\frac{-1}{-1} \cdot \frac{\sin x - x}{\tan x - x}} \]
      14. metadata-eval100.0%

        \[\leadsto \color{blue}{1} \cdot \frac{\sin x - x}{\tan x - x} \]
      15. *-lft-identity100.0%

        \[\leadsto \color{blue}{\frac{\sin x - x}{\tan x - x}} \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\frac{\sin x - x}{\tan x - x}} \]
    4. Taylor expanded in x around inf 98.3%

      \[\leadsto \color{blue}{1} \]

    if -1.6000000000000001 < x < 1.6000000000000001

    1. Initial program 3.3%

      \[\frac{x - \sin x}{x - \tan x} \]
    2. Step-by-step derivation
      1. sub-neg3.3%

        \[\leadsto \frac{\color{blue}{x + \left(-\sin x\right)}}{x - \tan x} \]
      2. +-commutative3.3%

        \[\leadsto \frac{\color{blue}{\left(-\sin x\right) + x}}{x - \tan x} \]
      3. neg-sub03.3%

        \[\leadsto \frac{\color{blue}{\left(0 - \sin x\right)} + x}{x - \tan x} \]
      4. associate-+l-3.3%

        \[\leadsto \frac{\color{blue}{0 - \left(\sin x - x\right)}}{x - \tan x} \]
      5. sub0-neg3.3%

        \[\leadsto \frac{\color{blue}{-\left(\sin x - x\right)}}{x - \tan x} \]
      6. neg-mul-13.3%

        \[\leadsto \frac{\color{blue}{-1 \cdot \left(\sin x - x\right)}}{x - \tan x} \]
      7. sub-neg3.3%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{x + \left(-\tan x\right)}} \]
      8. +-commutative3.3%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{\left(-\tan x\right) + x}} \]
      9. neg-sub03.3%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{\left(0 - \tan x\right)} + x} \]
      10. associate-+l-3.3%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{0 - \left(\tan x - x\right)}} \]
      11. sub0-neg3.3%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{-\left(\tan x - x\right)}} \]
      12. neg-mul-13.3%

        \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{-1 \cdot \left(\tan x - x\right)}} \]
      13. times-frac3.3%

        \[\leadsto \color{blue}{\frac{-1}{-1} \cdot \frac{\sin x - x}{\tan x - x}} \]
      14. metadata-eval3.3%

        \[\leadsto \color{blue}{1} \cdot \frac{\sin x - x}{\tan x - x} \]
      15. *-lft-identity3.3%

        \[\leadsto \color{blue}{\frac{\sin x - x}{\tan x - x}} \]
    3. Simplified3.3%

      \[\leadsto \color{blue}{\frac{\sin x - x}{\tan x - x}} \]
    4. Taylor expanded in x around 0 98.0%

      \[\leadsto \color{blue}{-0.5} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification98.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.6:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 1.6:\\ \;\;\;\;-0.5\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]

Alternative 8: 50.7% accurate, 207.0× speedup?

\[\begin{array}{l} \\ -0.5 \end{array} \]
(FPCore (x) :precision binary64 -0.5)
double code(double x) {
	return -0.5;
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = -0.5d0
end function
public static double code(double x) {
	return -0.5;
}
def code(x):
	return -0.5
function code(x)
	return -0.5
end
function tmp = code(x)
	tmp = -0.5;
end
code[x_] := -0.5
\begin{array}{l}

\\
-0.5
\end{array}
Derivation
  1. Initial program 52.0%

    \[\frac{x - \sin x}{x - \tan x} \]
  2. Step-by-step derivation
    1. sub-neg52.0%

      \[\leadsto \frac{\color{blue}{x + \left(-\sin x\right)}}{x - \tan x} \]
    2. +-commutative52.0%

      \[\leadsto \frac{\color{blue}{\left(-\sin x\right) + x}}{x - \tan x} \]
    3. neg-sub052.0%

      \[\leadsto \frac{\color{blue}{\left(0 - \sin x\right)} + x}{x - \tan x} \]
    4. associate-+l-52.0%

      \[\leadsto \frac{\color{blue}{0 - \left(\sin x - x\right)}}{x - \tan x} \]
    5. sub0-neg52.0%

      \[\leadsto \frac{\color{blue}{-\left(\sin x - x\right)}}{x - \tan x} \]
    6. neg-mul-152.0%

      \[\leadsto \frac{\color{blue}{-1 \cdot \left(\sin x - x\right)}}{x - \tan x} \]
    7. sub-neg52.0%

      \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{x + \left(-\tan x\right)}} \]
    8. +-commutative52.0%

      \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{\left(-\tan x\right) + x}} \]
    9. neg-sub052.0%

      \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{\left(0 - \tan x\right)} + x} \]
    10. associate-+l-52.0%

      \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{0 - \left(\tan x - x\right)}} \]
    11. sub0-neg52.0%

      \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{-\left(\tan x - x\right)}} \]
    12. neg-mul-152.0%

      \[\leadsto \frac{-1 \cdot \left(\sin x - x\right)}{\color{blue}{-1 \cdot \left(\tan x - x\right)}} \]
    13. times-frac52.0%

      \[\leadsto \color{blue}{\frac{-1}{-1} \cdot \frac{\sin x - x}{\tan x - x}} \]
    14. metadata-eval52.0%

      \[\leadsto \color{blue}{1} \cdot \frac{\sin x - x}{\tan x - x} \]
    15. *-lft-identity52.0%

      \[\leadsto \color{blue}{\frac{\sin x - x}{\tan x - x}} \]
  3. Simplified52.0%

    \[\leadsto \color{blue}{\frac{\sin x - x}{\tan x - x}} \]
  4. Taylor expanded in x around 0 49.4%

    \[\leadsto \color{blue}{-0.5} \]
  5. Final simplification49.4%

    \[\leadsto -0.5 \]

Reproduce

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