sintan (problem 3.4.5)

Percentage Accurate: 50.8% → 99.7%
Time: 15.7s
Alternatives: 10
Speedup: 40.4×

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 10 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.8% 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.7% accurate, 0.4× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;0.225 \cdot \left(x \cdot x\right) + -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.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\sin x}{\tan x - x} - \frac{x}{\tan 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.225 \cdot {x}^{2} - 0.5} \]
    5. Step-by-step derivation
      1. fma-neg100.0%

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

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

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

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

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

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

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

Alternative 2: 99.7% 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.225 \cdot \left(x \cdot x\right) + -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.225 (* x x)) -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.225 * (x * x)) + -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.225d0 * (x * x)) + (-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.225 * (x * x)) + -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.225 * (x * x)) + -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 = Float64(Float64(0.225 * Float64(x * x)) + -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.225 * (x * x)) + -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, N[(N[(0.225 * N[(x * x), $MachinePrecision]), $MachinePrecision] + -0.5), $MachinePrecision]]]
\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.225 \cdot \left(x \cdot x\right) + -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.6%

      \[\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.225 \cdot {x}^{2} - 0.5} \]
    5. Step-by-step derivation
      1. fma-neg100.0%

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

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

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

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

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

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

    \[\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.225 \cdot \left(x \cdot x\right) + -0.5\\ \end{array} \]

Alternative 3: 99.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -2.6 \lor \neg \left(x \leq 2.6\right):\\ \;\;\;\;1 + \frac{\tan x - \sin x}{x}\\ \mathbf{else}:\\ \;\;\;\;-0.5 + \left(0.225 \cdot \left(x \cdot x\right) + -0.009642857142857142 \cdot {x}^{4}\right)\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (or (<= x -2.6) (not (<= x 2.6)))
   (+ 1.0 (/ (- (tan x) (sin x)) x))
   (+ -0.5 (+ (* 0.225 (* x x)) (* -0.009642857142857142 (pow x 4.0))))))
double code(double x) {
	double tmp;
	if ((x <= -2.6) || !(x <= 2.6)) {
		tmp = 1.0 + ((tan(x) - sin(x)) / x);
	} else {
		tmp = -0.5 + ((0.225 * (x * x)) + (-0.009642857142857142 * pow(x, 4.0)));
	}
	return tmp;
}
real(8) function code(x)
    real(8), intent (in) :: x
    real(8) :: tmp
    if ((x <= (-2.6d0)) .or. (.not. (x <= 2.6d0))) then
        tmp = 1.0d0 + ((tan(x) - sin(x)) / x)
    else
        tmp = (-0.5d0) + ((0.225d0 * (x * x)) + ((-0.009642857142857142d0) * (x ** 4.0d0)))
    end if
    code = tmp
end function
public static double code(double x) {
	double tmp;
	if ((x <= -2.6) || !(x <= 2.6)) {
		tmp = 1.0 + ((Math.tan(x) - Math.sin(x)) / x);
	} else {
		tmp = -0.5 + ((0.225 * (x * x)) + (-0.009642857142857142 * Math.pow(x, 4.0)));
	}
	return tmp;
}
def code(x):
	tmp = 0
	if (x <= -2.6) or not (x <= 2.6):
		tmp = 1.0 + ((math.tan(x) - math.sin(x)) / x)
	else:
		tmp = -0.5 + ((0.225 * (x * x)) + (-0.009642857142857142 * math.pow(x, 4.0)))
	return tmp
function code(x)
	tmp = 0.0
	if ((x <= -2.6) || !(x <= 2.6))
		tmp = Float64(1.0 + Float64(Float64(tan(x) - sin(x)) / x));
	else
		tmp = Float64(-0.5 + Float64(Float64(0.225 * Float64(x * x)) + Float64(-0.009642857142857142 * (x ^ 4.0))));
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = 0.0;
	if ((x <= -2.6) || ~((x <= 2.6)))
		tmp = 1.0 + ((tan(x) - sin(x)) / x);
	else
		tmp = -0.5 + ((0.225 * (x * x)) + (-0.009642857142857142 * (x ^ 4.0)));
	end
	tmp_2 = tmp;
