Graphics.Rasterific.Svg.PathConverter:segmentToBezier from rasterific-svg-0.2.3.1, A

Percentage Accurate: 77.0% → 99.2%
Time: 3.0s
Alternatives: 7
Speedup: 1.0×

Specification

?
\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sin \left(x \cdot 0.5\right)\\ \frac{\left(\frac{8}{3} \cdot t\_0\right) \cdot t\_0}{\sin x} \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (let* ((t_0 (sin (* x 0.5)))) (/ (* (* (/ 8.0 3.0) t_0) t_0) (sin x))))
double code(double x) {
	double t_0 = sin((x * 0.5));
	return (((8.0 / 3.0) * t_0) * t_0) / sin(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
    real(8) :: t_0
    t_0 = sin((x * 0.5d0))
    code = (((8.0d0 / 3.0d0) * t_0) * t_0) / sin(x)
end function
public static double code(double x) {
	double t_0 = Math.sin((x * 0.5));
	return (((8.0 / 3.0) * t_0) * t_0) / Math.sin(x);
}
def code(x):
	t_0 = math.sin((x * 0.5))
	return (((8.0 / 3.0) * t_0) * t_0) / math.sin(x)
function code(x)
	t_0 = sin(Float64(x * 0.5))
	return Float64(Float64(Float64(Float64(8.0 / 3.0) * t_0) * t_0) / sin(x))
end
function tmp = code(x)
	t_0 = sin((x * 0.5));
	tmp = (((8.0 / 3.0) * t_0) * t_0) / sin(x);
end
code[x_] := Block[{t$95$0 = N[Sin[N[(x * 0.5), $MachinePrecision]], $MachinePrecision]}, N[(N[(N[(N[(8.0 / 3.0), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$0), $MachinePrecision] / N[Sin[x], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sin \left(x \cdot 0.5\right)\\
\frac{\left(\frac{8}{3} \cdot t\_0\right) \cdot t\_0}{\sin x}
\end{array}
\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 7 alternatives:

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

Initial Program: 77.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sin \left(x \cdot 0.5\right)\\ \frac{\left(\frac{8}{3} \cdot t\_0\right) \cdot t\_0}{\sin x} \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (let* ((t_0 (sin (* x 0.5)))) (/ (* (* (/ 8.0 3.0) t_0) t_0) (sin x))))
double code(double x) {
	double t_0 = sin((x * 0.5));
	return (((8.0 / 3.0) * t_0) * t_0) / sin(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
    real(8) :: t_0
    t_0 = sin((x * 0.5d0))
    code = (((8.0d0 / 3.0d0) * t_0) * t_0) / sin(x)
end function
public static double code(double x) {
	double t_0 = Math.sin((x * 0.5));
	return (((8.0 / 3.0) * t_0) * t_0) / Math.sin(x);
}
def code(x):
	t_0 = math.sin((x * 0.5))
	return (((8.0 / 3.0) * t_0) * t_0) / math.sin(x)
function code(x)
	t_0 = sin(Float64(x * 0.5))
	return Float64(Float64(Float64(Float64(8.0 / 3.0) * t_0) * t_0) / sin(x))
end
function tmp = code(x)
	t_0 = sin((x * 0.5));
	tmp = (((8.0 / 3.0) * t_0) * t_0) / sin(x);
end
code[x_] := Block[{t$95$0 = N[Sin[N[(x * 0.5), $MachinePrecision]], $MachinePrecision]}, N[(N[(N[(N[(8.0 / 3.0), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$0), $MachinePrecision] / N[Sin[x], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sin \left(x \cdot 0.5\right)\\
\frac{\left(\frac{8}{3} \cdot t\_0\right) \cdot t\_0}{\sin x}
\end{array}
\end{array}

Alternative 1: 99.2% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sin \left(0.5 \cdot x\right)\\ \frac{t\_0}{\sin x} \cdot \left(t\_0 \cdot 2.6666666666666665\right) \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (let* ((t_0 (sin (* 0.5 x)))) (* (/ t_0 (sin x)) (* t_0 2.6666666666666665))))
double code(double x) {
	double t_0 = sin((0.5 * x));
	return (t_0 / sin(x)) * (t_0 * 2.6666666666666665);
}
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) :: t_0
    t_0 = sin((0.5d0 * x))
    code = (t_0 / sin(x)) * (t_0 * 2.6666666666666665d0)
end function
public static double code(double x) {
	double t_0 = Math.sin((0.5 * x));
	return (t_0 / Math.sin(x)) * (t_0 * 2.6666666666666665);
}
def code(x):
	t_0 = math.sin((0.5 * x))
	return (t_0 / math.sin(x)) * (t_0 * 2.6666666666666665)
function code(x)
	t_0 = sin(Float64(0.5 * x))
	return Float64(Float64(t_0 / sin(x)) * Float64(t_0 * 2.6666666666666665))
end
function tmp = code(x)
	t_0 = sin((0.5 * x));
	tmp = (t_0 / sin(x)) * (t_0 * 2.6666666666666665);
end
code[x_] := Block[{t$95$0 = N[Sin[N[(0.5 * x), $MachinePrecision]], $MachinePrecision]}, N[(N[(t$95$0 / N[Sin[x], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * 2.6666666666666665), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sin \left(0.5 \cdot x\right)\\
\frac{t\_0}{\sin x} \cdot \left(t\_0 \cdot 2.6666666666666665\right)
\end{array}
\end{array}
Derivation
  1. Initial program 77.0%

    \[\frac{\left(\frac{8}{3} \cdot \sin \left(x \cdot 0.5\right)\right) \cdot \sin \left(x \cdot 0.5\right)}{\sin x} \]
  2. Step-by-step derivation
    1. lift-/.f64N/A

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

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

      \[\leadsto \frac{\color{blue}{\left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right)} \cdot \sin \left(x \cdot \frac{1}{2}\right)}{\sin x} \]
    4. lift-/.f64N/A

      \[\leadsto \frac{\left(\color{blue}{\frac{8}{3}} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right) \cdot \sin \left(x \cdot \frac{1}{2}\right)}{\sin x} \]
    5. lift-*.f64N/A

      \[\leadsto \frac{\left(\frac{8}{3} \cdot \sin \color{blue}{\left(x \cdot \frac{1}{2}\right)}\right) \cdot \sin \left(x \cdot \frac{1}{2}\right)}{\sin x} \]
    6. lift-sin.f64N/A

      \[\leadsto \frac{\left(\frac{8}{3} \cdot \color{blue}{\sin \left(x \cdot \frac{1}{2}\right)}\right) \cdot \sin \left(x \cdot \frac{1}{2}\right)}{\sin x} \]
    7. lift-*.f64N/A

      \[\leadsto \frac{\left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right) \cdot \sin \color{blue}{\left(x \cdot \frac{1}{2}\right)}}{\sin x} \]
    8. lift-sin.f64N/A

      \[\leadsto \frac{\left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right) \cdot \color{blue}{\sin \left(x \cdot \frac{1}{2}\right)}}{\sin x} \]
    9. lift-sin.f64N/A

      \[\leadsto \frac{\left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right) \cdot \sin \left(x \cdot \frac{1}{2}\right)}{\color{blue}{\sin x}} \]
    10. associate-/l*N/A

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

      \[\leadsto \color{blue}{\frac{\sin \left(x \cdot \frac{1}{2}\right)}{\sin x} \cdot \left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right)} \]
    12. lower-*.f64N/A

      \[\leadsto \color{blue}{\frac{\sin \left(x \cdot \frac{1}{2}\right)}{\sin x} \cdot \left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right)} \]
    13. lower-/.f64N/A

      \[\leadsto \color{blue}{\frac{\sin \left(x \cdot \frac{1}{2}\right)}{\sin x}} \cdot \left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right) \]
    14. lift-sin.f64N/A

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

      \[\leadsto \frac{\sin \color{blue}{\left(\frac{1}{2} \cdot x\right)}}{\sin x} \cdot \left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right) \]
    16. lower-*.f64N/A

      \[\leadsto \frac{\sin \color{blue}{\left(\frac{1}{2} \cdot x\right)}}{\sin x} \cdot \left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right) \]
    17. lift-sin.f64N/A

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

      \[\leadsto \frac{\sin \left(\frac{1}{2} \cdot x\right)}{\sin x} \cdot \color{blue}{\left(\sin \left(x \cdot \frac{1}{2}\right) \cdot \frac{8}{3}\right)} \]
    19. lower-*.f64N/A

      \[\leadsto \frac{\sin \left(\frac{1}{2} \cdot x\right)}{\sin x} \cdot \color{blue}{\left(\sin \left(x \cdot \frac{1}{2}\right) \cdot \frac{8}{3}\right)} \]
  3. Applied rewrites99.2%

    \[\leadsto \color{blue}{\frac{\sin \left(0.5 \cdot x\right)}{\sin x} \cdot \left(\sin \left(0.5 \cdot x\right) \cdot 2.6666666666666665\right)} \]
  4. Add Preprocessing

Alternative 2: 75.4% accurate, 1.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 2 \cdot 10^{-5}:\\ \;\;\;\;\left(\mathsf{fma}\left(0.020833333333333332, x \cdot x, 0.25\right) \cdot x\right) \cdot 2.6666666666666665\\ \mathbf{else}:\\ \;\;\;\;\frac{{\sin \left(0.5 \cdot x\right)}^{2}}{\sin x} \cdot 2.6666666666666665\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= x 2e-5)
   (* (* (fma 0.020833333333333332 (* x x) 0.25) x) 2.6666666666666665)
   (* (/ (pow (sin (* 0.5 x)) 2.0) (sin x)) 2.6666666666666665)))
double code(double x) {
	double tmp;
	if (x <= 2e-5) {
		tmp = (fma(0.020833333333333332, (x * x), 0.25) * x) * 2.6666666666666665;
	} else {
		tmp = (pow(sin((0.5 * x)), 2.0) / sin(x)) * 2.6666666666666665;
	}
	return tmp;
}
function code(x)
	tmp = 0.0
	if (x <= 2e-5)
		tmp = Float64(Float64(fma(0.020833333333333332, Float64(x * x), 0.25) * x) * 2.6666666666666665);
	else
		tmp = Float64(Float64((sin(Float64(0.5 * x)) ^ 2.0) / sin(x)) * 2.6666666666666665);
	end
	return tmp
end
code[x_] := If[LessEqual[x, 2e-5], N[(N[(N[(0.020833333333333332 * N[(x * x), $MachinePrecision] + 0.25), $MachinePrecision] * x), $MachinePrecision] * 2.6666666666666665), $MachinePrecision], N[(N[(N[Power[N[Sin[N[(0.5 * x), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] / N[Sin[x], $MachinePrecision]), $MachinePrecision] * 2.6666666666666665), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 2 \cdot 10^{-5}:\\
\;\;\;\;\left(\mathsf{fma}\left(0.020833333333333332, x \cdot x, 0.25\right) \cdot x\right) \cdot 2.6666666666666665\\

\mathbf{else}:\\
\;\;\;\;\frac{{\sin \left(0.5 \cdot x\right)}^{2}}{\sin x} \cdot 2.6666666666666665\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 2.00000000000000016e-5

    1. Initial program 69.3%

      \[\frac{\left(\frac{8}{3} \cdot \sin \left(x \cdot 0.5\right)\right) \cdot \sin \left(x \cdot 0.5\right)}{\sin x} \]
    2. Step-by-step derivation
      1. lift-/.f64N/A

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

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

        \[\leadsto \frac{\color{blue}{\left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right)} \cdot \sin \left(x \cdot \frac{1}{2}\right)}{\sin x} \]
      4. lift-/.f64N/A

        \[\leadsto \frac{\left(\color{blue}{\frac{8}{3}} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right) \cdot \sin \left(x \cdot \frac{1}{2}\right)}{\sin x} \]
      5. lift-*.f64N/A

        \[\leadsto \frac{\left(\frac{8}{3} \cdot \sin \color{blue}{\left(x \cdot \frac{1}{2}\right)}\right) \cdot \sin \left(x \cdot \frac{1}{2}\right)}{\sin x} \]
      6. lift-sin.f64N/A

        \[\leadsto \frac{\left(\frac{8}{3} \cdot \color{blue}{\sin \left(x \cdot \frac{1}{2}\right)}\right) \cdot \sin \left(x \cdot \frac{1}{2}\right)}{\sin x} \]
      7. lift-*.f64N/A

        \[\leadsto \frac{\left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right) \cdot \sin \color{blue}{\left(x \cdot \frac{1}{2}\right)}}{\sin x} \]
      8. lift-sin.f64N/A

        \[\leadsto \frac{\left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right) \cdot \color{blue}{\sin \left(x \cdot \frac{1}{2}\right)}}{\sin x} \]
      9. lift-sin.f64N/A

        \[\leadsto \frac{\left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right) \cdot \sin \left(x \cdot \frac{1}{2}\right)}{\color{blue}{\sin x}} \]
      10. associate-/l*N/A

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

        \[\leadsto \color{blue}{\frac{\sin \left(x \cdot \frac{1}{2}\right)}{\sin x} \cdot \left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right)} \]
      12. lower-*.f64N/A

        \[\leadsto \color{blue}{\frac{\sin \left(x \cdot \frac{1}{2}\right)}{\sin x} \cdot \left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right)} \]
      13. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{\sin \left(x \cdot \frac{1}{2}\right)}{\sin x}} \cdot \left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right) \]
      14. lift-sin.f64N/A

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

        \[\leadsto \frac{\sin \color{blue}{\left(\frac{1}{2} \cdot x\right)}}{\sin x} \cdot \left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right) \]
      16. lower-*.f64N/A

        \[\leadsto \frac{\sin \color{blue}{\left(\frac{1}{2} \cdot x\right)}}{\sin x} \cdot \left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right) \]
      17. lift-sin.f64N/A

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

        \[\leadsto \frac{\sin \left(\frac{1}{2} \cdot x\right)}{\sin x} \cdot \color{blue}{\left(\sin \left(x \cdot \frac{1}{2}\right) \cdot \frac{8}{3}\right)} \]
      19. lower-*.f64N/A

        \[\leadsto \frac{\sin \left(\frac{1}{2} \cdot x\right)}{\sin x} \cdot \color{blue}{\left(\sin \left(x \cdot \frac{1}{2}\right) \cdot \frac{8}{3}\right)} \]
    3. Applied rewrites99.3%

      \[\leadsto \color{blue}{\frac{\sin \left(0.5 \cdot x\right)}{\sin x} \cdot \left(\sin \left(0.5 \cdot x\right) \cdot 2.6666666666666665\right)} \]
    4. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \color{blue}{\frac{\sin \left(\frac{1}{2} \cdot x\right)}{\sin x} \cdot \left(\sin \left(\frac{1}{2} \cdot x\right) \cdot \frac{8}{3}\right)} \]
      2. lift-/.f64N/A

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

        \[\leadsto \frac{\sin \color{blue}{\left(\frac{1}{2} \cdot x\right)}}{\sin x} \cdot \left(\sin \left(\frac{1}{2} \cdot x\right) \cdot \frac{8}{3}\right) \]
      4. lift-sin.f64N/A

        \[\leadsto \frac{\color{blue}{\sin \left(\frac{1}{2} \cdot x\right)}}{\sin x} \cdot \left(\sin \left(\frac{1}{2} \cdot x\right) \cdot \frac{8}{3}\right) \]
      5. lift-sin.f64N/A

        \[\leadsto \frac{\sin \left(\frac{1}{2} \cdot x\right)}{\color{blue}{\sin x}} \cdot \left(\sin \left(\frac{1}{2} \cdot x\right) \cdot \frac{8}{3}\right) \]
      6. lift-*.f64N/A

        \[\leadsto \frac{\sin \left(\frac{1}{2} \cdot x\right)}{\sin x} \cdot \color{blue}{\left(\sin \left(\frac{1}{2} \cdot x\right) \cdot \frac{8}{3}\right)} \]
      7. lift-*.f64N/A

        \[\leadsto \frac{\sin \left(\frac{1}{2} \cdot x\right)}{\sin x} \cdot \left(\sin \color{blue}{\left(\frac{1}{2} \cdot x\right)} \cdot \frac{8}{3}\right) \]
      8. lift-sin.f64N/A

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

        \[\leadsto \color{blue}{\left(\frac{\sin \left(\frac{1}{2} \cdot x\right)}{\sin x} \cdot \sin \left(\frac{1}{2} \cdot x\right)\right) \cdot \frac{8}{3}} \]
      10. associate-*l/N/A

        \[\leadsto \color{blue}{\frac{\sin \left(\frac{1}{2} \cdot x\right) \cdot \sin \left(\frac{1}{2} \cdot x\right)}{\sin x}} \cdot \frac{8}{3} \]
      11. unpow2N/A

        \[\leadsto \frac{\color{blue}{{\sin \left(\frac{1}{2} \cdot x\right)}^{2}}}{\sin x} \cdot \frac{8}{3} \]
      12. lower-*.f64N/A

        \[\leadsto \color{blue}{\frac{{\sin \left(\frac{1}{2} \cdot x\right)}^{2}}{\sin x} \cdot \frac{8}{3}} \]
    5. Applied rewrites36.9%

      \[\leadsto \color{blue}{\frac{0.5 - 0.5 \cdot \cos \left(2 \cdot \left(x \cdot 0.5\right)\right)}{\sin x} \cdot 2.6666666666666665} \]
    6. Taylor expanded in x around 0

      \[\leadsto \color{blue}{\left(x \cdot \left(\frac{1}{4} + \frac{1}{48} \cdot {x}^{2}\right)\right)} \cdot \frac{8}{3} \]
    7. Step-by-step derivation
      1. *-commutativeN/A

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

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

        \[\leadsto \left(\left(\frac{1}{48} \cdot {x}^{2} + \frac{1}{4}\right) \cdot x\right) \cdot \frac{8}{3} \]
      4. lower-fma.f64N/A

        \[\leadsto \left(\mathsf{fma}\left(\frac{1}{48}, {x}^{2}, \frac{1}{4}\right) \cdot x\right) \cdot \frac{8}{3} \]
      5. pow2N/A

        \[\leadsto \left(\mathsf{fma}\left(\frac{1}{48}, x \cdot x, \frac{1}{4}\right) \cdot x\right) \cdot \frac{8}{3} \]
      6. lift-*.f6467.2

        \[\leadsto \left(\mathsf{fma}\left(0.020833333333333332, x \cdot x, 0.25\right) \cdot x\right) \cdot 2.6666666666666665 \]
    8. Applied rewrites67.2%

      \[\leadsto \color{blue}{\left(\mathsf{fma}\left(0.020833333333333332, x \cdot x, 0.25\right) \cdot x\right)} \cdot 2.6666666666666665 \]

    if 2.00000000000000016e-5 < x

    1. Initial program 99.0%

      \[\frac{\left(\frac{8}{3} \cdot \sin \left(x \cdot 0.5\right)\right) \cdot \sin \left(x \cdot 0.5\right)}{\sin x} \]
    2. Step-by-step derivation
      1. lift-/.f64N/A

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

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

        \[\leadsto \frac{\color{blue}{\left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right)} \cdot \sin \left(x \cdot \frac{1}{2}\right)}{\sin x} \]
      4. lift-/.f64N/A

        \[\leadsto \frac{\left(\color{blue}{\frac{8}{3}} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right) \cdot \sin \left(x \cdot \frac{1}{2}\right)}{\sin x} \]
      5. lift-*.f64N/A

        \[\leadsto \frac{\left(\frac{8}{3} \cdot \sin \color{blue}{\left(x \cdot \frac{1}{2}\right)}\right) \cdot \sin \left(x \cdot \frac{1}{2}\right)}{\sin x} \]
      6. lift-sin.f64N/A

        \[\leadsto \frac{\left(\frac{8}{3} \cdot \color{blue}{\sin \left(x \cdot \frac{1}{2}\right)}\right) \cdot \sin \left(x \cdot \frac{1}{2}\right)}{\sin x} \]
      7. lift-*.f64N/A

        \[\leadsto \frac{\left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right) \cdot \sin \color{blue}{\left(x \cdot \frac{1}{2}\right)}}{\sin x} \]
      8. lift-sin.f64N/A

        \[\leadsto \frac{\left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right) \cdot \color{blue}{\sin \left(x \cdot \frac{1}{2}\right)}}{\sin x} \]
      9. lift-sin.f64N/A

        \[\leadsto \frac{\left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right) \cdot \sin \left(x \cdot \frac{1}{2}\right)}{\color{blue}{\sin x}} \]
      10. associate-/l*N/A

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

        \[\leadsto \color{blue}{\frac{\sin \left(x \cdot \frac{1}{2}\right)}{\sin x} \cdot \left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right)} \]
      12. lower-*.f64N/A

        \[\leadsto \color{blue}{\frac{\sin \left(x \cdot \frac{1}{2}\right)}{\sin x} \cdot \left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right)} \]
      13. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{\sin \left(x \cdot \frac{1}{2}\right)}{\sin x}} \cdot \left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right) \]
      14. lift-sin.f64N/A

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

        \[\leadsto \frac{\sin \color{blue}{\left(\frac{1}{2} \cdot x\right)}}{\sin x} \cdot \left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right) \]
      16. lower-*.f64N/A

        \[\leadsto \frac{\sin \color{blue}{\left(\frac{1}{2} \cdot x\right)}}{\sin x} \cdot \left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right) \]
      17. lift-sin.f64N/A

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

        \[\leadsto \frac{\sin \left(\frac{1}{2} \cdot x\right)}{\sin x} \cdot \color{blue}{\left(\sin \left(x \cdot \frac{1}{2}\right) \cdot \frac{8}{3}\right)} \]
      19. lower-*.f64N/A

        \[\leadsto \frac{\sin \left(\frac{1}{2} \cdot x\right)}{\sin x} \cdot \color{blue}{\left(\sin \left(x \cdot \frac{1}{2}\right) \cdot \frac{8}{3}\right)} \]
    3. Applied rewrites99.0%

      \[\leadsto \color{blue}{\frac{\sin \left(0.5 \cdot x\right)}{\sin x} \cdot \left(\sin \left(0.5 \cdot x\right) \cdot 2.6666666666666665\right)} \]
    4. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \color{blue}{\frac{\sin \left(\frac{1}{2} \cdot x\right)}{\sin x} \cdot \left(\sin \left(\frac{1}{2} \cdot x\right) \cdot \frac{8}{3}\right)} \]
      2. lift-/.f64N/A

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

        \[\leadsto \frac{\sin \color{blue}{\left(\frac{1}{2} \cdot x\right)}}{\sin x} \cdot \left(\sin \left(\frac{1}{2} \cdot x\right) \cdot \frac{8}{3}\right) \]
      4. lift-sin.f64N/A

        \[\leadsto \frac{\color{blue}{\sin \left(\frac{1}{2} \cdot x\right)}}{\sin x} \cdot \left(\sin \left(\frac{1}{2} \cdot x\right) \cdot \frac{8}{3}\right) \]
      5. lift-sin.f64N/A

        \[\leadsto \frac{\sin \left(\frac{1}{2} \cdot x\right)}{\color{blue}{\sin x}} \cdot \left(\sin \left(\frac{1}{2} \cdot x\right) \cdot \frac{8}{3}\right) \]
      6. lift-*.f64N/A

        \[\leadsto \frac{\sin \left(\frac{1}{2} \cdot x\right)}{\sin x} \cdot \color{blue}{\left(\sin \left(\frac{1}{2} \cdot x\right) \cdot \frac{8}{3}\right)} \]
      7. lift-*.f64N/A

        \[\leadsto \frac{\sin \left(\frac{1}{2} \cdot x\right)}{\sin x} \cdot \left(\sin \color{blue}{\left(\frac{1}{2} \cdot x\right)} \cdot \frac{8}{3}\right) \]
      8. lift-sin.f64N/A

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

        \[\leadsto \color{blue}{\left(\frac{\sin \left(\frac{1}{2} \cdot x\right)}{\sin x} \cdot \sin \left(\frac{1}{2} \cdot x\right)\right) \cdot \frac{8}{3}} \]
      10. associate-*l/N/A

        \[\leadsto \color{blue}{\frac{\sin \left(\frac{1}{2} \cdot x\right) \cdot \sin \left(\frac{1}{2} \cdot x\right)}{\sin x}} \cdot \frac{8}{3} \]
      11. unpow2N/A

        \[\leadsto \frac{\color{blue}{{\sin \left(\frac{1}{2} \cdot x\right)}^{2}}}{\sin x} \cdot \frac{8}{3} \]
      12. lower-*.f64N/A

        \[\leadsto \color{blue}{\frac{{\sin \left(\frac{1}{2} \cdot x\right)}^{2}}{\sin x} \cdot \frac{8}{3}} \]
    5. Applied rewrites98.1%

      \[\leadsto \color{blue}{\frac{0.5 - 0.5 \cdot \cos \left(2 \cdot \left(x \cdot 0.5\right)\right)}{\sin x} \cdot 2.6666666666666665} \]
    6. Step-by-step derivation
      1. lift--.f64N/A

        \[\leadsto \frac{\color{blue}{\frac{1}{2} - \frac{1}{2} \cdot \cos \left(2 \cdot \left(x \cdot \frac{1}{2}\right)\right)}}{\sin x} \cdot \frac{8}{3} \]
      2. lift-*.f64N/A

        \[\leadsto \frac{\frac{1}{2} - \color{blue}{\frac{1}{2} \cdot \cos \left(2 \cdot \left(x \cdot \frac{1}{2}\right)\right)}}{\sin x} \cdot \frac{8}{3} \]
      3. lift-cos.f64N/A

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

        \[\leadsto \frac{\frac{1}{2} - \frac{1}{2} \cdot \cos \left(2 \cdot \color{blue}{\left(x \cdot \frac{1}{2}\right)}\right)}{\sin x} \cdot \frac{8}{3} \]
      5. lift-*.f64N/A

        \[\leadsto \frac{\frac{1}{2} - \frac{1}{2} \cdot \cos \color{blue}{\left(2 \cdot \left(x \cdot \frac{1}{2}\right)\right)}}{\sin x} \cdot \frac{8}{3} \]
      6. sqr-sin-a-revN/A

        \[\leadsto \frac{\color{blue}{\sin \left(x \cdot \frac{1}{2}\right) \cdot \sin \left(x \cdot \frac{1}{2}\right)}}{\sin x} \cdot \frac{8}{3} \]
      7. pow2N/A

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

        \[\leadsto \frac{\color{blue}{{\sin \left(x \cdot \frac{1}{2}\right)}^{2}}}{\sin x} \cdot \frac{8}{3} \]
      9. lift-sin.f64N/A

        \[\leadsto \frac{{\color{blue}{\sin \left(x \cdot \frac{1}{2}\right)}}^{2}}{\sin x} \cdot \frac{8}{3} \]
      10. *-commutativeN/A

        \[\leadsto \frac{{\sin \color{blue}{\left(\frac{1}{2} \cdot x\right)}}^{2}}{\sin x} \cdot \frac{8}{3} \]
      11. lower-*.f6499.0

        \[\leadsto \frac{{\sin \color{blue}{\left(0.5 \cdot x\right)}}^{2}}{\sin x} \cdot 2.6666666666666665 \]
    7. Applied rewrites99.0%

      \[\leadsto \frac{\color{blue}{{\sin \left(0.5 \cdot x\right)}^{2}}}{\sin x} \cdot 2.6666666666666665 \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 3: 75.3% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 0.023:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.017361111111111112, x \cdot x, 0.16666666666666666\right), x \cdot x, 1.3333333333333333\right) \cdot \sin \left(x \cdot 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 - 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot x\right)\right)\right) \cdot \frac{2.6666666666666665}{\sin x}\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= x 0.023)
   (*
    (fma
     (fma 0.017361111111111112 (* x x) 0.16666666666666666)
     (* x x)
     1.3333333333333333)
    (sin (* x 0.5)))
   (* (- 0.5 (* 0.5 (cos (* 2.0 (* 0.5 x))))) (/ 2.6666666666666665 (sin x)))))
