tanhf (example 3.4)

Percentage Accurate: 52.4% → 100.0%
Time: 9.5s
Alternatives: 10
Speedup: 17.9×

Specification

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

\\
\frac{1 - \cos x}{\sin x}
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 10 alternatives:

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

Initial Program: 52.4% accurate, 1.0× speedup?

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

\\
\frac{1 - \cos x}{\sin x}
\end{array}

Alternative 1: 100.0% accurate, 2.0× speedup?

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

\\
\tan \left(x \cdot 0.5\right)
\end{array}
Derivation
  1. Initial program 51.6%

    \[\frac{1 - \cos x}{\sin x} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. hang-p0-tanN/A

      \[\leadsto \color{blue}{\tan \left(\frac{x}{2}\right)} \]
    2. tan-lowering-tan.f64N/A

      \[\leadsto \color{blue}{\tan \left(\frac{x}{2}\right)} \]
    3. div-invN/A

      \[\leadsto \tan \color{blue}{\left(x \cdot \frac{1}{2}\right)} \]
    4. metadata-evalN/A

      \[\leadsto \tan \left(x \cdot \color{blue}{\frac{1}{2}}\right) \]
    5. *-lowering-*.f64100.0

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

    \[\leadsto \color{blue}{\tan \left(x \cdot 0.5\right)} \]
  5. Add Preprocessing

Alternative 2: 55.2% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{1 - \cos x}{\sin x} \leq 0.07:\\ \;\;\;\;x \cdot \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \left(x \cdot \left(x \cdot -4.266463529856387 \cdot 10^{-5}\right)\right), \frac{-1.736111111111111 \cdot 10^{-5}}{\mathsf{fma}\left(x \cdot x, 0.00042162698412698415, -0.004166666666666667\right)}\right), 0.041666666666666664\right), 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= (/ (- 1.0 (cos x)) (sin x)) 0.07)
   (*
    x
    (fma
     x
     (*
      x
      (fma
       (* x x)
       (fma
        x
        (* x (* x (* x -4.266463529856387e-5)))
        (/
         -1.736111111111111e-5
         (fma (* x x) 0.00042162698412698415 -0.004166666666666667)))
       0.041666666666666664))
     0.5))
   1.0))
double code(double x) {
	double tmp;
	if (((1.0 - cos(x)) / sin(x)) <= 0.07) {
		tmp = x * fma(x, (x * fma((x * x), fma(x, (x * (x * (x * -4.266463529856387e-5))), (-1.736111111111111e-5 / fma((x * x), 0.00042162698412698415, -0.004166666666666667))), 0.041666666666666664)), 0.5);
	} else {
		tmp = 1.0;
	}
	return tmp;
}
function code(x)
	tmp = 0.0
	if (Float64(Float64(1.0 - cos(x)) / sin(x)) <= 0.07)
		tmp = Float64(x * fma(x, Float64(x * fma(Float64(x * x), fma(x, Float64(x * Float64(x * Float64(x * -4.266463529856387e-5))), Float64(-1.736111111111111e-5 / fma(Float64(x * x), 0.00042162698412698415, -0.004166666666666667))), 0.041666666666666664)), 0.5));
	else
		tmp = 1.0;
	end
	return tmp
