Linear.Quaternion:$ccos from linear-1.19.1.3

Percentage Accurate: 100.0% → 100.0%
Time: 3.1s
Alternatives: 6
Speedup: 1.0×

Specification

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

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 6 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: 100.0% accurate, 1.0× speedup?

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

Alternative 1: 100.0% accurate, 1.0× speedup?

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

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

Alternative 2: 99.2% accurate, 0.3× speedup?

\[\begin{array}{l} t_0 := \sin \left(\left|x\right|\right)\\ t_1 := \frac{\sinh y}{y}\\ t_2 := t\_0 \cdot t\_1\\ \mathsf{copysign}\left(1, x\right) \cdot \begin{array}{l} \mathbf{if}\;t\_2 \leq -\infty:\\ \;\;\;\;\mathsf{fma}\left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|, -0.16666666666666666, \left|x\right|\right) \cdot t\_1\\ \mathbf{elif}\;t\_2 \leq 1:\\ \;\;\;\;t\_0 \cdot 1\\ \mathbf{else}:\\ \;\;\;\;t\_1 \cdot \left|x\right|\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (sin (fabs x))) (t_1 (/ (sinh y) y)) (t_2 (* t_0 t_1)))
   (*
    (copysign 1.0 x)
    (if (<= t_2 (- INFINITY))
      (*
       (fma (* (* (fabs x) (fabs x)) (fabs x)) -0.16666666666666666 (fabs x))
       t_1)
      (if (<= t_2 1.0) (* t_0 1.0) (* t_1 (fabs x)))))))
double code(double x, double y) {
	double t_0 = sin(fabs(x));
	double t_1 = sinh(y) / y;
	double t_2 = t_0 * t_1;
	double tmp;
	if (t_2 <= -((double) INFINITY)) {
		tmp = fma(((fabs(x) * fabs(x)) * fabs(x)), -0.16666666666666666, fabs(x)) * t_1;
	} else if (t_2 <= 1.0) {
		tmp = t_0 * 1.0;
	} else {
		tmp = t_1 * fabs(x);
	}
	return copysign(1.0, x) * tmp;
}
function code(x, y)
	t_0 = sin(abs(x))
	t_1 = Float64(sinh(y) / y)
	t_2 = Float64(t_0 * t_1)
	tmp = 0.0
	if (t_2 <= Float64(-Inf))
		tmp = Float64(fma(Float64(Float64(abs(x) * abs(x)) * abs(x)), -0.16666666666666666, abs(x)) * t_1);
	elseif (t_2 <= 1.0)
		tmp = Float64(t_0 * 1.0);
	else
		tmp = Float64(t_1 * abs(x));
	end
	return Float64(copysign(1.0, x) * tmp)
