Linear.Quaternion:$cexp from linear-1.19.1.3

Percentage Accurate: 99.8% → 99.8%
Time: 6.8s
Alternatives: 4
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 4 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.7%

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

Alternative 2: 63.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{\sin y}{y} \leq 4 \cdot 10^{-84}:\\ \;\;\;\;0\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \end{array} \]
(FPCore (x y) :precision binary64 (if (<= (/ (sin y) y) 4e-84) 0.0 x))
double code(double x, double y) {
	double tmp;
	if ((sin(y) / y) <= 4e-84) {
		tmp = 0.0;
	} else {
		tmp = x;
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if ((sin(y) / y) <= 4d-84) then
        tmp = 0.0d0
    else
        tmp = x
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if ((Math.sin(y) / y) <= 4e-84) {
		tmp = 0.0;
	} else {
		tmp = x;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if (math.sin(y) / y) <= 4e-84:
		tmp = 0.0
	else:
		tmp = x
	return tmp
function code(x, y)
	tmp = 0.0
	if (Float64(sin(y) / y) <= 4e-84)
		tmp = 0.0;
	else
		tmp = x;
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if ((sin(y) / y) <= 4e-84)
		tmp = 0.0;
	else
		tmp = x;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision], 4e-84], 0.0, x]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\frac{\sin y}{y} \leq 4 \cdot 10^{-84}:\\
\;\;\;\;0\\