end
code[x_] := If[LessEqual[N[(N[(1.0 - N[Cos[x], $MachinePrecision]), $MachinePrecision] / N[Sin[x], $MachinePrecision]), $MachinePrecision], 0.07], N[(x * N[(x * N[(x * N[(N[(x * x), $MachinePrecision] * N[(x * N[(x * N[(x * N[(x * -4.266463529856387e-5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(-1.736111111111111e-5 / N[(N[(x * x), $MachinePrecision] * 0.00042162698412698415 + -0.004166666666666667), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 0.041666666666666664), $MachinePrecision]), $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision], 1.0]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\frac{1 - \cos x}{\sin x} \leq 0.07:\\
\;\;\;\;x \cdot \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \left(x \cdot \left(x \cdot -4.266463529856387 \cdot 10^{-5}\right)\right), \frac{-1.736111111111111 \cdot 10^{-5}}{\mathsf{fma}\left(x \cdot x, 0.00042162698412698415, -0.004166666666666667\right)}\right), 0.041666666666666664\right), 0.5\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (-.f64 #s(literal 1 binary64) (cos.f64 x)) (sin.f64 x)) < 0.070000000000000007

    1. Initial program 34.5%

      \[\frac{1 - \cos x}{\sin x} \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0

      \[\leadsto \color{blue}{x \cdot \left(\frac{1}{2} + {x}^{2} \cdot \left(\frac{1}{24} + {x}^{2} \cdot \left(\frac{1}{240} + \frac{17}{40320} \cdot {x}^{2}\right)\right)\right)} \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{x \cdot \left(\frac{1}{2} + {x}^{2} \cdot \left(\frac{1}{24} + {x}^{2} \cdot \left(\frac{1}{240} + \frac{17}{40320} \cdot {x}^{2}\right)\right)\right)} \]
      2. +-commutativeN/A

        \[\leadsto x \cdot \color{blue}{\left({x}^{2} \cdot \left(\frac{1}{24} + {x}^{2} \cdot \left(\frac{1}{240} + \frac{17}{40320} \cdot {x}^{2}\right)\right) + \frac{1}{2}\right)} \]
      3. accelerator-lowering-fma.f64N/A

        \[\leadsto x \cdot \color{blue}{\mathsf{fma}\left({x}^{2}, \frac{1}{24} + {x}^{2} \cdot \left(\frac{1}{240} + \frac{17}{40320} \cdot {x}^{2}\right), \frac{1}{2}\right)} \]
      4. unpow2N/A

        \[\leadsto x \cdot \mathsf{fma}\left(\color{blue}{x \cdot x}, \frac{1}{24} + {x}^{2} \cdot \left(\frac{1}{240} + \frac{17}{40320} \cdot {x}^{2}\right), \frac{1}{2}\right) \]
      5. *-lowering-*.f64N/A

        \[\leadsto x \cdot \mathsf{fma}\left(\color{blue}{x \cdot x}, \frac{1}{24} + {x}^{2} \cdot \left(\frac{1}{240} + \frac{17}{40320} \cdot {x}^{2}\right), \frac{1}{2}\right) \]
      6. +-commutativeN/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \color{blue}{{x}^{2} \cdot \left(\frac{1}{240} + \frac{17}{40320} \cdot {x}^{2}\right) + \frac{1}{24}}, \frac{1}{2}\right) \]
      7. accelerator-lowering-fma.f64N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \color{blue}{\mathsf{fma}\left({x}^{2}, \frac{1}{240} + \frac{17}{40320} \cdot {x}^{2}, \frac{1}{24}\right)}, \frac{1}{2}\right) \]
      8. unpow2N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(\color{blue}{x \cdot x}, \frac{1}{240} + \frac{17}{40320} \cdot {x}^{2}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(\color{blue}{x \cdot x}, \frac{1}{240} + \frac{17}{40320} \cdot {x}^{2}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      10. +-commutativeN/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{\frac{17}{40320} \cdot {x}^{2} + \frac{1}{240}}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      11. unpow2N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \frac{17}{40320} \cdot \color{blue}{\left(x \cdot x\right)} + \frac{1}{240}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      12. associate-*r*N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{\left(\frac{17}{40320} \cdot x\right) \cdot x} + \frac{1}{240}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      13. *-commutativeN/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{x \cdot \left(\frac{17}{40320} \cdot x\right)} + \frac{1}{240}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      14. accelerator-lowering-fma.f64N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{\mathsf{fma}\left(x, \frac{17}{40320} \cdot x, \frac{1}{240}\right)}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      15. *-commutativeN/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, \color{blue}{x \cdot \frac{17}{40320}}, \frac{1}{240}\right), \frac{1}{24}\right), \frac{1}{2}\right) \]
      16. *-lowering-*.f6470.5

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, \color{blue}{x \cdot 0.00042162698412698415}, 0.004166666666666667\right), 0.041666666666666664\right), 0.5\right) \]
    5. Simplified70.5%

      \[\leadsto \color{blue}{x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot 0.00042162698412698415, 0.004166666666666667\right), 0.041666666666666664\right), 0.5\right)} \]
    6. Step-by-step derivation
      1. flip-+N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{\frac{\left(x \cdot \left(x \cdot \frac{17}{40320}\right)\right) \cdot \left(x \cdot \left(x \cdot \frac{17}{40320}\right)\right) - \frac{1}{240} \cdot \frac{1}{240}}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}}}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      2. div-subN/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{\frac{\left(x \cdot \left(x \cdot \frac{17}{40320}\right)\right) \cdot \left(x \cdot \left(x \cdot \frac{17}{40320}\right)\right)}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}} - \frac{\frac{1}{240} \cdot \frac{1}{240}}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}}}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      3. --lowering--.f64N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{\frac{\left(x \cdot \left(x \cdot \frac{17}{40320}\right)\right) \cdot \left(x \cdot \left(x \cdot \frac{17}{40320}\right)\right)}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}} - \frac{\frac{1}{240} \cdot \frac{1}{240}}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}}}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      4. /-lowering-/.f64N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{\frac{\left(x \cdot \left(x \cdot \frac{17}{40320}\right)\right) \cdot \left(x \cdot \left(x \cdot \frac{17}{40320}\right)\right)}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}}} - \frac{\frac{1}{240} \cdot \frac{1}{240}}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      5. swap-sqrN/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \frac{\color{blue}{\left(x \cdot x\right) \cdot \left(\left(x \cdot \frac{17}{40320}\right) \cdot \left(x \cdot \frac{17}{40320}\right)\right)}}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}} - \frac{\frac{1}{240} \cdot \frac{1}{240}}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      6. *-lowering-*.f64N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \frac{\color{blue}{\left(x \cdot x\right) \cdot \left(\left(x \cdot \frac{17}{40320}\right) \cdot \left(x \cdot \frac{17}{40320}\right)\right)}}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}} - \frac{\frac{1}{240} \cdot \frac{1}{240}}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \frac{\color{blue}{\left(x \cdot x\right)} \cdot \left(\left(x \cdot \frac{17}{40320}\right) \cdot \left(x \cdot \frac{17}{40320}\right)\right)}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}} - \frac{\frac{1}{240} \cdot \frac{1}{240}}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      8. swap-sqrN/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \frac{\left(x \cdot x\right) \cdot \color{blue}{\left(\left(x \cdot x\right) \cdot \left(\frac{17}{40320} \cdot \frac{17}{40320}\right)\right)}}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}} - \frac{\frac{1}{240} \cdot \frac{1}{240}}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \frac{\left(x \cdot x\right) \cdot \color{blue}{\left(\left(x \cdot x\right) \cdot \left(\frac{17}{40320} \cdot \frac{17}{40320}\right)\right)}}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}} - \frac{\frac{1}{240} \cdot \frac{1}{240}}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      10. *-lowering-*.f64N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \frac{\left(x \cdot x\right) \cdot \left(\color{blue}{\left(x \cdot x\right)} \cdot \left(\frac{17}{40320} \cdot \frac{17}{40320}\right)\right)}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}} - \frac{\frac{1}{240} \cdot \frac{1}{240}}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      11. metadata-evalN/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \frac{\left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot \color{blue}{\frac{289}{1625702400}}\right)}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}} - \frac{\frac{1}{240} \cdot \frac{1}{240}}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      12. sub-negN/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \frac{\left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot \frac{289}{1625702400}\right)}{\color{blue}{x \cdot \left(x \cdot \frac{17}{40320}\right) + \left(\mathsf{neg}\left(\frac{1}{240}\right)\right)}} - \frac{\frac{1}{240} \cdot \frac{1}{240}}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      13. accelerator-lowering-fma.f64N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \frac{\left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot \frac{289}{1625702400}\right)}{\color{blue}{\mathsf{fma}\left(x, x \cdot \frac{17}{40320}, \mathsf{neg}\left(\frac{1}{240}\right)\right)}} - \frac{\frac{1}{240} \cdot \frac{1}{240}}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      14. *-lowering-*.f64N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \frac{\left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot \frac{289}{1625702400}\right)}{\mathsf{fma}\left(x, \color{blue}{x \cdot \frac{17}{40320}}, \mathsf{neg}\left(\frac{1}{240}\right)\right)} - \frac{\frac{1}{240} \cdot \frac{1}{240}}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      15. metadata-evalN/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \frac{\left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot \frac{289}{1625702400}\right)}{\mathsf{fma}\left(x, x \cdot \frac{17}{40320}, \color{blue}{\frac{-1}{240}}\right)} - \frac{\frac{1}{240} \cdot \frac{1}{240}}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      16. /-lowering-/.f64N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \frac{\left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot \frac{289}{1625702400}\right)}{\mathsf{fma}\left(x, x \cdot \frac{17}{40320}, \frac{-1}{240}\right)} - \color{blue}{\frac{\frac{1}{240} \cdot \frac{1}{240}}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}}}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      17. metadata-evalN/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \frac{\left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot \frac{289}{1625702400}\right)}{\mathsf{fma}\left(x, x \cdot \frac{17}{40320}, \frac{-1}{240}\right)} - \frac{\color{blue}{\frac{1}{57600}}}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      18. sub-negN/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \frac{\left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot \frac{289}{1625702400}\right)}{\mathsf{fma}\left(x, x \cdot \frac{17}{40320}, \frac{-1}{240}\right)} - \frac{\frac{1}{57600}}{\color{blue}{x \cdot \left(x \cdot \frac{17}{40320}\right) + \left(\mathsf{neg}\left(\frac{1}{240}\right)\right)}}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      19. accelerator-lowering-fma.f64N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \frac{\left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot \frac{289}{1625702400}\right)}{\mathsf{fma}\left(x, x \cdot \frac{17}{40320}, \frac{-1}{240}\right)} - \frac{\frac{1}{57600}}{\color{blue}{\mathsf{fma}\left(x, x \cdot \frac{17}{40320}, \mathsf{neg}\left(\frac{1}{240}\right)\right)}}, \frac{1}{24}\right), \frac{1}{2}\right) \]
    7. Applied egg-rr70.2%

      \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{\frac{\left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot 1.7776931374401612 \cdot 10^{-7}\right)}{\mathsf{fma}\left(x, x \cdot 0.00042162698412698415, -0.004166666666666667\right)} - \frac{1.736111111111111 \cdot 10^{-5}}{\mathsf{fma}\left(x, x \cdot 0.00042162698412698415, -0.004166666666666667\right)}}, 0.041666666666666664\right), 0.5\right) \]
    8. Taylor expanded in x around 0

      \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{\frac{-289}{6773760} \cdot {x}^{4}} - \frac{\frac{1}{57600}}{\mathsf{fma}\left(x, x \cdot \frac{17}{40320}, \frac{-1}{240}\right)}, \frac{1}{24}\right), \frac{1}{2}\right) \]
    9. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{{x}^{4} \cdot \frac{-289}{6773760}} - \frac{\frac{1}{57600}}{\mathsf{fma}\left(x, x \cdot \frac{17}{40320}, \frac{-1}{240}\right)}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{{x}^{4} \cdot \frac{-289}{6773760}} - \frac{\frac{1}{57600}}{\mathsf{fma}\left(x, x \cdot \frac{17}{40320}, \frac{-1}{240}\right)}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      3. metadata-evalN/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, {x}^{\color{blue}{\left(3 + 1\right)}} \cdot \frac{-289}{6773760} - \frac{\frac{1}{57600}}{\mathsf{fma}\left(x, x \cdot \frac{17}{40320}, \frac{-1}{240}\right)}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      4. pow-plusN/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{\left({x}^{3} \cdot x\right)} \cdot \frac{-289}{6773760} - \frac{\frac{1}{57600}}{\mathsf{fma}\left(x, x \cdot \frac{17}{40320}, \frac{-1}{240}\right)}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      5. *-commutativeN/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{\left(x \cdot {x}^{3}\right)} \cdot \frac{-289}{6773760} - \frac{\frac{1}{57600}}{\mathsf{fma}\left(x, x \cdot \frac{17}{40320}, \frac{-1}{240}\right)}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      6. *-lowering-*.f64N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{\left(x \cdot {x}^{3}\right)} \cdot \frac{-289}{6773760} - \frac{\frac{1}{57600}}{\mathsf{fma}\left(x, x \cdot \frac{17}{40320}, \frac{-1}{240}\right)}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      7. cube-multN/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \left(x \cdot \color{blue}{\left(x \cdot \left(x \cdot x\right)\right)}\right) \cdot \frac{-289}{6773760} - \frac{\frac{1}{57600}}{\mathsf{fma}\left(x, x \cdot \frac{17}{40320}, \frac{-1}{240}\right)}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      8. unpow2N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \left(x \cdot \left(x \cdot \color{blue}{{x}^{2}}\right)\right) \cdot \frac{-289}{6773760} - \frac{\frac{1}{57600}}{\mathsf{fma}\left(x, x \cdot \frac{17}{40320}, \frac{-1}{240}\right)}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \left(x \cdot \color{blue}{\left(x \cdot {x}^{2}\right)}\right) \cdot \frac{-289}{6773760} - \frac{\frac{1}{57600}}{\mathsf{fma}\left(x, x \cdot \frac{17}{40320}, \frac{-1}{240}\right)}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      10. unpow2N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \left(x \cdot \left(x \cdot \color{blue}{\left(x \cdot x\right)}\right)\right) \cdot \frac{-289}{6773760} - \frac{\frac{1}{57600}}{\mathsf{fma}\left(x, x \cdot \frac{17}{40320}, \frac{-1}{240}\right)}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      11. *-lowering-*.f6470.6

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \left(x \cdot \left(x \cdot \color{blue}{\left(x \cdot x\right)}\right)\right) \cdot -4.266463529856387 \cdot 10^{-5} - \frac{1.736111111111111 \cdot 10^{-5}}{\mathsf{fma}\left(x, x \cdot 0.00042162698412698415, -0.004166666666666667\right)}, 0.041666666666666664\right), 0.5\right) \]
    10. Simplified70.6%

      \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{\left(x \cdot \left(x \cdot \left(x \cdot x\right)\right)\right) \cdot -4.266463529856387 \cdot 10^{-5}} - \frac{1.736111111111111 \cdot 10^{-5}}{\mathsf{fma}\left(x, x \cdot 0.00042162698412698415, -0.004166666666666667\right)}, 0.041666666666666664\right), 0.5\right) \]
    11. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \color{blue}{\left(\left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot \left(\left(x \cdot \left(x \cdot \left(x \cdot x\right)\right)\right) \cdot \frac{-289}{6773760} - \frac{\frac{1}{57600}}{x \cdot \left(x \cdot \frac{17}{40320}\right) + \frac{-1}{240}}\right) + \frac{1}{24}\right) + \frac{1}{2}\right) \cdot x} \]
      2. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{\left(\left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot \left(\left(x \cdot \left(x \cdot \left(x \cdot x\right)\right)\right) \cdot \frac{-289}{6773760} - \frac{\frac{1}{57600}}{x \cdot \left(x \cdot \frac{17}{40320}\right) + \frac{-1}{240}}\right) + \frac{1}{24}\right) + \frac{1}{2}\right) \cdot x} \]
    12. Applied egg-rr70.6%

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \left(x \cdot \left(x \cdot -4.266463529856387 \cdot 10^{-5}\right)\right), \frac{-1.736111111111111 \cdot 10^{-5}}{\mathsf{fma}\left(x \cdot x, 0.00042162698412698415, -0.004166666666666667\right)}\right), 0.041666666666666664\right), 0.5\right) \cdot x} \]

    if 0.070000000000000007 < (/.f64 (-.f64 #s(literal 1 binary64) (cos.f64 x)) (sin.f64 x))

    1. Initial program 98.8%

      \[\frac{1 - \cos x}{\sin x} \]
    2. Add Preprocessing
    3. Applied egg-rr19.1%

      \[\leadsto \color{blue}{{1}^{-0.5}} \]
    4. Step-by-step derivation
      1. pow-base-119.1

        \[\leadsto \color{blue}{1} \]
    5. Applied egg-rr19.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1 - \cos x}{\sin x} \leq 0.07:\\ \;\;\;\;x \cdot \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \left(x \cdot \left(x \cdot -4.266463529856387 \cdot 10^{-5}\right)\right), \frac{-1.736111111111111 \cdot 10^{-5}}{\mathsf{fma}\left(x \cdot x, 0.00042162698412698415, -0.004166666666666667\right)}\right), 0.041666666666666664\right), 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 53.0% accurate, 3.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 58000000:\\ \;\;\;\;x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, -4.266463529856387 \cdot 10^{-5} \cdot \left(x \cdot \left(x \cdot \left(x \cdot x\right)\right)\right) - \mathsf{fma}\left(x \cdot x, -0.00042162698412698415, -0.004166666666666667\right), 0.041666666666666664\right), 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= x 58000000.0)
   (*
    x
    (fma
     (* x x)
     (fma
      (* x x)
      (-
       (* -4.266463529856387e-5 (* x (* x (* x x))))
       (fma (* x x) -0.00042162698412698415 -0.004166666666666667))
      0.041666666666666664)
     0.5))
   1.0))
double code(double x) {
	double tmp;
	if (x <= 58000000.0) {
		tmp = x * fma((x * x), fma((x * x), ((-4.266463529856387e-5 * (x * (x * (x * x)))) - fma((x * x), -0.00042162698412698415, -0.004166666666666667)), 0.041666666666666664), 0.5);
	} else {
		tmp = 1.0;
	}
	return tmp;
}
function code(x)
	tmp = 0.0
	if (x <= 58000000.0)
		tmp = Float64(x * fma(Float64(x * x), fma(Float64(x * x), Float64(Float64(-4.266463529856387e-5 * Float64(x * Float64(x * Float64(x * x)))) - fma(Float64(x * x), -0.00042162698412698415, -0.004166666666666667)), 0.041666666666666664), 0.5));
	else
		tmp = 1.0;
	end
	return tmp
