cos2 (problem 3.4.1)

Percentage Accurate: 50.1% → 99.8%
Time: 9.6s
Alternatives: 10
Speedup: 17.8×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 10 alternatives:

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

Initial Program: 50.1% accurate, 1.0× speedup?

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

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

Alternative 1: 99.8% accurate, 0.5× speedup?

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

\\
\frac{\tan \left(\frac{x}{2}\right)}{x} \cdot \frac{\sin x}{x}
\end{array}
Derivation
  1. Initial program 55.1%

    \[\frac{1 - \cos x}{x \cdot x} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. flip--N/A

      \[\leadsto \frac{\frac{1 \cdot 1 - \cos x \cdot \cos x}{1 + \cos x}}{\color{blue}{x} \cdot x} \]
    2. associate-/l/N/A

      \[\leadsto \frac{1 \cdot 1 - \cos x \cdot \cos x}{\color{blue}{\left(x \cdot x\right) \cdot \left(1 + \cos x\right)}} \]
    3. metadata-evalN/A

      \[\leadsto \frac{1 - \cos x \cdot \cos x}{\left(\color{blue}{x} \cdot x\right) \cdot \left(1 + \cos x\right)} \]
    4. 1-sub-cosN/A

      \[\leadsto \frac{\sin x \cdot \sin x}{\color{blue}{\left(x \cdot x\right)} \cdot \left(1 + \cos x\right)} \]
    5. times-fracN/A

      \[\leadsto \frac{\sin x}{x \cdot x} \cdot \color{blue}{\frac{\sin x}{1 + \cos x}} \]
    6. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\left(\frac{\sin x}{x \cdot x}\right), \color{blue}{\left(\frac{\sin x}{1 + \cos x}\right)}\right) \]
    7. /-lowering-/.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\sin x, \left(x \cdot x\right)\right), \left(\frac{\color{blue}{\sin x}}{1 + \cos x}\right)\right) \]
    8. sin-lowering-sin.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(x\right), \left(x \cdot x\right)\right), \left(\frac{\sin \color{blue}{x}}{1 + \cos x}\right)\right) \]
    9. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(x\right), \mathsf{*.f64}\left(x, x\right)\right), \left(\frac{\sin x}{1 + \cos x}\right)\right) \]
    10. hang-0p-tanN/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(x\right), \mathsf{*.f64}\left(x, x\right)\right), \tan \left(\frac{x}{2}\right)\right) \]
    11. tan-lowering-tan.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(x\right), \mathsf{*.f64}\left(x, x\right)\right), \mathsf{tan.f64}\left(\left(\frac{x}{2}\right)\right)\right) \]
    12. /-lowering-/.f6476.1%

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(x\right), \mathsf{*.f64}\left(x, x\right)\right), \mathsf{tan.f64}\left(\mathsf{/.f64}\left(x, 2\right)\right)\right) \]
  4. Applied egg-rr76.1%

    \[\leadsto \color{blue}{\frac{\sin x}{x \cdot x} \cdot \tan \left(\frac{x}{2}\right)} \]
  5. Step-by-step derivation
    1. *-commutativeN/A

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

      \[\leadsto \frac{\tan \left(\frac{x}{2}\right) \cdot \sin x}{\color{blue}{x \cdot x}} \]
    3. times-fracN/A

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

      \[\leadsto \mathsf{*.f64}\left(\left(\frac{\tan \left(\frac{x}{2}\right)}{x}\right), \color{blue}{\left(\frac{\sin x}{x}\right)}\right) \]
    5. /-lowering-/.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\tan \left(\frac{x}{2}\right), x\right), \left(\frac{\color{blue}{\sin x}}{x}\right)\right) \]
    6. tan-lowering-tan.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{tan.f64}\left(\left(\frac{x}{2}\right)\right), x\right), \left(\frac{\sin \color{blue}{x}}{x}\right)\right) \]
    7. /-lowering-/.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{tan.f64}\left(\mathsf{/.f64}\left(x, 2\right)\right), x\right), \left(\frac{\sin x}{x}\right)\right) \]
    8. /-lowering-/.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{tan.f64}\left(\mathsf{/.f64}\left(x, 2\right)\right), x\right), \mathsf{/.f64}\left(\sin x, \color{blue}{x}\right)\right) \]
    9. sin-lowering-sin.f6499.8%

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{tan.f64}\left(\mathsf{/.f64}\left(x, 2\right)\right), x\right), \mathsf{/.f64}\left(\mathsf{sin.f64}\left(x\right), x\right)\right) \]
  6. Applied egg-rr99.8%

    \[\leadsto \color{blue}{\frac{\tan \left(\frac{x}{2}\right)}{x} \cdot \frac{\sin x}{x}} \]
  7. Add Preprocessing

Alternative 2: 75.1% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 0.088:\\ \;\;\;\;0.5 + x \cdot \left(x \cdot \left(-0.041666666666666664 + \left(x \cdot x\right) \cdot \left(0.001388888888888889 + \left(x \cdot x\right) \cdot -2.48015873015873 \cdot 10^{-5}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{x} \cdot \left(1 - \cos x\right)}{x}\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= x 0.088)
   (+
    0.5
    (*
     x
     (*
      x
      (+
       -0.041666666666666664
       (*
        (* x x)
        (+ 0.001388888888888889 (* (* x x) -2.48015873015873e-5)))))))
   (/ (* (/ 1.0 x) (- 1.0 (cos x))) x)))
double code(double x) {
	double tmp;
	if (x <= 0.088) {
		tmp = 0.5 + (x * (x * (-0.041666666666666664 + ((x * x) * (0.001388888888888889 + ((x * x) * -2.48015873015873e-5))))));
	} else {
		tmp = ((1.0 / x) * (1.0 - cos(x))) / x;
	}
	return tmp;
}
real(8) function code(x)
    real(8), intent (in) :: x
    real(8) :: tmp
    if (x <= 0.088d0) then
        tmp = 0.5d0 + (x * (x * ((-0.041666666666666664d0) + ((x * x) * (0.001388888888888889d0 + ((x * x) * (-2.48015873015873d-5)))))))
    else
        tmp = ((1.0d0 / x) * (1.0d0 - cos(x))) / x
    end if
    code = tmp
end function
public static double code(double x) {
	double tmp;
	if (x <= 0.088) {
		tmp = 0.5 + (x * (x * (-0.041666666666666664 + ((x * x) * (0.001388888888888889 + ((x * x) * -2.48015873015873e-5))))));
	} else {
		tmp = ((1.0 / x) * (1.0 - Math.cos(x))) / x;
	}
	return tmp;
}
def code(x):
	tmp = 0
	if x <= 0.088:
		tmp = 0.5 + (x * (x * (-0.041666666666666664 + ((x * x) * (0.001388888888888889 + ((x * x) * -2.48015873015873e-5))))))
	else:
		tmp = ((1.0 / x) * (1.0 - math.cos(x))) / x
	return tmp
function code(x)
	tmp = 0.0
	if (x <= 0.088)
		tmp = Float64(0.5 + Float64(x * Float64(x * Float64(-0.041666666666666664 + Float64(Float64(x * x) * Float64(0.001388888888888889 + Float64(Float64(x * x) * -2.48015873015873e-5)))))));
	else
		tmp = Float64(Float64(Float64(1.0 / x) * Float64(1.0 - cos(x))) / x);
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = 0.0;
	if (x <= 0.088)
		tmp = 0.5 + (x * (x * (-0.041666666666666664 + ((x * x) * (0.001388888888888889 + ((x * x) * -2.48015873015873e-5))))));
	else
		tmp = ((1.0 / x) * (1.0 - cos(x))) / x;
	end
	tmp_2 = tmp;