end
code[x_] := If[Or[LessEqual[x, -2.6], N[Not[LessEqual[x, 2.6]], $MachinePrecision]], N[(1.0 + N[(N[(N[Tan[x], $MachinePrecision] - N[Sin[x], $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], N[(-0.5 + N[(N[(0.225 * N[(x * x), $MachinePrecision]), $MachinePrecision] + N[(-0.009642857142857142 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.6 \lor \neg \left(x \leq 2.6\right):\\
\;\;\;\;1 + \frac{\tan x - \sin x}{x}\\

\mathbf{else}:\\
\;\;\;\;-0.5 + \left(0.225 \cdot \left(x \cdot x\right) + -0.009642857142857142 \cdot {x}^{4}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -2.60000000000000009 or 2.60000000000000009 < 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 99.3%

      \[\leadsto \color{blue}{\left(1 + -1 \cdot \frac{\sin x}{x}\right) - -1 \cdot \frac{\sin x}{\cos x \cdot x}} \]
    5. Step-by-step derivation
      1. associate--l+99.3%

        \[\leadsto \color{blue}{1 + \left(-1 \cdot \frac{\sin x}{x} - -1 \cdot \frac{\sin x}{\cos x \cdot x}\right)} \]
      2. associate-*r/99.3%

        \[\leadsto 1 + \left(\color{blue}{\frac{-1 \cdot \sin x}{x}} - -1 \cdot \frac{\sin x}{\cos x \cdot x}\right) \]
      3. associate-/r*99.3%

        \[\leadsto 1 + \left(\frac{-1 \cdot \sin x}{x} - -1 \cdot \color{blue}{\frac{\frac{\sin x}{\cos x}}{x}}\right) \]
      4. associate-*r/99.3%

        \[\leadsto 1 + \left(\frac{-1 \cdot \sin x}{x} - \color{blue}{\frac{-1 \cdot \frac{\sin x}{\cos x}}{x}}\right) \]
      5. div-sub99.3%

        \[\leadsto 1 + \color{blue}{\frac{-1 \cdot \sin x - -1 \cdot \frac{\sin x}{\cos x}}{x}} \]
      6. distribute-lft-out--99.3%

        \[\leadsto 1 + \frac{\color{blue}{-1 \cdot \left(\sin x - \frac{\sin x}{\cos x}\right)}}{x} \]
      7. associate-*r/99.3%

        \[\leadsto 1 + \color{blue}{-1 \cdot \frac{\sin x - \frac{\sin x}{\cos x}}{x}} \]
      8. mul-1-neg99.3%

        \[\leadsto 1 + \color{blue}{\left(-\frac{\sin x - \frac{\sin x}{\cos x}}{x}\right)} \]
      9. unsub-neg99.3%

        \[\leadsto \color{blue}{1 - \frac{\sin x - \frac{\sin x}{\cos x}}{x}} \]
    6. Simplified99.3%

      \[\leadsto \color{blue}{1 - \frac{\sin x - \frac{\sin x}{\cos x}}{x}} \]
    7. Step-by-step derivation
      1. tan-quot99.3%

        \[\leadsto 1 - \frac{\sin x - \color{blue}{\tan x}}{x} \]
      2. sub-neg99.3%

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

      \[\leadsto 1 - \frac{\color{blue}{\sin x + \left(-\tan x\right)}}{x} \]
    9. Step-by-step derivation
      1. sub-neg99.3%

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

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

    if -2.60000000000000009 < x < 2.60000000000000009

    1. Initial program 1.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(0.225 \cdot {x}^{2} + -0.009642857142857142 \cdot {x}^{4}\right) - 0.5} \]
    5. Step-by-step derivation
      1. sub-neg99.8%

        \[\leadsto \color{blue}{\left(0.225 \cdot {x}^{2} + -0.009642857142857142 \cdot {x}^{4}\right) + \left(-0.5\right)} \]
      2. fma-def99.8%

        \[\leadsto \color{blue}{\mathsf{fma}\left(0.225, {x}^{2}, -0.009642857142857142 \cdot {x}^{4}\right)} + \left(-0.5\right) \]
      3. unpow299.8%

        \[\leadsto \mathsf{fma}\left(0.225, \color{blue}{x \cdot x}, -0.009642857142857142 \cdot {x}^{4}\right) + \left(-0.5\right) \]
      4. metadata-eval99.8%

        \[\leadsto \mathsf{fma}\left(0.225, x \cdot x, -0.009642857142857142 \cdot {x}^{4}\right) + \color{blue}{-0.5} \]
    6. Simplified99.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(0.225, x \cdot x, -0.009642857142857142 \cdot {x}^{4}\right) + -0.5} \]
    7. Step-by-step derivation
      1. fma-udef99.8%

        \[\leadsto \color{blue}{\left(0.225 \cdot \left(x \cdot x\right) + -0.009642857142857142 \cdot {x}^{4}\right)} + -0.5 \]
    8. Applied egg-rr99.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.6 \lor \neg \left(x \leq 2.6\right):\\ \;\;\;\;1 + \frac{\tan x - \sin x}{x}\\ \mathbf{else}:\\ \;\;\;\;-0.5 + \left(0.225 \cdot \left(x \cdot x\right) + -0.009642857142857142 \cdot {x}^{4}\right)\\ \end{array} \]

Alternative 4: 98.9% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.6:\\
\;\;\;\;{x}^{-2} \cdot -3 - -1\\

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

\mathbf{else}:\\
\;\;\;\;\frac{x + \sin x}{x}\\


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

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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.6%

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

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

      \[\leadsto \color{blue}{\frac{3}{x \cdot x}} - \frac{x}{\tan x - x} \]
    9. Taylor expanded in x around inf 97.8%

      \[\leadsto \frac{3}{x \cdot x} - \color{blue}{-1} \]
    10. Step-by-step derivation
      1. frac-2neg97.8%

        \[\leadsto \color{blue}{\frac{-3}{-x \cdot x}} - -1 \]
      2. div-inv97.8%

        \[\leadsto \color{blue}{\left(-3\right) \cdot \frac{1}{-x \cdot x}} - -1 \]
      3. metadata-eval97.8%

        \[\leadsto \color{blue}{-3} \cdot \frac{1}{-x \cdot x} - -1 \]
      4. distribute-lft-neg-in97.8%

        \[\leadsto -3 \cdot \frac{1}{\color{blue}{\left(-x\right) \cdot x}} - -1 \]
      5. add-sqr-sqrt97.8%

        \[\leadsto -3 \cdot \frac{1}{\color{blue}{\left(\sqrt{-x} \cdot \sqrt{-x}\right)} \cdot x} - -1 \]
      6. sqrt-unprod97.8%

        \[\leadsto -3 \cdot \frac{1}{\color{blue}{\sqrt{\left(-x\right) \cdot \left(-x\right)}} \cdot x} - -1 \]
      7. sqr-neg97.8%

        \[\leadsto -3 \cdot \frac{1}{\sqrt{\color{blue}{x \cdot x}} \cdot x} - -1 \]
      8. sqrt-prod0.0%

        \[\leadsto -3 \cdot \frac{1}{\color{blue}{\left(\sqrt{x} \cdot \sqrt{x}\right)} \cdot x} - -1 \]
      9. add-sqr-sqrt97.8%

        \[\leadsto -3 \cdot \frac{1}{\color{blue}{x} \cdot x} - -1 \]
      10. pow297.8%

        \[\leadsto -3 \cdot \frac{1}{\color{blue}{{x}^{2}}} - -1 \]
      11. pow-flip97.8%

        \[\leadsto -3 \cdot \color{blue}{{x}^{\left(-2\right)}} - -1 \]
      12. metadata-eval97.8%

        \[\leadsto -3 \cdot {x}^{\color{blue}{-2}} - -1 \]
    11. Applied egg-rr97.8%

      \[\leadsto \color{blue}{-3 \cdot {x}^{-2}} - -1 \]
    12. Step-by-step derivation
      1. *-commutative97.8%

        \[\leadsto \color{blue}{{x}^{-2} \cdot -3} - -1 \]
    13. Simplified97.8%

      \[\leadsto \color{blue}{{x}^{-2} \cdot -3} - -1 \]

    if -3.60000000000000009 < x < 2.89999999999999991

    1. Initial program 1.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(0.225 \cdot {x}^{2} + -0.009642857142857142 \cdot {x}^{4}\right) - 0.5} \]
    5. Step-by-step derivation
      1. sub-neg99.8%

        \[\leadsto \color{blue}{\left(0.225 \cdot {x}^{2} + -0.009642857142857142 \cdot {x}^{4}\right) + \left(-0.5\right)} \]
      2. fma-def99.8%

        \[\leadsto \color{blue}{\mathsf{fma}\left(0.225, {x}^{2}, -0.009642857142857142 \cdot {x}^{4}\right)} + \left(-0.5\right) \]
      3. unpow299.8%

        \[\leadsto \mathsf{fma}\left(0.225, \color{blue}{x \cdot x}, -0.009642857142857142 \cdot {x}^{4}\right) + \left(-0.5\right) \]
      4. metadata-eval99.8%

        \[\leadsto \mathsf{fma}\left(0.225, x \cdot x, -0.009642857142857142 \cdot {x}^{4}\right) + \color{blue}{-0.5} \]
    6. Simplified99.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(0.225, x \cdot x, -0.009642857142857142 \cdot {x}^{4}\right) + -0.5} \]
    7. Step-by-step derivation
      1. fma-udef99.8%

        \[\leadsto \color{blue}{\left(0.225 \cdot \left(x \cdot x\right) + -0.009642857142857142 \cdot {x}^{4}\right)} + -0.5 \]
    8. Applied egg-rr99.8%

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

    if 2.89999999999999991 < 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 99.0%

      \[\leadsto \frac{\sin x - x}{\color{blue}{-1 \cdot x}} \]
    5. Step-by-step derivation
      1. neg-mul-199.0%

        \[\leadsto \frac{\sin x - x}{\color{blue}{-x}} \]
    6. Simplified99.0%

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

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\sin x - x}{-x}\right)\right)} \]
      2. expm1-udef99.0%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{\sin x - x}{-x}\right)} - 1} \]
      3. sub-neg99.0%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{\sin x + \left(-x\right)}}{-x}\right)} - 1 \]
      4. add-sqr-sqrt0.0%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\sin x + \color{blue}{\sqrt{-x} \cdot \sqrt{-x}}}{-x}\right)} - 1 \]
      5. sqrt-unprod0.7%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\sin x + \color{blue}{\sqrt{\left(-x\right) \cdot \left(-x\right)}}}{-x}\right)} - 1 \]
      6. sqr-neg0.7%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\sin x + \sqrt{\color{blue}{x \cdot x}}}{-x}\right)} - 1 \]
      7. sqrt-prod1.1%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\sin x + \color{blue}{\sqrt{x} \cdot \sqrt{x}}}{-x}\right)} - 1 \]
      8. add-sqr-sqrt1.5%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\sin x + \color{blue}{x}}{-x}\right)} - 1 \]
      9. add-sqr-sqrt0.0%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\sin x + x}{\color{blue}{\sqrt{-x} \cdot \sqrt{-x}}}\right)} - 1 \]
      10. sqrt-unprod48.7%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\sin x + x}{\color{blue}{\sqrt{\left(-x\right) \cdot \left(-x\right)}}}\right)} - 1 \]
      11. sqr-neg48.7%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\sin x + x}{\sqrt{\color{blue}{x \cdot x}}}\right)} - 1 \]
      12. sqrt-prod98.8%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\sin x + x}{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}\right)} - 1 \]
      13. add-sqr-sqrt99.1%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\sin x + x}{\color{blue}{x}}\right)} - 1 \]
    8. Applied egg-rr99.1%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{\sin x + x}{x}\right)} - 1} \]
    9. Step-by-step derivation
      1. expm1-def99.1%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\sin x + x}{x}\right)\right)} \]
      2. expm1-log1p99.1%

        \[\leadsto \color{blue}{\frac{\sin x + x}{x}} \]
      3. +-commutative99.1%

        \[\leadsto \frac{\color{blue}{x + \sin x}}{x} \]
    10. Simplified99.1%

      \[\leadsto \color{blue}{\frac{x + \sin x}{x}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification99.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -3.6:\\ \;\;\;\;{x}^{-2} \cdot -3 - -1\\ \mathbf{elif}\;x \leq 2.9:\\ \;\;\;\;-0.5 + \left(0.225 \cdot \left(x \cdot x\right) + -0.009642857142857142 \cdot {x}^{4}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x + \sin x}{x}\\ \end{array} \]

Alternative 5: 98.8% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -2.6:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 2.7:\\ \;\;\;\;0.225 \cdot \left(x \cdot x\right) + -0.5\\ \mathbf{else}:\\ \;\;\;\;\frac{x + \sin x}{x}\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= x -2.6)
   1.0
   (if (<= x 2.7) (+ (* 0.225 (* x x)) -0.5) (/ (+ x (sin x)) x))))