end
code[x_] := If[LessEqual[x, 58000000.0], N[(x * N[(N[(x * x), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * N[(N[(-4.266463529856387e-5 * N[(x * N[(x * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(x * x), $MachinePrecision] * -0.00042162698412698415 + -0.004166666666666667), $MachinePrecision]), $MachinePrecision] + 0.041666666666666664), $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision], 1.0]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 58000000:\\
\;\;\;\;x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, -4.266463529856387 \cdot 10^{-5} \cdot \left(x \cdot \left(x \cdot \left(x \cdot x\right)\right)\right) - \mathsf{fma}\left(x \cdot x, -0.00042162698412698415, -0.004166666666666667\right), 0.041666666666666664\right), 0.5\right)\\

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


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

    1. Initial program 37.3%

      \[\frac{1 - \cos x}{\sin x} \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0

      \[\leadsto \color{blue}{x \cdot \left(\frac{1}{2} + {x}^{2} \cdot \left(\frac{1}{24} + {x}^{2} \cdot \left(\frac{1}{240} + \frac{17}{40320} \cdot {x}^{2}\right)\right)\right)} \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{x \cdot \left(\frac{1}{2} + {x}^{2} \cdot \left(\frac{1}{24} + {x}^{2} \cdot \left(\frac{1}{240} + \frac{17}{40320} \cdot {x}^{2}\right)\right)\right)} \]
      2. +-commutativeN/A

        \[\leadsto x \cdot \color{blue}{\left({x}^{2} \cdot \left(\frac{1}{24} + {x}^{2} \cdot \left(\frac{1}{240} + \frac{17}{40320} \cdot {x}^{2}\right)\right) + \frac{1}{2}\right)} \]
      3. accelerator-lowering-fma.f64N/A

        \[\leadsto x \cdot \color{blue}{\mathsf{fma}\left({x}^{2}, \frac{1}{24} + {x}^{2} \cdot \left(\frac{1}{240} + \frac{17}{40320} \cdot {x}^{2}\right), \frac{1}{2}\right)} \]
      4. unpow2N/A

        \[\leadsto x \cdot \mathsf{fma}\left(\color{blue}{x \cdot x}, \frac{1}{24} + {x}^{2} \cdot \left(\frac{1}{240} + \frac{17}{40320} \cdot {x}^{2}\right), \frac{1}{2}\right) \]
      5. *-lowering-*.f64N/A

        \[\leadsto x \cdot \mathsf{fma}\left(\color{blue}{x \cdot x}, \frac{1}{24} + {x}^{2} \cdot \left(\frac{1}{240} + \frac{17}{40320} \cdot {x}^{2}\right), \frac{1}{2}\right) \]
      6. +-commutativeN/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \color{blue}{{x}^{2} \cdot \left(\frac{1}{240} + \frac{17}{40320} \cdot {x}^{2}\right) + \frac{1}{24}}, \frac{1}{2}\right) \]
      7. accelerator-lowering-fma.f64N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \color{blue}{\mathsf{fma}\left({x}^{2}, \frac{1}{240} + \frac{17}{40320} \cdot {x}^{2}, \frac{1}{24}\right)}, \frac{1}{2}\right) \]
      8. unpow2N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(\color{blue}{x \cdot x}, \frac{1}{240} + \frac{17}{40320} \cdot {x}^{2}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(\color{blue}{x \cdot x}, \frac{1}{240} + \frac{17}{40320} \cdot {x}^{2}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      10. +-commutativeN/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{\frac{17}{40320} \cdot {x}^{2} + \frac{1}{240}}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      11. unpow2N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \frac{17}{40320} \cdot \color{blue}{\left(x \cdot x\right)} + \frac{1}{240}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      12. associate-*r*N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{\left(\frac{17}{40320} \cdot x\right) \cdot x} + \frac{1}{240}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      13. *-commutativeN/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{x \cdot \left(\frac{17}{40320} \cdot x\right)} + \frac{1}{240}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      14. accelerator-lowering-fma.f64N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{\mathsf{fma}\left(x, \frac{17}{40320} \cdot x, \frac{1}{240}\right)}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      15. *-commutativeN/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, \color{blue}{x \cdot \frac{17}{40320}}, \frac{1}{240}\right), \frac{1}{24}\right), \frac{1}{2}\right) \]
      16. *-lowering-*.f6467.7

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, \color{blue}{x \cdot 0.00042162698412698415}, 0.004166666666666667\right), 0.041666666666666664\right), 0.5\right) \]
    5. Simplified67.7%

      \[\leadsto \color{blue}{x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot 0.00042162698412698415, 0.004166666666666667\right), 0.041666666666666664\right), 0.5\right)} \]
    6. Step-by-step derivation
      1. flip-+N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{\frac{\left(x \cdot \left(x \cdot \frac{17}{40320}\right)\right) \cdot \left(x \cdot \left(x \cdot \frac{17}{40320}\right)\right) - \frac{1}{240} \cdot \frac{1}{240}}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}}}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      2. div-subN/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{\frac{\left(x \cdot \left(x \cdot \frac{17}{40320}\right)\right) \cdot \left(x \cdot \left(x \cdot \frac{17}{40320}\right)\right)}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}} - \frac{\frac{1}{240} \cdot \frac{1}{240}}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}}}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      3. --lowering--.f64N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{\frac{\left(x \cdot \left(x \cdot \frac{17}{40320}\right)\right) \cdot \left(x \cdot \left(x \cdot \frac{17}{40320}\right)\right)}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}} - \frac{\frac{1}{240} \cdot \frac{1}{240}}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}}}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      4. /-lowering-/.f64N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{\frac{\left(x \cdot \left(x \cdot \frac{17}{40320}\right)\right) \cdot \left(x \cdot \left(x \cdot \frac{17}{40320}\right)\right)}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}}} - \frac{\frac{1}{240} \cdot \frac{1}{240}}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      5. swap-sqrN/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \frac{\color{blue}{\left(x \cdot x\right) \cdot \left(\left(x \cdot \frac{17}{40320}\right) \cdot \left(x \cdot \frac{17}{40320}\right)\right)}}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}} - \frac{\frac{1}{240} \cdot \frac{1}{240}}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      6. *-lowering-*.f64N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \frac{\color{blue}{\left(x \cdot x\right) \cdot \left(\left(x \cdot \frac{17}{40320}\right) \cdot \left(x \cdot \frac{17}{40320}\right)\right)}}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}} - \frac{\frac{1}{240} \cdot \frac{1}{240}}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \frac{\color{blue}{\left(x \cdot x\right)} \cdot \left(\left(x \cdot \frac{17}{40320}\right) \cdot \left(x \cdot \frac{17}{40320}\right)\right)}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}} - \frac{\frac{1}{240} \cdot \frac{1}{240}}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      8. swap-sqrN/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \frac{\left(x \cdot x\right) \cdot \color{blue}{\left(\left(x \cdot x\right) \cdot \left(\frac{17}{40320} \cdot \frac{17}{40320}\right)\right)}}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}} - \frac{\frac{1}{240} \cdot \frac{1}{240}}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \frac{\left(x \cdot x\right) \cdot \color{blue}{\left(\left(x \cdot x\right) \cdot \left(\frac{17}{40320} \cdot \frac{17}{40320}\right)\right)}}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}} - \frac{\frac{1}{240} \cdot \frac{1}{240}}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      10. *-lowering-*.f64N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \frac{\left(x \cdot x\right) \cdot \left(\color{blue}{\left(x \cdot x\right)} \cdot \left(\frac{17}{40320} \cdot \frac{17}{40320}\right)\right)}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}} - \frac{\frac{1}{240} \cdot \frac{1}{240}}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      11. metadata-evalN/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \frac{\left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot \color{blue}{\frac{289}{1625702400}}\right)}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}} - \frac{\frac{1}{240} \cdot \frac{1}{240}}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      12. sub-negN/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \frac{\left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot \frac{289}{1625702400}\right)}{\color{blue}{x \cdot \left(x \cdot \frac{17}{40320}\right) + \left(\mathsf{neg}\left(\frac{1}{240}\right)\right)}} - \frac{\frac{1}{240} \cdot \frac{1}{240}}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      13. accelerator-lowering-fma.f64N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \frac{\left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot \frac{289}{1625702400}\right)}{\color{blue}{\mathsf{fma}\left(x, x \cdot \frac{17}{40320}, \mathsf{neg}\left(\frac{1}{240}\right)\right)}} - \frac{\frac{1}{240} \cdot \frac{1}{240}}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      14. *-lowering-*.f64N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \frac{\left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot \frac{289}{1625702400}\right)}{\mathsf{fma}\left(x, \color{blue}{x \cdot \frac{17}{40320}}, \mathsf{neg}\left(\frac{1}{240}\right)\right)} - \frac{\frac{1}{240} \cdot \frac{1}{240}}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      15. metadata-evalN/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \frac{\left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot \frac{289}{1625702400}\right)}{\mathsf{fma}\left(x, x \cdot \frac{17}{40320}, \color{blue}{\frac{-1}{240}}\right)} - \frac{\frac{1}{240} \cdot \frac{1}{240}}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      16. /-lowering-/.f64N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \frac{\left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot \frac{289}{1625702400}\right)}{\mathsf{fma}\left(x, x \cdot \frac{17}{40320}, \frac{-1}{240}\right)} - \color{blue}{\frac{\frac{1}{240} \cdot \frac{1}{240}}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}}}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      17. metadata-evalN/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \frac{\left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot \frac{289}{1625702400}\right)}{\mathsf{fma}\left(x, x \cdot \frac{17}{40320}, \frac{-1}{240}\right)} - \frac{\color{blue}{\frac{1}{57600}}}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      18. sub-negN/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \frac{\left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot \frac{289}{1625702400}\right)}{\mathsf{fma}\left(x, x \cdot \frac{17}{40320}, \frac{-1}{240}\right)} - \frac{\frac{1}{57600}}{\color{blue}{x \cdot \left(x \cdot \frac{17}{40320}\right) + \left(\mathsf{neg}\left(\frac{1}{240}\right)\right)}}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      19. accelerator-lowering-fma.f64N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \frac{\left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot \frac{289}{1625702400}\right)}{\mathsf{fma}\left(x, x \cdot \frac{17}{40320}, \frac{-1}{240}\right)} - \frac{\frac{1}{57600}}{\color{blue}{\mathsf{fma}\left(x, x \cdot \frac{17}{40320}, \mathsf{neg}\left(\frac{1}{240}\right)\right)}}, \frac{1}{24}\right), \frac{1}{2}\right) \]
    7. Applied egg-rr67.4%

      \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{\frac{\left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot 1.7776931374401612 \cdot 10^{-7}\right)}{\mathsf{fma}\left(x, x \cdot 0.00042162698412698415, -0.004166666666666667\right)} - \frac{1.736111111111111 \cdot 10^{-5}}{\mathsf{fma}\left(x, x \cdot 0.00042162698412698415, -0.004166666666666667\right)}}, 0.041666666666666664\right), 0.5\right) \]
    8. Taylor expanded in x around 0

      \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{\frac{-289}{6773760} \cdot {x}^{4}} - \frac{\frac{1}{57600}}{\mathsf{fma}\left(x, x \cdot \frac{17}{40320}, \frac{-1}{240}\right)}, \frac{1}{24}\right), \frac{1}{2}\right) \]
    9. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{{x}^{4} \cdot \frac{-289}{6773760}} - \frac{\frac{1}{57600}}{\mathsf{fma}\left(x, x \cdot \frac{17}{40320}, \frac{-1}{240}\right)}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{{x}^{4} \cdot \frac{-289}{6773760}} - \frac{\frac{1}{57600}}{\mathsf{fma}\left(x, x \cdot \frac{17}{40320}, \frac{-1}{240}\right)}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      3. metadata-evalN/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, {x}^{\color{blue}{\left(3 + 1\right)}} \cdot \frac{-289}{6773760} - \frac{\frac{1}{57600}}{\mathsf{fma}\left(x, x \cdot \frac{17}{40320}, \frac{-1}{240}\right)}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      4. pow-plusN/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{\left({x}^{3} \cdot x\right)} \cdot \frac{-289}{6773760} - \frac{\frac{1}{57600}}{\mathsf{fma}\left(x, x \cdot \frac{17}{40320}, \frac{-1}{240}\right)}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      5. *-commutativeN/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{\left(x \cdot {x}^{3}\right)} \cdot \frac{-289}{6773760} - \frac{\frac{1}{57600}}{\mathsf{fma}\left(x, x \cdot \frac{17}{40320}, \frac{-1}{240}\right)}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      6. *-lowering-*.f64N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{\left(x \cdot {x}^{3}\right)} \cdot \frac{-289}{6773760} - \frac{\frac{1}{57600}}{\mathsf{fma}\left(x, x \cdot \frac{17}{40320}, \frac{-1}{240}\right)}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      7. cube-multN/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \left(x \cdot \color{blue}{\left(x \cdot \left(x \cdot x\right)\right)}\right) \cdot \frac{-289}{6773760} - \frac{\frac{1}{57600}}{\mathsf{fma}\left(x, x \cdot \frac{17}{40320}, \frac{-1}{240}\right)}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      8. unpow2N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \left(x \cdot \left(x \cdot \color{blue}{{x}^{2}}\right)\right) \cdot \frac{-289}{6773760} - \frac{\frac{1}{57600}}{\mathsf{fma}\left(x, x \cdot \frac{17}{40320}, \frac{-1}{240}\right)}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \left(x \cdot \color{blue}{\left(x \cdot {x}^{2}\right)}\right) \cdot \frac{-289}{6773760} - \frac{\frac{1}{57600}}{\mathsf{fma}\left(x, x \cdot \frac{17}{40320}, \frac{-1}{240}\right)}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      10. unpow2N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \left(x \cdot \left(x \cdot \color{blue}{\left(x \cdot x\right)}\right)\right) \cdot \frac{-289}{6773760} - \frac{\frac{1}{57600}}{\mathsf{fma}\left(x, x \cdot \frac{17}{40320}, \frac{-1}{240}\right)}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      11. *-lowering-*.f6467.9

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \left(x \cdot \left(x \cdot \color{blue}{\left(x \cdot x\right)}\right)\right) \cdot -4.266463529856387 \cdot 10^{-5} - \frac{1.736111111111111 \cdot 10^{-5}}{\mathsf{fma}\left(x, x \cdot 0.00042162698412698415, -0.004166666666666667\right)}, 0.041666666666666664\right), 0.5\right) \]
    10. Simplified67.9%

      \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{\left(x \cdot \left(x \cdot \left(x \cdot x\right)\right)\right) \cdot -4.266463529856387 \cdot 10^{-5}} - \frac{1.736111111111111 \cdot 10^{-5}}{\mathsf{fma}\left(x, x \cdot 0.00042162698412698415, -0.004166666666666667\right)}, 0.041666666666666664\right), 0.5\right) \]
    11. Taylor expanded in x around 0

      \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \left(x \cdot \left(x \cdot \left(x \cdot x\right)\right)\right) \cdot \frac{-289}{6773760} - \color{blue}{\left(\frac{-17}{40320} \cdot {x}^{2} - \frac{1}{240}\right)}, \frac{1}{24}\right), \frac{1}{2}\right) \]
    12. Step-by-step derivation
      1. sub-negN/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \left(x \cdot \left(x \cdot \left(x \cdot x\right)\right)\right) \cdot \frac{-289}{6773760} - \color{blue}{\left(\frac{-17}{40320} \cdot {x}^{2} + \left(\mathsf{neg}\left(\frac{1}{240}\right)\right)\right)}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      2. *-commutativeN/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \left(x \cdot \left(x \cdot \left(x \cdot x\right)\right)\right) \cdot \frac{-289}{6773760} - \left(\color{blue}{{x}^{2} \cdot \frac{-17}{40320}} + \left(\mathsf{neg}\left(\frac{1}{240}\right)\right)\right), \frac{1}{24}\right), \frac{1}{2}\right) \]
      3. accelerator-lowering-fma.f64N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \left(x \cdot \left(x \cdot \left(x \cdot x\right)\right)\right) \cdot \frac{-289}{6773760} - \color{blue}{\mathsf{fma}\left({x}^{2}, \frac{-17}{40320}, \mathsf{neg}\left(\frac{1}{240}\right)\right)}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      4. unpow2N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \left(x \cdot \left(x \cdot \left(x \cdot x\right)\right)\right) \cdot \frac{-289}{6773760} - \mathsf{fma}\left(\color{blue}{x \cdot x}, \frac{-17}{40320}, \mathsf{neg}\left(\frac{1}{240}\right)\right), \frac{1}{24}\right), \frac{1}{2}\right) \]
      5. *-lowering-*.f64N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \left(x \cdot \left(x \cdot \left(x \cdot x\right)\right)\right) \cdot \frac{-289}{6773760} - \mathsf{fma}\left(\color{blue}{x \cdot x}, \frac{-17}{40320}, \mathsf{neg}\left(\frac{1}{240}\right)\right), \frac{1}{24}\right), \frac{1}{2}\right) \]
      6. metadata-eval67.4

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \left(x \cdot \left(x \cdot \left(x \cdot x\right)\right)\right) \cdot -4.266463529856387 \cdot 10^{-5} - \mathsf{fma}\left(x \cdot x, -0.00042162698412698415, \color{blue}{-0.004166666666666667}\right), 0.041666666666666664\right), 0.5\right) \]
    13. Simplified67.4%

      \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \left(x \cdot \left(x \cdot \left(x \cdot x\right)\right)\right) \cdot -4.266463529856387 \cdot 10^{-5} - \color{blue}{\mathsf{fma}\left(x \cdot x, -0.00042162698412698415, -0.004166666666666667\right)}, 0.041666666666666664\right), 0.5\right) \]

    if 5.8e7 < x

    1. Initial program 98.2%

      \[\frac{1 - \cos x}{\sin x} \]
    2. Add Preprocessing
    3. Applied egg-rr10.0%

      \[\leadsto \color{blue}{{1}^{-0.5}} \]
    4. Step-by-step derivation
      1. pow-base-110.0

        \[\leadsto \color{blue}{1} \]
    5. Applied egg-rr10.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 58000000:\\ \;\;\;\;x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, -4.266463529856387 \cdot 10^{-5} \cdot \left(x \cdot \left(x \cdot \left(x \cdot x\right)\right)\right) - \mathsf{fma}\left(x \cdot x, -0.00042162698412698415, -0.004166666666666667\right), 0.041666666666666664\right), 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 53.3% accurate, 3.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 3.2:\\ \;\;\;\;x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, \left(x \cdot \left(x \cdot x\right)\right) \cdot 4.317254762354677 \cdot 10^{-6}, 0.00042162698412698415\right), 0.004166666666666667\right), 0.041666666666666664\right), 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= x 3.2)
   (*
    x
    (fma
     (* x x)
     (fma
      (* x x)
      (fma
       (* x x)
       (fma x (* (* x (* x x)) 4.317254762354677e-6) 0.00042162698412698415)
       0.004166666666666667)
      0.041666666666666664)
     0.5))
   1.0))