\mathbf{else}:\\
\;\;\;\;x\\


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

    1. Initial program 99.5%

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

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

        \[\leadsto x \cdot \frac{\mathsf{neg}\left(\left(\mathsf{neg}\left(\color{blue}{\sin y}\right)\right)\right)}{y} \]
      3. sin-+PI-revN/A

        \[\leadsto x \cdot \frac{\mathsf{neg}\left(\color{blue}{\sin \left(y + \mathsf{PI}\left(\right)\right)}\right)}{y} \]
      4. sin-neg-revN/A

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

        \[\leadsto x \cdot \frac{\sin \left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{PI}\left(\right) + y\right)}\right)\right)}{y} \]
      6. distribute-neg-inN/A

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

        \[\leadsto x \cdot \frac{\color{blue}{\sin \left(\mathsf{neg}\left(\mathsf{PI}\left(\right)\right)\right) \cdot \cos \left(\mathsf{neg}\left(y\right)\right) + \cos \left(\mathsf{neg}\left(\mathsf{PI}\left(\right)\right)\right) \cdot \sin \left(\mathsf{neg}\left(y\right)\right)}}{y} \]
      8. cos-neg-revN/A

        \[\leadsto x \cdot \frac{\sin \left(\mathsf{neg}\left(\mathsf{PI}\left(\right)\right)\right) \cdot \color{blue}{\cos y} + \cos \left(\mathsf{neg}\left(\mathsf{PI}\left(\right)\right)\right) \cdot \sin \left(\mathsf{neg}\left(y\right)\right)}{y} \]
      9. cos-neg-revN/A

        \[\leadsto x \cdot \frac{\sin \left(\mathsf{neg}\left(\mathsf{PI}\left(\right)\right)\right) \cdot \cos y + \color{blue}{\cos \mathsf{PI}\left(\right)} \cdot \sin \left(\mathsf{neg}\left(y\right)\right)}{y} \]
      10. sin-neg-revN/A

        \[\leadsto x \cdot \frac{\sin \left(\mathsf{neg}\left(\mathsf{PI}\left(\right)\right)\right) \cdot \cos y + \cos \mathsf{PI}\left(\right) \cdot \color{blue}{\left(\mathsf{neg}\left(\sin y\right)\right)}}{y} \]
      11. lift-sin.f64N/A

        \[\leadsto x \cdot \frac{\sin \left(\mathsf{neg}\left(\mathsf{PI}\left(\right)\right)\right) \cdot \cos y + \cos \mathsf{PI}\left(\right) \cdot \left(\mathsf{neg}\left(\color{blue}{\sin y}\right)\right)}{y} \]
      12. distribute-rgt-neg-inN/A

        \[\leadsto x \cdot \frac{\sin \left(\mathsf{neg}\left(\mathsf{PI}\left(\right)\right)\right) \cdot \cos y + \color{blue}{\left(\mathsf{neg}\left(\cos \mathsf{PI}\left(\right) \cdot \sin y\right)\right)}}{y} \]
      13. *-commutativeN/A

        \[\leadsto x \cdot \frac{\sin \left(\mathsf{neg}\left(\mathsf{PI}\left(\right)\right)\right) \cdot \cos y + \left(\mathsf{neg}\left(\color{blue}{\sin y \cdot \cos \mathsf{PI}\left(\right)}\right)\right)}{y} \]
      14. distribute-lft-neg-inN/A

        \[\leadsto x \cdot \frac{\sin \left(\mathsf{neg}\left(\mathsf{PI}\left(\right)\right)\right) \cdot \cos y + \color{blue}{\left(\mathsf{neg}\left(\sin y\right)\right) \cdot \cos \mathsf{PI}\left(\right)}}{y} \]
      15. lift-sin.f64N/A

        \[\leadsto x \cdot \frac{\sin \left(\mathsf{neg}\left(\mathsf{PI}\left(\right)\right)\right) \cdot \cos y + \left(\mathsf{neg}\left(\color{blue}{\sin y}\right)\right) \cdot \cos \mathsf{PI}\left(\right)}{y} \]
      16. sin-neg-revN/A

        \[\leadsto x \cdot \frac{\sin \left(\mathsf{neg}\left(\mathsf{PI}\left(\right)\right)\right) \cdot \cos y + \color{blue}{\sin \left(\mathsf{neg}\left(y\right)\right)} \cdot \cos \mathsf{PI}\left(\right)}{y} \]
      17. lower-fma.f64N/A

        \[\leadsto x \cdot \frac{\color{blue}{\mathsf{fma}\left(\sin \left(\mathsf{neg}\left(\mathsf{PI}\left(\right)\right)\right), \cos y, \sin \left(\mathsf{neg}\left(y\right)\right) \cdot \cos \mathsf{PI}\left(\right)\right)}}{y} \]
    4. Applied rewrites98.5%

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

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

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

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

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

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

        \[\leadsto \color{blue}{0} \cdot \frac{x}{y} \]
      6. mul0-lft26.0

        \[\leadsto \color{blue}{0} \]
    7. Applied rewrites26.0%

      \[\leadsto \color{blue}{0} \]

    if 4.0000000000000001e-84 < (/.f64 (sin.f64 y) y)

    1. Initial program 99.9%

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

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

        \[\leadsto x \cdot \frac{\mathsf{neg}\left(\left(\mathsf{neg}\left(\color{blue}{\sin y}\right)\right)\right)}{y} \]
      3. sin-+PI-revN/A

        \[\leadsto x \cdot \frac{\mathsf{neg}\left(\color{blue}{\sin \left(y + \mathsf{PI}\left(\right)\right)}\right)}{y} \]
      4. sin-neg-revN/A

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

        \[\leadsto x \cdot \frac{\sin \left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{PI}\left(\right) + y\right)}\right)\right)}{y} \]
      6. distribute-neg-inN/A

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

        \[\leadsto x \cdot \frac{\color{blue}{\sin \left(\mathsf{neg}\left(\mathsf{PI}\left(\right)\right)\right) \cdot \cos \left(\mathsf{neg}\left(y\right)\right) + \cos \left(\mathsf{neg}\left(\mathsf{PI}\left(\right)\right)\right) \cdot \sin \left(\mathsf{neg}\left(y\right)\right)}}{y} \]
      8. cos-neg-revN/A

        \[\leadsto x \cdot \frac{\sin \left(\mathsf{neg}\left(\mathsf{PI}\left(\right)\right)\right) \cdot \color{blue}{\cos y} + \cos \left(\mathsf{neg}\left(\mathsf{PI}\left(\right)\right)\right) \cdot \sin \left(\mathsf{neg}\left(y\right)\right)}{y} \]
      9. cos-neg-revN/A

        \[\leadsto x \cdot \frac{\sin \left(\mathsf{neg}\left(\mathsf{PI}\left(\right)\right)\right) \cdot \cos y + \color{blue}{\cos \mathsf{PI}\left(\right)} \cdot \sin \left(\mathsf{neg}\left(y\right)\right)}{y} \]
      10. sin-neg-revN/A

        \[\leadsto x \cdot \frac{\sin \left(\mathsf{neg}\left(\mathsf{PI}\left(\right)\right)\right) \cdot \cos y + \cos \mathsf{PI}\left(\right) \cdot \color{blue}{\left(\mathsf{neg}\left(\sin y\right)\right)}}{y} \]
      11. lift-sin.f64N/A

        \[\leadsto x \cdot \frac{\sin \left(\mathsf{neg}\left(\mathsf{PI}\left(\right)\right)\right) \cdot \cos y + \cos \mathsf{PI}\left(\right) \cdot \left(\mathsf{neg}\left(\color{blue}{\sin y}\right)\right)}{y} \]
      12. distribute-rgt-neg-inN/A

        \[\leadsto x \cdot \frac{\sin \left(\mathsf{neg}\left(\mathsf{PI}\left(\right)\right)\right) \cdot \cos y + \color{blue}{\left(\mathsf{neg}\left(\cos \mathsf{PI}\left(\right) \cdot \sin y\right)\right)}}{y} \]
      13. *-commutativeN/A

        \[\leadsto x \cdot \frac{\sin \left(\mathsf{neg}\left(\mathsf{PI}\left(\right)\right)\right) \cdot \cos y + \left(\mathsf{neg}\left(\color{blue}{\sin y \cdot \cos \mathsf{PI}\left(\right)}\right)\right)}{y} \]
      14. distribute-lft-neg-inN/A

        \[\leadsto x \cdot \frac{\sin \left(\mathsf{neg}\left(\mathsf{PI}\left(\right)\right)\right) \cdot \cos y + \color{blue}{\left(\mathsf{neg}\left(\sin y\right)\right) \cdot \cos \mathsf{PI}\left(\right)}}{y} \]
      15. lift-sin.f64N/A

        \[\leadsto x \cdot \frac{\sin \left(\mathsf{neg}\left(\mathsf{PI}\left(\right)\right)\right) \cdot \cos y + \left(\mathsf{neg}\left(\color{blue}{\sin y}\right)\right) \cdot \cos \mathsf{PI}\left(\right)}{y} \]
      16. sin-neg-revN/A

        \[\leadsto x \cdot \frac{\sin \left(\mathsf{neg}\left(\mathsf{PI}\left(\right)\right)\right) \cdot \cos y + \color{blue}{\sin \left(\mathsf{neg}\left(y\right)\right)} \cdot \cos \mathsf{PI}\left(\right)}{y} \]
      17. lower-fma.f64N/A

        \[\leadsto x \cdot \frac{\color{blue}{\mathsf{fma}\left(\sin \left(\mathsf{neg}\left(\mathsf{PI}\left(\right)\right)\right), \cos y, \sin \left(\mathsf{neg}\left(y\right)\right) \cdot \cos \mathsf{PI}\left(\right)\right)}}{y} \]
    4. Applied rewrites16.4%

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

      \[\leadsto \color{blue}{\frac{x \cdot y + x \cdot \sin \left(\mathsf{neg}\left(\mathsf{PI}\left(\right)\right)\right)}{y}} \]
    6. Step-by-step derivation
      1. div-addN/A

        \[\leadsto \color{blue}{\frac{x \cdot y}{y} + \frac{x \cdot \sin \left(\mathsf{neg}\left(\mathsf{PI}\left(\right)\right)\right)}{y}} \]
      2. *-commutativeN/A

        \[\leadsto \frac{x \cdot y}{y} + \frac{\color{blue}{\sin \left(\mathsf{neg}\left(\mathsf{PI}\left(\right)\right)\right) \cdot x}}{y} \]
      3. associate-/l*N/A

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

        \[\leadsto \frac{\color{blue}{y \cdot x}}{y} + \sin \left(\mathsf{neg}\left(\mathsf{PI}\left(\right)\right)\right) \cdot \frac{x}{y} \]
      5. associate-/l*N/A

        \[\leadsto \color{blue}{y \cdot \frac{x}{y}} + \sin \left(\mathsf{neg}\left(\mathsf{PI}\left(\right)\right)\right) \cdot \frac{x}{y} \]
      6. distribute-rgt-outN/A

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

        \[\leadsto \frac{x}{y} \cdot \left(y + \color{blue}{\left(\mathsf{neg}\left(\sin \mathsf{PI}\left(\right)\right)\right)}\right) \]
      8. sin-PIN/A

        \[\leadsto \frac{x}{y} \cdot \left(y + \left(\mathsf{neg}\left(\color{blue}{0}\right)\right)\right) \]
      9. metadata-evalN/A

        \[\leadsto \frac{x}{y} \cdot \left(y + \color{blue}{0}\right) \]
      10. +-rgt-identityN/A

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

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

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

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

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

        \[\leadsto x \cdot \color{blue}{1} \]
      16. *-rgt-identity90.2

        \[\leadsto \color{blue}{x} \]
    7. Applied rewrites90.2%

      \[\leadsto \color{blue}{x} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification59.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\sin y}{y} \leq 4 \cdot 10^{-84}:\\ \;\;\;\;0\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 57.5% accurate, 5.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.05 \cdot 10^{+29}:\\
