cos2 (problem 3.4.1)

Percentage Accurate: 50.1% → 99.6%
Time: 4.4s
Alternatives: 13
Speedup: 41.8×

Specification

?
\[\frac{1 - \cos x}{x \cdot x} \]
(FPCore (x) :precision binary64 (/ (- 1.0 (cos x)) (* x x)))
double code(double x) {
	return (1.0 - cos(x)) / (x * x);
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x)
use fmin_fmax_functions
    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]
\frac{1 - \cos x}{x \cdot x}

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 13 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?

\[\frac{1 - \cos x}{x \cdot x} \]
(FPCore (x) :precision binary64 (/ (- 1.0 (cos x)) (* x x)))
double code(double x) {
	return (1.0 - cos(x)) / (x * x);
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x)
use fmin_fmax_functions
    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]
\frac{1 - \cos x}{x \cdot x}

Alternative 1: 99.6% accurate, 0.7× speedup?

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

\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\cos \left(\left|x\right|\right), \frac{-1}{\left|x\right|}, \frac{1}{\left|x\right|}\right)}{\left|x\right|}\\


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

    1. Initial program 50.1%

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

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

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

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

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

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

        \[\leadsto \frac{1}{2} + {x}^{2} \cdot \left(\frac{1}{720} \cdot {x}^{2} - \frac{1}{24}\right) \]
      6. lower-pow.f6451.8%

        \[\leadsto 0.5 + {x}^{2} \cdot \left(0.001388888888888889 \cdot {x}^{2} - 0.041666666666666664\right) \]
    4. Applied rewrites51.8%

      \[\leadsto \color{blue}{0.5 + {x}^{2} \cdot \left(0.001388888888888889 \cdot {x}^{2} - 0.041666666666666664\right)} \]
    5. Step-by-step derivation
      1. lift-+.f64N/A

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

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

        \[\leadsto {x}^{2} \cdot \left(\frac{1}{720} \cdot {x}^{2} - \frac{1}{24}\right) + \frac{1}{2} \]
      4. lift-pow.f64N/A

        \[\leadsto {x}^{2} \cdot \left(\frac{1}{720} \cdot {x}^{2} - \frac{1}{24}\right) + \frac{1}{2} \]
      5. pow2N/A

        \[\leadsto \left(x \cdot x\right) \cdot \left(\frac{1}{720} \cdot {x}^{2} - \frac{1}{24}\right) + \frac{1}{2} \]
      6. lift-*.f64N/A

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

        \[\leadsto \left(\frac{1}{720} \cdot {x}^{2} - \frac{1}{24}\right) \cdot \left(x \cdot x\right) + \frac{1}{2} \]
      8. lower-fma.f6451.8%

        \[\leadsto \mathsf{fma}\left(0.001388888888888889 \cdot {x}^{2} - 0.041666666666666664, \color{blue}{x \cdot x}, 0.5\right) \]
      9. lift--.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{1}{720} \cdot {x}^{2} - \frac{1}{24}, \color{blue}{x} \cdot x, \frac{1}{2}\right) \]
      10. sub-flipN/A

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

        \[\leadsto \mathsf{fma}\left(\frac{1}{720} \cdot {x}^{2} + \left(\mathsf{neg}\left(\frac{1}{24}\right)\right), x \cdot x, \frac{1}{2}\right) \]
      12. lift-pow.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{1}{720} \cdot {x}^{2} + \left(\mathsf{neg}\left(\frac{1}{24}\right)\right), x \cdot x, \frac{1}{2}\right) \]
      13. pow2N/A

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

        \[\leadsto \mathsf{fma}\left(\left(\frac{1}{720} \cdot x\right) \cdot x + \left(\mathsf{neg}\left(\frac{1}{24}\right)\right), x \cdot x, \frac{1}{2}\right) \]
      15. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{720} \cdot x, x, \mathsf{neg}\left(\frac{1}{24}\right)\right), \color{blue}{x} \cdot x, \frac{1}{2}\right) \]
      16. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{720} \cdot x, x, \mathsf{neg}\left(\frac{1}{24}\right)\right), x \cdot x, \frac{1}{2}\right) \]
      17. metadata-eval51.8%

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(0.001388888888888889 \cdot x, x, -0.041666666666666664\right), x \cdot x, 0.5\right) \]
    6. Applied rewrites51.8%

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

    if 0.0027000000000000001 < x

    1. Initial program 50.1%

      \[\frac{1 - \cos x}{x \cdot x} \]
    2. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{1 - \cos x}{x \cdot x}} \]
      2. lift-*.f64N/A

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

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

        \[\leadsto \color{blue}{\frac{\frac{1 - \cos x}{x}}{x}} \]
      5. lower-/.f6451.3%

        \[\leadsto \frac{\color{blue}{\frac{1 - \cos x}{x}}}{x} \]
    3. Applied rewrites51.3%

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

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

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

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

        \[\leadsto \frac{\frac{\mathsf{neg}\left(\color{blue}{\left(1 - \cos x\right)}\right)}{-x}}{x} \]
      5. sub-negate-revN/A

        \[\leadsto \frac{\frac{\color{blue}{\cos x - 1}}{-x}}{x} \]
      6. sub-flipN/A

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

        \[\leadsto \frac{\frac{\cos x + \color{blue}{-1}}{-x}}{x} \]
      8. div-addN/A

        \[\leadsto \frac{\color{blue}{\frac{\cos x}{-x} + \frac{-1}{-x}}}{x} \]
      9. mult-flipN/A

        \[\leadsto \frac{\color{blue}{\cos x \cdot \frac{1}{-x}} + \frac{-1}{-x}}{x} \]
      10. metadata-evalN/A

        \[\leadsto \frac{\cos x \cdot \frac{1}{-x} + \frac{\color{blue}{\mathsf{neg}\left(1\right)}}{-x}}{x} \]
      11. lift-neg.f64N/A

        \[\leadsto \frac{\cos x \cdot \frac{1}{-x} + \frac{\mathsf{neg}\left(1\right)}{\color{blue}{\mathsf{neg}\left(x\right)}}}{x} \]
      12. frac-2negN/A

        \[\leadsto \frac{\cos x \cdot \frac{1}{-x} + \color{blue}{\frac{1}{x}}}{x} \]
      13. lower-fma.f64N/A

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

        \[\leadsto \frac{\mathsf{fma}\left(\cos x, \frac{\color{blue}{\mathsf{neg}\left(-1\right)}}{-x}, \frac{1}{x}\right)}{x} \]
      15. lift-neg.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(\cos x, \frac{\mathsf{neg}\left(-1\right)}{\color{blue}{\mathsf{neg}\left(x\right)}}, \frac{1}{x}\right)}{x} \]
      16. frac-2neg-revN/A

        \[\leadsto \frac{\mathsf{fma}\left(\cos x, \color{blue}{\frac{-1}{x}}, \frac{1}{x}\right)}{x} \]
      17. lower-/.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(\cos x, \color{blue}{\frac{-1}{x}}, \frac{1}{x}\right)}{x} \]
      18. lower-/.f6451.3%

        \[\leadsto \frac{\mathsf{fma}\left(\cos x, \frac{-1}{x}, \color{blue}{\frac{1}{x}}\right)}{x} \]
    5. Applied rewrites51.3%

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