end
code[x_] := If[LessEqual[x, 0.088], N[(0.5 + N[(x * N[(x * N[(-0.041666666666666664 + N[(N[(x * x), $MachinePrecision] * N[(0.001388888888888889 + N[(N[(x * x), $MachinePrecision] * -2.48015873015873e-5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 / x), $MachinePrecision] * N[(1.0 - N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.088:\\
\;\;\;\;0.5 + x \cdot \left(x \cdot \left(-0.041666666666666664 + \left(x \cdot x\right) \cdot \left(0.001388888888888889 + \left(x \cdot x\right) \cdot -2.48015873015873 \cdot 10^{-5}\right)\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x} \cdot \left(1 - \cos x\right)}{x}\\


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

    1. Initial program 39.3%

      \[\frac{1 - \cos x}{x \cdot x} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. flip--N/A

        \[\leadsto \frac{\frac{1 \cdot 1 - \cos x \cdot \cos x}{1 + \cos x}}{\color{blue}{x} \cdot x} \]
      2. associate-/l/N/A

        \[\leadsto \frac{1 \cdot 1 - \cos x \cdot \cos x}{\color{blue}{\left(x \cdot x\right) \cdot \left(1 + \cos x\right)}} \]
      3. metadata-evalN/A

        \[\leadsto \frac{1 - \cos x \cdot \cos x}{\left(\color{blue}{x} \cdot x\right) \cdot \left(1 + \cos x\right)} \]
      4. 1-sub-cosN/A

        \[\leadsto \frac{\sin x \cdot \sin x}{\color{blue}{\left(x \cdot x\right)} \cdot \left(1 + \cos x\right)} \]
      5. times-fracN/A

        \[\leadsto \frac{\sin x}{x \cdot x} \cdot \color{blue}{\frac{\sin x}{1 + \cos x}} \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{\sin x}{x \cdot x}\right), \color{blue}{\left(\frac{\sin x}{1 + \cos x}\right)}\right) \]
      7. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\sin x, \left(x \cdot x\right)\right), \left(\frac{\color{blue}{\sin x}}{1 + \cos x}\right)\right) \]
      8. sin-lowering-sin.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(x\right), \left(x \cdot x\right)\right), \left(\frac{\sin \color{blue}{x}}{1 + \cos x}\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(x\right), \mathsf{*.f64}\left(x, x\right)\right), \left(\frac{\sin x}{1 + \cos x}\right)\right) \]
      10. hang-0p-tanN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(x\right), \mathsf{*.f64}\left(x, x\right)\right), \tan \left(\frac{x}{2}\right)\right) \]
      11. tan-lowering-tan.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(x\right), \mathsf{*.f64}\left(x, x\right)\right), \mathsf{tan.f64}\left(\left(\frac{x}{2}\right)\right)\right) \]
      12. /-lowering-/.f6467.7%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(x\right), \mathsf{*.f64}\left(x, x\right)\right), \mathsf{tan.f64}\left(\mathsf{/.f64}\left(x, 2\right)\right)\right) \]
    4. Applied egg-rr67.7%

      \[\leadsto \color{blue}{\frac{\sin x}{x \cdot x} \cdot \tan \left(\frac{x}{2}\right)} \]
    5. Taylor expanded in x around 0

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

        \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \color{blue}{\left({x}^{2} \cdot \left({x}^{2} \cdot \left(\frac{1}{720} + \frac{-1}{40320} \cdot {x}^{2}\right) - \frac{1}{24}\right)\right)}\right) \]
      2. unpow2N/A

        \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \left(\left(x \cdot x\right) \cdot \left(\color{blue}{{x}^{2} \cdot \left(\frac{1}{720} + \frac{-1}{40320} \cdot {x}^{2}\right)} - \frac{1}{24}\right)\right)\right) \]
      3. associate-*l*N/A

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

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

        \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \color{blue}{\left({x}^{2} \cdot \left(\frac{1}{720} + \frac{-1}{40320} \cdot {x}^{2}\right) - \frac{1}{24}\right)}\right)\right)\right) \]
      6. sub-negN/A

        \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \left({x}^{2} \cdot \left(\frac{1}{720} + \frac{-1}{40320} \cdot {x}^{2}\right) + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{24}\right)\right)}\right)\right)\right)\right) \]
      7. metadata-evalN/A

        \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \left({x}^{2} \cdot \left(\frac{1}{720} + \frac{-1}{40320} \cdot {x}^{2}\right) + \frac{-1}{24}\right)\right)\right)\right) \]
      8. +-commutativeN/A

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

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

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

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

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

        \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{-1}{24}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \mathsf{+.f64}\left(\frac{1}{720}, \color{blue}{\left(\frac{-1}{40320} \cdot {x}^{2}\right)}\right)\right)\right)\right)\right)\right) \]
      14. *-commutativeN/A

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

        \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{-1}{24}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \mathsf{+.f64}\left(\frac{1}{720}, \mathsf{*.f64}\left(\left({x}^{2}\right), \color{blue}{\frac{-1}{40320}}\right)\right)\right)\right)\right)\right)\right) \]
      16. unpow2N/A

        \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{-1}{24}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \mathsf{+.f64}\left(\frac{1}{720}, \mathsf{*.f64}\left(\left(x \cdot x\right), \frac{-1}{40320}\right)\right)\right)\right)\right)\right)\right) \]
      17. *-lowering-*.f6463.4%

        \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{-1}{24}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \mathsf{+.f64}\left(\frac{1}{720}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \frac{-1}{40320}\right)\right)\right)\right)\right)\right)\right) \]
    7. Simplified63.4%

      \[\leadsto \color{blue}{0.5 + x \cdot \left(x \cdot \left(-0.041666666666666664 + \left(x \cdot x\right) \cdot \left(0.001388888888888889 + \left(x \cdot x\right) \cdot -2.48015873015873 \cdot 10^{-5}\right)\right)\right)} \]

    if 0.087999999999999995 < x

    1. Initial program 98.6%

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

      \[\leadsto \color{blue}{\frac{1 - \cos x}{{x}^{2}}} \]
    4. Step-by-step derivation
      1. unpow2N/A

        \[\leadsto \frac{1 - \cos x}{x \cdot \color{blue}{x}} \]
      2. associate-/r*N/A

        \[\leadsto \frac{\frac{1 - \cos x}{x}}{\color{blue}{x}} \]
      3. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{1 - \cos x}{x}\right), \color{blue}{x}\right) \]
      4. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\left(1 - \cos x\right), x\right), x\right) \]
      5. --lowering--.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \cos x\right), x\right), x\right) \]
      6. cos-lowering-cos.f6499.2%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{cos.f64}\left(x\right)\right), x\right), x\right) \]
    5. Simplified99.2%

      \[\leadsto \color{blue}{\frac{\frac{1 - \cos x}{x}}{x}} \]
    6. Step-by-step derivation
      1. clear-numN/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{1}{\frac{x}{1 - \cos x}}\right), x\right) \]
      2. associate-/r/N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{1}{x} \cdot \left(1 - \cos x\right)\right), x\right) \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\left(\frac{1}{x}\right), \left(1 - \cos x\right)\right), x\right) \]
      4. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(1, x\right), \left(1 - \cos x\right)\right), x\right) \]
      5. --lowering--.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(1, x\right), \mathsf{\_.f64}\left(1, \cos x\right)\right), x\right) \]
      6. cos-lowering-cos.f6499.2%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(1, x\right), \mathsf{\_.f64}\left(1, \mathsf{cos.f64}\left(x\right)\right)\right), x\right) \]
    7. Applied egg-rr99.2%

      \[\leadsto \frac{\color{blue}{\frac{1}{x} \cdot \left(1 - \cos x\right)}}{x} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 3: 75.1% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 0.088:\\ \;\;\;\;0.5 + x \cdot \left(x \cdot \left(-0.041666666666666664 + \left(x \cdot x\right) \cdot \left(0.001388888888888889 + \left(x \cdot x\right) \cdot -2.48015873015873 \cdot 10^{-5}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{-1}{x} \cdot \frac{\cos x + -1}{x}\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= x 0.088)
   (+
    0.5
    (*
     x
     (*
      x
      (+
       -0.041666666666666664
       (*
        (* x x)
        (+ 0.001388888888888889 (* (* x x) -2.48015873015873e-5)))))))
   (* (/ -1.0 x) (/ (+ (cos x) -1.0) x))))
double code(double x) {
	double tmp;
	if (x <= 0.088) {
		tmp = 0.5 + (x * (x * (-0.041666666666666664 + ((x * x) * (0.001388888888888889 + ((x * x) * -2.48015873015873e-5))))));
	} else {
		tmp = (-1.0 / x) * ((cos(x) + -1.0) / x);
	}
	return tmp;
}
real(8) function code(x)
    real(8), intent (in) :: x
    real(8) :: tmp
    if (x <= 0.088d0) then
        tmp = 0.5d0 + (x * (x * ((-0.041666666666666664d0) + ((x * x) * (0.001388888888888889d0 + ((x * x) * (-2.48015873015873d-5)))))))
    else
        tmp = ((-1.0d0) / x) * ((cos(x) + (-1.0d0)) / x)
    end if
    code = tmp
end function
public static double code(double x) {
	double tmp;
	if (x <= 0.088) {
		tmp = 0.5 + (x * (x * (-0.041666666666666664 + ((x * x) * (0.001388888888888889 + ((x * x) * -2.48015873015873e-5))))));
	} else {
		tmp = (-1.0 / x) * ((Math.cos(x) + -1.0) / x);
	}
	return tmp;
}
def code(x):
	tmp = 0
	if x <= 0.088:
		tmp = 0.5 + (x * (x * (-0.041666666666666664 + ((x * x) * (0.001388888888888889 + ((x * x) * -2.48015873015873e-5))))))
	else:
		tmp = (-1.0 / x) * ((math.cos(x) + -1.0) / x)
	return tmp
function code(x)
	tmp = 0.0
	if (x <= 0.088)
		tmp = Float64(0.5 + Float64(x * Float64(x * Float64(-0.041666666666666664 + Float64(Float64(x * x) * Float64(0.001388888888888889 + Float64(Float64(x * x) * -2.48015873015873e-5)))))));
	else
		tmp = Float64(Float64(-1.0 / x) * Float64(Float64(cos(x) + -1.0) / x));
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = 0.0;
	if (x <= 0.088)
		tmp = 0.5 + (x * (x * (-0.041666666666666664 + ((x * x) * (0.001388888888888889 + ((x * x) * -2.48015873015873e-5))))));
	else
		tmp = (-1.0 / x) * ((cos(x) + -1.0) / x);
	end
	tmp_2 = tmp;
end
code[x_] := If[LessEqual[x, 0.088], N[(0.5 + N[(x * N[(x * N[(-0.041666666666666664 + N[(N[(x * x), $MachinePrecision] * N[(0.001388888888888889 + N[(N[(x * x), $MachinePrecision] * -2.48015873015873e-5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-1.0 / x), $MachinePrecision] * N[(N[(N[Cos[x], $MachinePrecision] + -1.0), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.088:\\
\;\;\;\;0.5 + x \cdot \left(x \cdot \left(-0.041666666666666664 + \left(x \cdot x\right) \cdot \left(0.001388888888888889 + \left(x \cdot x\right) \cdot -2.48015873015873 \cdot 10^{-5}\right)\right)\right)\\

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


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

    1. Initial program 39.3%

      \[\frac{1 - \cos x}{x \cdot x} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. flip--N/A

        \[\leadsto \frac{\frac{1 \cdot 1 - \cos x \cdot \cos x}{1 + \cos x}}{\color{blue}{x} \cdot x} \]
      2. associate-/l/N/A

        \[\leadsto \frac{1 \cdot 1 - \cos x \cdot \cos x}{\color{blue}{\left(x \cdot x\right) \cdot \left(1 + \cos x\right)}} \]
      3. metadata-evalN/A

        \[\leadsto \frac{1 - \cos x \cdot \cos x}{\left(\color{blue}{x} \cdot x\right) \cdot \left(1 + \cos x\right)} \]
      4. 1-sub-cosN/A

        \[\leadsto \frac{\sin x \cdot \sin x}{\color{blue}{\left(x \cdot x\right)} \cdot \left(1 + \cos x\right)} \]
      5. times-fracN/A

        \[\leadsto \frac{\sin x}{x \cdot x} \cdot \color{blue}{\frac{\sin x}{1 + \cos x}} \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{\sin x}{x \cdot x}\right), \color{blue}{\left(\frac{\sin x}{1 + \cos x}\right)}\right) \]
      7. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\sin x, \left(x \cdot x\right)\right), \left(\frac{\color{blue}{\sin x}}{1 + \cos x}\right)\right) \]
      8. sin-lowering-sin.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(x\right), \left(x \cdot x\right)\right), \left(\frac{\sin \color{blue}{x}}{1 + \cos x}\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(x\right), \mathsf{*.f64}\left(x, x\right)\right), \left(\frac{\sin x}{1 + \cos x}\right)\right) \]
      10. hang-0p-tanN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(x\right), \mathsf{*.f64}\left(x, x\right)\right), \tan \left(\frac{x}{2}\right)\right) \]
      11. tan-lowering-tan.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(x\right), \mathsf{*.f64}\left(x, x\right)\right), \mathsf{tan.f64}\left(\left(\frac{x}{2}\right)\right)\right) \]
      12. /-lowering-/.f6467.7%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(x\right), \mathsf{*.f64}\left(x, x\right)\right), \mathsf{tan.f64}\left(\mathsf{/.f64}\left(x, 2\right)\right)\right) \]
    4. Applied egg-rr67.7%

      \[\leadsto \color{blue}{\frac{\sin x}{x \cdot x} \cdot \tan \left(\frac{x}{2}\right)} \]
    5. Taylor expanded in x around 0

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

        \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \color{blue}{\left({x}^{2} \cdot \left({x}^{2} \cdot \left(\frac{1}{720} + \frac{-1}{40320} \cdot {x}^{2}\right) - \frac{1}{24}\right)\right)}\right) \]
      2. unpow2N/A

        \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \left(\left(x \cdot x\right) \cdot \left(\color{blue}{{x}^{2} \cdot \left(\frac{1}{720} + \frac{-1}{40320} \cdot {x}^{2}\right)} - \frac{1}{24}\right)\right)\right) \]
      3. associate-*l*N/A

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

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

        \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \color{blue}{\left({x}^{2} \cdot \left(\frac{1}{720} + \frac{-1}{40320} \cdot {x}^{2}\right) - \frac{1}{24}\right)}\right)\right)\right) \]
      6. sub-negN/A

        \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \left({x}^{2} \cdot \left(\frac{1}{720} + \frac{-1}{40320} \cdot {x}^{2}\right) + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{24}\right)\right)}\right)\right)\right)\right) \]
      7. metadata-evalN/A

        \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \left({x}^{2} \cdot \left(\frac{1}{720} + \frac{-1}{40320} \cdot {x}^{2}\right) + \frac{-1}{24}\right)\right)\right)\right) \]
      8. +-commutativeN/A

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

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

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

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

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

        \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{-1}{24}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \mathsf{+.f64}\left(\frac{1}{720}, \color{blue}{\left(\frac{-1}{40320} \cdot {x}^{2}\right)}\right)\right)\right)\right)\right)\right) \]
      14. *-commutativeN/A

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

        \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{-1}{24}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \mathsf{+.f64}\left(\frac{1}{720}, \mathsf{*.f64}\left(\left({x}^{2}\right), \color{blue}{\frac{-1}{40320}}\right)\right)\right)\right)\right)\right)\right) \]
      16. unpow2N/A

        \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{-1}{24}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \mathsf{+.f64}\left(\frac{1}{720}, \mathsf{*.f64}\left(\left(x \cdot x\right), \frac{-1}{40320}\right)\right)\right)\right)\right)\right)\right) \]
      17. *-lowering-*.f6463.4%

        \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{-1}{24}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \mathsf{+.f64}\left(\frac{1}{720}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \frac{-1}{40320}\right)\right)\right)\right)\right)\right)\right) \]
    7. Simplified63.4%

      \[\leadsto \color{blue}{0.5 + x \cdot \left(x \cdot \left(-0.041666666666666664 + \left(x \cdot x\right) \cdot \left(0.001388888888888889 + \left(x \cdot x\right) \cdot -2.48015873015873 \cdot 10^{-5}\right)\right)\right)} \]

    if 0.087999999999999995 < x

    1. Initial program 98.6%

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

      \[\leadsto \color{blue}{\frac{-1}{x} \cdot \frac{\cos x + -1}{x}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 4: 75.1% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 0.1:\\ \;\;\;\;0.5 + x \cdot \left(x \cdot \left(-0.041666666666666664 + \left(x \cdot x\right) \cdot \left(0.001388888888888889 + \left(x \cdot x\right) \cdot -2.48015873015873 \cdot 10^{-5}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1 - \cos x}{x}}{x}\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= x 0.1)
   (+
    0.5
    (*
     x
     (*
      x
      (+
       -0.041666666666666664
       (*
        (* x x)
        (+ 0.001388888888888889 (* (* x x) -2.48015873015873e-5)))))))
   (/ (/ (- 1.0 (cos x)) x) x)))
