sintan (problem 3.4.5)

Percentage Accurate: 50.8% → 100.0%
Time: 13.5s
Alternatives: 7
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 7 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: 100.0% accurate, 0.7× speedup?

\[\begin{array}{l} x = |x|\\ \\ \begin{array}{l} \mathbf{if}\;x \leq 0.05:\\ \;\;\;\;\left(0.225 \cdot {x}^{2} + {x}^{4} \cdot \mathsf{fma}\left(x, x \cdot 0.00024107142857142857, -0.009642857142857142\right)\right) - 0.5\\ \mathbf{else}:\\ \;\;\;\;{\left(\frac{\tan x - x}{\sin x - x}\right)}^{-1}\\ \end{array} \end{array} \]
NOTE: x should be positive before calling this function
(FPCore (x)
 :precision binary64
 (if (<= x 0.05)
   (-
    (+
     (* 0.225 (pow x 2.0))
     (*
      (pow x 4.0)
      (fma x (* x 0.00024107142857142857) -0.009642857142857142)))
    0.5)
   (pow (/ (- (tan x) x) (- (sin x) x)) -1.0)))
x = abs(x);
double code(double x) {
	double tmp;
	if (x <= 0.05) {
		tmp = ((0.225 * pow(x, 2.0)) + (pow(x, 4.0) * fma(x, (x * 0.00024107142857142857), -0.009642857142857142))) - 0.5;
	} else {
		tmp = pow(((tan(x) - x) / (sin(x) - x)), -1.0);
	}
	return tmp;
}
x = abs(x)
function code(x)
	tmp = 0.0
	if (x <= 0.05)
		tmp = Float64(Float64(Float64(0.225 * (x ^ 2.0)) + Float64((x ^ 4.0) * fma(x, Float64(x * 0.00024107142857142857), -0.009642857142857142))) - 0.5);
	else
		tmp = Float64(Float64(tan(x) - x) / Float64(sin(x) - x)) ^ -1.0;
	end
	return tmp