Alternative 2: 99.6% accurate, 0.8× speedup?

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

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


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

    1. Initial program 50.1%

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

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

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

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

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

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

        \[\leadsto \frac{1}{2} + {x}^{2} \cdot \left(\frac{1}{720} \cdot {x}^{2} - \frac{1}{24}\right) \]
      6. lower-pow.f6451.8%

        \[\leadsto 0.5 + {x}^{2} \cdot \left(0.001388888888888889 \cdot {x}^{2} - 0.041666666666666664\right) \]
    4. Applied rewrites51.8%

      \[\leadsto \color{blue}{0.5 + {x}^{2} \cdot \left(0.001388888888888889 \cdot {x}^{2} - 0.041666666666666664\right)} \]
    5. Step-by-step derivation
      1. lift-+.f64N/A

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

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

        \[\leadsto {x}^{2} \cdot \left(\frac{1}{720} \cdot {x}^{2} - \frac{1}{24}\right) + \frac{1}{2} \]
      4. lift-pow.f64N/A

        \[\leadsto {x}^{2} \cdot \left(\frac{1}{720} \cdot {x}^{2} - \frac{1}{24}\right) + \frac{1}{2} \]
      5. pow2N/A

        \[\leadsto \left(x \cdot x\right) \cdot \left(\frac{1}{720} \cdot {x}^{2} - \frac{1}{24}\right) + \frac{1}{2} \]
      6. lift-*.f64N/A

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

        \[\leadsto \left(\frac{1}{720} \cdot {x}^{2} - \frac{1}{24}\right) \cdot \left(x \cdot x\right) + \frac{1}{2} \]
      8. lower-fma.f6451.8%

        \[\leadsto \mathsf{fma}\left(0.001388888888888889 \cdot {x}^{2} - 0.041666666666666664, \color{blue}{x \cdot x}, 0.5\right) \]
      9. lift--.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{1}{720} \cdot {x}^{2} - \frac{1}{24}, \color{blue}{x} \cdot x, \frac{1}{2}\right) \]
      10. sub-flipN/A

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

        \[\leadsto \mathsf{fma}\left(\frac{1}{720} \cdot {x}^{2} + \left(\mathsf{neg}\left(\frac{1}{24}\right)\right), x \cdot x, \frac{1}{2}\right) \]
      12. lift-pow.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{1}{720} \cdot {x}^{2} + \left(\mathsf{neg}\left(\frac{1}{24}\right)\right), x \cdot x, \frac{1}{2}\right) \]
      13. pow2N/A

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

        \[\leadsto \mathsf{fma}\left(\left(\frac{1}{720} \cdot x\right) \cdot x + \left(\mathsf{neg}\left(\frac{1}{24}\right)\right), x \cdot x, \frac{1}{2}\right) \]
      15. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{720} \cdot x, x, \mathsf{neg}\left(\frac{1}{24}\right)\right), \color{blue}{x} \cdot x, \frac{1}{2}\right) \]
      16. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{720} \cdot x, x, \mathsf{neg}\left(\frac{1}{24}\right)\right), x \cdot x, \frac{1}{2}\right) \]
      17. metadata-eval51.8%

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(0.001388888888888889 \cdot x, x, -0.041666666666666664\right), x \cdot x, 0.5\right) \]
    6. Applied rewrites51.8%

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

    if 0.0027000000000000001 < x

    1. Initial program 50.1%

      \[\frac{1 - \cos x}{x \cdot x} \]
    2. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{1 - \cos x}{x \cdot x}} \]
      2. lift-*.f64N/A

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

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

        \[\leadsto \color{blue}{\frac{\frac{1 - \cos x}{x}}{x}} \]
      5. lower-/.f6451.3%

        \[\leadsto \frac{\color{blue}{\frac{1 - \cos x}{x}}}{x} \]
    3. Applied rewrites51.3%

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

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

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

        \[\leadsto \frac{\color{blue}{\frac{1}{x} \cdot \left(1 - \cos x\right)}}{x} \]
      4. lower-*.f64N/A

        \[\leadsto \frac{\color{blue}{\frac{1}{x} \cdot \left(1 - \cos x\right)}}{x} \]
      5. lower-/.f6451.2%

        \[\leadsto \frac{\color{blue}{\frac{1}{x}} \cdot \left(1 - \cos x\right)}{x} \]
    5. Applied rewrites51.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: 99.6% accurate, 0.8× speedup?

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

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


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

    1. Initial program 50.1%

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

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

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

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

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

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

        \[\leadsto \frac{1}{2} + {x}^{2} \cdot \left(\frac{1}{720} \cdot {x}^{2} - \frac{1}{24}\right) \]
      6. lower-pow.f6451.8%

        \[\leadsto 0.5 + {x}^{2} \cdot \left(0.001388888888888889 \cdot {x}^{2} - 0.041666666666666664\right) \]
    4. Applied rewrites51.8%

      \[\leadsto \color{blue}{0.5 + {x}^{2} \cdot \left(0.001388888888888889 \cdot {x}^{2} - 0.041666666666666664\right)} \]
    5. Step-by-step derivation
      1. lift-+.f64N/A

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

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

        \[\leadsto {x}^{2} \cdot \left(\frac{1}{720} \cdot {x}^{2} - \frac{1}{24}\right) + \frac{1}{2} \]
      4. lift-pow.f64N/A

        \[\leadsto {x}^{2} \cdot \left(\frac{1}{720} \cdot {x}^{2} - \frac{1}{24}\right) + \frac{1}{2} \]
      5. pow2N/A

        \[\leadsto \left(x \cdot x\right) \cdot \left(\frac{1}{720} \cdot {x}^{2} - \frac{1}{24}\right) + \frac{1}{2} \]
      6. lift-*.f64N/A

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

        \[\leadsto \left(\frac{1}{720} \cdot {x}^{2} - \frac{1}{24}\right) \cdot \left(x \cdot x\right) + \frac{1}{2} \]
      8. lower-fma.f6451.8%

        \[\leadsto \mathsf{fma}\left(0.001388888888888889 \cdot {x}^{2} - 0.041666666666666664, \color{blue}{x \cdot x}, 0.5\right) \]
      9. lift--.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{1}{720} \cdot {x}^{2} - \frac{1}{24}, \color{blue}{x} \cdot x, \frac{1}{2}\right) \]
      10. sub-flipN/A

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

        \[\leadsto \mathsf{fma}\left(\frac{1}{720} \cdot {x}^{2} + \left(\mathsf{neg}\left(\frac{1}{24}\right)\right), x \cdot x, \frac{1}{2}\right) \]
      12. lift-pow.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{1}{720} \cdot {x}^{2} + \left(\mathsf{neg}\left(\frac{1}{24}\right)\right), x \cdot x, \frac{1}{2}\right) \]
      13. pow2N/A

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

        \[\leadsto \mathsf{fma}\left(\left(\frac{1}{720} \cdot x\right) \cdot x + \left(\mathsf{neg}\left(\frac{1}{24}\right)\right), x \cdot x, \frac{1}{2}\right) \]
      15. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{720} \cdot x, x, \mathsf{neg}\left(\frac{1}{24}\right)\right), \color{blue}{x} \cdot x, \frac{1}{2}\right) \]
      16. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{720} \cdot x, x, \mathsf{neg}\left(\frac{1}{24}\right)\right), x \cdot x, \frac{1}{2}\right) \]
      17. metadata-eval51.8%

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(0.001388888888888889 \cdot x, x, -0.041666666666666664\right), x \cdot x, 0.5\right) \]
    6. Applied rewrites51.8%

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

    if 0.0027000000000000001 < x

    1. Initial program 50.1%

      \[\frac{1 - \cos x}{x \cdot x} \]
    2. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{1 - \cos x}{x \cdot x}} \]
      2. lift-*.f64N/A

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

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

        \[\leadsto \color{blue}{\frac{\frac{1 - \cos x}{x}}{x}} \]
      5. lower-/.f6451.3%

        \[\leadsto \frac{\color{blue}{\frac{1 - \cos x}{x}}}{x} \]
    3. Applied rewrites51.3%

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

Alternative 4: 99.2% accurate, 0.8× speedup?

\[\begin{array}{l} t_0 := \left|x\right| \cdot \left|x\right|\\ \mathbf{if}\;\left|x\right| \leq 0.0027:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.001388888888888889 \cdot \left|x\right|, \left|x\right|, -0.041666666666666664\right), t\_0, 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1 - \cos \left(\left|x\right|\right)}{t\_0}\\ \end{array} \]
(FPCore (x)
 :precision binary64
 (let* ((t_0 (* (fabs x) (fabs x))))
   (if (<= (fabs x) 0.0027)
     (fma
      (fma (* 0.001388888888888889 (fabs x)) (fabs x) -0.041666666666666664)
      t_0
      0.5)
     (/ (- 1.0 (cos (fabs x))) t_0))))
double code(double x) {
	double t_0 = fabs(x) * fabs(x);
	double tmp;
	if (fabs(x) <= 0.0027) {
		tmp = fma(fma((0.001388888888888889 * fabs(x)), fabs(x), -0.041666666666666664), t_0, 0.5);
	} else {
		tmp = (1.0 - cos(fabs(x))) / t_0;
	}
	return tmp;
}
function code(x)
	t_0 = Float64(abs(x) * abs(x))
	tmp = 0.0
	if (abs(x) <= 0.0027)
		tmp = fma(fma(Float64(0.001388888888888889 * abs(x)), abs(x), -0.041666666666666664), t_0, 0.5);
	else
		tmp = Float64(Float64(1.0 - cos(abs(x))) / t_0);
	end
	return tmp
end
code[x_] := Block[{t$95$0 = N[(N[Abs[x], $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Abs[x], $MachinePrecision], 0.0027], N[(N[(N[(0.001388888888888889 * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision] + -0.041666666666666664), $MachinePrecision] * t$95$0 + 0.5), $MachinePrecision], N[(N[(1.0 - N[Cos[N[Abs[x], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision]]]
\begin{array}{l}
t_0 := \left|x\right| \cdot \left|x\right|\\
\mathbf{if}\;\left|x\right| \leq 0.0027:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.001388888888888889 \cdot \left|x\right|, \left|x\right|, -0.041666666666666664\right), t\_0, 0.5\right)\\

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


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

    1. Initial program 50.1%

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

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

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

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

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

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

        \[\leadsto \frac{1}{2} + {x}^{2} \cdot \left(\frac{1}{720} \cdot {x}^{2} - \frac{1}{24}\right) \]
      6. lower-pow.f6451.8%

        \[\leadsto 0.5 + {x}^{2} \cdot \left(0.001388888888888889 \cdot {x}^{2} - 0.041666666666666664\right) \]
    4. Applied rewrites51.8%

      \[\leadsto \color{blue}{0.5 + {x}^{2} \cdot \left(0.001388888888888889 \cdot {x}^{2} - 0.041666666666666664\right)} \]
    5. Step-by-step derivation
      1. lift-+.f64N/A

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

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

        \[\leadsto {x}^{2} \cdot \left(\frac{1}{720} \cdot {x}^{2} - \frac{1}{24}\right) + \frac{1}{2} \]
      4. lift-pow.f64N/A

        \[\leadsto {x}^{2} \cdot \left(\frac{1}{720} \cdot {x}^{2} - \frac{1}{24}\right) + \frac{1}{2} \]
      5. pow2N/A

        \[\leadsto \left(x \cdot x\right) \cdot \left(\frac{1}{720} \cdot {x}^{2} - \frac{1}{24}\right) + \frac{1}{2} \]
      6. lift-*.f64N/A

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

        \[\leadsto \left(\frac{1}{720} \cdot {x}^{2} - \frac{1}{24}\right) \cdot \left(x \cdot x\right) + \frac{1}{2} \]
      8. lower-fma.f6451.8%

        \[\leadsto \mathsf{fma}\left(0.001388888888888889 \cdot {x}^{2} - 0.041666666666666664, \color{blue}{x \cdot x}, 0.5\right) \]
      9. lift--.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{1}{720} \cdot {x}^{2} - \frac{1}{24}, \color{blue}{x} \cdot x, \frac{1}{2}\right) \]
      10. sub-flipN/A

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

        \[\leadsto \mathsf{fma}\left(\frac{1}{720} \cdot {x}^{2} + \left(\mathsf{neg}\left(\frac{1}{24}\right)\right), x \cdot x, \frac{1}{2}\right) \]
      12. lift-pow.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{1}{720} \cdot {x}^{2} + \left(\mathsf{neg}\left(\frac{1}{24}\right)\right), x \cdot x, \frac{1}{2}\right) \]
      13. pow2N/A

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

        \[\leadsto \mathsf{fma}\left(\left(\frac{1}{720} \cdot x\right) \cdot x + \left(\mathsf{neg}\left(\frac{1}{24}\right)\right), x \cdot x, \frac{1}{2}\right) \]
      15. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{720} \cdot x, x, \mathsf{neg}\left(\frac{1}{24}\right)\right), \color{blue}{x} \cdot x, \frac{1}{2}\right) \]
      16. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{720} \cdot x, x, \mathsf{neg}\left(\frac{1}{24}\right)\right), x \cdot x, \frac{1}{2}\right) \]
      17. metadata-eval51.8%

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(0.001388888888888889 \cdot x, x, -0.041666666666666664\right), x \cdot x, 0.5\right) \]
    6. Applied rewrites51.8%

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

    if 0.0027000000000000001 < x

    1. Initial program 50.1%

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

Alternative 5: 77.3% accurate, 1.1× speedup?

\[\begin{array}{l} t_0 := \left|x\right| \cdot \left|x\right|\\ t_1 := \frac{1}{\left|x\right|}\\ \mathbf{if}\;\left|x\right| \leq 7.8 \cdot 10^{+15}:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.001388888888888889 \cdot \left|x\right|, \left|x\right|, -0.041666666666666664\right), t\_0, 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(t\_1, t\_1, \frac{\left(-\left|x\right|\right) \cdot 1}{t\_0 \cdot \left|x\right|}\right)\\ \end{array} \]
(FPCore (x)
 :precision binary64
 (let* ((t_0 (* (fabs x) (fabs x))) (t_1 (/ 1.0 (fabs x))))
   (if (<= (fabs x) 7.8e+15)
     (fma
      (fma (* 0.001388888888888889 (fabs x)) (fabs x) -0.041666666666666664)
      t_0
      0.5)
     (fma t_1 t_1 (/ (* (- (fabs x)) 1.0) (* t_0 (fabs x)))))))
