sintan (problem 3.4.5)

Percentage Accurate: 51.4% → 100.0%
Time: 16.0s
Alternatives: 8
Speedup: 67.6×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 8 alternatives:

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

Initial Program: 51.4% accurate, 1.0× speedup?

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

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

Alternative 1: 100.0% accurate, 0.7× speedup?

\[\begin{array}{l} x = |x|\\ \\ \begin{array}{l} \mathbf{if}\;x \leq 0.082:\\ \;\;\;\;\left(0.225 \cdot {x}^{2} + \left(0.00024107142857142857 \cdot {x}^{6} + -0.009642857142857142 \cdot {x}^{4}\right)\right) - 0.5\\ \mathbf{else}:\\ \;\;\;\;\frac{x - \sin x}{x - \tan x}\\ \end{array} \end{array} \]
NOTE: x should be positive before calling this function
(FPCore (x)
 :precision binary64
 (if (<= x 0.082)
   (-
    (+
     (* 0.225 (pow x 2.0))
     (+
      (* 0.00024107142857142857 (pow x 6.0))
      (* -0.009642857142857142 (pow x 4.0))))
    0.5)
   (/ (- x (sin x)) (- x (tan x)))))
x = abs(x);
double code(double x) {
	double tmp;
	if (x <= 0.082) {
		tmp = ((0.225 * pow(x, 2.0)) + ((0.00024107142857142857 * pow(x, 6.0)) + (-0.009642857142857142 * pow(x, 4.0)))) - 0.5;
	} else {
		tmp = (x - sin(x)) / (x - tan(x));
	}
	return tmp;
}
NOTE: x should be positive before calling this function
real(8) function code(x)
    real(8), intent (in) :: x
    real(8) :: tmp
    if (x <= 0.082d0) then
        tmp = ((0.225d0 * (x ** 2.0d0)) + ((0.00024107142857142857d0 * (x ** 6.0d0)) + ((-0.009642857142857142d0) * (x ** 4.0d0)))) - 0.5d0
    else
        tmp = (x - sin(x)) / (x - tan(x))
    end if
    code = tmp
end function
x = Math.abs(x);
public static double code(double x) {
	double tmp;
	if (x <= 0.082) {
		tmp = ((0.225 * Math.pow(x, 2.0)) + ((0.00024107142857142857 * Math.pow(x, 6.0)) + (-0.009642857142857142 * Math.pow(x, 4.0)))) - 0.5;
	} else {
		tmp = (x - Math.sin(x)) / (x - Math.tan(x));
	}
	return tmp;
}
x = abs(x)
def code(x):
	tmp = 0
	if x <= 0.082:
		tmp = ((0.225 * math.pow(x, 2.0)) + ((0.00024107142857142857 * math.pow(x, 6.0)) + (-0.009642857142857142 * math.pow(x, 4.0)))) - 0.5
	else:
		tmp = (x - math.sin(x)) / (x - math.tan(x))
	return tmp
x = abs(x)
function code(x)
	tmp = 0.0
	if (x <= 0.082)
		tmp = Float64(Float64(Float64(0.225 * (x ^ 2.0)) + Float64(Float64(0.00024107142857142857 * (x ^ 6.0)) + Float64(-0.009642857142857142 * (x ^ 4.0)))) - 0.5);
	else
		tmp = Float64(Float64(x - sin(x)) / Float64(x - tan(x)));
	end
	return tmp
end
x = abs(x)
function tmp_2 = code(x)
	tmp = 0.0;
	if (x <= 0.082)
		tmp = ((0.225 * (x ^ 2.0)) + ((0.00024107142857142857 * (x ^ 6.0)) + (-0.009642857142857142 * (x ^ 4.0)))) - 0.5;
	else
		tmp = (x - sin(x)) / (x - tan(x));
	end
	tmp_2 = tmp;