double code(double x) {
	double tmp;
	if (x <= 0.023) {
		tmp = fma(fma(0.017361111111111112, (x * x), 0.16666666666666666), (x * x), 1.3333333333333333) * sin((x * 0.5));
	} else {
		tmp = (0.5 - (0.5 * cos((2.0 * (0.5 * x))))) * (2.6666666666666665 / sin(x));
	}
	return tmp;
}
function code(x)
	tmp = 0.0
	if (x <= 0.023)
		tmp = Float64(fma(fma(0.017361111111111112, Float64(x * x), 0.16666666666666666), Float64(x * x), 1.3333333333333333) * sin(Float64(x * 0.5)));
	else
		tmp = Float64(Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * x))))) * Float64(2.6666666666666665 / sin(x)));
	end
	return tmp
end
code[x_] := If[LessEqual[x, 0.023], N[(N[(N[(0.017361111111111112 * N[(x * x), $MachinePrecision] + 0.16666666666666666), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.3333333333333333), $MachinePrecision] * N[Sin[N[(x * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * N[(0.5 * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(2.6666666666666665 / N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.023:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.017361111111111112, x \cdot x, 0.16666666666666666\right), x \cdot x, 1.3333333333333333\right) \cdot \sin \left(x \cdot 0.5\right)\\

\mathbf{else}:\\
\;\;\;\;\left(0.5 - 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot x\right)\right)\right) \cdot \frac{2.6666666666666665}{\sin x}\\


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

    1. Initial program 69.4%

      \[\frac{\left(\frac{8}{3} \cdot \sin \left(x \cdot 0.5\right)\right) \cdot \sin \left(x \cdot 0.5\right)}{\sin x} \]
    2. Step-by-step derivation
      1. lift-/.f64N/A

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

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

        \[\leadsto \frac{\color{blue}{\left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right)} \cdot \sin \left(x \cdot \frac{1}{2}\right)}{\sin x} \]
      4. lift-/.f64N/A

        \[\leadsto \frac{\left(\color{blue}{\frac{8}{3}} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right) \cdot \sin \left(x \cdot \frac{1}{2}\right)}{\sin x} \]
      5. lift-*.f64N/A

        \[\leadsto \frac{\left(\frac{8}{3} \cdot \sin \color{blue}{\left(x \cdot \frac{1}{2}\right)}\right) \cdot \sin \left(x \cdot \frac{1}{2}\right)}{\sin x} \]
      6. lift-sin.f64N/A

        \[\leadsto \frac{\left(\frac{8}{3} \cdot \color{blue}{\sin \left(x \cdot \frac{1}{2}\right)}\right) \cdot \sin \left(x \cdot \frac{1}{2}\right)}{\sin x} \]
      7. lift-*.f64N/A

        \[\leadsto \frac{\left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right) \cdot \sin \color{blue}{\left(x \cdot \frac{1}{2}\right)}}{\sin x} \]
      8. lift-sin.f64N/A

        \[\leadsto \frac{\left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right) \cdot \color{blue}{\sin \left(x \cdot \frac{1}{2}\right)}}{\sin x} \]
      9. lift-sin.f64N/A

        \[\leadsto \frac{\left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right) \cdot \sin \left(x \cdot \frac{1}{2}\right)}{\color{blue}{\sin x}} \]
      10. associate-/l*N/A

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

        \[\leadsto \color{blue}{\frac{\sin \left(x \cdot \frac{1}{2}\right)}{\sin x} \cdot \left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right)} \]
      12. lower-*.f64N/A

        \[\leadsto \color{blue}{\frac{\sin \left(x \cdot \frac{1}{2}\right)}{\sin x} \cdot \left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right)} \]
      13. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{\sin \left(x \cdot \frac{1}{2}\right)}{\sin x}} \cdot \left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right) \]
      14. lift-sin.f64N/A

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

        \[\leadsto \frac{\sin \color{blue}{\left(\frac{1}{2} \cdot x\right)}}{\sin x} \cdot \left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right) \]
      16. lower-*.f64N/A

        \[\leadsto \frac{\sin \color{blue}{\left(\frac{1}{2} \cdot x\right)}}{\sin x} \cdot \left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right) \]
      17. lift-sin.f64N/A

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

        \[\leadsto \frac{\sin \left(\frac{1}{2} \cdot x\right)}{\sin x} \cdot \color{blue}{\left(\sin \left(x \cdot \frac{1}{2}\right) \cdot \frac{8}{3}\right)} \]
      19. lower-*.f64N/A

        \[\leadsto \frac{\sin \left(\frac{1}{2} \cdot x\right)}{\sin x} \cdot \color{blue}{\left(\sin \left(x \cdot \frac{1}{2}\right) \cdot \frac{8}{3}\right)} \]
    3. Applied rewrites99.3%

      \[\leadsto \color{blue}{\frac{\sin \left(0.5 \cdot x\right)}{\sin x} \cdot \left(\sin \left(0.5 \cdot x\right) \cdot 2.6666666666666665\right)} \]
    4. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \color{blue}{\frac{\sin \left(\frac{1}{2} \cdot x\right)}{\sin x} \cdot \left(\sin \left(\frac{1}{2} \cdot x\right) \cdot \frac{8}{3}\right)} \]
      2. lift-/.f64N/A

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

        \[\leadsto \frac{\sin \color{blue}{\left(\frac{1}{2} \cdot x\right)}}{\sin x} \cdot \left(\sin \left(\frac{1}{2} \cdot x\right) \cdot \frac{8}{3}\right) \]
      4. lift-sin.f64N/A

        \[\leadsto \frac{\color{blue}{\sin \left(\frac{1}{2} \cdot x\right)}}{\sin x} \cdot \left(\sin \left(\frac{1}{2} \cdot x\right) \cdot \frac{8}{3}\right) \]
      5. lift-sin.f64N/A

        \[\leadsto \frac{\sin \left(\frac{1}{2} \cdot x\right)}{\color{blue}{\sin x}} \cdot \left(\sin \left(\frac{1}{2} \cdot x\right) \cdot \frac{8}{3}\right) \]
      6. lift-*.f64N/A

        \[\leadsto \frac{\sin \left(\frac{1}{2} \cdot x\right)}{\sin x} \cdot \color{blue}{\left(\sin \left(\frac{1}{2} \cdot x\right) \cdot \frac{8}{3}\right)} \]
      7. lift-*.f64N/A

        \[\leadsto \frac{\sin \left(\frac{1}{2} \cdot x\right)}{\sin x} \cdot \left(\sin \color{blue}{\left(\frac{1}{2} \cdot x\right)} \cdot \frac{8}{3}\right) \]
      8. lift-sin.f64N/A

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

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

        \[\leadsto \color{blue}{\left(\frac{\sin \left(\frac{1}{2} \cdot x\right)}{\sin x} \cdot \frac{8}{3}\right) \cdot \sin \left(\frac{1}{2} \cdot x\right)} \]
      11. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(\frac{\sin \left(\frac{1}{2} \cdot x\right)}{\sin x} \cdot \frac{8}{3}\right) \cdot \sin \left(\frac{1}{2} \cdot x\right)} \]
    5. Applied rewrites99.3%

      \[\leadsto \color{blue}{\left(\frac{\sin \left(x \cdot 0.5\right)}{\sin x} \cdot 2.6666666666666665\right) \cdot \sin \left(x \cdot 0.5\right)} \]
    6. Taylor expanded in x around 0

      \[\leadsto \color{blue}{\left(\frac{4}{3} + {x}^{2} \cdot \left(\frac{1}{6} + \frac{5}{288} \cdot {x}^{2}\right)\right)} \cdot \sin \left(x \cdot \frac{1}{2}\right) \]
    7. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \left({x}^{2} \cdot \left(\frac{1}{6} + \frac{5}{288} \cdot {x}^{2}\right) + \color{blue}{\frac{4}{3}}\right) \cdot \sin \left(x \cdot \frac{1}{2}\right) \]
      2. *-commutativeN/A

        \[\leadsto \left(\left(\frac{1}{6} + \frac{5}{288} \cdot {x}^{2}\right) \cdot {x}^{2} + \frac{4}{3}\right) \cdot \sin \left(x \cdot \frac{1}{2}\right) \]
      3. lower-fma.f64N/A

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

        \[\leadsto \mathsf{fma}\left(\frac{5}{288} \cdot {x}^{2} + \frac{1}{6}, {\color{blue}{x}}^{2}, \frac{4}{3}\right) \cdot \sin \left(x \cdot \frac{1}{2}\right) \]
      5. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\frac{5}{288}, {x}^{2}, \frac{1}{6}\right), {\color{blue}{x}}^{2}, \frac{4}{3}\right) \cdot \sin \left(x \cdot \frac{1}{2}\right) \]
      6. pow2N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\frac{5}{288}, x \cdot x, \frac{1}{6}\right), {x}^{2}, \frac{4}{3}\right) \cdot \sin \left(x \cdot \frac{1}{2}\right) \]
      7. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\frac{5}{288}, x \cdot x, \frac{1}{6}\right), {x}^{2}, \frac{4}{3}\right) \cdot \sin \left(x \cdot \frac{1}{2}\right) \]
      8. pow2N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\frac{5}{288}, x \cdot x, \frac{1}{6}\right), x \cdot \color{blue}{x}, \frac{4}{3}\right) \cdot \sin \left(x \cdot \frac{1}{2}\right) \]
      9. lift-*.f6467.3

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(0.017361111111111112, x \cdot x, 0.16666666666666666\right), x \cdot \color{blue}{x}, 1.3333333333333333\right) \cdot \sin \left(x \cdot 0.5\right) \]
    8. Applied rewrites67.3%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(0.017361111111111112, x \cdot x, 0.16666666666666666\right), x \cdot x, 1.3333333333333333\right)} \cdot \sin \left(x \cdot 0.5\right) \]

    if 0.023 < x

    1. Initial program 99.0%

      \[\frac{\left(\frac{8}{3} \cdot \sin \left(x \cdot 0.5\right)\right) \cdot \sin \left(x \cdot 0.5\right)}{\sin x} \]
    2. Step-by-step derivation
      1. lift-/.f64N/A

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

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

        \[\leadsto \frac{\color{blue}{\left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right)} \cdot \sin \left(x \cdot \frac{1}{2}\right)}{\sin x} \]
      4. lift-/.f64N/A

        \[\leadsto \frac{\left(\color{blue}{\frac{8}{3}} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right) \cdot \sin \left(x \cdot \frac{1}{2}\right)}{\sin x} \]
      5. lift-*.f64N/A

        \[\leadsto \frac{\left(\frac{8}{3} \cdot \sin \color{blue}{\left(x \cdot \frac{1}{2}\right)}\right) \cdot \sin \left(x \cdot \frac{1}{2}\right)}{\sin x} \]
      6. lift-sin.f64N/A

        \[\leadsto \frac{\left(\frac{8}{3} \cdot \color{blue}{\sin \left(x \cdot \frac{1}{2}\right)}\right) \cdot \sin \left(x \cdot \frac{1}{2}\right)}{\sin x} \]
      7. lift-*.f64N/A

        \[\leadsto \frac{\left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right) \cdot \sin \color{blue}{\left(x \cdot \frac{1}{2}\right)}}{\sin x} \]
      8. lift-sin.f64N/A

        \[\leadsto \frac{\left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right) \cdot \color{blue}{\sin \left(x \cdot \frac{1}{2}\right)}}{\sin x} \]
      9. associate-*l*N/A

        \[\leadsto \frac{\color{blue}{\frac{8}{3} \cdot \left(\sin \left(x \cdot \frac{1}{2}\right) \cdot \sin \left(x \cdot \frac{1}{2}\right)\right)}}{\sin x} \]
      10. pow2N/A

        \[\leadsto \frac{\frac{8}{3} \cdot \color{blue}{{\sin \left(x \cdot \frac{1}{2}\right)}^{2}}}{\sin x} \]
      11. *-commutativeN/A

        \[\leadsto \frac{\frac{8}{3} \cdot {\sin \color{blue}{\left(\frac{1}{2} \cdot x\right)}}^{2}}{\sin x} \]
      12. lift-sin.f64N/A

        \[\leadsto \frac{\frac{8}{3} \cdot {\sin \left(\frac{1}{2} \cdot x\right)}^{2}}{\color{blue}{\sin x}} \]
      13. *-commutativeN/A

        \[\leadsto \frac{\color{blue}{{\sin \left(\frac{1}{2} \cdot x\right)}^{2} \cdot \frac{8}{3}}}{\sin x} \]
      14. associate-/l*N/A

        \[\leadsto \color{blue}{{\sin \left(\frac{1}{2} \cdot x\right)}^{2} \cdot \frac{\frac{8}{3}}{\sin x}} \]
      15. lower-*.f64N/A

        \[\leadsto \color{blue}{{\sin \left(\frac{1}{2} \cdot x\right)}^{2} \cdot \frac{\frac{8}{3}}{\sin x}} \]
    3. Applied rewrites98.4%

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