double code(double x) {
	double t_0 = fabs(x) * fabs(x);
	double t_1 = 1.0 / fabs(x);
	double tmp;
	if (fabs(x) <= 7.8e+15) {
		tmp = fma(fma((0.001388888888888889 * fabs(x)), fabs(x), -0.041666666666666664), t_0, 0.5);
	} else {
		tmp = fma(t_1, t_1, ((-fabs(x) * 1.0) / (t_0 * fabs(x))));
	}
	return tmp;
}
function code(x)
	t_0 = Float64(abs(x) * abs(x))
	t_1 = Float64(1.0 / abs(x))
	tmp = 0.0
	if (abs(x) <= 7.8e+15)
		tmp = fma(fma(Float64(0.001388888888888889 * abs(x)), abs(x), -0.041666666666666664), t_0, 0.5);
	else
		tmp = fma(t_1, t_1, Float64(Float64(Float64(-abs(x)) * 1.0) / Float64(t_0 * abs(x))));
	end
	return tmp
end
code[x_] := Block[{t$95$0 = N[(N[Abs[x], $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 / N[Abs[x], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Abs[x], $MachinePrecision], 7.8e+15], N[(N[(N[(0.001388888888888889 * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision] + -0.041666666666666664), $MachinePrecision] * t$95$0 + 0.5), $MachinePrecision], N[(t$95$1 * t$95$1 + N[(N[((-N[Abs[x], $MachinePrecision]) * 1.0), $MachinePrecision] / N[(t$95$0 * N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
t_0 := \left|x\right| \cdot \left|x\right|\\
t_1 := \frac{1}{\left|x\right|}\\
\mathbf{if}\;\left|x\right| \leq 7.8 \cdot 10^{+15}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.001388888888888889 \cdot \left|x\right|, \left|x\right|, -0.041666666666666664\right), t\_0, 0.5\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t\_1, t\_1, \frac{\left(-\left|x\right|\right) \cdot 1}{t\_0 \cdot \left|x\right|}\right)\\


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

    1. Initial program 50.1%

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

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

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

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

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

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

        \[\leadsto \frac{1}{2} + {x}^{2} \cdot \left(\frac{1}{720} \cdot {x}^{2} - \frac{1}{24}\right) \]
      6. lower-pow.f6451.8%

        \[\leadsto 0.5 + {x}^{2} \cdot \left(0.001388888888888889 \cdot {x}^{2} - 0.041666666666666664\right) \]
    4. Applied rewrites51.8%

      \[\leadsto \color{blue}{0.5 + {x}^{2} \cdot \left(0.001388888888888889 \cdot {x}^{2} - 0.041666666666666664\right)} \]
    5. Step-by-step derivation
      1. lift-+.f64N/A

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

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

        \[\leadsto {x}^{2} \cdot \left(\frac{1}{720} \cdot {x}^{2} - \frac{1}{24}\right) + \frac{1}{2} \]
      4. lift-pow.f64N/A

        \[\leadsto {x}^{2} \cdot \left(\frac{1}{720} \cdot {x}^{2} - \frac{1}{24}\right) + \frac{1}{2} \]
      5. pow2N/A

        \[\leadsto \left(x \cdot x\right) \cdot \left(\frac{1}{720} \cdot {x}^{2} - \frac{1}{24}\right) + \frac{1}{2} \]
      6. lift-*.f64N/A

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

        \[\leadsto \left(\frac{1}{720} \cdot {x}^{2} - \frac{1}{24}\right) \cdot \left(x \cdot x\right) + \frac{1}{2} \]
      8. lower-fma.f6451.8%

        \[\leadsto \mathsf{fma}\left(0.001388888888888889 \cdot {x}^{2} - 0.041666666666666664, \color{blue}{x \cdot x}, 0.5\right) \]
      9. lift--.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{1}{720} \cdot {x}^{2} - \frac{1}{24}, \color{blue}{x} \cdot x, \frac{1}{2}\right) \]
      10. sub-flipN/A

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

        \[\leadsto \mathsf{fma}\left(\frac{1}{720} \cdot {x}^{2} + \left(\mathsf{neg}\left(\frac{1}{24}\right)\right), x \cdot x, \frac{1}{2}\right) \]
      12. lift-pow.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{1}{720} \cdot {x}^{2} + \left(\mathsf{neg}\left(\frac{1}{24}\right)\right), x \cdot x, \frac{1}{2}\right) \]
      13. pow2N/A

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

        \[\leadsto \mathsf{fma}\left(\left(\frac{1}{720} \cdot x\right) \cdot x + \left(\mathsf{neg}\left(\frac{1}{24}\right)\right), x \cdot x, \frac{1}{2}\right) \]
      15. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{720} \cdot x, x, \mathsf{neg}\left(\frac{1}{24}\right)\right), \color{blue}{x} \cdot x, \frac{1}{2}\right) \]
      16. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{720} \cdot x, x, \mathsf{neg}\left(\frac{1}{24}\right)\right), x \cdot x, \frac{1}{2}\right) \]
      17. metadata-eval51.8%

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(0.001388888888888889 \cdot x, x, -0.041666666666666664\right), x \cdot x, 0.5\right) \]
    6. Applied rewrites51.8%

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

    if 7.8e15 < x

    1. Initial program 50.1%

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

      \[\leadsto \frac{1 - \color{blue}{1}}{x \cdot x} \]
    3. Step-by-step derivation
      1. Applied rewrites26.2%

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

          \[\leadsto \color{blue}{\frac{1 - 1}{x \cdot x}} \]
        2. lift-*.f64N/A

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

          \[\leadsto \color{blue}{\frac{\frac{1 - 1}{x}}{x}} \]
        4. lift--.f64N/A

          \[\leadsto \frac{\frac{\color{blue}{1 - 1}}{x}}{x} \]
        5. div-subN/A

          \[\leadsto \frac{\color{blue}{\frac{1}{x} - \frac{1}{x}}}{x} \]
        6. sub-divN/A

          \[\leadsto \color{blue}{\frac{\frac{1}{x}}{x} - \frac{\frac{1}{x}}{x}} \]
        7. frac-subN/A

          \[\leadsto \color{blue}{\frac{\frac{1}{x} \cdot x - x \cdot \frac{1}{x}}{x \cdot x}} \]
        8. lift-*.f64N/A

          \[\leadsto \frac{\frac{1}{x} \cdot x - x \cdot \frac{1}{x}}{\color{blue}{x \cdot x}} \]
        9. lower-/.f64N/A

          \[\leadsto \color{blue}{\frac{\frac{1}{x} \cdot x - x \cdot \frac{1}{x}}{x \cdot x}} \]
        10. inv-powN/A

          \[\leadsto \frac{\color{blue}{{x}^{-1}} \cdot x - x \cdot \frac{1}{x}}{x \cdot x} \]
        11. pow-plusN/A

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

          \[\leadsto \frac{{x}^{\color{blue}{0}} - x \cdot \frac{1}{x}}{x \cdot x} \]
        13. metadata-evalN/A

          \[\leadsto \frac{\color{blue}{1} - x \cdot \frac{1}{x}}{x \cdot x} \]
        14. lower--.f64N/A

          \[\leadsto \frac{\color{blue}{1 - x \cdot \frac{1}{x}}}{x \cdot x} \]
        15. lower-*.f64N/A

          \[\leadsto \frac{1 - \color{blue}{x \cdot \frac{1}{x}}}{x \cdot x} \]
        16. lower-/.f6426.6%

          \[\leadsto \frac{1 - x \cdot \color{blue}{\frac{1}{x}}}{x \cdot x} \]
      3. Applied rewrites26.6%

        \[\leadsto \color{blue}{\frac{1 - x \cdot \frac{1}{x}}{x \cdot x}} \]
      4. Applied rewrites27.5%

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

    Alternative 6: 77.0% accurate, 1.2× speedup?

    \[\begin{array}{l} t_0 := \left|x\right| \cdot \left|x\right|\\ \mathbf{if}\;\left|x\right| \leq 4.2 \cdot 10^{+14}:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.001388888888888889 \cdot \left|x\right|, \left|x\right|, -0.041666666666666664\right), t\_0, 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{t\_0} + \frac{\left(-\left|x\right|\right) \cdot 1}{t\_0 \cdot \left|x\right|}\\ \end{array} \]
    (FPCore (x)
     :precision binary64
     (let* ((t_0 (* (fabs x) (fabs x))))
       (if (<= (fabs x) 4.2e+14)
         (fma
          (fma (* 0.001388888888888889 (fabs x)) (fabs x) -0.041666666666666664)
          t_0
          0.5)
         (+ (/ 1.0 t_0) (/ (* (- (fabs x)) 1.0) (* t_0 (fabs x)))))))
    double code(double x) {
    	double t_0 = fabs(x) * fabs(x);
    	double tmp;
    	if (fabs(x) <= 4.2e+14) {
    		tmp = fma(fma((0.001388888888888889 * fabs(x)), fabs(x), -0.041666666666666664), t_0, 0.5);
    	} else {
    		tmp = (1.0 / t_0) + ((-fabs(x) * 1.0) / (t_0 * fabs(x)));
    	}
    	return tmp;
    }
    
    function code(x)
    	t_0 = Float64(abs(x) * abs(x))
    	tmp = 0.0
    	if (abs(x) <= 4.2e+14)
    		tmp = fma(fma(Float64(0.001388888888888889 * abs(x)), abs(x), -0.041666666666666664), t_0, 0.5);
    	else
    		tmp = Float64(Float64(1.0 / t_0) + Float64(Float64(Float64(-abs(x)) * 1.0) / Float64(t_0 * abs(x))));
    	end
    	return tmp
    end
    
    code[x_] := Block[{t$95$0 = N[(N[Abs[x], $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Abs[x], $MachinePrecision], 4.2e+14], N[(N[(N[(0.001388888888888889 * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision] + -0.041666666666666664), $MachinePrecision] * t$95$0 + 0.5), $MachinePrecision], N[(N[(1.0 / t$95$0), $MachinePrecision] + N[(N[((-N[Abs[x], $MachinePrecision]) * 1.0), $MachinePrecision] / N[(t$95$0 * N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
    
    \begin{array}{l}
    t_0 := \left|x\right| \cdot \left|x\right|\\
    \mathbf{if}\;\left|x\right| \leq 4.2 \cdot 10^{+14}:\\
    \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.001388888888888889 \cdot \left|x\right|, \left|x\right|, -0.041666666666666664\right), t\_0, 0.5\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;\frac{1}{t\_0} + \frac{\left(-\left|x\right|\right) \cdot 1}{t\_0 \cdot \left|x\right|}\\
    
    
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if x < 4.2e14

      1. Initial program 50.1%

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

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

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

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

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

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

          \[\leadsto \frac{1}{2} + {x}^{2} \cdot \left(\frac{1}{720} \cdot {x}^{2} - \frac{1}{24}\right) \]
        6. lower-pow.f6451.8%

          \[\leadsto 0.5 + {x}^{2} \cdot \left(0.001388888888888889 \cdot {x}^{2} - 0.041666666666666664\right) \]
      4. Applied rewrites51.8%

        \[\leadsto \color{blue}{0.5 + {x}^{2} \cdot \left(0.001388888888888889 \cdot {x}^{2} - 0.041666666666666664\right)} \]
      5. Step-by-step derivation
        1. lift-+.f64N/A

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

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

          \[\leadsto {x}^{2} \cdot \left(\frac{1}{720} \cdot {x}^{2} - \frac{1}{24}\right) + \frac{1}{2} \]
        4. lift-pow.f64N/A

          \[\leadsto {x}^{2} \cdot \left(\frac{1}{720} \cdot {x}^{2} - \frac{1}{24}\right) + \frac{1}{2} \]
        5. pow2N/A

          \[\leadsto \left(x \cdot x\right) \cdot \left(\frac{1}{720} \cdot {x}^{2} - \frac{1}{24}\right) + \frac{1}{2} \]
        6. lift-*.f64N/A

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

          \[\leadsto \left(\frac{1}{720} \cdot {x}^{2} - \frac{1}{24}\right) \cdot \left(x \cdot x\right) + \frac{1}{2} \]
        8. lower-fma.f6451.8%

          \[\leadsto \mathsf{fma}\left(0.001388888888888889 \cdot {x}^{2} - 0.041666666666666664, \color{blue}{x \cdot x}, 0.5\right) \]
        9. lift--.f64N/A

          \[\leadsto \mathsf{fma}\left(\frac{1}{720} \cdot {x}^{2} - \frac{1}{24}, \color{blue}{x} \cdot x, \frac{1}{2}\right) \]
        10. sub-flipN/A

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

          \[\leadsto \mathsf{fma}\left(\frac{1}{720} \cdot {x}^{2} + \left(\mathsf{neg}\left(\frac{1}{24}\right)\right), x \cdot x, \frac{1}{2}\right) \]
        12. lift-pow.f64N/A

          \[\leadsto \mathsf{fma}\left(\frac{1}{720} \cdot {x}^{2} + \left(\mathsf{neg}\left(\frac{1}{24}\right)\right), x \cdot x, \frac{1}{2}\right) \]
        13. pow2N/A

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

          \[\leadsto \mathsf{fma}\left(\left(\frac{1}{720} \cdot x\right) \cdot x + \left(\mathsf{neg}\left(\frac{1}{24}\right)\right), x \cdot x, \frac{1}{2}\right) \]
        15. lower-fma.f64N/A

          \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{720} \cdot x, x, \mathsf{neg}\left(\frac{1}{24}\right)\right), \color{blue}{x} \cdot x, \frac{1}{2}\right) \]
        16. lower-*.f64N/A

          \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{720} \cdot x, x, \mathsf{neg}\left(\frac{1}{24}\right)\right), x \cdot x, \frac{1}{2}\right) \]
        17. metadata-eval51.8%

          \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(0.001388888888888889 \cdot x, x, -0.041666666666666664\right), x \cdot x, 0.5\right) \]
      6. Applied rewrites51.8%

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

      if 4.2e14 < x

      1. Initial program 50.1%

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

        \[\leadsto \frac{1 - \color{blue}{1}}{x \cdot x} \]
      3. Step-by-step derivation
        1. Applied rewrites26.2%

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

            \[\leadsto \color{blue}{\frac{1 - 1}{x \cdot x}} \]
          2. lift-*.f64N/A

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

            \[\leadsto \color{blue}{\frac{\frac{1 - 1}{x}}{x}} \]
          4. lift--.f64N/A

            \[\leadsto \frac{\frac{\color{blue}{1 - 1}}{x}}{x} \]
          5. div-subN/A

            \[\leadsto \frac{\color{blue}{\frac{1}{x} - \frac{1}{x}}}{x} \]
          6. sub-divN/A

            \[\leadsto \color{blue}{\frac{\frac{1}{x}}{x} - \frac{\frac{1}{x}}{x}} \]
          7. frac-subN/A

            \[\leadsto \color{blue}{\frac{\frac{1}{x} \cdot x - x \cdot \frac{1}{x}}{x \cdot x}} \]
          8. lift-*.f64N/A

            \[\leadsto \frac{\frac{1}{x} \cdot x - x \cdot \frac{1}{x}}{\color{blue}{x \cdot x}} \]
          9. lower-/.f64N/A

            \[\leadsto \color{blue}{\frac{\frac{1}{x} \cdot x - x \cdot \frac{1}{x}}{x \cdot x}} \]
          10. inv-powN/A

            \[\leadsto \frac{\color{blue}{{x}^{-1}} \cdot x - x \cdot \frac{1}{x}}{x \cdot x} \]
          11. pow-plusN/A

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

            \[\leadsto \frac{{x}^{\color{blue}{0}} - x \cdot \frac{1}{x}}{x \cdot x} \]
          13. metadata-evalN/A

            \[\leadsto \frac{\color{blue}{1} - x \cdot \frac{1}{x}}{x \cdot x} \]
          14. lower--.f64N/A

            \[\leadsto \frac{\color{blue}{1 - x \cdot \frac{1}{x}}}{x \cdot x} \]
          15. lower-*.f64N/A

            \[\leadsto \frac{1 - \color{blue}{x \cdot \frac{1}{x}}}{x \cdot x} \]
          16. lower-/.f6426.6%

            \[\leadsto \frac{1 - x \cdot \color{blue}{\frac{1}{x}}}{x \cdot x} \]
        3. Applied rewrites26.6%

          \[\leadsto \color{blue}{\frac{1 - x \cdot \frac{1}{x}}{x \cdot x}} \]
        4. Applied rewrites27.0%

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

      Alternative 7: 76.4% accurate, 1.4× speedup?

      \[\begin{array}{l} t_0 := \left|x\right| \cdot \left|x\right|\\ \mathbf{if}\;\left|x\right| \leq 2.15 \cdot 10^{+27}:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.001388888888888889 \cdot \left|x\right|, \left|x\right|, -0.041666666666666664\right), t\_0, 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{-1}{t\_0}, \left|x\right|, \frac{1}{\left|x\right|}\right)}{\left|x\right|}\\ \end{array} \]
      (FPCore (x)
       :precision binary64
       (let* ((t_0 (* (fabs x) (fabs x))))
         (if (<= (fabs x) 2.15e+27)
           (fma
            (fma (* 0.001388888888888889 (fabs x)) (fabs x) -0.041666666666666664)
            t_0
            0.5)
           (/ (fma (/ (- 1.0) t_0) (fabs x) (/ 1.0 (fabs x))) (fabs x)))))
      double code(double x) {
      	double t_0 = fabs(x) * fabs(x);
      	double tmp;
      	if (fabs(x) <= 2.15e+27) {
      		tmp = fma(fma((0.001388888888888889 * fabs(x)), fabs(x), -0.041666666666666664), t_0, 0.5);
      	} else {
      		tmp = fma((-1.0 / t_0), fabs(x), (1.0 / fabs(x))) / fabs(x);
      	}
      	return tmp;
      }
      
      function code(x)
      	t_0 = Float64(abs(x) * abs(x))
      	tmp = 0.0
      	if (abs(x) <= 2.15e+27)
      		tmp = fma(fma(Float64(0.001388888888888889 * abs(x)), abs(x), -0.041666666666666664), t_0, 0.5);
      	else
      		tmp = Float64(fma(Float64(Float64(-1.0) / t_0), abs(x), Float64(1.0 / abs(x))) / abs(x));
      	end
      	return tmp
      end
      
      code[x_] := Block[{t$95$0 = N[(N[Abs[x], $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Abs[x], $MachinePrecision], 2.15e+27], N[(N[(N[(0.001388888888888889 * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision] + -0.041666666666666664), $MachinePrecision] * t$95$0 + 0.5), $MachinePrecision], N[(N[(N[((-1.0) / t$95$0), $MachinePrecision] * N[Abs[x], $MachinePrecision] + N[(1.0 / N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Abs[x], $MachinePrecision]), $MachinePrecision]]]
      
      \begin{array}{l}
      t_0 := \left|x\right| \cdot \left|x\right|\\
      \mathbf{if}\;\left|x\right| \leq 2.15 \cdot 10^{+27}:\\
      \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.001388888888888889 \cdot \left|x\right|, \left|x\right|, -0.041666666666666664\right), t\_0, 0.5\right)\\
      
      \mathbf{else}:\\
      \;\;\;\;\frac{\mathsf{fma}\left(\frac{-1}{t\_0}, \left|x\right|, \frac{1}{\left|x\right|}\right)}{\left|x\right|}\\
      
      
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if x < 2.15000000000000004e27

        1. Initial program 50.1%

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

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

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

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

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

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

            \[\leadsto \frac{1}{2} + {x}^{2} \cdot \left(\frac{1}{720} \cdot {x}^{2} - \frac{1}{24}\right) \]
          6. lower-pow.f6451.8%

            \[\leadsto 0.5 + {x}^{2} \cdot \left(0.001388888888888889 \cdot {x}^{2} - 0.041666666666666664\right) \]
        4. Applied rewrites51.8%

          \[\leadsto \color{blue}{0.5 + {x}^{2} \cdot \left(0.001388888888888889 \cdot {x}^{2} - 0.041666666666666664\right)} \]
        5. Step-by-step derivation
          1. lift-+.f64N/A

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

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

            \[\leadsto {x}^{2} \cdot \left(\frac{1}{720} \cdot {x}^{2} - \frac{1}{24}\right) + \frac{1}{2} \]
          4. lift-pow.f64N/A

            \[\leadsto {x}^{2} \cdot \left(\frac{1}{720} \cdot {x}^{2} - \frac{1}{24}\right) + \frac{1}{2} \]
          5. pow2N/A

            \[\leadsto \left(x \cdot x\right) \cdot \left(\frac{1}{720} \cdot {x}^{2} - \frac{1}{24}\right) + \frac{1}{2} \]
          6. lift-*.f64N/A

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

            \[\leadsto \left(\frac{1}{720} \cdot {x}^{2} - \frac{1}{24}\right) \cdot \left(x \cdot x\right) + \frac{1}{2} \]
          8. lower-fma.f6451.8%

            \[\leadsto \mathsf{fma}\left(0.001388888888888889 \cdot {x}^{2} - 0.041666666666666664, \color{blue}{x \cdot x}, 0.5\right) \]
          9. lift--.f64N/A

            \[\leadsto \mathsf{fma}\left(\frac{1}{720} \cdot {x}^{2} - \frac{1}{24}, \color{blue}{x} \cdot x, \frac{1}{2}\right) \]
          10. sub-flipN/A

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

            \[\leadsto \mathsf{fma}\left(\frac{1}{720} \cdot {x}^{2} + \left(\mathsf{neg}\left(\frac{1}{24}\right)\right), x \cdot x, \frac{1}{2}\right) \]
          12. lift-pow.f64N/A

            \[\leadsto \mathsf{fma}\left(\frac{1}{720} \cdot {x}^{2} + \left(\mathsf{neg}\left(\frac{1}{24}\right)\right), x \cdot x, \frac{1}{2}\right) \]
          13. pow2N/A

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

            \[\leadsto \mathsf{fma}\left(\left(\frac{1}{720} \cdot x\right) \cdot x + \left(\mathsf{neg}\left(\frac{1}{24}\right)\right), x \cdot x, \frac{1}{2}\right) \]
          15. lower-fma.f64N/A

            \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{720} \cdot x, x, \mathsf{neg}\left(\frac{1}{24}\right)\right), \color{blue}{x} \cdot x, \frac{1}{2}\right) \]
          16. lower-*.f64N/A

            \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{720} \cdot x, x, \mathsf{neg}\left(\frac{1}{24}\right)\right), x \cdot x, \frac{1}{2}\right) \]
          17. metadata-eval51.8%

            \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(0.001388888888888889 \cdot x, x, -0.041666666666666664\right), x \cdot x, 0.5\right) \]
        6. Applied rewrites51.8%

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

        if 2.15000000000000004e27 < x

        1. Initial program 50.1%

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

          \[\leadsto \frac{1 - \color{blue}{1}}{x \cdot x} \]
        3. Step-by-step derivation
          1. Applied rewrites26.2%

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

              \[\leadsto \color{blue}{\frac{1 - 1}{x \cdot x}} \]
            2. lift-*.f64N/A

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

              \[\leadsto \color{blue}{\frac{\frac{1 - 1}{x}}{x}} \]
            4. lift--.f64N/A

              \[\leadsto \frac{\frac{\color{blue}{1 - 1}}{x}}{x} \]
            5. div-subN/A

              \[\leadsto \frac{\color{blue}{\frac{1}{x} - \frac{1}{x}}}{x} \]
            6. sub-divN/A

              \[\leadsto \color{blue}{\frac{\frac{1}{x}}{x} - \frac{\frac{1}{x}}{x}} \]
            7. frac-subN/A

              \[\leadsto \color{blue}{\frac{\frac{1}{x} \cdot x - x \cdot \frac{1}{x}}{x \cdot x}} \]
            8. lift-*.f64N/A

              \[\leadsto \frac{\frac{1}{x} \cdot x - x \cdot \frac{1}{x}}{\color{blue}{x \cdot x}} \]
            9. lower-/.f64N/A

              \[\leadsto \color{blue}{\frac{\frac{1}{x} \cdot x - x \cdot \frac{1}{x}}{x \cdot x}} \]
            10. inv-powN/A

              \[\leadsto \frac{\color{blue}{{x}^{-1}} \cdot x - x \cdot \frac{1}{x}}{x \cdot x} \]
            11. pow-plusN/A

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

              \[\leadsto \frac{{x}^{\color{blue}{0}} - x \cdot \frac{1}{x}}{x \cdot x} \]
            13. metadata-evalN/A

              \[\leadsto \frac{\color{blue}{1} - x \cdot \frac{1}{x}}{x \cdot x} \]
            14. lower--.f64N/A

              \[\leadsto \frac{\color{blue}{1 - x \cdot \frac{1}{x}}}{x \cdot x} \]
            15. lower-*.f64N/A

              \[\leadsto \frac{1 - \color{blue}{x \cdot \frac{1}{x}}}{x \cdot x} \]
            16. lower-/.f6426.6%

              \[\leadsto \frac{1 - x \cdot \color{blue}{\frac{1}{x}}}{x \cdot x} \]
          3. Applied rewrites26.6%

            \[\leadsto \color{blue}{\frac{1 - x \cdot \frac{1}{x}}{x \cdot x}} \]
          4. Applied rewrites26.8%

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

        Alternative 8: 76.4% accurate, 1.5× speedup?

        \[\begin{array}{l} t_0 := \left|x\right| \cdot \left|x\right|\\ \mathbf{if}\;\left|x\right| \leq 400000:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.001388888888888889 \cdot \left|x\right|, \left|x\right|, -0.041666666666666664\right), t\_0, 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{1}{\left|x\right|}, \frac{-1}{\left|x\right|}, \frac{1}{t\_0}\right)\\ \end{array} \]
        (FPCore (x)
         :precision binary64
         (let* ((t_0 (* (fabs x) (fabs x))))
           (if (<= (fabs x) 400000.0)
             (fma
              (fma (* 0.001388888888888889 (fabs x)) (fabs x) -0.041666666666666664)
              t_0
              0.5)
             (fma (/ 1.0 (fabs x)) (/ -1.0 (fabs x)) (/ 1.0 t_0)))))
        double code(double x) {
        	double t_0 = fabs(x) * fabs(x);
        	double tmp;
        	if (fabs(x) <= 400000.0) {
        		tmp = fma(fma((0.001388888888888889 * fabs(x)), fabs(x), -0.041666666666666664), t_0, 0.5);
        	} else {
        		tmp = fma((1.0 / fabs(x)), (-1.0 / fabs(x)), (1.0 / t_0));
        	}
        	return tmp;
        }
        
        function code(x)
        	t_0 = Float64(abs(x) * abs(x))
        	tmp = 0.0
        	if (abs(x) <= 400000.0)
        		tmp = fma(fma(Float64(0.001388888888888889 * abs(x)), abs(x), -0.041666666666666664), t_0, 0.5);
        	else
        		tmp = fma(Float64(1.0 / abs(x)), Float64(-1.0 / abs(x)), Float64(1.0 / t_0));
        	end
        	return tmp
        end
        
        code[x_] := Block[{t$95$0 = N[(N[Abs[x], $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Abs[x], $MachinePrecision], 400000.0], N[(N[(N[(0.001388888888888889 * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision] + -0.041666666666666664), $MachinePrecision] * t$95$0 + 0.5), $MachinePrecision], N[(N[(1.0 / N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[(-1.0 / N[Abs[x], $MachinePrecision]), $MachinePrecision] + N[(1.0 / t$95$0), $MachinePrecision]), $MachinePrecision]]]
        
        \begin{array}{l}
        t_0 := \left|x\right| \cdot \left|x\right|\\
        \mathbf{if}\;\left|x\right| \leq 400000:\\
        \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.001388888888888889 \cdot \left|x\right|, \left|x\right|, -0.041666666666666664\right), t\_0, 0.5\right)\\
        
        \mathbf{else}:\\
        \;\;\;\;\mathsf{fma}\left(\frac{1}{\left|x\right|}, \frac{-1}{\left|x\right|}, \frac{1}{t\_0}\right)\\
        
        
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if x < 4e5

          1. Initial program 50.1%

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

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

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

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

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

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

              \[\leadsto \frac{1}{2} + {x}^{2} \cdot \left(\frac{1}{720} \cdot {x}^{2} - \frac{1}{24}\right) \]
            6. lower-pow.f6451.8%

              \[\leadsto 0.5 + {x}^{2} \cdot \left(0.001388888888888889 \cdot {x}^{2} - 0.041666666666666664\right) \]
          4. Applied rewrites51.8%

            \[\leadsto \color{blue}{0.5 + {x}^{2} \cdot \left(0.001388888888888889 \cdot {x}^{2} - 0.041666666666666664\right)} \]
          5. Step-by-step derivation
            1. lift-+.f64N/A

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

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

              \[\leadsto {x}^{2} \cdot \left(\frac{1}{720} \cdot {x}^{2} - \frac{1}{24}\right) + \frac{1}{2} \]
            4. lift-pow.f64N/A

              \[\leadsto {x}^{2} \cdot \left(\frac{1}{720} \cdot {x}^{2} - \frac{1}{24}\right) + \frac{1}{2} \]
            5. pow2N/A

              \[\leadsto \left(x \cdot x\right) \cdot \left(\frac{1}{720} \cdot {x}^{2} - \frac{1}{24}\right) + \frac{1}{2} \]
            6. lift-*.f64N/A

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

              \[\leadsto \left(\frac{1}{720} \cdot {x}^{2} - \frac{1}{24}\right) \cdot \left(x \cdot x\right) + \frac{1}{2} \]
            8. lower-fma.f6451.8%

              \[\leadsto \mathsf{fma}\left(0.001388888888888889 \cdot {x}^{2} - 0.041666666666666664, \color{blue}{x \cdot x}, 0.5\right) \]
            9. lift--.f64N/A

              \[\leadsto \mathsf{fma}\left(\frac{1}{720} \cdot {x}^{2} - \frac{1}{24}, \color{blue}{x} \cdot x, \frac{1}{2}\right) \]
            10. sub-flipN/A

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

              \[\leadsto \mathsf{fma}\left(\frac{1}{720} \cdot {x}^{2} + \left(\mathsf{neg}\left(\frac{1}{24}\right)\right), x \cdot x, \frac{1}{2}\right) \]
            12. lift-pow.f64N/A

              \[\leadsto \mathsf{fma}\left(\frac{1}{720} \cdot {x}^{2} + \left(\mathsf{neg}\left(\frac{1}{24}\right)\right), x \cdot x, \frac{1}{2}\right) \]
            13. pow2N/A

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

              \[\leadsto \mathsf{fma}\left(\left(\frac{1}{720} \cdot x\right) \cdot x + \left(\mathsf{neg}\left(\frac{1}{24}\right)\right), x \cdot x, \frac{1}{2}\right) \]
            15. lower-fma.f64N/A

              \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{720} \cdot x, x, \mathsf{neg}\left(\frac{1}{24}\right)\right), \color{blue}{x} \cdot x, \frac{1}{2}\right) \]
            16. lower-*.f64N/A

              \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{720} \cdot x, x, \mathsf{neg}\left(\frac{1}{24}\right)\right), x \cdot x, \frac{1}{2}\right) \]
            17. metadata-eval51.8%

              \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(0.001388888888888889 \cdot x, x, -0.041666666666666664\right), x \cdot x, 0.5\right) \]
          6. Applied rewrites51.8%

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

          if 4e5 < x

          1. Initial program 50.1%

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

            \[\leadsto \frac{1 - \color{blue}{1}}{x \cdot x} \]
          3. Step-by-step derivation
            1. Applied rewrites26.2%

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

                \[\leadsto \color{blue}{\frac{1 - 1}{x \cdot x}} \]
              2. lift-*.f64N/A

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

                \[\leadsto \color{blue}{\frac{\frac{1 - 1}{x}}{x}} \]
              4. lift--.f64N/A

                \[\leadsto \frac{\frac{\color{blue}{1 - 1}}{x}}{x} \]
              5. div-subN/A

                \[\leadsto \frac{\color{blue}{\frac{1}{x} - \frac{1}{x}}}{x} \]
              6. sub-divN/A

                \[\leadsto \color{blue}{\frac{\frac{1}{x}}{x} - \frac{\frac{1}{x}}{x}} \]
              7. frac-subN/A

                \[\leadsto \color{blue}{\frac{\frac{1}{x} \cdot x - x \cdot \frac{1}{x}}{x \cdot x}} \]
              8. lift-*.f64N/A

                \[\leadsto \frac{\frac{1}{x} \cdot x - x \cdot \frac{1}{x}}{\color{blue}{x \cdot x}} \]
              9. lower-/.f64N/A

                \[\leadsto \color{blue}{\frac{\frac{1}{x} \cdot x - x \cdot \frac{1}{x}}{x \cdot x}} \]
              10. inv-powN/A

                \[\leadsto \frac{\color{blue}{{x}^{-1}} \cdot x - x \cdot \frac{1}{x}}{x \cdot x} \]
              11. pow-plusN/A

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

                \[\leadsto \frac{{x}^{\color{blue}{0}} - x \cdot \frac{1}{x}}{x \cdot x} \]
              13. metadata-evalN/A

                \[\leadsto \frac{\color{blue}{1} - x \cdot \frac{1}{x}}{x \cdot x} \]
              14. lower--.f64N/A

                \[\leadsto \frac{\color{blue}{1 - x \cdot \frac{1}{x}}}{x \cdot x} \]
              15. lower-*.f64N/A

                \[\leadsto \frac{1 - \color{blue}{x \cdot \frac{1}{x}}}{x \cdot x} \]
              16. lower-/.f6426.6%

                \[\leadsto \frac{1 - x \cdot \color{blue}{\frac{1}{x}}}{x \cdot x} \]
            3. Applied rewrites26.6%

              \[\leadsto \color{blue}{\frac{1 - x \cdot \frac{1}{x}}{x \cdot x}} \]
            4. Applied rewrites27.4%

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

          Alternative 9: 76.4% accurate, 1.6× speedup?

          \[\begin{array}{l} t_0 := \left|x\right| \cdot \left|x\right|\\ \mathbf{if}\;\left|x\right| \leq 400000:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.001388888888888889 \cdot \left|x\right|, \left|x\right|, -0.041666666666666664\right), t\_0, 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{1}{-\left|x\right|}, \left|x\right|, 1\right)}{t\_0}\\ \end{array} \]
          (FPCore (x)
           :precision binary64
           (let* ((t_0 (* (fabs x) (fabs x))))
             (if (<= (fabs x) 400000.0)
               (fma
                (fma (* 0.001388888888888889 (fabs x)) (fabs x) -0.041666666666666664)
                t_0
                0.5)
               (/ (fma (/ 1.0 (- (fabs x))) (fabs x) 1.0) t_0))))
          double code(double x) {
          	double t_0 = fabs(x) * fabs(x);
          	double tmp;
          	if (fabs(x) <= 400000.0) {
          		tmp = fma(fma((0.001388888888888889 * fabs(x)), fabs(x), -0.041666666666666664), t_0, 0.5);
          	} else {
          		tmp = fma((1.0 / -fabs(x)), fabs(x), 1.0) / t_0;
          	}
          	return tmp;
          }
          
          function code(x)
          	t_0 = Float64(abs(x) * abs(x))
          	tmp = 0.0
          	if (abs(x) <= 400000.0)
          		tmp = fma(fma(Float64(0.001388888888888889 * abs(x)), abs(x), -0.041666666666666664), t_0, 0.5);
          	else
          		tmp = Float64(fma(Float64(1.0 / Float64(-abs(x))), abs(x), 1.0) / t_0);
          	end
          	return tmp
          end
          
          code[x_] := Block[{t$95$0 = N[(N[Abs[x], $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Abs[x], $MachinePrecision], 400000.0], N[(N[(N[(0.001388888888888889 * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision] + -0.041666666666666664), $MachinePrecision] * t$95$0 + 0.5), $MachinePrecision], N[(N[(N[(1.0 / (-N[Abs[x], $MachinePrecision])), $MachinePrecision] * N[Abs[x], $MachinePrecision] + 1.0), $MachinePrecision] / t$95$0), $MachinePrecision]]]
          
          \begin{array}{l}
          t_0 := \left|x\right| \cdot \left|x\right|\\
          \mathbf{if}\;\left|x\right| \leq 400000:\\
          \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.001388888888888889 \cdot \left|x\right|, \left|x\right|, -0.041666666666666664\right), t\_0, 0.5\right)\\
          
          \mathbf{else}:\\
          \;\;\;\;\frac{\mathsf{fma}\left(\frac{1}{-\left|x\right|}, \left|x\right|, 1\right)}{t\_0}\\
          
          
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if x < 4e5

            1. Initial program 50.1%

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

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

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

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

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

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

                \[\leadsto \frac{1}{2} + {x}^{2} \cdot \left(\frac{1}{720} \cdot {x}^{2} - \frac{1}{24}\right) \]
              6. lower-pow.f6451.8%

                \[\leadsto 0.5 + {x}^{2} \cdot \left(0.001388888888888889 \cdot {x}^{2} - 0.041666666666666664\right) \]
            4. Applied rewrites51.8%

              \[\leadsto \color{blue}{0.5 + {x}^{2} \cdot \left(0.001388888888888889 \cdot {x}^{2} - 0.041666666666666664\right)} \]
            5. Step-by-step derivation
              1. lift-+.f64N/A

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

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

                \[\leadsto {x}^{2} \cdot \left(\frac{1}{720} \cdot {x}^{2} - \frac{1}{24}\right) + \frac{1}{2} \]
              4. lift-pow.f64N/A

                \[\leadsto {x}^{2} \cdot \left(\frac{1}{720} \cdot {x}^{2} - \frac{1}{24}\right) + \frac{1}{2} \]
              5. pow2N/A

                \[\leadsto \left(x \cdot x\right) \cdot \left(\frac{1}{720} \cdot {x}^{2} - \frac{1}{24}\right) + \frac{1}{2} \]
              6. lift-*.f64N/A

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

                \[\leadsto \left(\frac{1}{720} \cdot {x}^{2} - \frac{1}{24}\right) \cdot \left(x \cdot x\right) + \frac{1}{2} \]
              8. lower-fma.f6451.8%

                \[\leadsto \mathsf{fma}\left(0.001388888888888889 \cdot {x}^{2} - 0.041666666666666664, \color{blue}{x \cdot x}, 0.5\right) \]
              9. lift--.f64N/A

                \[\leadsto \mathsf{fma}\left(\frac{1}{720} \cdot {x}^{2} - \frac{1}{24}, \color{blue}{x} \cdot x, \frac{1}{2}\right) \]
              10. sub-flipN/A

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

                \[\leadsto \mathsf{fma}\left(\frac{1}{720} \cdot {x}^{2} + \left(\mathsf{neg}\left(\frac{1}{24}\right)\right), x \cdot x, \frac{1}{2}\right) \]
              12. lift-pow.f64N/A

                \[\leadsto \mathsf{fma}\left(\frac{1}{720} \cdot {x}^{2} + \left(\mathsf{neg}\left(\frac{1}{24}\right)\right), x \cdot x, \frac{1}{2}\right) \]
              13. pow2N/A

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

                \[\leadsto \mathsf{fma}\left(\left(\frac{1}{720} \cdot x\right) \cdot x + \left(\mathsf{neg}\left(\frac{1}{24}\right)\right), x \cdot x, \frac{1}{2}\right) \]
              15. lower-fma.f64N/A

                \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{720} \cdot x, x, \mathsf{neg}\left(\frac{1}{24}\right)\right), \color{blue}{x} \cdot x, \frac{1}{2}\right) \]
              16. lower-*.f64N/A

                \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{720} \cdot x, x, \mathsf{neg}\left(\frac{1}{24}\right)\right), x \cdot x, \frac{1}{2}\right) \]
              17. metadata-eval51.8%

                \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(0.001388888888888889 \cdot x, x, -0.041666666666666664\right), x \cdot x, 0.5\right) \]
            6. Applied rewrites51.8%

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

            if 4e5 < x

            1. Initial program 50.1%

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

              \[\leadsto \frac{1 - \color{blue}{1}}{x \cdot x} \]
            3. Step-by-step derivation
              1. Applied rewrites26.2%

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

                  \[\leadsto \color{blue}{\frac{1 - 1}{x \cdot x}} \]
                2. lift-*.f64N/A

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

                  \[\leadsto \color{blue}{\frac{\frac{1 - 1}{x}}{x}} \]
                4. lift--.f64N/A

                  \[\leadsto \frac{\frac{\color{blue}{1 - 1}}{x}}{x} \]
                5. div-subN/A

                  \[\leadsto \frac{\color{blue}{\frac{1}{x} - \frac{1}{x}}}{x} \]
                6. sub-divN/A

                  \[\leadsto \color{blue}{\frac{\frac{1}{x}}{x} - \frac{\frac{1}{x}}{x}} \]
                7. frac-subN/A

                  \[\leadsto \color{blue}{\frac{\frac{1}{x} \cdot x - x \cdot \frac{1}{x}}{x \cdot x}} \]
                8. lift-*.f64N/A

                  \[\leadsto \frac{\frac{1}{x} \cdot x - x \cdot \frac{1}{x}}{\color{blue}{x \cdot x}} \]
                9. lower-/.f64N/A

                  \[\leadsto \color{blue}{\frac{\frac{1}{x} \cdot x - x \cdot \frac{1}{x}}{x \cdot x}} \]
                10. inv-powN/A

                  \[\leadsto \frac{\color{blue}{{x}^{-1}} \cdot x - x \cdot \frac{1}{x}}{x \cdot x} \]
                11. pow-plusN/A

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

                  \[\leadsto \frac{{x}^{\color{blue}{0}} - x \cdot \frac{1}{x}}{x \cdot x} \]
                13. metadata-evalN/A

                  \[\leadsto \frac{\color{blue}{1} - x \cdot \frac{1}{x}}{x \cdot x} \]
                14. lower--.f64N/A

                  \[\leadsto \frac{\color{blue}{1 - x \cdot \frac{1}{x}}}{x \cdot x} \]
                15. lower-*.f64N/A

                  \[\leadsto \frac{1 - \color{blue}{x \cdot \frac{1}{x}}}{x \cdot x} \]
                16. lower-/.f6426.6%

                  \[\leadsto \frac{1 - x \cdot \color{blue}{\frac{1}{x}}}{x \cdot x} \]
              3. Applied rewrites26.6%

                \[\leadsto \color{blue}{\frac{1 - x \cdot \frac{1}{x}}{x \cdot x}} \]
              4. Applied rewrites27.1%

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

            Alternative 10: 76.1% accurate, 1.6× speedup?

            \[\begin{array}{l} \mathbf{if}\;\left|x\right| \leq 2.3 \cdot 10^{+45}:\\ \;\;\;\;0.5\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{1}{-\left|x\right|}, \left|x\right|, 1\right)}{\left|x\right| \cdot \left|x\right|}\\ \end{array} \]
            (FPCore (x)
             :precision binary64
             (if (<= (fabs x) 2.3e+45)
               0.5
               (/ (fma (/ 1.0 (- (fabs x))) (fabs x) 1.0) (* (fabs x) (fabs x)))))
            double code(double x) {
            	double tmp;
            	if (fabs(x) <= 2.3e+45) {
            		tmp = 0.5;
            	} else {
            		tmp = fma((1.0 / -fabs(x)), fabs(x), 1.0) / (fabs(x) * fabs(x));
            	}
            	return tmp;
            }
            
            function code(x)
            	tmp = 0.0
            	if (abs(x) <= 2.3e+45)
            		tmp = 0.5;
            	else
            		tmp = Float64(fma(Float64(1.0 / Float64(-abs(x))), abs(x), 1.0) / Float64(abs(x) * abs(x)));
            	end
            	return tmp
            end
            
            code[x_] := If[LessEqual[N[Abs[x], $MachinePrecision], 2.3e+45], 0.5, N[(N[(N[(1.0 / (-N[Abs[x], $MachinePrecision])), $MachinePrecision] * N[Abs[x], $MachinePrecision] + 1.0), $MachinePrecision] / N[(N[Abs[x], $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
            
            \begin{array}{l}
            \mathbf{if}\;\left|x\right| \leq 2.3 \cdot 10^{+45}:\\
            \;\;\;\;0.5\\
            
            \mathbf{else}:\\
            \;\;\;\;\frac{\mathsf{fma}\left(\frac{1}{-\left|x\right|}, \left|x\right|, 1\right)}{\left|x\right| \cdot \left|x\right|}\\
            
            
            \end{array}
            
            Derivation
            1. Split input into 2 regimes
            2. if x < 2.30000000000000012e45

              1. Initial program 50.1%

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

                \[\leadsto \color{blue}{\frac{1}{2}} \]
              3. Step-by-step derivation
                1. Applied rewrites52.3%

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

                if 2.30000000000000012e45 < x

                1. Initial program 50.1%

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

                  \[\leadsto \frac{1 - \color{blue}{1}}{x \cdot x} \]
                3. Step-by-step derivation
                  1. Applied rewrites26.2%

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

                      \[\leadsto \color{blue}{\frac{1 - 1}{x \cdot x}} \]
                    2. lift-*.f64N/A

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

                      \[\leadsto \color{blue}{\frac{\frac{1 - 1}{x}}{x}} \]
                    4. lift--.f64N/A

                      \[\leadsto \frac{\frac{\color{blue}{1 - 1}}{x}}{x} \]
                    5. div-subN/A

                      \[\leadsto \frac{\color{blue}{\frac{1}{x} - \frac{1}{x}}}{x} \]
                    6. sub-divN/A

                      \[\leadsto \color{blue}{\frac{\frac{1}{x}}{x} - \frac{\frac{1}{x}}{x}} \]
                    7. frac-subN/A

                      \[\leadsto \color{blue}{\frac{\frac{1}{x} \cdot x - x \cdot \frac{1}{x}}{x \cdot x}} \]
                    8. lift-*.f64N/A

                      \[\leadsto \frac{\frac{1}{x} \cdot x - x \cdot \frac{1}{x}}{\color{blue}{x \cdot x}} \]
                    9. lower-/.f64N/A

                      \[\leadsto \color{blue}{\frac{\frac{1}{x} \cdot x - x \cdot \frac{1}{x}}{x \cdot x}} \]
                    10. inv-powN/A

                      \[\leadsto \frac{\color{blue}{{x}^{-1}} \cdot x - x \cdot \frac{1}{x}}{x \cdot x} \]
                    11. pow-plusN/A

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

                      \[\leadsto \frac{{x}^{\color{blue}{0}} - x \cdot \frac{1}{x}}{x \cdot x} \]
                    13. metadata-evalN/A

                      \[\leadsto \frac{\color{blue}{1} - x \cdot \frac{1}{x}}{x \cdot x} \]
                    14. lower--.f64N/A

                      \[\leadsto \frac{\color{blue}{1 - x \cdot \frac{1}{x}}}{x \cdot x} \]
                    15. lower-*.f64N/A

                      \[\leadsto \frac{1 - \color{blue}{x \cdot \frac{1}{x}}}{x \cdot x} \]
                    16. lower-/.f6426.6%

                      \[\leadsto \frac{1 - x \cdot \color{blue}{\frac{1}{x}}}{x \cdot x} \]
                  3. Applied rewrites26.6%

                    \[\leadsto \color{blue}{\frac{1 - x \cdot \frac{1}{x}}{x \cdot x}} \]
                  4. Applied rewrites27.1%

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

                Alternative 11: 76.0% accurate, 1.6× speedup?

                \[\begin{array}{l} \mathbf{if}\;\left|x\right| \leq 1.9 \cdot 10^{+45}:\\ \;\;\;\;0.5\\ \mathbf{else}:\\ \;\;\;\;\frac{1 - \left|x\right| \cdot \frac{1}{\left|x\right|}}{\left|x\right| \cdot \left|x\right|}\\ \end{array} \]
                (FPCore (x)
                 :precision binary64
                 (if (<= (fabs x) 1.9e+45)
                   0.5
                   (/ (- 1.0 (* (fabs x) (/ 1.0 (fabs x)))) (* (fabs x) (fabs x)))))
                double code(double x) {
                	double tmp;
                	if (fabs(x) <= 1.9e+45) {
                		tmp = 0.5;
                	} else {
                		tmp = (1.0 - (fabs(x) * (1.0 / fabs(x)))) / (fabs(x) * fabs(x));
                	}
                	return tmp;
                }
                
                module fmin_fmax_functions
                    implicit none
                    private
                    public fmax
                    public fmin
                
                    interface fmax
                        module procedure fmax88
                        module procedure fmax44
                        module procedure fmax84
                        module procedure fmax48
                    end interface
                    interface fmin
                        module procedure fmin88
                        module procedure fmin44
                        module procedure fmin84
                        module procedure fmin48
                    end interface
                contains
                    real(8) function fmax88(x, y) result (res)
                        real(8), intent (in) :: x
                        real(8), intent (in) :: y
                        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                    end function
                    real(4) function fmax44(x, y) result (res)
                        real(4), intent (in) :: x
                        real(4), intent (in) :: y
                        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                    end function
                    real(8) function fmax84(x, y) result(res)
                        real(8), intent (in) :: x
                        real(4), intent (in) :: y
                        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                    end function
                    real(8) function fmax48(x, y) result(res)
                        real(4), intent (in) :: x
                        real(8), intent (in) :: y
                        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                    end function
                    real(8) function fmin88(x, y) result (res)
                        real(8), intent (in) :: x
                        real(8), intent (in) :: y
                        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                    end function
                    real(4) function fmin44(x, y) result (res)
                        real(4), intent (in) :: x
                        real(4), intent (in) :: y
                        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                    end function
                    real(8) function fmin84(x, y) result(res)
                        real(8), intent (in) :: x
                        real(4), intent (in) :: y
                        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                    end function
                    real(8) function fmin48(x, y) result(res)
                        real(4), intent (in) :: x
                        real(8), intent (in) :: y
                        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                    end function
                end module
                
                real(8) function code(x)
                use fmin_fmax_functions
                    real(8), intent (in) :: x
                    real(8) :: tmp
                    if (abs(x) <= 1.9d+45) then
                        tmp = 0.5d0
                    else
                        tmp = (1.0d0 - (abs(x) * (1.0d0 / abs(x)))) / (abs(x) * abs(x))
                    end if
                    code = tmp
                end function
                
                public static double code(double x) {
                	double tmp;
                	if (Math.abs(x) <= 1.9e+45) {
                		tmp = 0.5;
                	} else {
                		tmp = (1.0 - (Math.abs(x) * (1.0 / Math.abs(x)))) / (Math.abs(x) * Math.abs(x));
                	}
                	return tmp;
                }
                
                def code(x):
                	tmp = 0
                	if math.fabs(x) <= 1.9e+45:
                		tmp = 0.5
                	else:
                		tmp = (1.0 - (math.fabs(x) * (1.0 / math.fabs(x)))) / (math.fabs(x) * math.fabs(x))
                	return tmp
                
                function code(x)
                	tmp = 0.0
                	if (abs(x) <= 1.9e+45)
                		tmp = 0.5;
                	else
                		tmp = Float64(Float64(1.0 - Float64(abs(x) * Float64(1.0 / abs(x)))) / Float64(abs(x) * abs(x)));
                	end
                	return tmp
                end
                
                function tmp_2 = code(x)
                	tmp = 0.0;
                	if (abs(x) <= 1.9e+45)
                		tmp = 0.5;
                	else
                		tmp = (1.0 - (abs(x) * (1.0 / abs(x)))) / (abs(x) * abs(x));
                	end
                	tmp_2 = tmp;
                end
                
                code[x_] := If[LessEqual[N[Abs[x], $MachinePrecision], 1.9e+45], 0.5, N[(N[(1.0 - N[(N[Abs[x], $MachinePrecision] * N[(1.0 / N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Abs[x], $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
                
                \begin{array}{l}
                \mathbf{if}\;\left|x\right| \leq 1.9 \cdot 10^{+45}:\\
                \;\;\;\;0.5\\
                
                \mathbf{else}:\\
                \;\;\;\;\frac{1 - \left|x\right| \cdot \frac{1}{\left|x\right|}}{\left|x\right| \cdot \left|x\right|}\\
                
                
                \end{array}
                
                Derivation
                1. Split input into 2 regimes
                2. if x < 1.9000000000000001e45

                  1. Initial program 50.1%

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

                    \[\leadsto \color{blue}{\frac{1}{2}} \]
                  3. Step-by-step derivation
                    1. Applied rewrites52.3%

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

                    if 1.9000000000000001e45 < x

                    1. Initial program 50.1%

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

                      \[\leadsto \frac{1 - \color{blue}{1}}{x \cdot x} \]
                    3. Step-by-step derivation
                      1. Applied rewrites26.2%

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

                          \[\leadsto \color{blue}{\frac{1 - 1}{x \cdot x}} \]
                        2. lift-*.f64N/A

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

                          \[\leadsto \color{blue}{\frac{\frac{1 - 1}{x}}{x}} \]
                        4. lift--.f64N/A

                          \[\leadsto \frac{\frac{\color{blue}{1 - 1}}{x}}{x} \]
                        5. div-subN/A

                          \[\leadsto \frac{\color{blue}{\frac{1}{x} - \frac{1}{x}}}{x} \]
                        6. sub-divN/A

                          \[\leadsto \color{blue}{\frac{\frac{1}{x}}{x} - \frac{\frac{1}{x}}{x}} \]
                        7. frac-subN/A

                          \[\leadsto \color{blue}{\frac{\frac{1}{x} \cdot x - x \cdot \frac{1}{x}}{x \cdot x}} \]
                        8. lift-*.f64N/A

                          \[\leadsto \frac{\frac{1}{x} \cdot x - x \cdot \frac{1}{x}}{\color{blue}{x \cdot x}} \]
                        9. lower-/.f64N/A

                          \[\leadsto \color{blue}{\frac{\frac{1}{x} \cdot x - x \cdot \frac{1}{x}}{x \cdot x}} \]
                        10. inv-powN/A

                          \[\leadsto \frac{\color{blue}{{x}^{-1}} \cdot x - x \cdot \frac{1}{x}}{x \cdot x} \]
                        11. pow-plusN/A

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

                          \[\leadsto \frac{{x}^{\color{blue}{0}} - x \cdot \frac{1}{x}}{x \cdot x} \]
                        13. metadata-evalN/A

                          \[\leadsto \frac{\color{blue}{1} - x \cdot \frac{1}{x}}{x \cdot x} \]
                        14. lower--.f64N/A

                          \[\leadsto \frac{\color{blue}{1 - x \cdot \frac{1}{x}}}{x \cdot x} \]
                        15. lower-*.f64N/A

                          \[\leadsto \frac{1 - \color{blue}{x \cdot \frac{1}{x}}}{x \cdot x} \]
                        16. lower-/.f6426.6%

                          \[\leadsto \frac{1 - x \cdot \color{blue}{\frac{1}{x}}}{x \cdot x} \]
                      3. Applied rewrites26.6%

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

                    Alternative 12: 75.9% accurate, 2.4× speedup?

                    \[\begin{array}{l} \mathbf{if}\;\left|x\right| \leq 1.05 \cdot 10^{+81}:\\ \;\;\;\;0.5\\ \mathbf{else}:\\ \;\;\;\;\frac{1 - 1}{\left|x\right| \cdot \left|x\right|}\\ \end{array} \]
                    (FPCore (x)
                     :precision binary64
                     (if (<= (fabs x) 1.05e+81) 0.5 (/ (- 1.0 1.0) (* (fabs x) (fabs x)))))
                    double code(double x) {
                    	double tmp;
                    	if (fabs(x) <= 1.05e+81) {
                    		tmp = 0.5;
                    	} else {
                    		tmp = (1.0 - 1.0) / (fabs(x) * fabs(x));
                    	}
                    	return tmp;
                    }
                    
                    module fmin_fmax_functions
                        implicit none
                        private
                        public fmax
                        public fmin
                    
                        interface fmax
                            module procedure fmax88
                            module procedure fmax44
                            module procedure fmax84
                            module procedure fmax48
                        end interface
                        interface fmin
                            module procedure fmin88
                            module procedure fmin44
                            module procedure fmin84
                            module procedure fmin48
                        end interface
                    contains
                        real(8) function fmax88(x, y) result (res)
                            real(8), intent (in) :: x
                            real(8), intent (in) :: y
                            res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                        end function
                        real(4) function fmax44(x, y) result (res)
                            real(4), intent (in) :: x
                            real(4), intent (in) :: y
                            res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                        end function
                        real(8) function fmax84(x, y) result(res)
                            real(8), intent (in) :: x
                            real(4), intent (in) :: y
                            res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                        end function
                        real(8) function fmax48(x, y) result(res)
                            real(4), intent (in) :: x
                            real(8), intent (in) :: y
                            res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                        end function
                        real(8) function fmin88(x, y) result (res)
                            real(8), intent (in) :: x
                            real(8), intent (in) :: y
                            res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                        end function
                        real(4) function fmin44(x, y) result (res)
                            real(4), intent (in) :: x
                            real(4), intent (in) :: y
                            res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                        end function
                        real(8) function fmin84(x, y) result(res)
                            real(8), intent (in) :: x
                            real(4), intent (in) :: y
                            res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                        end function
                        real(8) function fmin48(x, y) result(res)
                            real(4), intent (in) :: x
                            real(8), intent (in) :: y
                            res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                        end function
                    end module
                    
                    real(8) function code(x)
                    use fmin_fmax_functions
                        real(8), intent (in) :: x
                        real(8) :: tmp
                        if (abs(x) <= 1.05d+81) then
                            tmp = 0.5d0
                        else
                            tmp = (1.0d0 - 1.0d0) / (abs(x) * abs(x))
                        end if
                        code = tmp
                    end function
                    
                    public static double code(double x) {
                    	double tmp;
                    	if (Math.abs(x) <= 1.05e+81) {
                    		tmp = 0.5;
                    	} else {
                    		tmp = (1.0 - 1.0) / (Math.abs(x) * Math.abs(x));
                    	}
                    	return tmp;
                    }
                    
                    def code(x):
                    	tmp = 0
                    	if math.fabs(x) <= 1.05e+81:
                    		tmp = 0.5
                    	else:
                    		tmp = (1.0 - 1.0) / (math.fabs(x) * math.fabs(x))
                    	return tmp
                    
                    function code(x)
                    	tmp = 0.0
                    	if (abs(x) <= 1.05e+81)
                    		tmp = 0.5;
                    	else
                    		tmp = Float64(Float64(1.0 - 1.0) / Float64(abs(x) * abs(x)));
                    	end
                    	return tmp
                    end
                    
                    function tmp_2 = code(x)
                    	tmp = 0.0;
                    	if (abs(x) <= 1.05e+81)
                    		tmp = 0.5;
                    	else
                    		tmp = (1.0 - 1.0) / (abs(x) * abs(x));
                    	end
                    	tmp_2 = tmp;
                    end
                    
                    code[x_] := If[LessEqual[N[Abs[x], $MachinePrecision], 1.05e+81], 0.5, N[(N[(1.0 - 1.0), $MachinePrecision] / N[(N[Abs[x], $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
                    
                    \begin{array}{l}
                    \mathbf{if}\;\left|x\right| \leq 1.05 \cdot 10^{+81}:\\
                    \;\;\;\;0.5\\
                    
                    \mathbf{else}:\\
                    \;\;\;\;\frac{1 - 1}{\left|x\right| \cdot \left|x\right|}\\
                    
                    
                    \end{array}
                    
                    Derivation
                    1. Split input into 2 regimes
                    2. if x < 1.0499999999999999e81

                      1. Initial program 50.1%

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

                        \[\leadsto \color{blue}{\frac{1}{2}} \]
                      3. Step-by-step derivation
                        1. Applied rewrites52.3%

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

                        if 1.0499999999999999e81 < x

                        1. Initial program 50.1%

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

                          \[\leadsto \frac{1 - \color{blue}{1}}{x \cdot x} \]
                        3. Step-by-step derivation
                          1. Applied rewrites26.2%

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

                        Alternative 13: 52.3% accurate, 41.8× speedup?

                        \[0.5 \]
                        (FPCore (x) :precision binary64 0.5)
                        double code(double x) {
                        	return 0.5;
                        }
                        
                        module fmin_fmax_functions
                            implicit none
                            private
                            public fmax
                            public fmin
                        
                            interface fmax
                                module procedure fmax88
                                module procedure fmax44
                                module procedure fmax84
                                module procedure fmax48
                            end interface
                            interface fmin
                                module procedure fmin88
                                module procedure fmin44
                                module procedure fmin84
                                module procedure fmin48
                            end interface
                        contains
                            real(8) function fmax88(x, y) result (res)
                                real(8), intent (in) :: x
                                real(8), intent (in) :: y
                                res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                            end function
                            real(4) function fmax44(x, y) result (res)
                                real(4), intent (in) :: x
                                real(4), intent (in) :: y
                                res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                            end function
                            real(8) function fmax84(x, y) result(res)
                                real(8), intent (in) :: x
                                real(4), intent (in) :: y
                                res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                            end function
                            real(8) function fmax48(x, y) result(res)
                                real(4), intent (in) :: x
                                real(8), intent (in) :: y
                                res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                            end function
                            real(8) function fmin88(x, y) result (res)
                                real(8), intent (in) :: x
                                real(8), intent (in) :: y
                                res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                            end function
                            real(4) function fmin44(x, y) result (res)
                                real(4), intent (in) :: x
                                real(4), intent (in) :: y
                                res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                            end function
                            real(8) function fmin84(x, y) result(res)
                                real(8), intent (in) :: x
                                real(4), intent (in) :: y
                                res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                            end function
                            real(8) function fmin48(x, y) result(res)
                                real(4), intent (in) :: x
                                real(8), intent (in) :: y
                                res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                            end function
                        end module
                        
                        real(8) function code(x)
                        use fmin_fmax_functions
                            real(8), intent (in) :: x
                            code = 0.5d0
                        end function
                        
                        public static double code(double x) {
                        	return 0.5;
                        }
                        
                        def code(x):
                        	return 0.5
                        
                        function code(x)
                        	return 0.5
                        end
                        
                        function tmp = code(x)
                        	tmp = 0.5;
                        end
                        
                        code[x_] := 0.5
                        
                        0.5
                        
                        Derivation
                        1. Initial program 50.1%

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

                          \[\leadsto \color{blue}{\frac{1}{2}} \]
                        3. Step-by-step derivation
                          1. Applied rewrites52.3%

                            \[\leadsto \color{blue}{0.5} \]
                          2. Add Preprocessing

                          Reproduce

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