end
NOTE: x should be positive before calling this function
code[x_] := If[LessEqual[x, 0.082], N[(N[(N[(0.225 * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision] + N[(N[(0.00024107142857142857 * N[Power[x, 6.0], $MachinePrecision]), $MachinePrecision] + N[(-0.009642857142857142 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision], N[(N[(x - N[Sin[x], $MachinePrecision]), $MachinePrecision] / N[(x - N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.082:\\
\;\;\;\;\left(0.225 \cdot {x}^{2} + \left(0.00024107142857142857 \cdot {x}^{6} + -0.009642857142857142 \cdot {x}^{4}\right)\right) - 0.5\\

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


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

    1. Initial program 33.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.0820000000000000034 < x

    1. Initial program 99.9%

      \[\frac{x - \sin x}{x - \tan x} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification77.3%

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

Alternative 2: 99.4% accurate, 1.0× speedup?

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

\mathbf{else}:\\
\;\;\;\;1 + \frac{\tan x - \sin x}{x}\\


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

    1. Initial program 34.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{{\left(\frac{\tan x - x}{\sin x - x}\right)}^{-1}} \]
    6. Taylor expanded in x around 0 67.6%

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

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

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

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

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

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

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

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

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

    if 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 100.0%

      \[\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+100.0%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{1 - \frac{\sin x - \frac{\sin x}{\cos x}}{x}} \]
    7. Step-by-step derivation
      1. sub-neg100.0%

        \[\leadsto 1 - \frac{\color{blue}{\sin x + \left(-\frac{\sin x}{\cos x}\right)}}{x} \]
      2. quot-tan100.0%

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

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

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

      \[\leadsto 1 - \frac{\color{blue}{\sin x - \tan x}}{x} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification76.8%

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

Alternative 3: 100.0% accurate, 1.0× speedup?

\[\begin{array}{l} x = |x|\\ \\ \begin{array}{l} \mathbf{if}\;x \leq 0.028:\\ \;\;\;\;\left(0.225 \cdot \left(x \cdot x\right) + -0.009642857142857142 \cdot {x}^{4}\right) + -0.5\\ \mathbf{else}:\\ \;\;\;\;\frac{x - \sin x}{x - \tan x}\\ \end{array} \end{array} \]
NOTE: x should be positive before calling this function
(FPCore (x)
 :precision binary64
 (if (<= x 0.028)
   (+ (+ (* 0.225 (* x x)) (* -0.009642857142857142 (pow x 4.0))) -0.5)
   (/ (- x (sin x)) (- x (tan x)))))
x = abs(x);
double code(double x) {
	double tmp;
	if (x <= 0.028) {
		tmp = ((0.225 * (x * x)) + (-0.009642857142857142 * pow(x, 4.0))) + -0.5;
	} else {
		tmp = (x - sin(x)) / (x - tan(x));
	}
	return tmp;
}
NOTE: x should be positive before calling this function
real(8) function code(x)
    real(8), intent (in) :: x
    real(8) :: tmp
    if (x <= 0.028d0) then
        tmp = ((0.225d0 * (x * x)) + ((-0.009642857142857142d0) * (x ** 4.0d0))) + (-0.5d0)
    else
        tmp = (x - sin(x)) / (x - tan(x))
    end if
    code = tmp
end function
x = Math.abs(x);
public static double code(double x) {
	double tmp;
	if (x <= 0.028) {
		tmp = ((0.225 * (x * x)) + (-0.009642857142857142 * Math.pow(x, 4.0))) + -0.5;
	} else {
		tmp = (x - Math.sin(x)) / (x - Math.tan(x));
	}
	return tmp;
}
x = abs(x)
def code(x):
	tmp = 0
	if x <= 0.028:
		tmp = ((0.225 * (x * x)) + (-0.009642857142857142 * math.pow(x, 4.0))) + -0.5
	else:
		tmp = (x - math.sin(x)) / (x - math.tan(x))
	return tmp
x = abs(x)
function code(x)
	tmp = 0.0
	if (x <= 0.028)
		tmp = Float64(Float64(Float64(0.225 * Float64(x * x)) + Float64(-0.009642857142857142 * (x ^ 4.0))) + -0.5);
	else
		tmp = Float64(Float64(x - sin(x)) / Float64(x - tan(x)));
	end
	return tmp
end
x = abs(x)
function tmp_2 = code(x)
	tmp = 0.0;
	if (x <= 0.028)
		tmp = ((0.225 * (x * x)) + (-0.009642857142857142 * (x ^ 4.0))) + -0.5;
	else
		tmp = (x - sin(x)) / (x - tan(x));
	end
	tmp_2 = tmp;
end
NOTE: x should be positive before calling this function
code[x_] := If[LessEqual[x, 0.028], N[(N[(N[(0.225 * N[(x * x), $MachinePrecision]), $MachinePrecision] + N[(-0.009642857142857142 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -0.5), $MachinePrecision], N[(N[(x - N[Sin[x], $MachinePrecision]), $MachinePrecision] / N[(x - N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.028:\\
\;\;\;\;\left(0.225 \cdot \left(x \cdot x\right) + -0.009642857142857142 \cdot {x}^{4}\right) + -0.5\\

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


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

    1. Initial program 33.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{{\left(\frac{\tan x - x}{\sin x - x}\right)}^{-1}} \]
    6. Taylor expanded in x around 0 67.8%

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

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

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

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

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

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

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

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

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

    if 0.0280000000000000006 < x

    1. Initial program 99.9%

      \[\frac{x - \sin x}{x - \tan x} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification77.1%

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

Alternative 4: 99.0% accurate, 1.8× speedup?

\[\begin{array}{l} x = |x|\\ \\ \begin{array}{l} \mathbf{if}\;x \leq 2.8:\\ \;\;\;\;\left(0.225 \cdot \left(x \cdot x\right) + -0.009642857142857142 \cdot {x}^{4}\right) + -0.5\\ \mathbf{else}:\\ \;\;\;\;\frac{-x}{\tan x - x}\\ \end{array} \end{array} \]
NOTE: x should be positive before calling this function
(FPCore (x)
 :precision binary64
 (if (<= x 2.8)
   (+ (+ (* 0.225 (* x x)) (* -0.009642857142857142 (pow x 4.0))) -0.5)
   (/ (- x) (- (tan x) x))))
x = abs(x);
double code(double x) {
	double tmp;
	if (x <= 2.8) {
		tmp = ((0.225 * (x * x)) + (-0.009642857142857142 * pow(x, 4.0))) + -0.5;
	} else {
		tmp = -x / (tan(x) - x);
	}
	return tmp;
}
NOTE: x should be positive before calling this function
real(8) function code(x)
    real(8), intent (in) :: x
    real(8) :: tmp
    if (x <= 2.8d0) then
        tmp = ((0.225d0 * (x * x)) + ((-0.009642857142857142d0) * (x ** 4.0d0))) + (-0.5d0)
    else
        tmp = -x / (tan(x) - x)
    end if
    code = tmp
end function
x = Math.abs(x);
public static double code(double x) {
	double tmp;
	if (x <= 2.8) {
		tmp = ((0.225 * (x * x)) + (-0.009642857142857142 * Math.pow(x, 4.0))) + -0.5;
	} else {
		tmp = -x / (Math.tan(x) - x);
	}
	return tmp;
}
x = abs(x)
def code(x):
	tmp = 0
	if x <= 2.8:
		tmp = ((0.225 * (x * x)) + (-0.009642857142857142 * math.pow(x, 4.0))) + -0.5
	else:
		tmp = -x / (math.tan(x) - x)
	return tmp
x = abs(x)
function code(x)
	tmp = 0.0
	if (x <= 2.8)
		tmp = Float64(Float64(Float64(0.225 * Float64(x * x)) + Float64(-0.009642857142857142 * (x ^ 4.0))) + -0.5);
	else
		tmp = Float64(Float64(-x) / Float64(tan(x) - x));
	end
	return tmp
end
x = abs(x)
function tmp_2 = code(x)
	tmp = 0.0;
	if (x <= 2.8)
		tmp = ((0.225 * (x * x)) + (-0.009642857142857142 * (x ^ 4.0))) + -0.5;
	else
		tmp = -x / (tan(x) - x);
	end
	tmp_2 = tmp;
end
NOTE: x should be positive before calling this function
code[x_] := If[LessEqual[x, 2.8], N[(N[(N[(0.225 * N[(x * x), $MachinePrecision]), $MachinePrecision] + N[(-0.009642857142857142 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -0.5), $MachinePrecision], N[((-x) / N[(N[Tan[x], $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.8:\\
\;\;\;\;\left(0.225 \cdot \left(x \cdot x\right) + -0.009642857142857142 \cdot {x}^{4}\right) + -0.5\\

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


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

    1. Initial program 34.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{{\left(\frac{\tan x - x}{\sin x - x}\right)}^{-1}} \]
    6. Taylor expanded in x around 0 67.6%

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

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

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

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

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

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

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

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

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

    if 2.7999999999999998 < x

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\left(\sqrt[3]{\sin x} \cdot \sqrt[3]{\sin x}\right) \cdot \sqrt[3]{\sin x}} - x}{\tan x - x} \]
      2. *-un-lft-identity100.0%

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

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\sqrt[3]{\sin x} \cdot \sqrt[3]{\sin x}, \sqrt[3]{\sin x}, -x \cdot 1\right) + \mathsf{fma}\left(-x, 1, x \cdot 1\right)}}{\tan x - x} \]
      4. *-commutative100.0%

        \[\leadsto \frac{\mathsf{fma}\left(\sqrt[3]{\sin x} \cdot \sqrt[3]{\sin x}, \sqrt[3]{\sin x}, -\color{blue}{1 \cdot x}\right) + \mathsf{fma}\left(-x, 1, x \cdot 1\right)}{\tan x - x} \]
      5. *-un-lft-identity100.0%

        \[\leadsto \frac{\mathsf{fma}\left(\sqrt[3]{\sin x} \cdot \sqrt[3]{\sin x}, \sqrt[3]{\sin x}, -\color{blue}{x}\right) + \mathsf{fma}\left(-x, 1, x \cdot 1\right)}{\tan x - x} \]
      6. fma-neg100.0%

        \[\leadsto \frac{\color{blue}{\left(\left(\sqrt[3]{\sin x} \cdot \sqrt[3]{\sin x}\right) \cdot \sqrt[3]{\sin x} - x\right)} + \mathsf{fma}\left(-x, 1, x \cdot 1\right)}{\tan x - x} \]
      7. add-cube-cbrt100.0%

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

        \[\leadsto \frac{\left(\sin x - x\right) + \mathsf{fma}\left(-x, 1, \color{blue}{1 \cdot x}\right)}{\tan x - x} \]
      9. *-un-lft-identity100.0%

        \[\leadsto \frac{\left(\sin x - x\right) + \mathsf{fma}\left(-x, 1, \color{blue}{x}\right)}{\tan x - x} \]
    5. Applied egg-rr100.0%

      \[\leadsto \frac{\color{blue}{\left(\sin x - x\right) + \mathsf{fma}\left(-x, 1, x\right)}}{\tan x - x} \]
    6. Step-by-step derivation
      1. +-commutative100.0%

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(-x, 1, x\right) + \left(\sin x - x\right)}}{\tan x - x} \]
      2. fma-udef100.0%

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{x + \left(\left(\sin x - x\right) - x\right)}}{\tan x - x} \]
    8. Taylor expanded in x around inf 98.8%

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

        \[\leadsto \frac{\color{blue}{-x}}{\tan x - x} \]
    10. Simplified98.8%

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

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

Alternative 5: 98.9% accurate, 1.9× speedup?

\[\begin{array}{l} x = |x|\\ \\ \begin{array}{l} \mathbf{if}\;x \leq 2.3:\\ \;\;\;\;0.225 \cdot \left(x \cdot x\right) + -0.5\\ \mathbf{else}:\\ \;\;\;\;\frac{-x}{\tan x - x}\\ \end{array} \end{array} \]
NOTE: x should be positive before calling this function
(FPCore (x)
 :precision binary64
 (if (<= x 2.3) (+ (* 0.225 (* x x)) -0.5) (/ (- x) (- (tan x) x))))
x = abs(x);
double code(double x) {
	double tmp;
	if (x <= 2.3) {
		tmp = (0.225 * (x * x)) + -0.5;
	} else {
		tmp = -x / (tan(x) - x);
	}
	return tmp;
}
NOTE: x should be positive before calling this function
real(8) function code(x)
    real(8), intent (in) :: x
    real(8) :: tmp
    if (x <= 2.3d0) then
        tmp = (0.225d0 * (x * x)) + (-0.5d0)
    else
        tmp = -x / (tan(x) - x)
    end if
    code = tmp
end function
x = Math.abs(x);
public static double code(double x) {
	double tmp;
	if (x <= 2.3) {
		tmp = (0.225 * (x * x)) + -0.5;
	} else {
		tmp = -x / (Math.tan(x) - x);
	}
	return tmp;
}
x = abs(x)
def code(x):
	tmp = 0
	if x <= 2.3:
		tmp = (0.225 * (x * x)) + -0.5
	else:
		tmp = -x / (math.tan(x) - x)
	return tmp
x = abs(x)
function code(x)
	tmp = 0.0
	if (x <= 2.3)
		tmp = Float64(Float64(0.225 * Float64(x * x)) + -0.5);
	else
		tmp = Float64(Float64(-x) / Float64(tan(x) - x));
	end
	return tmp
end
x = abs(x)
function tmp_2 = code(x)
	tmp = 0.0;
	if (x <= 2.3)
		tmp = (0.225 * (x * x)) + -0.5;
	else
		tmp = -x / (tan(x) - x);
	end
	tmp_2 = tmp;
end
NOTE: x should be positive before calling this function
code[x_] := If[LessEqual[x, 2.3], N[(N[(0.225 * N[(x * x), $MachinePrecision]), $MachinePrecision] + -0.5), $MachinePrecision], N[((-x) / N[(N[Tan[x], $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.3:\\
\;\;\;\;0.225 \cdot \left(x \cdot x\right) + -0.5\\

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


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

    1. Initial program 34.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.2999999999999998 < 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. add-cube-cbrt100.0%

        \[\leadsto \frac{\color{blue}{\left(\sqrt[3]{\sin x} \cdot \sqrt[3]{\sin x}\right) \cdot \sqrt[3]{\sin x}} - x}{\tan x - x} \]
      2. *-un-lft-identity100.0%

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

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\sqrt[3]{\sin x} \cdot \sqrt[3]{\sin x}, \sqrt[3]{\sin x}, -x \cdot 1\right) + \mathsf{fma}\left(-x, 1, x \cdot 1\right)}}{\tan x - x} \]
      4. *-commutative100.0%

        \[\leadsto \frac{\mathsf{fma}\left(\sqrt[3]{\sin x} \cdot \sqrt[3]{\sin x}, \sqrt[3]{\sin x}, -\color{blue}{1 \cdot x}\right) + \mathsf{fma}\left(-x, 1, x \cdot 1\right)}{\tan x - x} \]
      5. *-un-lft-identity100.0%

        \[\leadsto \frac{\mathsf{fma}\left(\sqrt[3]{\sin x} \cdot \sqrt[3]{\sin x}, \sqrt[3]{\sin x}, -\color{blue}{x}\right) + \mathsf{fma}\left(-x, 1, x \cdot 1\right)}{\tan x - x} \]
      6. fma-neg100.0%

        \[\leadsto \frac{\color{blue}{\left(\left(\sqrt[3]{\sin x} \cdot \sqrt[3]{\sin x}\right) \cdot \sqrt[3]{\sin x} - x\right)} + \mathsf{fma}\left(-x, 1, x \cdot 1\right)}{\tan x - x} \]
      7. add-cube-cbrt100.0%

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

        \[\leadsto \frac{\left(\sin x - x\right) + \mathsf{fma}\left(-x, 1, \color{blue}{1 \cdot x}\right)}{\tan x - x} \]
      9. *-un-lft-identity100.0%

        \[\leadsto \frac{\left(\sin x - x\right) + \mathsf{fma}\left(-x, 1, \color{blue}{x}\right)}{\tan x - x} \]
    5. Applied egg-rr100.0%

      \[\leadsto \frac{\color{blue}{\left(\sin x - x\right) + \mathsf{fma}\left(-x, 1, x\right)}}{\tan x - x} \]
    6. Step-by-step derivation
      1. +-commutative100.0%

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(-x, 1, x\right) + \left(\sin x - x\right)}}{\tan x - x} \]
      2. fma-udef100.0%

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{x + \left(\left(\sin x - x\right) - x\right)}}{\tan x - x} \]
    8. Taylor expanded in x around inf 98.8%

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

        \[\leadsto \frac{\color{blue}{-x}}{\tan x - x} \]
    10. Simplified98.8%

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

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

Alternative 6: 98.9% accurate, 22.8× speedup?

\[\begin{array}{l} x = |x|\\ \\ \begin{array}{l} \mathbf{if}\;x \leq 2.6:\\ \;\;\;\;0.225 \cdot \left(x \cdot x\right) + -0.5\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \end{array} \]
NOTE: x should be positive before calling this function
(FPCore (x) :precision binary64 (if (<= x 2.6) (+ (* 0.225 (* x x)) -0.5) 1.0))
x = abs(x);
double code(double x) {
	double tmp;
	if (x <= 2.6) {
		tmp = (0.225 * (x * x)) + -0.5;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
NOTE: x should be positive before calling this function
real(8) function code(x)
    real(8), intent (in) :: x
    real(8) :: tmp
    if (x <= 2.6d0) then
        tmp = (0.225d0 * (x * x)) + (-0.5d0)
    else
        tmp = 1.0d0
    end if
    code = tmp
end function
x = Math.abs(x);
public static double code(double x) {
	double tmp;
	if (x <= 2.6) {
		tmp = (0.225 * (x * x)) + -0.5;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
x = abs(x)
def code(x):
	tmp = 0
	if x <= 2.6:
		tmp = (0.225 * (x * x)) + -0.5
	else:
		tmp = 1.0
	return tmp
x = abs(x)
function code(x)
	tmp = 0.0
	if (x <= 2.6)
		tmp = Float64(Float64(0.225 * Float64(x * x)) + -0.5);
	else
		tmp = 1.0;
	end
	return tmp
end
x = abs(x)
function tmp_2 = code(x)
	tmp = 0.0;
	if (x <= 2.6)
		tmp = (0.225 * (x * x)) + -0.5;
	else
		tmp = 1.0;
	end
	tmp_2 = tmp;
end
NOTE: x should be positive before calling this function
code[x_] := If[LessEqual[x, 2.6], N[(N[(0.225 * N[(x * x), $MachinePrecision]), $MachinePrecision] + -0.5), $MachinePrecision], 1.0]
\begin{array}{l}
x = |x|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.6:\\
\;\;\;\;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

    1. Initial program 34.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 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 98.8%

      \[\leadsto \color{blue}{1} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification77.1%

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

Alternative 7: 98.6% accurate, 67.6× speedup?

\[\begin{array}{l} x = |x|\\ \\ \begin{array}{l} \mathbf{if}\;x \leq 1.6:\\ \;\;\;\;-0.5\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \end{array} \]
NOTE: x should be positive before calling this function
(FPCore (x) :precision binary64 (if (<= x 1.6) -0.5 1.0))
x = abs(x);
double code(double x) {
	double tmp;
	if (x <= 1.6) {
		tmp = -0.5;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
NOTE: x should be positive before calling this function
real(8) function code(x)
    real(8), intent (in) :: x
    real(8) :: tmp
    if (x <= 1.6d0) then
        tmp = -0.5d0
    else
        tmp = 1.0d0
    end if
    code = tmp
end function
x = Math.abs(x);
public static double code(double x) {
	double tmp;
	if (x <= 1.6) {
		tmp = -0.5;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
x = abs(x)
def code(x):
	tmp = 0
	if x <= 1.6:
		tmp = -0.5
	else:
		tmp = 1.0
	return tmp
x = abs(x)
function code(x)
	tmp = 0.0
	if (x <= 1.6)
		tmp = -0.5;
	else
		tmp = 1.0;
	end
	return tmp
end
x = abs(x)
function tmp_2 = code(x)
	tmp = 0.0;
	if (x <= 1.6)
		tmp = -0.5;
	else
		tmp = 1.0;
	end
	tmp_2 = tmp;
end
NOTE: x should be positive before calling this function
code[x_] := If[LessEqual[x, 1.6], -0.5, 1.0]
\begin{array}{l}
x = |x|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.6:\\
\;\;\;\;-0.5\\

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


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

    1. Initial program 34.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-0.5} \]

    if 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.8%

      \[\leadsto \color{blue}{1} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification76.1%

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

Alternative 8: 49.7% accurate, 207.0× speedup?

\[\begin{array}{l} x = |x|\\ \\ -0.5 \end{array} \]
NOTE: x should be positive before calling this function
(FPCore (x) :precision binary64 -0.5)
x = abs(x);
double code(double x) {
	return -0.5;
}
NOTE: x should be positive before calling this function
real(8) function code(x)
    real(8), intent (in) :: x
    code = -0.5d0
end function
x = Math.abs(x);
public static double code(double x) {
	return -0.5;
}
x = abs(x)
def code(x):
	return -0.5
x = abs(x)
function code(x)
	return -0.5
end
x = abs(x)
function tmp = code(x)
	tmp = -0.5;
end
NOTE: x should be positive before calling this function
code[x_] := -0.5
\begin{array}{l}
x = |x|\\
\\
-0.5
\end{array}
Derivation
  1. Initial program 53.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto -0.5 \]

Reproduce

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