double code(double x) {
	double tmp;
	if (x <= 0.1) {
		tmp = 0.5 + (x * (x * (-0.041666666666666664 + ((x * x) * (0.001388888888888889 + ((x * x) * -2.48015873015873e-5))))));
	} else {
		tmp = ((1.0 - cos(x)) / x) / x;
	}
	return tmp;
}
real(8) function code(x)
    real(8), intent (in) :: x
    real(8) :: tmp
    if (x <= 0.1d0) then
        tmp = 0.5d0 + (x * (x * ((-0.041666666666666664d0) + ((x * x) * (0.001388888888888889d0 + ((x * x) * (-2.48015873015873d-5)))))))
    else
        tmp = ((1.0d0 - cos(x)) / x) / x
    end if
    code = tmp
end function
public static double code(double x) {
	double tmp;
	if (x <= 0.1) {
		tmp = 0.5 + (x * (x * (-0.041666666666666664 + ((x * x) * (0.001388888888888889 + ((x * x) * -2.48015873015873e-5))))));
	} else {
		tmp = ((1.0 - Math.cos(x)) / x) / x;
	}
	return tmp;
}
def code(x):
	tmp = 0
	if x <= 0.1:
		tmp = 0.5 + (x * (x * (-0.041666666666666664 + ((x * x) * (0.001388888888888889 + ((x * x) * -2.48015873015873e-5))))))
	else:
		tmp = ((1.0 - math.cos(x)) / x) / x
	return tmp
