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

Percentage Accurate: 77.3% → 99.5%
Time: 3.7s
Alternatives: 9
Speedup: 1.3×

Specification

?
\[\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} \]
(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}
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}

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 9 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.3% accurate, 1.0× speedup?

\[\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} \]
(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}
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}

Alternative 1: 99.5% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(\frac{\color{blue}{\frac{8}{3}}}{\sin x} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right) \cdot \sin \left(x \cdot \frac{1}{2}\right) \]
    14. metadata-eval99.2%

      \[\leadsto \left(\frac{\color{blue}{2.6666666666666665}}{\sin x} \cdot \sin \left(x \cdot 0.5\right)\right) \cdot \sin \left(x \cdot 0.5\right) \]
    15. lift-*.f64N/A

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

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

      \[\leadsto \left(\frac{2.6666666666666665}{\sin x} \cdot \sin \color{blue}{\left(0.5 \cdot x\right)}\right) \cdot \sin \left(x \cdot 0.5\right) \]
    18. lift-*.f64N/A

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

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

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

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

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

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

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

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

      \[\leadsto \left(\left(\color{blue}{\frac{1}{\sin x}} \cdot \frac{8}{3}\right) \cdot \sin \left(\frac{1}{2} \cdot x\right)\right) \cdot \sin \left(\frac{1}{2} \cdot x\right) \]
    7. metadata-eval99.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\sin \left(\frac{1}{2} \cdot x\right) \cdot \color{blue}{\frac{\sin \left(\frac{1}{2} \cdot x\right)}{\sin x}}}{\frac{3}{8}} \]
    14. lower-/.f6499.5%

      \[\leadsto \frac{\sin \left(0.5 \cdot x\right) \cdot \color{blue}{\frac{\sin \left(0.5 \cdot x\right)}{\sin x}}}{0.375} \]
  9. Applied rewrites99.5%

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

Alternative 2: 99.3% accurate, 1.1× speedup?