end
code[x_, y_] := Block[{t$95$0 = N[Sin[N[Abs[x], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$0 * t$95$1), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$2, (-Infinity)], N[(N[(N[(N[(N[Abs[x], $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision] * -0.16666666666666666 + N[Abs[x], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision], If[LessEqual[t$95$2, 1.0], N[(t$95$0 * 1.0), $MachinePrecision], N[(t$95$1 * N[Abs[x], $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]]]]
\begin{array}{l}
t_0 := \sin \left(\left|x\right|\right)\\
t_1 := \frac{\sinh y}{y}\\
t_2 := t\_0 \cdot t\_1\\
\mathsf{copysign}\left(1, x\right) \cdot \begin{array}{l}
\mathbf{if}\;t\_2 \leq -\infty:\\
\;\;\;\;\mathsf{fma}\left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|, -0.16666666666666666, \left|x\right|\right) \cdot t\_1\\

\mathbf{elif}\;t\_2 \leq 1:\\
\;\;\;\;t\_0 \cdot 1\\

\mathbf{else}:\\
\;\;\;\;t\_1 \cdot \left|x\right|\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 (sin.f64 x) (/.f64 (sinh.f64 y) y)) < -inf.0

    1. Initial program 100.0%

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

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

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

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

        \[\leadsto \left(x \cdot \left(1 + \frac{-1}{6} \cdot \color{blue}{{x}^{2}}\right)\right) \cdot \frac{\sinh y}{y} \]
      4. lower-pow.f6463.3

        \[\leadsto \left(x \cdot \left(1 + -0.16666666666666666 \cdot {x}^{\color{blue}{2}}\right)\right) \cdot \frac{\sinh y}{y} \]
    4. Applied rewrites63.3%

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

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

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

        \[\leadsto \left(x \cdot \left(\frac{-1}{6} \cdot {x}^{2} + \color{blue}{1}\right)\right) \cdot \frac{\sinh y}{y} \]
      4. distribute-rgt-inN/A

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

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

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

        \[\leadsto \left(x \cdot \left({x}^{2} \cdot \frac{-1}{6}\right) + 1 \cdot x\right) \cdot \frac{\sinh y}{y} \]
      8. associate-*r*N/A

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

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

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

        \[\leadsto \mathsf{fma}\left({x}^{2} \cdot x, \frac{-1}{6}, x\right) \cdot \frac{\sinh y}{y} \]
      12. lower-*.f6463.3

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

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

        \[\leadsto \mathsf{fma}\left(\left(x \cdot x\right) \cdot x, \frac{-1}{6}, x\right) \cdot \frac{\sinh y}{y} \]
      15. lower-*.f6463.3

        \[\leadsto \mathsf{fma}\left(\left(x \cdot x\right) \cdot x, -0.16666666666666666, x\right) \cdot \frac{\sinh y}{y} \]
    6. Applied rewrites63.3%

      \[\leadsto \mathsf{fma}\left(\left(x \cdot x\right) \cdot x, \color{blue}{-0.16666666666666666}, x\right) \cdot \frac{\sinh y}{y} \]

    if -inf.0 < (*.f64 (sin.f64 x) (/.f64 (sinh.f64 y) y)) < 1

    1. Initial program 100.0%

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

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

        \[\leadsto \sin x \cdot \color{blue}{1} \]

      if 1 < (*.f64 (sin.f64 x) (/.f64 (sinh.f64 y) y))

      1. Initial program 100.0%

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

        \[\leadsto \color{blue}{x} \cdot \frac{\sinh y}{y} \]
      3. Step-by-step derivation
        1. Applied rewrites63.0%

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

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

            \[\leadsto \color{blue}{\frac{\sinh y}{y} \cdot x} \]
          3. lower-*.f6463.0

            \[\leadsto \color{blue}{\frac{\sinh y}{y} \cdot x} \]
        3. Applied rewrites63.0%

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

      Alternative 3: 75.8% accurate, 0.5× speedup?

      \[\begin{array}{l} t_0 := \frac{\sinh y}{y}\\ \mathsf{copysign}\left(1, x\right) \cdot \begin{array}{l} \mathbf{if}\;\sin \left(\left|x\right|\right) \cdot t\_0 \leq 2 \cdot 10^{-6}:\\ \;\;\;\;\mathsf{fma}\left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|, -0.16666666666666666, \left|x\right|\right) \cdot t\_0\\ \mathbf{else}:\\ \;\;\;\;\frac{\sinh y \cdot \left|x\right|}{y}\\ \end{array} \end{array} \]
      (FPCore (x y)
       :precision binary64
       (let* ((t_0 (/ (sinh y) y)))
         (*
          (copysign 1.0 x)
          (if (<= (* (sin (fabs x)) t_0) 2e-6)
            (*
             (fma (* (* (fabs x) (fabs x)) (fabs x)) -0.16666666666666666 (fabs x))
             t_0)
            (/ (* (sinh y) (fabs x)) y)))))
      double code(double x, double y) {
      	double t_0 = sinh(y) / y;
      	double tmp;
      	if ((sin(fabs(x)) * t_0) <= 2e-6) {
      		tmp = fma(((fabs(x) * fabs(x)) * fabs(x)), -0.16666666666666666, fabs(x)) * t_0;
      	} else {
      		tmp = (sinh(y) * fabs(x)) / y;
      	}
      	return copysign(1.0, x) * tmp;
      }
      
      function code(x, y)
      	t_0 = Float64(sinh(y) / y)
      	tmp = 0.0
      	if (Float64(sin(abs(x)) * t_0) <= 2e-6)
      		tmp = Float64(fma(Float64(Float64(abs(x) * abs(x)) * abs(x)), -0.16666666666666666, abs(x)) * t_0);
      	else
      		tmp = Float64(Float64(sinh(y) * abs(x)) / y);
      	end
      	return Float64(copysign(1.0, x) * tmp)
      end
      
      code[x_, y_] := Block[{t$95$0 = N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[(N[Sin[N[Abs[x], $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision], 2e-6], N[(N[(N[(N[(N[Abs[x], $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision] * -0.16666666666666666 + N[Abs[x], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[(N[Sinh[y], $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]]), $MachinePrecision]]
      
      \begin{array}{l}
      t_0 := \frac{\sinh y}{y}\\
      \mathsf{copysign}\left(1, x\right) \cdot \begin{array}{l}
      \mathbf{if}\;\sin \left(\left|x\right|\right) \cdot t\_0 \leq 2 \cdot 10^{-6}:\\
      \;\;\;\;\mathsf{fma}\left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|, -0.16666666666666666, \left|x\right|\right) \cdot t\_0\\
      
      \mathbf{else}:\\
      \;\;\;\;\frac{\sinh y \cdot \left|x\right|}{y}\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if (*.f64 (sin.f64 x) (/.f64 (sinh.f64 y) y)) < 1.99999999999999991e-6

        1. Initial program 100.0%

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

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

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

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

            \[\leadsto \left(x \cdot \left(1 + \frac{-1}{6} \cdot \color{blue}{{x}^{2}}\right)\right) \cdot \frac{\sinh y}{y} \]
          4. lower-pow.f6463.3

            \[\leadsto \left(x \cdot \left(1 + -0.16666666666666666 \cdot {x}^{\color{blue}{2}}\right)\right) \cdot \frac{\sinh y}{y} \]
        4. Applied rewrites63.3%

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

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

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

            \[\leadsto \left(x \cdot \left(\frac{-1}{6} \cdot {x}^{2} + \color{blue}{1}\right)\right) \cdot \frac{\sinh y}{y} \]
          4. distribute-rgt-inN/A

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

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

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

            \[\leadsto \left(x \cdot \left({x}^{2} \cdot \frac{-1}{6}\right) + 1 \cdot x\right) \cdot \frac{\sinh y}{y} \]
          8. associate-*r*N/A

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

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

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

            \[\leadsto \mathsf{fma}\left({x}^{2} \cdot x, \frac{-1}{6}, x\right) \cdot \frac{\sinh y}{y} \]
          12. lower-*.f6463.3

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

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

            \[\leadsto \mathsf{fma}\left(\left(x \cdot x\right) \cdot x, \frac{-1}{6}, x\right) \cdot \frac{\sinh y}{y} \]
          15. lower-*.f6463.3

            \[\leadsto \mathsf{fma}\left(\left(x \cdot x\right) \cdot x, -0.16666666666666666, x\right) \cdot \frac{\sinh y}{y} \]
        6. Applied rewrites63.3%

          \[\leadsto \mathsf{fma}\left(\left(x \cdot x\right) \cdot x, \color{blue}{-0.16666666666666666}, x\right) \cdot \frac{\sinh y}{y} \]

        if 1.99999999999999991e-6 < (*.f64 (sin.f64 x) (/.f64 (sinh.f64 y) y))

        1. Initial program 100.0%

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

          \[\leadsto \color{blue}{x} \cdot \frac{\sinh y}{y} \]
        3. Step-by-step derivation
          1. Applied rewrites63.0%

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

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

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

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

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

              \[\leadsto \frac{\color{blue}{\sinh y \cdot x}}{y} \]
            6. lower-*.f6452.0

              \[\leadsto \frac{\color{blue}{\sinh y \cdot x}}{y} \]
          3. Applied rewrites52.0%

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

        Alternative 4: 63.0% accurate, 2.6× speedup?

        \[\frac{\sinh y}{y} \cdot x \]
        (FPCore (x y) :precision binary64 (* (/ (sinh y) y) x))
        double code(double x, double y) {
        	return (sinh(y) / y) * x;
        }
        
        module fmin_fmax_functions
            implicit none
            private
            public fmax
            public fmin
        
            interface fmax
                module procedure fmax88
                module procedure fmax44
                module procedure fmax84
                module procedure fmax48
            end interface
            interface fmin
                module procedure fmin88
                module procedure fmin44
                module procedure fmin84
                module procedure fmin48
            end interface
        contains
            real(8) function fmax88(x, y) result (res)
                real(8), intent (in) :: x
                real(8), intent (in) :: y
                res = merge(y, merge(x, max(x, y), y /= y), x /= x)
            end function
            real(4) function fmax44(x, y) result (res)
                real(4), intent (in) :: x
                real(4), intent (in) :: y
                res = merge(y, merge(x, max(x, y), y /= y), x /= x)
            end function
            real(8) function fmax84(x, y) result(res)
                real(8), intent (in) :: x
                real(4), intent (in) :: y
                res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
            end function
            real(8) function fmax48(x, y) result(res)
                real(4), intent (in) :: x
                real(8), intent (in) :: y
                res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
            end function
            real(8) function fmin88(x, y) result (res)
                real(8), intent (in) :: x
                real(8), intent (in) :: y
                res = merge(y, merge(x, min(x, y), y /= y), x /= x)
            end function
            real(4) function fmin44(x, y) result (res)
                real(4), intent (in) :: x
                real(4), intent (in) :: y
                res = merge(y, merge(x, min(x, y), y /= y), x /= x)
            end function
            real(8) function fmin84(x, y) result(res)
                real(8), intent (in) :: x
                real(4), intent (in) :: y
                res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
            end function
            real(8) function fmin48(x, y) result(res)
                real(4), intent (in) :: x
                real(8), intent (in) :: y
                res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
            end function
        end module
        
        real(8) function code(x, y)
        use fmin_fmax_functions
            real(8), intent (in) :: x
            real(8), intent (in) :: y
            code = (sinh(y) / y) * x
        end function
        
        public static double code(double x, double y) {
        	return (Math.sinh(y) / y) * x;
        }
        
        def code(x, y):
        	return (math.sinh(y) / y) * x
        
        function code(x, y)
        	return Float64(Float64(sinh(y) / y) * x)
        end
        
        function tmp = code(x, y)
        	tmp = (sinh(y) / y) * x;
        end
        
        code[x_, y_] := N[(N[(N[Sinh[y], $MachinePrecision] / y), $MachinePrecision] * x), $MachinePrecision]
        
        \frac{\sinh y}{y} \cdot x
        
        Derivation
        1. Initial program 100.0%

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

          \[\leadsto \color{blue}{x} \cdot \frac{\sinh y}{y} \]
        3. Step-by-step derivation
          1. Applied rewrites63.0%

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

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

              \[\leadsto \color{blue}{\frac{\sinh y}{y} \cdot x} \]
            3. lower-*.f6463.0

              \[\leadsto \color{blue}{\frac{\sinh y}{y} \cdot x} \]
          3. Applied rewrites63.0%

            \[\leadsto \color{blue}{\frac{\sinh y}{y} \cdot x} \]
          4. Add Preprocessing

          Alternative 5: 32.7% accurate, 1.0× speedup?

          \[\mathsf{copysign}\left(1, x\right) \cdot \begin{array}{l} \mathbf{if}\;\sin \left(\left|x\right|\right) \leq 10^{-6}:\\ \;\;\;\;1 \cdot \left|x\right|\\ \mathbf{else}:\\ \;\;\;\;\frac{y \cdot \left|x\right|}{y}\\ \end{array} \]
          (FPCore (x y)
           :precision binary64
           (*
            (copysign 1.0 x)
            (if (<= (sin (fabs x)) 1e-6) (* 1.0 (fabs x)) (/ (* y (fabs x)) y))))
          double code(double x, double y) {
          	double tmp;
          	if (sin(fabs(x)) <= 1e-6) {
          		tmp = 1.0 * fabs(x);
          	} else {
          		tmp = (y * fabs(x)) / y;
          	}
          	return copysign(1.0, x) * tmp;
          }
          
          public static double code(double x, double y) {
          	double tmp;
          	if (Math.sin(Math.abs(x)) <= 1e-6) {
          		tmp = 1.0 * Math.abs(x);
          	} else {
          		tmp = (y * Math.abs(x)) / y;
          	}
          	return Math.copySign(1.0, x) * tmp;
          }
          
          def code(x, y):
          	tmp = 0
          	if math.sin(math.fabs(x)) <= 1e-6:
          		tmp = 1.0 * math.fabs(x)
          	else:
          		tmp = (y * math.fabs(x)) / y
          	return math.copysign(1.0, x) * tmp
          
          function code(x, y)
          	tmp = 0.0
          	if (sin(abs(x)) <= 1e-6)
          		tmp = Float64(1.0 * abs(x));
          	else
          		tmp = Float64(Float64(y * abs(x)) / y);
          	end
          	return Float64(copysign(1.0, x) * tmp)
          end
          
          function tmp_2 = code(x, y)
          	tmp = 0.0;
          	if (sin(abs(x)) <= 1e-6)
          		tmp = 1.0 * abs(x);
          	else
          		tmp = (y * abs(x)) / y;
          	end
          	tmp_2 = (sign(x) * abs(1.0)) * tmp;
          end
          
          code[x_, y_] := N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[Sin[N[Abs[x], $MachinePrecision]], $MachinePrecision], 1e-6], N[(1.0 * N[Abs[x], $MachinePrecision]), $MachinePrecision], N[(N[(y * N[Abs[x], $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]]), $MachinePrecision]
          
          \mathsf{copysign}\left(1, x\right) \cdot \begin{array}{l}
          \mathbf{if}\;\sin \left(\left|x\right|\right) \leq 10^{-6}:\\
          \;\;\;\;1 \cdot \left|x\right|\\
          
          \mathbf{else}:\\
          \;\;\;\;\frac{y \cdot \left|x\right|}{y}\\
          
          
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if (sin.f64 x) < 9.99999999999999955e-7

            1. Initial program 100.0%

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

              \[\leadsto \color{blue}{x} \cdot \frac{\sinh y}{y} \]
            3. Step-by-step derivation
              1. Applied rewrites63.0%

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

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

                  \[\leadsto \color{blue}{\frac{\sinh y}{y} \cdot x} \]
                3. lower-*.f6463.0

                  \[\leadsto \color{blue}{\frac{\sinh y}{y} \cdot x} \]
              3. Applied rewrites63.0%

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

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

                  \[\leadsto \color{blue}{1} \cdot x \]

                if 9.99999999999999955e-7 < (sin.f64 x)

                1. Initial program 100.0%

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

                  \[\leadsto \color{blue}{x} \cdot \frac{\sinh y}{y} \]
                3. Step-by-step derivation
                  1. Applied rewrites63.0%

                    \[\leadsto \color{blue}{x} \cdot \frac{\sinh y}{y} \]
                  2. Taylor expanded in y around 0

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

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

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

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

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

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

                        \[\leadsto \frac{\color{blue}{y \cdot x}}{y} \]
                      6. lower-*.f6421.6

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

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

                  Alternative 6: 26.9% accurate, 13.0× speedup?

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

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

                    \[\leadsto \color{blue}{x} \cdot \frac{\sinh y}{y} \]
                  3. Step-by-step derivation
                    1. Applied rewrites63.0%

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

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

                        \[\leadsto \color{blue}{\frac{\sinh y}{y} \cdot x} \]
                      3. lower-*.f6463.0

                        \[\leadsto \color{blue}{\frac{\sinh y}{y} \cdot x} \]
                    3. Applied rewrites63.0%

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

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

                        \[\leadsto \color{blue}{1} \cdot x \]
                      2. Add Preprocessing

                      Reproduce

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