function code(x)
	tmp = 0.0
	if (x <= 0.1)
		tmp = Float64(0.5 + Float64(x * Float64(x * Float64(-0.041666666666666664 + Float64(Float64(x * x) * Float64(0.001388888888888889 + Float64(Float64(x * x) * -2.48015873015873e-5)))))));
	else
		tmp = Float64(Float64(Float64(1.0 - cos(x)) / x) / x);
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = 0.0;
	if (x <= 0.1)
		tmp = 0.5 + (x * (x * (-0.041666666666666664 + ((x * x) * (0.001388888888888889 + ((x * x) * -2.48015873015873e-5))))));
	else
		tmp = ((1.0 - cos(x)) / x) / x;
	end
	tmp_2 = tmp;
end
code[x_] := If[LessEqual[x, 0.1], N[(0.5 + N[(x * N[(x * N[(-0.041666666666666664 + N[(N[(x * x), $MachinePrecision] * N[(0.001388888888888889 + N[(N[(x * x), $MachinePrecision] * -2.48015873015873e-5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 - N[Cos[x], $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.1:\\
\;\;\;\;0.5 + x \cdot \left(x \cdot \left(-0.041666666666666664 + \left(x \cdot x\right) \cdot \left(0.001388888888888889 + \left(x \cdot x\right) \cdot -2.48015873015873 \cdot 10^{-5}\right)\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 - \cos x}{x}}{x}\\


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

    1. Initial program 39.6%

      \[\frac{1 - \cos x}{x \cdot x} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. flip--N/A

        \[\leadsto \frac{\frac{1 \cdot 1 - \cos x \cdot \cos x}{1 + \cos x}}{\color{blue}{x} \cdot x} \]
      2. associate-/l/N/A

        \[\leadsto \frac{1 \cdot 1 - \cos x \cdot \cos x}{\color{blue}{\left(x \cdot x\right) \cdot \left(1 + \cos x\right)}} \]
      3. metadata-evalN/A

        \[\leadsto \frac{1 - \cos x \cdot \cos x}{\left(\color{blue}{x} \cdot x\right) \cdot \left(1 + \cos x\right)} \]
      4. 1-sub-cosN/A

        \[\leadsto \frac{\sin x \cdot \sin x}{\color{blue}{\left(x \cdot x\right)} \cdot \left(1 + \cos x\right)} \]
      5. times-fracN/A

        \[\leadsto \frac{\sin x}{x \cdot x} \cdot \color{blue}{\frac{\sin x}{1 + \cos x}} \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{\sin x}{x \cdot x}\right), \color{blue}{\left(\frac{\sin x}{1 + \cos x}\right)}\right) \]
      7. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\sin x, \left(x \cdot x\right)\right), \left(\frac{\color{blue}{\sin x}}{1 + \cos x}\right)\right) \]
      8. sin-lowering-sin.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(x\right), \left(x \cdot x\right)\right), \left(\frac{\sin \color{blue}{x}}{1 + \cos x}\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(x\right), \mathsf{*.f64}\left(x, x\right)\right), \left(\frac{\sin x}{1 + \cos x}\right)\right) \]
      10. hang-0p-tanN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(x\right), \mathsf{*.f64}\left(x, x\right)\right), \tan \left(\frac{x}{2}\right)\right) \]
      11. tan-lowering-tan.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(x\right), \mathsf{*.f64}\left(x, x\right)\right), \mathsf{tan.f64}\left(\left(\frac{x}{2}\right)\right)\right) \]
      12. /-lowering-/.f6467.9%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(x\right), \mathsf{*.f64}\left(x, x\right)\right), \mathsf{tan.f64}\left(\mathsf{/.f64}\left(x, 2\right)\right)\right) \]
    4. Applied egg-rr67.9%

      \[\leadsto \color{blue}{\frac{\sin x}{x \cdot x} \cdot \tan \left(\frac{x}{2}\right)} \]
    5. Taylor expanded in x around 0

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

        \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \color{blue}{\left({x}^{2} \cdot \left({x}^{2} \cdot \left(\frac{1}{720} + \frac{-1}{40320} \cdot {x}^{2}\right) - \frac{1}{24}\right)\right)}\right) \]
      2. unpow2N/A

        \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \left(\left(x \cdot x\right) \cdot \left(\color{blue}{{x}^{2} \cdot \left(\frac{1}{720} + \frac{-1}{40320} \cdot {x}^{2}\right)} - \frac{1}{24}\right)\right)\right) \]
      3. associate-*l*N/A

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

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

        \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \color{blue}{\left({x}^{2} \cdot \left(\frac{1}{720} + \frac{-1}{40320} \cdot {x}^{2}\right) - \frac{1}{24}\right)}\right)\right)\right) \]
      6. sub-negN/A

        \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \left({x}^{2} \cdot \left(\frac{1}{720} + \frac{-1}{40320} \cdot {x}^{2}\right) + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{24}\right)\right)}\right)\right)\right)\right) \]
      7. metadata-evalN/A

        \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \left({x}^{2} \cdot \left(\frac{1}{720} + \frac{-1}{40320} \cdot {x}^{2}\right) + \frac{-1}{24}\right)\right)\right)\right) \]
      8. +-commutativeN/A

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

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

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

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

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

        \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{-1}{24}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \mathsf{+.f64}\left(\frac{1}{720}, \color{blue}{\left(\frac{-1}{40320} \cdot {x}^{2}\right)}\right)\right)\right)\right)\right)\right) \]
      14. *-commutativeN/A

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

        \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{-1}{24}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \mathsf{+.f64}\left(\frac{1}{720}, \mathsf{*.f64}\left(\left({x}^{2}\right), \color{blue}{\frac{-1}{40320}}\right)\right)\right)\right)\right)\right)\right) \]
      16. unpow2N/A

        \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{-1}{24}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \mathsf{+.f64}\left(\frac{1}{720}, \mathsf{*.f64}\left(\left(x \cdot x\right), \frac{-1}{40320}\right)\right)\right)\right)\right)\right)\right) \]
      17. *-lowering-*.f6463.6%

        \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{-1}{24}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \mathsf{+.f64}\left(\frac{1}{720}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \frac{-1}{40320}\right)\right)\right)\right)\right)\right)\right) \]
    7. Simplified63.6%

      \[\leadsto \color{blue}{0.5 + x \cdot \left(x \cdot \left(-0.041666666666666664 + \left(x \cdot x\right) \cdot \left(0.001388888888888889 + \left(x \cdot x\right) \cdot -2.48015873015873 \cdot 10^{-5}\right)\right)\right)} \]

    if 0.10000000000000001 < x

    1. Initial program 98.7%

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

      \[\leadsto \color{blue}{\frac{1 - \cos x}{{x}^{2}}} \]
    4. Step-by-step derivation
      1. unpow2N/A

        \[\leadsto \frac{1 - \cos x}{x \cdot \color{blue}{x}} \]
      2. associate-/r*N/A

        \[\leadsto \frac{\frac{1 - \cos x}{x}}{\color{blue}{x}} \]
      3. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{1 - \cos x}{x}\right), \color{blue}{x}\right) \]
      4. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\left(1 - \cos x\right), x\right), x\right) \]
      5. --lowering--.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \cos x\right), x\right), x\right) \]
      6. cos-lowering-cos.f6499.3%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{cos.f64}\left(x\right)\right), x\right), x\right) \]
    5. Simplified99.3%

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

