Linear.Quaternion:$cexp from linear-1.19.1.3

Percentage Accurate: 99.8% → 99.8%
Time: 10.1s
Alternatives: 7
Speedup: 1.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 7 alternatives:

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

Initial Program: 99.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ x \cdot \frac{\sin y}{y} \end{array} \]
(FPCore (x y) :precision binary64 (* x (/ (sin y) y)))
double code(double x, double y) {
	return x * (sin(y) / y);
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = x * (sin(y) / y)
end function
public static double code(double x, double y) {
	return x * (Math.sin(y) / y);
}
def code(x, y):
	return x * (math.sin(y) / y)
function code(x, y)
	return Float64(x * Float64(sin(y) / y))
end
function tmp = code(x, y)
	tmp = x * (sin(y) / y);
end
code[x_, y_] := N[(x * N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

Alternative 1: 99.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ x \cdot \frac{\sin y}{y} \end{array} \]
(FPCore (x y) :precision binary64 (* x (/ (sin y) y)))
double code(double x, double y) {
	return x * (sin(y) / y);
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = x * (sin(y) / y)
end function
public static double code(double x, double y) {
	return x * (Math.sin(y) / y);
}
def code(x, y):
	return x * (math.sin(y) / y)
function code(x, y)
	return Float64(x * Float64(sin(y) / y))
end
function tmp = code(x, y)
	tmp = x * (sin(y) / y);
end
code[x_, y_] := N[(x * N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
x \cdot \frac{\sin y}{y}
\end{array}
Derivation
  1. Initial program 99.8%

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

Alternative 2: 61.2% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\frac{\sin y}{y} \leq 0.05:\\
\;\;\;\;y \cdot \frac{x}{y}\\

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


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

    1. Initial program 99.5%

      \[x \cdot \frac{\sin y}{y} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. associate-*r/N/A

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{1 \cdot x}{y}} \cdot \sin y \]
      7. *-lft-identityN/A

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

        \[\leadsto \color{blue}{\frac{x}{y}} \cdot \sin y \]
      9. sin-lowering-sin.f6499.7

        \[\leadsto \frac{x}{y} \cdot \color{blue}{\sin y} \]
    4. Applied egg-rr99.7%

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

      \[\leadsto \frac{x}{y} \cdot \color{blue}{y} \]
    6. Step-by-step derivation
      1. Simplified22.5%

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

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

      1. Initial program 100.0%

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

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

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

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

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

          \[\leadsto x \cdot \left(\color{blue}{y \cdot \left(\frac{-1}{6} \cdot y\right)} + 1\right) \]
        5. accelerator-lowering-fma.f64N/A

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

          \[\leadsto x \cdot \mathsf{fma}\left(y, \color{blue}{y \cdot \frac{-1}{6}}, 1\right) \]
        7. *-lowering-*.f6499.4

          \[\leadsto x \cdot \mathsf{fma}\left(y, \color{blue}{y \cdot -0.16666666666666666}, 1\right) \]
      5. Simplified99.4%

        \[\leadsto x \cdot \color{blue}{\mathsf{fma}\left(y, y \cdot -0.16666666666666666, 1\right)} \]
    7. Recombined 2 regimes into one program.
    8. Final simplification65.2%

      \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\sin y}{y} \leq 0.05:\\ \;\;\;\;y \cdot \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \mathsf{fma}\left(y, y \cdot -0.16666666666666666, 1\right)\\ \end{array} \]
    9. Add Preprocessing

    Alternative 3: 62.4% accurate, 2.6× speedup?

    \[\begin{array}{l} \\ \frac{x}{\mathsf{fma}\left(y, y \cdot \mathsf{fma}\left(y \cdot y, \mathsf{fma}\left(y, y \cdot 0.00205026455026455, 0.019444444444444445\right), 0.16666666666666666\right), 1\right)} \end{array} \]
    (FPCore (x y)
     :precision binary64
     (/
      x
      (fma
       y
       (*
        y
        (fma
         (* y y)
         (fma y (* y 0.00205026455026455) 0.019444444444444445)
         0.16666666666666666))
       1.0)))
    double code(double x, double y) {
    	return x / fma(y, (y * fma((y * y), fma(y, (y * 0.00205026455026455), 0.019444444444444445), 0.16666666666666666)), 1.0);
    }
    
    function code(x, y)
    	return Float64(x / fma(y, Float64(y * fma(Float64(y * y), fma(y, Float64(y * 0.00205026455026455), 0.019444444444444445), 0.16666666666666666)), 1.0))
    end
    
    code[x_, y_] := N[(x / N[(y * N[(y * N[(N[(y * y), $MachinePrecision] * N[(y * N[(y * 0.00205026455026455), $MachinePrecision] + 0.019444444444444445), $MachinePrecision] + 0.16666666666666666), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]
    
    \begin{array}{l}
    
    \\
    \frac{x}{\mathsf{fma}\left(y, y \cdot \mathsf{fma}\left(y \cdot y, \mathsf{fma}\left(y, y \cdot 0.00205026455026455, 0.019444444444444445\right), 0.16666666666666666\right), 1\right)}
    \end{array}
    
    Derivation
    1. Initial program 99.8%

      \[x \cdot \frac{\sin y}{y} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. clear-numN/A

        \[\leadsto x \cdot \color{blue}{\frac{1}{\frac{y}{\sin y}}} \]
      2. un-div-invN/A

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

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

        \[\leadsto \frac{x}{\color{blue}{\frac{y}{\sin y}}} \]
      5. sin-lowering-sin.f6499.4

        \[\leadsto \frac{x}{\frac{y}{\color{blue}{\sin y}}} \]
    4. Applied egg-rr99.4%

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

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

        \[\leadsto \frac{x}{\color{blue}{{y}^{2} \cdot \left(\frac{1}{6} + {y}^{2} \cdot \left(\frac{7}{360} + \frac{31}{15120} \cdot {y}^{2}\right)\right) + 1}} \]
      2. unpow2N/A

        \[\leadsto \frac{x}{\color{blue}{\left(y \cdot y\right)} \cdot \left(\frac{1}{6} + {y}^{2} \cdot \left(\frac{7}{360} + \frac{31}{15120} \cdot {y}^{2}\right)\right) + 1} \]
      3. associate-*l*N/A

        \[\leadsto \frac{x}{\color{blue}{y \cdot \left(y \cdot \left(\frac{1}{6} + {y}^{2} \cdot \left(\frac{7}{360} + \frac{31}{15120} \cdot {y}^{2}\right)\right)\right)} + 1} \]
      4. accelerator-lowering-fma.f64N/A

        \[\leadsto \frac{x}{\color{blue}{\mathsf{fma}\left(y, y \cdot \left(\frac{1}{6} + {y}^{2} \cdot \left(\frac{7}{360} + \frac{31}{15120} \cdot {y}^{2}\right)\right), 1\right)}} \]
      5. *-lowering-*.f64N/A

        \[\leadsto \frac{x}{\mathsf{fma}\left(y, \color{blue}{y \cdot \left(\frac{1}{6} + {y}^{2} \cdot \left(\frac{7}{360} + \frac{31}{15120} \cdot {y}^{2}\right)\right)}, 1\right)} \]
      6. +-commutativeN/A

        \[\leadsto \frac{x}{\mathsf{fma}\left(y, y \cdot \color{blue}{\left({y}^{2} \cdot \left(\frac{7}{360} + \frac{31}{15120} \cdot {y}^{2}\right) + \frac{1}{6}\right)}, 1\right)} \]
      7. accelerator-lowering-fma.f64N/A

        \[\leadsto \frac{x}{\mathsf{fma}\left(y, y \cdot \color{blue}{\mathsf{fma}\left({y}^{2}, \frac{7}{360} + \frac{31}{15120} \cdot {y}^{2}, \frac{1}{6}\right)}, 1\right)} \]
      8. unpow2N/A

        \[\leadsto \frac{x}{\mathsf{fma}\left(y, y \cdot \mathsf{fma}\left(\color{blue}{y \cdot y}, \frac{7}{360} + \frac{31}{15120} \cdot {y}^{2}, \frac{1}{6}\right), 1\right)} \]
      9. *-lowering-*.f64N/A

        \[\leadsto \frac{x}{\mathsf{fma}\left(y, y \cdot \mathsf{fma}\left(\color{blue}{y \cdot y}, \frac{7}{360} + \frac{31}{15120} \cdot {y}^{2}, \frac{1}{6}\right), 1\right)} \]
      10. +-commutativeN/A

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

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

        \[\leadsto \frac{x}{\mathsf{fma}\left(y, y \cdot \mathsf{fma}\left(y \cdot y, \color{blue}{\left(y \cdot y\right)} \cdot \frac{31}{15120} + \frac{7}{360}, \frac{1}{6}\right), 1\right)} \]
      13. associate-*l*N/A

        \[\leadsto \frac{x}{\mathsf{fma}\left(y, y \cdot \mathsf{fma}\left(y \cdot y, \color{blue}{y \cdot \left(y \cdot \frac{31}{15120}\right)} + \frac{7}{360}, \frac{1}{6}\right), 1\right)} \]
      14. accelerator-lowering-fma.f64N/A

        \[\leadsto \frac{x}{\mathsf{fma}\left(y, y \cdot \mathsf{fma}\left(y \cdot y, \color{blue}{\mathsf{fma}\left(y, y \cdot \frac{31}{15120}, \frac{7}{360}\right)}, \frac{1}{6}\right), 1\right)} \]
      15. *-lowering-*.f6466.5

        \[\leadsto \frac{x}{\mathsf{fma}\left(y, y \cdot \mathsf{fma}\left(y \cdot y, \mathsf{fma}\left(y, \color{blue}{y \cdot 0.00205026455026455}, 0.019444444444444445\right), 0.16666666666666666\right), 1\right)} \]
    7. Simplified66.5%

      \[\leadsto \frac{x}{\color{blue}{\mathsf{fma}\left(y, y \cdot \mathsf{fma}\left(y \cdot y, \mathsf{fma}\left(y, y \cdot 0.00205026455026455, 0.019444444444444445\right), 0.16666666666666666\right), 1\right)}} \]
    8. Add Preprocessing

    Alternative 4: 62.4% accurate, 3.4× speedup?

    \[\begin{array}{l} \\ \frac{x}{\mathsf{fma}\left(y, y \cdot \mathsf{fma}\left(y \cdot y, 0.019444444444444445, 0.16666666666666666\right), 1\right)} \end{array} \]
    (FPCore (x y)
     :precision binary64
     (/
      x
      (fma y (* y (fma (* y y) 0.019444444444444445 0.16666666666666666)) 1.0)))
    double code(double x, double y) {
    	return x / fma(y, (y * fma((y * y), 0.019444444444444445, 0.16666666666666666)), 1.0);
    }
    
    function code(x, y)
    	return Float64(x / fma(y, Float64(y * fma(Float64(y * y), 0.019444444444444445, 0.16666666666666666)), 1.0))
    end
    
    code[x_, y_] := N[(x / N[(y * N[(y * N[(N[(y * y), $MachinePrecision] * 0.019444444444444445 + 0.16666666666666666), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]
    
    \begin{array}{l}
    
    \\
    \frac{x}{\mathsf{fma}\left(y, y \cdot \mathsf{fma}\left(y \cdot y, 0.019444444444444445, 0.16666666666666666\right), 1\right)}
    \end{array}
    
    Derivation
    1. Initial program 99.8%

      \[x \cdot \frac{\sin y}{y} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. clear-numN/A

        \[\leadsto x \cdot \color{blue}{\frac{1}{\frac{y}{\sin y}}} \]
      2. un-div-invN/A

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

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

        \[\leadsto \frac{x}{\color{blue}{\frac{y}{\sin y}}} \]
      5. sin-lowering-sin.f6499.4

        \[\leadsto \frac{x}{\frac{y}{\color{blue}{\sin y}}} \]
    4. Applied egg-rr99.4%

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

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

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

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

        \[\leadsto \frac{x}{\color{blue}{y \cdot \left(y \cdot \left(\frac{1}{6} + \frac{7}{360} \cdot {y}^{2}\right)\right)} + 1} \]
      4. accelerator-lowering-fma.f64N/A

        \[\leadsto \frac{x}{\color{blue}{\mathsf{fma}\left(y, y \cdot \left(\frac{1}{6} + \frac{7}{360} \cdot {y}^{2}\right), 1\right)}} \]
      5. *-lowering-*.f64N/A

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

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

        \[\leadsto \frac{x}{\mathsf{fma}\left(y, y \cdot \left(\color{blue}{{y}^{2} \cdot \frac{7}{360}} + \frac{1}{6}\right), 1\right)} \]
      8. accelerator-lowering-fma.f64N/A

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

        \[\leadsto \frac{x}{\mathsf{fma}\left(y, y \cdot \mathsf{fma}\left(\color{blue}{y \cdot y}, \frac{7}{360}, \frac{1}{6}\right), 1\right)} \]
      10. *-lowering-*.f6466.5

        \[\leadsto \frac{x}{\mathsf{fma}\left(y, y \cdot \mathsf{fma}\left(\color{blue}{y \cdot y}, 0.019444444444444445, 0.16666666666666666\right), 1\right)} \]
    7. Simplified66.5%

      \[\leadsto \frac{x}{\color{blue}{\mathsf{fma}\left(y, y \cdot \mathsf{fma}\left(y \cdot y, 0.019444444444444445, 0.16666666666666666\right), 1\right)}} \]
    8. Add Preprocessing

    Alternative 5: 55.7% accurate, 5.1× speedup?

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

      1. Initial program 99.8%

        \[x \cdot \frac{\sin y}{y} \]
      2. Add Preprocessing
      3. Step-by-step derivation
        1. clear-numN/A

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

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

          \[\leadsto x \cdot \color{blue}{\left(\frac{1}{y} \cdot \sin y\right)} \]
        4. /-lowering-/.f64N/A

          \[\leadsto x \cdot \left(\color{blue}{\frac{1}{y}} \cdot \sin y\right) \]
        5. sin-lowering-sin.f6499.7

          \[\leadsto x \cdot \left(\frac{1}{y} \cdot \color{blue}{\sin y}\right) \]
      4. Applied egg-rr99.7%

        \[\leadsto x \cdot \color{blue}{\left(\frac{1}{y} \cdot \sin y\right)} \]
      5. Taylor expanded in y around 0

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

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

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

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

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

          \[\leadsto \mathsf{fma}\left(\frac{-1}{6}, \color{blue}{y \cdot \left(x \cdot y\right)}, x\right) \]
        6. *-lowering-*.f64N/A

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

          \[\leadsto \mathsf{fma}\left(\frac{-1}{6}, y \cdot \color{blue}{\left(y \cdot x\right)}, x\right) \]
        8. *-lowering-*.f6472.8

          \[\leadsto \mathsf{fma}\left(-0.16666666666666666, y \cdot \color{blue}{\left(y \cdot x\right)}, x\right) \]
      7. Simplified72.8%

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

      if 2.35000000000000009 < y

      1. Initial program 99.6%

        \[x \cdot \frac{\sin y}{y} \]
      2. Add Preprocessing
      3. Step-by-step derivation
        1. associate-*r/N/A

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

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

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

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

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

          \[\leadsto \color{blue}{\frac{1 \cdot x}{y}} \cdot \sin y \]
        7. *-lft-identityN/A

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

          \[\leadsto \color{blue}{\frac{x}{y}} \cdot \sin y \]
        9. sin-lowering-sin.f6499.6

          \[\leadsto \frac{x}{y} \cdot \color{blue}{\sin y} \]
      4. Applied egg-rr99.6%

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

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

          \[\leadsto \frac{x}{y} \cdot \color{blue}{y} \]
      7. Recombined 2 regimes into one program.
      8. Final simplification60.4%

        \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 2.35:\\ \;\;\;\;\mathsf{fma}\left(-0.16666666666666666, y \cdot \left(x \cdot y\right), x\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{x}{y}\\ \end{array} \]
      9. Add Preprocessing

      Alternative 6: 62.5% accurate, 5.1× speedup?

      \[\begin{array}{l} \\ \frac{x}{\mathsf{fma}\left(y, y \cdot 0.16666666666666666, 1\right)} \end{array} \]
      (FPCore (x y) :precision binary64 (/ x (fma y (* y 0.16666666666666666) 1.0)))
      double code(double x, double y) {
      	return x / fma(y, (y * 0.16666666666666666), 1.0);
      }
      
      function code(x, y)
      	return Float64(x / fma(y, Float64(y * 0.16666666666666666), 1.0))
      end
      
      code[x_, y_] := N[(x / N[(y * N[(y * 0.16666666666666666), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]
      
      \begin{array}{l}
      
      \\
      \frac{x}{\mathsf{fma}\left(y, y \cdot 0.16666666666666666, 1\right)}
      \end{array}
      
      Derivation
      1. Initial program 99.8%

        \[x \cdot \frac{\sin y}{y} \]
      2. Add Preprocessing
      3. Step-by-step derivation
        1. clear-numN/A

          \[\leadsto x \cdot \color{blue}{\frac{1}{\frac{y}{\sin y}}} \]
        2. un-div-invN/A

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

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

          \[\leadsto \frac{x}{\color{blue}{\frac{y}{\sin y}}} \]
        5. sin-lowering-sin.f6499.4

          \[\leadsto \frac{x}{\frac{y}{\color{blue}{\sin y}}} \]
      4. Applied egg-rr99.4%

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

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

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

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

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

          \[\leadsto \frac{x}{\color{blue}{y \cdot \left(y \cdot \frac{1}{6}\right)} + 1} \]
        5. accelerator-lowering-fma.f64N/A

          \[\leadsto \frac{x}{\color{blue}{\mathsf{fma}\left(y, y \cdot \frac{1}{6}, 1\right)}} \]
        6. *-lowering-*.f6466.3

          \[\leadsto \frac{x}{\mathsf{fma}\left(y, \color{blue}{y \cdot 0.16666666666666666}, 1\right)} \]
      7. Simplified66.3%

        \[\leadsto \frac{x}{\color{blue}{\mathsf{fma}\left(y, y \cdot 0.16666666666666666, 1\right)}} \]
      8. Add Preprocessing

      Alternative 7: 50.7% accurate, 117.0× speedup?

      \[\begin{array}{l} \\ x \end{array} \]
      (FPCore (x y) :precision binary64 x)
      double code(double x, double y) {
      	return x;
      }
      
      real(8) function code(x, y)
          real(8), intent (in) :: x
          real(8), intent (in) :: y
          code = x
      end function
      
      public static double code(double x, double y) {
      	return x;
      }
      
      def code(x, y):
      	return x
      
      function code(x, y)
      	return x
      end
      
      function tmp = code(x, y)
      	tmp = x;
      end
      
      code[x_, y_] := x
      
      \begin{array}{l}
      
      \\
      x
      \end{array}
      
      Derivation
      1. Initial program 99.8%

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

        \[\leadsto \color{blue}{x} \]
      4. Step-by-step derivation
        1. Simplified56.4%

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

        Reproduce

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