double code(double x) {
	double tmp;
	if (x <= 3.2) {
		tmp = x * fma((x * x), fma((x * x), fma((x * x), fma(x, ((x * (x * x)) * 4.317254762354677e-6), 0.00042162698412698415), 0.004166666666666667), 0.041666666666666664), 0.5);
	} else {
		tmp = 1.0;
	}
	return tmp;
}
function code(x)
	tmp = 0.0
	if (x <= 3.2)
		tmp = Float64(x * fma(Float64(x * x), fma(Float64(x * x), fma(Float64(x * x), fma(x, Float64(Float64(x * Float64(x * x)) * 4.317254762354677e-6), 0.00042162698412698415), 0.004166666666666667), 0.041666666666666664), 0.5));
	else
		tmp = 1.0;
	end
	return tmp
end
code[x_] := If[LessEqual[x, 3.2], N[(x * N[(N[(x * x), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * N[(x * N[(N[(x * N[(x * x), $MachinePrecision]), $MachinePrecision] * 4.317254762354677e-6), $MachinePrecision] + 0.00042162698412698415), $MachinePrecision] + 0.004166666666666667), $MachinePrecision] + 0.041666666666666664), $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision], 1.0]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.2:\\
\;\;\;\;x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, \left(x \cdot \left(x \cdot x\right)\right) \cdot 4.317254762354677 \cdot 10^{-6}, 0.00042162698412698415\right), 0.004166666666666667\right), 0.041666666666666664\right), 0.5\right)\\

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


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

    1. Initial program 37.0%

      \[\frac{1 - \cos x}{\sin x} \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0

      \[\leadsto \color{blue}{x \cdot \left(\frac{1}{2} + {x}^{2} \cdot \left(\frac{1}{24} + {x}^{2} \cdot \left(\frac{1}{240} + \frac{17}{40320} \cdot {x}^{2}\right)\right)\right)} \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{x \cdot \left(\frac{1}{2} + {x}^{2} \cdot \left(\frac{1}{24} + {x}^{2} \cdot \left(\frac{1}{240} + \frac{17}{40320} \cdot {x}^{2}\right)\right)\right)} \]
      2. +-commutativeN/A

        \[\leadsto x \cdot \color{blue}{\left({x}^{2} \cdot \left(\frac{1}{24} + {x}^{2} \cdot \left(\frac{1}{240} + \frac{17}{40320} \cdot {x}^{2}\right)\right) + \frac{1}{2}\right)} \]
      3. accelerator-lowering-fma.f64N/A

        \[\leadsto x \cdot \color{blue}{\mathsf{fma}\left({x}^{2}, \frac{1}{24} + {x}^{2} \cdot \left(\frac{1}{240} + \frac{17}{40320} \cdot {x}^{2}\right), \frac{1}{2}\right)} \]
      4. unpow2N/A

        \[\leadsto x \cdot \mathsf{fma}\left(\color{blue}{x \cdot x}, \frac{1}{24} + {x}^{2} \cdot \left(\frac{1}{240} + \frac{17}{40320} \cdot {x}^{2}\right), \frac{1}{2}\right) \]
      5. *-lowering-*.f64N/A

        \[\leadsto x \cdot \mathsf{fma}\left(\color{blue}{x \cdot x}, \frac{1}{24} + {x}^{2} \cdot \left(\frac{1}{240} + \frac{17}{40320} \cdot {x}^{2}\right), \frac{1}{2}\right) \]
      6. +-commutativeN/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \color{blue}{{x}^{2} \cdot \left(\frac{1}{240} + \frac{17}{40320} \cdot {x}^{2}\right) + \frac{1}{24}}, \frac{1}{2}\right) \]
      7. accelerator-lowering-fma.f64N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \color{blue}{\mathsf{fma}\left({x}^{2}, \frac{1}{240} + \frac{17}{40320} \cdot {x}^{2}, \frac{1}{24}\right)}, \frac{1}{2}\right) \]
      8. unpow2N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(\color{blue}{x \cdot x}, \frac{1}{240} + \frac{17}{40320} \cdot {x}^{2}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(\color{blue}{x \cdot x}, \frac{1}{240} + \frac{17}{40320} \cdot {x}^{2}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      10. +-commutativeN/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{\frac{17}{40320} \cdot {x}^{2} + \frac{1}{240}}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      11. unpow2N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \frac{17}{40320} \cdot \color{blue}{\left(x \cdot x\right)} + \frac{1}{240}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      12. associate-*r*N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{\left(\frac{17}{40320} \cdot x\right) \cdot x} + \frac{1}{240}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      13. *-commutativeN/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{x \cdot \left(\frac{17}{40320} \cdot x\right)} + \frac{1}{240}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      14. accelerator-lowering-fma.f64N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{\mathsf{fma}\left(x, \frac{17}{40320} \cdot x, \frac{1}{240}\right)}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      15. *-commutativeN/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, \color{blue}{x \cdot \frac{17}{40320}}, \frac{1}{240}\right), \frac{1}{24}\right), \frac{1}{2}\right) \]
      16. *-lowering-*.f6468.0

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, \color{blue}{x \cdot 0.00042162698412698415}, 0.004166666666666667\right), 0.041666666666666664\right), 0.5\right) \]
    5. Simplified68.0%

      \[\leadsto \color{blue}{x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot 0.00042162698412698415, 0.004166666666666667\right), 0.041666666666666664\right), 0.5\right)} \]
    6. Step-by-step derivation
      1. flip-+N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{\frac{\left(x \cdot \left(x \cdot \frac{17}{40320}\right)\right) \cdot \left(x \cdot \left(x \cdot \frac{17}{40320}\right)\right) - \frac{1}{240} \cdot \frac{1}{240}}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}}}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      2. div-subN/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{\frac{\left(x \cdot \left(x \cdot \frac{17}{40320}\right)\right) \cdot \left(x \cdot \left(x \cdot \frac{17}{40320}\right)\right)}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}} - \frac{\frac{1}{240} \cdot \frac{1}{240}}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}}}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      3. --lowering--.f64N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{\frac{\left(x \cdot \left(x \cdot \frac{17}{40320}\right)\right) \cdot \left(x \cdot \left(x \cdot \frac{17}{40320}\right)\right)}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}} - \frac{\frac{1}{240} \cdot \frac{1}{240}}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}}}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      4. /-lowering-/.f64N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{\frac{\left(x \cdot \left(x \cdot \frac{17}{40320}\right)\right) \cdot \left(x \cdot \left(x \cdot \frac{17}{40320}\right)\right)}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}}} - \frac{\frac{1}{240} \cdot \frac{1}{240}}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      5. swap-sqrN/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \frac{\color{blue}{\left(x \cdot x\right) \cdot \left(\left(x \cdot \frac{17}{40320}\right) \cdot \left(x \cdot \frac{17}{40320}\right)\right)}}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}} - \frac{\frac{1}{240} \cdot \frac{1}{240}}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      6. *-lowering-*.f64N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \frac{\color{blue}{\left(x \cdot x\right) \cdot \left(\left(x \cdot \frac{17}{40320}\right) \cdot \left(x \cdot \frac{17}{40320}\right)\right)}}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}} - \frac{\frac{1}{240} \cdot \frac{1}{240}}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \frac{\color{blue}{\left(x \cdot x\right)} \cdot \left(\left(x \cdot \frac{17}{40320}\right) \cdot \left(x \cdot \frac{17}{40320}\right)\right)}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}} - \frac{\frac{1}{240} \cdot \frac{1}{240}}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      8. swap-sqrN/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \frac{\left(x \cdot x\right) \cdot \color{blue}{\left(\left(x \cdot x\right) \cdot \left(\frac{17}{40320} \cdot \frac{17}{40320}\right)\right)}}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}} - \frac{\frac{1}{240} \cdot \frac{1}{240}}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \frac{\left(x \cdot x\right) \cdot \color{blue}{\left(\left(x \cdot x\right) \cdot \left(\frac{17}{40320} \cdot \frac{17}{40320}\right)\right)}}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}} - \frac{\frac{1}{240} \cdot \frac{1}{240}}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      10. *-lowering-*.f64N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \frac{\left(x \cdot x\right) \cdot \left(\color{blue}{\left(x \cdot x\right)} \cdot \left(\frac{17}{40320} \cdot \frac{17}{40320}\right)\right)}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}} - \frac{\frac{1}{240} \cdot \frac{1}{240}}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      11. metadata-evalN/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \frac{\left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot \color{blue}{\frac{289}{1625702400}}\right)}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}} - \frac{\frac{1}{240} \cdot \frac{1}{240}}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      12. sub-negN/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \frac{\left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot \frac{289}{1625702400}\right)}{\color{blue}{x \cdot \left(x \cdot \frac{17}{40320}\right) + \left(\mathsf{neg}\left(\frac{1}{240}\right)\right)}} - \frac{\frac{1}{240} \cdot \frac{1}{240}}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      13. accelerator-lowering-fma.f64N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \frac{\left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot \frac{289}{1625702400}\right)}{\color{blue}{\mathsf{fma}\left(x, x \cdot \frac{17}{40320}, \mathsf{neg}\left(\frac{1}{240}\right)\right)}} - \frac{\frac{1}{240} \cdot \frac{1}{240}}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      14. *-lowering-*.f64N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \frac{\left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot \frac{289}{1625702400}\right)}{\mathsf{fma}\left(x, \color{blue}{x \cdot \frac{17}{40320}}, \mathsf{neg}\left(\frac{1}{240}\right)\right)} - \frac{\frac{1}{240} \cdot \frac{1}{240}}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      15. metadata-evalN/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \frac{\left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot \frac{289}{1625702400}\right)}{\mathsf{fma}\left(x, x \cdot \frac{17}{40320}, \color{blue}{\frac{-1}{240}}\right)} - \frac{\frac{1}{240} \cdot \frac{1}{240}}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      16. /-lowering-/.f64N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \frac{\left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot \frac{289}{1625702400}\right)}{\mathsf{fma}\left(x, x \cdot \frac{17}{40320}, \frac{-1}{240}\right)} - \color{blue}{\frac{\frac{1}{240} \cdot \frac{1}{240}}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}}}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      17. metadata-evalN/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \frac{\left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot \frac{289}{1625702400}\right)}{\mathsf{fma}\left(x, x \cdot \frac{17}{40320}, \frac{-1}{240}\right)} - \frac{\color{blue}{\frac{1}{57600}}}{x \cdot \left(x \cdot \frac{17}{40320}\right) - \frac{1}{240}}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      18. sub-negN/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \frac{\left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot \frac{289}{1625702400}\right)}{\mathsf{fma}\left(x, x \cdot \frac{17}{40320}, \frac{-1}{240}\right)} - \frac{\frac{1}{57600}}{\color{blue}{x \cdot \left(x \cdot \frac{17}{40320}\right) + \left(\mathsf{neg}\left(\frac{1}{240}\right)\right)}}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      19. accelerator-lowering-fma.f64N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \frac{\left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot \frac{289}{1625702400}\right)}{\mathsf{fma}\left(x, x \cdot \frac{17}{40320}, \frac{-1}{240}\right)} - \frac{\frac{1}{57600}}{\color{blue}{\mathsf{fma}\left(x, x \cdot \frac{17}{40320}, \mathsf{neg}\left(\frac{1}{240}\right)\right)}}, \frac{1}{24}\right), \frac{1}{2}\right) \]
    7. Applied egg-rr67.7%

      \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{\frac{\left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot 1.7776931374401612 \cdot 10^{-7}\right)}{\mathsf{fma}\left(x, x \cdot 0.00042162698412698415, -0.004166666666666667\right)} - \frac{1.736111111111111 \cdot 10^{-5}}{\mathsf{fma}\left(x, x \cdot 0.00042162698412698415, -0.004166666666666667\right)}}, 0.041666666666666664\right), 0.5\right) \]
    8. Taylor expanded in x around 0

      \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{\frac{-289}{6773760} \cdot {x}^{4}} - \frac{\frac{1}{57600}}{\mathsf{fma}\left(x, x \cdot \frac{17}{40320}, \frac{-1}{240}\right)}, \frac{1}{24}\right), \frac{1}{2}\right) \]
    9. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{{x}^{4} \cdot \frac{-289}{6773760}} - \frac{\frac{1}{57600}}{\mathsf{fma}\left(x, x \cdot \frac{17}{40320}, \frac{-1}{240}\right)}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{{x}^{4} \cdot \frac{-289}{6773760}} - \frac{\frac{1}{57600}}{\mathsf{fma}\left(x, x \cdot \frac{17}{40320}, \frac{-1}{240}\right)}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      3. metadata-evalN/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, {x}^{\color{blue}{\left(3 + 1\right)}} \cdot \frac{-289}{6773760} - \frac{\frac{1}{57600}}{\mathsf{fma}\left(x, x \cdot \frac{17}{40320}, \frac{-1}{240}\right)}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      4. pow-plusN/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{\left({x}^{3} \cdot x\right)} \cdot \frac{-289}{6773760} - \frac{\frac{1}{57600}}{\mathsf{fma}\left(x, x \cdot \frac{17}{40320}, \frac{-1}{240}\right)}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      5. *-commutativeN/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{\left(x \cdot {x}^{3}\right)} \cdot \frac{-289}{6773760} - \frac{\frac{1}{57600}}{\mathsf{fma}\left(x, x \cdot \frac{17}{40320}, \frac{-1}{240}\right)}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      6. *-lowering-*.f64N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{\left(x \cdot {x}^{3}\right)} \cdot \frac{-289}{6773760} - \frac{\frac{1}{57600}}{\mathsf{fma}\left(x, x \cdot \frac{17}{40320}, \frac{-1}{240}\right)}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      7. cube-multN/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \left(x \cdot \color{blue}{\left(x \cdot \left(x \cdot x\right)\right)}\right) \cdot \frac{-289}{6773760} - \frac{\frac{1}{57600}}{\mathsf{fma}\left(x, x \cdot \frac{17}{40320}, \frac{-1}{240}\right)}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      8. unpow2N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \left(x \cdot \left(x \cdot \color{blue}{{x}^{2}}\right)\right) \cdot \frac{-289}{6773760} - \frac{\frac{1}{57600}}{\mathsf{fma}\left(x, x \cdot \frac{17}{40320}, \frac{-1}{240}\right)}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \left(x \cdot \color{blue}{\left(x \cdot {x}^{2}\right)}\right) \cdot \frac{-289}{6773760} - \frac{\frac{1}{57600}}{\mathsf{fma}\left(x, x \cdot \frac{17}{40320}, \frac{-1}{240}\right)}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      10. unpow2N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \left(x \cdot \left(x \cdot \color{blue}{\left(x \cdot x\right)}\right)\right) \cdot \frac{-289}{6773760} - \frac{\frac{1}{57600}}{\mathsf{fma}\left(x, x \cdot \frac{17}{40320}, \frac{-1}{240}\right)}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      11. *-lowering-*.f6468.2

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \left(x \cdot \left(x \cdot \color{blue}{\left(x \cdot x\right)}\right)\right) \cdot -4.266463529856387 \cdot 10^{-5} - \frac{1.736111111111111 \cdot 10^{-5}}{\mathsf{fma}\left(x, x \cdot 0.00042162698412698415, -0.004166666666666667\right)}, 0.041666666666666664\right), 0.5\right) \]
    10. Simplified68.2%

      \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{\left(x \cdot \left(x \cdot \left(x \cdot x\right)\right)\right) \cdot -4.266463529856387 \cdot 10^{-5}} - \frac{1.736111111111111 \cdot 10^{-5}}{\mathsf{fma}\left(x, x \cdot 0.00042162698412698415, -0.004166666666666667\right)}, 0.041666666666666664\right), 0.5\right) \]
    11. Taylor expanded in x around 0

      \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{\frac{1}{240} + {x}^{2} \cdot \left(\frac{17}{40320} + \frac{4913}{1137991680} \cdot {x}^{4}\right)}, \frac{1}{24}\right), \frac{1}{2}\right) \]
    12. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{{x}^{2} \cdot \left(\frac{17}{40320} + \frac{4913}{1137991680} \cdot {x}^{4}\right) + \frac{1}{240}}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      2. accelerator-lowering-fma.f64N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{\mathsf{fma}\left({x}^{2}, \frac{17}{40320} + \frac{4913}{1137991680} \cdot {x}^{4}, \frac{1}{240}\right)}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      3. unpow2N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(\color{blue}{x \cdot x}, \frac{17}{40320} + \frac{4913}{1137991680} \cdot {x}^{4}, \frac{1}{240}\right), \frac{1}{24}\right), \frac{1}{2}\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(\color{blue}{x \cdot x}, \frac{17}{40320} + \frac{4913}{1137991680} \cdot {x}^{4}, \frac{1}{240}\right), \frac{1}{24}\right), \frac{1}{2}\right) \]
      5. +-commutativeN/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{\frac{4913}{1137991680} \cdot {x}^{4} + \frac{17}{40320}}, \frac{1}{240}\right), \frac{1}{24}\right), \frac{1}{2}\right) \]
      6. *-commutativeN/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{{x}^{4} \cdot \frac{4913}{1137991680}} + \frac{17}{40320}, \frac{1}{240}\right), \frac{1}{24}\right), \frac{1}{2}\right) \]
      7. metadata-evalN/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, {x}^{\color{blue}{\left(2 \cdot 2\right)}} \cdot \frac{4913}{1137991680} + \frac{17}{40320}, \frac{1}{240}\right), \frac{1}{24}\right), \frac{1}{2}\right) \]
      8. pow-sqrN/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{\left({x}^{2} \cdot {x}^{2}\right)} \cdot \frac{4913}{1137991680} + \frac{17}{40320}, \frac{1}{240}\right), \frac{1}{24}\right), \frac{1}{2}\right) \]
      9. unpow2N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \left(\color{blue}{\left(x \cdot x\right)} \cdot {x}^{2}\right) \cdot \frac{4913}{1137991680} + \frac{17}{40320}, \frac{1}{240}\right), \frac{1}{24}\right), \frac{1}{2}\right) \]
      10. associate-*l*N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{\left(x \cdot \left(x \cdot {x}^{2}\right)\right)} \cdot \frac{4913}{1137991680} + \frac{17}{40320}, \frac{1}{240}\right), \frac{1}{24}\right), \frac{1}{2}\right) \]
      11. associate-*l*N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{x \cdot \left(\left(x \cdot {x}^{2}\right) \cdot \frac{4913}{1137991680}\right)} + \frac{17}{40320}, \frac{1}{240}\right), \frac{1}{24}\right), \frac{1}{2}\right) \]
      12. accelerator-lowering-fma.f64N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{\mathsf{fma}\left(x, \left(x \cdot {x}^{2}\right) \cdot \frac{4913}{1137991680}, \frac{17}{40320}\right)}, \frac{1}{240}\right), \frac{1}{24}\right), \frac{1}{2}\right) \]
      13. *-lowering-*.f64N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, \color{blue}{\left(x \cdot {x}^{2}\right) \cdot \frac{4913}{1137991680}}, \frac{17}{40320}\right), \frac{1}{240}\right), \frac{1}{24}\right), \frac{1}{2}\right) \]
      14. *-lowering-*.f64N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, \color{blue}{\left(x \cdot {x}^{2}\right)} \cdot \frac{4913}{1137991680}, \frac{17}{40320}\right), \frac{1}{240}\right), \frac{1}{24}\right), \frac{1}{2}\right) \]
      15. unpow2N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, \left(x \cdot \color{blue}{\left(x \cdot x\right)}\right) \cdot \frac{4913}{1137991680}, \frac{17}{40320}\right), \frac{1}{240}\right), \frac{1}{24}\right), \frac{1}{2}\right) \]
      16. *-lowering-*.f6468.0

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, \left(x \cdot \color{blue}{\left(x \cdot x\right)}\right) \cdot 4.317254762354677 \cdot 10^{-6}, 0.00042162698412698415\right), 0.004166666666666667\right), 0.041666666666666664\right), 0.5\right) \]
    13. Simplified68.0%

      \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, \left(x \cdot \left(x \cdot x\right)\right) \cdot 4.317254762354677 \cdot 10^{-6}, 0.00042162698412698415\right), 0.004166666666666667\right)}, 0.041666666666666664\right), 0.5\right) \]

    if 3.2000000000000002 < x

    1. Initial program 98.2%

      \[\frac{1 - \cos x}{\sin x} \]
    2. Add Preprocessing
    3. Applied egg-rr9.8%

      \[\leadsto \color{blue}{{1}^{-0.5}} \]
    4. Step-by-step derivation
      1. pow-base-19.8

        \[\leadsto \color{blue}{1} \]
    5. Applied egg-rr9.8%

      \[\leadsto \color{blue}{1} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 5: 53.3% accurate, 4.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 3.2:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot 0.00042162698412698415, 0.004166666666666667\right), 0.041666666666666664\right), x \cdot \left(x \cdot x\right), x \cdot 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= x 3.2)
   (fma
    (fma
     (* x x)
     (fma x (* x 0.00042162698412698415) 0.004166666666666667)
     0.041666666666666664)
    (* x (* x x))
    (* x 0.5))
   1.0))
