ENA, Section 1.4, Exercise 4a

Percentage Accurate: 53.3% → 99.5%
Time: 5.2s
Alternatives: 10
Speedup: 10.7×

Specification

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

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

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 10 alternatives:

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

Initial Program: 53.3% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{x - \sin x}{\tan x} \end{array} \]
(FPCore (x) :precision binary64 (/ (- x (sin x)) (tan x)))
double code(double x) {
	return (x - sin(x)) / tan(x);
}
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 = (x - sin(x)) / tan(x)
end function
public static double code(double x) {
	return (x - Math.sin(x)) / Math.tan(x);
}
def code(x):
	return (x - math.sin(x)) / math.tan(x)
function code(x)
	return Float64(Float64(x - sin(x)) / tan(x))
end
function tmp = code(x)
	tmp = (x - sin(x)) / tan(x);
end
code[x_] := N[(N[(x - N[Sin[x], $MachinePrecision]), $MachinePrecision] / N[Tan[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

Alternative 1: 99.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, -0.00023644179894179894, -0.0007275132275132275\right), x \cdot x, -0.06388888888888888\right) \cdot x\\ \frac{\left({\left(t\_0 \cdot x\right)}^{2} - 0.027777777777777776\right) \cdot x}{\mathsf{fma}\left(t\_0, x, -0.16666666666666666\right)} \cdot x \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (let* ((t_0
         (*
          (fma
           (fma (* x x) -0.00023644179894179894 -0.0007275132275132275)
           (* x x)
           -0.06388888888888888)
          x)))
   (*
    (/
     (* (- (pow (* t_0 x) 2.0) 0.027777777777777776) x)
     (fma t_0 x -0.16666666666666666))
    x)))
double code(double x) {
	double t_0 = fma(fma((x * x), -0.00023644179894179894, -0.0007275132275132275), (x * x), -0.06388888888888888) * x;
	return (((pow((t_0 * x), 2.0) - 0.027777777777777776) * x) / fma(t_0, x, -0.16666666666666666)) * x;
}
function code(x)
	t_0 = Float64(fma(fma(Float64(x * x), -0.00023644179894179894, -0.0007275132275132275), Float64(x * x), -0.06388888888888888) * x)
	return Float64(Float64(Float64(Float64((Float64(t_0 * x) ^ 2.0) - 0.027777777777777776) * x) / fma(t_0, x, -0.16666666666666666)) * x)
end
code[x_] := Block[{t$95$0 = N[(N[(N[(N[(x * x), $MachinePrecision] * -0.00023644179894179894 + -0.0007275132275132275), $MachinePrecision] * N[(x * x), $MachinePrecision] + -0.06388888888888888), $MachinePrecision] * x), $MachinePrecision]}, N[(N[(N[(N[(N[Power[N[(t$95$0 * x), $MachinePrecision], 2.0], $MachinePrecision] - 0.027777777777777776), $MachinePrecision] * x), $MachinePrecision] / N[(t$95$0 * x + -0.16666666666666666), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, -0.00023644179894179894, -0.0007275132275132275\right), x \cdot x, -0.06388888888888888\right) \cdot x\\
\frac{\left({\left(t\_0 \cdot x\right)}^{2} - 0.027777777777777776\right) \cdot x}{\mathsf{fma}\left(t\_0, x, -0.16666666666666666\right)} \cdot x
\end{array}
\end{array}
Derivation
  1. Initial program 53.3%

    \[\frac{x - \sin x}{\tan x} \]
  2. Taylor expanded in x around 0

    \[\leadsto \color{blue}{{x}^{2} \cdot \left(\frac{1}{6} + {x}^{2} \cdot \left({x}^{2} \cdot \left(\frac{-143}{604800} \cdot {x}^{2} - \frac{11}{15120}\right) - \frac{23}{360}\right)\right)} \]
  3. Step-by-step derivation
    1. lower-*.f64N/A

      \[\leadsto {x}^{2} \cdot \color{blue}{\left(\frac{1}{6} + {x}^{2} \cdot \left({x}^{2} \cdot \left(\frac{-143}{604800} \cdot {x}^{2} - \frac{11}{15120}\right) - \frac{23}{360}\right)\right)} \]
    2. lower-pow.f64N/A

      \[\leadsto {x}^{2} \cdot \left(\color{blue}{\frac{1}{6}} + {x}^{2} \cdot \left({x}^{2} \cdot \left(\frac{-143}{604800} \cdot {x}^{2} - \frac{11}{15120}\right) - \frac{23}{360}\right)\right) \]
    3. lower-+.f64N/A

      \[\leadsto {x}^{2} \cdot \left(\frac{1}{6} + \color{blue}{{x}^{2} \cdot \left({x}^{2} \cdot \left(\frac{-143}{604800} \cdot {x}^{2} - \frac{11}{15120}\right) - \frac{23}{360}\right)}\right) \]
    4. lower-*.f64N/A

      \[\leadsto {x}^{2} \cdot \left(\frac{1}{6} + {x}^{2} \cdot \color{blue}{\left({x}^{2} \cdot \left(\frac{-143}{604800} \cdot {x}^{2} - \frac{11}{15120}\right) - \frac{23}{360}\right)}\right) \]
    5. lower-pow.f64N/A

      \[\leadsto {x}^{2} \cdot \left(\frac{1}{6} + {x}^{2} \cdot \left(\color{blue}{{x}^{2} \cdot \left(\frac{-143}{604800} \cdot {x}^{2} - \frac{11}{15120}\right)} - \frac{23}{360}\right)\right) \]
    6. lower--.f64N/A

      \[\leadsto {x}^{2} \cdot \left(\frac{1}{6} + {x}^{2} \cdot \left({x}^{2} \cdot \left(\frac{-143}{604800} \cdot {x}^{2} - \frac{11}{15120}\right) - \color{blue}{\frac{23}{360}}\right)\right) \]
    7. lower-*.f64N/A

      \[\leadsto {x}^{2} \cdot \left(\frac{1}{6} + {x}^{2} \cdot \left({x}^{2} \cdot \left(\frac{-143}{604800} \cdot {x}^{2} - \frac{11}{15120}\right) - \frac{23}{360}\right)\right) \]
    8. lower-pow.f64N/A

      \[\leadsto {x}^{2} \cdot \left(\frac{1}{6} + {x}^{2} \cdot \left({x}^{2} \cdot \left(\frac{-143}{604800} \cdot {x}^{2} - \frac{11}{15120}\right) - \frac{23}{360}\right)\right) \]
    9. lower--.f64N/A

      \[\leadsto {x}^{2} \cdot \left(\frac{1}{6} + {x}^{2} \cdot \left({x}^{2} \cdot \left(\frac{-143}{604800} \cdot {x}^{2} - \frac{11}{15120}\right) - \frac{23}{360}\right)\right) \]
    10. lower-*.f64N/A

      \[\leadsto {x}^{2} \cdot \left(\frac{1}{6} + {x}^{2} \cdot \left({x}^{2} \cdot \left(\frac{-143}{604800} \cdot {x}^{2} - \frac{11}{15120}\right) - \frac{23}{360}\right)\right) \]
    11. lower-pow.f6499.5

      \[\leadsto {x}^{2} \cdot \left(0.16666666666666666 + {x}^{2} \cdot \left({x}^{2} \cdot \left(-0.00023644179894179894 \cdot {x}^{2} - 0.0007275132275132275\right) - 0.06388888888888888\right)\right) \]
  4. Applied rewrites99.5%

    \[\leadsto \color{blue}{{x}^{2} \cdot \left(0.16666666666666666 + {x}^{2} \cdot \left({x}^{2} \cdot \left(-0.00023644179894179894 \cdot {x}^{2} - 0.0007275132275132275\right) - 0.06388888888888888\right)\right)} \]
  5. Step-by-step derivation
    1. lift-*.f64N/A

      \[\leadsto {x}^{2} \cdot \color{blue}{\left(\frac{1}{6} + {x}^{2} \cdot \left({x}^{2} \cdot \left(\frac{-143}{604800} \cdot {x}^{2} - \frac{11}{15120}\right) - \frac{23}{360}\right)\right)} \]
    2. *-commutativeN/A

      \[\leadsto \left(\frac{1}{6} + {x}^{2} \cdot \left({x}^{2} \cdot \left(\frac{-143}{604800} \cdot {x}^{2} - \frac{11}{15120}\right) - \frac{23}{360}\right)\right) \cdot \color{blue}{{x}^{2}} \]
    3. lift-pow.f64N/A

      \[\leadsto \left(\frac{1}{6} + {x}^{2} \cdot \left({x}^{2} \cdot \left(\frac{-143}{604800} \cdot {x}^{2} - \frac{11}{15120}\right) - \frac{23}{360}\right)\right) \cdot {x}^{\color{blue}{2}} \]
    4. unpow2N/A

      \[\leadsto \left(\frac{1}{6} + {x}^{2} \cdot \left({x}^{2} \cdot \left(\frac{-143}{604800} \cdot {x}^{2} - \frac{11}{15120}\right) - \frac{23}{360}\right)\right) \cdot \left(x \cdot \color{blue}{x}\right) \]
    5. associate-*r*N/A

      \[\leadsto \left(\left(\frac{1}{6} + {x}^{2} \cdot \left({x}^{2} \cdot \left(\frac{-143}{604800} \cdot {x}^{2} - \frac{11}{15120}\right) - \frac{23}{360}\right)\right) \cdot x\right) \cdot \color{blue}{x} \]
    6. lower-*.f64N/A

      \[\leadsto \left(\left(\frac{1}{6} + {x}^{2} \cdot \left({x}^{2} \cdot \left(\frac{-143}{604800} \cdot {x}^{2} - \frac{11}{15120}\right) - \frac{23}{360}\right)\right) \cdot x\right) \cdot \color{blue}{x} \]
  6. Applied rewrites99.5%

    \[\leadsto \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.00023644179894179894, x \cdot x, -0.0007275132275132275\right), x \cdot x, -0.06388888888888888\right) \cdot x, x, 0.16666666666666666\right) \cdot x\right) \cdot \color{blue}{x} \]
  7. Step-by-step derivation
    1. lift-*.f64N/A

      \[\leadsto \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{-143}{604800}, x \cdot x, \frac{-11}{15120}\right), x \cdot x, \frac{-23}{360}\right) \cdot x, x, \frac{1}{6}\right) \cdot x\right) \cdot x \]
    2. lift-fma.f64N/A

      \[\leadsto \left(\left(\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{-143}{604800}, x \cdot x, \frac{-11}{15120}\right), x \cdot x, \frac{-23}{360}\right) \cdot x\right) \cdot x + \frac{1}{6}\right) \cdot x\right) \cdot x \]
    3. flip-+N/A

      \[\leadsto \left(\frac{\left(\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{-143}{604800}, x \cdot x, \frac{-11}{15120}\right), x \cdot x, \frac{-23}{360}\right) \cdot x\right) \cdot x\right) \cdot \left(\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{-143}{604800}, x \cdot x, \frac{-11}{15120}\right), x \cdot x, \frac{-23}{360}\right) \cdot x\right) \cdot x\right) - \frac{1}{6} \cdot \frac{1}{6}}{\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{-143}{604800}, x \cdot x, \frac{-11}{15120}\right), x \cdot x, \frac{-23}{360}\right) \cdot x\right) \cdot x - \frac{1}{6}} \cdot x\right) \cdot x \]
    4. associate-*l/N/A

      \[\leadsto \frac{\left(\left(\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{-143}{604800}, x \cdot x, \frac{-11}{15120}\right), x \cdot x, \frac{-23}{360}\right) \cdot x\right) \cdot x\right) \cdot \left(\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{-143}{604800}, x \cdot x, \frac{-11}{15120}\right), x \cdot x, \frac{-23}{360}\right) \cdot x\right) \cdot x\right) - \frac{1}{6} \cdot \frac{1}{6}\right) \cdot x}{\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{-143}{604800}, x \cdot x, \frac{-11}{15120}\right), x \cdot x, \frac{-23}{360}\right) \cdot x\right) \cdot x - \frac{1}{6}} \cdot x \]
    5. lower-/.f64N/A

      \[\leadsto \frac{\left(\left(\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{-143}{604800}, x \cdot x, \frac{-11}{15120}\right), x \cdot x, \frac{-23}{360}\right) \cdot x\right) \cdot x\right) \cdot \left(\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{-143}{604800}, x \cdot x, \frac{-11}{15120}\right), x \cdot x, \frac{-23}{360}\right) \cdot x\right) \cdot x\right) - \frac{1}{6} \cdot \frac{1}{6}\right) \cdot x}{\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{-143}{604800}, x \cdot x, \frac{-11}{15120}\right), x \cdot x, \frac{-23}{360}\right) \cdot x\right) \cdot x - \frac{1}{6}} \cdot x \]
  8. Applied rewrites99.5%

    \[\leadsto \frac{\left({\left(\left(\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, -0.00023644179894179894, -0.0007275132275132275\right), x \cdot x, -0.06388888888888888\right) \cdot x\right) \cdot x\right)}^{2} - 0.027777777777777776\right) \cdot x}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, -0.00023644179894179894, -0.0007275132275132275\right), x \cdot x, -0.06388888888888888\right) \cdot x, x, -0.16666666666666666\right)} \cdot x \]
  9. Add Preprocessing