Alternative 5: 74.7% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 0.1:\\ \;\;\;\;0.5 + x \cdot \left(x \cdot \left(-0.041666666666666664 + \left(x \cdot x\right) \cdot \left(0.001388888888888889 + \left(x \cdot x\right) \cdot -2.48015873015873 \cdot 10^{-5}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1 - \cos x}{x \cdot x}\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= x 0.1)
   (+
    0.5
    (*
     x
     (*
      x
      (+
       -0.041666666666666664
       (*
        (* x x)
        (+ 0.001388888888888889 (* (* x x) -2.48015873015873e-5)))))))
   (/ (- 1.0 (cos x)) (* x x))))
double code(double x) {
	double tmp;
	if (x <= 0.1) {
		tmp = 0.5 + (x * (x * (-0.041666666666666664 + ((x * x) * (0.001388888888888889 + ((x * x) * -2.48015873015873e-5))))));
	} else {
		tmp = (1.0 - cos(x)) / (x * x);
	}
	return tmp;
}
real(8) function code(x)
    real(8), intent (in) :: x
    real(8) :: tmp
    if (x <= 0.1d0) then
        tmp = 0.5d0 + (x * (x * ((-0.041666666666666664d0) + ((x * x) * (0.001388888888888889d0 + ((x * x) * (-2.48015873015873d-5)))))))
    else
        tmp = (1.0d0 - cos(x)) / (x * x)
    end if
    code = tmp
end function
public static double code(double x) {
	double tmp;
	if (x <= 0.1) {
		tmp = 0.5 + (x * (x * (-0.041666666666666664 + ((x * x) * (0.001388888888888889 + ((x * x) * -2.48015873015873e-5))))));
	} else {
		tmp = (1.0 - Math.cos(x)) / (x * x);
	}
	return tmp;
}
def code(x):
	tmp = 0
	if x <= 0.1:
		tmp = 0.5 + (x * (x * (-0.041666666666666664 + ((x * x) * (0.001388888888888889 + ((x * x) * -2.48015873015873e-5))))))
	else:
		tmp = (1.0 - math.cos(x)) / (x * x)
	return tmp
function code(x)
	tmp = 0.0
	if (x <= 0.1)
		tmp = Float64(0.5 + Float64(x * Float64(x * Float64(-0.041666666666666664 + Float64(Float64(x * x) * Float64(0.001388888888888889 + Float64(Float64(x * x) * -2.48015873015873e-5)))))));
	else
		tmp = Float64(Float64(1.0 - cos(x)) / Float64(x * x));
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = 0.0;
	if (x <= 0.1)
		tmp = 0.5 + (x * (x * (-0.041666666666666664 + ((x * x) * (0.001388888888888889 + ((x * x) * -2.48015873015873e-5))))));
	else
		tmp = (1.0 - cos(x)) / (x * x);
	end
	tmp_2 = tmp;