double code(double x) {
	double tmp;
	if (x <= 3.2) {
		tmp = fma(fma((x * x), fma(x, (x * 0.00042162698412698415), 0.004166666666666667), 0.041666666666666664), (x * (x * x)), (x * 0.5));
	} else {
		tmp = 1.0;
	}
	return tmp;
}
function code(x)
	tmp = 0.0
	if (x <= 3.2)
		tmp = fma(fma(Float64(x * x), fma(x, Float64(x * 0.00042162698412698415), 0.004166666666666667), 0.041666666666666664), Float64(x * Float64(x * x)), Float64(x * 0.5));
	else
		tmp = 1.0;
	end
	return tmp
end
code[x_] := If[LessEqual[x, 3.2], N[(N[(N[(x * x), $MachinePrecision] * N[(x * N[(x * 0.00042162698412698415), $MachinePrecision] + 0.004166666666666667), $MachinePrecision] + 0.041666666666666664), $MachinePrecision] * N[(x * N[(x * x), $MachinePrecision]), $MachinePrecision] + N[(x * 0.5), $MachinePrecision]), $MachinePrecision], 1.0]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.2:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot 0.00042162698412698415, 0.004166666666666667\right), 0.041666666666666664\right), x \cdot \left(x \cdot x\right), x \cdot 0.5\right)\\

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


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

    1. Initial program 37.0%

      \[\frac{1 - \cos x}{\sin x} \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0

      \[\leadsto \color{blue}{x \cdot \left(\frac{1}{2} + {x}^{2} \cdot \left(\frac{1}{24} + {x}^{2} \cdot \left(\frac{1}{240} + \frac{17}{40320} \cdot {x}^{2}\right)\right)\right)} \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{x \cdot \left(\frac{1}{2} + {x}^{2} \cdot \left(\frac{1}{24} + {x}^{2} \cdot \left(\frac{1}{240} + \frac{17}{40320} \cdot {x}^{2}\right)\right)\right)} \]
      2. +-commutativeN/A

        \[\leadsto x \cdot \color{blue}{\left({x}^{2} \cdot \left(\frac{1}{24} + {x}^{2} \cdot \left(\frac{1}{240} + \frac{17}{40320} \cdot {x}^{2}\right)\right) + \frac{1}{2}\right)} \]
      3. accelerator-lowering-fma.f64N/A

        \[\leadsto x \cdot \color{blue}{\mathsf{fma}\left({x}^{2}, \frac{1}{24} + {x}^{2} \cdot \left(\frac{1}{240} + \frac{17}{40320} \cdot {x}^{2}\right), \frac{1}{2}\right)} \]
      4. unpow2N/A

        \[\leadsto x \cdot \mathsf{fma}\left(\color{blue}{x \cdot x}, \frac{1}{24} + {x}^{2} \cdot \left(\frac{1}{240} + \frac{17}{40320} \cdot {x}^{2}\right), \frac{1}{2}\right) \]
      5. *-lowering-*.f64N/A

        \[\leadsto x \cdot \mathsf{fma}\left(\color{blue}{x \cdot x}, \frac{1}{24} + {x}^{2} \cdot \left(\frac{1}{240} + \frac{17}{40320} \cdot {x}^{2}\right), \frac{1}{2}\right) \]
      6. +-commutativeN/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \color{blue}{{x}^{2} \cdot \left(\frac{1}{240} + \frac{17}{40320} \cdot {x}^{2}\right) + \frac{1}{24}}, \frac{1}{2}\right) \]
      7. accelerator-lowering-fma.f64N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \color{blue}{\mathsf{fma}\left({x}^{2}, \frac{1}{240} + \frac{17}{40320} \cdot {x}^{2}, \frac{1}{24}\right)}, \frac{1}{2}\right) \]
      8. unpow2N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(\color{blue}{x \cdot x}, \frac{1}{240} + \frac{17}{40320} \cdot {x}^{2}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(\color{blue}{x \cdot x}, \frac{1}{240} + \frac{17}{40320} \cdot {x}^{2}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      10. +-commutativeN/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{\frac{17}{40320} \cdot {x}^{2} + \frac{1}{240}}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      11. unpow2N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \frac{17}{40320} \cdot \color{blue}{\left(x \cdot x\right)} + \frac{1}{240}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      12. associate-*r*N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{\left(\frac{17}{40320} \cdot x\right) \cdot x} + \frac{1}{240}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      13. *-commutativeN/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{x \cdot \left(\frac{17}{40320} \cdot x\right)} + \frac{1}{240}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      14. accelerator-lowering-fma.f64N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{\mathsf{fma}\left(x, \frac{17}{40320} \cdot x, \frac{1}{240}\right)}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      15. *-commutativeN/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, \color{blue}{x \cdot \frac{17}{40320}}, \frac{1}{240}\right), \frac{1}{24}\right), \frac{1}{2}\right) \]
      16. *-lowering-*.f6468.0

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, \color{blue}{x \cdot 0.00042162698412698415}, 0.004166666666666667\right), 0.041666666666666664\right), 0.5\right) \]
    5. Simplified68.0%

      \[\leadsto \color{blue}{x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot 0.00042162698412698415, 0.004166666666666667\right), 0.041666666666666664\right), 0.5\right)} \]
    6. Step-by-step derivation
      1. distribute-lft-inN/A

        \[\leadsto \color{blue}{x \cdot \left(\left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot \left(x \cdot \frac{17}{40320}\right) + \frac{1}{240}\right) + \frac{1}{24}\right)\right) + x \cdot \frac{1}{2}} \]
      2. *-commutativeN/A

        \[\leadsto \color{blue}{\left(\left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot \left(x \cdot \frac{17}{40320}\right) + \frac{1}{240}\right) + \frac{1}{24}\right)\right) \cdot x} + x \cdot \frac{1}{2} \]
      3. *-commutativeN/A

        \[\leadsto \color{blue}{\left(\left(\left(x \cdot x\right) \cdot \left(x \cdot \left(x \cdot \frac{17}{40320}\right) + \frac{1}{240}\right) + \frac{1}{24}\right) \cdot \left(x \cdot x\right)\right)} \cdot x + x \cdot \frac{1}{2} \]
      4. associate-*l*N/A

        \[\leadsto \color{blue}{\left(\left(x \cdot x\right) \cdot \left(x \cdot \left(x \cdot \frac{17}{40320}\right) + \frac{1}{240}\right) + \frac{1}{24}\right) \cdot \left(\left(x \cdot x\right) \cdot x\right)} + x \cdot \frac{1}{2} \]
      5. pow3N/A

        \[\leadsto \left(\left(x \cdot x\right) \cdot \left(x \cdot \left(x \cdot \frac{17}{40320}\right) + \frac{1}{240}\right) + \frac{1}{24}\right) \cdot \color{blue}{{x}^{3}} + x \cdot \frac{1}{2} \]
      6. accelerator-lowering-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(\left(x \cdot x\right) \cdot \left(x \cdot \left(x \cdot \frac{17}{40320}\right) + \frac{1}{240}\right) + \frac{1}{24}, {x}^{3}, x \cdot \frac{1}{2}\right)} \]
      7. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(x \cdot x, x \cdot \left(x \cdot \frac{17}{40320}\right) + \frac{1}{240}, \frac{1}{24}\right)}, {x}^{3}, x \cdot \frac{1}{2}\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\color{blue}{x \cdot x}, x \cdot \left(x \cdot \frac{17}{40320}\right) + \frac{1}{240}, \frac{1}{24}\right), {x}^{3}, x \cdot \frac{1}{2}\right) \]
      9. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, \color{blue}{\mathsf{fma}\left(x, x \cdot \frac{17}{40320}, \frac{1}{240}\right)}, \frac{1}{24}\right), {x}^{3}, x \cdot \frac{1}{2}\right) \]
      10. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, \color{blue}{x \cdot \frac{17}{40320}}, \frac{1}{240}\right), \frac{1}{24}\right), {x}^{3}, x \cdot \frac{1}{2}\right) \]
      11. cube-unmultN/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \frac{17}{40320}, \frac{1}{240}\right), \frac{1}{24}\right), \color{blue}{x \cdot \left(x \cdot x\right)}, x \cdot \frac{1}{2}\right) \]
      12. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \frac{17}{40320}, \frac{1}{240}\right), \frac{1}{24}\right), \color{blue}{x \cdot \left(x \cdot x\right)}, x \cdot \frac{1}{2}\right) \]
      13. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \frac{17}{40320}, \frac{1}{240}\right), \frac{1}{24}\right), x \cdot \color{blue}{\left(x \cdot x\right)}, x \cdot \frac{1}{2}\right) \]
      14. *-lowering-*.f6468.0

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot 0.00042162698412698415, 0.004166666666666667\right), 0.041666666666666664\right), x \cdot \left(x \cdot x\right), \color{blue}{x \cdot 0.5}\right) \]
    7. Applied egg-rr68.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot 0.00042162698412698415, 0.004166666666666667\right), 0.041666666666666664\right), x \cdot \left(x \cdot x\right), x \cdot 0.5\right)} \]

    if 3.2000000000000002 < x

    1. Initial program 98.2%

      \[\frac{1 - \cos x}{\sin x} \]
    2. Add Preprocessing
    3. Applied egg-rr9.8%

      \[\leadsto \color{blue}{{1}^{-0.5}} \]
    4. Step-by-step derivation
      1. pow-base-19.8

        \[\leadsto \color{blue}{1} \]
    5. Applied egg-rr9.8%

      \[\leadsto \color{blue}{1} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 6: 53.3% accurate, 4.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 3.2:\\ \;\;\;\;x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot 0.00042162698412698415, 0.004166666666666667\right), 0.041666666666666664\right), 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= x 3.2)
   (*
    x
    (fma
     (* x x)
     (fma
      (* x x)
      (fma x (* x 0.00042162698412698415) 0.004166666666666667)
      0.041666666666666664)
     0.5))
   1.0))