Alternative 2: 99.5% accurate, 2.4× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.00023644179894179894, x \cdot x, -0.0007275132275132275\right), x \cdot x, -0.06388888888888888\right) \cdot x, x, 0.16666666666666666\right) \cdot \left(x \cdot x\right) \end{array} \]
(FPCore (x)
 :precision binary64
 (*
  (fma
   (*
    (fma
     (fma -0.00023644179894179894 (* x x) -0.0007275132275132275)
     (* x x)
     -0.06388888888888888)
    x)
   x
   0.16666666666666666)
  (* x x)))
double code(double x) {
	return fma((fma(fma(-0.00023644179894179894, (x * x), -0.0007275132275132275), (x * x), -0.06388888888888888) * x), x, 0.16666666666666666) * (x * x);
}
function code(x)
	return Float64(fma(Float64(fma(fma(-0.00023644179894179894, Float64(x * x), -0.0007275132275132275), Float64(x * x), -0.06388888888888888) * x), x, 0.16666666666666666) * Float64(x * x))
end
code[x_] := N[(N[(N[(N[(N[(-0.00023644179894179894 * N[(x * x), $MachinePrecision] + -0.0007275132275132275), $MachinePrecision] * N[(x * x), $MachinePrecision] + -0.06388888888888888), $MachinePrecision] * x), $MachinePrecision] * x + 0.16666666666666666), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.00023644179894179894, x \cdot x, -0.0007275132275132275\right), x \cdot x, -0.06388888888888888\right) \cdot x, x, 0.16666666666666666\right) \cdot \left(x \cdot x\right)
\end{array}
Derivation
  1. Initial program 53.3%

    \[\frac{x - \sin x}{\tan x} \]
  2. Taylor expanded in x around 0

    \[\leadsto \color{blue}{{x}^{2} \cdot \left(\frac{1}{6} + {x}^{2} \cdot \left({x}^{2} \cdot \left(\frac{-143}{604800} \cdot {x}^{2} - \frac{11}{15120}\right) - \frac{23}{360}\right)\right)} \]
  3. Step-by-step derivation
    1. lower-*.f64N/A

      \[\leadsto {x}^{2} \cdot \color{blue}{\left(\frac{1}{6} + {x}^{2} \cdot \left({x}^{2} \cdot \left(\frac{-143}{604800} \cdot {x}^{2} - \frac{11}{15120}\right) - \frac{23}{360}\right)\right)} \]
    2. lower-pow.f64N/A

      \[\leadsto {x}^{2} \cdot \left(\color{blue}{\frac{1}{6}} + {x}^{2} \cdot \left({x}^{2} \cdot \left(\frac{-143}{604800} \cdot {x}^{2} - \frac{11}{15120}\right) - \frac{23}{360}\right)\right) \]
    3. lower-+.f64N/A

      \[\leadsto {x}^{2} \cdot \left(\frac{1}{6} + \color{blue}{{x}^{2} \cdot \left({x}^{2} \cdot \left(\frac{-143}{604800} \cdot {x}^{2} - \frac{11}{15120}\right) - \frac{23}{360}\right)}\right) \]
    4. lower-*.f64N/A

      \[\leadsto {x}^{2} \cdot \left(\frac{1}{6} + {x}^{2} \cdot \color{blue}{\left({x}^{2} \cdot \left(\frac{-143}{604800} \cdot {x}^{2} - \frac{11}{15120}\right) - \frac{23}{360}\right)}\right) \]
    5. lower-pow.f64N/A

      \[\leadsto {x}^{2} \cdot \left(\frac{1}{6} + {x}^{2} \cdot \left(\color{blue}{{x}^{2} \cdot \left(\frac{-143}{604800} \cdot {x}^{2} - \frac{11}{15120}\right)} - \frac{23}{360}\right)\right) \]
    6. lower--.f64N/A

      \[\leadsto {x}^{2} \cdot \left(\frac{1}{6} + {x}^{2} \cdot \left({x}^{2} \cdot \left(\frac{-143}{604800} \cdot {x}^{2} - \frac{11}{15120}\right) - \color{blue}{\frac{23}{360}}\right)\right) \]
    7. lower-*.f64N/A

      \[\leadsto {x}^{2} \cdot \left(\frac{1}{6} + {x}^{2} \cdot \left({x}^{2} \cdot \left(\frac{-143}{604800} \cdot {x}^{2} - \frac{11}{15120}\right) - \frac{23}{360}\right)\right) \]
    8. lower-pow.f64N/A

      \[\leadsto {x}^{2} \cdot \left(\frac{1}{6} + {x}^{2} \cdot \left({x}^{2} \cdot \left(\frac{-143}{604800} \cdot {x}^{2} - \frac{11}{15120}\right) - \frac{23}{360}\right)\right) \]
    9. lower--.f64N/A

      \[\leadsto {x}^{2} \cdot \left(\frac{1}{6} + {x}^{2} \cdot \left({x}^{2} \cdot \left(\frac{-143}{604800} \cdot {x}^{2} - \frac{11}{15120}\right) - \frac{23}{360}\right)\right) \]
    10. lower-*.f64N/A

      \[\leadsto {x}^{2} \cdot \left(\frac{1}{6} + {x}^{2} \cdot \left({x}^{2} \cdot \left(\frac{-143}{604800} \cdot {x}^{2} - \frac{11}{15120}\right) - \frac{23}{360}\right)\right) \]
    11. lower-pow.f6499.5

      \[\leadsto {x}^{2} \cdot \left(0.16666666666666666 + {x}^{2} \cdot \left({x}^{2} \cdot \left(-0.00023644179894179894 \cdot {x}^{2} - 0.0007275132275132275\right) - 0.06388888888888888\right)\right) \]
  4. Applied rewrites99.5%

    \[\leadsto \color{blue}{{x}^{2} \cdot \left(0.16666666666666666 + {x}^{2} \cdot \left({x}^{2} \cdot \left(-0.00023644179894179894 \cdot {x}^{2} - 0.0007275132275132275\right) - 0.06388888888888888\right)\right)} \]
  5. Step-by-step derivation
    1. lift-*.f64N/A

      \[\leadsto {x}^{2} \cdot \color{blue}{\left(\frac{1}{6} + {x}^{2} \cdot \left({x}^{2} \cdot \left(\frac{-143}{604800} \cdot {x}^{2} - \frac{11}{15120}\right) - \frac{23}{360}\right)\right)} \]
    2. *-commutativeN/A

      \[\leadsto \left(\frac{1}{6} + {x}^{2} \cdot \left({x}^{2} \cdot \left(\frac{-143}{604800} \cdot {x}^{2} - \frac{11}{15120}\right) - \frac{23}{360}\right)\right) \cdot \color{blue}{{x}^{2}} \]
    3. lower-*.f6499.5

      \[\leadsto \left(0.16666666666666666 + {x}^{2} \cdot \left({x}^{2} \cdot \left(-0.00023644179894179894 \cdot {x}^{2} - 0.0007275132275132275\right) - 0.06388888888888888\right)\right) \cdot \color{blue}{{x}^{2}} \]
  6. Applied rewrites99.5%

    \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.00023644179894179894, x \cdot x, -0.0007275132275132275\right), x \cdot x, -0.06388888888888888\right) \cdot x, x, 0.16666666666666666\right) \cdot \color{blue}{\left(x \cdot x\right)} \]
  7. Add Preprocessing

