Linear.Quaternion:$cexp from linear-1.19.1.3

Percentage Accurate: 99.8% → 99.8%
Time: 9.5s
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} \\ \frac{x}{\frac{y}{\sin y}} \end{array} \]
(FPCore (x y) :precision binary64 (/ x (/ y (sin y))))
double code(double x, double y) {
	return x / (y / sin(y));
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = x / (y / sin(y))
end function
public static double code(double x, double y) {
	return x / (y / Math.sin(y));
}
def code(x, y):
	return x / (y / math.sin(y))
function code(x, y)
	return Float64(x / Float64(y / sin(y)))
end
function tmp = code(x, y)
	tmp = x / (y / sin(y));
end
code[x_, y_] := N[(x / N[(y / N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

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

      \[\leadsto x \cdot \frac{\color{blue}{\sin y}}{y} \]
    2. clear-numN/A

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

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

      \[\leadsto \color{blue}{\frac{x}{\frac{y}{\sin y}}} \]
    5. lower-/.f6499.8

      \[\leadsto \frac{x}{\color{blue}{\frac{y}{\sin y}}} \]
  4. Applied rewrites99.8%

    \[\leadsto \color{blue}{\frac{x}{\frac{y}{\sin y}}} \]
  5. Add Preprocessing

Alternative 2: 63.7% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\frac{\sin y}{y} \leq 5 \cdot 10^{-6}:\\
\;\;\;\;\frac{x}{y \cdot y} \cdot 6\\

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


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

    1. Initial program 99.6%

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

        \[\leadsto x \cdot \frac{\color{blue}{\sin y}}{y} \]
      2. clear-numN/A

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

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

        \[\leadsto \color{blue}{\frac{x}{\frac{y}{\sin y}}} \]
      5. lower-/.f6499.7

        \[\leadsto \frac{x}{\color{blue}{\frac{y}{\sin y}}} \]
    4. Applied rewrites99.7%

      \[\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. lower-fma.f64N/A

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

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

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

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

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

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

        \[\leadsto \frac{x}{\color{blue}{\left(y \cdot y\right)} \cdot \frac{1}{6}} \]
      4. lower-*.f6428.7

        \[\leadsto \frac{x}{\color{blue}{\left(y \cdot y\right)} \cdot 0.16666666666666666} \]
    10. Applied rewrites28.7%

      \[\leadsto \frac{x}{\color{blue}{\left(y \cdot y\right) \cdot 0.16666666666666666}} \]
    11. Step-by-step derivation
      1. *-rgt-identityN/A

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

        \[\leadsto \frac{x \cdot 1}{\color{blue}{\left(y \cdot y\right)} \cdot \frac{1}{6}} \]
      3. times-fracN/A

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

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

        \[\leadsto \color{blue}{\frac{x}{y \cdot y}} \cdot \frac{1}{\frac{1}{6}} \]
      6. metadata-eval28.7

        \[\leadsto \frac{x}{y \cdot y} \cdot \color{blue}{6} \]
    12. Applied rewrites28.7%

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

    if 5.00000000000000041e-6 < (/.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 \color{blue}{x + \frac{-1}{6} \cdot \left(x \cdot {y}^{2}\right)} \]
    4. Step-by-step derivation
      1. associate-*r*N/A

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

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

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

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

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

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

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

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

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

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

Alternative 3: 63.7% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\frac{\sin y}{y} \leq 5 \cdot 10^{-6}:\\
\;\;\;\;x \cdot \frac{6}{y \cdot y}\\

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


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

    1. Initial program 99.6%

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

        \[\leadsto x \cdot \frac{\color{blue}{\sin y}}{y} \]
      2. clear-numN/A

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

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

        \[\leadsto \color{blue}{\frac{x}{\frac{y}{\sin y}}} \]
      5. lower-/.f6499.7

        \[\leadsto \frac{x}{\color{blue}{\frac{y}{\sin y}}} \]
    4. Applied rewrites99.7%

      \[\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. lower-fma.f64N/A

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

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

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

      \[\leadsto \color{blue}{6 \cdot \frac{x}{{y}^{2}}} \]
    9. Step-by-step derivation
      1. associate-*r/N/A

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

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

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

        \[\leadsto \color{blue}{x \cdot \frac{6}{{y}^{2}}} \]
      5. lower-/.f64N/A

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

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

        \[\leadsto x \cdot \frac{6}{\color{blue}{y \cdot y}} \]
    10. Applied rewrites28.7%

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

    if 5.00000000000000041e-6 < (/.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 \color{blue}{x + \frac{-1}{6} \cdot \left(x \cdot {y}^{2}\right)} \]
    4. Step-by-step derivation
      1. associate-*r*N/A

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

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

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

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

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

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

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

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

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

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

Alternative 4: 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 5: 63.6% accurate, 2.6× speedup?

\[\begin{array}{l} \\ \frac{x}{\mathsf{fma}\left(y \cdot y, \mathsf{fma}\left(y \cdot y, \mathsf{fma}\left(y \cdot y, 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(Float64(y * y), fma(Float64(y * y), fma(Float64(y * y), 0.00205026455026455, 0.019444444444444445), 0.16666666666666666), 1.0))
end
code[x_, y_] := N[(x / N[(N[(y * y), $MachinePrecision] * N[(N[(y * y), $MachinePrecision] * N[(N[(y * y), $MachinePrecision] * 0.00205026455026455 + 0.019444444444444445), $MachinePrecision] + 0.16666666666666666), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{x}{\mathsf{fma}\left(y \cdot y, \mathsf{fma}\left(y \cdot y, \mathsf{fma}\left(y \cdot y, 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. lift-sin.f64N/A

      \[\leadsto x \cdot \frac{\color{blue}{\sin y}}{y} \]
    2. clear-numN/A

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

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

      \[\leadsto \color{blue}{\frac{x}{\frac{y}{\sin y}}} \]
    5. lower-/.f6499.8

      \[\leadsto \frac{x}{\color{blue}{\frac{y}{\sin y}}} \]
  4. Applied rewrites99.8%

    \[\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. lower-fma.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 63.7% 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. lift-sin.f64N/A

      \[\leadsto x \cdot \frac{\color{blue}{\sin y}}{y} \]
    2. clear-numN/A

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

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

      \[\leadsto \color{blue}{\frac{x}{\frac{y}{\sin y}}} \]
    5. lower-/.f6499.8

      \[\leadsto \frac{x}{\color{blue}{\frac{y}{\sin y}}} \]
  4. Applied rewrites99.8%

    \[\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. lower-fma.f64N/A

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

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

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

Alternative 7: 51.8% 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 x \cdot \color{blue}{1} \]
  4. Step-by-step derivation
    1. Applied rewrites53.8%

      \[\leadsto x \cdot \color{blue}{1} \]
    2. Step-by-step derivation
      1. *-rgt-identity53.8

        \[\leadsto \color{blue}{x} \]
    3. Applied rewrites53.8%

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

    Reproduce

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