end
NOTE: x should be positive before calling this function
code[x_] := If[LessEqual[x, 0.05], N[(N[(N[(0.225 * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision] + N[(N[Power[x, 4.0], $MachinePrecision] * N[(x * N[(x * 0.00024107142857142857), $MachinePrecision] + -0.009642857142857142), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision], N[Power[N[(N[(N[Tan[x], $MachinePrecision] - x), $MachinePrecision] / N[(N[Sin[x], $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision]]
\begin{array}{l}
x = |x|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.05:\\
\;\;\;\;\left(0.225 \cdot {x}^{2} + {x}^{4} \cdot \mathsf{fma}\left(x, x \cdot 0.00024107142857142857, -0.009642857142857142\right)\right) - 0.5\\

\mathbf{else}:\\
\;\;\;\;{\left(\frac{\tan x - x}{\sin x - x}\right)}^{-1}\\


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

    1. Initial program 38.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(0.225 \cdot {x}^{2} + \left(-0.009642857142857142 \cdot {x}^{4} + 0.00024107142857142857 \cdot {x}^{6}\right)\right) - 0.5} \]
    5. Step-by-step derivation
      1. expm1-log1p-u62.9%

        \[\leadsto \left(0.225 \cdot {x}^{2} + \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(-0.009642857142857142 \cdot {x}^{4} + 0.00024107142857142857 \cdot {x}^{6}\right)\right)}\right) - 0.5 \]
      2. expm1-udef62.9%

        \[\leadsto \left(0.225 \cdot {x}^{2} + \color{blue}{\left(e^{\mathsf{log1p}\left(-0.009642857142857142 \cdot {x}^{4} + 0.00024107142857142857 \cdot {x}^{6}\right)} - 1\right)}\right) - 0.5 \]
      3. +-commutative62.9%

        \[\leadsto \left(0.225 \cdot {x}^{2} + \left(e^{\mathsf{log1p}\left(\color{blue}{0.00024107142857142857 \cdot {x}^{6} + -0.009642857142857142 \cdot {x}^{4}}\right)} - 1\right)\right) - 0.5 \]
      4. fma-def62.9%

        \[\leadsto \left(0.225 \cdot {x}^{2} + \left(e^{\mathsf{log1p}\left(\color{blue}{\mathsf{fma}\left(0.00024107142857142857, {x}^{6}, -0.009642857142857142 \cdot {x}^{4}\right)}\right)} - 1\right)\right) - 0.5 \]
    6. Applied egg-rr62.9%

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

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

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

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

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

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

        \[\leadsto \left(0.225 \cdot {x}^{2} + \left(\color{blue}{\left({x}^{3} \cdot {x}^{3}\right)} \cdot 0.00024107142857142857 + -0.009642857142857142 \cdot {x}^{4}\right)\right) - 0.5 \]
      7. cube-mult62.9%

        \[\leadsto \left(0.225 \cdot {x}^{2} + \left(\left({x}^{3} \cdot \color{blue}{\left(x \cdot \left(x \cdot x\right)\right)}\right) \cdot 0.00024107142857142857 + -0.009642857142857142 \cdot {x}^{4}\right)\right) - 0.5 \]
      8. associate-*r*62.9%

        \[\leadsto \left(0.225 \cdot {x}^{2} + \left(\color{blue}{\left(\left({x}^{3} \cdot x\right) \cdot \left(x \cdot x\right)\right)} \cdot 0.00024107142857142857 + -0.009642857142857142 \cdot {x}^{4}\right)\right) - 0.5 \]
      9. pow-plus62.9%

        \[\leadsto \left(0.225 \cdot {x}^{2} + \left(\left(\color{blue}{{x}^{\left(3 + 1\right)}} \cdot \left(x \cdot x\right)\right) \cdot 0.00024107142857142857 + -0.009642857142857142 \cdot {x}^{4}\right)\right) - 0.5 \]
      10. metadata-eval62.9%

        \[\leadsto \left(0.225 \cdot {x}^{2} + \left(\left({x}^{\color{blue}{4}} \cdot \left(x \cdot x\right)\right) \cdot 0.00024107142857142857 + -0.009642857142857142 \cdot {x}^{4}\right)\right) - 0.5 \]
      11. associate-*r*62.9%

        \[\leadsto \left(0.225 \cdot {x}^{2} + \left(\color{blue}{{x}^{4} \cdot \left(\left(x \cdot x\right) \cdot 0.00024107142857142857\right)} + -0.009642857142857142 \cdot {x}^{4}\right)\right) - 0.5 \]
      12. *-commutative62.9%

        \[\leadsto \left(0.225 \cdot {x}^{2} + \left({x}^{4} \cdot \left(\left(x \cdot x\right) \cdot 0.00024107142857142857\right) + \color{blue}{{x}^{4} \cdot -0.009642857142857142}\right)\right) - 0.5 \]
      13. distribute-lft-out63.7%

        \[\leadsto \left(0.225 \cdot {x}^{2} + \color{blue}{{x}^{4} \cdot \left(\left(x \cdot x\right) \cdot 0.00024107142857142857 + -0.009642857142857142\right)}\right) - 0.5 \]
      14. associate-*l*63.7%

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

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

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

    if 0.050000000000000003 < 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. clear-num100.0%

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

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

      \[\leadsto \color{blue}{{\left(\frac{\tan x - x}{\sin x - x}\right)}^{-1}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification74.0%

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

Alternative 2: 100.0% accurate, 0.7× speedup?

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

\mathbf{else}:\\
\;\;\;\;{\left(\frac{\tan x - x}{\sin x - x}\right)}^{-1}\\


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

    1. Initial program 38.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\color{blue}{\left(x \cdot x\right) \cdot 0.225} + -0.009642857142857142 \cdot {x}^{4}\right) + -0.5 \]
      3. associate-*l*62.5%

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

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

    if 0.0290000000000000015 < 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. clear-num100.0%

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

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

      \[\leadsto \color{blue}{{\left(\frac{\tan x - x}{\sin x - x}\right)}^{-1}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification73.2%

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

Alternative 3: 100.0% accurate, 1.0× speedup?

\[\begin{array}{l} x = |x|\\ \\ \begin{array}{l} \mathbf{if}\;x \leq 0.029:\\ \;\;\;\;\left(x \cdot \left(x \cdot 0.225\right) + {x}^{4} \cdot -0.009642857142857142\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.029)
   (+ (+ (* x (* x 0.225)) (* (pow x 4.0) -0.009642857142857142)) -0.5)
   (/ (- x (sin x)) (- x (tan x)))))
x = abs(x);
double code(double x) {
	double tmp;
	if (x <= 0.029) {
		tmp = ((x * (x * 0.225)) + (pow(x, 4.0) * -0.009642857142857142)) + -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.029d0) then
        tmp = ((x * (x * 0.225d0)) + ((x ** 4.0d0) * (-0.009642857142857142d0))) + (-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.029) {
		tmp = ((x * (x * 0.225)) + (Math.pow(x, 4.0) * -0.009642857142857142)) + -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.029:
		tmp = ((x * (x * 0.225)) + (math.pow(x, 4.0) * -0.009642857142857142)) + -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.029)
		tmp = Float64(Float64(Float64(x * Float64(x * 0.225)) + Float64((x ^ 4.0) * -0.009642857142857142)) + -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.029)
		tmp = ((x * (x * 0.225)) + ((x ^ 4.0) * -0.009642857142857142)) + -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.029], N[(N[(N[(x * N[(x * 0.225), $MachinePrecision]), $MachinePrecision] + N[(N[Power[x, 4.0], $MachinePrecision] * -0.009642857142857142), $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.029:\\
\;\;\;\;\left(x \cdot \left(x \cdot 0.225\right) + {x}^{4} \cdot -0.009642857142857142\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.0290000000000000015

    1. Initial program 38.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\color{blue}{\left(x \cdot x\right) \cdot 0.225} + -0.009642857142857142 \cdot {x}^{4}\right) + -0.5 \]
      3. associate-*l*62.5%

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

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

    if 0.0290000000000000015 < x

    1. Initial program 100.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 0.029:\\ \;\;\;\;\left(x \cdot \left(x \cdot 0.225\right) + {x}^{4} \cdot -0.009642857142857142\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.9:\\ \;\;\;\;\left(x \cdot \left(x \cdot 0.225\right) + {x}^{4} \cdot -0.009642857142857142\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.9)
   (+ (+ (* x (* x 0.225)) (* (pow x 4.0) -0.009642857142857142)) -0.5)
   1.0))
x = abs(x);
double code(double x) {
	double tmp;
	if (x <= 2.9) {
		tmp = ((x * (x * 0.225)) + (pow(x, 4.0) * -0.009642857142857142)) + -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.9d0) then
        tmp = ((x * (x * 0.225d0)) + ((x ** 4.0d0) * (-0.009642857142857142d0))) + (-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.9) {
		tmp = ((x * (x * 0.225)) + (Math.pow(x, 4.0) * -0.009642857142857142)) + -0.5;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
x = abs(x)
def code(x):
	tmp = 0
	if x <= 2.9:
		tmp = ((x * (x * 0.225)) + (math.pow(x, 4.0) * -0.009642857142857142)) + -0.5
	else:
		tmp = 1.0
	return tmp
x = abs(x)
function code(x)
	tmp = 0.0
	if (x <= 2.9)
		tmp = Float64(Float64(Float64(x * Float64(x * 0.225)) + Float64((x ^ 4.0) * -0.009642857142857142)) + -0.5);
	else
		tmp = 1.0;
	end
	return tmp
end
x = abs(x)
function tmp_2 = code(x)
	tmp = 0.0;
	if (x <= 2.9)
		tmp = ((x * (x * 0.225)) + ((x ^ 4.0) * -0.009642857142857142)) + -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.9], N[(N[(N[(x * N[(x * 0.225), $MachinePrecision]), $MachinePrecision] + N[(N[Power[x, 4.0], $MachinePrecision] * -0.009642857142857142), $MachinePrecision]), $MachinePrecision] + -0.5), $MachinePrecision], 1.0]
\begin{array}{l}
x = |x|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.9:\\
\;\;\;\;\left(x \cdot \left(x \cdot 0.225\right) + {x}^{4} \cdot -0.009642857142857142\right) + -0.5\\

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


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

    1. Initial program 38.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\color{blue}{\left(x \cdot x\right) \cdot 0.225} + -0.009642857142857142 \cdot {x}^{4}\right) + -0.5 \]
      3. associate-*l*62.3%

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

      \[\leadsto \color{blue}{\left(x \cdot \left(x \cdot 0.225\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.3%

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

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

Alternative 5: 98.9% accurate, 22.8× speedup?

\[\begin{array}{l} x = |x|\\ \\ \begin{array}{l} \mathbf{if}\;x \leq 2.6:\\ \;\;\;\;x \cdot \left(x \cdot 0.225\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) (- (* x (* x 0.225)) 0.5) 1.0))
x = abs(x);
double code(double x) {
	double tmp;
	if (x <= 2.6) {
		tmp = (x * (x * 0.225)) - 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 = (x * (x * 0.225d0)) - 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 = (x * (x * 0.225)) - 0.5;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
x = abs(x)
def code(x):
	tmp = 0
	if x <= 2.6:
		tmp = (x * (x * 0.225)) - 0.5
	else:
		tmp = 1.0
	return tmp
x = abs(x)
function code(x)
	tmp = 0.0
	if (x <= 2.6)
		tmp = Float64(Float64(x * Float64(x * 0.225)) - 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 = (x * (x * 0.225)) - 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[(x * N[(x * 0.225), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision], 1.0]
\begin{array}{l}
x = |x|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.6:\\
\;\;\;\;x \cdot \left(x \cdot 0.225\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 38.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{0.225 \cdot \left(x \cdot x\right) - 0.5} \]
      3. *-commutative63.6%

        \[\leadsto \color{blue}{\left(x \cdot x\right) \cdot 0.225} - 0.5 \]
      4. associate-*l*63.6%

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

      \[\leadsto \color{blue}{x \cdot \left(x \cdot 0.225\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 99.3%

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

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

Alternative 6: 98.6% accurate, 67.6× speedup?

\[\begin{array}{l} x = |x|\\ \\ \begin{array}{l} \mathbf{if}\;x \leq 1.55:\\ \;\;\;\;-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.55) -0.5 1.0))
x = abs(x);
double code(double x) {
	double tmp;
	if (x <= 1.55) {
		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.55d0) 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.55) {
		tmp = -0.5;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
x = abs(x)
def code(x):
	tmp = 0
	if x <= 1.55:
		tmp = -0.5
	else:
		tmp = 1.0
	return tmp
x = abs(x)
function code(x)
	tmp = 0.0
	if (x <= 1.55)
		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.55)
		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.55], -0.5, 1.0]
\begin{array}{l}
x = |x|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.55:\\
\;\;\;\;-0.5\\

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


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

    1. Initial program 38.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.55000000000000004 < 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.2%

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

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

Alternative 7: 50.3% 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 56.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto -0.5 \]

Reproduce

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