Alternative 4: 75.3% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 0.023:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.017361111111111112, x \cdot x, 0.16666666666666666\right), x \cdot x, 1.3333333333333333\right) \cdot \sin \left(x \cdot 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{0.5 - 0.5 \cdot \cos x}{\sin x} \cdot 2.6666666666666665\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= x 0.023)
   (*
    (fma
     (fma 0.017361111111111112 (* x x) 0.16666666666666666)
     (* x x)
     1.3333333333333333)
    (sin (* x 0.5)))
   (* (/ (- 0.5 (* 0.5 (cos x))) (sin x)) 2.6666666666666665)))
double code(double x) {
	double tmp;
	if (x <= 0.023) {
		tmp = fma(fma(0.017361111111111112, (x * x), 0.16666666666666666), (x * x), 1.3333333333333333) * sin((x * 0.5));
	} else {
		tmp = ((0.5 - (0.5 * cos(x))) / sin(x)) * 2.6666666666666665;
	}
	return tmp;
}
function code(x)
	tmp = 0.0
	if (x <= 0.023)
		tmp = Float64(fma(fma(0.017361111111111112, Float64(x * x), 0.16666666666666666), Float64(x * x), 1.3333333333333333) * sin(Float64(x * 0.5)));
	else
		tmp = Float64(Float64(Float64(0.5 - Float64(0.5 * cos(x))) / sin(x)) * 2.6666666666666665);
	end
	return tmp
