ENA, Section 1.4, Exercise 4a

Percentage Accurate: 52.8% → 99.2%
Time: 24.1s
Alternatives: 7
Speedup: 41.0×

Specification

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

\\
\frac{x - \sin 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: 52.8% accurate, 1.0× speedup?

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

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

Alternative 1: 99.2% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \left(0.027777777777777776 - {x}^{4} \cdot 0.00408179012345679\right) \cdot \left(x \cdot \frac{x}{\mathsf{fma}\left({x}^{2}, 0.06388888888888888, 0.16666666666666666\right)}\right) \end{array} \]
(FPCore (x)
 :precision binary64
 (*
  (- 0.027777777777777776 (* (pow x 4.0) 0.00408179012345679))
  (* x (/ x (fma (pow x 2.0) 0.06388888888888888 0.16666666666666666)))))
double code(double x) {
	return (0.027777777777777776 - (pow(x, 4.0) * 0.00408179012345679)) * (x * (x / fma(pow(x, 2.0), 0.06388888888888888, 0.16666666666666666)));
}
function code(x)
	return Float64(Float64(0.027777777777777776 - Float64((x ^ 4.0) * 0.00408179012345679)) * Float64(x * Float64(x / fma((x ^ 2.0), 0.06388888888888888, 0.16666666666666666))))