\[\mathsf{copysign}\left(1, x\right) \cdot \begin{array}{l} \mathbf{if}\;\left|x\right| \leq 10^{-7}:\\ \;\;\;\;\mathsf{fma}\left(\left|x\right|, 0.6666666666666666, \left(\left|x\right| \cdot 0.05555555555555555\right) \cdot \left(\left|x\right| \cdot \left|x\right|\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{2.6666666666666665 \cdot {\sin \left(0.5 \cdot \left|x\right|\right)}^{2}}{\sin \left(\left|x\right|\right)}\\ \end{array} \]
(FPCore (x)
 :precision binary64
 (*
  (copysign 1.0 x)
  (if (<= (fabs x) 1e-7)
    (fma
     (fabs x)
     0.6666666666666666
     (* (* (fabs x) 0.05555555555555555) (* (fabs x) (fabs x))))
    (/
     (* 2.6666666666666665 (pow (sin (* 0.5 (fabs x))) 2.0))
     (sin (fabs x))))))
double code(double x) {
	double tmp;
	if (fabs(x) <= 1e-7) {
		tmp = fma(fabs(x), 0.6666666666666666, ((fabs(x) * 0.05555555555555555) * (fabs(x) * fabs(x))));
	} else {
		tmp = (2.6666666666666665 * pow(sin((0.5 * fabs(x))), 2.0)) / sin(fabs(x));
	}
	return copysign(1.0, x) * tmp;
}
function code(x)
	tmp = 0.0
	if (abs(x) <= 1e-7)
		tmp = fma(abs(x), 0.6666666666666666, Float64(Float64(abs(x) * 0.05555555555555555) * Float64(abs(x) * abs(x))));
	else
		tmp = Float64(Float64(2.6666666666666665 * (sin(Float64(0.5 * abs(x))) ^ 2.0)) / sin(abs(x)));
	end
	return Float64(copysign(1.0, x) * tmp)
end
code[x_] := N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[Abs[x], $MachinePrecision], 1e-7], N[(N[Abs[x], $MachinePrecision] * 0.6666666666666666 + N[(N[(N[Abs[x], $MachinePrecision] * 0.05555555555555555), $MachinePrecision] * N[(N[Abs[x], $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(2.6666666666666665 * N[Power[N[Sin[N[(0.5 * N[Abs[x], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / N[Sin[N[Abs[x], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\mathsf{copysign}\left(1, x\right) \cdot \begin{array}{l}
\mathbf{if}\;\left|x\right| \leq 10^{-7}:\\
\;\;\;\;\mathsf{fma}\left(\left|x\right|, 0.6666666666666666, \left(\left|x\right| \cdot 0.05555555555555555\right) \cdot \left(\left|x\right| \cdot \left|x\right|\right)\right)\\

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


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

    1. Initial program 77.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. Taylor expanded in x around 0

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

        \[\leadsto x \cdot \color{blue}{\left(\frac{2}{3} + {x}^{2} \cdot \left(\frac{1}{18} + {x}^{2} \cdot \left(\frac{1}{180} + \frac{17}{30240} \cdot {x}^{2}\right)\right)\right)} \]
      2. lower-+.f64N/A

        \[\leadsto x \cdot \left(\frac{2}{3} + \color{blue}{{x}^{2} \cdot \left(\frac{1}{18} + {x}^{2} \cdot \left(\frac{1}{180} + \frac{17}{30240} \cdot {x}^{2}\right)\right)}\right) \]
      3. lower-*.f64N/A

        \[\leadsto x \cdot \left(\frac{2}{3} + {x}^{2} \cdot \color{blue}{\left(\frac{1}{18} + {x}^{2} \cdot \left(\frac{1}{180} + \frac{17}{30240} \cdot {x}^{2}\right)\right)}\right) \]
      4. lower-pow.f64N/A

        \[\leadsto x \cdot \left(\frac{2}{3} + {x}^{2} \cdot \left(\color{blue}{\frac{1}{18}} + {x}^{2} \cdot \left(\frac{1}{180} + \frac{17}{30240} \cdot {x}^{2}\right)\right)\right) \]
      5. lower-+.f64N/A

        \[\leadsto x \cdot \left(\frac{2}{3} + {x}^{2} \cdot \left(\frac{1}{18} + \color{blue}{{x}^{2} \cdot \left(\frac{1}{180} + \frac{17}{30240} \cdot {x}^{2}\right)}\right)\right) \]
      6. lower-*.f64N/A

        \[\leadsto x \cdot \left(\frac{2}{3} + {x}^{2} \cdot \left(\frac{1}{18} + {x}^{2} \cdot \color{blue}{\left(\frac{1}{180} + \frac{17}{30240} \cdot {x}^{2}\right)}\right)\right) \]
      7. lower-pow.f64N/A

        \[\leadsto x \cdot \left(\frac{2}{3} + {x}^{2} \cdot \left(\frac{1}{18} + {x}^{2} \cdot \left(\color{blue}{\frac{1}{180}} + \frac{17}{30240} \cdot {x}^{2}\right)\right)\right) \]
      8. lower-+.f64N/A

        \[\leadsto x \cdot \left(\frac{2}{3} + {x}^{2} \cdot \left(\frac{1}{18} + {x}^{2} \cdot \left(\frac{1}{180} + \color{blue}{\frac{17}{30240} \cdot {x}^{2}}\right)\right)\right) \]
      9. lower-*.f64N/A

        \[\leadsto x \cdot \left(\frac{2}{3} + {x}^{2} \cdot \left(\frac{1}{18} + {x}^{2} \cdot \left(\frac{1}{180} + \frac{17}{30240} \cdot \color{blue}{{x}^{2}}\right)\right)\right) \]
      10. lower-pow.f6451.0%

        \[\leadsto x \cdot \left(0.6666666666666666 + {x}^{2} \cdot \left(0.05555555555555555 + {x}^{2} \cdot \left(0.005555555555555556 + 0.0005621693121693122 \cdot {x}^{\color{blue}{2}}\right)\right)\right) \]
    4. Applied rewrites51.0%

      \[\leadsto \color{blue}{x \cdot \left(0.6666666666666666 + {x}^{2} \cdot \left(0.05555555555555555 + {x}^{2} \cdot \left(0.005555555555555556 + 0.0005621693121693122 \cdot {x}^{2}\right)\right)\right)} \]
    5. Taylor expanded in x around 0

      \[\leadsto x \cdot \left(0.6666666666666666 + {x}^{2} \cdot \frac{1}{18}\right) \]
    6. Step-by-step derivation
      1. Applied rewrites51.1%

        \[\leadsto x \cdot \left(0.6666666666666666 + {x}^{2} \cdot 0.05555555555555555\right) \]
      2. Step-by-step derivation
        1. lift-*.f64N/A

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

          \[\leadsto x \cdot \left(\frac{2}{3} + \color{blue}{{x}^{2} \cdot \frac{1}{18}}\right) \]
        3. distribute-lft-inN/A

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

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

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

          \[\leadsto \mathsf{fma}\left(x, \frac{2}{3}, x \cdot \left(\frac{1}{18} \cdot {x}^{2}\right)\right) \]
        7. associate-*r*N/A

          \[\leadsto \mathsf{fma}\left(x, \frac{2}{3}, \left(x \cdot \frac{1}{18}\right) \cdot {x}^{2}\right) \]
        8. lower-*.f64N/A

          \[\leadsto \mathsf{fma}\left(x, \frac{2}{3}, \left(x \cdot \frac{1}{18}\right) \cdot {x}^{2}\right) \]
        9. lower-*.f6451.1%

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

          \[\leadsto \mathsf{fma}\left(x, \frac{2}{3}, \left(x \cdot \frac{1}{18}\right) \cdot {x}^{2}\right) \]
        11. unpow2N/A

          \[\leadsto \mathsf{fma}\left(x, \frac{2}{3}, \left(x \cdot \frac{1}{18}\right) \cdot \left(x \cdot x\right)\right) \]
        12. lower-*.f6451.1%

          \[\leadsto \mathsf{fma}\left(x, 0.6666666666666666, \left(x \cdot 0.05555555555555555\right) \cdot \left(x \cdot x\right)\right) \]
      3. Applied rewrites51.1%

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

      if 9.9999999999999995e-8 < x

      1. Initial program 77.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. Taylor expanded in x around inf

        \[\leadsto \frac{\color{blue}{\frac{8}{3} \cdot {\sin \left(\frac{1}{2} \cdot x\right)}^{2}}}{\sin x} \]
      3. Step-by-step derivation
        1. metadata-evalN/A

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

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

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

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

          \[\leadsto \frac{\frac{8}{3} \cdot {\sin \left(\frac{1}{2} \cdot x\right)}^{2}}{\sin x} \]
        6. lower-*.f6477.3%

          \[\leadsto \frac{2.6666666666666665 \cdot {\sin \left(0.5 \cdot x\right)}^{2}}{\sin x} \]
      4. Applied rewrites77.3%

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

    Alternative 3: 99.2% accurate, 1.0× speedup?

    \[\frac{\sin \left(0.5 \cdot x\right)}{\sin x} \cdot \left(\sin \left(-0.5 \cdot x\right) \cdot -2.6666666666666665\right) \]
    (FPCore (x)
     :precision binary64
     (* (/ (sin (* 0.5 x)) (sin x)) (* (sin (* -0.5 x)) -2.6666666666666665)))
    double code(double x) {
    	return (sin((0.5 * x)) / sin(x)) * (sin((-0.5 * x)) * -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
        code = (sin((0.5d0 * x)) / sin(x)) * (sin(((-0.5d0) * x)) * (-2.6666666666666665d0))
    end function
    
    public static double code(double x) {
    	return (Math.sin((0.5 * x)) / Math.sin(x)) * (Math.sin((-0.5 * x)) * -2.6666666666666665);
    }
    
    def code(x):
    	return (math.sin((0.5 * x)) / math.sin(x)) * (math.sin((-0.5 * x)) * -2.6666666666666665)
    
    function code(x)
    	return Float64(Float64(sin(Float64(0.5 * x)) / sin(x)) * Float64(sin(Float64(-0.5 * x)) * -2.6666666666666665))
    end
    
    function tmp = code(x)
    	tmp = (sin((0.5 * x)) / sin(x)) * (sin((-0.5 * x)) * -2.6666666666666665);
    end
    
    code[x_] := N[(N[(N[Sin[N[(0.5 * x), $MachinePrecision]], $MachinePrecision] / N[Sin[x], $MachinePrecision]), $MachinePrecision] * N[(N[Sin[N[(-0.5 * x), $MachinePrecision]], $MachinePrecision] * -2.6666666666666665), $MachinePrecision]), $MachinePrecision]
    
    \frac{\sin \left(0.5 \cdot x\right)}{\sin x} \cdot \left(\sin \left(-0.5 \cdot x\right) \cdot -2.6666666666666665\right)
    
    Derivation
    1. Initial program 77.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. 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}} \]
      4. *-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)} \]
      5. 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)} \]
      6. lower-/.f6499.2%

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

        \[\leadsto \frac{\sin \color{blue}{\left(x \cdot \frac{1}{2}\right)}}{\sin x} \cdot \left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right) \]
      8. *-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) \]
      9. lower-*.f6499.2%

        \[\leadsto \frac{\sin \color{blue}{\left(0.5 \cdot x\right)}}{\sin x} \cdot \left(\frac{8}{3} \cdot \sin \left(x \cdot 0.5\right)\right) \]
      10. remove-double-negN/A

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

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

        \[\leadsto \frac{\sin \left(\frac{1}{2} \cdot x\right)}{\sin x} \cdot \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\color{blue}{\sin \left(x \cdot \frac{1}{2}\right) \cdot \frac{8}{3}}\right)\right)\right)\right) \]
      13. distribute-lft-neg-inN/A

        \[\leadsto \frac{\sin \left(\frac{1}{2} \cdot x\right)}{\sin x} \cdot \left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(\sin \left(x \cdot \frac{1}{2}\right)\right)\right) \cdot \frac{8}{3}}\right)\right) \]
      14. distribute-rgt-neg-inN/A

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

        \[\leadsto \frac{\sin \left(\frac{1}{2} \cdot x\right)}{\sin x} \cdot \color{blue}{\left(\left(\mathsf{neg}\left(\sin \left(x \cdot \frac{1}{2}\right)\right)\right) \cdot \left(\mathsf{neg}\left(\frac{8}{3}\right)\right)\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 4: 99.2% accurate, 1.1× speedup?

    \[\mathsf{copysign}\left(1, x\right) \cdot \begin{array}{l} \mathbf{if}\;\left|x\right| \leq 10^{-7}:\\ \;\;\;\;\mathsf{fma}\left(\left|x\right|, 0.6666666666666666, \left(\left|x\right| \cdot 0.05555555555555555\right) \cdot \left(\left|x\right| \cdot \left|x\right|\right)\right)\\ \mathbf{else}:\\ \;\;\;\;2.6666666666666665 \cdot \frac{{\sin \left(0.5 \cdot \left|x\right|\right)}^{2}}{\sin \left(\left|x\right|\right)}\\ \end{array} \]
    (FPCore (x)
     :precision binary64
     (*
      (copysign 1.0 x)
      (if (<= (fabs x) 1e-7)
        (fma
         (fabs x)
         0.6666666666666666
         (* (* (fabs x) 0.05555555555555555) (* (fabs x) (fabs x))))
        (*
         2.6666666666666665
         (/ (pow (sin (* 0.5 (fabs x))) 2.0) (sin (fabs x)))))))
    double code(double x) {
    	double tmp;
    	if (fabs(x) <= 1e-7) {
    		tmp = fma(fabs(x), 0.6666666666666666, ((fabs(x) * 0.05555555555555555) * (fabs(x) * fabs(x))));
    	} else {
    		tmp = 2.6666666666666665 * (pow(sin((0.5 * fabs(x))), 2.0) / sin(fabs(x)));
    	}
    	return copysign(1.0, x) * tmp;
    }
    
    function code(x)
    	tmp = 0.0
    	if (abs(x) <= 1e-7)
    		tmp = fma(abs(x), 0.6666666666666666, Float64(Float64(abs(x) * 0.05555555555555555) * Float64(abs(x) * abs(x))));
    	else
    		tmp = Float64(2.6666666666666665 * Float64((sin(Float64(0.5 * abs(x))) ^ 2.0) / sin(abs(x))));
    	end
    	return Float64(copysign(1.0, x) * tmp)
    end
    
    code[x_] := N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[Abs[x], $MachinePrecision], 1e-7], N[(N[Abs[x], $MachinePrecision] * 0.6666666666666666 + N[(N[(N[Abs[x], $MachinePrecision] * 0.05555555555555555), $MachinePrecision] * N[(N[Abs[x], $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(2.6666666666666665 * N[(N[Power[N[Sin[N[(0.5 * N[Abs[x], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] / N[Sin[N[Abs[x], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
    
    \mathsf{copysign}\left(1, x\right) \cdot \begin{array}{l}
    \mathbf{if}\;\left|x\right| \leq 10^{-7}:\\
    \;\;\;\;\mathsf{fma}\left(\left|x\right|, 0.6666666666666666, \left(\left|x\right| \cdot 0.05555555555555555\right) \cdot \left(\left|x\right| \cdot \left|x\right|\right)\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;2.6666666666666665 \cdot \frac{{\sin \left(0.5 \cdot \left|x\right|\right)}^{2}}{\sin \left(\left|x\right|\right)}\\
    
    
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if x < 9.9999999999999995e-8

      1. Initial program 77.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. Taylor expanded in x around 0

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

          \[\leadsto x \cdot \color{blue}{\left(\frac{2}{3} + {x}^{2} \cdot \left(\frac{1}{18} + {x}^{2} \cdot \left(\frac{1}{180} + \frac{17}{30240} \cdot {x}^{2}\right)\right)\right)} \]
        2. lower-+.f64N/A

          \[\leadsto x \cdot \left(\frac{2}{3} + \color{blue}{{x}^{2} \cdot \left(\frac{1}{18} + {x}^{2} \cdot \left(\frac{1}{180} + \frac{17}{30240} \cdot {x}^{2}\right)\right)}\right) \]
        3. lower-*.f64N/A

          \[\leadsto x \cdot \left(\frac{2}{3} + {x}^{2} \cdot \color{blue}{\left(\frac{1}{18} + {x}^{2} \cdot \left(\frac{1}{180} + \frac{17}{30240} \cdot {x}^{2}\right)\right)}\right) \]
        4. lower-pow.f64N/A

          \[\leadsto x \cdot \left(\frac{2}{3} + {x}^{2} \cdot \left(\color{blue}{\frac{1}{18}} + {x}^{2} \cdot \left(\frac{1}{180} + \frac{17}{30240} \cdot {x}^{2}\right)\right)\right) \]
        5. lower-+.f64N/A

          \[\leadsto x \cdot \left(\frac{2}{3} + {x}^{2} \cdot \left(\frac{1}{18} + \color{blue}{{x}^{2} \cdot \left(\frac{1}{180} + \frac{17}{30240} \cdot {x}^{2}\right)}\right)\right) \]
        6. lower-*.f64N/A

          \[\leadsto x \cdot \left(\frac{2}{3} + {x}^{2} \cdot \left(\frac{1}{18} + {x}^{2} \cdot \color{blue}{\left(\frac{1}{180} + \frac{17}{30240} \cdot {x}^{2}\right)}\right)\right) \]
        7. lower-pow.f64N/A

          \[\leadsto x \cdot \left(\frac{2}{3} + {x}^{2} \cdot \left(\frac{1}{18} + {x}^{2} \cdot \left(\color{blue}{\frac{1}{180}} + \frac{17}{30240} \cdot {x}^{2}\right)\right)\right) \]
        8. lower-+.f64N/A

          \[\leadsto x \cdot \left(\frac{2}{3} + {x}^{2} \cdot \left(\frac{1}{18} + {x}^{2} \cdot \left(\frac{1}{180} + \color{blue}{\frac{17}{30240} \cdot {x}^{2}}\right)\right)\right) \]
        9. lower-*.f64N/A

          \[\leadsto x \cdot \left(\frac{2}{3} + {x}^{2} \cdot \left(\frac{1}{18} + {x}^{2} \cdot \left(\frac{1}{180} + \frac{17}{30240} \cdot \color{blue}{{x}^{2}}\right)\right)\right) \]
        10. lower-pow.f6451.0%

          \[\leadsto x \cdot \left(0.6666666666666666 + {x}^{2} \cdot \left(0.05555555555555555 + {x}^{2} \cdot \left(0.005555555555555556 + 0.0005621693121693122 \cdot {x}^{\color{blue}{2}}\right)\right)\right) \]
      4. Applied rewrites51.0%

        \[\leadsto \color{blue}{x \cdot \left(0.6666666666666666 + {x}^{2} \cdot \left(0.05555555555555555 + {x}^{2} \cdot \left(0.005555555555555556 + 0.0005621693121693122 \cdot {x}^{2}\right)\right)\right)} \]
      5. Taylor expanded in x around 0

        \[\leadsto x \cdot \left(0.6666666666666666 + {x}^{2} \cdot \frac{1}{18}\right) \]
      6. Step-by-step derivation
        1. Applied rewrites51.1%

          \[\leadsto x \cdot \left(0.6666666666666666 + {x}^{2} \cdot 0.05555555555555555\right) \]
        2. Step-by-step derivation
          1. lift-*.f64N/A

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

            \[\leadsto x \cdot \left(\frac{2}{3} + \color{blue}{{x}^{2} \cdot \frac{1}{18}}\right) \]
          3. distribute-lft-inN/A

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

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

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

            \[\leadsto \mathsf{fma}\left(x, \frac{2}{3}, x \cdot \left(\frac{1}{18} \cdot {x}^{2}\right)\right) \]
          7. associate-*r*N/A

            \[\leadsto \mathsf{fma}\left(x, \frac{2}{3}, \left(x \cdot \frac{1}{18}\right) \cdot {x}^{2}\right) \]
          8. lower-*.f64N/A

            \[\leadsto \mathsf{fma}\left(x, \frac{2}{3}, \left(x \cdot \frac{1}{18}\right) \cdot {x}^{2}\right) \]
          9. lower-*.f6451.1%

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

            \[\leadsto \mathsf{fma}\left(x, \frac{2}{3}, \left(x \cdot \frac{1}{18}\right) \cdot {x}^{2}\right) \]
          11. unpow2N/A

            \[\leadsto \mathsf{fma}\left(x, \frac{2}{3}, \left(x \cdot \frac{1}{18}\right) \cdot \left(x \cdot x\right)\right) \]
          12. lower-*.f6451.1%

            \[\leadsto \mathsf{fma}\left(x, 0.6666666666666666, \left(x \cdot 0.05555555555555555\right) \cdot \left(x \cdot x\right)\right) \]
        3. Applied rewrites51.1%

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

        if 9.9999999999999995e-8 < x

        1. Initial program 77.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. Taylor expanded in x around inf

          \[\leadsto \color{blue}{\frac{8}{3} \cdot \frac{{\sin \left(\frac{1}{2} \cdot x\right)}^{2}}{\sin x}} \]
        3. Step-by-step derivation
          1. metadata-evalN/A

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

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

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

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

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

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

            \[\leadsto \frac{8}{3} \cdot \frac{{\sin \left(\frac{1}{2} \cdot x\right)}^{2}}{\sin x} \]
          8. lower-sin.f6477.3%

            \[\leadsto 2.6666666666666665 \cdot \frac{{\sin \left(0.5 \cdot x\right)}^{2}}{\sin x} \]
        4. Applied rewrites77.3%

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

      Alternative 5: 99.0% accurate, 1.3× speedup?

      \[\begin{array}{l} t_0 := \left|x\right| \cdot \left|x\right|\\ \mathsf{copysign}\left(1, x\right) \cdot \begin{array}{l} \mathbf{if}\;\left|x\right| \leq 0.00135:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.0005621693121693122, t\_0, 0.005555555555555556\right), t\_0, 0.05555555555555555\right) \cdot \left|x\right|, \left|x\right|, 0.6666666666666666\right) \cdot \left|x\right|\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{\sin \left(\left|x\right|\right)}{\mathsf{fma}\left(\cos \left(\left|x\right|\right), -1.3333333333333333, 1.3333333333333333\right)}}\\ \end{array} \end{array} \]
      (FPCore (x)
       :precision binary64
       (let* ((t_0 (* (fabs x) (fabs x))))
         (*
          (copysign 1.0 x)
          (if (<= (fabs x) 0.00135)
            (*
             (fma
              (*
               (fma
                (fma 0.0005621693121693122 t_0 0.005555555555555556)
                t_0
                0.05555555555555555)
               (fabs x))
              (fabs x)
              0.6666666666666666)
             (fabs x))
            (/
             1.0
             (/
              (sin (fabs x))
              (fma (cos (fabs x)) -1.3333333333333333 1.3333333333333333)))))))
      double code(double x) {
      	double t_0 = fabs(x) * fabs(x);
      	double tmp;
      	if (fabs(x) <= 0.00135) {
      		tmp = fma((fma(fma(0.0005621693121693122, t_0, 0.005555555555555556), t_0, 0.05555555555555555) * fabs(x)), fabs(x), 0.6666666666666666) * fabs(x);
      	} else {
      		tmp = 1.0 / (sin(fabs(x)) / fma(cos(fabs(x)), -1.3333333333333333, 1.3333333333333333));
      	}
      	return copysign(1.0, x) * tmp;
      }
      
      function code(x)
      	t_0 = Float64(abs(x) * abs(x))
      	tmp = 0.0
      	if (abs(x) <= 0.00135)
      		tmp = Float64(fma(Float64(fma(fma(0.0005621693121693122, t_0, 0.005555555555555556), t_0, 0.05555555555555555) * abs(x)), abs(x), 0.6666666666666666) * abs(x));
      	else
      		tmp = Float64(1.0 / Float64(sin(abs(x)) / fma(cos(abs(x)), -1.3333333333333333, 1.3333333333333333)));
      	end
      	return Float64(copysign(1.0, x) * tmp)
      end
      
      code[x_] := Block[{t$95$0 = N[(N[Abs[x], $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[Abs[x], $MachinePrecision], 0.00135], N[(N[(N[(N[(N[(0.0005621693121693122 * t$95$0 + 0.005555555555555556), $MachinePrecision] * t$95$0 + 0.05555555555555555), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision] + 0.6666666666666666), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[Sin[N[Abs[x], $MachinePrecision]], $MachinePrecision] / N[(N[Cos[N[Abs[x], $MachinePrecision]], $MachinePrecision] * -1.3333333333333333 + 1.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]]
      
      \begin{array}{l}
      t_0 := \left|x\right| \cdot \left|x\right|\\
      \mathsf{copysign}\left(1, x\right) \cdot \begin{array}{l}
      \mathbf{if}\;\left|x\right| \leq 0.00135:\\
      \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.0005621693121693122, t\_0, 0.005555555555555556\right), t\_0, 0.05555555555555555\right) \cdot \left|x\right|, \left|x\right|, 0.6666666666666666\right) \cdot \left|x\right|\\
      
      \mathbf{else}:\\
      \;\;\;\;\frac{1}{\frac{\sin \left(\left|x\right|\right)}{\mathsf{fma}\left(\cos \left(\left|x\right|\right), -1.3333333333333333, 1.3333333333333333\right)}}\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if x < 0.0013500000000000001

        1. Initial program 77.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. Taylor expanded in x around 0

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

            \[\leadsto x \cdot \color{blue}{\left(\frac{2}{3} + {x}^{2} \cdot \left(\frac{1}{18} + {x}^{2} \cdot \left(\frac{1}{180} + \frac{17}{30240} \cdot {x}^{2}\right)\right)\right)} \]
          2. lower-+.f64N/A

            \[\leadsto x \cdot \left(\frac{2}{3} + \color{blue}{{x}^{2} \cdot \left(\frac{1}{18} + {x}^{2} \cdot \left(\frac{1}{180} + \frac{17}{30240} \cdot {x}^{2}\right)\right)}\right) \]
          3. lower-*.f64N/A

            \[\leadsto x \cdot \left(\frac{2}{3} + {x}^{2} \cdot \color{blue}{\left(\frac{1}{18} + {x}^{2} \cdot \left(\frac{1}{180} + \frac{17}{30240} \cdot {x}^{2}\right)\right)}\right) \]
          4. lower-pow.f64N/A

            \[\leadsto x \cdot \left(\frac{2}{3} + {x}^{2} \cdot \left(\color{blue}{\frac{1}{18}} + {x}^{2} \cdot \left(\frac{1}{180} + \frac{17}{30240} \cdot {x}^{2}\right)\right)\right) \]
          5. lower-+.f64N/A

            \[\leadsto x \cdot \left(\frac{2}{3} + {x}^{2} \cdot \left(\frac{1}{18} + \color{blue}{{x}^{2} \cdot \left(\frac{1}{180} + \frac{17}{30240} \cdot {x}^{2}\right)}\right)\right) \]
          6. lower-*.f64N/A

            \[\leadsto x \cdot \left(\frac{2}{3} + {x}^{2} \cdot \left(\frac{1}{18} + {x}^{2} \cdot \color{blue}{\left(\frac{1}{180} + \frac{17}{30240} \cdot {x}^{2}\right)}\right)\right) \]
          7. lower-pow.f64N/A

            \[\leadsto x \cdot \left(\frac{2}{3} + {x}^{2} \cdot \left(\frac{1}{18} + {x}^{2} \cdot \left(\color{blue}{\frac{1}{180}} + \frac{17}{30240} \cdot {x}^{2}\right)\right)\right) \]
          8. lower-+.f64N/A

            \[\leadsto x \cdot \left(\frac{2}{3} + {x}^{2} \cdot \left(\frac{1}{18} + {x}^{2} \cdot \left(\frac{1}{180} + \color{blue}{\frac{17}{30240} \cdot {x}^{2}}\right)\right)\right) \]
          9. lower-*.f64N/A

            \[\leadsto x \cdot \left(\frac{2}{3} + {x}^{2} \cdot \left(\frac{1}{18} + {x}^{2} \cdot \left(\frac{1}{180} + \frac{17}{30240} \cdot \color{blue}{{x}^{2}}\right)\right)\right) \]
          10. lower-pow.f6451.0%

            \[\leadsto x \cdot \left(0.6666666666666666 + {x}^{2} \cdot \left(0.05555555555555555 + {x}^{2} \cdot \left(0.005555555555555556 + 0.0005621693121693122 \cdot {x}^{\color{blue}{2}}\right)\right)\right) \]
        4. Applied rewrites51.0%

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

            \[\leadsto x \cdot \color{blue}{\left(\frac{2}{3} + {x}^{2} \cdot \left(\frac{1}{18} + {x}^{2} \cdot \left(\frac{1}{180} + \frac{17}{30240} \cdot {x}^{2}\right)\right)\right)} \]
          2. *-commutativeN/A

            \[\leadsto \left(\frac{2}{3} + {x}^{2} \cdot \left(\frac{1}{18} + {x}^{2} \cdot \left(\frac{1}{180} + \frac{17}{30240} \cdot {x}^{2}\right)\right)\right) \cdot \color{blue}{x} \]
          3. lower-*.f6451.0%

            \[\leadsto \left(0.6666666666666666 + {x}^{2} \cdot \left(0.05555555555555555 + {x}^{2} \cdot \left(0.005555555555555556 + 0.0005621693121693122 \cdot {x}^{2}\right)\right)\right) \cdot \color{blue}{x} \]
        6. Applied rewrites51.0%

          \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.0005621693121693122, x \cdot x, 0.005555555555555556\right), x \cdot x, 0.05555555555555555\right) \cdot x, x, 0.6666666666666666\right) \cdot \color{blue}{x} \]

        if 0.0013500000000000001 < x

        1. Initial program 77.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 \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} \]
          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. 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} \]
          4. lift-sin.f64N/A

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

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

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

            \[\leadsto \frac{\frac{8}{3} \cdot \color{blue}{\left(\frac{1}{2} + \left(\mathsf{neg}\left(\frac{1}{2} \cdot \cos \left(2 \cdot \left(x \cdot \frac{1}{2}\right)\right)\right)\right)\right)}}{\sin x} \]
          8. distribute-rgt-inN/A

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

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

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

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

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

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

          \[\leadsto \frac{\color{blue}{1.3333333333333333 + \left(-0.5 \cdot \cos x\right) \cdot 2.6666666666666665}}{\sin x} \]
        4. Step-by-step derivation
          1. metadata-evalN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \frac{1}{\frac{\sin x}{\cos x \cdot \color{blue}{\left(\mathsf{neg}\left(\frac{4}{3}\right)\right)} + \frac{4}{3}}} \]
          15. lower-fma.f64N/A

            \[\leadsto \frac{1}{\frac{\sin x}{\color{blue}{\mathsf{fma}\left(\cos x, \mathsf{neg}\left(\frac{4}{3}\right), \frac{4}{3}\right)}}} \]
          16. metadata-eval52.3%

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

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

      Alternative 6: 99.0% accurate, 1.3× speedup?

      \[\begin{array}{l} t_0 := \left|x\right| \cdot \left|x\right|\\ \mathsf{copysign}\left(1, x\right) \cdot \begin{array}{l} \mathbf{if}\;\left|x\right| \leq 0.00135:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.0005621693121693122, t\_0, 0.005555555555555556\right), t\_0, 0.05555555555555555\right) \cdot \left|x\right|, \left|x\right|, 0.6666666666666666\right) \cdot \left|x\right|\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos \left(\left|x\right|\right) - 1}{-0.75 \cdot \sin \left(\left|x\right|\right)}\\ \end{array} \end{array} \]
      (FPCore (x)
       :precision binary64
       (let* ((t_0 (* (fabs x) (fabs x))))
         (*
          (copysign 1.0 x)
          (if (<= (fabs x) 0.00135)
            (*
             (fma
              (*
               (fma
                (fma 0.0005621693121693122 t_0 0.005555555555555556)
                t_0
                0.05555555555555555)
               (fabs x))
              (fabs x)
              0.6666666666666666)
             (fabs x))
            (/ (- (cos (fabs x)) 1.0) (* -0.75 (sin (fabs x))))))))
      double code(double x) {
      	double t_0 = fabs(x) * fabs(x);
      	double tmp;
      	if (fabs(x) <= 0.00135) {
      		tmp = fma((fma(fma(0.0005621693121693122, t_0, 0.005555555555555556), t_0, 0.05555555555555555) * fabs(x)), fabs(x), 0.6666666666666666) * fabs(x);
      	} else {
      		tmp = (cos(fabs(x)) - 1.0) / (-0.75 * sin(fabs(x)));
      	}
      	return copysign(1.0, x) * tmp;
      }
      
      function code(x)
      	t_0 = Float64(abs(x) * abs(x))
      	tmp = 0.0
      	if (abs(x) <= 0.00135)
      		tmp = Float64(fma(Float64(fma(fma(0.0005621693121693122, t_0, 0.005555555555555556), t_0, 0.05555555555555555) * abs(x)), abs(x), 0.6666666666666666) * abs(x));
      	else
      		tmp = Float64(Float64(cos(abs(x)) - 1.0) / Float64(-0.75 * sin(abs(x))));
      	end
      	return Float64(copysign(1.0, x) * tmp)
      end
      
      code[x_] := Block[{t$95$0 = N[(N[Abs[x], $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[Abs[x], $MachinePrecision], 0.00135], N[(N[(N[(N[(N[(0.0005621693121693122 * t$95$0 + 0.005555555555555556), $MachinePrecision] * t$95$0 + 0.05555555555555555), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision] + 0.6666666666666666), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision], N[(N[(N[Cos[N[Abs[x], $MachinePrecision]], $MachinePrecision] - 1.0), $MachinePrecision] / N[(-0.75 * N[Sin[N[Abs[x], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]]
      
      \begin{array}{l}
      t_0 := \left|x\right| \cdot \left|x\right|\\
      \mathsf{copysign}\left(1, x\right) \cdot \begin{array}{l}
      \mathbf{if}\;\left|x\right| \leq 0.00135:\\
      \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.0005621693121693122, t\_0, 0.005555555555555556\right), t\_0, 0.05555555555555555\right) \cdot \left|x\right|, \left|x\right|, 0.6666666666666666\right) \cdot \left|x\right|\\
      
      \mathbf{else}:\\
      \;\;\;\;\frac{\cos \left(\left|x\right|\right) - 1}{-0.75 \cdot \sin \left(\left|x\right|\right)}\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if x < 0.0013500000000000001

        1. Initial program 77.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. Taylor expanded in x around 0

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

            \[\leadsto x \cdot \color{blue}{\left(\frac{2}{3} + {x}^{2} \cdot \left(\frac{1}{18} + {x}^{2} \cdot \left(\frac{1}{180} + \frac{17}{30240} \cdot {x}^{2}\right)\right)\right)} \]
          2. lower-+.f64N/A

            \[\leadsto x \cdot \left(\frac{2}{3} + \color{blue}{{x}^{2} \cdot \left(\frac{1}{18} + {x}^{2} \cdot \left(\frac{1}{180} + \frac{17}{30240} \cdot {x}^{2}\right)\right)}\right) \]
          3. lower-*.f64N/A

            \[\leadsto x \cdot \left(\frac{2}{3} + {x}^{2} \cdot \color{blue}{\left(\frac{1}{18} + {x}^{2} \cdot \left(\frac{1}{180} + \frac{17}{30240} \cdot {x}^{2}\right)\right)}\right) \]
          4. lower-pow.f64N/A

            \[\leadsto x \cdot \left(\frac{2}{3} + {x}^{2} \cdot \left(\color{blue}{\frac{1}{18}} + {x}^{2} \cdot \left(\frac{1}{180} + \frac{17}{30240} \cdot {x}^{2}\right)\right)\right) \]
          5. lower-+.f64N/A

            \[\leadsto x \cdot \left(\frac{2}{3} + {x}^{2} \cdot \left(\frac{1}{18} + \color{blue}{{x}^{2} \cdot \left(\frac{1}{180} + \frac{17}{30240} \cdot {x}^{2}\right)}\right)\right) \]
          6. lower-*.f64N/A

            \[\leadsto x \cdot \left(\frac{2}{3} + {x}^{2} \cdot \left(\frac{1}{18} + {x}^{2} \cdot \color{blue}{\left(\frac{1}{180} + \frac{17}{30240} \cdot {x}^{2}\right)}\right)\right) \]
          7. lower-pow.f64N/A

            \[\leadsto x \cdot \left(\frac{2}{3} + {x}^{2} \cdot \left(\frac{1}{18} + {x}^{2} \cdot \left(\color{blue}{\frac{1}{180}} + \frac{17}{30240} \cdot {x}^{2}\right)\right)\right) \]
          8. lower-+.f64N/A

            \[\leadsto x \cdot \left(\frac{2}{3} + {x}^{2} \cdot \left(\frac{1}{18} + {x}^{2} \cdot \left(\frac{1}{180} + \color{blue}{\frac{17}{30240} \cdot {x}^{2}}\right)\right)\right) \]
          9. lower-*.f64N/A

            \[\leadsto x \cdot \left(\frac{2}{3} + {x}^{2} \cdot \left(\frac{1}{18} + {x}^{2} \cdot \left(\frac{1}{180} + \frac{17}{30240} \cdot \color{blue}{{x}^{2}}\right)\right)\right) \]
          10. lower-pow.f6451.0%

            \[\leadsto x \cdot \left(0.6666666666666666 + {x}^{2} \cdot \left(0.05555555555555555 + {x}^{2} \cdot \left(0.005555555555555556 + 0.0005621693121693122 \cdot {x}^{\color{blue}{2}}\right)\right)\right) \]
        4. Applied rewrites51.0%

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

            \[\leadsto x \cdot \color{blue}{\left(\frac{2}{3} + {x}^{2} \cdot \left(\frac{1}{18} + {x}^{2} \cdot \left(\frac{1}{180} + \frac{17}{30240} \cdot {x}^{2}\right)\right)\right)} \]
          2. *-commutativeN/A

            \[\leadsto \left(\frac{2}{3} + {x}^{2} \cdot \left(\frac{1}{18} + {x}^{2} \cdot \left(\frac{1}{180} + \frac{17}{30240} \cdot {x}^{2}\right)\right)\right) \cdot \color{blue}{x} \]
          3. lower-*.f6451.0%

            \[\leadsto \left(0.6666666666666666 + {x}^{2} \cdot \left(0.05555555555555555 + {x}^{2} \cdot \left(0.005555555555555556 + 0.0005621693121693122 \cdot {x}^{2}\right)\right)\right) \cdot \color{blue}{x} \]
        6. Applied rewrites51.0%

          \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.0005621693121693122, x \cdot x, 0.005555555555555556\right), x \cdot x, 0.05555555555555555\right) \cdot x, x, 0.6666666666666666\right) \cdot \color{blue}{x} \]

        if 0.0013500000000000001 < x

        1. Initial program 77.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 \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} \]
          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. 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} \]
          4. lift-sin.f64N/A

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

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

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

            \[\leadsto \frac{\frac{8}{3} \cdot \color{blue}{\left(\frac{1}{2} + \left(\mathsf{neg}\left(\frac{1}{2} \cdot \cos \left(2 \cdot \left(x \cdot \frac{1}{2}\right)\right)\right)\right)\right)}}{\sin x} \]
          8. distribute-rgt-inN/A

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

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

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

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

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

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

          \[\leadsto \frac{\color{blue}{1.3333333333333333 + \left(-0.5 \cdot \cos x\right) \cdot 2.6666666666666665}}{\sin x} \]
        4. Step-by-step derivation
          1. metadata-evalN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \frac{\color{blue}{\frac{-4}{3}} \cdot \cos x - \left(\mathsf{neg}\left(\frac{4}{3}\right)\right)}{\sin x} \]
          15. metadata-eval52.2%

            \[\leadsto \frac{-1.3333333333333333 \cdot \cos x - \color{blue}{-1.3333333333333333}}{\sin x} \]
        5. Applied rewrites52.2%

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

            \[\leadsto \color{blue}{\frac{\frac{-4}{3} \cdot \cos x - \frac{-4}{3}}{\sin x}} \]
          2. lift--.f64N/A

            \[\leadsto \frac{\color{blue}{\frac{-4}{3} \cdot \cos x - \frac{-4}{3}}}{\sin x} \]
          3. metadata-evalN/A

            \[\leadsto \frac{\frac{-4}{3} \cdot \cos x - \color{blue}{\frac{1}{\frac{-3}{4}}}}{\sin x} \]
          4. metadata-evalN/A

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

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

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

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

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

            \[\leadsto \frac{\color{blue}{\frac{\cos x}{-2 \cdot \frac{3}{8}}} - \frac{1}{-2 \cdot \frac{3}{8}}}{\sin x} \]
          10. div-subN/A

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

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

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

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

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

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

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

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

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

            \[\leadsto \frac{1}{\color{blue}{\frac{-2 \cdot \frac{3}{8}}{\cos x - 1}} \cdot \sin x} \]
        7. Applied rewrites52.3%

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

      Alternative 7: 98.9% accurate, 1.3× speedup?

      \[\begin{array}{l} t_0 := \left|x\right| \cdot \left|x\right|\\ \mathsf{copysign}\left(1, x\right) \cdot \begin{array}{l} \mathbf{if}\;\left|x\right| \leq 0.00135:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.0005621693121693122, t\_0, 0.005555555555555556\right), t\_0, 0.05555555555555555\right) \cdot \left|x\right|, \left|x\right|, 0.6666666666666666\right) \cdot \left|x\right|\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\cos \left(\left|x\right|\right), -1.3333333333333333, 1.3333333333333333\right)}{\sin \left(\left|x\right|\right)}\\ \end{array} \end{array} \]
      (FPCore (x)
       :precision binary64
       (let* ((t_0 (* (fabs x) (fabs x))))
         (*
          (copysign 1.0 x)
          (if (<= (fabs x) 0.00135)
            (*
             (fma
              (*
               (fma
                (fma 0.0005621693121693122 t_0 0.005555555555555556)
                t_0
                0.05555555555555555)
               (fabs x))
              (fabs x)
              0.6666666666666666)
             (fabs x))
            (/
             (fma (cos (fabs x)) -1.3333333333333333 1.3333333333333333)
             (sin (fabs x)))))))
      double code(double x) {
      	double t_0 = fabs(x) * fabs(x);
      	double tmp;
      	if (fabs(x) <= 0.00135) {
      		tmp = fma((fma(fma(0.0005621693121693122, t_0, 0.005555555555555556), t_0, 0.05555555555555555) * fabs(x)), fabs(x), 0.6666666666666666) * fabs(x);
      	} else {
      		tmp = fma(cos(fabs(x)), -1.3333333333333333, 1.3333333333333333) / sin(fabs(x));
      	}
      	return copysign(1.0, x) * tmp;
      }
      
      function code(x)
      	t_0 = Float64(abs(x) * abs(x))
      	tmp = 0.0
      	if (abs(x) <= 0.00135)
      		tmp = Float64(fma(Float64(fma(fma(0.0005621693121693122, t_0, 0.005555555555555556), t_0, 0.05555555555555555) * abs(x)), abs(x), 0.6666666666666666) * abs(x));
      	else
      		tmp = Float64(fma(cos(abs(x)), -1.3333333333333333, 1.3333333333333333) / sin(abs(x)));
      	end
      	return Float64(copysign(1.0, x) * tmp)
      end
      
      code[x_] := Block[{t$95$0 = N[(N[Abs[x], $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[Abs[x], $MachinePrecision], 0.00135], N[(N[(N[(N[(N[(0.0005621693121693122 * t$95$0 + 0.005555555555555556), $MachinePrecision] * t$95$0 + 0.05555555555555555), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision] + 0.6666666666666666), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision], N[(N[(N[Cos[N[Abs[x], $MachinePrecision]], $MachinePrecision] * -1.3333333333333333 + 1.3333333333333333), $MachinePrecision] / N[Sin[N[Abs[x], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]]
      
      \begin{array}{l}
      t_0 := \left|x\right| \cdot \left|x\right|\\
      \mathsf{copysign}\left(1, x\right) \cdot \begin{array}{l}
      \mathbf{if}\;\left|x\right| \leq 0.00135:\\
      \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.0005621693121693122, t\_0, 0.005555555555555556\right), t\_0, 0.05555555555555555\right) \cdot \left|x\right|, \left|x\right|, 0.6666666666666666\right) \cdot \left|x\right|\\
      
      \mathbf{else}:\\
      \;\;\;\;\frac{\mathsf{fma}\left(\cos \left(\left|x\right|\right), -1.3333333333333333, 1.3333333333333333\right)}{\sin \left(\left|x\right|\right)}\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if x < 0.0013500000000000001

        1. Initial program 77.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. Taylor expanded in x around 0

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

            \[\leadsto x \cdot \color{blue}{\left(\frac{2}{3} + {x}^{2} \cdot \left(\frac{1}{18} + {x}^{2} \cdot \left(\frac{1}{180} + \frac{17}{30240} \cdot {x}^{2}\right)\right)\right)} \]
          2. lower-+.f64N/A

            \[\leadsto x \cdot \left(\frac{2}{3} + \color{blue}{{x}^{2} \cdot \left(\frac{1}{18} + {x}^{2} \cdot \left(\frac{1}{180} + \frac{17}{30240} \cdot {x}^{2}\right)\right)}\right) \]
          3. lower-*.f64N/A

            \[\leadsto x \cdot \left(\frac{2}{3} + {x}^{2} \cdot \color{blue}{\left(\frac{1}{18} + {x}^{2} \cdot \left(\frac{1}{180} + \frac{17}{30240} \cdot {x}^{2}\right)\right)}\right) \]
          4. lower-pow.f64N/A

            \[\leadsto x \cdot \left(\frac{2}{3} + {x}^{2} \cdot \left(\color{blue}{\frac{1}{18}} + {x}^{2} \cdot \left(\frac{1}{180} + \frac{17}{30240} \cdot {x}^{2}\right)\right)\right) \]
          5. lower-+.f64N/A

            \[\leadsto x \cdot \left(\frac{2}{3} + {x}^{2} \cdot \left(\frac{1}{18} + \color{blue}{{x}^{2} \cdot \left(\frac{1}{180} + \frac{17}{30240} \cdot {x}^{2}\right)}\right)\right) \]
          6. lower-*.f64N/A

            \[\leadsto x \cdot \left(\frac{2}{3} + {x}^{2} \cdot \left(\frac{1}{18} + {x}^{2} \cdot \color{blue}{\left(\frac{1}{180} + \frac{17}{30240} \cdot {x}^{2}\right)}\right)\right) \]
          7. lower-pow.f64N/A

            \[\leadsto x \cdot \left(\frac{2}{3} + {x}^{2} \cdot \left(\frac{1}{18} + {x}^{2} \cdot \left(\color{blue}{\frac{1}{180}} + \frac{17}{30240} \cdot {x}^{2}\right)\right)\right) \]
          8. lower-+.f64N/A

            \[\leadsto x \cdot \left(\frac{2}{3} + {x}^{2} \cdot \left(\frac{1}{18} + {x}^{2} \cdot \left(\frac{1}{180} + \color{blue}{\frac{17}{30240} \cdot {x}^{2}}\right)\right)\right) \]
          9. lower-*.f64N/A

            \[\leadsto x \cdot \left(\frac{2}{3} + {x}^{2} \cdot \left(\frac{1}{18} + {x}^{2} \cdot \left(\frac{1}{180} + \frac{17}{30240} \cdot \color{blue}{{x}^{2}}\right)\right)\right) \]
          10. lower-pow.f6451.0%

            \[\leadsto x \cdot \left(0.6666666666666666 + {x}^{2} \cdot \left(0.05555555555555555 + {x}^{2} \cdot \left(0.005555555555555556 + 0.0005621693121693122 \cdot {x}^{\color{blue}{2}}\right)\right)\right) \]
        4. Applied rewrites51.0%

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

            \[\leadsto x \cdot \color{blue}{\left(\frac{2}{3} + {x}^{2} \cdot \left(\frac{1}{18} + {x}^{2} \cdot \left(\frac{1}{180} + \frac{17}{30240} \cdot {x}^{2}\right)\right)\right)} \]
          2. *-commutativeN/A

            \[\leadsto \left(\frac{2}{3} + {x}^{2} \cdot \left(\frac{1}{18} + {x}^{2} \cdot \left(\frac{1}{180} + \frac{17}{30240} \cdot {x}^{2}\right)\right)\right) \cdot \color{blue}{x} \]
          3. lower-*.f6451.0%

            \[\leadsto \left(0.6666666666666666 + {x}^{2} \cdot \left(0.05555555555555555 + {x}^{2} \cdot \left(0.005555555555555556 + 0.0005621693121693122 \cdot {x}^{2}\right)\right)\right) \cdot \color{blue}{x} \]
        6. Applied rewrites51.0%

          \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.0005621693121693122, x \cdot x, 0.005555555555555556\right), x \cdot x, 0.05555555555555555\right) \cdot x, x, 0.6666666666666666\right) \cdot \color{blue}{x} \]

        if 0.0013500000000000001 < x

        1. Initial program 77.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 \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} \]
          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. 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} \]
          4. lift-sin.f64N/A

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

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

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

            \[\leadsto \frac{\frac{8}{3} \cdot \color{blue}{\left(\frac{1}{2} + \left(\mathsf{neg}\left(\frac{1}{2} \cdot \cos \left(2 \cdot \left(x \cdot \frac{1}{2}\right)\right)\right)\right)\right)}}{\sin x} \]
          8. distribute-rgt-inN/A

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

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

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

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

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

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

          \[\leadsto \frac{\color{blue}{1.3333333333333333 + \left(-0.5 \cdot \cos x\right) \cdot 2.6666666666666665}}{\sin x} \]
        4. Step-by-step derivation
          1. metadata-evalN/A

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

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

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

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

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

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

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

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

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

            \[\leadsto \frac{\cos x \cdot \color{blue}{\left(\mathsf{neg}\left(\frac{4}{3}\right)\right)} + \frac{4}{3}}{\sin x} \]
          11. lower-fma.f64N/A

            \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\cos x, \mathsf{neg}\left(\frac{4}{3}\right), \frac{4}{3}\right)}}{\sin x} \]
          12. metadata-eval52.3%

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

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

      Alternative 8: 55.2% accurate, 3.0× speedup?

      \[1.3333333333333333 \cdot \sin \left(0.5 \cdot x\right) \]
      (FPCore (x) :precision binary64 (* 1.3333333333333333 (sin (* 0.5 x))))
      double code(double x) {
      	return 1.3333333333333333 * sin((0.5 * x));
      }
      
      module fmin_fmax_functions
          implicit none
          private
          public fmax
          public fmin
      
          interface fmax
              module procedure fmax88
              module procedure fmax44
              module procedure fmax84
              module procedure fmax48
          end interface
          interface fmin
              module procedure fmin88
              module procedure fmin44
              module procedure fmin84
              module procedure fmin48
          end interface
      contains
          real(8) function fmax88(x, y) result (res)
              real(8), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
          end function
          real(4) function fmax44(x, y) result (res)
              real(4), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
          end function
          real(8) function fmax84(x, y) result(res)
              real(8), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
          end function
          real(8) function fmax48(x, y) result(res)
              real(4), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
          end function
          real(8) function fmin88(x, y) result (res)
              real(8), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
          end function
          real(4) function fmin44(x, y) result (res)
              real(4), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
          end function
          real(8) function fmin84(x, y) result(res)
              real(8), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
          end function
          real(8) function fmin48(x, y) result(res)
              real(4), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
          end function
      end module
      
      real(8) function code(x)
      use fmin_fmax_functions
          real(8), intent (in) :: x
          code = 1.3333333333333333d0 * sin((0.5d0 * x))
      end function
      
      public static double code(double x) {
      	return 1.3333333333333333 * Math.sin((0.5 * x));
      }
      
      def code(x):
      	return 1.3333333333333333 * math.sin((0.5 * x))
      
      function code(x)
      	return Float64(1.3333333333333333 * sin(Float64(0.5 * x)))
      end
      
      function tmp = code(x)
      	tmp = 1.3333333333333333 * sin((0.5 * x));
      end
      
      code[x_] := N[(1.3333333333333333 * N[Sin[N[(0.5 * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
      
      1.3333333333333333 \cdot \sin \left(0.5 \cdot x\right)
      
      Derivation
      1. Initial program 77.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. associate-*l/N/A

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \left(\frac{\color{blue}{\frac{8}{3}}}{\sin x} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right) \cdot \sin \left(x \cdot \frac{1}{2}\right) \]
        14. metadata-eval99.2%

          \[\leadsto \left(\frac{\color{blue}{2.6666666666666665}}{\sin x} \cdot \sin \left(x \cdot 0.5\right)\right) \cdot \sin \left(x \cdot 0.5\right) \]
        15. lift-*.f64N/A

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

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

          \[\leadsto \left(\frac{2.6666666666666665}{\sin x} \cdot \sin \color{blue}{\left(0.5 \cdot x\right)}\right) \cdot \sin \left(x \cdot 0.5\right) \]
        18. lift-*.f64N/A

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

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

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

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

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

        Alternative 9: 51.3% accurate, 29.0× speedup?

        \[0.6666666666666666 \cdot x \]
        (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]
        
        0.6666666666666666 \cdot x
        
        Derivation
        1. Initial program 77.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. Taylor expanded in x around 0

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

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

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

        Reproduce

        ?
        herbie shell --seed 2025183 
        (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)))