double code(double x) {
	double tmp;
	if (x <= 3.2) {
		tmp = x * fma((x * x), fma((x * x), fma(x, (x * 0.00042162698412698415), 0.004166666666666667), 0.041666666666666664), 0.5);
	} else {
		tmp = 1.0;
	}
	return tmp;
}
function code(x)
	tmp = 0.0
	if (x <= 3.2)
		tmp = Float64(x * fma(Float64(x * x), fma(Float64(x * x), fma(x, Float64(x * 0.00042162698412698415), 0.004166666666666667), 0.041666666666666664), 0.5));
	else
		tmp = 1.0;
	end
	return tmp
end
code[x_] := If[LessEqual[x, 3.2], N[(x * N[(N[(x * x), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * N[(x * N[(x * 0.00042162698412698415), $MachinePrecision] + 0.004166666666666667), $MachinePrecision] + 0.041666666666666664), $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision], 1.0]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.2:\\
\;\;\;\;x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot 0.00042162698412698415, 0.004166666666666667\right), 0.041666666666666664\right), 0.5\right)\\

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


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

    1. Initial program 37.0%

      \[\frac{1 - \cos x}{\sin x} \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0

      \[\leadsto \color{blue}{x \cdot \left(\frac{1}{2} + {x}^{2} \cdot \left(\frac{1}{24} + {x}^{2} \cdot \left(\frac{1}{240} + \frac{17}{40320} \cdot {x}^{2}\right)\right)\right)} \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{x \cdot \left(\frac{1}{2} + {x}^{2} \cdot \left(\frac{1}{24} + {x}^{2} \cdot \left(\frac{1}{240} + \frac{17}{40320} \cdot {x}^{2}\right)\right)\right)} \]
      2. +-commutativeN/A

        \[\leadsto x \cdot \color{blue}{\left({x}^{2} \cdot \left(\frac{1}{24} + {x}^{2} \cdot \left(\frac{1}{240} + \frac{17}{40320} \cdot {x}^{2}\right)\right) + \frac{1}{2}\right)} \]
      3. accelerator-lowering-fma.f64N/A

        \[\leadsto x \cdot \color{blue}{\mathsf{fma}\left({x}^{2}, \frac{1}{24} + {x}^{2} \cdot \left(\frac{1}{240} + \frac{17}{40320} \cdot {x}^{2}\right), \frac{1}{2}\right)} \]
      4. unpow2N/A

        \[\leadsto x \cdot \mathsf{fma}\left(\color{blue}{x \cdot x}, \frac{1}{24} + {x}^{2} \cdot \left(\frac{1}{240} + \frac{17}{40320} \cdot {x}^{2}\right), \frac{1}{2}\right) \]
      5. *-lowering-*.f64N/A

        \[\leadsto x \cdot \mathsf{fma}\left(\color{blue}{x \cdot x}, \frac{1}{24} + {x}^{2} \cdot \left(\frac{1}{240} + \frac{17}{40320} \cdot {x}^{2}\right), \frac{1}{2}\right) \]
      6. +-commutativeN/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \color{blue}{{x}^{2} \cdot \left(\frac{1}{240} + \frac{17}{40320} \cdot {x}^{2}\right) + \frac{1}{24}}, \frac{1}{2}\right) \]
      7. accelerator-lowering-fma.f64N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \color{blue}{\mathsf{fma}\left({x}^{2}, \frac{1}{240} + \frac{17}{40320} \cdot {x}^{2}, \frac{1}{24}\right)}, \frac{1}{2}\right) \]
      8. unpow2N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(\color{blue}{x \cdot x}, \frac{1}{240} + \frac{17}{40320} \cdot {x}^{2}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(\color{blue}{x \cdot x}, \frac{1}{240} + \frac{17}{40320} \cdot {x}^{2}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      10. +-commutativeN/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{\frac{17}{40320} \cdot {x}^{2} + \frac{1}{240}}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      11. unpow2N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \frac{17}{40320} \cdot \color{blue}{\left(x \cdot x\right)} + \frac{1}{240}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      12. associate-*r*N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{\left(\frac{17}{40320} \cdot x\right) \cdot x} + \frac{1}{240}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      13. *-commutativeN/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{x \cdot \left(\frac{17}{40320} \cdot x\right)} + \frac{1}{240}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      14. accelerator-lowering-fma.f64N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{\mathsf{fma}\left(x, \frac{17}{40320} \cdot x, \frac{1}{240}\right)}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      15. *-commutativeN/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, \color{blue}{x \cdot \frac{17}{40320}}, \frac{1}{240}\right), \frac{1}{24}\right), \frac{1}{2}\right) \]
      16. *-lowering-*.f6468.0

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, \color{blue}{x \cdot 0.00042162698412698415}, 0.004166666666666667\right), 0.041666666666666664\right), 0.5\right) \]
    5. Simplified68.0%

      \[\leadsto \color{blue}{x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot 0.00042162698412698415, 0.004166666666666667\right), 0.041666666666666664\right), 0.5\right)} \]

    if 3.2000000000000002 < x

    1. Initial program 98.2%

      \[\frac{1 - \cos x}{\sin x} \]
    2. Add Preprocessing
    3. Applied egg-rr9.8%

      \[\leadsto \color{blue}{{1}^{-0.5}} \]
    4. Step-by-step derivation
      1. pow-base-19.8

        \[\leadsto \color{blue}{1} \]
    5. Applied egg-rr9.8%

      \[\leadsto \color{blue}{1} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 7: 53.3% accurate, 6.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 3.2:\\ \;\;\;\;x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot 0.004166666666666667, 0.041666666666666664\right), 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= x 3.2)
   (*
    x
    (fma (* x x) (fma x (* x 0.004166666666666667) 0.041666666666666664) 0.5))
   1.0))