\;\;\;\;\mathsf{fma}\left(y, y \cdot \left(-0.16666666666666666 \cdot x\right), x\right)\\

\mathbf{else}:\\
\;\;\;\;0\\


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

    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. 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. frac-2negN/A

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

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

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

        \[\leadsto \frac{\mathsf{neg}\left(\left(\mathsf{neg}\left(\color{blue}{\sin y \cdot x}\right)\right)\right)}{y} \]
      9. distribute-lft-neg-inN/A

        \[\leadsto \frac{\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(\sin y\right)\right) \cdot x}\right)}{y} \]
      10. distribute-lft-neg-inN/A

        \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\sin y\right)\right)\right)\right) \cdot x}}{y} \]
      11. remove-double-negN/A

        \[\leadsto \frac{\color{blue}{\sin y} \cdot x}{y} \]
      12. lower-*.f6479.8

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

      \[\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-*.f6464.1

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

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

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

      if 2.0500000000000002e29 < y

      1. Initial program 99.4%

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

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

          \[\leadsto x \cdot \frac{\mathsf{neg}\left(\left(\mathsf{neg}\left(\color{blue}{\sin y}\right)\right)\right)}{y} \]
        3. sin-+PI-revN/A

          \[\leadsto x \cdot \frac{\mathsf{neg}\left(\color{blue}{\sin \left(y + \mathsf{PI}\left(\right)\right)}\right)}{y} \]
        4. sin-neg-revN/A

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

          \[\leadsto x \cdot \frac{\sin \left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{PI}\left(\right) + y\right)}\right)\right)}{y} \]
        6. distribute-neg-inN/A

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

          \[\leadsto x \cdot \frac{\color{blue}{\sin \left(\mathsf{neg}\left(\mathsf{PI}\left(\right)\right)\right) \cdot \cos \left(\mathsf{neg}\left(y\right)\right) + \cos \left(\mathsf{neg}\left(\mathsf{PI}\left(\right)\right)\right) \cdot \sin \left(\mathsf{neg}\left(y\right)\right)}}{y} \]
        8. cos-neg-revN/A

          \[\leadsto x \cdot \frac{\sin \left(\mathsf{neg}\left(\mathsf{PI}\left(\right)\right)\right) \cdot \color{blue}{\cos y} + \cos \left(\mathsf{neg}\left(\mathsf{PI}\left(\right)\right)\right) \cdot \sin \left(\mathsf{neg}\left(y\right)\right)}{y} \]
        9. cos-neg-revN/A

          \[\leadsto x \cdot \frac{\sin \left(\mathsf{neg}\left(\mathsf{PI}\left(\right)\right)\right) \cdot \cos y + \color{blue}{\cos \mathsf{PI}\left(\right)} \cdot \sin \left(\mathsf{neg}\left(y\right)\right)}{y} \]
        10. sin-neg-revN/A

          \[\leadsto x \cdot \frac{\sin \left(\mathsf{neg}\left(\mathsf{PI}\left(\right)\right)\right) \cdot \cos y + \cos \mathsf{PI}\left(\right) \cdot \color{blue}{\left(\mathsf{neg}\left(\sin y\right)\right)}}{y} \]
        11. lift-sin.f64N/A

          \[\leadsto x \cdot \frac{\sin \left(\mathsf{neg}\left(\mathsf{PI}\left(\right)\right)\right) \cdot \cos y + \cos \mathsf{PI}\left(\right) \cdot \left(\mathsf{neg}\left(\color{blue}{\sin y}\right)\right)}{y} \]
        12. distribute-rgt-neg-inN/A

          \[\leadsto x \cdot \frac{\sin \left(\mathsf{neg}\left(\mathsf{PI}\left(\right)\right)\right) \cdot \cos y + \color{blue}{\left(\mathsf{neg}\left(\cos \mathsf{PI}\left(\right) \cdot \sin y\right)\right)}}{y} \]
        13. *-commutativeN/A

          \[\leadsto x \cdot \frac{\sin \left(\mathsf{neg}\left(\mathsf{PI}\left(\right)\right)\right) \cdot \cos y + \left(\mathsf{neg}\left(\color{blue}{\sin y \cdot \cos \mathsf{PI}\left(\right)}\right)\right)}{y} \]
        14. distribute-lft-neg-inN/A

          \[\leadsto x \cdot \frac{\sin \left(\mathsf{neg}\left(\mathsf{PI}\left(\right)\right)\right) \cdot \cos y + \color{blue}{\left(\mathsf{neg}\left(\sin y\right)\right) \cdot \cos \mathsf{PI}\left(\right)}}{y} \]
        15. lift-sin.f64N/A

          \[\leadsto x \cdot \frac{\sin \left(\mathsf{neg}\left(\mathsf{PI}\left(\right)\right)\right) \cdot \cos y + \left(\mathsf{neg}\left(\color{blue}{\sin y}\right)\right) \cdot \cos \mathsf{PI}\left(\right)}{y} \]
        16. sin-neg-revN/A

          \[\leadsto x \cdot \frac{\sin \left(\mathsf{neg}\left(\mathsf{PI}\left(\right)\right)\right) \cdot \cos y + \color{blue}{\sin \left(\mathsf{neg}\left(y\right)\right)} \cdot \cos \mathsf{PI}\left(\right)}{y} \]
        17. lower-fma.f64N/A

          \[\leadsto x \cdot \frac{\color{blue}{\mathsf{fma}\left(\sin \left(\mathsf{neg}\left(\mathsf{PI}\left(\right)\right)\right), \cos y, \sin \left(\mathsf{neg}\left(y\right)\right) \cdot \cos \mathsf{PI}\left(\right)\right)}}{y} \]
      4. Applied rewrites98.6%

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

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

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

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

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

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

          \[\leadsto \color{blue}{0} \cdot \frac{x}{y} \]
        6. mul0-lft25.3

          \[\leadsto \color{blue}{0} \]
      7. Applied rewrites25.3%

        \[\leadsto \color{blue}{0} \]
    9. Recombined 2 regimes into one program.
    10. Final simplification54.4%

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

    Alternative 4: 16.4% accurate, 117.0× speedup?

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

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

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

        \[\leadsto x \cdot \frac{\mathsf{neg}\left(\left(\mathsf{neg}\left(\color{blue}{\sin y}\right)\right)\right)}{y} \]
      3. sin-+PI-revN/A

        \[\leadsto x \cdot \frac{\mathsf{neg}\left(\color{blue}{\sin \left(y + \mathsf{PI}\left(\right)\right)}\right)}{y} \]
      4. sin-neg-revN/A

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

        \[\leadsto x \cdot \frac{\sin \left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{PI}\left(\right) + y\right)}\right)\right)}{y} \]
      6. distribute-neg-inN/A

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

        \[\leadsto x \cdot \frac{\color{blue}{\sin \left(\mathsf{neg}\left(\mathsf{PI}\left(\right)\right)\right) \cdot \cos \left(\mathsf{neg}\left(y\right)\right) + \cos \left(\mathsf{neg}\left(\mathsf{PI}\left(\right)\right)\right) \cdot \sin \left(\mathsf{neg}\left(y\right)\right)}}{y} \]
      8. cos-neg-revN/A

        \[\leadsto x \cdot \frac{\sin \left(\mathsf{neg}\left(\mathsf{PI}\left(\right)\right)\right) \cdot \color{blue}{\cos y} + \cos \left(\mathsf{neg}\left(\mathsf{PI}\left(\right)\right)\right) \cdot \sin \left(\mathsf{neg}\left(y\right)\right)}{y} \]
      9. cos-neg-revN/A

        \[\leadsto x \cdot \frac{\sin \left(\mathsf{neg}\left(\mathsf{PI}\left(\right)\right)\right) \cdot \cos y + \color{blue}{\cos \mathsf{PI}\left(\right)} \cdot \sin \left(\mathsf{neg}\left(y\right)\right)}{y} \]
      10. sin-neg-revN/A

        \[\leadsto x \cdot \frac{\sin \left(\mathsf{neg}\left(\mathsf{PI}\left(\right)\right)\right) \cdot \cos y + \cos \mathsf{PI}\left(\right) \cdot \color{blue}{\left(\mathsf{neg}\left(\sin y\right)\right)}}{y} \]
      11. lift-sin.f64N/A

        \[\leadsto x \cdot \frac{\sin \left(\mathsf{neg}\left(\mathsf{PI}\left(\right)\right)\right) \cdot \cos y + \cos \mathsf{PI}\left(\right) \cdot \left(\mathsf{neg}\left(\color{blue}{\sin y}\right)\right)}{y} \]
      12. distribute-rgt-neg-inN/A

        \[\leadsto x \cdot \frac{\sin \left(\mathsf{neg}\left(\mathsf{PI}\left(\right)\right)\right) \cdot \cos y + \color{blue}{\left(\mathsf{neg}\left(\cos \mathsf{PI}\left(\right) \cdot \sin y\right)\right)}}{y} \]
      13. *-commutativeN/A

        \[\leadsto x \cdot \frac{\sin \left(\mathsf{neg}\left(\mathsf{PI}\left(\right)\right)\right) \cdot \cos y + \left(\mathsf{neg}\left(\color{blue}{\sin y \cdot \cos \mathsf{PI}\left(\right)}\right)\right)}{y} \]
      14. distribute-lft-neg-inN/A

        \[\leadsto x \cdot \frac{\sin \left(\mathsf{neg}\left(\mathsf{PI}\left(\right)\right)\right) \cdot \cos y + \color{blue}{\left(\mathsf{neg}\left(\sin y\right)\right) \cdot \cos \mathsf{PI}\left(\right)}}{y} \]
      15. lift-sin.f64N/A

        \[\leadsto x \cdot \frac{\sin \left(\mathsf{neg}\left(\mathsf{PI}\left(\right)\right)\right) \cdot \cos y + \left(\mathsf{neg}\left(\color{blue}{\sin y}\right)\right) \cdot \cos \mathsf{PI}\left(\right)}{y} \]
      16. sin-neg-revN/A

        \[\leadsto x \cdot \frac{\sin \left(\mathsf{neg}\left(\mathsf{PI}\left(\right)\right)\right) \cdot \cos y + \color{blue}{\sin \left(\mathsf{neg}\left(y\right)\right)} \cdot \cos \mathsf{PI}\left(\right)}{y} \]
      17. lower-fma.f64N/A

        \[\leadsto x \cdot \frac{\color{blue}{\mathsf{fma}\left(\sin \left(\mathsf{neg}\left(\mathsf{PI}\left(\right)\right)\right), \cos y, \sin \left(\mathsf{neg}\left(y\right)\right) \cdot \cos \mathsf{PI}\left(\right)\right)}}{y} \]
    4. Applied rewrites55.2%

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

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

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

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

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

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

        \[\leadsto \color{blue}{0} \cdot \frac{x}{y} \]
      6. mul0-lft14.6

        \[\leadsto \color{blue}{0} \]
    7. Applied rewrites14.6%

      \[\leadsto \color{blue}{0} \]
    8. Final simplification14.6%

      \[\leadsto 0 \]
    9. Add Preprocessing

    Reproduce

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