Linear.Quaternion:$ctanh from linear-1.19.1.3

Percentage Accurate: 96.4% → 96.4%
Time: 3.5s
Alternatives: 12
Speedup: 0.9×

Specification

?
\[\begin{array}{l} \\ \frac{x \cdot \frac{\sin y}{y}}{z} \end{array} \]
(FPCore (x y z) :precision binary64 (/ (* x (/ (sin y) y)) z))
double code(double x, double y, double z) {
	return (x * (sin(y) / y)) / z;
}
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, y, z)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = (x * (sin(y) / y)) / z
end function
public static double code(double x, double y, double z) {
	return (x * (Math.sin(y) / y)) / z;
}
def code(x, y, z):
	return (x * (math.sin(y) / y)) / z
function code(x, y, z)
	return Float64(Float64(x * Float64(sin(y) / y)) / z)
end
function tmp = code(x, y, z)
	tmp = (x * (sin(y) / y)) / z;
end
code[x_, y_, z_] := N[(N[(x * N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}

\\
\frac{x \cdot \frac{\sin y}{y}}{z}
\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 12 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: 96.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{x \cdot \frac{\sin y}{y}}{z} \end{array} \]
(FPCore (x y z) :precision binary64 (/ (* x (/ (sin y) y)) z))
double code(double x, double y, double z) {
	return (x * (sin(y) / y)) / z;
}
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, y, z)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = (x * (sin(y) / y)) / z
end function
public static double code(double x, double y, double z) {
	return (x * (Math.sin(y) / y)) / z;
}
def code(x, y, z):
	return (x * (math.sin(y) / y)) / z
function code(x, y, z)
	return Float64(Float64(x * Float64(sin(y) / y)) / z)
end
function tmp = code(x, y, z)
	tmp = (x * (sin(y) / y)) / z;
end
code[x_, y_, z_] := N[(N[(x * N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}

\\
\frac{x \cdot \frac{\sin y}{y}}{z}
\end{array}

Alternative 1: 96.4% accurate, 0.9× speedup?

\[\begin{array}{l} z\_m = \left|z\right| \\ z\_s = \mathsf{copysign}\left(1, z\right) \\ z\_s \cdot \begin{array}{l} \mathbf{if}\;z\_m \leq 1.5 \cdot 10^{-92}:\\ \;\;\;\;\frac{\sin y}{z\_m} \cdot \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sin y}{y} \cdot \frac{x}{z\_m}\\ \end{array} \end{array} \]
z\_m = (fabs.f64 z)
z\_s = (copysign.f64 #s(literal 1 binary64) z)
(FPCore (z_s x y z_m)
 :precision binary64
 (*
  z_s
  (if (<= z_m 1.5e-92)
    (* (/ (sin y) z_m) (/ x y))
    (* (/ (sin y) y) (/ x z_m)))))
z\_m = fabs(z);
z\_s = copysign(1.0, z);
double code(double z_s, double x, double y, double z_m) {
	double tmp;
	if (z_m <= 1.5e-92) {
		tmp = (sin(y) / z_m) * (x / y);
	} else {
		tmp = (sin(y) / y) * (x / z_m);
	}
	return z_s * tmp;
}
z\_m =     private
z\_s =     private
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(z_s, x, y, z_m)
use fmin_fmax_functions
    real(8), intent (in) :: z_s
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z_m
    real(8) :: tmp
    if (z_m <= 1.5d-92) then
        tmp = (sin(y) / z_m) * (x / y)
    else
        tmp = (sin(y) / y) * (x / z_m)
    end if
    code = z_s * tmp
end function
z\_m = Math.abs(z);
z\_s = Math.copySign(1.0, z);
public static double code(double z_s, double x, double y, double z_m) {
	double tmp;
	if (z_m <= 1.5e-92) {
		tmp = (Math.sin(y) / z_m) * (x / y);
	} else {
		tmp = (Math.sin(y) / y) * (x / z_m);
	}
	return z_s * tmp;
}
z\_m = math.fabs(z)
z\_s = math.copysign(1.0, z)
def code(z_s, x, y, z_m):
	tmp = 0
	if z_m <= 1.5e-92:
		tmp = (math.sin(y) / z_m) * (x / y)
	else:
		tmp = (math.sin(y) / y) * (x / z_m)
	return z_s * tmp
z\_m = abs(z)
z\_s = copysign(1.0, z)
function code(z_s, x, y, z_m)
	tmp = 0.0
	if (z_m <= 1.5e-92)
		tmp = Float64(Float64(sin(y) / z_m) * Float64(x / y));
	else
		tmp = Float64(Float64(sin(y) / y) * Float64(x / z_m));
	end
	return Float64(z_s * tmp)
end
z\_m = abs(z);
z\_s = sign(z) * abs(1.0);
function tmp_2 = code(z_s, x, y, z_m)
	tmp = 0.0;
	if (z_m <= 1.5e-92)
		tmp = (sin(y) / z_m) * (x / y);
	else
		tmp = (sin(y) / y) * (x / z_m);
	end
	tmp_2 = z_s * tmp;
end
z\_m = N[Abs[z], $MachinePrecision]
z\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[z$95$s_, x_, y_, z$95$m_] := N[(z$95$s * If[LessEqual[z$95$m, 1.5e-92], N[(N[(N[Sin[y], $MachinePrecision] / z$95$m), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision] * N[(x / z$95$m), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
z\_m = \left|z\right|
\\
z\_s = \mathsf{copysign}\left(1, z\right)

\\
z\_s \cdot \begin{array}{l}
\mathbf{if}\;z\_m \leq 1.5 \cdot 10^{-92}:\\
\;\;\;\;\frac{\sin y}{z\_m} \cdot \frac{x}{y}\\

\mathbf{else}:\\
\;\;\;\;\frac{\sin y}{y} \cdot \frac{x}{z\_m}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < 1.50000000000000007e-92

    1. Initial program 96.4%

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

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

        \[\leadsto \frac{\color{blue}{x \cdot \frac{\sin y}{y}}}{z} \]
      3. lift-/.f64N/A

        \[\leadsto \frac{x \cdot \color{blue}{\frac{\sin y}{y}}}{z} \]
      4. lift-sin.f64N/A

        \[\leadsto \frac{x \cdot \frac{\color{blue}{\sin y}}{y}}{z} \]
      5. associate-/l*N/A

        \[\leadsto \frac{\color{blue}{\frac{x \cdot \sin y}{y}}}{z} \]
      6. associate-/r*N/A

        \[\leadsto \color{blue}{\frac{x \cdot \sin y}{y \cdot z}} \]
      7. times-fracN/A

        \[\leadsto \color{blue}{\frac{x}{y} \cdot \frac{\sin y}{z}} \]
      8. *-commutativeN/A

        \[\leadsto \color{blue}{\frac{\sin y}{z} \cdot \frac{x}{y}} \]
      9. lower-*.f64N/A

        \[\leadsto \color{blue}{\frac{\sin y}{z} \cdot \frac{x}{y}} \]
      10. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{\sin y}{z}} \cdot \frac{x}{y} \]
      11. lift-sin.f64N/A

        \[\leadsto \frac{\color{blue}{\sin y}}{z} \cdot \frac{x}{y} \]
      12. lower-/.f6484.4

        \[\leadsto \frac{\sin y}{z} \cdot \color{blue}{\frac{x}{y}} \]
    3. Applied rewrites84.4%

      \[\leadsto \color{blue}{\frac{\sin y}{z} \cdot \frac{x}{y}} \]

    if 1.50000000000000007e-92 < z

    1. Initial program 96.4%

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

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

        \[\leadsto \frac{\color{blue}{x \cdot \frac{\sin y}{y}}}{z} \]
      3. lift-/.f64N/A

        \[\leadsto \frac{x \cdot \color{blue}{\frac{\sin y}{y}}}{z} \]
      4. lift-sin.f64N/A

        \[\leadsto \frac{x \cdot \frac{\color{blue}{\sin y}}{y}}{z} \]
      5. *-commutativeN/A

        \[\leadsto \frac{\color{blue}{\frac{\sin y}{y} \cdot x}}{z} \]
      6. associate-/l*N/A

        \[\leadsto \color{blue}{\frac{\sin y}{y} \cdot \frac{x}{z}} \]
      7. lower-*.f64N/A

        \[\leadsto \color{blue}{\frac{\sin y}{y} \cdot \frac{x}{z}} \]
      8. lift-sin.f64N/A

        \[\leadsto \frac{\color{blue}{\sin y}}{y} \cdot \frac{x}{z} \]
      9. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{\sin y}{y}} \cdot \frac{x}{z} \]
      10. lower-/.f6495.6

        \[\leadsto \frac{\sin y}{y} \cdot \color{blue}{\frac{x}{z}} \]
    3. Applied rewrites95.6%

      \[\leadsto \color{blue}{\frac{\sin y}{y} \cdot \frac{x}{z}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 2: 96.3% accurate, 0.5× speedup?

\[\begin{array}{l} z\_m = \left|z\right| \\ z\_s = \mathsf{copysign}\left(1, z\right) \\ \begin{array}{l} t_0 := \frac{\sin y}{y}\\ z\_s \cdot \begin{array}{l} \mathbf{if}\;t\_0 \leq 10^{-128}:\\ \;\;\;\;\sin y \cdot \frac{\frac{x}{y}}{z\_m}\\ \mathbf{else}:\\ \;\;\;\;t\_0 \cdot \frac{x}{z\_m}\\ \end{array} \end{array} \end{array} \]
z\_m = (fabs.f64 z)
z\_s = (copysign.f64 #s(literal 1 binary64) z)
(FPCore (z_s x y z_m)
 :precision binary64
 (let* ((t_0 (/ (sin y) y)))
   (* z_s (if (<= t_0 1e-128) (* (sin y) (/ (/ x y) z_m)) (* t_0 (/ x z_m))))))
z\_m = fabs(z);
z\_s = copysign(1.0, z);
double code(double z_s, double x, double y, double z_m) {
	double t_0 = sin(y) / y;
	double tmp;
	if (t_0 <= 1e-128) {
		tmp = sin(y) * ((x / y) / z_m);
	} else {
		tmp = t_0 * (x / z_m);
	}
	return z_s * tmp;
}
z\_m =     private
z\_s =     private
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(z_s, x, y, z_m)
use fmin_fmax_functions
    real(8), intent (in) :: z_s
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z_m
    real(8) :: t_0
    real(8) :: tmp
    t_0 = sin(y) / y
    if (t_0 <= 1d-128) then
        tmp = sin(y) * ((x / y) / z_m)
    else
        tmp = t_0 * (x / z_m)
    end if
    code = z_s * tmp
end function
z\_m = Math.abs(z);
z\_s = Math.copySign(1.0, z);
public static double code(double z_s, double x, double y, double z_m) {
	double t_0 = Math.sin(y) / y;
	double tmp;
	if (t_0 <= 1e-128) {
		tmp = Math.sin(y) * ((x / y) / z_m);
	} else {
		tmp = t_0 * (x / z_m);
	}
	return z_s * tmp;
}
z\_m = math.fabs(z)
z\_s = math.copysign(1.0, z)
def code(z_s, x, y, z_m):
	t_0 = math.sin(y) / y
	tmp = 0
	if t_0 <= 1e-128:
		tmp = math.sin(y) * ((x / y) / z_m)
	else:
		tmp = t_0 * (x / z_m)
	return z_s * tmp
z\_m = abs(z)
z\_s = copysign(1.0, z)
function code(z_s, x, y, z_m)
	t_0 = Float64(sin(y) / y)
	tmp = 0.0
	if (t_0 <= 1e-128)
		tmp = Float64(sin(y) * Float64(Float64(x / y) / z_m));
	else
		tmp = Float64(t_0 * Float64(x / z_m));
	end
	return Float64(z_s * tmp)
end
z\_m = abs(z);
z\_s = sign(z) * abs(1.0);
function tmp_2 = code(z_s, x, y, z_m)
	t_0 = sin(y) / y;
	tmp = 0.0;
	if (t_0 <= 1e-128)
		tmp = sin(y) * ((x / y) / z_m);
	else
		tmp = t_0 * (x / z_m);
	end
	tmp_2 = z_s * tmp;
end
z\_m = N[Abs[z], $MachinePrecision]
z\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[z$95$s_, x_, y_, z$95$m_] := Block[{t$95$0 = N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision]}, N[(z$95$s * If[LessEqual[t$95$0, 1e-128], N[(N[Sin[y], $MachinePrecision] * N[(N[(x / y), $MachinePrecision] / z$95$m), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(x / z$95$m), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]]
\begin{array}{l}
z\_m = \left|z\right|
\\
z\_s = \mathsf{copysign}\left(1, z\right)

\\
\begin{array}{l}
t_0 := \frac{\sin y}{y}\\
z\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_0 \leq 10^{-128}:\\
\;\;\;\;\sin y \cdot \frac{\frac{x}{y}}{z\_m}\\

\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \frac{x}{z\_m}\\


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (sin.f64 y) y) < 1.00000000000000005e-128

    1. Initial program 96.4%

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

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

        \[\leadsto \frac{\color{blue}{x \cdot \frac{\sin y}{y}}}{z} \]
      3. lift-/.f64N/A

        \[\leadsto \frac{x \cdot \color{blue}{\frac{\sin y}{y}}}{z} \]
      4. lift-sin.f64N/A

        \[\leadsto \frac{x \cdot \frac{\color{blue}{\sin y}}{y}}{z} \]
      5. associate-/l*N/A

        \[\leadsto \frac{\color{blue}{\frac{x \cdot \sin y}{y}}}{z} \]
      6. associate-/r*N/A

        \[\leadsto \color{blue}{\frac{x \cdot \sin y}{y \cdot z}} \]
      7. *-commutativeN/A

        \[\leadsto \frac{\color{blue}{\sin y \cdot x}}{y \cdot z} \]
      8. associate-/l*N/A

        \[\leadsto \color{blue}{\sin y \cdot \frac{x}{y \cdot z}} \]
      9. lower-*.f64N/A

        \[\leadsto \color{blue}{\sin y \cdot \frac{x}{y \cdot z}} \]
      10. lift-sin.f64N/A

        \[\leadsto \color{blue}{\sin y} \cdot \frac{x}{y \cdot z} \]
      11. lower-/.f64N/A

        \[\leadsto \sin y \cdot \color{blue}{\frac{x}{y \cdot z}} \]
      12. *-commutativeN/A

        \[\leadsto \sin y \cdot \frac{x}{\color{blue}{z \cdot y}} \]
      13. lower-*.f6484.0

        \[\leadsto \sin y \cdot \frac{x}{\color{blue}{z \cdot y}} \]
    3. Applied rewrites84.0%

      \[\leadsto \color{blue}{\sin y \cdot \frac{x}{z \cdot y}} \]
    4. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \sin y \cdot \frac{x}{\color{blue}{z \cdot y}} \]
      2. lift-/.f64N/A

        \[\leadsto \sin y \cdot \color{blue}{\frac{x}{z \cdot y}} \]
      3. *-commutativeN/A

        \[\leadsto \sin y \cdot \frac{x}{\color{blue}{y \cdot z}} \]
      4. associate-/r*N/A

        \[\leadsto \sin y \cdot \color{blue}{\frac{\frac{x}{y}}{z}} \]
      5. lower-/.f64N/A

        \[\leadsto \sin y \cdot \color{blue}{\frac{\frac{x}{y}}{z}} \]
      6. lower-/.f6484.2

        \[\leadsto \sin y \cdot \frac{\color{blue}{\frac{x}{y}}}{z} \]
    5. Applied rewrites84.2%

      \[\leadsto \sin y \cdot \color{blue}{\frac{\frac{x}{y}}{z}} \]

    if 1.00000000000000005e-128 < (/.f64 (sin.f64 y) y)

    1. Initial program 96.4%

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

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

        \[\leadsto \frac{\color{blue}{x \cdot \frac{\sin y}{y}}}{z} \]
      3. lift-/.f64N/A

        \[\leadsto \frac{x \cdot \color{blue}{\frac{\sin y}{y}}}{z} \]
      4. lift-sin.f64N/A

        \[\leadsto \frac{x \cdot \frac{\color{blue}{\sin y}}{y}}{z} \]
      5. *-commutativeN/A

        \[\leadsto \frac{\color{blue}{\frac{\sin y}{y} \cdot x}}{z} \]
      6. associate-/l*N/A

        \[\leadsto \color{blue}{\frac{\sin y}{y} \cdot \frac{x}{z}} \]
      7. lower-*.f64N/A

        \[\leadsto \color{blue}{\frac{\sin y}{y} \cdot \frac{x}{z}} \]
      8. lift-sin.f64N/A

        \[\leadsto \frac{\color{blue}{\sin y}}{y} \cdot \frac{x}{z} \]
      9. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{\sin y}{y}} \cdot \frac{x}{z} \]
      10. lower-/.f6495.6

        \[\leadsto \frac{\sin y}{y} \cdot \color{blue}{\frac{x}{z}} \]
    3. Applied rewrites95.6%

      \[\leadsto \color{blue}{\frac{\sin y}{y} \cdot \frac{x}{z}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 3: 96.2% accurate, 0.5× speedup?

\[\begin{array}{l} z\_m = \left|z\right| \\ z\_s = \mathsf{copysign}\left(1, z\right) \\ z\_s \cdot \begin{array}{l} \mathbf{if}\;\frac{\sin y}{y} \leq 0.002:\\ \;\;\;\;\sin y \cdot \frac{\frac{x}{y}}{z\_m}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot \mathsf{fma}\left(\mathsf{fma}\left(0.008333333333333333, y \cdot y, -0.16666666666666666\right), y \cdot y, 1\right)}{z\_m}\\ \end{array} \end{array} \]
z\_m = (fabs.f64 z)
z\_s = (copysign.f64 #s(literal 1 binary64) z)
(FPCore (z_s x y z_m)
 :precision binary64
 (*
  z_s
  (if (<= (/ (sin y) y) 0.002)
    (* (sin y) (/ (/ x y) z_m))
    (/
     (*
      x
      (fma
       (fma 0.008333333333333333 (* y y) -0.16666666666666666)
       (* y y)
       1.0))
     z_m))))
z\_m = fabs(z);
z\_s = copysign(1.0, z);
double code(double z_s, double x, double y, double z_m) {
	double tmp;
	if ((sin(y) / y) <= 0.002) {
		tmp = sin(y) * ((x / y) / z_m);
	} else {
		tmp = (x * fma(fma(0.008333333333333333, (y * y), -0.16666666666666666), (y * y), 1.0)) / z_m;
	}
	return z_s * tmp;
}
z\_m = abs(z)
z\_s = copysign(1.0, z)
function code(z_s, x, y, z_m)
	tmp = 0.0
	if (Float64(sin(y) / y) <= 0.002)
		tmp = Float64(sin(y) * Float64(Float64(x / y) / z_m));
	else
		tmp = Float64(Float64(x * fma(fma(0.008333333333333333, Float64(y * y), -0.16666666666666666), Float64(y * y), 1.0)) / z_m);
	end
	return Float64(z_s * tmp)
end
z\_m = N[Abs[z], $MachinePrecision]
z\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[z$95$s_, x_, y_, z$95$m_] := N[(z$95$s * If[LessEqual[N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision], 0.002], N[(N[Sin[y], $MachinePrecision] * N[(N[(x / y), $MachinePrecision] / z$95$m), $MachinePrecision]), $MachinePrecision], N[(N[(x * N[(N[(0.008333333333333333 * N[(y * y), $MachinePrecision] + -0.16666666666666666), $MachinePrecision] * N[(y * y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / z$95$m), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
z\_m = \left|z\right|
\\
z\_s = \mathsf{copysign}\left(1, z\right)

\\
z\_s \cdot \begin{array}{l}
\mathbf{if}\;\frac{\sin y}{y} \leq 0.002:\\
\;\;\;\;\sin y \cdot \frac{\frac{x}{y}}{z\_m}\\

\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \mathsf{fma}\left(\mathsf{fma}\left(0.008333333333333333, y \cdot y, -0.16666666666666666\right), y \cdot y, 1\right)}{z\_m}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (sin.f64 y) y) < 2e-3

    1. Initial program 96.4%

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

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

        \[\leadsto \frac{\color{blue}{x \cdot \frac{\sin y}{y}}}{z} \]
      3. lift-/.f64N/A

        \[\leadsto \frac{x \cdot \color{blue}{\frac{\sin y}{y}}}{z} \]
      4. lift-sin.f64N/A

        \[\leadsto \frac{x \cdot \frac{\color{blue}{\sin y}}{y}}{z} \]
      5. associate-/l*N/A

        \[\leadsto \frac{\color{blue}{\frac{x \cdot \sin y}{y}}}{z} \]
      6. associate-/r*N/A

        \[\leadsto \color{blue}{\frac{x \cdot \sin y}{y \cdot z}} \]
      7. *-commutativeN/A

        \[\leadsto \frac{\color{blue}{\sin y \cdot x}}{y \cdot z} \]
      8. associate-/l*N/A

        \[\leadsto \color{blue}{\sin y \cdot \frac{x}{y \cdot z}} \]
      9. lower-*.f64N/A

        \[\leadsto \color{blue}{\sin y \cdot \frac{x}{y \cdot z}} \]
      10. lift-sin.f64N/A

        \[\leadsto \color{blue}{\sin y} \cdot \frac{x}{y \cdot z} \]
      11. lower-/.f64N/A

        \[\leadsto \sin y \cdot \color{blue}{\frac{x}{y \cdot z}} \]
      12. *-commutativeN/A

        \[\leadsto \sin y \cdot \frac{x}{\color{blue}{z \cdot y}} \]
      13. lower-*.f6484.0

        \[\leadsto \sin y \cdot \frac{x}{\color{blue}{z \cdot y}} \]
    3. Applied rewrites84.0%

      \[\leadsto \color{blue}{\sin y \cdot \frac{x}{z \cdot y}} \]
    4. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \sin y \cdot \frac{x}{\color{blue}{z \cdot y}} \]
      2. lift-/.f64N/A

        \[\leadsto \sin y \cdot \color{blue}{\frac{x}{z \cdot y}} \]
      3. *-commutativeN/A

        \[\leadsto \sin y \cdot \frac{x}{\color{blue}{y \cdot z}} \]
      4. associate-/r*N/A

        \[\leadsto \sin y \cdot \color{blue}{\frac{\frac{x}{y}}{z}} \]
      5. lower-/.f64N/A

        \[\leadsto \sin y \cdot \color{blue}{\frac{\frac{x}{y}}{z}} \]
      6. lower-/.f6484.2

        \[\leadsto \sin y \cdot \frac{\color{blue}{\frac{x}{y}}}{z} \]
    5. Applied rewrites84.2%

      \[\leadsto \sin y \cdot \color{blue}{\frac{\frac{x}{y}}{z}} \]

    if 2e-3 < (/.f64 (sin.f64 y) y)

    1. Initial program 96.4%

      \[\frac{x \cdot \frac{\sin y}{y}}{z} \]
    2. Taylor expanded in y around 0

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

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

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

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

        \[\leadsto \frac{x \cdot \mathsf{fma}\left(y \cdot y, \frac{-1}{6}, 1\right)}{z} \]
      5. lower-*.f6453.2

        \[\leadsto \frac{x \cdot \mathsf{fma}\left(y \cdot y, -0.16666666666666666, 1\right)}{z} \]
    4. Applied rewrites53.2%

      \[\leadsto \frac{x \cdot \color{blue}{\mathsf{fma}\left(y \cdot y, -0.16666666666666666, 1\right)}}{z} \]
    5. Taylor expanded in y around inf

      \[\leadsto \frac{x \cdot \left(\frac{-1}{6} \cdot \color{blue}{{y}^{2}}\right)}{z} \]
    6. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \frac{x \cdot \left({y}^{2} \cdot \frac{-1}{6}\right)}{z} \]
      2. lower-*.f64N/A

        \[\leadsto \frac{x \cdot \left({y}^{2} \cdot \frac{-1}{6}\right)}{z} \]
      3. pow2N/A

        \[\leadsto \frac{x \cdot \left(\left(y \cdot y\right) \cdot \frac{-1}{6}\right)}{z} \]
      4. lift-*.f6410.5

        \[\leadsto \frac{x \cdot \left(\left(y \cdot y\right) \cdot -0.16666666666666666\right)}{z} \]
    7. Applied rewrites10.5%

      \[\leadsto \frac{x \cdot \left(\left(y \cdot y\right) \cdot \color{blue}{-0.16666666666666666}\right)}{z} \]
    8. Taylor expanded in y around 0

      \[\leadsto \frac{x \cdot \color{blue}{\left(1 + {y}^{2} \cdot \left(\frac{1}{120} \cdot {y}^{2} - \frac{1}{6}\right)\right)}}{z} \]
    9. Step-by-step derivation
      1. +-commutativeN/A

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

        \[\leadsto \frac{x \cdot \left(\left(\frac{1}{120} \cdot {y}^{2} - \frac{1}{6}\right) \cdot {y}^{2} + 1\right)}{z} \]
      3. lower-fma.f64N/A

        \[\leadsto \frac{x \cdot \mathsf{fma}\left(\frac{1}{120} \cdot {y}^{2} - \frac{1}{6}, \color{blue}{{y}^{2}}, 1\right)}{z} \]
      4. metadata-evalN/A

        \[\leadsto \frac{x \cdot \mathsf{fma}\left(\frac{1}{120} \cdot {y}^{2} - \frac{1}{6} \cdot 1, {y}^{2}, 1\right)}{z} \]
      5. fp-cancel-sub-sign-invN/A

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

        \[\leadsto \frac{x \cdot \mathsf{fma}\left(\frac{1}{120} \cdot {y}^{2} + \frac{-1}{6} \cdot 1, {y}^{2}, 1\right)}{z} \]
      7. metadata-evalN/A

        \[\leadsto \frac{x \cdot \mathsf{fma}\left(\frac{1}{120} \cdot {y}^{2} + \frac{-1}{6}, {y}^{2}, 1\right)}{z} \]
      8. lower-fma.f64N/A

        \[\leadsto \frac{x \cdot \mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{120}, {y}^{2}, \frac{-1}{6}\right), {\color{blue}{y}}^{2}, 1\right)}{z} \]
      9. pow2N/A

        \[\leadsto \frac{x \cdot \mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{120}, y \cdot y, \frac{-1}{6}\right), {y}^{2}, 1\right)}{z} \]
      10. lift-*.f64N/A

        \[\leadsto \frac{x \cdot \mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{120}, y \cdot y, \frac{-1}{6}\right), {y}^{2}, 1\right)}{z} \]
      11. pow2N/A

        \[\leadsto \frac{x \cdot \mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{120}, y \cdot y, \frac{-1}{6}\right), y \cdot \color{blue}{y}, 1\right)}{z} \]
      12. lift-*.f6452.8

        \[\leadsto \frac{x \cdot \mathsf{fma}\left(\mathsf{fma}\left(0.008333333333333333, y \cdot y, -0.16666666666666666\right), y \cdot \color{blue}{y}, 1\right)}{z} \]
    10. Applied rewrites52.8%

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

Alternative 4: 95.5% accurate, 1.0× speedup?

\[\begin{array}{l} z\_m = \left|z\right| \\ z\_s = \mathsf{copysign}\left(1, z\right) \\ z\_s \cdot \frac{x \cdot \frac{\sin y}{y}}{z\_m} \end{array} \]
z\_m = (fabs.f64 z)
z\_s = (copysign.f64 #s(literal 1 binary64) z)
(FPCore (z_s x y z_m) :precision binary64 (* z_s (/ (* x (/ (sin y) y)) z_m)))
z\_m = fabs(z);
z\_s = copysign(1.0, z);
double code(double z_s, double x, double y, double z_m) {
	return z_s * ((x * (sin(y) / y)) / z_m);
}
z\_m =     private
z\_s =     private
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(z_s, x, y, z_m)
use fmin_fmax_functions
    real(8), intent (in) :: z_s
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z_m
    code = z_s * ((x * (sin(y) / y)) / z_m)
end function
z\_m = Math.abs(z);
z\_s = Math.copySign(1.0, z);
public static double code(double z_s, double x, double y, double z_m) {
	return z_s * ((x * (Math.sin(y) / y)) / z_m);
}
z\_m = math.fabs(z)
z\_s = math.copysign(1.0, z)
def code(z_s, x, y, z_m):
	return z_s * ((x * (math.sin(y) / y)) / z_m)
z\_m = abs(z)
z\_s = copysign(1.0, z)
function code(z_s, x, y, z_m)
	return Float64(z_s * Float64(Float64(x * Float64(sin(y) / y)) / z_m))
end
z\_m = abs(z);
z\_s = sign(z) * abs(1.0);
function tmp = code(z_s, x, y, z_m)
	tmp = z_s * ((x * (sin(y) / y)) / z_m);
end
z\_m = N[Abs[z], $MachinePrecision]
z\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[z$95$s_, x_, y_, z$95$m_] := N[(z$95$s * N[(N[(x * N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] / z$95$m), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
z\_m = \left|z\right|
\\
z\_s = \mathsf{copysign}\left(1, z\right)

\\
z\_s \cdot \frac{x \cdot \frac{\sin y}{y}}{z\_m}
\end{array}
Derivation
  1. Initial program 96.4%

    \[\frac{x \cdot \frac{\sin y}{y}}{z} \]
  2. Add Preprocessing

Alternative 5: 77.6% accurate, 0.9× speedup?

\[\begin{array}{l} z\_m = \left|z\right| \\ z\_s = \mathsf{copysign}\left(1, z\right) \\ z\_s \cdot \begin{array}{l} \mathbf{if}\;y \leq 10^{-13}:\\ \;\;\;\;\frac{x}{z\_m}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sin y}{z\_m \cdot y} \cdot x\\ \end{array} \end{array} \]
z\_m = (fabs.f64 z)
z\_s = (copysign.f64 #s(literal 1 binary64) z)
(FPCore (z_s x y z_m)
 :precision binary64
 (* z_s (if (<= y 1e-13) (/ x z_m) (* (/ (sin y) (* z_m y)) x))))
z\_m = fabs(z);
z\_s = copysign(1.0, z);
double code(double z_s, double x, double y, double z_m) {
	double tmp;
	if (y <= 1e-13) {
		tmp = x / z_m;
	} else {
		tmp = (sin(y) / (z_m * y)) * x;
	}
	return z_s * tmp;
}
z\_m =     private
z\_s =     private
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(z_s, x, y, z_m)
use fmin_fmax_functions
    real(8), intent (in) :: z_s
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z_m
    real(8) :: tmp
    if (y <= 1d-13) then
        tmp = x / z_m
    else
        tmp = (sin(y) / (z_m * y)) * x
    end if
    code = z_s * tmp
end function
z\_m = Math.abs(z);
z\_s = Math.copySign(1.0, z);
public static double code(double z_s, double x, double y, double z_m) {
	double tmp;
	if (y <= 1e-13) {
		tmp = x / z_m;
	} else {
		tmp = (Math.sin(y) / (z_m * y)) * x;
	}
	return z_s * tmp;
}
z\_m = math.fabs(z)
z\_s = math.copysign(1.0, z)
def code(z_s, x, y, z_m):
	tmp = 0
	if y <= 1e-13:
		tmp = x / z_m
	else:
		tmp = (math.sin(y) / (z_m * y)) * x
	return z_s * tmp
z\_m = abs(z)
z\_s = copysign(1.0, z)
function code(z_s, x, y, z_m)
	tmp = 0.0
	if (y <= 1e-13)
		tmp = Float64(x / z_m);
	else
		tmp = Float64(Float64(sin(y) / Float64(z_m * y)) * x);
	end
	return Float64(z_s * tmp)
end
z\_m = abs(z);
z\_s = sign(z) * abs(1.0);
function tmp_2 = code(z_s, x, y, z_m)
	tmp = 0.0;
	if (y <= 1e-13)
		tmp = x / z_m;
	else
		tmp = (sin(y) / (z_m * y)) * x;
	end
	tmp_2 = z_s * tmp;
end
z\_m = N[Abs[z], $MachinePrecision]
z\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[z$95$s_, x_, y_, z$95$m_] := N[(z$95$s * If[LessEqual[y, 1e-13], N[(x / z$95$m), $MachinePrecision], N[(N[(N[Sin[y], $MachinePrecision] / N[(z$95$m * y), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
z\_m = \left|z\right|
\\
z\_s = \mathsf{copysign}\left(1, z\right)

\\
z\_s \cdot \begin{array}{l}
\mathbf{if}\;y \leq 10^{-13}:\\
\;\;\;\;\frac{x}{z\_m}\\

\mathbf{else}:\\
\;\;\;\;\frac{\sin y}{z\_m \cdot y} \cdot x\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 1e-13

    1. Initial program 96.4%

      \[\frac{x \cdot \frac{\sin y}{y}}{z} \]
    2. Taylor expanded in y around 0

      \[\leadsto \frac{\color{blue}{x}}{z} \]
    3. Step-by-step derivation
      1. Applied rewrites58.7%

        \[\leadsto \frac{\color{blue}{x}}{z} \]

      if 1e-13 < y

      1. Initial program 96.4%

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

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

          \[\leadsto \frac{\color{blue}{x \cdot \frac{\sin y}{y}}}{z} \]
        3. lift-/.f64N/A

          \[\leadsto \frac{x \cdot \color{blue}{\frac{\sin y}{y}}}{z} \]
        4. lift-sin.f64N/A

          \[\leadsto \frac{x \cdot \frac{\color{blue}{\sin y}}{y}}{z} \]
        5. associate-/l*N/A

          \[\leadsto \color{blue}{x \cdot \frac{\frac{\sin y}{y}}{z}} \]
        6. *-commutativeN/A

          \[\leadsto \color{blue}{\frac{\frac{\sin y}{y}}{z} \cdot x} \]
        7. lower-*.f64N/A

          \[\leadsto \color{blue}{\frac{\frac{\sin y}{y}}{z} \cdot x} \]
        8. associate-/l/N/A

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

          \[\leadsto \color{blue}{\frac{\sin y}{y \cdot z}} \cdot x \]
        10. lift-sin.f64N/A

          \[\leadsto \frac{\color{blue}{\sin y}}{y \cdot z} \cdot x \]
        11. *-commutativeN/A

          \[\leadsto \frac{\sin y}{\color{blue}{z \cdot y}} \cdot x \]
        12. lower-*.f6488.4

          \[\leadsto \frac{\sin y}{\color{blue}{z \cdot y}} \cdot x \]
      3. Applied rewrites88.4%

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

    Alternative 6: 77.6% accurate, 0.9× speedup?

    \[\begin{array}{l} z\_m = \left|z\right| \\ z\_s = \mathsf{copysign}\left(1, z\right) \\ z\_s \cdot \begin{array}{l} \mathbf{if}\;y \leq 1.4 \cdot 10^{-13}:\\ \;\;\;\;\frac{x}{z\_m}\\ \mathbf{else}:\\ \;\;\;\;\sin y \cdot \frac{x}{z\_m \cdot y}\\ \end{array} \end{array} \]
    z\_m = (fabs.f64 z)
    z\_s = (copysign.f64 #s(literal 1 binary64) z)
    (FPCore (z_s x y z_m)
     :precision binary64
     (* z_s (if (<= y 1.4e-13) (/ x z_m) (* (sin y) (/ x (* z_m y))))))
    z\_m = fabs(z);
    z\_s = copysign(1.0, z);
    double code(double z_s, double x, double y, double z_m) {
    	double tmp;
    	if (y <= 1.4e-13) {
    		tmp = x / z_m;
    	} else {
    		tmp = sin(y) * (x / (z_m * y));
    	}
    	return z_s * tmp;
    }
    
    z\_m =     private
    z\_s =     private
    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(z_s, x, y, z_m)
    use fmin_fmax_functions
        real(8), intent (in) :: z_s
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        real(8), intent (in) :: z_m
        real(8) :: tmp
        if (y <= 1.4d-13) then
            tmp = x / z_m
        else
            tmp = sin(y) * (x / (z_m * y))
        end if
        code = z_s * tmp
    end function
    
    z\_m = Math.abs(z);
    z\_s = Math.copySign(1.0, z);
    public static double code(double z_s, double x, double y, double z_m) {
    	double tmp;
    	if (y <= 1.4e-13) {
    		tmp = x / z_m;
    	} else {
    		tmp = Math.sin(y) * (x / (z_m * y));
    	}
    	return z_s * tmp;
    }
    
    z\_m = math.fabs(z)
    z\_s = math.copysign(1.0, z)
    def code(z_s, x, y, z_m):
    	tmp = 0
    	if y <= 1.4e-13:
    		tmp = x / z_m
    	else:
    		tmp = math.sin(y) * (x / (z_m * y))
    	return z_s * tmp
    
    z\_m = abs(z)
    z\_s = copysign(1.0, z)
    function code(z_s, x, y, z_m)
    	tmp = 0.0
    	if (y <= 1.4e-13)
    		tmp = Float64(x / z_m);
    	else
    		tmp = Float64(sin(y) * Float64(x / Float64(z_m * y)));
    	end
    	return Float64(z_s * tmp)
    end
    
    z\_m = abs(z);
    z\_s = sign(z) * abs(1.0);
    function tmp_2 = code(z_s, x, y, z_m)
    	tmp = 0.0;
    	if (y <= 1.4e-13)
    		tmp = x / z_m;
    	else
    		tmp = sin(y) * (x / (z_m * y));
    	end
    	tmp_2 = z_s * tmp;
    end
    
    z\_m = N[Abs[z], $MachinePrecision]
    z\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
    code[z$95$s_, x_, y_, z$95$m_] := N[(z$95$s * If[LessEqual[y, 1.4e-13], N[(x / z$95$m), $MachinePrecision], N[(N[Sin[y], $MachinePrecision] * N[(x / N[(z$95$m * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
    
    \begin{array}{l}
    z\_m = \left|z\right|
    \\
    z\_s = \mathsf{copysign}\left(1, z\right)
    
    \\
    z\_s \cdot \begin{array}{l}
    \mathbf{if}\;y \leq 1.4 \cdot 10^{-13}:\\
    \;\;\;\;\frac{x}{z\_m}\\
    
    \mathbf{else}:\\
    \;\;\;\;\sin y \cdot \frac{x}{z\_m \cdot y}\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if y < 1.4000000000000001e-13

      1. Initial program 96.4%

        \[\frac{x \cdot \frac{\sin y}{y}}{z} \]
      2. Taylor expanded in y around 0

        \[\leadsto \frac{\color{blue}{x}}{z} \]
      3. Step-by-step derivation
        1. Applied rewrites58.7%

          \[\leadsto \frac{\color{blue}{x}}{z} \]

        if 1.4000000000000001e-13 < y

        1. Initial program 96.4%

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

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

            \[\leadsto \frac{\color{blue}{x \cdot \frac{\sin y}{y}}}{z} \]
          3. lift-/.f64N/A

            \[\leadsto \frac{x \cdot \color{blue}{\frac{\sin y}{y}}}{z} \]
          4. lift-sin.f64N/A

            \[\leadsto \frac{x \cdot \frac{\color{blue}{\sin y}}{y}}{z} \]
          5. associate-/l*N/A

            \[\leadsto \frac{\color{blue}{\frac{x \cdot \sin y}{y}}}{z} \]
          6. associate-/r*N/A

            \[\leadsto \color{blue}{\frac{x \cdot \sin y}{y \cdot z}} \]
          7. *-commutativeN/A

            \[\leadsto \frac{\color{blue}{\sin y \cdot x}}{y \cdot z} \]
          8. associate-/l*N/A

            \[\leadsto \color{blue}{\sin y \cdot \frac{x}{y \cdot z}} \]
          9. lower-*.f64N/A

            \[\leadsto \color{blue}{\sin y \cdot \frac{x}{y \cdot z}} \]
          10. lift-sin.f64N/A

            \[\leadsto \color{blue}{\sin y} \cdot \frac{x}{y \cdot z} \]
          11. lower-/.f64N/A

            \[\leadsto \sin y \cdot \color{blue}{\frac{x}{y \cdot z}} \]
          12. *-commutativeN/A

            \[\leadsto \sin y \cdot \frac{x}{\color{blue}{z \cdot y}} \]
          13. lower-*.f6484.0

            \[\leadsto \sin y \cdot \frac{x}{\color{blue}{z \cdot y}} \]
        3. Applied rewrites84.0%

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

      Alternative 7: 66.7% accurate, 0.7× speedup?

      \[\begin{array}{l} z\_m = \left|z\right| \\ z\_s = \mathsf{copysign}\left(1, z\right) \\ z\_s \cdot \begin{array}{l} \mathbf{if}\;\frac{\sin y}{y} \leq 0.002:\\ \;\;\;\;y \cdot \frac{x}{z\_m \cdot y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot \mathsf{fma}\left(\mathsf{fma}\left(0.008333333333333333, y \cdot y, -0.16666666666666666\right), y \cdot y, 1\right)}{z\_m}\\ \end{array} \end{array} \]
      z\_m = (fabs.f64 z)
      z\_s = (copysign.f64 #s(literal 1 binary64) z)
      (FPCore (z_s x y z_m)
       :precision binary64
       (*
        z_s
        (if (<= (/ (sin y) y) 0.002)
          (* y (/ x (* z_m y)))
          (/
           (*
            x
            (fma
             (fma 0.008333333333333333 (* y y) -0.16666666666666666)
             (* y y)
             1.0))
           z_m))))
      z\_m = fabs(z);
      z\_s = copysign(1.0, z);
      double code(double z_s, double x, double y, double z_m) {
      	double tmp;
      	if ((sin(y) / y) <= 0.002) {
      		tmp = y * (x / (z_m * y));
      	} else {
      		tmp = (x * fma(fma(0.008333333333333333, (y * y), -0.16666666666666666), (y * y), 1.0)) / z_m;
      	}
      	return z_s * tmp;
      }
      
      z\_m = abs(z)
      z\_s = copysign(1.0, z)
      function code(z_s, x, y, z_m)
      	tmp = 0.0
      	if (Float64(sin(y) / y) <= 0.002)
      		tmp = Float64(y * Float64(x / Float64(z_m * y)));
      	else
      		tmp = Float64(Float64(x * fma(fma(0.008333333333333333, Float64(y * y), -0.16666666666666666), Float64(y * y), 1.0)) / z_m);
      	end
      	return Float64(z_s * tmp)
      end
      
      z\_m = N[Abs[z], $MachinePrecision]
      z\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
      code[z$95$s_, x_, y_, z$95$m_] := N[(z$95$s * If[LessEqual[N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision], 0.002], N[(y * N[(x / N[(z$95$m * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * N[(N[(0.008333333333333333 * N[(y * y), $MachinePrecision] + -0.16666666666666666), $MachinePrecision] * N[(y * y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / z$95$m), $MachinePrecision]]), $MachinePrecision]
      
      \begin{array}{l}
      z\_m = \left|z\right|
      \\
      z\_s = \mathsf{copysign}\left(1, z\right)
      
      \\
      z\_s \cdot \begin{array}{l}
      \mathbf{if}\;\frac{\sin y}{y} \leq 0.002:\\
      \;\;\;\;y \cdot \frac{x}{z\_m \cdot y}\\
      
      \mathbf{else}:\\
      \;\;\;\;\frac{x \cdot \mathsf{fma}\left(\mathsf{fma}\left(0.008333333333333333, y \cdot y, -0.16666666666666666\right), y \cdot y, 1\right)}{z\_m}\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if (/.f64 (sin.f64 y) y) < 2e-3

        1. Initial program 96.4%

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

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

            \[\leadsto \frac{\color{blue}{x \cdot \frac{\sin y}{y}}}{z} \]
          3. lift-/.f64N/A

            \[\leadsto \frac{x \cdot \color{blue}{\frac{\sin y}{y}}}{z} \]
          4. lift-sin.f64N/A

            \[\leadsto \frac{x \cdot \frac{\color{blue}{\sin y}}{y}}{z} \]
          5. associate-/l*N/A

            \[\leadsto \frac{\color{blue}{\frac{x \cdot \sin y}{y}}}{z} \]
          6. associate-/r*N/A

            \[\leadsto \color{blue}{\frac{x \cdot \sin y}{y \cdot z}} \]
          7. *-commutativeN/A

            \[\leadsto \frac{\color{blue}{\sin y \cdot x}}{y \cdot z} \]
          8. associate-/l*N/A

            \[\leadsto \color{blue}{\sin y \cdot \frac{x}{y \cdot z}} \]
          9. lower-*.f64N/A

            \[\leadsto \color{blue}{\sin y \cdot \frac{x}{y \cdot z}} \]
          10. lift-sin.f64N/A

            \[\leadsto \color{blue}{\sin y} \cdot \frac{x}{y \cdot z} \]
          11. lower-/.f64N/A

            \[\leadsto \sin y \cdot \color{blue}{\frac{x}{y \cdot z}} \]
          12. *-commutativeN/A

            \[\leadsto \sin y \cdot \frac{x}{\color{blue}{z \cdot y}} \]
          13. lower-*.f6484.0

            \[\leadsto \sin y \cdot \frac{x}{\color{blue}{z \cdot y}} \]
        3. Applied rewrites84.0%

          \[\leadsto \color{blue}{\sin y \cdot \frac{x}{z \cdot y}} \]
        4. Taylor expanded in y around 0

          \[\leadsto \color{blue}{y} \cdot \frac{x}{z \cdot y} \]
        5. Step-by-step derivation
          1. Applied rewrites54.4%

            \[\leadsto \color{blue}{y} \cdot \frac{x}{z \cdot y} \]

          if 2e-3 < (/.f64 (sin.f64 y) y)

          1. Initial program 96.4%

            \[\frac{x \cdot \frac{\sin y}{y}}{z} \]
          2. Taylor expanded in y around 0

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

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

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

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

              \[\leadsto \frac{x \cdot \mathsf{fma}\left(y \cdot y, \frac{-1}{6}, 1\right)}{z} \]
            5. lower-*.f6453.2

              \[\leadsto \frac{x \cdot \mathsf{fma}\left(y \cdot y, -0.16666666666666666, 1\right)}{z} \]
          4. Applied rewrites53.2%

            \[\leadsto \frac{x \cdot \color{blue}{\mathsf{fma}\left(y \cdot y, -0.16666666666666666, 1\right)}}{z} \]
          5. Taylor expanded in y around inf

            \[\leadsto \frac{x \cdot \left(\frac{-1}{6} \cdot \color{blue}{{y}^{2}}\right)}{z} \]
          6. Step-by-step derivation
            1. *-commutativeN/A

              \[\leadsto \frac{x \cdot \left({y}^{2} \cdot \frac{-1}{6}\right)}{z} \]
            2. lower-*.f64N/A

              \[\leadsto \frac{x \cdot \left({y}^{2} \cdot \frac{-1}{6}\right)}{z} \]
            3. pow2N/A

              \[\leadsto \frac{x \cdot \left(\left(y \cdot y\right) \cdot \frac{-1}{6}\right)}{z} \]
            4. lift-*.f6410.5

              \[\leadsto \frac{x \cdot \left(\left(y \cdot y\right) \cdot -0.16666666666666666\right)}{z} \]
          7. Applied rewrites10.5%

            \[\leadsto \frac{x \cdot \left(\left(y \cdot y\right) \cdot \color{blue}{-0.16666666666666666}\right)}{z} \]
          8. Taylor expanded in y around 0

            \[\leadsto \frac{x \cdot \color{blue}{\left(1 + {y}^{2} \cdot \left(\frac{1}{120} \cdot {y}^{2} - \frac{1}{6}\right)\right)}}{z} \]
          9. Step-by-step derivation
            1. +-commutativeN/A

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

              \[\leadsto \frac{x \cdot \left(\left(\frac{1}{120} \cdot {y}^{2} - \frac{1}{6}\right) \cdot {y}^{2} + 1\right)}{z} \]
            3. lower-fma.f64N/A

              \[\leadsto \frac{x \cdot \mathsf{fma}\left(\frac{1}{120} \cdot {y}^{2} - \frac{1}{6}, \color{blue}{{y}^{2}}, 1\right)}{z} \]
            4. metadata-evalN/A

              \[\leadsto \frac{x \cdot \mathsf{fma}\left(\frac{1}{120} \cdot {y}^{2} - \frac{1}{6} \cdot 1, {y}^{2}, 1\right)}{z} \]
            5. fp-cancel-sub-sign-invN/A

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

              \[\leadsto \frac{x \cdot \mathsf{fma}\left(\frac{1}{120} \cdot {y}^{2} + \frac{-1}{6} \cdot 1, {y}^{2}, 1\right)}{z} \]
            7. metadata-evalN/A

              \[\leadsto \frac{x \cdot \mathsf{fma}\left(\frac{1}{120} \cdot {y}^{2} + \frac{-1}{6}, {y}^{2}, 1\right)}{z} \]
            8. lower-fma.f64N/A

              \[\leadsto \frac{x \cdot \mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{120}, {y}^{2}, \frac{-1}{6}\right), {\color{blue}{y}}^{2}, 1\right)}{z} \]
            9. pow2N/A

              \[\leadsto \frac{x \cdot \mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{120}, y \cdot y, \frac{-1}{6}\right), {y}^{2}, 1\right)}{z} \]
            10. lift-*.f64N/A

              \[\leadsto \frac{x \cdot \mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{120}, y \cdot y, \frac{-1}{6}\right), {y}^{2}, 1\right)}{z} \]
            11. pow2N/A

              \[\leadsto \frac{x \cdot \mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{120}, y \cdot y, \frac{-1}{6}\right), y \cdot \color{blue}{y}, 1\right)}{z} \]
            12. lift-*.f6452.8

              \[\leadsto \frac{x \cdot \mathsf{fma}\left(\mathsf{fma}\left(0.008333333333333333, y \cdot y, -0.16666666666666666\right), y \cdot \color{blue}{y}, 1\right)}{z} \]
          10. Applied rewrites52.8%

            \[\leadsto \frac{x \cdot \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(0.008333333333333333, y \cdot y, -0.16666666666666666\right), y \cdot y, 1\right)}}{z} \]
        6. Recombined 2 regimes into one program.
        7. Add Preprocessing

        Alternative 8: 66.6% accurate, 0.8× speedup?

        \[\begin{array}{l} z\_m = \left|z\right| \\ z\_s = \mathsf{copysign}\left(1, z\right) \\ z\_s \cdot \begin{array}{l} \mathbf{if}\;\frac{\sin y}{y} \leq 0.01:\\ \;\;\;\;y \cdot \frac{x}{z\_m \cdot y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot \mathsf{fma}\left(y \cdot y, -0.16666666666666666, 1\right)}{z\_m}\\ \end{array} \end{array} \]
        z\_m = (fabs.f64 z)
        z\_s = (copysign.f64 #s(literal 1 binary64) z)
        (FPCore (z_s x y z_m)
         :precision binary64
         (*
          z_s
          (if (<= (/ (sin y) y) 0.01)
            (* y (/ x (* z_m y)))
            (/ (* x (fma (* y y) -0.16666666666666666 1.0)) z_m))))
        z\_m = fabs(z);
        z\_s = copysign(1.0, z);
        double code(double z_s, double x, double y, double z_m) {
        	double tmp;
        	if ((sin(y) / y) <= 0.01) {
        		tmp = y * (x / (z_m * y));
        	} else {
        		tmp = (x * fma((y * y), -0.16666666666666666, 1.0)) / z_m;
        	}
        	return z_s * tmp;
        }
        
        z\_m = abs(z)
        z\_s = copysign(1.0, z)
        function code(z_s, x, y, z_m)
        	tmp = 0.0
        	if (Float64(sin(y) / y) <= 0.01)
        		tmp = Float64(y * Float64(x / Float64(z_m * y)));
        	else
        		tmp = Float64(Float64(x * fma(Float64(y * y), -0.16666666666666666, 1.0)) / z_m);
        	end
        	return Float64(z_s * tmp)
        end
        
        z\_m = N[Abs[z], $MachinePrecision]
        z\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
        code[z$95$s_, x_, y_, z$95$m_] := N[(z$95$s * If[LessEqual[N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision], 0.01], N[(y * N[(x / N[(z$95$m * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * N[(N[(y * y), $MachinePrecision] * -0.16666666666666666 + 1.0), $MachinePrecision]), $MachinePrecision] / z$95$m), $MachinePrecision]]), $MachinePrecision]
        
        \begin{array}{l}
        z\_m = \left|z\right|
        \\
        z\_s = \mathsf{copysign}\left(1, z\right)
        
        \\
        z\_s \cdot \begin{array}{l}
        \mathbf{if}\;\frac{\sin y}{y} \leq 0.01:\\
        \;\;\;\;y \cdot \frac{x}{z\_m \cdot y}\\
        
        \mathbf{else}:\\
        \;\;\;\;\frac{x \cdot \mathsf{fma}\left(y \cdot y, -0.16666666666666666, 1\right)}{z\_m}\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if (/.f64 (sin.f64 y) y) < 0.0100000000000000002

          1. Initial program 96.4%

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

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

              \[\leadsto \frac{\color{blue}{x \cdot \frac{\sin y}{y}}}{z} \]
            3. lift-/.f64N/A

              \[\leadsto \frac{x \cdot \color{blue}{\frac{\sin y}{y}}}{z} \]
            4. lift-sin.f64N/A

              \[\leadsto \frac{x \cdot \frac{\color{blue}{\sin y}}{y}}{z} \]
            5. associate-/l*N/A

              \[\leadsto \frac{\color{blue}{\frac{x \cdot \sin y}{y}}}{z} \]
            6. associate-/r*N/A

              \[\leadsto \color{blue}{\frac{x \cdot \sin y}{y \cdot z}} \]
            7. *-commutativeN/A

              \[\leadsto \frac{\color{blue}{\sin y \cdot x}}{y \cdot z} \]
            8. associate-/l*N/A

              \[\leadsto \color{blue}{\sin y \cdot \frac{x}{y \cdot z}} \]
            9. lower-*.f64N/A

              \[\leadsto \color{blue}{\sin y \cdot \frac{x}{y \cdot z}} \]
            10. lift-sin.f64N/A

              \[\leadsto \color{blue}{\sin y} \cdot \frac{x}{y \cdot z} \]
            11. lower-/.f64N/A

              \[\leadsto \sin y \cdot \color{blue}{\frac{x}{y \cdot z}} \]
            12. *-commutativeN/A

              \[\leadsto \sin y \cdot \frac{x}{\color{blue}{z \cdot y}} \]
            13. lower-*.f6484.0

              \[\leadsto \sin y \cdot \frac{x}{\color{blue}{z \cdot y}} \]
          3. Applied rewrites84.0%

            \[\leadsto \color{blue}{\sin y \cdot \frac{x}{z \cdot y}} \]
          4. Taylor expanded in y around 0

            \[\leadsto \color{blue}{y} \cdot \frac{x}{z \cdot y} \]
          5. Step-by-step derivation
            1. Applied rewrites54.4%

              \[\leadsto \color{blue}{y} \cdot \frac{x}{z \cdot y} \]

            if 0.0100000000000000002 < (/.f64 (sin.f64 y) y)

            1. Initial program 96.4%

              \[\frac{x \cdot \frac{\sin y}{y}}{z} \]
            2. Taylor expanded in y around 0

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

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

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

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

                \[\leadsto \frac{x \cdot \mathsf{fma}\left(y \cdot y, \frac{-1}{6}, 1\right)}{z} \]
              5. lower-*.f6453.2

                \[\leadsto \frac{x \cdot \mathsf{fma}\left(y \cdot y, -0.16666666666666666, 1\right)}{z} \]
            4. Applied rewrites53.2%

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

          Alternative 9: 66.6% accurate, 0.8× speedup?

          \[\begin{array}{l} z\_m = \left|z\right| \\ z\_s = \mathsf{copysign}\left(1, z\right) \\ z\_s \cdot \begin{array}{l} \mathbf{if}\;\frac{\sin y}{y} \leq 0.01:\\ \;\;\;\;y \cdot \frac{x}{z\_m \cdot y}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\left(y \cdot y\right) \cdot x, -0.16666666666666666, x\right)}{z\_m}\\ \end{array} \end{array} \]
          z\_m = (fabs.f64 z)
          z\_s = (copysign.f64 #s(literal 1 binary64) z)
          (FPCore (z_s x y z_m)
           :precision binary64
           (*
            z_s
            (if (<= (/ (sin y) y) 0.01)
              (* y (/ x (* z_m y)))
              (/ (fma (* (* y y) x) -0.16666666666666666 x) z_m))))
          z\_m = fabs(z);
          z\_s = copysign(1.0, z);
          double code(double z_s, double x, double y, double z_m) {
          	double tmp;
          	if ((sin(y) / y) <= 0.01) {
          		tmp = y * (x / (z_m * y));
          	} else {
          		tmp = fma(((y * y) * x), -0.16666666666666666, x) / z_m;
          	}
          	return z_s * tmp;
          }
          
          z\_m = abs(z)
          z\_s = copysign(1.0, z)
          function code(z_s, x, y, z_m)
          	tmp = 0.0
          	if (Float64(sin(y) / y) <= 0.01)
          		tmp = Float64(y * Float64(x / Float64(z_m * y)));
          	else
          		tmp = Float64(fma(Float64(Float64(y * y) * x), -0.16666666666666666, x) / z_m);
          	end
          	return Float64(z_s * tmp)
          end
          
          z\_m = N[Abs[z], $MachinePrecision]
          z\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
          code[z$95$s_, x_, y_, z$95$m_] := N[(z$95$s * If[LessEqual[N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision], 0.01], N[(y * N[(x / N[(z$95$m * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(y * y), $MachinePrecision] * x), $MachinePrecision] * -0.16666666666666666 + x), $MachinePrecision] / z$95$m), $MachinePrecision]]), $MachinePrecision]
          
          \begin{array}{l}
          z\_m = \left|z\right|
          \\
          z\_s = \mathsf{copysign}\left(1, z\right)
          
          \\
          z\_s \cdot \begin{array}{l}
          \mathbf{if}\;\frac{\sin y}{y} \leq 0.01:\\
          \;\;\;\;y \cdot \frac{x}{z\_m \cdot y}\\
          
          \mathbf{else}:\\
          \;\;\;\;\frac{\mathsf{fma}\left(\left(y \cdot y\right) \cdot x, -0.16666666666666666, x\right)}{z\_m}\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if (/.f64 (sin.f64 y) y) < 0.0100000000000000002

            1. Initial program 96.4%

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

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

                \[\leadsto \frac{\color{blue}{x \cdot \frac{\sin y}{y}}}{z} \]
              3. lift-/.f64N/A

                \[\leadsto \frac{x \cdot \color{blue}{\frac{\sin y}{y}}}{z} \]
              4. lift-sin.f64N/A

                \[\leadsto \frac{x \cdot \frac{\color{blue}{\sin y}}{y}}{z} \]
              5. associate-/l*N/A

                \[\leadsto \frac{\color{blue}{\frac{x \cdot \sin y}{y}}}{z} \]
              6. associate-/r*N/A

                \[\leadsto \color{blue}{\frac{x \cdot \sin y}{y \cdot z}} \]
              7. *-commutativeN/A

                \[\leadsto \frac{\color{blue}{\sin y \cdot x}}{y \cdot z} \]
              8. associate-/l*N/A

                \[\leadsto \color{blue}{\sin y \cdot \frac{x}{y \cdot z}} \]
              9. lower-*.f64N/A

                \[\leadsto \color{blue}{\sin y \cdot \frac{x}{y \cdot z}} \]
              10. lift-sin.f64N/A

                \[\leadsto \color{blue}{\sin y} \cdot \frac{x}{y \cdot z} \]
              11. lower-/.f64N/A

                \[\leadsto \sin y \cdot \color{blue}{\frac{x}{y \cdot z}} \]
              12. *-commutativeN/A

                \[\leadsto \sin y \cdot \frac{x}{\color{blue}{z \cdot y}} \]
              13. lower-*.f6484.0

                \[\leadsto \sin y \cdot \frac{x}{\color{blue}{z \cdot y}} \]
            3. Applied rewrites84.0%

              \[\leadsto \color{blue}{\sin y \cdot \frac{x}{z \cdot y}} \]
            4. Taylor expanded in y around 0

              \[\leadsto \color{blue}{y} \cdot \frac{x}{z \cdot y} \]
            5. Step-by-step derivation
              1. Applied rewrites54.4%

                \[\leadsto \color{blue}{y} \cdot \frac{x}{z \cdot y} \]

              if 0.0100000000000000002 < (/.f64 (sin.f64 y) y)

              1. Initial program 96.4%

                \[\frac{x \cdot \frac{\sin y}{y}}{z} \]
              2. Taylor expanded in y around 0

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

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

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

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

                  \[\leadsto \frac{\mathsf{fma}\left({y}^{2} \cdot x, \frac{-1}{6}, x\right)}{z} \]
                5. lower-*.f64N/A

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

                  \[\leadsto \frac{\mathsf{fma}\left(\left(y \cdot y\right) \cdot x, \frac{-1}{6}, x\right)}{z} \]
                7. lower-*.f6453.2

                  \[\leadsto \frac{\mathsf{fma}\left(\left(y \cdot y\right) \cdot x, -0.16666666666666666, x\right)}{z} \]
              4. Applied rewrites53.2%

                \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\left(y \cdot y\right) \cdot x, -0.16666666666666666, x\right)}}{z} \]
            6. Recombined 2 regimes into one program.
            7. Add Preprocessing

            Alternative 10: 66.4% accurate, 0.9× speedup?

            \[\begin{array}{l} z\_m = \left|z\right| \\ z\_s = \mathsf{copysign}\left(1, z\right) \\ z\_s \cdot \begin{array}{l} \mathbf{if}\;\frac{\sin y}{y} \leq 10^{-27}:\\ \;\;\;\;y \cdot \frac{x}{z\_m \cdot y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z\_m}\\ \end{array} \end{array} \]
            z\_m = (fabs.f64 z)
            z\_s = (copysign.f64 #s(literal 1 binary64) z)
            (FPCore (z_s x y z_m)
             :precision binary64
             (* z_s (if (<= (/ (sin y) y) 1e-27) (* y (/ x (* z_m y))) (/ x z_m))))
            z\_m = fabs(z);
            z\_s = copysign(1.0, z);
            double code(double z_s, double x, double y, double z_m) {
            	double tmp;
            	if ((sin(y) / y) <= 1e-27) {
            		tmp = y * (x / (z_m * y));
            	} else {
            		tmp = x / z_m;
            	}
            	return z_s * tmp;
            }
            
            z\_m =     private
            z\_s =     private
            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(z_s, x, y, z_m)
            use fmin_fmax_functions
                real(8), intent (in) :: z_s
                real(8), intent (in) :: x
                real(8), intent (in) :: y
                real(8), intent (in) :: z_m
                real(8) :: tmp
                if ((sin(y) / y) <= 1d-27) then
                    tmp = y * (x / (z_m * y))
                else
                    tmp = x / z_m
                end if
                code = z_s * tmp
            end function
            
            z\_m = Math.abs(z);
            z\_s = Math.copySign(1.0, z);
            public static double code(double z_s, double x, double y, double z_m) {
            	double tmp;
            	if ((Math.sin(y) / y) <= 1e-27) {
            		tmp = y * (x / (z_m * y));
            	} else {
            		tmp = x / z_m;
            	}
            	return z_s * tmp;
            }
            
            z\_m = math.fabs(z)
            z\_s = math.copysign(1.0, z)
            def code(z_s, x, y, z_m):
            	tmp = 0
            	if (math.sin(y) / y) <= 1e-27:
            		tmp = y * (x / (z_m * y))
            	else:
            		tmp = x / z_m
            	return z_s * tmp
            
            z\_m = abs(z)
            z\_s = copysign(1.0, z)
            function code(z_s, x, y, z_m)
            	tmp = 0.0
            	if (Float64(sin(y) / y) <= 1e-27)
            		tmp = Float64(y * Float64(x / Float64(z_m * y)));
            	else
            		tmp = Float64(x / z_m);
            	end
            	return Float64(z_s * tmp)
            end
            
            z\_m = abs(z);
            z\_s = sign(z) * abs(1.0);
            function tmp_2 = code(z_s, x, y, z_m)
            	tmp = 0.0;
            	if ((sin(y) / y) <= 1e-27)
            		tmp = y * (x / (z_m * y));
            	else
            		tmp = x / z_m;
            	end
            	tmp_2 = z_s * tmp;
            end
            
            z\_m = N[Abs[z], $MachinePrecision]
            z\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
            code[z$95$s_, x_, y_, z$95$m_] := N[(z$95$s * If[LessEqual[N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision], 1e-27], N[(y * N[(x / N[(z$95$m * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x / z$95$m), $MachinePrecision]]), $MachinePrecision]
            
            \begin{array}{l}
            z\_m = \left|z\right|
            \\
            z\_s = \mathsf{copysign}\left(1, z\right)
            
            \\
            z\_s \cdot \begin{array}{l}
            \mathbf{if}\;\frac{\sin y}{y} \leq 10^{-27}:\\
            \;\;\;\;y \cdot \frac{x}{z\_m \cdot y}\\
            
            \mathbf{else}:\\
            \;\;\;\;\frac{x}{z\_m}\\
            
            
            \end{array}
            \end{array}
            
            Derivation
            1. Split input into 2 regimes
            2. if (/.f64 (sin.f64 y) y) < 1e-27

              1. Initial program 96.4%

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

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

                  \[\leadsto \frac{\color{blue}{x \cdot \frac{\sin y}{y}}}{z} \]
                3. lift-/.f64N/A

                  \[\leadsto \frac{x \cdot \color{blue}{\frac{\sin y}{y}}}{z} \]
                4. lift-sin.f64N/A

                  \[\leadsto \frac{x \cdot \frac{\color{blue}{\sin y}}{y}}{z} \]
                5. associate-/l*N/A

                  \[\leadsto \frac{\color{blue}{\frac{x \cdot \sin y}{y}}}{z} \]
                6. associate-/r*N/A

                  \[\leadsto \color{blue}{\frac{x \cdot \sin y}{y \cdot z}} \]
                7. *-commutativeN/A

                  \[\leadsto \frac{\color{blue}{\sin y \cdot x}}{y \cdot z} \]
                8. associate-/l*N/A

                  \[\leadsto \color{blue}{\sin y \cdot \frac{x}{y \cdot z}} \]
                9. lower-*.f64N/A

                  \[\leadsto \color{blue}{\sin y \cdot \frac{x}{y \cdot z}} \]
                10. lift-sin.f64N/A

                  \[\leadsto \color{blue}{\sin y} \cdot \frac{x}{y \cdot z} \]
                11. lower-/.f64N/A

                  \[\leadsto \sin y \cdot \color{blue}{\frac{x}{y \cdot z}} \]
                12. *-commutativeN/A

                  \[\leadsto \sin y \cdot \frac{x}{\color{blue}{z \cdot y}} \]
                13. lower-*.f6484.0

                  \[\leadsto \sin y \cdot \frac{x}{\color{blue}{z \cdot y}} \]
              3. Applied rewrites84.0%

                \[\leadsto \color{blue}{\sin y \cdot \frac{x}{z \cdot y}} \]
              4. Taylor expanded in y around 0

                \[\leadsto \color{blue}{y} \cdot \frac{x}{z \cdot y} \]
              5. Step-by-step derivation
                1. Applied rewrites54.4%

                  \[\leadsto \color{blue}{y} \cdot \frac{x}{z \cdot y} \]

                if 1e-27 < (/.f64 (sin.f64 y) y)

                1. Initial program 96.4%

                  \[\frac{x \cdot \frac{\sin y}{y}}{z} \]
                2. Taylor expanded in y around 0

                  \[\leadsto \frac{\color{blue}{x}}{z} \]
                3. Step-by-step derivation
                  1. Applied rewrites58.7%

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

                Alternative 11: 62.6% accurate, 0.9× speedup?

                \[\begin{array}{l} z\_m = \left|z\right| \\ z\_s = \mathsf{copysign}\left(1, z\right) \\ z\_s \cdot \begin{array}{l} \mathbf{if}\;\frac{\sin y}{y} \leq 2 \cdot 10^{-57}:\\ \;\;\;\;x \cdot \frac{y}{z\_m \cdot y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z\_m}\\ \end{array} \end{array} \]
                z\_m = (fabs.f64 z)
                z\_s = (copysign.f64 #s(literal 1 binary64) z)
                (FPCore (z_s x y z_m)
                 :precision binary64
                 (* z_s (if (<= (/ (sin y) y) 2e-57) (* x (/ y (* z_m y))) (/ x z_m))))
                z\_m = fabs(z);
                z\_s = copysign(1.0, z);
                double code(double z_s, double x, double y, double z_m) {
                	double tmp;
                	if ((sin(y) / y) <= 2e-57) {
                		tmp = x * (y / (z_m * y));
                	} else {
                		tmp = x / z_m;
                	}
                	return z_s * tmp;
                }
                
                z\_m =     private
                z\_s =     private
                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(z_s, x, y, z_m)
                use fmin_fmax_functions
                    real(8), intent (in) :: z_s
                    real(8), intent (in) :: x
                    real(8), intent (in) :: y
                    real(8), intent (in) :: z_m
                    real(8) :: tmp
                    if ((sin(y) / y) <= 2d-57) then
                        tmp = x * (y / (z_m * y))
                    else
                        tmp = x / z_m
                    end if
                    code = z_s * tmp
                end function
                
                z\_m = Math.abs(z);
                z\_s = Math.copySign(1.0, z);
                public static double code(double z_s, double x, double y, double z_m) {
                	double tmp;
                	if ((Math.sin(y) / y) <= 2e-57) {
                		tmp = x * (y / (z_m * y));
                	} else {
                		tmp = x / z_m;
                	}
                	return z_s * tmp;
                }
                
                z\_m = math.fabs(z)
                z\_s = math.copysign(1.0, z)
                def code(z_s, x, y, z_m):
                	tmp = 0
                	if (math.sin(y) / y) <= 2e-57:
                		tmp = x * (y / (z_m * y))
                	else:
                		tmp = x / z_m
                	return z_s * tmp
                
                z\_m = abs(z)
                z\_s = copysign(1.0, z)
                function code(z_s, x, y, z_m)
                	tmp = 0.0
                	if (Float64(sin(y) / y) <= 2e-57)
                		tmp = Float64(x * Float64(y / Float64(z_m * y)));
                	else
                		tmp = Float64(x / z_m);
                	end
                	return Float64(z_s * tmp)
                end
                
                z\_m = abs(z);
                z\_s = sign(z) * abs(1.0);
                function tmp_2 = code(z_s, x, y, z_m)
                	tmp = 0.0;
                	if ((sin(y) / y) <= 2e-57)
                		tmp = x * (y / (z_m * y));
                	else
                		tmp = x / z_m;
                	end
                	tmp_2 = z_s * tmp;
                end
                
                z\_m = N[Abs[z], $MachinePrecision]
                z\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
                code[z$95$s_, x_, y_, z$95$m_] := N[(z$95$s * If[LessEqual[N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision], 2e-57], N[(x * N[(y / N[(z$95$m * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x / z$95$m), $MachinePrecision]]), $MachinePrecision]
                
                \begin{array}{l}
                z\_m = \left|z\right|
                \\
                z\_s = \mathsf{copysign}\left(1, z\right)
                
                \\
                z\_s \cdot \begin{array}{l}
                \mathbf{if}\;\frac{\sin y}{y} \leq 2 \cdot 10^{-57}:\\
                \;\;\;\;x \cdot \frac{y}{z\_m \cdot y}\\
                
                \mathbf{else}:\\
                \;\;\;\;\frac{x}{z\_m}\\
                
                
                \end{array}
                \end{array}
                
                Derivation
                1. Split input into 2 regimes
                2. if (/.f64 (sin.f64 y) y) < 1.99999999999999991e-57

                  1. Initial program 96.4%

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

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

                      \[\leadsto \frac{\color{blue}{x \cdot \frac{\sin y}{y}}}{z} \]
                    3. lift-/.f64N/A

                      \[\leadsto \frac{x \cdot \color{blue}{\frac{\sin y}{y}}}{z} \]
                    4. lift-sin.f64N/A

                      \[\leadsto \frac{x \cdot \frac{\color{blue}{\sin y}}{y}}{z} \]
                    5. associate-/l*N/A

                      \[\leadsto \frac{\color{blue}{\frac{x \cdot \sin y}{y}}}{z} \]
                    6. associate-/r*N/A

                      \[\leadsto \color{blue}{\frac{x \cdot \sin y}{y \cdot z}} \]
                    7. *-commutativeN/A

                      \[\leadsto \frac{\color{blue}{\sin y \cdot x}}{y \cdot z} \]
                    8. associate-/l*N/A

                      \[\leadsto \color{blue}{\sin y \cdot \frac{x}{y \cdot z}} \]
                    9. lower-*.f64N/A

                      \[\leadsto \color{blue}{\sin y \cdot \frac{x}{y \cdot z}} \]
                    10. lift-sin.f64N/A

                      \[\leadsto \color{blue}{\sin y} \cdot \frac{x}{y \cdot z} \]
                    11. lower-/.f64N/A

                      \[\leadsto \sin y \cdot \color{blue}{\frac{x}{y \cdot z}} \]
                    12. *-commutativeN/A

                      \[\leadsto \sin y \cdot \frac{x}{\color{blue}{z \cdot y}} \]
                    13. lower-*.f6484.0

                      \[\leadsto \sin y \cdot \frac{x}{\color{blue}{z \cdot y}} \]
                  3. Applied rewrites84.0%

                    \[\leadsto \color{blue}{\sin y \cdot \frac{x}{z \cdot y}} \]
                  4. Taylor expanded in y around 0

                    \[\leadsto \color{blue}{y} \cdot \frac{x}{z \cdot y} \]
                  5. Step-by-step derivation
                    1. Applied rewrites54.4%

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

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

                        \[\leadsto y \cdot \frac{x}{\color{blue}{z \cdot y}} \]
                      3. lift-/.f64N/A

                        \[\leadsto y \cdot \color{blue}{\frac{x}{z \cdot y}} \]
                      4. associate-*r/N/A

                        \[\leadsto \color{blue}{\frac{y \cdot x}{z \cdot y}} \]
                      5. times-fracN/A

                        \[\leadsto \color{blue}{\frac{y}{z} \cdot \frac{x}{y}} \]
                      6. lower-*.f64N/A

                        \[\leadsto \color{blue}{\frac{y}{z} \cdot \frac{x}{y}} \]
                      7. lower-/.f64N/A

                        \[\leadsto \color{blue}{\frac{y}{z}} \cdot \frac{x}{y} \]
                      8. lower-/.f6449.4

                        \[\leadsto \frac{y}{z} \cdot \color{blue}{\frac{x}{y}} \]
                    3. Applied rewrites49.4%

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

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

                        \[\leadsto \color{blue}{\frac{y}{z}} \cdot \frac{x}{y} \]
                      3. lift-/.f64N/A

                        \[\leadsto \frac{y}{z} \cdot \color{blue}{\frac{x}{y}} \]
                      4. frac-timesN/A

                        \[\leadsto \color{blue}{\frac{y \cdot x}{z \cdot y}} \]
                      5. *-commutativeN/A

                        \[\leadsto \frac{\color{blue}{x \cdot y}}{z \cdot y} \]
                      6. associate-/l*N/A

                        \[\leadsto \color{blue}{x \cdot \frac{y}{z \cdot y}} \]
                      7. lower-*.f64N/A

                        \[\leadsto \color{blue}{x \cdot \frac{y}{z \cdot y}} \]
                      8. lower-/.f64N/A

                        \[\leadsto x \cdot \color{blue}{\frac{y}{z \cdot y}} \]
                      9. lift-*.f6455.0

                        \[\leadsto x \cdot \frac{y}{\color{blue}{z \cdot y}} \]
                    5. Applied rewrites55.0%

                      \[\leadsto \color{blue}{x \cdot \frac{y}{z \cdot y}} \]

                    if 1.99999999999999991e-57 < (/.f64 (sin.f64 y) y)

                    1. Initial program 96.4%

                      \[\frac{x \cdot \frac{\sin y}{y}}{z} \]
                    2. Taylor expanded in y around 0

                      \[\leadsto \frac{\color{blue}{x}}{z} \]
                    3. Step-by-step derivation
                      1. Applied rewrites58.7%

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

                    Alternative 12: 58.7% accurate, 9.7× speedup?

                    \[\begin{array}{l} z\_m = \left|z\right| \\ z\_s = \mathsf{copysign}\left(1, z\right) \\ z\_s \cdot \frac{x}{z\_m} \end{array} \]
                    z\_m = (fabs.f64 z)
                    z\_s = (copysign.f64 #s(literal 1 binary64) z)
                    (FPCore (z_s x y z_m) :precision binary64 (* z_s (/ x z_m)))
                    z\_m = fabs(z);
                    z\_s = copysign(1.0, z);
                    double code(double z_s, double x, double y, double z_m) {
                    	return z_s * (x / z_m);
                    }
                    
                    z\_m =     private
                    z\_s =     private
                    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(z_s, x, y, z_m)
                    use fmin_fmax_functions
                        real(8), intent (in) :: z_s
                        real(8), intent (in) :: x
                        real(8), intent (in) :: y
                        real(8), intent (in) :: z_m
                        code = z_s * (x / z_m)
                    end function
                    
                    z\_m = Math.abs(z);
                    z\_s = Math.copySign(1.0, z);
                    public static double code(double z_s, double x, double y, double z_m) {
                    	return z_s * (x / z_m);
                    }
                    
                    z\_m = math.fabs(z)
                    z\_s = math.copysign(1.0, z)
                    def code(z_s, x, y, z_m):
                    	return z_s * (x / z_m)
                    
                    z\_m = abs(z)
                    z\_s = copysign(1.0, z)
                    function code(z_s, x, y, z_m)
                    	return Float64(z_s * Float64(x / z_m))
                    end
                    
                    z\_m = abs(z);
                    z\_s = sign(z) * abs(1.0);
                    function tmp = code(z_s, x, y, z_m)
                    	tmp = z_s * (x / z_m);
                    end
                    
                    z\_m = N[Abs[z], $MachinePrecision]
                    z\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
                    code[z$95$s_, x_, y_, z$95$m_] := N[(z$95$s * N[(x / z$95$m), $MachinePrecision]), $MachinePrecision]
                    
                    \begin{array}{l}
                    z\_m = \left|z\right|
                    \\
                    z\_s = \mathsf{copysign}\left(1, z\right)
                    
                    \\
                    z\_s \cdot \frac{x}{z\_m}
                    \end{array}
                    
                    Derivation
                    1. Initial program 96.4%

                      \[\frac{x \cdot \frac{\sin y}{y}}{z} \]
                    2. Taylor expanded in y around 0

                      \[\leadsto \frac{\color{blue}{x}}{z} \]
                    3. Step-by-step derivation
                      1. Applied rewrites58.7%

                        \[\leadsto \frac{\color{blue}{x}}{z} \]
                      2. Add Preprocessing

                      Reproduce

                      ?
                      herbie shell --seed 2025123 
                      (FPCore (x y z)
                        :name "Linear.Quaternion:$ctanh from linear-1.19.1.3"
                        :precision binary64
                        (/ (* x (/ (sin y) y)) z))