double code(double x) {
	double tmp;
	if (x <= -2.6) {
		tmp = 1.0;
	} else if (x <= 2.7) {
		tmp = (0.225 * (x * x)) + -0.5;
	} else {
		tmp = (x + sin(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.7d0) then
        tmp = (0.225d0 * (x * x)) + (-0.5d0)
    else
        tmp = (x + sin(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.7) {
		tmp = (0.225 * (x * x)) + -0.5;
	} else {
		tmp = (x + Math.sin(x)) / x;
	}
	return tmp;
}
def code(x):
	tmp = 0
	if x <= -2.6:
		tmp = 1.0
	elif x <= 2.7:
		tmp = (0.225 * (x * x)) + -0.5
	else:
		tmp = (x + math.sin(x)) / x
	return tmp
function code(x)
	tmp = 0.0
	if (x <= -2.6)
		tmp = 1.0;
	elseif (x <= 2.7)
		tmp = Float64(Float64(0.225 * Float64(x * x)) + -0.5);
	else
		tmp = Float64(Float64(x + sin(x)) / x);
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = 0.0;
	if (x <= -2.6)
		tmp = 1.0;
	elseif (x <= 2.7)
		tmp = (0.225 * (x * x)) + -0.5;
	else
		tmp = (x + sin(x)) / x;
	end
	tmp_2 = tmp;
end
code[x_] := If[LessEqual[x, -2.6], 1.0, If[LessEqual[x, 2.7], N[(N[(0.225 * N[(x * x), $MachinePrecision]), $MachinePrecision] + -0.5), $MachinePrecision], N[(N[(x + N[Sin[x], $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]]]
\begin{array}{l}

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

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

\mathbf{else}:\\
\;\;\;\;\frac{x + \sin x}{x}\\


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

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.60000000000000009 < x < 2.7000000000000002

    1. Initial program 1.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.7000000000000002 < 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 99.0%

      \[\leadsto \frac{\sin x - x}{\color{blue}{-1 \cdot x}} \]
    5. Step-by-step derivation
      1. neg-mul-199.0%

        \[\leadsto \frac{\sin x - x}{\color{blue}{-x}} \]
    6. Simplified99.0%

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

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\sin x - x}{-x}\right)\right)} \]
      2. expm1-udef99.0%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{\sin x - x}{-x}\right)} - 1} \]
      3. sub-neg99.0%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{\sin x + \left(-x\right)}}{-x}\right)} - 1 \]
      4. add-sqr-sqrt0.0%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\sin x + \color{blue}{\sqrt{-x} \cdot \sqrt{-x}}}{-x}\right)} - 1 \]
      5. sqrt-unprod0.7%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\sin x + \color{blue}{\sqrt{\left(-x\right) \cdot \left(-x\right)}}}{-x}\right)} - 1 \]
      6. sqr-neg0.7%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\sin x + \sqrt{\color{blue}{x \cdot x}}}{-x}\right)} - 1 \]
      7. sqrt-prod1.1%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\sin x + \color{blue}{\sqrt{x} \cdot \sqrt{x}}}{-x}\right)} - 1 \]
      8. add-sqr-sqrt1.5%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\sin x + \color{blue}{x}}{-x}\right)} - 1 \]
      9. add-sqr-sqrt0.0%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\sin x + x}{\color{blue}{\sqrt{-x} \cdot \sqrt{-x}}}\right)} - 1 \]
      10. sqrt-unprod48.7%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\sin x + x}{\color{blue}{\sqrt{\left(-x\right) \cdot \left(-x\right)}}}\right)} - 1 \]
      11. sqr-neg48.7%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\sin x + x}{\sqrt{\color{blue}{x \cdot x}}}\right)} - 1 \]
      12. sqrt-prod98.8%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\sin x + x}{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}\right)} - 1 \]
      13. add-sqr-sqrt99.1%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\sin x + x}{\color{blue}{x}}\right)} - 1 \]
    8. Applied egg-rr99.1%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{\sin x + x}{x}\right)} - 1} \]
    9. Step-by-step derivation
      1. expm1-def99.1%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\sin x + x}{x}\right)\right)} \]
      2. expm1-log1p99.1%

        \[\leadsto \color{blue}{\frac{\sin x + x}{x}} \]
      3. +-commutative99.1%

        \[\leadsto \frac{\color{blue}{x + \sin x}}{x} \]
    10. Simplified99.1%

      \[\leadsto \color{blue}{\frac{x + \sin x}{x}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification99.0%

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

Alternative 6: 98.8% accurate, 1.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.85:\\
\;\;\;\;{x}^{-2} \cdot -3 - -1\\

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

\mathbf{else}:\\
\;\;\;\;\frac{x + \sin x}{x}\\


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

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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.6%

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

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

      \[\leadsto \color{blue}{\frac{3}{x \cdot x}} - \frac{x}{\tan x - x} \]
    9. Taylor expanded in x around inf 97.8%

      \[\leadsto \frac{3}{x \cdot x} - \color{blue}{-1} \]
    10. Step-by-step derivation
      1. frac-2neg97.8%

        \[\leadsto \color{blue}{\frac{-3}{-x \cdot x}} - -1 \]
      2. div-inv97.8%

        \[\leadsto \color{blue}{\left(-3\right) \cdot \frac{1}{-x \cdot x}} - -1 \]
      3. metadata-eval97.8%

        \[\leadsto \color{blue}{-3} \cdot \frac{1}{-x \cdot x} - -1 \]
      4. distribute-lft-neg-in97.8%

        \[\leadsto -3 \cdot \frac{1}{\color{blue}{\left(-x\right) \cdot x}} - -1 \]
      5. add-sqr-sqrt97.8%

        \[\leadsto -3 \cdot \frac{1}{\color{blue}{\left(\sqrt{-x} \cdot \sqrt{-x}\right)} \cdot x} - -1 \]
      6. sqrt-unprod97.8%

        \[\leadsto -3 \cdot \frac{1}{\color{blue}{\sqrt{\left(-x\right) \cdot \left(-x\right)}} \cdot x} - -1 \]
      7. sqr-neg97.8%

        \[\leadsto -3 \cdot \frac{1}{\sqrt{\color{blue}{x \cdot x}} \cdot x} - -1 \]
      8. sqrt-prod0.0%

        \[\leadsto -3 \cdot \frac{1}{\color{blue}{\left(\sqrt{x} \cdot \sqrt{x}\right)} \cdot x} - -1 \]
      9. add-sqr-sqrt97.8%

        \[\leadsto -3 \cdot \frac{1}{\color{blue}{x} \cdot x} - -1 \]
      10. pow297.8%

        \[\leadsto -3 \cdot \frac{1}{\color{blue}{{x}^{2}}} - -1 \]
      11. pow-flip97.8%

        \[\leadsto -3 \cdot \color{blue}{{x}^{\left(-2\right)}} - -1 \]
      12. metadata-eval97.8%

        \[\leadsto -3 \cdot {x}^{\color{blue}{-2}} - -1 \]
    11. Applied egg-rr97.8%

      \[\leadsto \color{blue}{-3 \cdot {x}^{-2}} - -1 \]
    12. Step-by-step derivation
      1. *-commutative97.8%

        \[\leadsto \color{blue}{{x}^{-2} \cdot -3} - -1 \]
    13. Simplified97.8%

      \[\leadsto \color{blue}{{x}^{-2} \cdot -3} - -1 \]

    if -1.8500000000000001 < x < 2.7000000000000002

    1. Initial program 1.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.7000000000000002 < 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 99.0%

      \[\leadsto \frac{\sin x - x}{\color{blue}{-1 \cdot x}} \]
    5. Step-by-step derivation
      1. neg-mul-199.0%

        \[\leadsto \frac{\sin x - x}{\color{blue}{-x}} \]
    6. Simplified99.0%

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

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\sin x - x}{-x}\right)\right)} \]
      2. expm1-udef99.0%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{\sin x - x}{-x}\right)} - 1} \]
      3. sub-neg99.0%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{\sin x + \left(-x\right)}}{-x}\right)} - 1 \]
      4. add-sqr-sqrt0.0%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\sin x + \color{blue}{\sqrt{-x} \cdot \sqrt{-x}}}{-x}\right)} - 1 \]
      5. sqrt-unprod0.7%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\sin x + \color{blue}{\sqrt{\left(-x\right) \cdot \left(-x\right)}}}{-x}\right)} - 1 \]
      6. sqr-neg0.7%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\sin x + \sqrt{\color{blue}{x \cdot x}}}{-x}\right)} - 1 \]
      7. sqrt-prod1.1%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\sin x + \color{blue}{\sqrt{x} \cdot \sqrt{x}}}{-x}\right)} - 1 \]
      8. add-sqr-sqrt1.5%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\sin x + \color{blue}{x}}{-x}\right)} - 1 \]
      9. add-sqr-sqrt0.0%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\sin x + x}{\color{blue}{\sqrt{-x} \cdot \sqrt{-x}}}\right)} - 1 \]
      10. sqrt-unprod48.7%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\sin x + x}{\color{blue}{\sqrt{\left(-x\right) \cdot \left(-x\right)}}}\right)} - 1 \]
      11. sqr-neg48.7%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\sin x + x}{\sqrt{\color{blue}{x \cdot x}}}\right)} - 1 \]
      12. sqrt-prod98.8%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\sin x + x}{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}\right)} - 1 \]
      13. add-sqr-sqrt99.1%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\sin x + x}{\color{blue}{x}}\right)} - 1 \]
    8. Applied egg-rr99.1%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{\sin x + x}{x}\right)} - 1} \]
    9. Step-by-step derivation
      1. expm1-def99.1%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\sin x + x}{x}\right)\right)} \]
      2. expm1-log1p99.1%

        \[\leadsto \color{blue}{\frac{\sin x + x}{x}} \]
      3. +-commutative99.1%

        \[\leadsto \frac{\color{blue}{x + \sin x}}{x} \]
    10. Simplified99.1%

      \[\leadsto \color{blue}{\frac{x + \sin x}{x}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification99.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.85:\\ \;\;\;\;{x}^{-2} \cdot -3 - -1\\ \mathbf{elif}\;x \leq 2.7:\\ \;\;\;\;0.225 \cdot \left(x \cdot x\right) + -0.5\\ \mathbf{else}:\\ \;\;\;\;\frac{x + \sin x}{x}\\ \end{array} \]

Alternative 7: 98.8% accurate, 18.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -2.6:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 2.55:\\ \;\;\;\;0.225 \cdot \left(x \cdot x\right) + -0.5\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= x -2.6) 1.0 (if (<= x 2.55) (+ (* 0.225 (* x x)) -0.5) 1.0)))
double code(double x) {
	double tmp;
	if (x <= -2.6) {
		tmp = 1.0;
	} else if (x <= 2.55) {
		tmp = (0.225 * (x * x)) + -0.5;
	} 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.55d0) then
        tmp = (0.225d0 * (x * x)) + (-0.5d0)
    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.55) {
		tmp = (0.225 * (x * x)) + -0.5;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
def code(x):
	tmp = 0
	if x <= -2.6:
		tmp = 1.0
	elif x <= 2.55:
		tmp = (0.225 * (x * x)) + -0.5
	else:
		tmp = 1.0
	return tmp
function code(x)
	tmp = 0.0
	if (x <= -2.6)
		tmp = 1.0;
	elseif (x <= 2.55)
		tmp = Float64(Float64(0.225 * Float64(x * x)) + -0.5);
	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.55)
		tmp = (0.225 * (x * x)) + -0.5;
	else
		tmp = 1.0;
	end
	tmp_2 = tmp;