double code(double x) {
	double tmp;
	if (x <= 3.2) {
		tmp = x * fma((x * x), fma(x, (x * 0.004166666666666667), 0.041666666666666664), 0.5);
	} else {
		tmp = 1.0;
	}
	return tmp;
}
function code(x)
	tmp = 0.0
	if (x <= 3.2)
		tmp = Float64(x * fma(Float64(x * x), fma(x, Float64(x * 0.004166666666666667), 0.041666666666666664), 0.5));
	else
		tmp = 1.0;
	end
	return tmp
end
code[x_] := If[LessEqual[x, 3.2], N[(x * N[(N[(x * x), $MachinePrecision] * N[(x * N[(x * 0.004166666666666667), $MachinePrecision] + 0.041666666666666664), $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision], 1.0]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.2:\\
\;\;\;\;x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot 0.004166666666666667, 0.041666666666666664\right), 0.5\right)\\

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


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

    1. Initial program 37.0%

      \[\frac{1 - \cos x}{\sin x} \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0

      \[\leadsto \color{blue}{x \cdot \left(\frac{1}{2} + {x}^{2} \cdot \left(\frac{1}{24} + \frac{1}{240} \cdot {x}^{2}\right)\right)} \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{x \cdot \left(\frac{1}{2} + {x}^{2} \cdot \left(\frac{1}{24} + \frac{1}{240} \cdot {x}^{2}\right)\right)} \]
      2. +-commutativeN/A

        \[\leadsto x \cdot \color{blue}{\left({x}^{2} \cdot \left(\frac{1}{24} + \frac{1}{240} \cdot {x}^{2}\right) + \frac{1}{2}\right)} \]
      3. accelerator-lowering-fma.f64N/A

        \[\leadsto x \cdot \color{blue}{\mathsf{fma}\left({x}^{2}, \frac{1}{24} + \frac{1}{240} \cdot {x}^{2}, \frac{1}{2}\right)} \]
      4. unpow2N/A

        \[\leadsto x \cdot \mathsf{fma}\left(\color{blue}{x \cdot x}, \frac{1}{24} + \frac{1}{240} \cdot {x}^{2}, \frac{1}{2}\right) \]
      5. *-lowering-*.f64N/A

        \[\leadsto x \cdot \mathsf{fma}\left(\color{blue}{x \cdot x}, \frac{1}{24} + \frac{1}{240} \cdot {x}^{2}, \frac{1}{2}\right) \]
      6. +-commutativeN/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \color{blue}{\frac{1}{240} \cdot {x}^{2} + \frac{1}{24}}, \frac{1}{2}\right) \]
      7. unpow2N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \frac{1}{240} \cdot \color{blue}{\left(x \cdot x\right)} + \frac{1}{24}, \frac{1}{2}\right) \]
      8. associate-*r*N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \color{blue}{\left(\frac{1}{240} \cdot x\right) \cdot x} + \frac{1}{24}, \frac{1}{2}\right) \]
      9. *-commutativeN/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \color{blue}{x \cdot \left(\frac{1}{240} \cdot x\right)} + \frac{1}{24}, \frac{1}{2}\right) \]
      10. accelerator-lowering-fma.f64N/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \color{blue}{\mathsf{fma}\left(x, \frac{1}{240} \cdot x, \frac{1}{24}\right)}, \frac{1}{2}\right) \]
      11. *-commutativeN/A

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, \color{blue}{x \cdot \frac{1}{240}}, \frac{1}{24}\right), \frac{1}{2}\right) \]
      12. *-lowering-*.f6467.9

        \[\leadsto x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, \color{blue}{x \cdot 0.004166666666666667}, 0.041666666666666664\right), 0.5\right) \]
    5. Simplified67.9%

      \[\leadsto \color{blue}{x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot 0.004166666666666667, 0.041666666666666664\right), 0.5\right)} \]

    if 3.2000000000000002 < x

    1. Initial program 98.2%

      \[\frac{1 - \cos x}{\sin x} \]
    2. Add Preprocessing
    3. Applied egg-rr9.8%

      \[\leadsto \color{blue}{{1}^{-0.5}} \]
    4. Step-by-step derivation
      1. pow-base-19.8

        \[\leadsto \color{blue}{1} \]
    5. Applied egg-rr9.8%

      \[\leadsto \color{blue}{1} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 8: 53.3% accurate, 9.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 3.2:\\ \;\;\;\;x \cdot \mathsf{fma}\left(x, x \cdot 0.041666666666666664, 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= x 3.2) (* x (fma x (* x 0.041666666666666664) 0.5)) 1.0))