end
code[x_] := N[(N[(0.027777777777777776 - N[(N[Power[x, 4.0], $MachinePrecision] * 0.00408179012345679), $MachinePrecision]), $MachinePrecision] * N[(x * N[(x / N[(N[Power[x, 2.0], $MachinePrecision] * 0.06388888888888888 + 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\left(0.027777777777777776 - {x}^{4} \cdot 0.00408179012345679\right) \cdot \left(x \cdot \frac{x}{\mathsf{fma}\left({x}^{2}, 0.06388888888888888, 0.16666666666666666\right)}\right)
\end{array}
Derivation
  1. Initial program 52.9%

    \[\frac{x - \sin x}{\tan x} \]
  2. Add Preprocessing
  3. Taylor expanded in x around 0 99.4%

    \[\leadsto \color{blue}{{x}^{2} \cdot \left(0.16666666666666666 + -0.06388888888888888 \cdot {x}^{2}\right)} \]
  4. Step-by-step derivation
    1. *-commutative99.4%

      \[\leadsto {x}^{2} \cdot \left(0.16666666666666666 + \color{blue}{{x}^{2} \cdot -0.06388888888888888}\right) \]
  5. Simplified99.4%

    \[\leadsto \color{blue}{{x}^{2} \cdot \left(0.16666666666666666 + {x}^{2} \cdot -0.06388888888888888\right)} \]
  6. Step-by-step derivation
    1. flip-+99.4%

      \[\leadsto {x}^{2} \cdot \color{blue}{\frac{0.16666666666666666 \cdot 0.16666666666666666 - \left({x}^{2} \cdot -0.06388888888888888\right) \cdot \left({x}^{2} \cdot -0.06388888888888888\right)}{0.16666666666666666 - {x}^{2} \cdot -0.06388888888888888}} \]
    2. associate-*r/99.3%

      \[\leadsto \color{blue}{\frac{{x}^{2} \cdot \left(0.16666666666666666 \cdot 0.16666666666666666 - \left({x}^{2} \cdot -0.06388888888888888\right) \cdot \left({x}^{2} \cdot -0.06388888888888888\right)\right)}{0.16666666666666666 - {x}^{2} \cdot -0.06388888888888888}} \]
    3. metadata-eval99.3%

      \[\leadsto \frac{{x}^{2} \cdot \left(\color{blue}{0.027777777777777776} - \left({x}^{2} \cdot -0.06388888888888888\right) \cdot \left({x}^{2} \cdot -0.06388888888888888\right)\right)}{0.16666666666666666 - {x}^{2} \cdot -0.06388888888888888} \]
    4. swap-sqr99.3%

      \[\leadsto \frac{{x}^{2} \cdot \left(0.027777777777777776 - \color{blue}{\left({x}^{2} \cdot {x}^{2}\right) \cdot \left(-0.06388888888888888 \cdot -0.06388888888888888\right)}\right)}{0.16666666666666666 - {x}^{2} \cdot -0.06388888888888888} \]
    5. pow-prod-up99.3%

      \[\leadsto \frac{{x}^{2} \cdot \left(0.027777777777777776 - \color{blue}{{x}^{\left(2 + 2\right)}} \cdot \left(-0.06388888888888888 \cdot -0.06388888888888888\right)\right)}{0.16666666666666666 - {x}^{2} \cdot -0.06388888888888888} \]
    6. metadata-eval99.3%

      \[\leadsto \frac{{x}^{2} \cdot \left(0.027777777777777776 - {x}^{\color{blue}{4}} \cdot \left(-0.06388888888888888 \cdot -0.06388888888888888\right)\right)}{0.16666666666666666 - {x}^{2} \cdot -0.06388888888888888} \]
    7. metadata-eval99.3%

      \[\leadsto \frac{{x}^{2} \cdot \left(0.027777777777777776 - {x}^{4} \cdot \color{blue}{0.00408179012345679}\right)}{0.16666666666666666 - {x}^{2} \cdot -0.06388888888888888} \]
    8. *-commutative99.3%

      \[\leadsto \frac{{x}^{2} \cdot \left(0.027777777777777776 - {x}^{4} \cdot 0.00408179012345679\right)}{0.16666666666666666 - \color{blue}{-0.06388888888888888 \cdot {x}^{2}}} \]
    9. cancel-sign-sub-inv99.3%

      \[\leadsto \frac{{x}^{2} \cdot \left(0.027777777777777776 - {x}^{4} \cdot 0.00408179012345679\right)}{\color{blue}{0.16666666666666666 + \left(--0.06388888888888888\right) \cdot {x}^{2}}} \]
    10. metadata-eval99.3%

      \[\leadsto \frac{{x}^{2} \cdot \left(0.027777777777777776 - {x}^{4} \cdot 0.00408179012345679\right)}{0.16666666666666666 + \color{blue}{0.06388888888888888} \cdot {x}^{2}} \]
  7. Applied egg-rr99.3%

    \[\leadsto \color{blue}{\frac{{x}^{2} \cdot \left(0.027777777777777776 - {x}^{4} \cdot 0.00408179012345679\right)}{0.16666666666666666 + 0.06388888888888888 \cdot {x}^{2}}} \]
  8. Step-by-step derivation
    1. *-commutative99.3%

      \[\leadsto \frac{\color{blue}{\left(0.027777777777777776 - {x}^{4} \cdot 0.00408179012345679\right) \cdot {x}^{2}}}{0.16666666666666666 + 0.06388888888888888 \cdot {x}^{2}} \]
    2. associate-/l*99.4%

      \[\leadsto \color{blue}{\left(0.027777777777777776 - {x}^{4} \cdot 0.00408179012345679\right) \cdot \frac{{x}^{2}}{0.16666666666666666 + 0.06388888888888888 \cdot {x}^{2}}} \]
    3. +-commutative99.4%

      \[\leadsto \left(0.027777777777777776 - {x}^{4} \cdot 0.00408179012345679\right) \cdot \frac{{x}^{2}}{\color{blue}{0.06388888888888888 \cdot {x}^{2} + 0.16666666666666666}} \]
    4. *-commutative99.4%

      \[\leadsto \left(0.027777777777777776 - {x}^{4} \cdot 0.00408179012345679\right) \cdot \frac{{x}^{2}}{\color{blue}{{x}^{2} \cdot 0.06388888888888888} + 0.16666666666666666} \]
    5. fma-define99.4%

      \[\leadsto \left(0.027777777777777776 - {x}^{4} \cdot 0.00408179012345679\right) \cdot \frac{{x}^{2}}{\color{blue}{\mathsf{fma}\left({x}^{2}, 0.06388888888888888, 0.16666666666666666\right)}} \]
  9. Simplified99.4%

    \[\leadsto \color{blue}{\left(0.027777777777777776 - {x}^{4} \cdot 0.00408179012345679\right) \cdot \frac{{x}^{2}}{\mathsf{fma}\left({x}^{2}, 0.06388888888888888, 0.16666666666666666\right)}} \]
  10. Step-by-step derivation
    1. unpow299.4%

      \[\leadsto \left(0.027777777777777776 - {x}^{4} \cdot 0.00408179012345679\right) \cdot \frac{\color{blue}{x \cdot x}}{\mathsf{fma}\left({x}^{2}, 0.06388888888888888, 0.16666666666666666\right)} \]
    2. fma-undefine99.4%

      \[\leadsto \left(0.027777777777777776 - {x}^{4} \cdot 0.00408179012345679\right) \cdot \frac{x \cdot x}{\color{blue}{{x}^{2} \cdot 0.06388888888888888 + 0.16666666666666666}} \]
    3. *-commutative99.4%

      \[\leadsto \left(0.027777777777777776 - {x}^{4} \cdot 0.00408179012345679\right) \cdot \frac{x \cdot x}{\color{blue}{0.06388888888888888 \cdot {x}^{2}} + 0.16666666666666666} \]
    4. +-commutative99.4%

      \[\leadsto \left(0.027777777777777776 - {x}^{4} \cdot 0.00408179012345679\right) \cdot \frac{x \cdot x}{\color{blue}{0.16666666666666666 + 0.06388888888888888 \cdot {x}^{2}}} \]
    5. associate-/l*99.5%

      \[\leadsto \left(0.027777777777777776 - {x}^{4} \cdot 0.00408179012345679\right) \cdot \color{blue}{\left(x \cdot \frac{x}{0.16666666666666666 + 0.06388888888888888 \cdot {x}^{2}}\right)} \]
    6. +-commutative99.5%

      \[\leadsto \left(0.027777777777777776 - {x}^{4} \cdot 0.00408179012345679\right) \cdot \left(x \cdot \frac{x}{\color{blue}{0.06388888888888888 \cdot {x}^{2} + 0.16666666666666666}}\right) \]
    7. *-commutative99.5%

      \[\leadsto \left(0.027777777777777776 - {x}^{4} \cdot 0.00408179012345679\right) \cdot \left(x \cdot \frac{x}{\color{blue}{{x}^{2} \cdot 0.06388888888888888} + 0.16666666666666666}\right) \]
    8. fma-undefine99.5%

      \[\leadsto \left(0.027777777777777776 - {x}^{4} \cdot 0.00408179012345679\right) \cdot \left(x \cdot \frac{x}{\color{blue}{\mathsf{fma}\left({x}^{2}, 0.06388888888888888, 0.16666666666666666\right)}}\right) \]
  11. Applied egg-rr99.5%

    \[\leadsto \left(0.027777777777777776 - {x}^{4} \cdot 0.00408179012345679\right) \cdot \color{blue}{\left(x \cdot \frac{x}{\mathsf{fma}\left({x}^{2}, 0.06388888888888888, 0.16666666666666666\right)}\right)} \]
  12. Add Preprocessing

Alternative 2: 99.4% accurate, 0.7× speedup?

\[\begin{array}{l} \\ {x}^{2} \cdot \left(0.16666666666666666 + {x}^{2} \cdot \left({x}^{2} \cdot -0.0007275132275132275 - 0.06388888888888888\right)\right) \end{array} \]
(FPCore (x)
 :precision binary64
 (*
  (pow x 2.0)
  (+
   0.16666666666666666
   (*
    (pow x 2.0)
    (- (* (pow x 2.0) -0.0007275132275132275) 0.06388888888888888)))))
double code(double x) {
	return pow(x, 2.0) * (0.16666666666666666 + (pow(x, 2.0) * ((pow(x, 2.0) * -0.0007275132275132275) - 0.06388888888888888)));
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = (x ** 2.0d0) * (0.16666666666666666d0 + ((x ** 2.0d0) * (((x ** 2.0d0) * (-0.0007275132275132275d0)) - 0.06388888888888888d0)))
end function
public static double code(double x) {
	return Math.pow(x, 2.0) * (0.16666666666666666 + (Math.pow(x, 2.0) * ((Math.pow(x, 2.0) * -0.0007275132275132275) - 0.06388888888888888)));
}
def code(x):
	return math.pow(x, 2.0) * (0.16666666666666666 + (math.pow(x, 2.0) * ((math.pow(x, 2.0) * -0.0007275132275132275) - 0.06388888888888888)))
function code(x)
	return Float64((x ^ 2.0) * Float64(0.16666666666666666 + Float64((x ^ 2.0) * Float64(Float64((x ^ 2.0) * -0.0007275132275132275) - 0.06388888888888888))))
end
function tmp = code(x)
	tmp = (x ^ 2.0) * (0.16666666666666666 + ((x ^ 2.0) * (((x ^ 2.0) * -0.0007275132275132275) - 0.06388888888888888)));
end
code[x_] := N[(N[Power[x, 2.0], $MachinePrecision] * N[(0.16666666666666666 + N[(N[Power[x, 2.0], $MachinePrecision] * N[(N[(N[Power[x, 2.0], $MachinePrecision] * -0.0007275132275132275), $MachinePrecision] - 0.06388888888888888), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
{x}^{2} \cdot \left(0.16666666666666666 + {x}^{2} \cdot \left({x}^{2} \cdot -0.0007275132275132275 - 0.06388888888888888\right)\right)
\end{array}
Derivation
  1. Initial program 52.9%

    \[\frac{x - \sin x}{\tan x} \]
  2. Add Preprocessing
  3. Taylor expanded in x around 0 99.5%

    \[\leadsto \color{blue}{{x}^{2} \cdot \left(0.16666666666666666 + {x}^{2} \cdot \left(-0.0007275132275132275 \cdot {x}^{2} - 0.06388888888888888\right)\right)} \]
  4. Final simplification99.5%

    \[\leadsto {x}^{2} \cdot \left(0.16666666666666666 + {x}^{2} \cdot \left({x}^{2} \cdot -0.0007275132275132275 - 0.06388888888888888\right)\right) \]
  5. Add Preprocessing

Alternative 3: 99.3% accurate, 1.8× speedup?

\[\begin{array}{l} \\ x \cdot \left(x \cdot 0.16666666666666666\right) + x \cdot \left(-0.06388888888888888 \cdot {x}^{3}\right) \end{array} \]
(FPCore (x)
 :precision binary64
 (+
  (* x (* x 0.16666666666666666))
  (* x (* -0.06388888888888888 (pow x 3.0)))))
double code(double x) {
	return (x * (x * 0.16666666666666666)) + (x * (-0.06388888888888888 * pow(x, 3.0)));
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = (x * (x * 0.16666666666666666d0)) + (x * ((-0.06388888888888888d0) * (x ** 3.0d0)))
end function
public static double code(double x) {
	return (x * (x * 0.16666666666666666)) + (x * (-0.06388888888888888 * Math.pow(x, 3.0)));
}
def code(x):
	return (x * (x * 0.16666666666666666)) + (x * (-0.06388888888888888 * math.pow(x, 3.0)))
function code(x)
	return Float64(Float64(x * Float64(x * 0.16666666666666666)) + Float64(x * Float64(-0.06388888888888888 * (x ^ 3.0))))
end
function tmp = code(x)
	tmp = (x * (x * 0.16666666666666666)) + (x * (-0.06388888888888888 * (x ^ 3.0)));
end
code[x_] := N[(N[(x * N[(x * 0.16666666666666666), $MachinePrecision]), $MachinePrecision] + N[(x * N[(-0.06388888888888888 * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
x \cdot \left(x \cdot 0.16666666666666666\right) + x \cdot \left(-0.06388888888888888 \cdot {x}^{3}\right)
\end{array}
Derivation
  1. Initial program 52.9%

    \[\frac{x - \sin x}{\tan x} \]
  2. Add Preprocessing
  3. Taylor expanded in x around 0 99.4%

    \[\leadsto \color{blue}{{x}^{2} \cdot \left(0.16666666666666666 + -0.06388888888888888 \cdot {x}^{2}\right)} \]
  4. Step-by-step derivation
    1. *-commutative99.4%

      \[\leadsto {x}^{2} \cdot \left(0.16666666666666666 + \color{blue}{{x}^{2} \cdot -0.06388888888888888}\right) \]
  5. Simplified99.4%

    \[\leadsto \color{blue}{{x}^{2} \cdot \left(0.16666666666666666 + {x}^{2} \cdot -0.06388888888888888\right)} \]
  6. Step-by-step derivation
    1. flip-+99.4%

      \[\leadsto {x}^{2} \cdot \color{blue}{\frac{0.16666666666666666 \cdot 0.16666666666666666 - \left({x}^{2} \cdot -0.06388888888888888\right) \cdot \left({x}^{2} \cdot -0.06388888888888888\right)}{0.16666666666666666 - {x}^{2} \cdot -0.06388888888888888}} \]
    2. associate-*r/99.3%

      \[\leadsto \color{blue}{\frac{{x}^{2} \cdot \left(0.16666666666666666 \cdot 0.16666666666666666 - \left({x}^{2} \cdot -0.06388888888888888\right) \cdot \left({x}^{2} \cdot -0.06388888888888888\right)\right)}{0.16666666666666666 - {x}^{2} \cdot -0.06388888888888888}} \]
    3. metadata-eval99.3%

      \[\leadsto \frac{{x}^{2} \cdot \left(\color{blue}{0.027777777777777776} - \left({x}^{2} \cdot -0.06388888888888888\right) \cdot \left({x}^{2} \cdot -0.06388888888888888\right)\right)}{0.16666666666666666 - {x}^{2} \cdot -0.06388888888888888} \]
    4. swap-sqr99.3%

      \[\leadsto \frac{{x}^{2} \cdot \left(0.027777777777777776 - \color{blue}{\left({x}^{2} \cdot {x}^{2}\right) \cdot \left(-0.06388888888888888 \cdot -0.06388888888888888\right)}\right)}{0.16666666666666666 - {x}^{2} \cdot -0.06388888888888888} \]
    5. pow-prod-up99.3%

      \[\leadsto \frac{{x}^{2} \cdot \left(0.027777777777777776 - \color{blue}{{x}^{\left(2 + 2\right)}} \cdot \left(-0.06388888888888888 \cdot -0.06388888888888888\right)\right)}{0.16666666666666666 - {x}^{2} \cdot -0.06388888888888888} \]
    6. metadata-eval99.3%

      \[\leadsto \frac{{x}^{2} \cdot \left(0.027777777777777776 - {x}^{\color{blue}{4}} \cdot \left(-0.06388888888888888 \cdot -0.06388888888888888\right)\right)}{0.16666666666666666 - {x}^{2} \cdot -0.06388888888888888} \]
    7. metadata-eval99.3%

      \[\leadsto \frac{{x}^{2} \cdot \left(0.027777777777777776 - {x}^{4} \cdot \color{blue}{0.00408179012345679}\right)}{0.16666666666666666 - {x}^{2} \cdot -0.06388888888888888} \]
    8. *-commutative99.3%

      \[\leadsto \frac{{x}^{2} \cdot \left(0.027777777777777776 - {x}^{4} \cdot 0.00408179012345679\right)}{0.16666666666666666 - \color{blue}{-0.06388888888888888 \cdot {x}^{2}}} \]
    9. cancel-sign-sub-inv99.3%

      \[\leadsto \frac{{x}^{2} \cdot \left(0.027777777777777776 - {x}^{4} \cdot 0.00408179012345679\right)}{\color{blue}{0.16666666666666666 + \left(--0.06388888888888888\right) \cdot {x}^{2}}} \]
    10. metadata-eval99.3%

      \[\leadsto \frac{{x}^{2} \cdot \left(0.027777777777777776 - {x}^{4} \cdot 0.00408179012345679\right)}{0.16666666666666666 + \color{blue}{0.06388888888888888} \cdot {x}^{2}} \]
  7. Applied egg-rr99.3%

    \[\leadsto \color{blue}{\frac{{x}^{2} \cdot \left(0.027777777777777776 - {x}^{4} \cdot 0.00408179012345679\right)}{0.16666666666666666 + 0.06388888888888888 \cdot {x}^{2}}} \]
  8. Step-by-step derivation
    1. *-commutative99.3%

      \[\leadsto \frac{\color{blue}{\left(0.027777777777777776 - {x}^{4} \cdot 0.00408179012345679\right) \cdot {x}^{2}}}{0.16666666666666666 + 0.06388888888888888 \cdot {x}^{2}} \]
    2. associate-/l*99.4%

      \[\leadsto \color{blue}{\left(0.027777777777777776 - {x}^{4} \cdot 0.00408179012345679\right) \cdot \frac{{x}^{2}}{0.16666666666666666 + 0.06388888888888888 \cdot {x}^{2}}} \]
    3. +-commutative99.4%

      \[\leadsto \left(0.027777777777777776 - {x}^{4} \cdot 0.00408179012345679\right) \cdot \frac{{x}^{2}}{\color{blue}{0.06388888888888888 \cdot {x}^{2} + 0.16666666666666666}} \]
    4. *-commutative99.4%

      \[\leadsto \left(0.027777777777777776 - {x}^{4} \cdot 0.00408179012345679\right) \cdot \frac{{x}^{2}}{\color{blue}{{x}^{2} \cdot 0.06388888888888888} + 0.16666666666666666} \]
    5. fma-define99.4%

      \[\leadsto \left(0.027777777777777776 - {x}^{4} \cdot 0.00408179012345679\right) \cdot \frac{{x}^{2}}{\color{blue}{\mathsf{fma}\left({x}^{2}, 0.06388888888888888, 0.16666666666666666\right)}} \]
  9. Simplified99.4%

    \[\leadsto \color{blue}{\left(0.027777777777777776 - {x}^{4} \cdot 0.00408179012345679\right) \cdot \frac{{x}^{2}}{\mathsf{fma}\left({x}^{2}, 0.06388888888888888, 0.16666666666666666\right)}} \]
  10. Step-by-step derivation
    1. unpow299.4%

      \[\leadsto \left(0.027777777777777776 - {x}^{4} \cdot 0.00408179012345679\right) \cdot \frac{\color{blue}{x \cdot x}}{\mathsf{fma}\left({x}^{2}, 0.06388888888888888, 0.16666666666666666\right)} \]
    2. fma-undefine99.4%

      \[\leadsto \left(0.027777777777777776 - {x}^{4} \cdot 0.00408179012345679\right) \cdot \frac{x \cdot x}{\color{blue}{{x}^{2} \cdot 0.06388888888888888 + 0.16666666666666666}} \]
    3. *-commutative99.4%

      \[\leadsto \left(0.027777777777777776 - {x}^{4} \cdot 0.00408179012345679\right) \cdot \frac{x \cdot x}{\color{blue}{0.06388888888888888 \cdot {x}^{2}} + 0.16666666666666666} \]
    4. +-commutative99.4%

      \[\leadsto \left(0.027777777777777776 - {x}^{4} \cdot 0.00408179012345679\right) \cdot \frac{x \cdot x}{\color{blue}{0.16666666666666666 + 0.06388888888888888 \cdot {x}^{2}}} \]
    5. associate-/l*99.5%

      \[\leadsto \left(0.027777777777777776 - {x}^{4} \cdot 0.00408179012345679\right) \cdot \color{blue}{\left(x \cdot \frac{x}{0.16666666666666666 + 0.06388888888888888 \cdot {x}^{2}}\right)} \]
    6. +-commutative99.5%

      \[\leadsto \left(0.027777777777777776 - {x}^{4} \cdot 0.00408179012345679\right) \cdot \left(x \cdot \frac{x}{\color{blue}{0.06388888888888888 \cdot {x}^{2} + 0.16666666666666666}}\right) \]
    7. *-commutative99.5%

      \[\leadsto \left(0.027777777777777776 - {x}^{4} \cdot 0.00408179012345679\right) \cdot \left(x \cdot \frac{x}{\color{blue}{{x}^{2} \cdot 0.06388888888888888} + 0.16666666666666666}\right) \]
    8. fma-undefine99.5%

      \[\leadsto \left(0.027777777777777776 - {x}^{4} \cdot 0.00408179012345679\right) \cdot \left(x \cdot \frac{x}{\color{blue}{\mathsf{fma}\left({x}^{2}, 0.06388888888888888, 0.16666666666666666\right)}}\right) \]
  11. Applied egg-rr99.5%

    \[\leadsto \left(0.027777777777777776 - {x}^{4} \cdot 0.00408179012345679\right) \cdot \color{blue}{\left(x \cdot \frac{x}{\mathsf{fma}\left({x}^{2}, 0.06388888888888888, 0.16666666666666666\right)}\right)} \]
  12. Step-by-step derivation
    1. *-commutative99.5%

      \[\leadsto \color{blue}{\left(x \cdot \frac{x}{\mathsf{fma}\left({x}^{2}, 0.06388888888888888, 0.16666666666666666\right)}\right) \cdot \left(0.027777777777777776 - {x}^{4} \cdot 0.00408179012345679\right)} \]
    2. associate-*r/99.4%

      \[\leadsto \color{blue}{\frac{x \cdot x}{\mathsf{fma}\left({x}^{2}, 0.06388888888888888, 0.16666666666666666\right)}} \cdot \left(0.027777777777777776 - {x}^{4} \cdot 0.00408179012345679\right) \]
    3. unpow299.4%

      \[\leadsto \frac{\color{blue}{{x}^{2}}}{\mathsf{fma}\left({x}^{2}, 0.06388888888888888, 0.16666666666666666\right)} \cdot \left(0.027777777777777776 - {x}^{4} \cdot 0.00408179012345679\right) \]
    4. associate-*l/99.3%

      \[\leadsto \color{blue}{\frac{{x}^{2} \cdot \left(0.027777777777777776 - {x}^{4} \cdot 0.00408179012345679\right)}{\mathsf{fma}\left({x}^{2}, 0.06388888888888888, 0.16666666666666666\right)}} \]
    5. *-commutative99.3%

      \[\leadsto \frac{{x}^{2} \cdot \left(0.027777777777777776 - \color{blue}{0.00408179012345679 \cdot {x}^{4}}\right)}{\mathsf{fma}\left({x}^{2}, 0.06388888888888888, 0.16666666666666666\right)} \]
    6. metadata-eval99.3%

      \[\leadsto \frac{{x}^{2} \cdot \left(0.027777777777777776 - \color{blue}{\left(-0.06388888888888888 \cdot -0.06388888888888888\right)} \cdot {x}^{4}\right)}{\mathsf{fma}\left({x}^{2}, 0.06388888888888888, 0.16666666666666666\right)} \]
    7. metadata-eval99.3%

      \[\leadsto \frac{{x}^{2} \cdot \left(0.027777777777777776 - \left(-0.06388888888888888 \cdot -0.06388888888888888\right) \cdot {x}^{\color{blue}{\left(2 \cdot 2\right)}}\right)}{\mathsf{fma}\left({x}^{2}, 0.06388888888888888, 0.16666666666666666\right)} \]
    8. pow-sqr99.3%

      \[\leadsto \frac{{x}^{2} \cdot \left(0.027777777777777776 - \left(-0.06388888888888888 \cdot -0.06388888888888888\right) \cdot \color{blue}{\left({x}^{2} \cdot {x}^{2}\right)}\right)}{\mathsf{fma}\left({x}^{2}, 0.06388888888888888, 0.16666666666666666\right)} \]
    9. swap-sqr99.3%

      \[\leadsto \frac{{x}^{2} \cdot \left(0.027777777777777776 - \color{blue}{\left(-0.06388888888888888 \cdot {x}^{2}\right) \cdot \left(-0.06388888888888888 \cdot {x}^{2}\right)}\right)}{\mathsf{fma}\left({x}^{2}, 0.06388888888888888, 0.16666666666666666\right)} \]
    10. metadata-eval99.3%

      \[\leadsto \frac{{x}^{2} \cdot \left(\color{blue}{0.16666666666666666 \cdot 0.16666666666666666} - \left(-0.06388888888888888 \cdot {x}^{2}\right) \cdot \left(-0.06388888888888888 \cdot {x}^{2}\right)\right)}{\mathsf{fma}\left({x}^{2}, 0.06388888888888888, 0.16666666666666666\right)} \]
    11. fma-undefine99.3%

      \[\leadsto \frac{{x}^{2} \cdot \left(0.16666666666666666 \cdot 0.16666666666666666 - \left(-0.06388888888888888 \cdot {x}^{2}\right) \cdot \left(-0.06388888888888888 \cdot {x}^{2}\right)\right)}{\color{blue}{{x}^{2} \cdot 0.06388888888888888 + 0.16666666666666666}} \]
    12. metadata-eval99.3%

      \[\leadsto \frac{{x}^{2} \cdot \left(0.16666666666666666 \cdot 0.16666666666666666 - \left(-0.06388888888888888 \cdot {x}^{2}\right) \cdot \left(-0.06388888888888888 \cdot {x}^{2}\right)\right)}{{x}^{\color{blue}{\left(\frac{4}{2}\right)}} \cdot 0.06388888888888888 + 0.16666666666666666} \]
    13. sqrt-pow199.3%

      \[\leadsto \frac{{x}^{2} \cdot \left(0.16666666666666666 \cdot 0.16666666666666666 - \left(-0.06388888888888888 \cdot {x}^{2}\right) \cdot \left(-0.06388888888888888 \cdot {x}^{2}\right)\right)}{\color{blue}{\sqrt{{x}^{4}}} \cdot 0.06388888888888888 + 0.16666666666666666} \]
    14. metadata-eval99.3%

      \[\leadsto \frac{{x}^{2} \cdot \left(0.16666666666666666 \cdot 0.16666666666666666 - \left(-0.06388888888888888 \cdot {x}^{2}\right) \cdot \left(-0.06388888888888888 \cdot {x}^{2}\right)\right)}{\sqrt{{x}^{4}} \cdot \color{blue}{\sqrt{0.00408179012345679}} + 0.16666666666666666} \]
    15. sqrt-prod99.3%

      \[\leadsto \frac{{x}^{2} \cdot \left(0.16666666666666666 \cdot 0.16666666666666666 - \left(-0.06388888888888888 \cdot {x}^{2}\right) \cdot \left(-0.06388888888888888 \cdot {x}^{2}\right)\right)}{\color{blue}{\sqrt{{x}^{4} \cdot 0.00408179012345679}} + 0.16666666666666666} \]
    16. +-commutative99.3%

      \[\leadsto \frac{{x}^{2} \cdot \left(0.16666666666666666 \cdot 0.16666666666666666 - \left(-0.06388888888888888 \cdot {x}^{2}\right) \cdot \left(-0.06388888888888888 \cdot {x}^{2}\right)\right)}{\color{blue}{0.16666666666666666 + \sqrt{{x}^{4} \cdot 0.00408179012345679}}} \]
    17. *-commutative99.3%

      \[\leadsto \frac{{x}^{2} \cdot \left(0.16666666666666666 \cdot 0.16666666666666666 - \left(-0.06388888888888888 \cdot {x}^{2}\right) \cdot \left(-0.06388888888888888 \cdot {x}^{2}\right)\right)}{0.16666666666666666 + \sqrt{\color{blue}{0.00408179012345679 \cdot {x}^{4}}}} \]
    18. sqrt-prod99.3%

      \[\leadsto \frac{{x}^{2} \cdot \left(0.16666666666666666 \cdot 0.16666666666666666 - \left(-0.06388888888888888 \cdot {x}^{2}\right) \cdot \left(-0.06388888888888888 \cdot {x}^{2}\right)\right)}{0.16666666666666666 + \color{blue}{\sqrt{0.00408179012345679} \cdot \sqrt{{x}^{4}}}} \]
    19. metadata-eval99.3%

      \[\leadsto \frac{{x}^{2} \cdot \left(0.16666666666666666 \cdot 0.16666666666666666 - \left(-0.06388888888888888 \cdot {x}^{2}\right) \cdot \left(-0.06388888888888888 \cdot {x}^{2}\right)\right)}{0.16666666666666666 + \color{blue}{0.06388888888888888} \cdot \sqrt{{x}^{4}}} \]
    20. metadata-eval99.3%

      \[\leadsto \frac{{x}^{2} \cdot \left(0.16666666666666666 \cdot 0.16666666666666666 - \left(-0.06388888888888888 \cdot {x}^{2}\right) \cdot \left(-0.06388888888888888 \cdot {x}^{2}\right)\right)}{0.16666666666666666 + \color{blue}{\left(--0.06388888888888888\right)} \cdot \sqrt{{x}^{4}}} \]
  13. Applied egg-rr99.5%

    \[\leadsto \color{blue}{\left(x \cdot 0.16666666666666666\right) \cdot x + \left(-0.06388888888888888 \cdot {x}^{3}\right) \cdot x} \]
  14. Final simplification99.5%

    \[\leadsto x \cdot \left(x \cdot 0.16666666666666666\right) + x \cdot \left(-0.06388888888888888 \cdot {x}^{3}\right) \]
  15. Add Preprocessing

Alternative 4: 99.3% accurate, 1.9× speedup?

\[\begin{array}{l} \\ x \cdot \left(x \cdot 0.16666666666666666 + -0.06388888888888888 \cdot {x}^{3}\right) \end{array} \]
(FPCore (x)
 :precision binary64
 (* x (+ (* x 0.16666666666666666) (* -0.06388888888888888 (pow x 3.0)))))
double code(double x) {
	return x * ((x * 0.16666666666666666) + (-0.06388888888888888 * pow(x, 3.0)));
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = x * ((x * 0.16666666666666666d0) + ((-0.06388888888888888d0) * (x ** 3.0d0)))
end function
public static double code(double x) {
	return x * ((x * 0.16666666666666666) + (-0.06388888888888888 * Math.pow(x, 3.0)));
}
def code(x):
	return x * ((x * 0.16666666666666666) + (-0.06388888888888888 * math.pow(x, 3.0)))
function code(x)
	return Float64(x * Float64(Float64(x * 0.16666666666666666) + Float64(-0.06388888888888888 * (x ^ 3.0))))
end
function tmp = code(x)
	tmp = x * ((x * 0.16666666666666666) + (-0.06388888888888888 * (x ^ 3.0)));
end
code[x_] := N[(x * N[(N[(x * 0.16666666666666666), $MachinePrecision] + N[(-0.06388888888888888 * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
x \cdot \left(x \cdot 0.16666666666666666 + -0.06388888888888888 \cdot {x}^{3}\right)
\end{array}
Derivation
  1. Initial program 52.9%

    \[\frac{x - \sin x}{\tan x} \]
  2. Add Preprocessing
  3. Taylor expanded in x around 0 99.4%

    \[\leadsto \color{blue}{{x}^{2} \cdot \left(0.16666666666666666 + -0.06388888888888888 \cdot {x}^{2}\right)} \]
  4. Step-by-step derivation
    1. *-commutative99.4%

      \[\leadsto {x}^{2} \cdot \left(0.16666666666666666 + \color{blue}{{x}^{2} \cdot -0.06388888888888888}\right) \]
  5. Simplified99.4%

    \[\leadsto \color{blue}{{x}^{2} \cdot \left(0.16666666666666666 + {x}^{2} \cdot -0.06388888888888888\right)} \]
  6. Step-by-step derivation
    1. flip-+99.4%

      \[\leadsto {x}^{2} \cdot \color{blue}{\frac{0.16666666666666666 \cdot 0.16666666666666666 - \left({x}^{2} \cdot -0.06388888888888888\right) \cdot \left({x}^{2} \cdot -0.06388888888888888\right)}{0.16666666666666666 - {x}^{2} \cdot -0.06388888888888888}} \]
    2. associate-*r/99.3%

      \[\leadsto \color{blue}{\frac{{x}^{2} \cdot \left(0.16666666666666666 \cdot 0.16666666666666666 - \left({x}^{2} \cdot -0.06388888888888888\right) \cdot \left({x}^{2} \cdot -0.06388888888888888\right)\right)}{0.16666666666666666 - {x}^{2} \cdot -0.06388888888888888}} \]
    3. metadata-eval99.3%

      \[\leadsto \frac{{x}^{2} \cdot \left(\color{blue}{0.027777777777777776} - \left({x}^{2} \cdot -0.06388888888888888\right) \cdot \left({x}^{2} \cdot -0.06388888888888888\right)\right)}{0.16666666666666666 - {x}^{2} \cdot -0.06388888888888888} \]
    4. swap-sqr99.3%

      \[\leadsto \frac{{x}^{2} \cdot \left(0.027777777777777776 - \color{blue}{\left({x}^{2} \cdot {x}^{2}\right) \cdot \left(-0.06388888888888888 \cdot -0.06388888888888888\right)}\right)}{0.16666666666666666 - {x}^{2} \cdot -0.06388888888888888} \]
    5. pow-prod-up99.3%

      \[\leadsto \frac{{x}^{2} \cdot \left(0.027777777777777776 - \color{blue}{{x}^{\left(2 + 2\right)}} \cdot \left(-0.06388888888888888 \cdot -0.06388888888888888\right)\right)}{0.16666666666666666 - {x}^{2} \cdot -0.06388888888888888} \]
    6. metadata-eval99.3%

      \[\leadsto \frac{{x}^{2} \cdot \left(0.027777777777777776 - {x}^{\color{blue}{4}} \cdot \left(-0.06388888888888888 \cdot -0.06388888888888888\right)\right)}{0.16666666666666666 - {x}^{2} \cdot -0.06388888888888888} \]
    7. metadata-eval99.3%

      \[\leadsto \frac{{x}^{2} \cdot \left(0.027777777777777776 - {x}^{4} \cdot \color{blue}{0.00408179012345679}\right)}{0.16666666666666666 - {x}^{2} \cdot -0.06388888888888888} \]
    8. *-commutative99.3%

      \[\leadsto \frac{{x}^{2} \cdot \left(0.027777777777777776 - {x}^{4} \cdot 0.00408179012345679\right)}{0.16666666666666666 - \color{blue}{-0.06388888888888888 \cdot {x}^{2}}} \]
    9. cancel-sign-sub-inv99.3%

      \[\leadsto \frac{{x}^{2} \cdot \left(0.027777777777777776 - {x}^{4} \cdot 0.00408179012345679\right)}{\color{blue}{0.16666666666666666 + \left(--0.06388888888888888\right) \cdot {x}^{2}}} \]
    10. metadata-eval99.3%

      \[\leadsto \frac{{x}^{2} \cdot \left(0.027777777777777776 - {x}^{4} \cdot 0.00408179012345679\right)}{0.16666666666666666 + \color{blue}{0.06388888888888888} \cdot {x}^{2}} \]
  7. Applied egg-rr99.3%

    \[\leadsto \color{blue}{\frac{{x}^{2} \cdot \left(0.027777777777777776 - {x}^{4} \cdot 0.00408179012345679\right)}{0.16666666666666666 + 0.06388888888888888 \cdot {x}^{2}}} \]
  8. Step-by-step derivation
    1. associate-/l*99.4%

      \[\leadsto \color{blue}{{x}^{2} \cdot \frac{0.027777777777777776 - {x}^{4} \cdot 0.00408179012345679}{0.16666666666666666 + 0.06388888888888888 \cdot {x}^{2}}} \]
    2. unpow299.4%

      \[\leadsto \color{blue}{\left(x \cdot x\right)} \cdot \frac{0.027777777777777776 - {x}^{4} \cdot 0.00408179012345679}{0.16666666666666666 + 0.06388888888888888 \cdot {x}^{2}} \]
    3. associate-*l*99.4%

      \[\leadsto \color{blue}{x \cdot \left(x \cdot \frac{0.027777777777777776 - {x}^{4} \cdot 0.00408179012345679}{0.16666666666666666 + 0.06388888888888888 \cdot {x}^{2}}\right)} \]
    4. metadata-eval99.4%

      \[\leadsto x \cdot \left(x \cdot \frac{\color{blue}{0.16666666666666666 \cdot 0.16666666666666666} - {x}^{4} \cdot 0.00408179012345679}{0.16666666666666666 + 0.06388888888888888 \cdot {x}^{2}}\right) \]
    5. *-commutative99.4%

      \[\leadsto x \cdot \left(x \cdot \frac{0.16666666666666666 \cdot 0.16666666666666666 - \color{blue}{0.00408179012345679 \cdot {x}^{4}}}{0.16666666666666666 + 0.06388888888888888 \cdot {x}^{2}}\right) \]
    6. metadata-eval99.4%

      \[\leadsto x \cdot \left(x \cdot \frac{0.16666666666666666 \cdot 0.16666666666666666 - 0.00408179012345679 \cdot {x}^{\color{blue}{\left(2 \cdot 2\right)}}}{0.16666666666666666 + 0.06388888888888888 \cdot {x}^{2}}\right) \]
    7. pow-sqr99.4%

      \[\leadsto x \cdot \left(x \cdot \frac{0.16666666666666666 \cdot 0.16666666666666666 - 0.00408179012345679 \cdot \color{blue}{\left({x}^{2} \cdot {x}^{2}\right)}}{0.16666666666666666 + 0.06388888888888888 \cdot {x}^{2}}\right) \]
    8. metadata-eval99.4%

      \[\leadsto x \cdot \left(x \cdot \frac{0.16666666666666666 \cdot 0.16666666666666666 - \color{blue}{\left(0.06388888888888888 \cdot 0.06388888888888888\right)} \cdot \left({x}^{2} \cdot {x}^{2}\right)}{0.16666666666666666 + 0.06388888888888888 \cdot {x}^{2}}\right) \]
    9. swap-sqr99.4%

      \[\leadsto x \cdot \left(x \cdot \frac{0.16666666666666666 \cdot 0.16666666666666666 - \color{blue}{\left(0.06388888888888888 \cdot {x}^{2}\right) \cdot \left(0.06388888888888888 \cdot {x}^{2}\right)}}{0.16666666666666666 + 0.06388888888888888 \cdot {x}^{2}}\right) \]
    10. flip--99.4%

      \[\leadsto x \cdot \left(x \cdot \color{blue}{\left(0.16666666666666666 - 0.06388888888888888 \cdot {x}^{2}\right)}\right) \]
    11. cancel-sign-sub-inv99.4%

      \[\leadsto x \cdot \left(x \cdot \color{blue}{\left(0.16666666666666666 + \left(-0.06388888888888888\right) \cdot {x}^{2}\right)}\right) \]
    12. metadata-eval99.4%

      \[\leadsto x \cdot \left(x \cdot \left(0.16666666666666666 + \color{blue}{-0.06388888888888888} \cdot {x}^{2}\right)\right) \]
  9. Applied egg-rr99.4%

    \[\leadsto \color{blue}{x \cdot \left(x \cdot \left(0.16666666666666666 + -0.06388888888888888 \cdot {x}^{2}\right)\right)} \]
  10. Step-by-step derivation
    1. distribute-lft-in99.4%

      \[\leadsto x \cdot \color{blue}{\left(x \cdot 0.16666666666666666 + x \cdot \left(-0.06388888888888888 \cdot {x}^{2}\right)\right)} \]
    2. *-commutative99.4%

      \[\leadsto x \cdot \left(x \cdot 0.16666666666666666 + \color{blue}{\left(-0.06388888888888888 \cdot {x}^{2}\right) \cdot x}\right) \]
    3. associate-*l*99.4%

      \[\leadsto x \cdot \left(x \cdot 0.16666666666666666 + \color{blue}{-0.06388888888888888 \cdot \left({x}^{2} \cdot x\right)}\right) \]
    4. unpow299.4%

      \[\leadsto x \cdot \left(x \cdot 0.16666666666666666 + -0.06388888888888888 \cdot \left(\color{blue}{\left(x \cdot x\right)} \cdot x\right)\right) \]
    5. unpow399.4%

      \[\leadsto x \cdot \left(x \cdot 0.16666666666666666 + -0.06388888888888888 \cdot \color{blue}{{x}^{3}}\right) \]
  11. Applied egg-rr99.4%

    \[\leadsto x \cdot \color{blue}{\left(x \cdot 0.16666666666666666 + -0.06388888888888888 \cdot {x}^{3}\right)} \]
  12. Add Preprocessing

Alternative 5: 99.3% accurate, 1.9× speedup?

\[\begin{array}{l} \\ x \cdot \left(x \cdot \left(0.16666666666666666 + {x}^{2} \cdot -0.06388888888888888\right)\right) \end{array} \]
(FPCore (x)
 :precision binary64
 (* x (* x (+ 0.16666666666666666 (* (pow x 2.0) -0.06388888888888888)))))
double code(double x) {
	return x * (x * (0.16666666666666666 + (pow(x, 2.0) * -0.06388888888888888)));
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = x * (x * (0.16666666666666666d0 + ((x ** 2.0d0) * (-0.06388888888888888d0))))
end function
public static double code(double x) {
	return x * (x * (0.16666666666666666 + (Math.pow(x, 2.0) * -0.06388888888888888)));
}
def code(x):
	return x * (x * (0.16666666666666666 + (math.pow(x, 2.0) * -0.06388888888888888)))
function code(x)
	return Float64(x * Float64(x * Float64(0.16666666666666666 + Float64((x ^ 2.0) * -0.06388888888888888))))
end
function tmp = code(x)
	tmp = x * (x * (0.16666666666666666 + ((x ^ 2.0) * -0.06388888888888888)));
end
code[x_] := N[(x * N[(x * N[(0.16666666666666666 + N[(N[Power[x, 2.0], $MachinePrecision] * -0.06388888888888888), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
x \cdot \left(x \cdot \left(0.16666666666666666 + {x}^{2} \cdot -0.06388888888888888\right)\right)
\end{array}
Derivation
  1. Initial program 52.9%

    \[\frac{x - \sin x}{\tan x} \]
  2. Add Preprocessing
  3. Taylor expanded in x around 0 99.4%

    \[\leadsto \color{blue}{{x}^{2} \cdot \left(0.16666666666666666 + -0.06388888888888888 \cdot {x}^{2}\right)} \]
  4. Step-by-step derivation
    1. *-commutative99.4%

      \[\leadsto {x}^{2} \cdot \left(0.16666666666666666 + \color{blue}{{x}^{2} \cdot -0.06388888888888888}\right) \]
  5. Simplified99.4%

    \[\leadsto \color{blue}{{x}^{2} \cdot \left(0.16666666666666666 + {x}^{2} \cdot -0.06388888888888888\right)} \]
  6. Step-by-step derivation
    1. flip-+99.4%

      \[\leadsto {x}^{2} \cdot \color{blue}{\frac{0.16666666666666666 \cdot 0.16666666666666666 - \left({x}^{2} \cdot -0.06388888888888888\right) \cdot \left({x}^{2} \cdot -0.06388888888888888\right)}{0.16666666666666666 - {x}^{2} \cdot -0.06388888888888888}} \]
    2. associate-*r/99.3%

      \[\leadsto \color{blue}{\frac{{x}^{2} \cdot \left(0.16666666666666666 \cdot 0.16666666666666666 - \left({x}^{2} \cdot -0.06388888888888888\right) \cdot \left({x}^{2} \cdot -0.06388888888888888\right)\right)}{0.16666666666666666 - {x}^{2} \cdot -0.06388888888888888}} \]
    3. metadata-eval99.3%

      \[\leadsto \frac{{x}^{2} \cdot \left(\color{blue}{0.027777777777777776} - \left({x}^{2} \cdot -0.06388888888888888\right) \cdot \left({x}^{2} \cdot -0.06388888888888888\right)\right)}{0.16666666666666666 - {x}^{2} \cdot -0.06388888888888888} \]
    4. swap-sqr99.3%

      \[\leadsto \frac{{x}^{2} \cdot \left(0.027777777777777776 - \color{blue}{\left({x}^{2} \cdot {x}^{2}\right) \cdot \left(-0.06388888888888888 \cdot -0.06388888888888888\right)}\right)}{0.16666666666666666 - {x}^{2} \cdot -0.06388888888888888} \]
    5. pow-prod-up99.3%

      \[\leadsto \frac{{x}^{2} \cdot \left(0.027777777777777776 - \color{blue}{{x}^{\left(2 + 2\right)}} \cdot \left(-0.06388888888888888 \cdot -0.06388888888888888\right)\right)}{0.16666666666666666 - {x}^{2} \cdot -0.06388888888888888} \]
    6. metadata-eval99.3%

      \[\leadsto \frac{{x}^{2} \cdot \left(0.027777777777777776 - {x}^{\color{blue}{4}} \cdot \left(-0.06388888888888888 \cdot -0.06388888888888888\right)\right)}{0.16666666666666666 - {x}^{2} \cdot -0.06388888888888888} \]
    7. metadata-eval99.3%

      \[\leadsto \frac{{x}^{2} \cdot \left(0.027777777777777776 - {x}^{4} \cdot \color{blue}{0.00408179012345679}\right)}{0.16666666666666666 - {x}^{2} \cdot -0.06388888888888888} \]
    8. *-commutative99.3%

      \[\leadsto \frac{{x}^{2} \cdot \left(0.027777777777777776 - {x}^{4} \cdot 0.00408179012345679\right)}{0.16666666666666666 - \color{blue}{-0.06388888888888888 \cdot {x}^{2}}} \]
    9. cancel-sign-sub-inv99.3%

      \[\leadsto \frac{{x}^{2} \cdot \left(0.027777777777777776 - {x}^{4} \cdot 0.00408179012345679\right)}{\color{blue}{0.16666666666666666 + \left(--0.06388888888888888\right) \cdot {x}^{2}}} \]
    10. metadata-eval99.3%

      \[\leadsto \frac{{x}^{2} \cdot \left(0.027777777777777776 - {x}^{4} \cdot 0.00408179012345679\right)}{0.16666666666666666 + \color{blue}{0.06388888888888888} \cdot {x}^{2}} \]
  7. Applied egg-rr99.3%

    \[\leadsto \color{blue}{\frac{{x}^{2} \cdot \left(0.027777777777777776 - {x}^{4} \cdot 0.00408179012345679\right)}{0.16666666666666666 + 0.06388888888888888 \cdot {x}^{2}}} \]
  8. Step-by-step derivation
    1. associate-/l*99.4%

      \[\leadsto \color{blue}{{x}^{2} \cdot \frac{0.027777777777777776 - {x}^{4} \cdot 0.00408179012345679}{0.16666666666666666 + 0.06388888888888888 \cdot {x}^{2}}} \]
    2. unpow299.4%

      \[\leadsto \color{blue}{\left(x \cdot x\right)} \cdot \frac{0.027777777777777776 - {x}^{4} \cdot 0.00408179012345679}{0.16666666666666666 + 0.06388888888888888 \cdot {x}^{2}} \]
    3. associate-*l*99.4%

      \[\leadsto \color{blue}{x \cdot \left(x \cdot \frac{0.027777777777777776 - {x}^{4} \cdot 0.00408179012345679}{0.16666666666666666 + 0.06388888888888888 \cdot {x}^{2}}\right)} \]
    4. metadata-eval99.4%

      \[\leadsto x \cdot \left(x \cdot \frac{\color{blue}{0.16666666666666666 \cdot 0.16666666666666666} - {x}^{4} \cdot 0.00408179012345679}{0.16666666666666666 + 0.06388888888888888 \cdot {x}^{2}}\right) \]
    5. *-commutative99.4%

      \[\leadsto x \cdot \left(x \cdot \frac{0.16666666666666666 \cdot 0.16666666666666666 - \color{blue}{0.00408179012345679 \cdot {x}^{4}}}{0.16666666666666666 + 0.06388888888888888 \cdot {x}^{2}}\right) \]
    6. metadata-eval99.4%

      \[\leadsto x \cdot \left(x \cdot \frac{0.16666666666666666 \cdot 0.16666666666666666 - 0.00408179012345679 \cdot {x}^{\color{blue}{\left(2 \cdot 2\right)}}}{0.16666666666666666 + 0.06388888888888888 \cdot {x}^{2}}\right) \]
    7. pow-sqr99.4%

      \[\leadsto x \cdot \left(x \cdot \frac{0.16666666666666666 \cdot 0.16666666666666666 - 0.00408179012345679 \cdot \color{blue}{\left({x}^{2} \cdot {x}^{2}\right)}}{0.16666666666666666 + 0.06388888888888888 \cdot {x}^{2}}\right) \]
    8. metadata-eval99.4%

      \[\leadsto x \cdot \left(x \cdot \frac{0.16666666666666666 \cdot 0.16666666666666666 - \color{blue}{\left(0.06388888888888888 \cdot 0.06388888888888888\right)} \cdot \left({x}^{2} \cdot {x}^{2}\right)}{0.16666666666666666 + 0.06388888888888888 \cdot {x}^{2}}\right) \]
    9. swap-sqr99.4%

      \[\leadsto x \cdot \left(x \cdot \frac{0.16666666666666666 \cdot 0.16666666666666666 - \color{blue}{\left(0.06388888888888888 \cdot {x}^{2}\right) \cdot \left(0.06388888888888888 \cdot {x}^{2}\right)}}{0.16666666666666666 + 0.06388888888888888 \cdot {x}^{2}}\right) \]
    10. flip--99.4%

      \[\leadsto x \cdot \left(x \cdot \color{blue}{\left(0.16666666666666666 - 0.06388888888888888 \cdot {x}^{2}\right)}\right) \]
    11. cancel-sign-sub-inv99.4%

      \[\leadsto x \cdot \left(x \cdot \color{blue}{\left(0.16666666666666666 + \left(-0.06388888888888888\right) \cdot {x}^{2}\right)}\right) \]
    12. metadata-eval99.4%

      \[\leadsto x \cdot \left(x \cdot \left(0.16666666666666666 + \color{blue}{-0.06388888888888888} \cdot {x}^{2}\right)\right) \]
  9. Applied egg-rr99.4%

    \[\leadsto \color{blue}{x \cdot \left(x \cdot \left(0.16666666666666666 + -0.06388888888888888 \cdot {x}^{2}\right)\right)} \]
  10. Final simplification99.4%

    \[\leadsto x \cdot \left(x \cdot \left(0.16666666666666666 + {x}^{2} \cdot -0.06388888888888888\right)\right) \]
  11. Add Preprocessing

Alternative 6: 98.6% accurate, 41.0× speedup?

\[\begin{array}{l} \\ x \cdot \left(x \cdot 0.16666666666666666\right) \end{array} \]
(FPCore (x) :precision binary64 (* x (* x 0.16666666666666666)))
double code(double x) {
	return x * (x * 0.16666666666666666);
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = x * (x * 0.16666666666666666d0)
end function
public static double code(double x) {
	return x * (x * 0.16666666666666666);
}
def code(x):
	return x * (x * 0.16666666666666666)
function code(x)
	return Float64(x * Float64(x * 0.16666666666666666))
end
function tmp = code(x)
	tmp = x * (x * 0.16666666666666666);
end
code[x_] := N[(x * N[(x * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
x \cdot \left(x \cdot 0.16666666666666666\right)
\end{array}
Derivation
  1. Initial program 52.9%

    \[\frac{x - \sin x}{\tan x} \]
  2. Add Preprocessing
  3. Taylor expanded in x around 0 99.4%

    \[\leadsto \color{blue}{{x}^{2} \cdot \left(0.16666666666666666 + -0.06388888888888888 \cdot {x}^{2}\right)} \]
  4. Step-by-step derivation
    1. *-commutative99.4%

      \[\leadsto {x}^{2} \cdot \left(0.16666666666666666 + \color{blue}{{x}^{2} \cdot -0.06388888888888888}\right) \]
  5. Simplified99.4%

    \[\leadsto \color{blue}{{x}^{2} \cdot \left(0.16666666666666666 + {x}^{2} \cdot -0.06388888888888888\right)} \]
  6. Step-by-step derivation
    1. flip-+99.4%

      \[\leadsto {x}^{2} \cdot \color{blue}{\frac{0.16666666666666666 \cdot 0.16666666666666666 - \left({x}^{2} \cdot -0.06388888888888888\right) \cdot \left({x}^{2} \cdot -0.06388888888888888\right)}{0.16666666666666666 - {x}^{2} \cdot -0.06388888888888888}} \]
    2. associate-*r/99.3%

      \[\leadsto \color{blue}{\frac{{x}^{2} \cdot \left(0.16666666666666666 \cdot 0.16666666666666666 - \left({x}^{2} \cdot -0.06388888888888888\right) \cdot \left({x}^{2} \cdot -0.06388888888888888\right)\right)}{0.16666666666666666 - {x}^{2} \cdot -0.06388888888888888}} \]
    3. metadata-eval99.3%

      \[\leadsto \frac{{x}^{2} \cdot \left(\color{blue}{0.027777777777777776} - \left({x}^{2} \cdot -0.06388888888888888\right) \cdot \left({x}^{2} \cdot -0.06388888888888888\right)\right)}{0.16666666666666666 - {x}^{2} \cdot -0.06388888888888888} \]
    4. swap-sqr99.3%

      \[\leadsto \frac{{x}^{2} \cdot \left(0.027777777777777776 - \color{blue}{\left({x}^{2} \cdot {x}^{2}\right) \cdot \left(-0.06388888888888888 \cdot -0.06388888888888888\right)}\right)}{0.16666666666666666 - {x}^{2} \cdot -0.06388888888888888} \]
    5. pow-prod-up99.3%

      \[\leadsto \frac{{x}^{2} \cdot \left(0.027777777777777776 - \color{blue}{{x}^{\left(2 + 2\right)}} \cdot \left(-0.06388888888888888 \cdot -0.06388888888888888\right)\right)}{0.16666666666666666 - {x}^{2} \cdot -0.06388888888888888} \]
    6. metadata-eval99.3%

      \[\leadsto \frac{{x}^{2} \cdot \left(0.027777777777777776 - {x}^{\color{blue}{4}} \cdot \left(-0.06388888888888888 \cdot -0.06388888888888888\right)\right)}{0.16666666666666666 - {x}^{2} \cdot -0.06388888888888888} \]
    7. metadata-eval99.3%

      \[\leadsto \frac{{x}^{2} \cdot \left(0.027777777777777776 - {x}^{4} \cdot \color{blue}{0.00408179012345679}\right)}{0.16666666666666666 - {x}^{2} \cdot -0.06388888888888888} \]
    8. *-commutative99.3%

      \[\leadsto \frac{{x}^{2} \cdot \left(0.027777777777777776 - {x}^{4} \cdot 0.00408179012345679\right)}{0.16666666666666666 - \color{blue}{-0.06388888888888888 \cdot {x}^{2}}} \]
    9. cancel-sign-sub-inv99.3%

      \[\leadsto \frac{{x}^{2} \cdot \left(0.027777777777777776 - {x}^{4} \cdot 0.00408179012345679\right)}{\color{blue}{0.16666666666666666 + \left(--0.06388888888888888\right) \cdot {x}^{2}}} \]
    10. metadata-eval99.3%

      \[\leadsto \frac{{x}^{2} \cdot \left(0.027777777777777776 - {x}^{4} \cdot 0.00408179012345679\right)}{0.16666666666666666 + \color{blue}{0.06388888888888888} \cdot {x}^{2}} \]
  7. Applied egg-rr99.3%

    \[\leadsto \color{blue}{\frac{{x}^{2} \cdot \left(0.027777777777777776 - {x}^{4} \cdot 0.00408179012345679\right)}{0.16666666666666666 + 0.06388888888888888 \cdot {x}^{2}}} \]
  8. Step-by-step derivation
    1. associate-/l*99.4%

      \[\leadsto \color{blue}{{x}^{2} \cdot \frac{0.027777777777777776 - {x}^{4} \cdot 0.00408179012345679}{0.16666666666666666 + 0.06388888888888888 \cdot {x}^{2}}} \]
    2. unpow299.4%

      \[\leadsto \color{blue}{\left(x \cdot x\right)} \cdot \frac{0.027777777777777776 - {x}^{4} \cdot 0.00408179012345679}{0.16666666666666666 + 0.06388888888888888 \cdot {x}^{2}} \]
    3. associate-*l*99.4%

      \[\leadsto \color{blue}{x \cdot \left(x \cdot \frac{0.027777777777777776 - {x}^{4} \cdot 0.00408179012345679}{0.16666666666666666 + 0.06388888888888888 \cdot {x}^{2}}\right)} \]
    4. metadata-eval99.4%

      \[\leadsto x \cdot \left(x \cdot \frac{\color{blue}{0.16666666666666666 \cdot 0.16666666666666666} - {x}^{4} \cdot 0.00408179012345679}{0.16666666666666666 + 0.06388888888888888 \cdot {x}^{2}}\right) \]
    5. *-commutative99.4%

      \[\leadsto x \cdot \left(x \cdot \frac{0.16666666666666666 \cdot 0.16666666666666666 - \color{blue}{0.00408179012345679 \cdot {x}^{4}}}{0.16666666666666666 + 0.06388888888888888 \cdot {x}^{2}}\right) \]
    6. metadata-eval99.4%

      \[\leadsto x \cdot \left(x \cdot \frac{0.16666666666666666 \cdot 0.16666666666666666 - 0.00408179012345679 \cdot {x}^{\color{blue}{\left(2 \cdot 2\right)}}}{0.16666666666666666 + 0.06388888888888888 \cdot {x}^{2}}\right) \]
    7. pow-sqr99.4%

      \[\leadsto x \cdot \left(x \cdot \frac{0.16666666666666666 \cdot 0.16666666666666666 - 0.00408179012345679 \cdot \color{blue}{\left({x}^{2} \cdot {x}^{2}\right)}}{0.16666666666666666 + 0.06388888888888888 \cdot {x}^{2}}\right) \]
    8. metadata-eval99.4%

      \[\leadsto x \cdot \left(x \cdot \frac{0.16666666666666666 \cdot 0.16666666666666666 - \color{blue}{\left(0.06388888888888888 \cdot 0.06388888888888888\right)} \cdot \left({x}^{2} \cdot {x}^{2}\right)}{0.16666666666666666 + 0.06388888888888888 \cdot {x}^{2}}\right) \]
    9. swap-sqr99.4%

      \[\leadsto x \cdot \left(x \cdot \frac{0.16666666666666666 \cdot 0.16666666666666666 - \color{blue}{\left(0.06388888888888888 \cdot {x}^{2}\right) \cdot \left(0.06388888888888888 \cdot {x}^{2}\right)}}{0.16666666666666666 + 0.06388888888888888 \cdot {x}^{2}}\right) \]
    10. flip--99.4%

      \[\leadsto x \cdot \left(x \cdot \color{blue}{\left(0.16666666666666666 - 0.06388888888888888 \cdot {x}^{2}\right)}\right) \]
    11. cancel-sign-sub-inv99.4%

      \[\leadsto x \cdot \left(x \cdot \color{blue}{\left(0.16666666666666666 + \left(-0.06388888888888888\right) \cdot {x}^{2}\right)}\right) \]
    12. metadata-eval99.4%

      \[\leadsto x \cdot \left(x \cdot \left(0.16666666666666666 + \color{blue}{-0.06388888888888888} \cdot {x}^{2}\right)\right) \]
  9. Applied egg-rr99.4%

    \[\leadsto \color{blue}{x \cdot \left(x \cdot \left(0.16666666666666666 + -0.06388888888888888 \cdot {x}^{2}\right)\right)} \]
  10. Taylor expanded in x around 0 99.1%

    \[\leadsto x \cdot \color{blue}{\left(0.16666666666666666 \cdot x\right)} \]
  11. Step-by-step derivation
    1. *-commutative99.1%

      \[\leadsto x \cdot \color{blue}{\left(x \cdot 0.16666666666666666\right)} \]
  12. Simplified99.1%

    \[\leadsto x \cdot \color{blue}{\left(x \cdot 0.16666666666666666\right)} \]
  13. Add Preprocessing

Alternative 7: 4.3% accurate, 205.0× speedup?

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

\\
1
\end{array}
Derivation
  1. Initial program 52.9%

    \[\frac{x - \sin x}{\tan x} \]
  2. Add Preprocessing
  3. Taylor expanded in x around inf 4.2%

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

    \[\leadsto \color{blue}{1} \]
  5. Add Preprocessing

Developer target: 98.6% accurate, 41.0× speedup?

\[\begin{array}{l} \\ 0.16666666666666666 \cdot \left(x \cdot x\right) \end{array} \]
(FPCore (x) :precision binary64 (* 0.16666666666666666 (* x x)))
double code(double x) {
	return 0.16666666666666666 * (x * x);
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = 0.16666666666666666d0 * (x * x)
end function
public static double code(double x) {
	return 0.16666666666666666 * (x * x);
}
def code(x):
	return 0.16666666666666666 * (x * x)
function code(x)
	return Float64(0.16666666666666666 * Float64(x * x))
end
function tmp = code(x)
	tmp = 0.16666666666666666 * (x * x);
end
code[x_] := N[(0.16666666666666666 * N[(x * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
0.16666666666666666 \cdot \left(x \cdot x\right)
\end{array}

Reproduce

?
herbie shell --seed 2024085 
(FPCore (x)
  :name "ENA, Section 1.4, Exercise 4a"
  :precision binary64
  :pre (and (<= -1.0 x) (<= x 1.0))

  :alt
  (* 0.16666666666666666 (* x x))

  (/ (- x (sin x)) (tan x)))