end
code[x_] := If[LessEqual[x, -2.6], 1.0, If[LessEqual[x, 2.55], N[(N[(0.225 * N[(x * x), $MachinePrecision]), $MachinePrecision] + -0.5), $MachinePrecision], 1.0]]
\begin{array}{l}

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -2.60000000000000009 or 2.5499999999999998 < 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.5%

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

    if -2.60000000000000009 < x < 2.5499999999999998

    1. Initial program 1.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 98.8% accurate, 18.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -2.6:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 2.85:\\ \;\;\;\;0.225 \cdot \left(x \cdot x\right) + -0.5\\ \mathbf{else}:\\ \;\;\;\;\frac{3}{x \cdot x} - -1\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= x -2.6)
   1.0
   (if (<= x 2.85) (+ (* 0.225 (* x x)) -0.5) (- (/ 3.0 (* x x)) -1.0))))
double code(double x) {
	double tmp;
	if (x <= -2.6) {
		tmp = 1.0;
	} else if (x <= 2.85) {
		tmp = (0.225 * (x * x)) + -0.5;
	} else {
		tmp = (3.0 / (x * x)) - -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.85d0) then
        tmp = (0.225d0 * (x * x)) + (-0.5d0)
    else
        tmp = (3.0d0 / (x * x)) - (-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.85) {
		tmp = (0.225 * (x * x)) + -0.5;
	} else {
		tmp = (3.0 / (x * x)) - -1.0;
	}
	return tmp;
}
def code(x):
	tmp = 0
	if x <= -2.6:
		tmp = 1.0
	elif x <= 2.85:
		tmp = (0.225 * (x * x)) + -0.5
	else:
		tmp = (3.0 / (x * x)) - -1.0
	return tmp