Alternative 3: 99.5% accurate, 2.4× speedup?

\[\begin{array}{l} \\ \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.00023644179894179894, x \cdot x, -0.0007275132275132275\right), x \cdot x, -0.06388888888888888\right) \cdot x, x, 0.16666666666666666\right) \cdot x\right) \cdot x \end{array} \]
(FPCore (x)
 :precision binary64
 (*
  (*
   (fma
    (*
     (fma
      (fma -0.00023644179894179894 (* x x) -0.0007275132275132275)
      (* x x)
      -0.06388888888888888)
     x)
    x
    0.16666666666666666)
   x)
  x))
double code(double x) {
	return (fma((fma(fma(-0.00023644179894179894, (x * x), -0.0007275132275132275), (x * x), -0.06388888888888888) * x), x, 0.16666666666666666) * x) * x;
}
function code(x)
	return Float64(Float64(fma(Float64(fma(fma(-0.00023644179894179894, Float64(x * x), -0.0007275132275132275), Float64(x * x), -0.06388888888888888) * x), x, 0.16666666666666666) * x) * x)
end
code[x_] := N[(N[(N[(N[(N[(N[(-0.00023644179894179894 * N[(x * x), $MachinePrecision] + -0.0007275132275132275), $MachinePrecision] * N[(x * x), $MachinePrecision] + -0.06388888888888888), $MachinePrecision] * x), $MachinePrecision] * x + 0.16666666666666666), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision]
\begin{array}{l}

\\
\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.00023644179894179894, x \cdot x, -0.0007275132275132275\right), x \cdot x, -0.06388888888888888\right) \cdot x, x, 0.16666666666666666\right) \cdot x\right) \cdot x
\end{array}
Derivation
  1. Initial program 53.3%

    \[\frac{x - \sin x}{\tan x} \]
  2. Taylor expanded in x around 0

    \[\leadsto \color{blue}{{x}^{2} \cdot \left(\frac{1}{6} + {x}^{2} \cdot \left({x}^{2} \cdot \left(\frac{-143}{604800} \cdot {x}^{2} - \frac{11}{15120}\right) - \frac{23}{360}\right)\right)} \]
  3. Step-by-step derivation
    1. lower-*.f64N/A

      \[\leadsto {x}^{2} \cdot \color{blue}{\left(\frac{1}{6} + {x}^{2} \cdot \left({x}^{2} \cdot \left(\frac{-143}{604800} \cdot {x}^{2} - \frac{11}{15120}\right) - \frac{23}{360}\right)\right)} \]
    2. lower-pow.f64N/A

      \[\leadsto {x}^{2} \cdot \left(\color{blue}{\frac{1}{6}} + {x}^{2} \cdot \left({x}^{2} \cdot \left(\frac{-143}{604800} \cdot {x}^{2} - \frac{11}{15120}\right) - \frac{23}{360}\right)\right) \]
    3. lower-+.f64N/A

      \[\leadsto {x}^{2} \cdot \left(\frac{1}{6} + \color{blue}{{x}^{2} \cdot \left({x}^{2} \cdot \left(\frac{-143}{604800} \cdot {x}^{2} - \frac{11}{15120}\right) - \frac{23}{360}\right)}\right) \]
    4. lower-*.f64N/A

      \[\leadsto {x}^{2} \cdot \left(\frac{1}{6} + {x}^{2} \cdot \color{blue}{\left({x}^{2} \cdot \left(\frac{-143}{604800} \cdot {x}^{2} - \frac{11}{15120}\right) - \frac{23}{360}\right)}\right) \]
    5. lower-pow.f64N/A

      \[\leadsto {x}^{2} \cdot \left(\frac{1}{6} + {x}^{2} \cdot \left(\color{blue}{{x}^{2} \cdot \left(\frac{-143}{604800} \cdot {x}^{2} - \frac{11}{15120}\right)} - \frac{23}{360}\right)\right) \]
    6. lower--.f64N/A

      \[\leadsto {x}^{2} \cdot \left(\frac{1}{6} + {x}^{2} \cdot \left({x}^{2} \cdot \left(\frac{-143}{604800} \cdot {x}^{2} - \frac{11}{15120}\right) - \color{blue}{\frac{23}{360}}\right)\right) \]
    7. lower-*.f64N/A

      \[\leadsto {x}^{2} \cdot \left(\frac{1}{6} + {x}^{2} \cdot \left({x}^{2} \cdot \left(\frac{-143}{604800} \cdot {x}^{2} - \frac{11}{15120}\right) - \frac{23}{360}\right)\right) \]
    8. lower-pow.f64N/A

      \[\leadsto {x}^{2} \cdot \left(\frac{1}{6} + {x}^{2} \cdot \left({x}^{2} \cdot \left(\frac{-143}{604800} \cdot {x}^{2} - \frac{11}{15120}\right) - \frac{23}{360}\right)\right) \]
    9. lower--.f64N/A

      \[\leadsto {x}^{2} \cdot \left(\frac{1}{6} + {x}^{2} \cdot \left({x}^{2} \cdot \left(\frac{-143}{604800} \cdot {x}^{2} - \frac{11}{15120}\right) - \frac{23}{360}\right)\right) \]
    10. lower-*.f64N/A

      \[\leadsto {x}^{2} \cdot \left(\frac{1}{6} + {x}^{2} \cdot \left({x}^{2} \cdot \left(\frac{-143}{604800} \cdot {x}^{2} - \frac{11}{15120}\right) - \frac{23}{360}\right)\right) \]
    11. lower-pow.f6499.5

      \[\leadsto {x}^{2} \cdot \left(0.16666666666666666 + {x}^{2} \cdot \left({x}^{2} \cdot \left(-0.00023644179894179894 \cdot {x}^{2} - 0.0007275132275132275\right) - 0.06388888888888888\right)\right) \]
  4. Applied rewrites99.5%

    \[\leadsto \color{blue}{{x}^{2} \cdot \left(0.16666666666666666 + {x}^{2} \cdot \left({x}^{2} \cdot \left(-0.00023644179894179894 \cdot {x}^{2} - 0.0007275132275132275\right) - 0.06388888888888888\right)\right)} \]
  5. Step-by-step derivation
    1. lift-*.f64N/A

      \[\leadsto {x}^{2} \cdot \color{blue}{\left(\frac{1}{6} + {x}^{2} \cdot \left({x}^{2} \cdot \left(\frac{-143}{604800} \cdot {x}^{2} - \frac{11}{15120}\right) - \frac{23}{360}\right)\right)} \]
    2. *-commutativeN/A

      \[\leadsto \left(\frac{1}{6} + {x}^{2} \cdot \left({x}^{2} \cdot \left(\frac{-143}{604800} \cdot {x}^{2} - \frac{11}{15120}\right) - \frac{23}{360}\right)\right) \cdot \color{blue}{{x}^{2}} \]
    3. lift-pow.f64N/A

      \[\leadsto \left(\frac{1}{6} + {x}^{2} \cdot \left({x}^{2} \cdot \left(\frac{-143}{604800} \cdot {x}^{2} - \frac{11}{15120}\right) - \frac{23}{360}\right)\right) \cdot {x}^{\color{blue}{2}} \]
    4. unpow2N/A

      \[\leadsto \left(\frac{1}{6} + {x}^{2} \cdot \left({x}^{2} \cdot \left(\frac{-143}{604800} \cdot {x}^{2} - \frac{11}{15120}\right) - \frac{23}{360}\right)\right) \cdot \left(x \cdot \color{blue}{x}\right) \]
    5. associate-*r*N/A

      \[\leadsto \left(\left(\frac{1}{6} + {x}^{2} \cdot \left({x}^{2} \cdot \left(\frac{-143}{604800} \cdot {x}^{2} - \frac{11}{15120}\right) - \frac{23}{360}\right)\right) \cdot x\right) \cdot \color{blue}{x} \]
    6. lower-*.f64N/A

      \[\leadsto \left(\left(\frac{1}{6} + {x}^{2} \cdot \left({x}^{2} \cdot \left(\frac{-143}{604800} \cdot {x}^{2} - \frac{11}{15120}\right) - \frac{23}{360}\right)\right) \cdot x\right) \cdot \color{blue}{x} \]
  6. Applied rewrites99.5%

    \[\leadsto \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.00023644179894179894, x \cdot x, -0.0007275132275132275\right), x \cdot x, -0.06388888888888888\right) \cdot x, x, 0.16666666666666666\right) \cdot x\right) \cdot \color{blue}{x} \]
  7. Add Preprocessing