double code(double x) {
	double tmp;
	if (x <= 3.2) {
		tmp = x * fma(x, (x * 0.041666666666666664), 0.5);
	} else {
		tmp = 1.0;
	}
	return tmp;
}
function code(x)
	tmp = 0.0
	if (x <= 3.2)
		tmp = Float64(x * fma(x, Float64(x * 0.041666666666666664), 0.5));
	else
		tmp = 1.0;
	end
	return tmp
end
code[x_] := If[LessEqual[x, 3.2], N[(x * N[(x * N[(x * 0.041666666666666664), $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision], 1.0]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.2:\\
\;\;\;\;x \cdot \mathsf{fma}\left(x, x \cdot 0.041666666666666664, 0.5\right)\\

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


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

    1. Initial program 37.0%

      \[\frac{1 - \cos x}{\sin x} \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0

      \[\leadsto \color{blue}{x \cdot \left(\frac{1}{2} + \frac{1}{24} \cdot {x}^{2}\right)} \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{x \cdot \left(\frac{1}{2} + \frac{1}{24} \cdot {x}^{2}\right)} \]
      2. +-commutativeN/A

        \[\leadsto x \cdot \color{blue}{\left(\frac{1}{24} \cdot {x}^{2} + \frac{1}{2}\right)} \]
      3. unpow2N/A

        \[\leadsto x \cdot \left(\frac{1}{24} \cdot \color{blue}{\left(x \cdot x\right)} + \frac{1}{2}\right) \]
      4. associate-*r*N/A

        \[\leadsto x \cdot \left(\color{blue}{\left(\frac{1}{24} \cdot x\right) \cdot x} + \frac{1}{2}\right) \]
      5. *-commutativeN/A

        \[\leadsto x \cdot \left(\color{blue}{x \cdot \left(\frac{1}{24} \cdot x\right)} + \frac{1}{2}\right) \]
      6. accelerator-lowering-fma.f64N/A

        \[\leadsto x \cdot \color{blue}{\mathsf{fma}\left(x, \frac{1}{24} \cdot x, \frac{1}{2}\right)} \]
      7. *-commutativeN/A

        \[\leadsto x \cdot \mathsf{fma}\left(x, \color{blue}{x \cdot \frac{1}{24}}, \frac{1}{2}\right) \]
      8. *-lowering-*.f6467.8

        \[\leadsto x \cdot \mathsf{fma}\left(x, \color{blue}{x \cdot 0.041666666666666664}, 0.5\right) \]
    5. Simplified67.8%

      \[\leadsto \color{blue}{x \cdot \mathsf{fma}\left(x, x \cdot 0.041666666666666664, 0.5\right)} \]

    if 3.2000000000000002 < x

    1. Initial program 98.2%

      \[\frac{1 - \cos x}{\sin x} \]
    2. Add Preprocessing
    3. Applied egg-rr9.8%

      \[\leadsto \color{blue}{{1}^{-0.5}} \]
    4. Step-by-step derivation
      1. pow-base-19.8

        \[\leadsto \color{blue}{1} \]
    5. Applied egg-rr9.8%

      \[\leadsto \color{blue}{1} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 9: 53.3% accurate, 17.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.4:\\
\;\;\;\;x \cdot 0.5\\

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


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

    1. Initial program 37.0%

      \[\frac{1 - \cos x}{\sin x} \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0

      \[\leadsto \color{blue}{\frac{1}{2} \cdot x} \]
    4. Step-by-step derivation
      1. *-lowering-*.f6467.8

        \[\leadsto \color{blue}{0.5 \cdot x} \]
    5. Simplified67.8%

      \[\leadsto \color{blue}{0.5 \cdot x} \]

    if 1.3999999999999999 < x

    1. Initial program 98.2%

      \[\frac{1 - \cos x}{\sin x} \]
    2. Add Preprocessing
    3. Applied egg-rr9.8%

      \[\leadsto \color{blue}{{1}^{-0.5}} \]
    4. Step-by-step derivation
      1. pow-base-19.8

        \[\leadsto \color{blue}{1} \]
    5. Applied egg-rr9.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 1.4:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 7.0% accurate, 215.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 51.6%

    \[\frac{1 - \cos x}{\sin x} \]
  2. Add Preprocessing
  3. Applied egg-rr7.3%

    \[\leadsto \color{blue}{{1}^{-0.5}} \]
  4. Step-by-step derivation
    1. pow-base-17.3

      \[\leadsto \color{blue}{1} \]
  5. Applied egg-rr7.3%

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

Developer Target 1: 100.0% accurate, 1.9× speedup?

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

\\
\tan \left(\frac{x}{2}\right)
\end{array}

Reproduce

?
herbie shell --seed 2024205 
(FPCore (x)
  :name "tanhf (example 3.4)"
  :precision binary64

  :alt
  (! :herbie-platform default (tan (/ x 2)))

  (/ (- 1.0 (cos x)) (sin x)))