Linear.Quaternion:$cexp from linear-1.19.1.3

Percentage Accurate: 99.8% → 99.8%
Time: 7.7s
Alternatives: 8
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 8 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-*.f64N/A

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

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

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

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

      \[\leadsto \color{blue}{\frac{x}{\frac{y}{\sin y}}} \]
    6. 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: 99.8% accurate, 1.0× speedup?

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

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

    \[x \cdot \frac{\sin y}{y} \]
  2. Add Preprocessing
  3. Final simplification99.8%

    \[\leadsto \frac{\sin y}{y} \cdot x \]
  4. Add Preprocessing

Alternative 3: 63.9% accurate, 2.6× speedup?

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

\\
\frac{x}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.00205026455026455, y \cdot y, 0.019444444444444445\right), y \cdot y, 0.16666666666666666\right), y \cdot y, 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-*.f64N/A

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

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

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

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

      \[\leadsto \color{blue}{\frac{x}{\frac{y}{\sin y}}} \]
    6. 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. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 63.8% accurate, 3.4× speedup?

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

\\
\frac{x}{\mathsf{fma}\left(\mathsf{fma}\left(0.019444444444444445, y \cdot y, 0.16666666666666666\right), y \cdot y, 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-*.f64N/A

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

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

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

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

      \[\leadsto \color{blue}{\frac{x}{\frac{y}{\sin y}}} \]
    6. 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} + \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. *-commutativeN/A

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

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

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

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

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

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

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

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

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

Alternative 5: 57.9% accurate, 4.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq 2020:\\
\;\;\;\;\mathsf{fma}\left(y, \left(-0.16666666666666666 \cdot x\right) \cdot y, x\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{x}{0.16666666666666666 \cdot \left(y \cdot y\right)}\\


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

    1. Initial program 99.9%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\sin y \cdot x}{y}} \]
    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. *-commutativeN/A

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

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\left(y \cdot y\right) \cdot x, -0.16666666666666666, x\right)} \]
    8. Step-by-step derivation
      1. Applied rewrites62.6%

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

      if 2020 < y

      1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{x}{\frac{1}{6} \cdot \color{blue}{{y}^{2}}} \]
      9. Step-by-step derivation
        1. Applied rewrites25.7%

          \[\leadsto \frac{x}{0.16666666666666666 \cdot \color{blue}{\left(y \cdot y\right)}} \]
      10. Recombined 2 regimes into one program.
      11. Final simplification51.8%

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

      Alternative 6: 57.3% accurate, 5.1× speedup?

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

        1. Initial program 99.9%

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

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

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

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

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

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

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

          \[\leadsto \color{blue}{\frac{\sin y \cdot x}{y}} \]
        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. *-commutativeN/A

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

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

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

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

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

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

          \[\leadsto \color{blue}{\mathsf{fma}\left(\left(y \cdot y\right) \cdot x, -0.16666666666666666, x\right)} \]
        8. Step-by-step derivation
          1. Applied rewrites62.6%

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

          if 2020 < y

          1. Initial program 99.6%

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

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

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

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

              \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(x \cdot \sin y\right)}{\mathsf{neg}\left(y\right)}} \]
            5. neg-sub0N/A

              \[\leadsto \frac{\mathsf{neg}\left(x \cdot \sin y\right)}{\color{blue}{0 - y}} \]
            6. flip--N/A

              \[\leadsto \frac{\mathsf{neg}\left(x \cdot \sin y\right)}{\color{blue}{\frac{0 \cdot 0 - y \cdot y}{0 + y}}} \]
            7. +-lft-identityN/A

              \[\leadsto \frac{\mathsf{neg}\left(x \cdot \sin y\right)}{\frac{0 \cdot 0 - y \cdot y}{\color{blue}{y}}} \]
            8. associate-/r/N/A

              \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(x \cdot \sin y\right)}{0 \cdot 0 - y \cdot y} \cdot y} \]
            9. lower-*.f64N/A

              \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(x \cdot \sin y\right)}{0 \cdot 0 - y \cdot y} \cdot y} \]
          4. Applied rewrites68.4%

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

            \[\leadsto \color{blue}{\frac{x}{y}} \cdot y \]
          6. Step-by-step derivation
            1. lower-/.f6424.8

              \[\leadsto \color{blue}{\frac{x}{y}} \cdot y \]
          7. Applied rewrites24.8%

            \[\leadsto \color{blue}{\frac{x}{y}} \cdot y \]
        9. Recombined 2 regimes into one program.
        10. Final simplification51.5%

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

        Alternative 7: 63.9% accurate, 5.1× speedup?

        \[\begin{array}{l} \\ \frac{x}{\mathsf{fma}\left(0.16666666666666666, y \cdot y, 1\right)} \end{array} \]
        (FPCore (x y) :precision binary64 (/ x (fma 0.16666666666666666 (* y y) 1.0)))
        double code(double x, double y) {
        	return x / fma(0.16666666666666666, (y * y), 1.0);
        }
        
        function code(x, y)
        	return Float64(x / fma(0.16666666666666666, Float64(y * y), 1.0))
        end
        
        code[x_, y_] := N[(x / N[(0.16666666666666666 * N[(y * y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]
        
        \begin{array}{l}
        
        \\
        \frac{x}{\mathsf{fma}\left(0.16666666666666666, y \cdot y, 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-*.f64N/A

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

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

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

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

            \[\leadsto \color{blue}{\frac{x}{\frac{y}{\sin y}}} \]
          6. 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. lower-fma.f64N/A

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

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

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

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

        Alternative 8: 51.9% accurate, 19.5× speedup?

        \[\begin{array}{l} \\ 1 \cdot x \end{array} \]
        (FPCore (x y) :precision binary64 (* 1.0 x))
        double code(double x, double y) {
        	return 1.0 * x;
        }
        
        real(8) function code(x, y)
            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]
        
        \begin{array}{l}
        
        \\
        1 \cdot 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 rewrites45.8%

            \[\leadsto x \cdot \color{blue}{1} \]
          2. Final simplification45.8%

            \[\leadsto 1 \cdot x \]
          3. Add Preprocessing

          Reproduce

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