Alternative 4: 99.4% accurate, 2.6× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(0.16666666666666666 \cdot x, x, \left(\left(\left(\mathsf{fma}\left(-0.0007275132275132275, x \cdot x, -0.06388888888888888\right) \cdot x\right) \cdot x\right) \cdot x\right) \cdot x\right) \end{array} \]
(FPCore (x)
 :precision binary64
 (fma
  (* 0.16666666666666666 x)
  x
  (*
   (* (* (* (fma -0.0007275132275132275 (* x x) -0.06388888888888888) x) x) x)
   x)))
double code(double x) {
	return fma((0.16666666666666666 * x), x, ((((fma(-0.0007275132275132275, (x * x), -0.06388888888888888) * x) * x) * x) * x));
}
function code(x)
	return fma(Float64(0.16666666666666666 * x), x, Float64(Float64(Float64(Float64(fma(-0.0007275132275132275, Float64(x * x), -0.06388888888888888) * x) * x) * x) * x))
end
code[x_] := N[(N[(0.16666666666666666 * x), $MachinePrecision] * x + N[(N[(N[(N[(N[(-0.0007275132275132275 * N[(x * x), $MachinePrecision] + -0.06388888888888888), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\mathsf{fma}\left(0.16666666666666666 \cdot x, x, \left(\left(\left(\mathsf{fma}\left(-0.0007275132275132275, x \cdot x, -0.06388888888888888\right) \cdot x\right) \cdot x\right) \cdot x\right) \cdot x\right)
\end{array}
Derivation
  1. Initial program 53.3%

    \[\frac{x - \sin x}{\tan x} \]
  2. Taylor expanded in x around 0

    \[\leadsto \color{blue}{{x}^{2} \cdot \left(\frac{1}{6} + {x}^{2} \cdot \left(\frac{-11}{15120} \cdot {x}^{2} - \frac{23}{360}\right)\right)} \]
  3. Step-by-step derivation
    1. lower-*.f64N/A

      \[\leadsto {x}^{2} \cdot \color{blue}{\left(\frac{1}{6} + {x}^{2} \cdot \left(\frac{-11}{15120} \cdot {x}^{2} - \frac{23}{360}\right)\right)} \]
    2. lower-pow.f64N/A

      \[\leadsto {x}^{2} \cdot \left(\color{blue}{\frac{1}{6}} + {x}^{2} \cdot \left(\frac{-11}{15120} \cdot {x}^{2} - \frac{23}{360}\right)\right) \]
    3. lower-+.f64N/A

      \[\leadsto {x}^{2} \cdot \left(\frac{1}{6} + \color{blue}{{x}^{2} \cdot \left(\frac{-11}{15120} \cdot {x}^{2} - \frac{23}{360}\right)}\right) \]
    4. lower-*.f64N/A

      \[\leadsto {x}^{2} \cdot \left(\frac{1}{6} + {x}^{2} \cdot \color{blue}{\left(\frac{-11}{15120} \cdot {x}^{2} - \frac{23}{360}\right)}\right) \]
    5. lower-pow.f64N/A

      \[\leadsto {x}^{2} \cdot \left(\frac{1}{6} + {x}^{2} \cdot \left(\color{blue}{\frac{-11}{15120} \cdot {x}^{2}} - \frac{23}{360}\right)\right) \]
    6. lower--.f64N/A

      \[\leadsto {x}^{2} \cdot \left(\frac{1}{6} + {x}^{2} \cdot \left(\frac{-11}{15120} \cdot {x}^{2} - \color{blue}{\frac{23}{360}}\right)\right) \]
    7. lower-*.f64N/A

      \[\leadsto {x}^{2} \cdot \left(\frac{1}{6} + {x}^{2} \cdot \left(\frac{-11}{15120} \cdot {x}^{2} - \frac{23}{360}\right)\right) \]
    8. lower-pow.f6499.4

      \[\leadsto {x}^{2} \cdot \left(0.16666666666666666 + {x}^{2} \cdot \left(-0.0007275132275132275 \cdot {x}^{2} - 0.06388888888888888\right)\right) \]
  4. Applied rewrites99.4%

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

      \[\leadsto {x}^{2} \cdot \color{blue}{\left(\frac{1}{6} + {x}^{2} \cdot \left(\frac{-11}{15120} \cdot {x}^{2} - \frac{23}{360}\right)\right)} \]
    2. lift-+.f64N/A

      \[\leadsto {x}^{2} \cdot \left(\frac{1}{6} + \color{blue}{{x}^{2} \cdot \left(\frac{-11}{15120} \cdot {x}^{2} - \frac{23}{360}\right)}\right) \]
    3. distribute-rgt-inN/A

      \[\leadsto \frac{1}{6} \cdot {x}^{2} + \color{blue}{\left({x}^{2} \cdot \left(\frac{-11}{15120} \cdot {x}^{2} - \frac{23}{360}\right)\right) \cdot {x}^{2}} \]
    4. lift-pow.f64N/A

      \[\leadsto \frac{1}{6} \cdot {x}^{2} + \left({x}^{2} \cdot \color{blue}{\left(\frac{-11}{15120} \cdot {x}^{2} - \frac{23}{360}\right)}\right) \cdot {x}^{2} \]
    5. unpow2N/A

      \[\leadsto \frac{1}{6} \cdot \left(x \cdot x\right) + \left({x}^{2} \cdot \color{blue}{\left(\frac{-11}{15120} \cdot {x}^{2} - \frac{23}{360}\right)}\right) \cdot {x}^{2} \]
    6. associate-*r*N/A

      \[\leadsto \left(\frac{1}{6} \cdot x\right) \cdot x + \color{blue}{\left({x}^{2} \cdot \left(\frac{-11}{15120} \cdot {x}^{2} - \frac{23}{360}\right)\right)} \cdot {x}^{2} \]
    7. lower-fma.f64N/A

      \[\leadsto \mathsf{fma}\left(\frac{1}{6} \cdot x, \color{blue}{x}, \left({x}^{2} \cdot \left(\frac{-11}{15120} \cdot {x}^{2} - \frac{23}{360}\right)\right) \cdot {x}^{2}\right) \]
    8. lower-*.f64N/A

      \[\leadsto \mathsf{fma}\left(\frac{1}{6} \cdot x, x, \left({x}^{2} \cdot \left(\frac{-11}{15120} \cdot {x}^{2} - \frac{23}{360}\right)\right) \cdot {x}^{2}\right) \]
    9. lift-pow.f64N/A

      \[\leadsto \mathsf{fma}\left(\frac{1}{6} \cdot x, x, \left({x}^{2} \cdot \left(\frac{-11}{15120} \cdot {x}^{2} - \frac{23}{360}\right)\right) \cdot {x}^{2}\right) \]
    10. unpow2N/A

      \[\leadsto \mathsf{fma}\left(\frac{1}{6} \cdot x, x, \left({x}^{2} \cdot \left(\frac{-11}{15120} \cdot {x}^{2} - \frac{23}{360}\right)\right) \cdot \left(x \cdot x\right)\right) \]
    11. associate-*r*N/A

      \[\leadsto \mathsf{fma}\left(\frac{1}{6} \cdot x, x, \left(\left({x}^{2} \cdot \left(\frac{-11}{15120} \cdot {x}^{2} - \frac{23}{360}\right)\right) \cdot x\right) \cdot x\right) \]
    12. lower-*.f64N/A

      \[\leadsto \mathsf{fma}\left(\frac{1}{6} \cdot x, x, \left(\left({x}^{2} \cdot \left(\frac{-11}{15120} \cdot {x}^{2} - \frac{23}{360}\right)\right) \cdot x\right) \cdot x\right) \]
  6. Applied rewrites99.4%

    \[\leadsto \mathsf{fma}\left(0.16666666666666666 \cdot x, \color{blue}{x}, \left(\left(\left(\mathsf{fma}\left(-0.0007275132275132275, x \cdot x, -0.06388888888888888\right) \cdot x\right) \cdot x\right) \cdot x\right) \cdot x\right) \]
  7. Add Preprocessing

Alternative 5: 99.4% accurate, 2.9× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(x, 0.16666666666666666, \left(\left(\mathsf{fma}\left(-0.0007275132275132275, x \cdot x, -0.06388888888888888\right) \cdot x\right) \cdot x\right) \cdot x\right) \cdot x \end{array} \]
(FPCore (x)
 :precision binary64
 (*
  (fma
   x
   0.16666666666666666
   (* (* (* (fma -0.0007275132275132275 (* x x) -0.06388888888888888) x) x) x))
  x))
double code(double x) {
	return fma(x, 0.16666666666666666, (((fma(-0.0007275132275132275, (x * x), -0.06388888888888888) * x) * x) * x)) * x;
}
function code(x)
	return Float64(fma(x, 0.16666666666666666, Float64(Float64(Float64(fma(-0.0007275132275132275, Float64(x * x), -0.06388888888888888) * x) * x) * x)) * x)
end
code[x_] := N[(N[(x * 0.16666666666666666 + N[(N[(N[(N[(-0.0007275132275132275 * N[(x * x), $MachinePrecision] + -0.06388888888888888), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]
\begin{array}{l}

\\
\mathsf{fma}\left(x, 0.16666666666666666, \left(\left(\mathsf{fma}\left(-0.0007275132275132275, x \cdot x, -0.06388888888888888\right) \cdot x\right) \cdot x\right) \cdot x\right) \cdot x
\end{array}
Derivation
  1. Initial program 53.3%

    \[\frac{x - \sin x}{\tan x} \]
  2. Taylor expanded in x around 0

    \[\leadsto \color{blue}{{x}^{2} \cdot \left(\frac{1}{6} + {x}^{2} \cdot \left(\frac{-11}{15120} \cdot {x}^{2} - \frac{23}{360}\right)\right)} \]
  3. Step-by-step derivation
    1. lower-*.f64N/A

      \[\leadsto {x}^{2} \cdot \color{blue}{\left(\frac{1}{6} + {x}^{2} \cdot \left(\frac{-11}{15120} \cdot {x}^{2} - \frac{23}{360}\right)\right)} \]
    2. lower-pow.f64N/A

      \[\leadsto {x}^{2} \cdot \left(\color{blue}{\frac{1}{6}} + {x}^{2} \cdot \left(\frac{-11}{15120} \cdot {x}^{2} - \frac{23}{360}\right)\right) \]
    3. lower-+.f64N/A

      \[\leadsto {x}^{2} \cdot \left(\frac{1}{6} + \color{blue}{{x}^{2} \cdot \left(\frac{-11}{15120} \cdot {x}^{2} - \frac{23}{360}\right)}\right) \]
    4. lower-*.f64N/A

      \[\leadsto {x}^{2} \cdot \left(\frac{1}{6} + {x}^{2} \cdot \color{blue}{\left(\frac{-11}{15120} \cdot {x}^{2} - \frac{23}{360}\right)}\right) \]
    5. lower-pow.f64N/A

      \[\leadsto {x}^{2} \cdot \left(\frac{1}{6} + {x}^{2} \cdot \left(\color{blue}{\frac{-11}{15120} \cdot {x}^{2}} - \frac{23}{360}\right)\right) \]
    6. lower--.f64N/A

      \[\leadsto {x}^{2} \cdot \left(\frac{1}{6} + {x}^{2} \cdot \left(\frac{-11}{15120} \cdot {x}^{2} - \color{blue}{\frac{23}{360}}\right)\right) \]
    7. lower-*.f64N/A

      \[\leadsto {x}^{2} \cdot \left(\frac{1}{6} + {x}^{2} \cdot \left(\frac{-11}{15120} \cdot {x}^{2} - \frac{23}{360}\right)\right) \]
    8. lower-pow.f6499.4

      \[\leadsto {x}^{2} \cdot \left(0.16666666666666666 + {x}^{2} \cdot \left(-0.0007275132275132275 \cdot {x}^{2} - 0.06388888888888888\right)\right) \]
  4. Applied rewrites99.4%

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

      \[\leadsto {x}^{2} \cdot \color{blue}{\left(\frac{1}{6} + {x}^{2} \cdot \left(\frac{-11}{15120} \cdot {x}^{2} - \frac{23}{360}\right)\right)} \]
    2. *-commutativeN/A

      \[\leadsto \left(\frac{1}{6} + {x}^{2} \cdot \left(\frac{-11}{15120} \cdot {x}^{2} - \frac{23}{360}\right)\right) \cdot \color{blue}{{x}^{2}} \]
    3. lift-pow.f64N/A

      \[\leadsto \left(\frac{1}{6} + {x}^{2} \cdot \left(\frac{-11}{15120} \cdot {x}^{2} - \frac{23}{360}\right)\right) \cdot {x}^{\color{blue}{2}} \]
    4. unpow2N/A

      \[\leadsto \left(\frac{1}{6} + {x}^{2} \cdot \left(\frac{-11}{15120} \cdot {x}^{2} - \frac{23}{360}\right)\right) \cdot \left(x \cdot \color{blue}{x}\right) \]
    5. associate-*r*N/A

      \[\leadsto \left(\left(\frac{1}{6} + {x}^{2} \cdot \left(\frac{-11}{15120} \cdot {x}^{2} - \frac{23}{360}\right)\right) \cdot x\right) \cdot \color{blue}{x} \]
    6. lower-*.f64N/A

      \[\leadsto \left(\left(\frac{1}{6} + {x}^{2} \cdot \left(\frac{-11}{15120} \cdot {x}^{2} - \frac{23}{360}\right)\right) \cdot x\right) \cdot \color{blue}{x} \]
  6. Applied rewrites99.4%

    \[\leadsto \color{blue}{\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.0007275132275132275, x \cdot x, -0.06388888888888888\right), x \cdot x, 0.16666666666666666\right) \cdot x\right) \cdot x} \]
  7. Step-by-step derivation
    1. lift-*.f64N/A

      \[\leadsto \left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{-11}{15120}, x \cdot x, \frac{-23}{360}\right), x \cdot x, \frac{1}{6}\right) \cdot x\right) \cdot x \]
    2. *-commutativeN/A

      \[\leadsto \left(x \cdot \mathsf{fma}\left(\mathsf{fma}\left(\frac{-11}{15120}, x \cdot x, \frac{-23}{360}\right), x \cdot x, \frac{1}{6}\right)\right) \cdot x \]
    3. lift-fma.f64N/A

      \[\leadsto \left(x \cdot \left(\mathsf{fma}\left(\frac{-11}{15120}, x \cdot x, \frac{-23}{360}\right) \cdot \left(x \cdot x\right) + \frac{1}{6}\right)\right) \cdot x \]
    4. +-commutativeN/A

      \[\leadsto \left(x \cdot \left(\frac{1}{6} + \mathsf{fma}\left(\frac{-11}{15120}, x \cdot x, \frac{-23}{360}\right) \cdot \left(x \cdot x\right)\right)\right) \cdot x \]
    5. distribute-rgt-inN/A

      \[\leadsto \left(\frac{1}{6} \cdot x + \left(\mathsf{fma}\left(\frac{-11}{15120}, x \cdot x, \frac{-23}{360}\right) \cdot \left(x \cdot x\right)\right) \cdot x\right) \cdot x \]
    6. *-commutativeN/A

      \[\leadsto \left(x \cdot \frac{1}{6} + \left(\mathsf{fma}\left(\frac{-11}{15120}, x \cdot x, \frac{-23}{360}\right) \cdot \left(x \cdot x\right)\right) \cdot x\right) \cdot x \]
    7. lower-fma.f64N/A

      \[\leadsto \mathsf{fma}\left(x, \frac{1}{6}, \left(\mathsf{fma}\left(\frac{-11}{15120}, x \cdot x, \frac{-23}{360}\right) \cdot \left(x \cdot x\right)\right) \cdot x\right) \cdot x \]
    8. lower-*.f64N/A

      \[\leadsto \mathsf{fma}\left(x, \frac{1}{6}, \left(\mathsf{fma}\left(\frac{-11}{15120}, x \cdot x, \frac{-23}{360}\right) \cdot \left(x \cdot x\right)\right) \cdot x\right) \cdot x \]
    9. lift-*.f64N/A

      \[\leadsto \mathsf{fma}\left(x, \frac{1}{6}, \left(\mathsf{fma}\left(\frac{-11}{15120}, x \cdot x, \frac{-23}{360}\right) \cdot \left(x \cdot x\right)\right) \cdot x\right) \cdot x \]
    10. associate-*r*N/A

      \[\leadsto \mathsf{fma}\left(x, \frac{1}{6}, \left(\left(\mathsf{fma}\left(\frac{-11}{15120}, x \cdot x, \frac{-23}{360}\right) \cdot x\right) \cdot x\right) \cdot x\right) \cdot x \]
    11. lower-*.f64N/A

      \[\leadsto \mathsf{fma}\left(x, \frac{1}{6}, \left(\left(\mathsf{fma}\left(\frac{-11}{15120}, x \cdot x, \frac{-23}{360}\right) \cdot x\right) \cdot x\right) \cdot x\right) \cdot x \]
    12. lower-*.f6499.4

      \[\leadsto \mathsf{fma}\left(x, 0.16666666666666666, \left(\left(\mathsf{fma}\left(-0.0007275132275132275, x \cdot x, -0.06388888888888888\right) \cdot x\right) \cdot x\right) \cdot x\right) \cdot x \]
  8. Applied rewrites99.4%

    \[\leadsto \mathsf{fma}\left(x, 0.16666666666666666, \left(\left(\mathsf{fma}\left(-0.0007275132275132275, x \cdot x, -0.06388888888888888\right) \cdot x\right) \cdot x\right) \cdot x\right) \cdot x \]
  9. Add Preprocessing

Alternative 6: 99.4% accurate, 3.2× speedup?

\[\begin{array}{l} \\ \left(\mathsf{fma}\left(\mathsf{fma}\left(-0.0007275132275132275, x \cdot x, -0.06388888888888888\right), x \cdot x, 0.16666666666666666\right) \cdot x\right) \cdot x \end{array} \]
(FPCore (x)
 :precision binary64
 (*
  (*
   (fma
    (fma -0.0007275132275132275 (* x x) -0.06388888888888888)
    (* x x)
    0.16666666666666666)
   x)
  x))
double code(double x) {
	return (fma(fma(-0.0007275132275132275, (x * x), -0.06388888888888888), (x * x), 0.16666666666666666) * x) * x;
}
function code(x)
	return Float64(Float64(fma(fma(-0.0007275132275132275, Float64(x * x), -0.06388888888888888), Float64(x * x), 0.16666666666666666) * x) * x)
end
code[x_] := N[(N[(N[(N[(-0.0007275132275132275 * N[(x * x), $MachinePrecision] + -0.06388888888888888), $MachinePrecision] * N[(x * x), $MachinePrecision] + 0.16666666666666666), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision]
\begin{array}{l}

\\
\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.0007275132275132275, x \cdot x, -0.06388888888888888\right), x \cdot x, 0.16666666666666666\right) \cdot x\right) \cdot x
\end{array}
Derivation
  1. Initial program 53.3%

    \[\frac{x - \sin x}{\tan x} \]
  2. Taylor expanded in x around 0

    \[\leadsto \color{blue}{{x}^{2} \cdot \left(\frac{1}{6} + {x}^{2} \cdot \left(\frac{-11}{15120} \cdot {x}^{2} - \frac{23}{360}\right)\right)} \]
  3. Step-by-step derivation
    1. lower-*.f64N/A

      \[\leadsto {x}^{2} \cdot \color{blue}{\left(\frac{1}{6} + {x}^{2} \cdot \left(\frac{-11}{15120} \cdot {x}^{2} - \frac{23}{360}\right)\right)} \]
    2. lower-pow.f64N/A

      \[\leadsto {x}^{2} \cdot \left(\color{blue}{\frac{1}{6}} + {x}^{2} \cdot \left(\frac{-11}{15120} \cdot {x}^{2} - \frac{23}{360}\right)\right) \]
    3. lower-+.f64N/A

      \[\leadsto {x}^{2} \cdot \left(\frac{1}{6} + \color{blue}{{x}^{2} \cdot \left(\frac{-11}{15120} \cdot {x}^{2} - \frac{23}{360}\right)}\right) \]
    4. lower-*.f64N/A

      \[\leadsto {x}^{2} \cdot \left(\frac{1}{6} + {x}^{2} \cdot \color{blue}{\left(\frac{-11}{15120} \cdot {x}^{2} - \frac{23}{360}\right)}\right) \]
    5. lower-pow.f64N/A

      \[\leadsto {x}^{2} \cdot \left(\frac{1}{6} + {x}^{2} \cdot \left(\color{blue}{\frac{-11}{15120} \cdot {x}^{2}} - \frac{23}{360}\right)\right) \]
    6. lower--.f64N/A

      \[\leadsto {x}^{2} \cdot \left(\frac{1}{6} + {x}^{2} \cdot \left(\frac{-11}{15120} \cdot {x}^{2} - \color{blue}{\frac{23}{360}}\right)\right) \]
    7. lower-*.f64N/A

      \[\leadsto {x}^{2} \cdot \left(\frac{1}{6} + {x}^{2} \cdot \left(\frac{-11}{15120} \cdot {x}^{2} - \frac{23}{360}\right)\right) \]
    8. lower-pow.f6499.4

      \[\leadsto {x}^{2} \cdot \left(0.16666666666666666 + {x}^{2} \cdot \left(-0.0007275132275132275 \cdot {x}^{2} - 0.06388888888888888\right)\right) \]
  4. Applied rewrites99.4%

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

      \[\leadsto {x}^{2} \cdot \color{blue}{\left(\frac{1}{6} + {x}^{2} \cdot \left(\frac{-11}{15120} \cdot {x}^{2} - \frac{23}{360}\right)\right)} \]
    2. *-commutativeN/A

      \[\leadsto \left(\frac{1}{6} + {x}^{2} \cdot \left(\frac{-11}{15120} \cdot {x}^{2} - \frac{23}{360}\right)\right) \cdot \color{blue}{{x}^{2}} \]
    3. lift-pow.f64N/A

      \[\leadsto \left(\frac{1}{6} + {x}^{2} \cdot \left(\frac{-11}{15120} \cdot {x}^{2} - \frac{23}{360}\right)\right) \cdot {x}^{\color{blue}{2}} \]
    4. unpow2N/A

      \[\leadsto \left(\frac{1}{6} + {x}^{2} \cdot \left(\frac{-11}{15120} \cdot {x}^{2} - \frac{23}{360}\right)\right) \cdot \left(x \cdot \color{blue}{x}\right) \]
    5. associate-*r*N/A

      \[\leadsto \left(\left(\frac{1}{6} + {x}^{2} \cdot \left(\frac{-11}{15120} \cdot {x}^{2} - \frac{23}{360}\right)\right) \cdot x\right) \cdot \color{blue}{x} \]
    6. lower-*.f64N/A

      \[\leadsto \left(\left(\frac{1}{6} + {x}^{2} \cdot \left(\frac{-11}{15120} \cdot {x}^{2} - \frac{23}{360}\right)\right) \cdot x\right) \cdot \color{blue}{x} \]
  6. Applied rewrites99.4%

    \[\leadsto \color{blue}{\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.0007275132275132275, x \cdot x, -0.06388888888888888\right), x \cdot x, 0.16666666666666666\right) \cdot x\right) \cdot x} \]
  7. Add Preprocessing

Alternative 7: 99.3% accurate, 5.0× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(-0.06388888888888888, x \cdot x, 0.16666666666666666\right) \cdot \left(x \cdot x\right) \end{array} \]
(FPCore (x)
 :precision binary64
 (* (fma -0.06388888888888888 (* x x) 0.16666666666666666) (* x x)))
double code(double x) {
	return fma(-0.06388888888888888, (x * x), 0.16666666666666666) * (x * x);
}
function code(x)
	return Float64(fma(-0.06388888888888888, Float64(x * x), 0.16666666666666666) * Float64(x * x))
end
code[x_] := N[(N[(-0.06388888888888888 * N[(x * x), $MachinePrecision] + 0.16666666666666666), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\mathsf{fma}\left(-0.06388888888888888, x \cdot x, 0.16666666666666666\right) \cdot \left(x \cdot x\right)
\end{array}
Derivation
  1. Initial program 53.3%

    \[\frac{x - \sin x}{\tan x} \]
  2. Taylor expanded in x around 0

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

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

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

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

      \[\leadsto {x}^{2} \cdot \left(\frac{1}{6} + \frac{-23}{360} \cdot \color{blue}{{x}^{2}}\right) \]
    5. lower-pow.f6499.2

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

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

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

      \[\leadsto \left(\frac{1}{6} + \frac{-23}{360} \cdot {x}^{2}\right) \cdot \color{blue}{{x}^{2}} \]
    3. lower-*.f6499.2

      \[\leadsto \left(0.16666666666666666 + -0.06388888888888888 \cdot {x}^{2}\right) \cdot \color{blue}{{x}^{2}} \]
    4. lift-+.f64N/A

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

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

      \[\leadsto \left(\frac{-23}{360} \cdot {x}^{2} + \frac{1}{6}\right) \cdot {x}^{2} \]
    7. lower-fma.f6499.2

      \[\leadsto \mathsf{fma}\left(-0.06388888888888888, {x}^{2}, 0.16666666666666666\right) \cdot {\color{blue}{x}}^{2} \]
    8. lift-pow.f64N/A

      \[\leadsto \mathsf{fma}\left(\frac{-23}{360}, {x}^{2}, \frac{1}{6}\right) \cdot {x}^{2} \]
    9. unpow2N/A

      \[\leadsto \mathsf{fma}\left(\frac{-23}{360}, x \cdot x, \frac{1}{6}\right) \cdot {x}^{2} \]
    10. lower-*.f6499.2

      \[\leadsto \mathsf{fma}\left(-0.06388888888888888, x \cdot x, 0.16666666666666666\right) \cdot {x}^{2} \]
    11. lift-pow.f64N/A

      \[\leadsto \mathsf{fma}\left(\frac{-23}{360}, x \cdot x, \frac{1}{6}\right) \cdot {x}^{\color{blue}{2}} \]
    12. unpow2N/A

      \[\leadsto \mathsf{fma}\left(\frac{-23}{360}, x \cdot x, \frac{1}{6}\right) \cdot \left(x \cdot \color{blue}{x}\right) \]
    13. lower-*.f6499.2

      \[\leadsto \mathsf{fma}\left(-0.06388888888888888, x \cdot x, 0.16666666666666666\right) \cdot \left(x \cdot \color{blue}{x}\right) \]
  6. Applied rewrites99.2%

    \[\leadsto \mathsf{fma}\left(-0.06388888888888888, x \cdot x, 0.16666666666666666\right) \cdot \color{blue}{\left(x \cdot x\right)} \]
  7. Add Preprocessing

Alternative 8: 99.2% accurate, 5.0× speedup?

\[\begin{array}{l} \\ \left(\mathsf{fma}\left(-0.06388888888888888, x \cdot x, 0.16666666666666666\right) \cdot x\right) \cdot x \end{array} \]
(FPCore (x)
 :precision binary64
 (* (* (fma -0.06388888888888888 (* x x) 0.16666666666666666) x) x))
double code(double x) {
	return (fma(-0.06388888888888888, (x * x), 0.16666666666666666) * x) * x;
}
function code(x)
	return Float64(Float64(fma(-0.06388888888888888, Float64(x * x), 0.16666666666666666) * x) * x)
end
code[x_] := N[(N[(N[(-0.06388888888888888 * N[(x * x), $MachinePrecision] + 0.16666666666666666), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision]
\begin{array}{l}

\\
\left(\mathsf{fma}\left(-0.06388888888888888, x \cdot x, 0.16666666666666666\right) \cdot x\right) \cdot x
\end{array}
Derivation
  1. Initial program 53.3%

    \[\frac{x - \sin x}{\tan x} \]
  2. Taylor expanded in x around 0

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

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

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

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

      \[\leadsto {x}^{2} \cdot \left(\frac{1}{6} + \frac{-23}{360} \cdot \color{blue}{{x}^{2}}\right) \]
    5. lower-pow.f6499.2

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

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

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

      \[\leadsto \left(\frac{1}{6} + \frac{-23}{360} \cdot {x}^{2}\right) \cdot \color{blue}{{x}^{2}} \]
    3. lift-pow.f64N/A

      \[\leadsto \left(\frac{1}{6} + \frac{-23}{360} \cdot {x}^{2}\right) \cdot {x}^{\color{blue}{2}} \]
    4. unpow2N/A

      \[\leadsto \left(\frac{1}{6} + \frac{-23}{360} \cdot {x}^{2}\right) \cdot \left(x \cdot \color{blue}{x}\right) \]
    5. associate-*r*N/A

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

      \[\leadsto \left(\left(\frac{1}{6} + \frac{-23}{360} \cdot {x}^{2}\right) \cdot x\right) \cdot \color{blue}{x} \]
    7. lower-*.f6499.3

      \[\leadsto \left(\left(0.16666666666666666 + -0.06388888888888888 \cdot {x}^{2}\right) \cdot x\right) \cdot x \]
    8. lift-+.f64N/A

      \[\leadsto \left(\left(\frac{1}{6} + \frac{-23}{360} \cdot {x}^{2}\right) \cdot x\right) \cdot x \]
    9. +-commutativeN/A

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

      \[\leadsto \left(\left(\frac{-23}{360} \cdot {x}^{2} + \frac{1}{6}\right) \cdot x\right) \cdot x \]
    11. lower-fma.f6499.3

      \[\leadsto \left(\mathsf{fma}\left(-0.06388888888888888, {x}^{2}, 0.16666666666666666\right) \cdot x\right) \cdot x \]
    12. lift-pow.f64N/A

      \[\leadsto \left(\mathsf{fma}\left(\frac{-23}{360}, {x}^{2}, \frac{1}{6}\right) \cdot x\right) \cdot x \]
    13. unpow2N/A

      \[\leadsto \left(\mathsf{fma}\left(\frac{-23}{360}, x \cdot x, \frac{1}{6}\right) \cdot x\right) \cdot x \]
    14. lower-*.f6499.3

      \[\leadsto \left(\mathsf{fma}\left(-0.06388888888888888, x \cdot x, 0.16666666666666666\right) \cdot x\right) \cdot x \]
  6. Applied rewrites99.3%

    \[\leadsto \left(\mathsf{fma}\left(-0.06388888888888888, x \cdot x, 0.16666666666666666\right) \cdot x\right) \cdot \color{blue}{x} \]
  7. Add Preprocessing

Alternative 9: 99.2% accurate, 5.0× speedup?

\[\begin{array}{l} \\ \left(-0.06388888888888888 \cdot x\right) \cdot \left(x \cdot \mathsf{fma}\left(x, x, -2.608695652173913\right)\right) \end{array} \]
(FPCore (x)
 :precision binary64
 (* (* -0.06388888888888888 x) (* x (fma x x -2.608695652173913))))
double code(double x) {
	return (-0.06388888888888888 * x) * (x * fma(x, x, -2.608695652173913));
}
function code(x)
	return Float64(Float64(-0.06388888888888888 * x) * Float64(x * fma(x, x, -2.608695652173913)))
end
code[x_] := N[(N[(-0.06388888888888888 * x), $MachinePrecision] * N[(x * N[(x * x + -2.608695652173913), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\left(-0.06388888888888888 \cdot x\right) \cdot \left(x \cdot \mathsf{fma}\left(x, x, -2.608695652173913\right)\right)
\end{array}
Derivation
  1. Initial program 53.3%

    \[\frac{x - \sin x}{\tan x} \]
  2. Taylor expanded in x around 0

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

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

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

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

      \[\leadsto {x}^{2} \cdot \left(\frac{1}{6} + \frac{-23}{360} \cdot \color{blue}{{x}^{2}}\right) \]
    5. lower-pow.f6499.2

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

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

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

      \[\leadsto \left(\frac{1}{6} + \frac{-23}{360} \cdot {x}^{2}\right) \cdot \color{blue}{{x}^{2}} \]
    3. lower-*.f6499.2

      \[\leadsto \left(0.16666666666666666 + -0.06388888888888888 \cdot {x}^{2}\right) \cdot \color{blue}{{x}^{2}} \]
    4. lift-+.f64N/A

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

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

      \[\leadsto \left(\frac{-23}{360} \cdot {x}^{2} + \frac{1}{6}\right) \cdot {x}^{2} \]
    7. lower-fma.f6499.2

      \[\leadsto \mathsf{fma}\left(-0.06388888888888888, {x}^{2}, 0.16666666666666666\right) \cdot {\color{blue}{x}}^{2} \]
    8. lift-pow.f64N/A

      \[\leadsto \mathsf{fma}\left(\frac{-23}{360}, {x}^{2}, \frac{1}{6}\right) \cdot {x}^{2} \]
    9. unpow2N/A

      \[\leadsto \mathsf{fma}\left(\frac{-23}{360}, x \cdot x, \frac{1}{6}\right) \cdot {x}^{2} \]
    10. lower-*.f6499.2

      \[\leadsto \mathsf{fma}\left(-0.06388888888888888, x \cdot x, 0.16666666666666666\right) \cdot {x}^{2} \]
    11. lift-pow.f64N/A

      \[\leadsto \mathsf{fma}\left(\frac{-23}{360}, x \cdot x, \frac{1}{6}\right) \cdot {x}^{\color{blue}{2}} \]
    12. unpow2N/A

      \[\leadsto \mathsf{fma}\left(\frac{-23}{360}, x \cdot x, \frac{1}{6}\right) \cdot \left(x \cdot \color{blue}{x}\right) \]
    13. lower-*.f6499.2

      \[\leadsto \mathsf{fma}\left(-0.06388888888888888, x \cdot x, 0.16666666666666666\right) \cdot \left(x \cdot \color{blue}{x}\right) \]
  6. Applied rewrites99.2%

    \[\leadsto \mathsf{fma}\left(-0.06388888888888888, x \cdot x, 0.16666666666666666\right) \cdot \color{blue}{\left(x \cdot x\right)} \]
  7. Step-by-step derivation
    1. lift-*.f64N/A

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

      \[\leadsto \left(x \cdot x\right) \cdot \color{blue}{\mathsf{fma}\left(\frac{-23}{360}, x \cdot x, \frac{1}{6}\right)} \]
    3. lift-fma.f64N/A

      \[\leadsto \left(x \cdot x\right) \cdot \left(\frac{-23}{360} \cdot \left(x \cdot x\right) + \color{blue}{\frac{1}{6}}\right) \]
    4. sum-to-multN/A

      \[\leadsto \left(x \cdot x\right) \cdot \left(\left(1 + \frac{\frac{1}{6}}{\frac{-23}{360} \cdot \left(x \cdot x\right)}\right) \cdot \color{blue}{\left(\frac{-23}{360} \cdot \left(x \cdot x\right)\right)}\right) \]
    5. associate-*r*N/A

      \[\leadsto \left(\left(x \cdot x\right) \cdot \left(1 + \frac{\frac{1}{6}}{\frac{-23}{360} \cdot \left(x \cdot x\right)}\right)\right) \cdot \color{blue}{\left(\frac{-23}{360} \cdot \left(x \cdot x\right)\right)} \]
    6. lower-*.f64N/A

      \[\leadsto \left(\left(x \cdot x\right) \cdot \left(1 + \frac{\frac{1}{6}}{\frac{-23}{360} \cdot \left(x \cdot x\right)}\right)\right) \cdot \color{blue}{\left(\frac{-23}{360} \cdot \left(x \cdot x\right)\right)} \]
    7. lower-*.f64N/A

      \[\leadsto \left(\left(x \cdot x\right) \cdot \left(1 + \frac{\frac{1}{6}}{\frac{-23}{360} \cdot \left(x \cdot x\right)}\right)\right) \cdot \left(\color{blue}{\frac{-23}{360}} \cdot \left(x \cdot x\right)\right) \]
    8. +-commutativeN/A

      \[\leadsto \left(\left(x \cdot x\right) \cdot \left(\frac{\frac{1}{6}}{\frac{-23}{360} \cdot \left(x \cdot x\right)} + 1\right)\right) \cdot \left(\frac{-23}{360} \cdot \left(x \cdot x\right)\right) \]
    9. lower-+.f64N/A

      \[\leadsto \left(\left(x \cdot x\right) \cdot \left(\frac{\frac{1}{6}}{\frac{-23}{360} \cdot \left(x \cdot x\right)} + 1\right)\right) \cdot \left(\frac{-23}{360} \cdot \left(x \cdot x\right)\right) \]
    10. associate-/r*N/A

      \[\leadsto \left(\left(x \cdot x\right) \cdot \left(\frac{\frac{\frac{1}{6}}{\frac{-23}{360}}}{x \cdot x} + 1\right)\right) \cdot \left(\frac{-23}{360} \cdot \left(x \cdot x\right)\right) \]
    11. lower-/.f64N/A

      \[\leadsto \left(\left(x \cdot x\right) \cdot \left(\frac{\frac{\frac{1}{6}}{\frac{-23}{360}}}{x \cdot x} + 1\right)\right) \cdot \left(\frac{-23}{360} \cdot \left(x \cdot x\right)\right) \]
    12. metadata-evalN/A

      \[\leadsto \left(\left(x \cdot x\right) \cdot \left(\frac{\frac{-60}{23}}{x \cdot x} + 1\right)\right) \cdot \left(\frac{-23}{360} \cdot \left(x \cdot x\right)\right) \]
    13. lower-*.f6449.4

      \[\leadsto \left(\left(x \cdot x\right) \cdot \left(\frac{-2.608695652173913}{x \cdot x} + 1\right)\right) \cdot \left(-0.06388888888888888 \cdot \color{blue}{\left(x \cdot x\right)}\right) \]
  8. Applied rewrites49.4%

    \[\leadsto \left(\left(x \cdot x\right) \cdot \left(\frac{-2.608695652173913}{x \cdot x} + 1\right)\right) \cdot \color{blue}{\left(-0.06388888888888888 \cdot \left(x \cdot x\right)\right)} \]
  9. Step-by-step derivation
    1. lift-*.f64N/A

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

      \[\leadsto \left(\frac{-23}{360} \cdot \left(x \cdot x\right)\right) \cdot \color{blue}{\left(\left(x \cdot x\right) \cdot \left(\frac{\frac{-60}{23}}{x \cdot x} + 1\right)\right)} \]
    3. lift-*.f64N/A

      \[\leadsto \left(\frac{-23}{360} \cdot \left(x \cdot x\right)\right) \cdot \left(\color{blue}{\left(x \cdot x\right)} \cdot \left(\frac{\frac{-60}{23}}{x \cdot x} + 1\right)\right) \]
    4. lift-*.f64N/A

      \[\leadsto \left(\frac{-23}{360} \cdot \left(x \cdot x\right)\right) \cdot \left(\left(x \cdot \color{blue}{x}\right) \cdot \left(\frac{\frac{-60}{23}}{x \cdot x} + 1\right)\right) \]
    5. associate-*r*N/A

      \[\leadsto \left(\left(\frac{-23}{360} \cdot x\right) \cdot x\right) \cdot \left(\color{blue}{\left(x \cdot x\right)} \cdot \left(\frac{\frac{-60}{23}}{x \cdot x} + 1\right)\right) \]
    6. associate-*l*N/A

      \[\leadsto \left(\frac{-23}{360} \cdot x\right) \cdot \color{blue}{\left(x \cdot \left(\left(x \cdot x\right) \cdot \left(\frac{\frac{-60}{23}}{x \cdot x} + 1\right)\right)\right)} \]
    7. lower-*.f64N/A

      \[\leadsto \left(\frac{-23}{360} \cdot x\right) \cdot \color{blue}{\left(x \cdot \left(\left(x \cdot x\right) \cdot \left(\frac{\frac{-60}{23}}{x \cdot x} + 1\right)\right)\right)} \]
    8. lower-*.f64N/A

      \[\leadsto \left(\frac{-23}{360} \cdot x\right) \cdot \left(\color{blue}{x} \cdot \left(\left(x \cdot x\right) \cdot \left(\frac{\frac{-60}{23}}{x \cdot x} + 1\right)\right)\right) \]
    9. lower-*.f6449.4

      \[\leadsto \left(-0.06388888888888888 \cdot x\right) \cdot \left(x \cdot \color{blue}{\left(\left(x \cdot x\right) \cdot \left(\frac{-2.608695652173913}{x \cdot x} + 1\right)\right)}\right) \]
    10. lift-*.f64N/A

      \[\leadsto \left(\frac{-23}{360} \cdot x\right) \cdot \left(x \cdot \left(\left(x \cdot x\right) \cdot \color{blue}{\left(\frac{\frac{-60}{23}}{x \cdot x} + 1\right)}\right)\right) \]
    11. *-commutativeN/A

      \[\leadsto \left(\frac{-23}{360} \cdot x\right) \cdot \left(x \cdot \left(\left(\frac{\frac{-60}{23}}{x \cdot x} + 1\right) \cdot \color{blue}{\left(x \cdot x\right)}\right)\right) \]
    12. lift-+.f64N/A

      \[\leadsto \left(\frac{-23}{360} \cdot x\right) \cdot \left(x \cdot \left(\left(\frac{\frac{-60}{23}}{x \cdot x} + 1\right) \cdot \left(\color{blue}{x} \cdot x\right)\right)\right) \]
    13. +-commutativeN/A

      \[\leadsto \left(\frac{-23}{360} \cdot x\right) \cdot \left(x \cdot \left(\left(1 + \frac{\frac{-60}{23}}{x \cdot x}\right) \cdot \left(\color{blue}{x} \cdot x\right)\right)\right) \]
    14. lift-/.f64N/A

      \[\leadsto \left(\frac{-23}{360} \cdot x\right) \cdot \left(x \cdot \left(\left(1 + \frac{\frac{-60}{23}}{x \cdot x}\right) \cdot \left(x \cdot x\right)\right)\right) \]
    15. sum-to-mult-revN/A

      \[\leadsto \left(\frac{-23}{360} \cdot x\right) \cdot \left(x \cdot \left(x \cdot x + \color{blue}{\frac{-60}{23}}\right)\right) \]
    16. lift-*.f64N/A

      \[\leadsto \left(\frac{-23}{360} \cdot x\right) \cdot \left(x \cdot \left(x \cdot x + \frac{-60}{23}\right)\right) \]
    17. lower-fma.f6499.2

      \[\leadsto \left(-0.06388888888888888 \cdot x\right) \cdot \left(x \cdot \mathsf{fma}\left(x, \color{blue}{x}, -2.608695652173913\right)\right) \]
  10. Applied rewrites99.2%

    \[\leadsto \left(-0.06388888888888888 \cdot x\right) \cdot \color{blue}{\left(x \cdot \mathsf{fma}\left(x, x, -2.608695652173913\right)\right)} \]
  11. Add Preprocessing

Alternative 10: 98.6% accurate, 10.7× speedup?

\[\begin{array}{l} \\ \left(0.16666666666666666 \cdot x\right) \cdot x \end{array} \]
(FPCore (x) :precision binary64 (* (* 0.16666666666666666 x) x))
double code(double x) {
	return (0.16666666666666666 * 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 = (0.16666666666666666d0 * x) * x
end function
public static double code(double x) {
	return (0.16666666666666666 * x) * x;
}
def code(x):
	return (0.16666666666666666 * x) * x
function code(x)
	return Float64(Float64(0.16666666666666666 * x) * x)
end
function tmp = code(x)
	tmp = (0.16666666666666666 * x) * x;
end
code[x_] := N[(N[(0.16666666666666666 * x), $MachinePrecision] * x), $MachinePrecision]
\begin{array}{l}

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

    \[\frac{x - \sin x}{\tan x} \]
  2. Taylor expanded in x around 0

    \[\leadsto \color{blue}{\frac{1}{6} \cdot {x}^{2}} \]
  3. Step-by-step derivation
    1. lower-*.f64N/A

      \[\leadsto \frac{1}{6} \cdot \color{blue}{{x}^{2}} \]
    2. lower-pow.f6498.6

      \[\leadsto 0.16666666666666666 \cdot {x}^{\color{blue}{2}} \]
  4. Applied rewrites98.6%

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

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

      \[\leadsto \frac{1}{6} \cdot {x}^{\color{blue}{2}} \]
    3. unpow2N/A

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

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

      \[\leadsto \left(\frac{1}{6} \cdot x\right) \cdot \color{blue}{x} \]
    6. lower-*.f6498.6

      \[\leadsto \left(0.16666666666666666 \cdot x\right) \cdot x \]
  6. Applied rewrites98.6%

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

Developer Target 1: 98.6% accurate, 10.7× speedup?

\[\begin{array}{l} \\ 0.16666666666666666 \cdot \left(x \cdot x\right) \end{array} \]
(FPCore (x) :precision binary64 (* 0.16666666666666666 (* x x)))
double code(double x) {
	return 0.16666666666666666 * (x * x);
}
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.16666666666666666d0 * (x * x)
end function
public static double code(double x) {
	return 0.16666666666666666 * (x * x);
}
def code(x):
	return 0.16666666666666666 * (x * x)
function code(x)
	return Float64(0.16666666666666666 * Float64(x * x))
end
function tmp = code(x)
	tmp = 0.16666666666666666 * (x * x);
end
code[x_] := N[(0.16666666666666666 * N[(x * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

Reproduce

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

  :alt
  (! :herbie-platform c (* 1/6 (* x x)))

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