end
code[x_] := If[LessEqual[x, 0.023], N[(N[(N[(0.017361111111111112 * N[(x * x), $MachinePrecision] + 0.16666666666666666), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.3333333333333333), $MachinePrecision] * N[Sin[N[(x * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[(0.5 - N[(0.5 * N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sin[x], $MachinePrecision]), $MachinePrecision] * 2.6666666666666665), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.023:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.017361111111111112, x \cdot x, 0.16666666666666666\right), x \cdot x, 1.3333333333333333\right) \cdot \sin \left(x \cdot 0.5\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{0.5 - 0.5 \cdot \cos x}{\sin x} \cdot 2.6666666666666665\\


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

    1. Initial program 69.4%

      \[\frac{\left(\frac{8}{3} \cdot \sin \left(x \cdot 0.5\right)\right) \cdot \sin \left(x \cdot 0.5\right)}{\sin x} \]
    2. Step-by-step derivation
      1. lift-/.f64N/A

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

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

        \[\leadsto \frac{\color{blue}{\left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right)} \cdot \sin \left(x \cdot \frac{1}{2}\right)}{\sin x} \]
      4. lift-/.f64N/A

        \[\leadsto \frac{\left(\color{blue}{\frac{8}{3}} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right) \cdot \sin \left(x \cdot \frac{1}{2}\right)}{\sin x} \]
      5. lift-*.f64N/A

        \[\leadsto \frac{\left(\frac{8}{3} \cdot \sin \color{blue}{\left(x \cdot \frac{1}{2}\right)}\right) \cdot \sin \left(x \cdot \frac{1}{2}\right)}{\sin x} \]
      6. lift-sin.f64N/A

        \[\leadsto \frac{\left(\frac{8}{3} \cdot \color{blue}{\sin \left(x \cdot \frac{1}{2}\right)}\right) \cdot \sin \left(x \cdot \frac{1}{2}\right)}{\sin x} \]
      7. lift-*.f64N/A

        \[\leadsto \frac{\left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right) \cdot \sin \color{blue}{\left(x \cdot \frac{1}{2}\right)}}{\sin x} \]
      8. lift-sin.f64N/A

        \[\leadsto \frac{\left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right) \cdot \color{blue}{\sin \left(x \cdot \frac{1}{2}\right)}}{\sin x} \]
      9. lift-sin.f64N/A

        \[\leadsto \frac{\left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right) \cdot \sin \left(x \cdot \frac{1}{2}\right)}{\color{blue}{\sin x}} \]
      10. associate-/l*N/A

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

        \[\leadsto \color{blue}{\frac{\sin \left(x \cdot \frac{1}{2}\right)}{\sin x} \cdot \left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right)} \]
      12. lower-*.f64N/A

        \[\leadsto \color{blue}{\frac{\sin \left(x \cdot \frac{1}{2}\right)}{\sin x} \cdot \left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right)} \]
      13. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{\sin \left(x \cdot \frac{1}{2}\right)}{\sin x}} \cdot \left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right) \]
      14. lift-sin.f64N/A

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

        \[\leadsto \frac{\sin \color{blue}{\left(\frac{1}{2} \cdot x\right)}}{\sin x} \cdot \left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right) \]
      16. lower-*.f64N/A

        \[\leadsto \frac{\sin \color{blue}{\left(\frac{1}{2} \cdot x\right)}}{\sin x} \cdot \left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right) \]
      17. lift-sin.f64N/A

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

        \[\leadsto \frac{\sin \left(\frac{1}{2} \cdot x\right)}{\sin x} \cdot \color{blue}{\left(\sin \left(x \cdot \frac{1}{2}\right) \cdot \frac{8}{3}\right)} \]
      19. lower-*.f64N/A

        \[\leadsto \frac{\sin \left(\frac{1}{2} \cdot x\right)}{\sin x} \cdot \color{blue}{\left(\sin \left(x \cdot \frac{1}{2}\right) \cdot \frac{8}{3}\right)} \]
    3. Applied rewrites99.3%

      \[\leadsto \color{blue}{\frac{\sin \left(0.5 \cdot x\right)}{\sin x} \cdot \left(\sin \left(0.5 \cdot x\right) \cdot 2.6666666666666665\right)} \]
    4. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \color{blue}{\frac{\sin \left(\frac{1}{2} \cdot x\right)}{\sin x} \cdot \left(\sin \left(\frac{1}{2} \cdot x\right) \cdot \frac{8}{3}\right)} \]
      2. lift-/.f64N/A

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

        \[\leadsto \frac{\sin \color{blue}{\left(\frac{1}{2} \cdot x\right)}}{\sin x} \cdot \left(\sin \left(\frac{1}{2} \cdot x\right) \cdot \frac{8}{3}\right) \]
      4. lift-sin.f64N/A

        \[\leadsto \frac{\color{blue}{\sin \left(\frac{1}{2} \cdot x\right)}}{\sin x} \cdot \left(\sin \left(\frac{1}{2} \cdot x\right) \cdot \frac{8}{3}\right) \]
      5. lift-sin.f64N/A

        \[\leadsto \frac{\sin \left(\frac{1}{2} \cdot x\right)}{\color{blue}{\sin x}} \cdot \left(\sin \left(\frac{1}{2} \cdot x\right) \cdot \frac{8}{3}\right) \]
      6. lift-*.f64N/A

        \[\leadsto \frac{\sin \left(\frac{1}{2} \cdot x\right)}{\sin x} \cdot \color{blue}{\left(\sin \left(\frac{1}{2} \cdot x\right) \cdot \frac{8}{3}\right)} \]
      7. lift-*.f64N/A

        \[\leadsto \frac{\sin \left(\frac{1}{2} \cdot x\right)}{\sin x} \cdot \left(\sin \color{blue}{\left(\frac{1}{2} \cdot x\right)} \cdot \frac{8}{3}\right) \]
      8. lift-sin.f64N/A

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

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

        \[\leadsto \color{blue}{\left(\frac{\sin \left(\frac{1}{2} \cdot x\right)}{\sin x} \cdot \frac{8}{3}\right) \cdot \sin \left(\frac{1}{2} \cdot x\right)} \]
      11. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(\frac{\sin \left(\frac{1}{2} \cdot x\right)}{\sin x} \cdot \frac{8}{3}\right) \cdot \sin \left(\frac{1}{2} \cdot x\right)} \]
    5. Applied rewrites99.3%

      \[\leadsto \color{blue}{\left(\frac{\sin \left(x \cdot 0.5\right)}{\sin x} \cdot 2.6666666666666665\right) \cdot \sin \left(x \cdot 0.5\right)} \]
    6. Taylor expanded in x around 0

      \[\leadsto \color{blue}{\left(\frac{4}{3} + {x}^{2} \cdot \left(\frac{1}{6} + \frac{5}{288} \cdot {x}^{2}\right)\right)} \cdot \sin \left(x \cdot \frac{1}{2}\right) \]
    7. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \left({x}^{2} \cdot \left(\frac{1}{6} + \frac{5}{288} \cdot {x}^{2}\right) + \color{blue}{\frac{4}{3}}\right) \cdot \sin \left(x \cdot \frac{1}{2}\right) \]
      2. *-commutativeN/A

        \[\leadsto \left(\left(\frac{1}{6} + \frac{5}{288} \cdot {x}^{2}\right) \cdot {x}^{2} + \frac{4}{3}\right) \cdot \sin \left(x \cdot \frac{1}{2}\right) \]
      3. lower-fma.f64N/A

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

        \[\leadsto \mathsf{fma}\left(\frac{5}{288} \cdot {x}^{2} + \frac{1}{6}, {\color{blue}{x}}^{2}, \frac{4}{3}\right) \cdot \sin \left(x \cdot \frac{1}{2}\right) \]
      5. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\frac{5}{288}, {x}^{2}, \frac{1}{6}\right), {\color{blue}{x}}^{2}, \frac{4}{3}\right) \cdot \sin \left(x \cdot \frac{1}{2}\right) \]
      6. pow2N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\frac{5}{288}, x \cdot x, \frac{1}{6}\right), {x}^{2}, \frac{4}{3}\right) \cdot \sin \left(x \cdot \frac{1}{2}\right) \]
      7. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\frac{5}{288}, x \cdot x, \frac{1}{6}\right), {x}^{2}, \frac{4}{3}\right) \cdot \sin \left(x \cdot \frac{1}{2}\right) \]
      8. pow2N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\frac{5}{288}, x \cdot x, \frac{1}{6}\right), x \cdot \color{blue}{x}, \frac{4}{3}\right) \cdot \sin \left(x \cdot \frac{1}{2}\right) \]
      9. lift-*.f6467.3

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(0.017361111111111112, x \cdot x, 0.16666666666666666\right), x \cdot \color{blue}{x}, 1.3333333333333333\right) \cdot \sin \left(x \cdot 0.5\right) \]
    8. Applied rewrites67.3%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(0.017361111111111112, x \cdot x, 0.16666666666666666\right), x \cdot x, 1.3333333333333333\right)} \cdot \sin \left(x \cdot 0.5\right) \]

    if 0.023 < x

    1. Initial program 99.0%

      \[\frac{\left(\frac{8}{3} \cdot \sin \left(x \cdot 0.5\right)\right) \cdot \sin \left(x \cdot 0.5\right)}{\sin x} \]
    2. Step-by-step derivation
      1. lift-/.f64N/A

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

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

        \[\leadsto \frac{\color{blue}{\left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right)} \cdot \sin \left(x \cdot \frac{1}{2}\right)}{\sin x} \]
      4. lift-/.f64N/A

        \[\leadsto \frac{\left(\color{blue}{\frac{8}{3}} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right) \cdot \sin \left(x \cdot \frac{1}{2}\right)}{\sin x} \]
      5. lift-*.f64N/A

        \[\leadsto \frac{\left(\frac{8}{3} \cdot \sin \color{blue}{\left(x \cdot \frac{1}{2}\right)}\right) \cdot \sin \left(x \cdot \frac{1}{2}\right)}{\sin x} \]
      6. lift-sin.f64N/A

        \[\leadsto \frac{\left(\frac{8}{3} \cdot \color{blue}{\sin \left(x \cdot \frac{1}{2}\right)}\right) \cdot \sin \left(x \cdot \frac{1}{2}\right)}{\sin x} \]
      7. lift-*.f64N/A

        \[\leadsto \frac{\left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right) \cdot \sin \color{blue}{\left(x \cdot \frac{1}{2}\right)}}{\sin x} \]
      8. lift-sin.f64N/A

        \[\leadsto \frac{\left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right) \cdot \color{blue}{\sin \left(x \cdot \frac{1}{2}\right)}}{\sin x} \]
      9. lift-sin.f64N/A

        \[\leadsto \frac{\left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right) \cdot \sin \left(x \cdot \frac{1}{2}\right)}{\color{blue}{\sin x}} \]
      10. associate-/l*N/A

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

        \[\leadsto \color{blue}{\frac{\sin \left(x \cdot \frac{1}{2}\right)}{\sin x} \cdot \left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right)} \]
      12. lower-*.f64N/A

        \[\leadsto \color{blue}{\frac{\sin \left(x \cdot \frac{1}{2}\right)}{\sin x} \cdot \left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right)} \]
      13. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{\sin \left(x \cdot \frac{1}{2}\right)}{\sin x}} \cdot \left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right) \]
      14. lift-sin.f64N/A

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

        \[\leadsto \frac{\sin \color{blue}{\left(\frac{1}{2} \cdot x\right)}}{\sin x} \cdot \left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right) \]
      16. lower-*.f64N/A

        \[\leadsto \frac{\sin \color{blue}{\left(\frac{1}{2} \cdot x\right)}}{\sin x} \cdot \left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right) \]
      17. lift-sin.f64N/A

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

        \[\leadsto \frac{\sin \left(\frac{1}{2} \cdot x\right)}{\sin x} \cdot \color{blue}{\left(\sin \left(x \cdot \frac{1}{2}\right) \cdot \frac{8}{3}\right)} \]
      19. lower-*.f64N/A

        \[\leadsto \frac{\sin \left(\frac{1}{2} \cdot x\right)}{\sin x} \cdot \color{blue}{\left(\sin \left(x \cdot \frac{1}{2}\right) \cdot \frac{8}{3}\right)} \]
    3. Applied rewrites99.0%

      \[\leadsto \color{blue}{\frac{\sin \left(0.5 \cdot x\right)}{\sin x} \cdot \left(\sin \left(0.5 \cdot x\right) \cdot 2.6666666666666665\right)} \]
    4. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \color{blue}{\frac{\sin \left(\frac{1}{2} \cdot x\right)}{\sin x} \cdot \left(\sin \left(\frac{1}{2} \cdot x\right) \cdot \frac{8}{3}\right)} \]
      2. lift-/.f64N/A

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

        \[\leadsto \frac{\sin \color{blue}{\left(\frac{1}{2} \cdot x\right)}}{\sin x} \cdot \left(\sin \left(\frac{1}{2} \cdot x\right) \cdot \frac{8}{3}\right) \]
      4. lift-sin.f64N/A

        \[\leadsto \frac{\color{blue}{\sin \left(\frac{1}{2} \cdot x\right)}}{\sin x} \cdot \left(\sin \left(\frac{1}{2} \cdot x\right) \cdot \frac{8}{3}\right) \]
      5. lift-sin.f64N/A

        \[\leadsto \frac{\sin \left(\frac{1}{2} \cdot x\right)}{\color{blue}{\sin x}} \cdot \left(\sin \left(\frac{1}{2} \cdot x\right) \cdot \frac{8}{3}\right) \]
      6. lift-*.f64N/A

        \[\leadsto \frac{\sin \left(\frac{1}{2} \cdot x\right)}{\sin x} \cdot \color{blue}{\left(\sin \left(\frac{1}{2} \cdot x\right) \cdot \frac{8}{3}\right)} \]
      7. lift-*.f64N/A

        \[\leadsto \frac{\sin \left(\frac{1}{2} \cdot x\right)}{\sin x} \cdot \left(\sin \color{blue}{\left(\frac{1}{2} \cdot x\right)} \cdot \frac{8}{3}\right) \]
      8. lift-sin.f64N/A

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

        \[\leadsto \color{blue}{\left(\frac{\sin \left(\frac{1}{2} \cdot x\right)}{\sin x} \cdot \sin \left(\frac{1}{2} \cdot x\right)\right) \cdot \frac{8}{3}} \]
      10. associate-*l/N/A

        \[\leadsto \color{blue}{\frac{\sin \left(\frac{1}{2} \cdot x\right) \cdot \sin \left(\frac{1}{2} \cdot x\right)}{\sin x}} \cdot \frac{8}{3} \]
      11. unpow2N/A

        \[\leadsto \frac{\color{blue}{{\sin \left(\frac{1}{2} \cdot x\right)}^{2}}}{\sin x} \cdot \frac{8}{3} \]
      12. lower-*.f64N/A

        \[\leadsto \color{blue}{\frac{{\sin \left(\frac{1}{2} \cdot x\right)}^{2}}{\sin x} \cdot \frac{8}{3}} \]
    5. Applied rewrites98.4%

      \[\leadsto \color{blue}{\frac{0.5 - 0.5 \cdot \cos \left(2 \cdot \left(x \cdot 0.5\right)\right)}{\sin x} \cdot 2.6666666666666665} \]
    6. Taylor expanded in x around 0

      \[\leadsto \frac{\frac{1}{2} - \frac{1}{2} \cdot \cos \color{blue}{x}}{\sin x} \cdot \frac{8}{3} \]
    7. Step-by-step derivation
      1. Applied rewrites98.4%

        \[\leadsto \frac{0.5 - 0.5 \cdot \cos \color{blue}{x}}{\sin x} \cdot 2.6666666666666665 \]
    8. Recombined 2 regimes into one program.
    9. Add Preprocessing

    Alternative 5: 75.3% accurate, 1.4× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 0.023:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.017361111111111112, x \cdot x, 0.16666666666666666\right), x \cdot x, 1.3333333333333333\right) \cdot \sin \left(x \cdot 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{2.6666666666666665 \cdot \left(0.5 - \cos x \cdot 0.5\right)}{\sin x}\\ \end{array} \end{array} \]
    (FPCore (x)
     :precision binary64
     (if (<= x 0.023)
       (*
        (fma
         (fma 0.017361111111111112 (* x x) 0.16666666666666666)
         (* x x)
         1.3333333333333333)
        (sin (* x 0.5)))
       (/ (* 2.6666666666666665 (- 0.5 (* (cos x) 0.5))) (sin x))))
    double code(double x) {
    	double tmp;
    	if (x <= 0.023) {
    		tmp = fma(fma(0.017361111111111112, (x * x), 0.16666666666666666), (x * x), 1.3333333333333333) * sin((x * 0.5));
    	} else {
    		tmp = (2.6666666666666665 * (0.5 - (cos(x) * 0.5))) / sin(x);
    	}
    	return tmp;
    }
    
    function code(x)
    	tmp = 0.0
    	if (x <= 0.023)
    		tmp = Float64(fma(fma(0.017361111111111112, Float64(x * x), 0.16666666666666666), Float64(x * x), 1.3333333333333333) * sin(Float64(x * 0.5)));
    	else
    		tmp = Float64(Float64(2.6666666666666665 * Float64(0.5 - Float64(cos(x) * 0.5))) / sin(x));
    	end
    	return tmp
    end
    
    code[x_] := If[LessEqual[x, 0.023], N[(N[(N[(0.017361111111111112 * N[(x * x), $MachinePrecision] + 0.16666666666666666), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.3333333333333333), $MachinePrecision] * N[Sin[N[(x * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(2.6666666666666665 * N[(0.5 - N[(N[Cos[x], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sin[x], $MachinePrecision]), $MachinePrecision]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    \mathbf{if}\;x \leq 0.023:\\
    \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.017361111111111112, x \cdot x, 0.16666666666666666\right), x \cdot x, 1.3333333333333333\right) \cdot \sin \left(x \cdot 0.5\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;\frac{2.6666666666666665 \cdot \left(0.5 - \cos x \cdot 0.5\right)}{\sin x}\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if x < 0.023

      1. Initial program 69.4%

        \[\frac{\left(\frac{8}{3} \cdot \sin \left(x \cdot 0.5\right)\right) \cdot \sin \left(x \cdot 0.5\right)}{\sin x} \]
      2. Step-by-step derivation
        1. lift-/.f64N/A

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

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

          \[\leadsto \frac{\color{blue}{\left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right)} \cdot \sin \left(x \cdot \frac{1}{2}\right)}{\sin x} \]
        4. lift-/.f64N/A

          \[\leadsto \frac{\left(\color{blue}{\frac{8}{3}} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right) \cdot \sin \left(x \cdot \frac{1}{2}\right)}{\sin x} \]
        5. lift-*.f64N/A

          \[\leadsto \frac{\left(\frac{8}{3} \cdot \sin \color{blue}{\left(x \cdot \frac{1}{2}\right)}\right) \cdot \sin \left(x \cdot \frac{1}{2}\right)}{\sin x} \]
        6. lift-sin.f64N/A

          \[\leadsto \frac{\left(\frac{8}{3} \cdot \color{blue}{\sin \left(x \cdot \frac{1}{2}\right)}\right) \cdot \sin \left(x \cdot \frac{1}{2}\right)}{\sin x} \]
        7. lift-*.f64N/A

          \[\leadsto \frac{\left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right) \cdot \sin \color{blue}{\left(x \cdot \frac{1}{2}\right)}}{\sin x} \]
        8. lift-sin.f64N/A

          \[\leadsto \frac{\left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right) \cdot \color{blue}{\sin \left(x \cdot \frac{1}{2}\right)}}{\sin x} \]
        9. lift-sin.f64N/A

          \[\leadsto \frac{\left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right) \cdot \sin \left(x \cdot \frac{1}{2}\right)}{\color{blue}{\sin x}} \]
        10. associate-/l*N/A

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

          \[\leadsto \color{blue}{\frac{\sin \left(x \cdot \frac{1}{2}\right)}{\sin x} \cdot \left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right)} \]
        12. lower-*.f64N/A

          \[\leadsto \color{blue}{\frac{\sin \left(x \cdot \frac{1}{2}\right)}{\sin x} \cdot \left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right)} \]
        13. lower-/.f64N/A

          \[\leadsto \color{blue}{\frac{\sin \left(x \cdot \frac{1}{2}\right)}{\sin x}} \cdot \left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right) \]
        14. lift-sin.f64N/A

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

          \[\leadsto \frac{\sin \color{blue}{\left(\frac{1}{2} \cdot x\right)}}{\sin x} \cdot \left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right) \]
        16. lower-*.f64N/A

          \[\leadsto \frac{\sin \color{blue}{\left(\frac{1}{2} \cdot x\right)}}{\sin x} \cdot \left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right) \]
        17. lift-sin.f64N/A

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

          \[\leadsto \frac{\sin \left(\frac{1}{2} \cdot x\right)}{\sin x} \cdot \color{blue}{\left(\sin \left(x \cdot \frac{1}{2}\right) \cdot \frac{8}{3}\right)} \]
        19. lower-*.f64N/A

          \[\leadsto \frac{\sin \left(\frac{1}{2} \cdot x\right)}{\sin x} \cdot \color{blue}{\left(\sin \left(x \cdot \frac{1}{2}\right) \cdot \frac{8}{3}\right)} \]
      3. Applied rewrites99.3%

        \[\leadsto \color{blue}{\frac{\sin \left(0.5 \cdot x\right)}{\sin x} \cdot \left(\sin \left(0.5 \cdot x\right) \cdot 2.6666666666666665\right)} \]
      4. Step-by-step derivation
        1. lift-*.f64N/A

          \[\leadsto \color{blue}{\frac{\sin \left(\frac{1}{2} \cdot x\right)}{\sin x} \cdot \left(\sin \left(\frac{1}{2} \cdot x\right) \cdot \frac{8}{3}\right)} \]
        2. lift-/.f64N/A

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

          \[\leadsto \frac{\sin \color{blue}{\left(\frac{1}{2} \cdot x\right)}}{\sin x} \cdot \left(\sin \left(\frac{1}{2} \cdot x\right) \cdot \frac{8}{3}\right) \]
        4. lift-sin.f64N/A

          \[\leadsto \frac{\color{blue}{\sin \left(\frac{1}{2} \cdot x\right)}}{\sin x} \cdot \left(\sin \left(\frac{1}{2} \cdot x\right) \cdot \frac{8}{3}\right) \]
        5. lift-sin.f64N/A

          \[\leadsto \frac{\sin \left(\frac{1}{2} \cdot x\right)}{\color{blue}{\sin x}} \cdot \left(\sin \left(\frac{1}{2} \cdot x\right) \cdot \frac{8}{3}\right) \]
        6. lift-*.f64N/A

          \[\leadsto \frac{\sin \left(\frac{1}{2} \cdot x\right)}{\sin x} \cdot \color{blue}{\left(\sin \left(\frac{1}{2} \cdot x\right) \cdot \frac{8}{3}\right)} \]
        7. lift-*.f64N/A

          \[\leadsto \frac{\sin \left(\frac{1}{2} \cdot x\right)}{\sin x} \cdot \left(\sin \color{blue}{\left(\frac{1}{2} \cdot x\right)} \cdot \frac{8}{3}\right) \]
        8. lift-sin.f64N/A

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

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

          \[\leadsto \color{blue}{\left(\frac{\sin \left(\frac{1}{2} \cdot x\right)}{\sin x} \cdot \frac{8}{3}\right) \cdot \sin \left(\frac{1}{2} \cdot x\right)} \]
        11. lower-*.f64N/A

          \[\leadsto \color{blue}{\left(\frac{\sin \left(\frac{1}{2} \cdot x\right)}{\sin x} \cdot \frac{8}{3}\right) \cdot \sin \left(\frac{1}{2} \cdot x\right)} \]
      5. Applied rewrites99.3%

        \[\leadsto \color{blue}{\left(\frac{\sin \left(x \cdot 0.5\right)}{\sin x} \cdot 2.6666666666666665\right) \cdot \sin \left(x \cdot 0.5\right)} \]
      6. Taylor expanded in x around 0

        \[\leadsto \color{blue}{\left(\frac{4}{3} + {x}^{2} \cdot \left(\frac{1}{6} + \frac{5}{288} \cdot {x}^{2}\right)\right)} \cdot \sin \left(x \cdot \frac{1}{2}\right) \]
      7. Step-by-step derivation
        1. +-commutativeN/A

          \[\leadsto \left({x}^{2} \cdot \left(\frac{1}{6} + \frac{5}{288} \cdot {x}^{2}\right) + \color{blue}{\frac{4}{3}}\right) \cdot \sin \left(x \cdot \frac{1}{2}\right) \]
        2. *-commutativeN/A

          \[\leadsto \left(\left(\frac{1}{6} + \frac{5}{288} \cdot {x}^{2}\right) \cdot {x}^{2} + \frac{4}{3}\right) \cdot \sin \left(x \cdot \frac{1}{2}\right) \]
        3. lower-fma.f64N/A

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

          \[\leadsto \mathsf{fma}\left(\frac{5}{288} \cdot {x}^{2} + \frac{1}{6}, {\color{blue}{x}}^{2}, \frac{4}{3}\right) \cdot \sin \left(x \cdot \frac{1}{2}\right) \]
        5. lower-fma.f64N/A

          \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\frac{5}{288}, {x}^{2}, \frac{1}{6}\right), {\color{blue}{x}}^{2}, \frac{4}{3}\right) \cdot \sin \left(x \cdot \frac{1}{2}\right) \]
        6. pow2N/A

          \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\frac{5}{288}, x \cdot x, \frac{1}{6}\right), {x}^{2}, \frac{4}{3}\right) \cdot \sin \left(x \cdot \frac{1}{2}\right) \]
        7. lift-*.f64N/A

          \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\frac{5}{288}, x \cdot x, \frac{1}{6}\right), {x}^{2}, \frac{4}{3}\right) \cdot \sin \left(x \cdot \frac{1}{2}\right) \]
        8. pow2N/A

          \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\frac{5}{288}, x \cdot x, \frac{1}{6}\right), x \cdot \color{blue}{x}, \frac{4}{3}\right) \cdot \sin \left(x \cdot \frac{1}{2}\right) \]
        9. lift-*.f6467.3

          \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(0.017361111111111112, x \cdot x, 0.16666666666666666\right), x \cdot \color{blue}{x}, 1.3333333333333333\right) \cdot \sin \left(x \cdot 0.5\right) \]
      8. Applied rewrites67.3%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(0.017361111111111112, x \cdot x, 0.16666666666666666\right), x \cdot x, 1.3333333333333333\right)} \cdot \sin \left(x \cdot 0.5\right) \]

      if 0.023 < x

      1. Initial program 99.0%

        \[\frac{\left(\frac{8}{3} \cdot \sin \left(x \cdot 0.5\right)\right) \cdot \sin \left(x \cdot 0.5\right)}{\sin x} \]
      2. Step-by-step derivation
        1. lift-/.f64N/A

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

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

          \[\leadsto \frac{\color{blue}{\left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right)} \cdot \sin \left(x \cdot \frac{1}{2}\right)}{\sin x} \]
        4. lift-/.f64N/A

          \[\leadsto \frac{\left(\color{blue}{\frac{8}{3}} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right) \cdot \sin \left(x \cdot \frac{1}{2}\right)}{\sin x} \]
        5. lift-*.f64N/A

          \[\leadsto \frac{\left(\frac{8}{3} \cdot \sin \color{blue}{\left(x \cdot \frac{1}{2}\right)}\right) \cdot \sin \left(x \cdot \frac{1}{2}\right)}{\sin x} \]
        6. lift-sin.f64N/A

          \[\leadsto \frac{\left(\frac{8}{3} \cdot \color{blue}{\sin \left(x \cdot \frac{1}{2}\right)}\right) \cdot \sin \left(x \cdot \frac{1}{2}\right)}{\sin x} \]
        7. lift-*.f64N/A

          \[\leadsto \frac{\left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right) \cdot \sin \color{blue}{\left(x \cdot \frac{1}{2}\right)}}{\sin x} \]
        8. lift-sin.f64N/A

          \[\leadsto \frac{\left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right) \cdot \color{blue}{\sin \left(x \cdot \frac{1}{2}\right)}}{\sin x} \]
        9. lift-sin.f64N/A

          \[\leadsto \frac{\left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right) \cdot \sin \left(x \cdot \frac{1}{2}\right)}{\color{blue}{\sin x}} \]
        10. associate-/l*N/A

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

          \[\leadsto \color{blue}{\frac{\sin \left(x \cdot \frac{1}{2}\right)}{\sin x} \cdot \left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right)} \]
        12. lower-*.f64N/A

          \[\leadsto \color{blue}{\frac{\sin \left(x \cdot \frac{1}{2}\right)}{\sin x} \cdot \left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right)} \]
        13. lower-/.f64N/A

          \[\leadsto \color{blue}{\frac{\sin \left(x \cdot \frac{1}{2}\right)}{\sin x}} \cdot \left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right) \]
        14. lift-sin.f64N/A

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

          \[\leadsto \frac{\sin \color{blue}{\left(\frac{1}{2} \cdot x\right)}}{\sin x} \cdot \left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right) \]
        16. lower-*.f64N/A

          \[\leadsto \frac{\sin \color{blue}{\left(\frac{1}{2} \cdot x\right)}}{\sin x} \cdot \left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right) \]
        17. lift-sin.f64N/A

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

          \[\leadsto \frac{\sin \left(\frac{1}{2} \cdot x\right)}{\sin x} \cdot \color{blue}{\left(\sin \left(x \cdot \frac{1}{2}\right) \cdot \frac{8}{3}\right)} \]
        19. lower-*.f64N/A

          \[\leadsto \frac{\sin \left(\frac{1}{2} \cdot x\right)}{\sin x} \cdot \color{blue}{\left(\sin \left(x \cdot \frac{1}{2}\right) \cdot \frac{8}{3}\right)} \]
      3. Applied rewrites99.0%

        \[\leadsto \color{blue}{\frac{\sin \left(0.5 \cdot x\right)}{\sin x} \cdot \left(\sin \left(0.5 \cdot x\right) \cdot 2.6666666666666665\right)} \]
      4. Step-by-step derivation
        1. lift-*.f64N/A

          \[\leadsto \color{blue}{\frac{\sin \left(\frac{1}{2} \cdot x\right)}{\sin x} \cdot \left(\sin \left(\frac{1}{2} \cdot x\right) \cdot \frac{8}{3}\right)} \]
        2. lift-/.f64N/A

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

          \[\leadsto \frac{\sin \color{blue}{\left(\frac{1}{2} \cdot x\right)}}{\sin x} \cdot \left(\sin \left(\frac{1}{2} \cdot x\right) \cdot \frac{8}{3}\right) \]
        4. lift-sin.f64N/A

          \[\leadsto \frac{\color{blue}{\sin \left(\frac{1}{2} \cdot x\right)}}{\sin x} \cdot \left(\sin \left(\frac{1}{2} \cdot x\right) \cdot \frac{8}{3}\right) \]
        5. lift-sin.f64N/A

          \[\leadsto \frac{\sin \left(\frac{1}{2} \cdot x\right)}{\color{blue}{\sin x}} \cdot \left(\sin \left(\frac{1}{2} \cdot x\right) \cdot \frac{8}{3}\right) \]
        6. lift-*.f64N/A

          \[\leadsto \frac{\sin \left(\frac{1}{2} \cdot x\right)}{\sin x} \cdot \color{blue}{\left(\sin \left(\frac{1}{2} \cdot x\right) \cdot \frac{8}{3}\right)} \]
        7. lift-*.f64N/A

          \[\leadsto \frac{\sin \left(\frac{1}{2} \cdot x\right)}{\sin x} \cdot \left(\sin \color{blue}{\left(\frac{1}{2} \cdot x\right)} \cdot \frac{8}{3}\right) \]
        8. lift-sin.f64N/A

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

          \[\leadsto \color{blue}{\left(\frac{\sin \left(\frac{1}{2} \cdot x\right)}{\sin x} \cdot \sin \left(\frac{1}{2} \cdot x\right)\right) \cdot \frac{8}{3}} \]
        10. associate-*l/N/A

          \[\leadsto \color{blue}{\frac{\sin \left(\frac{1}{2} \cdot x\right) \cdot \sin \left(\frac{1}{2} \cdot x\right)}{\sin x}} \cdot \frac{8}{3} \]
        11. unpow2N/A

          \[\leadsto \frac{\color{blue}{{\sin \left(\frac{1}{2} \cdot x\right)}^{2}}}{\sin x} \cdot \frac{8}{3} \]
        12. lower-*.f64N/A

          \[\leadsto \color{blue}{\frac{{\sin \left(\frac{1}{2} \cdot x\right)}^{2}}{\sin x} \cdot \frac{8}{3}} \]
      5. Applied rewrites98.4%

        \[\leadsto \color{blue}{\frac{0.5 - 0.5 \cdot \cos \left(2 \cdot \left(x \cdot 0.5\right)\right)}{\sin x} \cdot 2.6666666666666665} \]
      6. Taylor expanded in x around inf

        \[\leadsto \color{blue}{\frac{8}{3} \cdot \frac{\frac{1}{2} - \frac{1}{2} \cdot \cos x}{\sin x}} \]
      7. Step-by-step derivation
        1. associate-*l/N/A

          \[\leadsto \color{blue}{\frac{8}{3}} \cdot \frac{\frac{1}{2} - \frac{1}{2} \cdot \cos x}{\sin x} \]
        2. sqr-sin-a-revN/A

          \[\leadsto \frac{8}{3} \cdot \frac{\frac{1}{2} - \frac{1}{2} \cdot \cos x}{\sin x} \]
        3. pow2N/A

          \[\leadsto \frac{8}{3} \cdot \frac{\frac{1}{2} - \frac{1}{2} \cdot \cos x}{\sin x} \]
        4. *-commutativeN/A

          \[\leadsto \frac{8}{3} \cdot \frac{\frac{1}{2} - \frac{1}{2} \cdot \cos x}{\sin x} \]
        5. *-commutativeN/A

          \[\leadsto \frac{8}{3} \cdot \frac{\frac{1}{2} - \frac{1}{2} \cdot \cos x}{\sin x} \]
        6. *-commutativeN/A

          \[\leadsto \frac{8}{3} \cdot \frac{\frac{1}{2} - \frac{1}{2} \cdot \cos x}{\sin x} \]
        7. pow2N/A

          \[\leadsto \frac{8}{3} \cdot \frac{\frac{1}{2} - \frac{1}{2} \cdot \cos x}{\sin x} \]
        8. associate-*l*N/A

          \[\leadsto \frac{8}{3} \cdot \frac{\frac{1}{2} - \frac{1}{2} \cdot \cos x}{\sin x} \]
        9. metadata-evalN/A

          \[\leadsto \frac{8}{3} \cdot \frac{\frac{1}{2} - \frac{1}{2} \cdot \cos x}{\sin x} \]
        10. associate-*r/N/A

          \[\leadsto \frac{\frac{8}{3} \cdot \left(\frac{1}{2} - \frac{1}{2} \cdot \cos x\right)}{\color{blue}{\sin x}} \]
        11. lower-/.f64N/A

          \[\leadsto \frac{\frac{8}{3} \cdot \left(\frac{1}{2} - \frac{1}{2} \cdot \cos x\right)}{\color{blue}{\sin x}} \]
      8. Applied rewrites98.4%

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

    Alternative 6: 55.0% accurate, 3.0× speedup?

    \[\begin{array}{l} \\ 1.3333333333333333 \cdot \sin \left(x \cdot 0.5\right) \end{array} \]
    (FPCore (x) :precision binary64 (* 1.3333333333333333 (sin (* x 0.5))))
    double code(double x) {
    	return 1.3333333333333333 * sin((x * 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 = 1.3333333333333333d0 * sin((x * 0.5d0))
    end function
    
    public static double code(double x) {
    	return 1.3333333333333333 * Math.sin((x * 0.5));
    }
    
    def code(x):
    	return 1.3333333333333333 * math.sin((x * 0.5))
    
    function code(x)
    	return Float64(1.3333333333333333 * sin(Float64(x * 0.5)))
    end
    
    function tmp = code(x)
    	tmp = 1.3333333333333333 * sin((x * 0.5));
    end
    
    code[x_] := N[(1.3333333333333333 * N[Sin[N[(x * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
    
    \begin{array}{l}
    
    \\
    1.3333333333333333 \cdot \sin \left(x \cdot 0.5\right)
    \end{array}
    
    Derivation
    1. Initial program 77.0%

      \[\frac{\left(\frac{8}{3} \cdot \sin \left(x \cdot 0.5\right)\right) \cdot \sin \left(x \cdot 0.5\right)}{\sin x} \]
    2. Step-by-step derivation
      1. lift-/.f64N/A

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

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

        \[\leadsto \frac{\color{blue}{\left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right)} \cdot \sin \left(x \cdot \frac{1}{2}\right)}{\sin x} \]
      4. lift-/.f64N/A

        \[\leadsto \frac{\left(\color{blue}{\frac{8}{3}} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right) \cdot \sin \left(x \cdot \frac{1}{2}\right)}{\sin x} \]
      5. lift-*.f64N/A

        \[\leadsto \frac{\left(\frac{8}{3} \cdot \sin \color{blue}{\left(x \cdot \frac{1}{2}\right)}\right) \cdot \sin \left(x \cdot \frac{1}{2}\right)}{\sin x} \]
      6. lift-sin.f64N/A

        \[\leadsto \frac{\left(\frac{8}{3} \cdot \color{blue}{\sin \left(x \cdot \frac{1}{2}\right)}\right) \cdot \sin \left(x \cdot \frac{1}{2}\right)}{\sin x} \]
      7. lift-*.f64N/A

        \[\leadsto \frac{\left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right) \cdot \sin \color{blue}{\left(x \cdot \frac{1}{2}\right)}}{\sin x} \]
      8. lift-sin.f64N/A

        \[\leadsto \frac{\left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right) \cdot \color{blue}{\sin \left(x \cdot \frac{1}{2}\right)}}{\sin x} \]
      9. lift-sin.f64N/A

        \[\leadsto \frac{\left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right) \cdot \sin \left(x \cdot \frac{1}{2}\right)}{\color{blue}{\sin x}} \]
      10. associate-/l*N/A

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

        \[\leadsto \color{blue}{\frac{\sin \left(x \cdot \frac{1}{2}\right)}{\sin x} \cdot \left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right)} \]
      12. lower-*.f64N/A

        \[\leadsto \color{blue}{\frac{\sin \left(x \cdot \frac{1}{2}\right)}{\sin x} \cdot \left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right)} \]
      13. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{\sin \left(x \cdot \frac{1}{2}\right)}{\sin x}} \cdot \left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right) \]
      14. lift-sin.f64N/A

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

        \[\leadsto \frac{\sin \color{blue}{\left(\frac{1}{2} \cdot x\right)}}{\sin x} \cdot \left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right) \]
      16. lower-*.f64N/A

        \[\leadsto \frac{\sin \color{blue}{\left(\frac{1}{2} \cdot x\right)}}{\sin x} \cdot \left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right) \]
      17. lift-sin.f64N/A

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

        \[\leadsto \frac{\sin \left(\frac{1}{2} \cdot x\right)}{\sin x} \cdot \color{blue}{\left(\sin \left(x \cdot \frac{1}{2}\right) \cdot \frac{8}{3}\right)} \]
      19. lower-*.f64N/A

        \[\leadsto \frac{\sin \left(\frac{1}{2} \cdot x\right)}{\sin x} \cdot \color{blue}{\left(\sin \left(x \cdot \frac{1}{2}\right) \cdot \frac{8}{3}\right)} \]
    3. Applied rewrites99.2%

      \[\leadsto \color{blue}{\frac{\sin \left(0.5 \cdot x\right)}{\sin x} \cdot \left(\sin \left(0.5 \cdot x\right) \cdot 2.6666666666666665\right)} \]
    4. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \color{blue}{\frac{\sin \left(\frac{1}{2} \cdot x\right)}{\sin x} \cdot \left(\sin \left(\frac{1}{2} \cdot x\right) \cdot \frac{8}{3}\right)} \]
      2. lift-/.f64N/A

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

        \[\leadsto \frac{\sin \color{blue}{\left(\frac{1}{2} \cdot x\right)}}{\sin x} \cdot \left(\sin \left(\frac{1}{2} \cdot x\right) \cdot \frac{8}{3}\right) \]
      4. lift-sin.f64N/A

        \[\leadsto \frac{\color{blue}{\sin \left(\frac{1}{2} \cdot x\right)}}{\sin x} \cdot \left(\sin \left(\frac{1}{2} \cdot x\right) \cdot \frac{8}{3}\right) \]
      5. lift-sin.f64N/A

        \[\leadsto \frac{\sin \left(\frac{1}{2} \cdot x\right)}{\color{blue}{\sin x}} \cdot \left(\sin \left(\frac{1}{2} \cdot x\right) \cdot \frac{8}{3}\right) \]
      6. lift-*.f64N/A

        \[\leadsto \frac{\sin \left(\frac{1}{2} \cdot x\right)}{\sin x} \cdot \color{blue}{\left(\sin \left(\frac{1}{2} \cdot x\right) \cdot \frac{8}{3}\right)} \]
      7. lift-*.f64N/A

        \[\leadsto \frac{\sin \left(\frac{1}{2} \cdot x\right)}{\sin x} \cdot \left(\sin \color{blue}{\left(\frac{1}{2} \cdot x\right)} \cdot \frac{8}{3}\right) \]
      8. lift-sin.f64N/A

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

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

        \[\leadsto \color{blue}{\left(\frac{\sin \left(\frac{1}{2} \cdot x\right)}{\sin x} \cdot \frac{8}{3}\right) \cdot \sin \left(\frac{1}{2} \cdot x\right)} \]
      11. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(\frac{\sin \left(\frac{1}{2} \cdot x\right)}{\sin x} \cdot \frac{8}{3}\right) \cdot \sin \left(\frac{1}{2} \cdot x\right)} \]
    5. Applied rewrites99.2%

      \[\leadsto \color{blue}{\left(\frac{\sin \left(x \cdot 0.5\right)}{\sin x} \cdot 2.6666666666666665\right) \cdot \sin \left(x \cdot 0.5\right)} \]
    6. Taylor expanded in x around 0

      \[\leadsto \color{blue}{\frac{4}{3}} \cdot \sin \left(x \cdot \frac{1}{2}\right) \]
    7. Step-by-step derivation
      1. Applied rewrites55.0%

        \[\leadsto \color{blue}{1.3333333333333333} \cdot \sin \left(x \cdot 0.5\right) \]
      2. Add Preprocessing

      Alternative 7: 51.0% accurate, 29.0× speedup?

      \[\begin{array}{l} \\ 0.6666666666666666 \cdot x \end{array} \]
      (FPCore (x) :precision binary64 (* 0.6666666666666666 x))
      double code(double x) {
      	return 0.6666666666666666 * 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.6666666666666666d0 * x
      end function
      
      public static double code(double x) {
      	return 0.6666666666666666 * x;
      }
      
      def code(x):
      	return 0.6666666666666666 * x
      
      function code(x)
      	return Float64(0.6666666666666666 * x)
      end
      
      function tmp = code(x)
      	tmp = 0.6666666666666666 * x;
      end
      
      code[x_] := N[(0.6666666666666666 * x), $MachinePrecision]
      
      \begin{array}{l}
      
      \\
      0.6666666666666666 \cdot x
      \end{array}
      
      Derivation
      1. Initial program 77.0%

        \[\frac{\left(\frac{8}{3} \cdot \sin \left(x \cdot 0.5\right)\right) \cdot \sin \left(x \cdot 0.5\right)}{\sin x} \]
      2. Taylor expanded in x around 0

        \[\leadsto \color{blue}{\frac{2}{3} \cdot x} \]
      3. Step-by-step derivation
        1. lower-*.f6451.0

          \[\leadsto 0.6666666666666666 \cdot \color{blue}{x} \]
      4. Applied rewrites51.0%

        \[\leadsto \color{blue}{0.6666666666666666 \cdot x} \]
      5. Add Preprocessing

      Reproduce

      ?
      herbie shell --seed 2025114 
      (FPCore (x)
        :name "Graphics.Rasterific.Svg.PathConverter:segmentToBezier from rasterific-svg-0.2.3.1, A"
        :precision binary64
        (/ (* (* (/ 8.0 3.0) (sin (* x 0.5))) (sin (* x 0.5))) (sin x)))