function code(x)
	tmp = 0.0
	if (x <= -2.6)
		tmp = 1.0;
	elseif (x <= 2.85)
		tmp = Float64(Float64(0.225 * Float64(x * x)) + -0.5);
	else
		tmp = Float64(Float64(3.0 / Float64(x * x)) - -1.0);
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = 0.0;
	if (x <= -2.6)
		tmp = 1.0;
	elseif (x <= 2.85)
		tmp = (0.225 * (x * x)) + -0.5;
	else
		tmp = (3.0 / (x * x)) - -1.0;
	end
	tmp_2 = tmp;
end
code[x_] := If[LessEqual[x, -2.6], 1.0, If[LessEqual[x, 2.85], N[(N[(0.225 * N[(x * x), $MachinePrecision]), $MachinePrecision] + -0.5), $MachinePrecision], N[(N[(3.0 / N[(x * x), $MachinePrecision]), $MachinePrecision] - -1.0), $MachinePrecision]]]
\begin{array}{l}

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

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

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


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

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.60000000000000009 < x < 2.85000000000000009

    1. Initial program 1.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.85000000000000009 < 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 99.0%

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

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

      \[\leadsto \color{blue}{\frac{3}{x \cdot x}} - \frac{x}{\tan x - x} \]
    9. Taylor expanded in x around inf 99.1%

      \[\leadsto \frac{3}{x \cdot x} - \color{blue}{-1} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification99.0%

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

Alternative 9: 98.5% accurate, 40.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1.55:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 1.6:\\ \;\;\;\;-0.5\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \end{array} \]
(FPCore (x) :precision binary64 (if (<= x -1.55) 1.0 (if (<= x 1.6) -0.5 1.0)))
double code(double x) {
	double tmp;
	if (x <= -1.55) {
		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.55d0)) 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.55) {
		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.55:
		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.55)
		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.55)
		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.55], 1.0, If[LessEqual[x, 1.6], -0.5, 1.0]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.55:\\
\;\;\;\;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.55000000000000004 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.5%

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

    if -1.55000000000000004 < x < 1.6000000000000001

    1. Initial program 1.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 50.2% 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 55.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{-0.5} \]
  5. Final simplification45.3%

    \[\leadsto -0.5 \]

Reproduce

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