end
code[x_] := If[LessEqual[x, 0.1], N[(0.5 + N[(x * N[(x * N[(-0.041666666666666664 + N[(N[(x * x), $MachinePrecision] * N[(0.001388888888888889 + N[(N[(x * x), $MachinePrecision] * -2.48015873015873e-5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - N[Cos[x], $MachinePrecision]), $MachinePrecision] / N[(x * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.1:\\
\;\;\;\;0.5 + x \cdot \left(x \cdot \left(-0.041666666666666664 + \left(x \cdot x\right) \cdot \left(0.001388888888888889 + \left(x \cdot x\right) \cdot -2.48015873015873 \cdot 10^{-5}\right)\right)\right)\\

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


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

    1. Initial program 39.6%

      \[\frac{1 - \cos x}{x \cdot x} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. flip--N/A

        \[\leadsto \frac{\frac{1 \cdot 1 - \cos x \cdot \cos x}{1 + \cos x}}{\color{blue}{x} \cdot x} \]
      2. associate-/l/N/A

        \[\leadsto \frac{1 \cdot 1 - \cos x \cdot \cos x}{\color{blue}{\left(x \cdot x\right) \cdot \left(1 + \cos x\right)}} \]
      3. metadata-evalN/A

        \[\leadsto \frac{1 - \cos x \cdot \cos x}{\left(\color{blue}{x} \cdot x\right) \cdot \left(1 + \cos x\right)} \]
      4. 1-sub-cosN/A

        \[\leadsto \frac{\sin x \cdot \sin x}{\color{blue}{\left(x \cdot x\right)} \cdot \left(1 + \cos x\right)} \]
      5. times-fracN/A

        \[\leadsto \frac{\sin x}{x \cdot x} \cdot \color{blue}{\frac{\sin x}{1 + \cos x}} \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{\sin x}{x \cdot x}\right), \color{blue}{\left(\frac{\sin x}{1 + \cos x}\right)}\right) \]
      7. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\sin x, \left(x \cdot x\right)\right), \left(\frac{\color{blue}{\sin x}}{1 + \cos x}\right)\right) \]
      8. sin-lowering-sin.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(x\right), \left(x \cdot x\right)\right), \left(\frac{\sin \color{blue}{x}}{1 + \cos x}\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(x\right), \mathsf{*.f64}\left(x, x\right)\right), \left(\frac{\sin x}{1 + \cos x}\right)\right) \]
      10. hang-0p-tanN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(x\right), \mathsf{*.f64}\left(x, x\right)\right), \tan \left(\frac{x}{2}\right)\right) \]
      11. tan-lowering-tan.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(x\right), \mathsf{*.f64}\left(x, x\right)\right), \mathsf{tan.f64}\left(\left(\frac{x}{2}\right)\right)\right) \]
      12. /-lowering-/.f6467.9%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{sin.f64}\left(x\right), \mathsf{*.f64}\left(x, x\right)\right), \mathsf{tan.f64}\left(\mathsf{/.f64}\left(x, 2\right)\right)\right) \]
    4. Applied egg-rr67.9%

      \[\leadsto \color{blue}{\frac{\sin x}{x \cdot x} \cdot \tan \left(\frac{x}{2}\right)} \]
    5. Taylor expanded in x around 0

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

        \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \color{blue}{\left({x}^{2} \cdot \left({x}^{2} \cdot \left(\frac{1}{720} + \frac{-1}{40320} \cdot {x}^{2}\right) - \frac{1}{24}\right)\right)}\right) \]
      2. unpow2N/A

        \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \left(\left(x \cdot x\right) \cdot \left(\color{blue}{{x}^{2} \cdot \left(\frac{1}{720} + \frac{-1}{40320} \cdot {x}^{2}\right)} - \frac{1}{24}\right)\right)\right) \]
      3. associate-*l*N/A

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

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

        \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \color{blue}{\left({x}^{2} \cdot \left(\frac{1}{720} + \frac{-1}{40320} \cdot {x}^{2}\right) - \frac{1}{24}\right)}\right)\right)\right) \]
      6. sub-negN/A

        \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \left({x}^{2} \cdot \left(\frac{1}{720} + \frac{-1}{40320} \cdot {x}^{2}\right) + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{24}\right)\right)}\right)\right)\right)\right) \]
      7. metadata-evalN/A

        \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \left({x}^{2} \cdot \left(\frac{1}{720} + \frac{-1}{40320} \cdot {x}^{2}\right) + \frac{-1}{24}\right)\right)\right)\right) \]
      8. +-commutativeN/A

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

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

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

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

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

        \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{-1}{24}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \mathsf{+.f64}\left(\frac{1}{720}, \color{blue}{\left(\frac{-1}{40320} \cdot {x}^{2}\right)}\right)\right)\right)\right)\right)\right) \]
      14. *-commutativeN/A

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

        \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{-1}{24}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \mathsf{+.f64}\left(\frac{1}{720}, \mathsf{*.f64}\left(\left({x}^{2}\right), \color{blue}{\frac{-1}{40320}}\right)\right)\right)\right)\right)\right)\right) \]
      16. unpow2N/A

        \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{-1}{24}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \mathsf{+.f64}\left(\frac{1}{720}, \mathsf{*.f64}\left(\left(x \cdot x\right), \frac{-1}{40320}\right)\right)\right)\right)\right)\right)\right) \]
      17. *-lowering-*.f6463.6%

        \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{-1}{24}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \mathsf{+.f64}\left(\frac{1}{720}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \frac{-1}{40320}\right)\right)\right)\right)\right)\right)\right) \]
    7. Simplified63.6%

      \[\leadsto \color{blue}{0.5 + x \cdot \left(x \cdot \left(-0.041666666666666664 + \left(x \cdot x\right) \cdot \left(0.001388888888888889 + \left(x \cdot x\right) \cdot -2.48015873015873 \cdot 10^{-5}\right)\right)\right)} \]

    if 0.10000000000000001 < x

    1. Initial program 98.7%

      \[\frac{1 - \cos x}{x \cdot x} \]
    2. Add Preprocessing
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 6: 63.3% accurate, 8.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.5:\\
\;\;\;\;0.5 + -0.041666666666666664 \cdot \left(x \cdot x\right)\\

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


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

    1. Initial program 40.2%

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

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

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

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

        \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{24}, \left(x \cdot \color{blue}{x}\right)\right)\right) \]
      4. *-lowering-*.f6462.8%

        \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{24}, \mathsf{*.f64}\left(x, \color{blue}{x}\right)\right)\right) \]
    5. Simplified62.8%

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

    if 3.5 < x

    1. Initial program 98.8%

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

      \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \color{blue}{1}\right), \mathsf{*.f64}\left(x, x\right)\right) \]
    4. Step-by-step derivation
      1. Simplified50.4%

        \[\leadsto \frac{1 - \color{blue}{1}}{x \cdot x} \]
    5. Recombined 2 regimes into one program.
    6. Final simplification59.7%

      \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 3.5:\\ \;\;\;\;0.5 + -0.041666666666666664 \cdot \left(x \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1 + -1}{x \cdot x}\\ \end{array} \]
    7. Add Preprocessing

    Alternative 7: 63.3% accurate, 8.9× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 3.5:\\ \;\;\;\;0.5 + -0.041666666666666664 \cdot \left(x \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \end{array} \]
    (FPCore (x)
     :precision binary64
     (if (<= x 3.5) (+ 0.5 (* -0.041666666666666664 (* x x))) 0.0))
    double code(double x) {
    	double tmp;
    	if (x <= 3.5) {
    		tmp = 0.5 + (-0.041666666666666664 * (x * x));
    	} else {
    		tmp = 0.0;
    	}
    	return tmp;
    }
    
    real(8) function code(x)
        real(8), intent (in) :: x
        real(8) :: tmp
        if (x <= 3.5d0) then
            tmp = 0.5d0 + ((-0.041666666666666664d0) * (x * x))
        else
            tmp = 0.0d0
        end if
        code = tmp
    end function
    
    public static double code(double x) {
    	double tmp;
    	if (x <= 3.5) {
    		tmp = 0.5 + (-0.041666666666666664 * (x * x));
    	} else {
    		tmp = 0.0;
    	}
    	return tmp;
    }
    
    def code(x):
    	tmp = 0
    	if x <= 3.5:
    		tmp = 0.5 + (-0.041666666666666664 * (x * x))
    	else:
    		tmp = 0.0
    	return tmp
    
    function code(x)
    	tmp = 0.0
    	if (x <= 3.5)
    		tmp = Float64(0.5 + Float64(-0.041666666666666664 * Float64(x * x)));
    	else
    		tmp = 0.0;
    	end
    	return tmp
    end
    
    function tmp_2 = code(x)
    	tmp = 0.0;
    	if (x <= 3.5)
    		tmp = 0.5 + (-0.041666666666666664 * (x * x));
    	else
    		tmp = 0.0;
    	end
    	tmp_2 = tmp;
    end
    
    code[x_] := If[LessEqual[x, 3.5], N[(0.5 + N[(-0.041666666666666664 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    \mathbf{if}\;x \leq 3.5:\\
    \;\;\;\;0.5 + -0.041666666666666664 \cdot \left(x \cdot x\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;0\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if x < 3.5

      1. Initial program 40.2%

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

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

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

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

          \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{24}, \left(x \cdot \color{blue}{x}\right)\right)\right) \]
        4. *-lowering-*.f6462.8%

          \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{24}, \mathsf{*.f64}\left(x, \color{blue}{x}\right)\right)\right) \]
      5. Simplified62.8%

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

      if 3.5 < x

      1. Initial program 98.8%

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

        \[\leadsto \color{blue}{\frac{1 - \cos x}{{x}^{2}}} \]
      4. Step-by-step derivation
        1. unpow2N/A

          \[\leadsto \frac{1 - \cos x}{x \cdot \color{blue}{x}} \]
        2. associate-/r*N/A

          \[\leadsto \frac{\frac{1 - \cos x}{x}}{\color{blue}{x}} \]
        3. /-lowering-/.f64N/A

          \[\leadsto \mathsf{/.f64}\left(\left(\frac{1 - \cos x}{x}\right), \color{blue}{x}\right) \]
        4. /-lowering-/.f64N/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\left(1 - \cos x\right), x\right), x\right) \]
        5. --lowering--.f64N/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \cos x\right), x\right), x\right) \]
        6. cos-lowering-cos.f6499.4%

          \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{cos.f64}\left(x\right)\right), x\right), x\right) \]
      5. Simplified99.4%

        \[\leadsto \color{blue}{\frac{\frac{1 - \cos x}{x}}{x}} \]
      6. Taylor expanded in x around 0

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \color{blue}{1}\right), x\right), x\right) \]
      7. Step-by-step derivation
        1. Simplified50.4%

          \[\leadsto \frac{\frac{1 - \color{blue}{1}}{x}}{x} \]
        2. Step-by-step derivation
          1. metadata-evalN/A

            \[\leadsto \frac{\frac{0}{x}}{x} \]
          2. div0N/A

            \[\leadsto \frac{0}{x} \]
          3. div050.4%

            \[\leadsto 0 \]
        3. Applied egg-rr50.4%

          \[\leadsto \color{blue}{0} \]
      8. Recombined 2 regimes into one program.
      9. Add Preprocessing

      Alternative 8: 78.7% accurate, 11.9× speedup?

      \[\begin{array}{l} \\ \frac{-1}{-2 + x \cdot \left(x \cdot -0.16666666666666666\right)} \end{array} \]
      (FPCore (x)
       :precision binary64
       (/ -1.0 (+ -2.0 (* x (* x -0.16666666666666666)))))
      double code(double x) {
      	return -1.0 / (-2.0 + (x * (x * -0.16666666666666666)));
      }
      
      real(8) function code(x)
          real(8), intent (in) :: x
          code = (-1.0d0) / ((-2.0d0) + (x * (x * (-0.16666666666666666d0))))
      end function
      
      public static double code(double x) {
      	return -1.0 / (-2.0 + (x * (x * -0.16666666666666666)));
      }
      
      def code(x):
      	return -1.0 / (-2.0 + (x * (x * -0.16666666666666666)))
      
      function code(x)
      	return Float64(-1.0 / Float64(-2.0 + Float64(x * Float64(x * -0.16666666666666666))))
      end
      
      function tmp = code(x)
      	tmp = -1.0 / (-2.0 + (x * (x * -0.16666666666666666)));
      end
      
      code[x_] := N[(-1.0 / N[(-2.0 + N[(x * N[(x * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
      
      \begin{array}{l}
      
      \\
      \frac{-1}{-2 + x \cdot \left(x \cdot -0.16666666666666666\right)}
      \end{array}
      
      Derivation
      1. Initial program 55.1%

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

        \[\leadsto \color{blue}{\frac{1 - \cos x}{{x}^{2}}} \]
      4. Step-by-step derivation
        1. unpow2N/A

          \[\leadsto \frac{1 - \cos x}{x \cdot \color{blue}{x}} \]
        2. associate-/r*N/A

          \[\leadsto \frac{\frac{1 - \cos x}{x}}{\color{blue}{x}} \]
        3. /-lowering-/.f64N/A

          \[\leadsto \mathsf{/.f64}\left(\left(\frac{1 - \cos x}{x}\right), \color{blue}{x}\right) \]
        4. /-lowering-/.f64N/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\left(1 - \cos x\right), x\right), x\right) \]
        5. --lowering--.f64N/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \cos x\right), x\right), x\right) \]
        6. cos-lowering-cos.f6456.1%

          \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{cos.f64}\left(x\right)\right), x\right), x\right) \]
      5. Simplified56.1%

        \[\leadsto \color{blue}{\frac{\frac{1 - \cos x}{x}}{x}} \]
      6. Step-by-step derivation
        1. clear-numN/A

          \[\leadsto \frac{1}{\color{blue}{\frac{x}{\frac{1 - \cos x}{x}}}} \]
        2. frac-2negN/A

          \[\leadsto \frac{\mathsf{neg}\left(1\right)}{\color{blue}{\mathsf{neg}\left(\frac{x}{\frac{1 - \cos x}{x}}\right)}} \]
        3. metadata-evalN/A

          \[\leadsto \frac{-1}{\mathsf{neg}\left(\color{blue}{\frac{x}{\frac{1 - \cos x}{x}}}\right)} \]
        4. /-lowering-/.f64N/A

          \[\leadsto \mathsf{/.f64}\left(-1, \color{blue}{\left(\mathsf{neg}\left(\frac{x}{\frac{1 - \cos x}{x}}\right)\right)}\right) \]
        5. div-invN/A

          \[\leadsto \mathsf{/.f64}\left(-1, \left(\mathsf{neg}\left(x \cdot \frac{1}{\frac{1 - \cos x}{x}}\right)\right)\right) \]
        6. clear-numN/A

          \[\leadsto \mathsf{/.f64}\left(-1, \left(\mathsf{neg}\left(x \cdot \frac{x}{1 - \cos x}\right)\right)\right) \]
        7. distribute-rgt-neg-inN/A

          \[\leadsto \mathsf{/.f64}\left(-1, \left(x \cdot \color{blue}{\left(\mathsf{neg}\left(\frac{x}{1 - \cos x}\right)\right)}\right)\right) \]
        8. *-lowering-*.f64N/A

          \[\leadsto \mathsf{/.f64}\left(-1, \mathsf{*.f64}\left(x, \color{blue}{\left(\mathsf{neg}\left(\frac{x}{1 - \cos x}\right)\right)}\right)\right) \]
        9. distribute-frac-neg2N/A

          \[\leadsto \mathsf{/.f64}\left(-1, \mathsf{*.f64}\left(x, \left(\frac{x}{\color{blue}{\mathsf{neg}\left(\left(1 - \cos x\right)\right)}}\right)\right)\right) \]
        10. /-lowering-/.f64N/A

          \[\leadsto \mathsf{/.f64}\left(-1, \mathsf{*.f64}\left(x, \mathsf{/.f64}\left(x, \color{blue}{\left(\mathsf{neg}\left(\left(1 - \cos x\right)\right)\right)}\right)\right)\right) \]
        11. sub-negN/A

          \[\leadsto \mathsf{/.f64}\left(-1, \mathsf{*.f64}\left(x, \mathsf{/.f64}\left(x, \left(\mathsf{neg}\left(\left(1 + \left(\mathsf{neg}\left(\cos x\right)\right)\right)\right)\right)\right)\right)\right) \]
        12. +-commutativeN/A

          \[\leadsto \mathsf{/.f64}\left(-1, \mathsf{*.f64}\left(x, \mathsf{/.f64}\left(x, \left(\mathsf{neg}\left(\left(\left(\mathsf{neg}\left(\cos x\right)\right) + 1\right)\right)\right)\right)\right)\right) \]
        13. distribute-neg-inN/A

          \[\leadsto \mathsf{/.f64}\left(-1, \mathsf{*.f64}\left(x, \mathsf{/.f64}\left(x, \left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\cos x\right)\right)\right)\right) + \color{blue}{\left(\mathsf{neg}\left(1\right)\right)}\right)\right)\right)\right) \]
        14. remove-double-negN/A

          \[\leadsto \mathsf{/.f64}\left(-1, \mathsf{*.f64}\left(x, \mathsf{/.f64}\left(x, \left(\cos x + \left(\mathsf{neg}\left(\color{blue}{1}\right)\right)\right)\right)\right)\right) \]
        15. metadata-evalN/A

          \[\leadsto \mathsf{/.f64}\left(-1, \mathsf{*.f64}\left(x, \mathsf{/.f64}\left(x, \left(\cos x + -1\right)\right)\right)\right) \]
        16. +-lowering-+.f64N/A

          \[\leadsto \mathsf{/.f64}\left(-1, \mathsf{*.f64}\left(x, \mathsf{/.f64}\left(x, \mathsf{+.f64}\left(\cos x, \color{blue}{-1}\right)\right)\right)\right) \]
        17. cos-lowering-cos.f6455.5%

          \[\leadsto \mathsf{/.f64}\left(-1, \mathsf{*.f64}\left(x, \mathsf{/.f64}\left(x, \mathsf{+.f64}\left(\mathsf{cos.f64}\left(x\right), -1\right)\right)\right)\right) \]
      7. Applied egg-rr55.5%

        \[\leadsto \color{blue}{\frac{-1}{x \cdot \frac{x}{\cos x + -1}}} \]
      8. Taylor expanded in x around 0

        \[\leadsto \mathsf{/.f64}\left(-1, \color{blue}{\left(\frac{-1}{6} \cdot {x}^{2} - 2\right)}\right) \]
      9. Step-by-step derivation
        1. sub-negN/A

          \[\leadsto \mathsf{/.f64}\left(-1, \left(\frac{-1}{6} \cdot {x}^{2} + \color{blue}{\left(\mathsf{neg}\left(2\right)\right)}\right)\right) \]
        2. metadata-evalN/A

          \[\leadsto \mathsf{/.f64}\left(-1, \left(\frac{-1}{6} \cdot {x}^{2} + -2\right)\right) \]
        3. +-commutativeN/A

          \[\leadsto \mathsf{/.f64}\left(-1, \left(-2 + \color{blue}{\frac{-1}{6} \cdot {x}^{2}}\right)\right) \]
        4. +-lowering-+.f64N/A

          \[\leadsto \mathsf{/.f64}\left(-1, \mathsf{+.f64}\left(-2, \color{blue}{\left(\frac{-1}{6} \cdot {x}^{2}\right)}\right)\right) \]
        5. unpow2N/A

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

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

          \[\leadsto \mathsf{/.f64}\left(-1, \mathsf{+.f64}\left(-2, \left(x \cdot \color{blue}{\left(\frac{-1}{6} \cdot x\right)}\right)\right)\right) \]
        8. *-lowering-*.f64N/A

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

          \[\leadsto \mathsf{/.f64}\left(-1, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(x, \left(x \cdot \color{blue}{\frac{-1}{6}}\right)\right)\right)\right) \]
        10. *-lowering-*.f6475.6%

          \[\leadsto \mathsf{/.f64}\left(-1, \mathsf{+.f64}\left(-2, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \color{blue}{\frac{-1}{6}}\right)\right)\right)\right) \]
      10. Simplified75.6%

        \[\leadsto \frac{-1}{\color{blue}{-2 + x \cdot \left(x \cdot -0.16666666666666666\right)}} \]
      11. Add Preprocessing

      Alternative 9: 63.9% accurate, 17.8× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 8 \cdot 10^{+76}:\\ \;\;\;\;0.5\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \end{array} \]
      (FPCore (x) :precision binary64 (if (<= x 8e+76) 0.5 0.0))
      double code(double x) {
      	double tmp;
      	if (x <= 8e+76) {
      		tmp = 0.5;
      	} else {
      		tmp = 0.0;
      	}
      	return tmp;
      }
      
      real(8) function code(x)
          real(8), intent (in) :: x
          real(8) :: tmp
          if (x <= 8d+76) then
              tmp = 0.5d0
          else
              tmp = 0.0d0
          end if
          code = tmp
      end function
      
      public static double code(double x) {
      	double tmp;
      	if (x <= 8e+76) {
      		tmp = 0.5;
      	} else {
      		tmp = 0.0;
      	}
      	return tmp;
      }
      
      def code(x):
      	tmp = 0
      	if x <= 8e+76:
      		tmp = 0.5
      	else:
      		tmp = 0.0
      	return tmp
      
      function code(x)
      	tmp = 0.0
      	if (x <= 8e+76)
      		tmp = 0.5;
      	else
      		tmp = 0.0;
      	end
      	return tmp
      end
      
      function tmp_2 = code(x)
      	tmp = 0.0;
      	if (x <= 8e+76)
      		tmp = 0.5;
      	else
      		tmp = 0.0;
      	end
      	tmp_2 = tmp;
      end
      
      code[x_] := If[LessEqual[x, 8e+76], 0.5, 0.0]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;x \leq 8 \cdot 10^{+76}:\\
      \;\;\;\;0.5\\
      
      \mathbf{else}:\\
      \;\;\;\;0\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if x < 8.0000000000000004e76

        1. Initial program 45.0%

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

          \[\leadsto \color{blue}{\frac{1}{2}} \]
        4. Step-by-step derivation
          1. Simplified58.2%

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

          if 8.0000000000000004e76 < x

          1. Initial program 98.5%

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

            \[\leadsto \color{blue}{\frac{1 - \cos x}{{x}^{2}}} \]
          4. Step-by-step derivation
            1. unpow2N/A

              \[\leadsto \frac{1 - \cos x}{x \cdot \color{blue}{x}} \]
            2. associate-/r*N/A

              \[\leadsto \frac{\frac{1 - \cos x}{x}}{\color{blue}{x}} \]
            3. /-lowering-/.f64N/A

              \[\leadsto \mathsf{/.f64}\left(\left(\frac{1 - \cos x}{x}\right), \color{blue}{x}\right) \]
            4. /-lowering-/.f64N/A

              \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\left(1 - \cos x\right), x\right), x\right) \]
            5. --lowering--.f64N/A

              \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \cos x\right), x\right), x\right) \]
            6. cos-lowering-cos.f6499.4%

              \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{cos.f64}\left(x\right)\right), x\right), x\right) \]
          5. Simplified99.4%

            \[\leadsto \color{blue}{\frac{\frac{1 - \cos x}{x}}{x}} \]
          6. Taylor expanded in x around 0

            \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \color{blue}{1}\right), x\right), x\right) \]
          7. Step-by-step derivation
            1. Simplified66.9%

              \[\leadsto \frac{\frac{1 - \color{blue}{1}}{x}}{x} \]
            2. Step-by-step derivation
              1. metadata-evalN/A

                \[\leadsto \frac{\frac{0}{x}}{x} \]
              2. div0N/A

                \[\leadsto \frac{0}{x} \]
              3. div066.9%

                \[\leadsto 0 \]
            3. Applied egg-rr66.9%

              \[\leadsto \color{blue}{0} \]
          8. Recombined 2 regimes into one program.
          9. Add Preprocessing

          Alternative 10: 27.2% accurate, 107.0× speedup?

          \[\begin{array}{l} \\ 0 \end{array} \]
          (FPCore (x) :precision binary64 0.0)
          double code(double x) {
          	return 0.0;
          }
          
          real(8) function code(x)
              real(8), intent (in) :: x
              code = 0.0d0
          end function
          
          public static double code(double x) {
          	return 0.0;
          }
          
          def code(x):
          	return 0.0
          
          function code(x)
          	return 0.0
          end
          
          function tmp = code(x)
          	tmp = 0.0;
          end
          
          code[x_] := 0.0
          
          \begin{array}{l}
          
          \\
          0
          \end{array}
          
          Derivation
          1. Initial program 55.1%

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

            \[\leadsto \color{blue}{\frac{1 - \cos x}{{x}^{2}}} \]
          4. Step-by-step derivation
            1. unpow2N/A

              \[\leadsto \frac{1 - \cos x}{x \cdot \color{blue}{x}} \]
            2. associate-/r*N/A

              \[\leadsto \frac{\frac{1 - \cos x}{x}}{\color{blue}{x}} \]
            3. /-lowering-/.f64N/A

              \[\leadsto \mathsf{/.f64}\left(\left(\frac{1 - \cos x}{x}\right), \color{blue}{x}\right) \]
            4. /-lowering-/.f64N/A

              \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\left(1 - \cos x\right), x\right), x\right) \]
            5. --lowering--.f64N/A

              \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \cos x\right), x\right), x\right) \]
            6. cos-lowering-cos.f6456.1%

              \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{cos.f64}\left(x\right)\right), x\right), x\right) \]
          5. Simplified56.1%

            \[\leadsto \color{blue}{\frac{\frac{1 - \cos x}{x}}{x}} \]
          6. Taylor expanded in x around 0

            \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \color{blue}{1}\right), x\right), x\right) \]
          7. Step-by-step derivation
            1. Simplified27.8%

              \[\leadsto \frac{\frac{1 - \color{blue}{1}}{x}}{x} \]
            2. Step-by-step derivation
              1. metadata-evalN/A

                \[\leadsto \frac{\frac{0}{x}}{x} \]
              2. div0N/A

                \[\leadsto \frac{0}{x} \]
              3. div027.8%

                \[\leadsto 0 \]
            3. Applied egg-rr27.8%

              \[\leadsto \color{blue}{0} \]
            4. Add Preprocessing

            Reproduce

            ?
            herbie shell --seed 2024140 
            (FPCore (x)
              :name "cos2 (problem 3.4.1)"
              :precision binary64
              (/ (- 1.0 (cos x)) (* x x)))