Diagrams.ThreeD.Transform:aboutX from diagrams-lib-1.3.0.3, A

Percentage Accurate: 99.8% → 99.8%
Time: 11.3s
Alternatives: 9
Speedup: 1.0×

Specification

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

\\
x \cdot \cos y - z \cdot \sin 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 9 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 \cos y - z \cdot \sin y \end{array} \]
(FPCore (x y z) :precision binary64 (- (* x (cos y)) (* z (sin y))))
double code(double x, double y, double z) {
	return (x * cos(y)) - (z * sin(y));
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = (x * cos(y)) - (z * sin(y))
end function
public static double code(double x, double y, double z) {
	return (x * Math.cos(y)) - (z * Math.sin(y));
}
def code(x, y, z):
	return (x * math.cos(y)) - (z * math.sin(y))
function code(x, y, z)
	return Float64(Float64(x * cos(y)) - Float64(z * sin(y)))
end
function tmp = code(x, y, z)
	tmp = (x * cos(y)) - (z * sin(y));
end
code[x_, y_, z_] := N[(N[(x * N[Cos[y], $MachinePrecision]), $MachinePrecision] - N[(z * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
x \cdot \cos y - z \cdot \sin y
\end{array}

Alternative 1: 99.8% accurate, 1.0× speedup?

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

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

    \[x \cdot \cos y - z \cdot \sin y \]
  2. Add Preprocessing
  3. Final simplification99.8%

    \[\leadsto \cos y \cdot x - \sin y \cdot z \]
  4. Add Preprocessing

Alternative 2: 75.3% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos y \cdot x\\ t_1 := \frac{\sin y}{\frac{-1}{z}}\\ \mathbf{if}\;y \leq -1.7 \cdot 10^{+194}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq -0.0225:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;y \leq 0.0055:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, z \cdot y, -0.5 \cdot x\right) \cdot y - z, y, x\right)\\ \mathbf{elif}\;y \leq 9.5 \cdot 10^{+122}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq 1.5 \cdot 10^{+253}:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* (cos y) x)) (t_1 (/ (sin y) (/ -1.0 z))))
   (if (<= y -1.7e+194)
     t_0
     (if (<= y -0.0225)
       t_1
       (if (<= y 0.0055)
         (fma (- (* (fma 0.16666666666666666 (* z y) (* -0.5 x)) y) z) y x)
         (if (<= y 9.5e+122) t_0 (if (<= y 1.5e+253) t_1 t_0)))))))
double code(double x, double y, double z) {
	double t_0 = cos(y) * x;
	double t_1 = sin(y) / (-1.0 / z);
	double tmp;
	if (y <= -1.7e+194) {
		tmp = t_0;
	} else if (y <= -0.0225) {
		tmp = t_1;
	} else if (y <= 0.0055) {
		tmp = fma(((fma(0.16666666666666666, (z * y), (-0.5 * x)) * y) - z), y, x);
	} else if (y <= 9.5e+122) {
		tmp = t_0;
	} else if (y <= 1.5e+253) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
function code(x, y, z)
	t_0 = Float64(cos(y) * x)
	t_1 = Float64(sin(y) / Float64(-1.0 / z))
	tmp = 0.0
	if (y <= -1.7e+194)
		tmp = t_0;
	elseif (y <= -0.0225)
		tmp = t_1;
	elseif (y <= 0.0055)
		tmp = fma(Float64(Float64(fma(0.16666666666666666, Float64(z * y), Float64(-0.5 * x)) * y) - z), y, x);
	elseif (y <= 9.5e+122)
		tmp = t_0;
	elseif (y <= 1.5e+253)
		tmp = t_1;
	else
		tmp = t_0;
	end
	return tmp
end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[Cos[y], $MachinePrecision] * x), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[y], $MachinePrecision] / N[(-1.0 / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.7e+194], t$95$0, If[LessEqual[y, -0.0225], t$95$1, If[LessEqual[y, 0.0055], N[(N[(N[(N[(0.16666666666666666 * N[(z * y), $MachinePrecision] + N[(-0.5 * x), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision] - z), $MachinePrecision] * y + x), $MachinePrecision], If[LessEqual[y, 9.5e+122], t$95$0, If[LessEqual[y, 1.5e+253], t$95$1, t$95$0]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \cos y \cdot x\\
t_1 := \frac{\sin y}{\frac{-1}{z}}\\
\mathbf{if}\;y \leq -1.7 \cdot 10^{+194}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y \leq -0.0225:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;y \leq 0.0055:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, z \cdot y, -0.5 \cdot x\right) \cdot y - z, y, x\right)\\

\mathbf{elif}\;y \leq 9.5 \cdot 10^{+122}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y \leq 1.5 \cdot 10^{+253}:\\
\;\;\;\;t\_1\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -1.7000000000000001e194 or 0.0054999999999999997 < y < 9.49999999999999986e122 or 1.4999999999999999e253 < y

    1. Initial program 99.5%

      \[x \cdot \cos y - z \cdot \sin y \]
    2. Add Preprocessing
    3. Taylor expanded in z around 0

      \[\leadsto \color{blue}{x \cdot \cos y} \]
    4. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \color{blue}{\cos y \cdot x} \]
      2. lower-*.f64N/A

        \[\leadsto \color{blue}{\cos y \cdot x} \]
      3. lower-cos.f6476.2

        \[\leadsto \color{blue}{\cos y} \cdot x \]
    5. Applied rewrites76.2%

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

    if -1.7000000000000001e194 < y < -0.022499999999999999 or 9.49999999999999986e122 < y < 1.4999999999999999e253

    1. Initial program 99.6%

      \[x \cdot \cos y - z \cdot \sin y \]
    2. Add Preprocessing
    3. Taylor expanded in z around inf

      \[\leadsto \color{blue}{-1 \cdot \left(z \cdot \sin y\right)} \]
    4. Step-by-step derivation
      1. mul-1-negN/A

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

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

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

        \[\leadsto \color{blue}{\left(-z\right)} \cdot \sin y \]
      5. lower-sin.f6467.0

        \[\leadsto \left(-z\right) \cdot \color{blue}{\sin y} \]
    5. Applied rewrites67.0%

      \[\leadsto \color{blue}{\left(-z\right) \cdot \sin y} \]
    6. Step-by-step derivation
      1. Applied rewrites26.6%

        \[\leadsto \frac{0 - {z}^{3}}{0 + \mathsf{fma}\left(z, z, 0 \cdot z\right)} \cdot \sin \color{blue}{y} \]
      2. Step-by-step derivation
        1. Applied rewrites67.1%

          \[\leadsto \frac{\sin y}{\color{blue}{\frac{-1}{z}}} \]

        if -0.022499999999999999 < y < 0.0054999999999999997

        1. Initial program 100.0%

          \[x \cdot \cos y - z \cdot \sin y \]
        2. Add Preprocessing
        3. Taylor expanded in y around 0

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{6}, \color{blue}{z \cdot y}, \frac{-1}{2} \cdot x\right) \cdot y - z, y, x\right) \]
          11. lower-*.f64100.0

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

          \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, z \cdot y, -0.5 \cdot x\right) \cdot y - z, y, x\right)} \]
      3. Recombined 3 regimes into one program.
      4. Add Preprocessing

      Alternative 3: 78.2% accurate, 1.4× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(-z, \frac{1}{\frac{x}{\sin y}}, 1\right) \cdot x\\ \mathbf{if}\;z \leq -1.55 \cdot 10^{-16}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq 1.62 \cdot 10^{+34}:\\ \;\;\;\;\cos y \cdot x\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
      (FPCore (x y z)
       :precision binary64
       (let* ((t_0 (* (fma (- z) (/ 1.0 (/ x (sin y))) 1.0) x)))
         (if (<= z -1.55e-16) t_0 (if (<= z 1.62e+34) (* (cos y) x) t_0))))
      double code(double x, double y, double z) {
      	double t_0 = fma(-z, (1.0 / (x / sin(y))), 1.0) * x;
      	double tmp;
      	if (z <= -1.55e-16) {
      		tmp = t_0;
      	} else if (z <= 1.62e+34) {
      		tmp = cos(y) * x;
      	} else {
      		tmp = t_0;
      	}
      	return tmp;
      }
      
      function code(x, y, z)
      	t_0 = Float64(fma(Float64(-z), Float64(1.0 / Float64(x / sin(y))), 1.0) * x)
      	tmp = 0.0
      	if (z <= -1.55e-16)
      		tmp = t_0;
      	elseif (z <= 1.62e+34)
      		tmp = Float64(cos(y) * x);
      	else
      		tmp = t_0;
      	end
      	return tmp
      end
      
      code[x_, y_, z_] := Block[{t$95$0 = N[(N[((-z) * N[(1.0 / N[(x / N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[z, -1.55e-16], t$95$0, If[LessEqual[z, 1.62e+34], N[(N[Cos[y], $MachinePrecision] * x), $MachinePrecision], t$95$0]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      t_0 := \mathsf{fma}\left(-z, \frac{1}{\frac{x}{\sin y}}, 1\right) \cdot x\\
      \mathbf{if}\;z \leq -1.55 \cdot 10^{-16}:\\
      \;\;\;\;t\_0\\
      
      \mathbf{elif}\;z \leq 1.62 \cdot 10^{+34}:\\
      \;\;\;\;\cos y \cdot x\\
      
      \mathbf{else}:\\
      \;\;\;\;t\_0\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if z < -1.55e-16 or 1.62000000000000006e34 < z

        1. Initial program 99.8%

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

            \[\leadsto \color{blue}{x \cdot \cos y - z \cdot \sin y} \]
          2. sub-negN/A

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

            \[\leadsto \color{blue}{\left(\mathsf{neg}\left(z \cdot \sin y\right)\right) + x \cdot \cos y} \]
          4. flip-+N/A

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

            \[\leadsto \frac{\color{blue}{\left(z \cdot \sin y\right) \cdot \left(z \cdot \sin y\right)} - \left(x \cdot \cos y\right) \cdot \left(x \cdot \cos y\right)}{\left(\mathsf{neg}\left(z \cdot \sin y\right)\right) - x \cdot \cos y} \]
          6. clear-numN/A

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

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

            \[\leadsto \frac{1}{\color{blue}{\frac{\left(\mathsf{neg}\left(z \cdot \sin y\right)\right) - x \cdot \cos y}{\left(z \cdot \sin y\right) \cdot \left(z \cdot \sin y\right) - \left(x \cdot \cos y\right) \cdot \left(x \cdot \cos y\right)}}} \]
        4. Applied rewrites52.2%

          \[\leadsto \color{blue}{\frac{1}{\frac{\left(-z\right) \cdot \sin y - \cos y \cdot x}{{\left(\sin y \cdot z\right)}^{2} - {\left(\cos y \cdot x\right)}^{2}}}} \]
        5. Taylor expanded in x around inf

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

            \[\leadsto \color{blue}{\left(\cos y + -1 \cdot \frac{z \cdot \sin y}{x}\right) \cdot x} \]
          2. lower-*.f64N/A

            \[\leadsto \color{blue}{\left(\cos y + -1 \cdot \frac{z \cdot \sin y}{x}\right) \cdot x} \]
          3. +-commutativeN/A

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

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

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

            \[\leadsto \color{blue}{\mathsf{fma}\left(-1 \cdot z, \frac{\sin y}{x}, \cos y\right)} \cdot x \]
          7. mul-1-negN/A

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

            \[\leadsto \mathsf{fma}\left(\color{blue}{-z}, \frac{\sin y}{x}, \cos y\right) \cdot x \]
          9. lower-/.f64N/A

            \[\leadsto \mathsf{fma}\left(-z, \color{blue}{\frac{\sin y}{x}}, \cos y\right) \cdot x \]
          10. lower-sin.f64N/A

            \[\leadsto \mathsf{fma}\left(-z, \frac{\color{blue}{\sin y}}{x}, \cos y\right) \cdot x \]
          11. lower-cos.f6487.2

            \[\leadsto \mathsf{fma}\left(-z, \frac{\sin y}{x}, \color{blue}{\cos y}\right) \cdot x \]
        7. Applied rewrites87.2%

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

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

            \[\leadsto \mathsf{fma}\left(-z, \frac{1}{\frac{x}{\sin y}}, 1\right) \cdot x \]
          3. Step-by-step derivation
            1. Applied rewrites78.8%

              \[\leadsto \mathsf{fma}\left(-z, \frac{1}{\frac{x}{\sin y}}, 1\right) \cdot x \]

            if -1.55e-16 < z < 1.62000000000000006e34

            1. Initial program 99.8%

              \[x \cdot \cos y - z \cdot \sin y \]
            2. Add Preprocessing
            3. Taylor expanded in z around 0

              \[\leadsto \color{blue}{x \cdot \cos y} \]
            4. Step-by-step derivation
              1. *-commutativeN/A

                \[\leadsto \color{blue}{\cos y \cdot x} \]
              2. lower-*.f64N/A

                \[\leadsto \color{blue}{\cos y \cdot x} \]
              3. lower-cos.f6486.0

                \[\leadsto \color{blue}{\cos y} \cdot x \]
            5. Applied rewrites86.0%

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

          Alternative 4: 75.4% accurate, 1.5× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos y \cdot x\\ t_1 := \left(-z\right) \cdot \sin y\\ \mathbf{if}\;y \leq -1.7 \cdot 10^{+194}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq -0.0225:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;y \leq 0.0055:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, z \cdot y, -0.5 \cdot x\right) \cdot y - z, y, x\right)\\ \mathbf{elif}\;y \leq 6.3 \cdot 10^{+121}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq 6.6 \cdot 10^{+253}:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
          (FPCore (x y z)
           :precision binary64
           (let* ((t_0 (* (cos y) x)) (t_1 (* (- z) (sin y))))
             (if (<= y -1.7e+194)
               t_0
               (if (<= y -0.0225)
                 t_1
                 (if (<= y 0.0055)
                   (fma (- (* (fma 0.16666666666666666 (* z y) (* -0.5 x)) y) z) y x)
                   (if (<= y 6.3e+121) t_0 (if (<= y 6.6e+253) t_1 t_0)))))))
          double code(double x, double y, double z) {
          	double t_0 = cos(y) * x;
          	double t_1 = -z * sin(y);
          	double tmp;
          	if (y <= -1.7e+194) {
          		tmp = t_0;
          	} else if (y <= -0.0225) {
          		tmp = t_1;
          	} else if (y <= 0.0055) {
          		tmp = fma(((fma(0.16666666666666666, (z * y), (-0.5 * x)) * y) - z), y, x);
          	} else if (y <= 6.3e+121) {
          		tmp = t_0;
          	} else if (y <= 6.6e+253) {
          		tmp = t_1;
          	} else {
          		tmp = t_0;
          	}
          	return tmp;
          }
          
          function code(x, y, z)
          	t_0 = Float64(cos(y) * x)
          	t_1 = Float64(Float64(-z) * sin(y))
          	tmp = 0.0
          	if (y <= -1.7e+194)
          		tmp = t_0;
          	elseif (y <= -0.0225)
          		tmp = t_1;
          	elseif (y <= 0.0055)
          		tmp = fma(Float64(Float64(fma(0.16666666666666666, Float64(z * y), Float64(-0.5 * x)) * y) - z), y, x);
          	elseif (y <= 6.3e+121)
          		tmp = t_0;
          	elseif (y <= 6.6e+253)
          		tmp = t_1;
          	else
          		tmp = t_0;
          	end
          	return tmp
          end
          
          code[x_, y_, z_] := Block[{t$95$0 = N[(N[Cos[y], $MachinePrecision] * x), $MachinePrecision]}, Block[{t$95$1 = N[((-z) * N[Sin[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.7e+194], t$95$0, If[LessEqual[y, -0.0225], t$95$1, If[LessEqual[y, 0.0055], N[(N[(N[(N[(0.16666666666666666 * N[(z * y), $MachinePrecision] + N[(-0.5 * x), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision] - z), $MachinePrecision] * y + x), $MachinePrecision], If[LessEqual[y, 6.3e+121], t$95$0, If[LessEqual[y, 6.6e+253], t$95$1, t$95$0]]]]]]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          t_0 := \cos y \cdot x\\
          t_1 := \left(-z\right) \cdot \sin y\\
          \mathbf{if}\;y \leq -1.7 \cdot 10^{+194}:\\
          \;\;\;\;t\_0\\
          
          \mathbf{elif}\;y \leq -0.0225:\\
          \;\;\;\;t\_1\\
          
          \mathbf{elif}\;y \leq 0.0055:\\
          \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, z \cdot y, -0.5 \cdot x\right) \cdot y - z, y, x\right)\\
          
          \mathbf{elif}\;y \leq 6.3 \cdot 10^{+121}:\\
          \;\;\;\;t\_0\\
          
          \mathbf{elif}\;y \leq 6.6 \cdot 10^{+253}:\\
          \;\;\;\;t\_1\\
          
          \mathbf{else}:\\
          \;\;\;\;t\_0\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 3 regimes
          2. if y < -1.7000000000000001e194 or 0.0054999999999999997 < y < 6.29999999999999956e121 or 6.5999999999999998e253 < y

            1. Initial program 99.5%

              \[x \cdot \cos y - z \cdot \sin y \]
            2. Add Preprocessing
            3. Taylor expanded in z around 0

              \[\leadsto \color{blue}{x \cdot \cos y} \]
            4. Step-by-step derivation
              1. *-commutativeN/A

                \[\leadsto \color{blue}{\cos y \cdot x} \]
              2. lower-*.f64N/A

                \[\leadsto \color{blue}{\cos y \cdot x} \]
              3. lower-cos.f6476.2

                \[\leadsto \color{blue}{\cos y} \cdot x \]
            5. Applied rewrites76.2%

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

            if -1.7000000000000001e194 < y < -0.022499999999999999 or 6.29999999999999956e121 < y < 6.5999999999999998e253

            1. Initial program 99.6%

              \[x \cdot \cos y - z \cdot \sin y \]
            2. Add Preprocessing
            3. Taylor expanded in z around inf

              \[\leadsto \color{blue}{-1 \cdot \left(z \cdot \sin y\right)} \]
            4. Step-by-step derivation
              1. mul-1-negN/A

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

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

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

                \[\leadsto \color{blue}{\left(-z\right)} \cdot \sin y \]
              5. lower-sin.f6467.0

                \[\leadsto \left(-z\right) \cdot \color{blue}{\sin y} \]
            5. Applied rewrites67.0%

              \[\leadsto \color{blue}{\left(-z\right) \cdot \sin y} \]

            if -0.022499999999999999 < y < 0.0054999999999999997

            1. Initial program 100.0%

              \[x \cdot \cos y - z \cdot \sin y \]
            2. Add Preprocessing
            3. Taylor expanded in y around 0

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

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

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

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

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

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

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

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

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

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

                \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{6}, \color{blue}{z \cdot y}, \frac{-1}{2} \cdot x\right) \cdot y - z, y, x\right) \]
              11. lower-*.f64100.0

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

              \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, z \cdot y, -0.5 \cdot x\right) \cdot y - z, y, x\right)} \]
          3. Recombined 3 regimes into one program.
          4. Add Preprocessing

          Alternative 5: 74.1% accurate, 1.8× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos y \cdot x\\ \mathbf{if}\;y \leq -9.5 \cdot 10^{+17}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq 0.0055:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, z \cdot y, -0.5 \cdot x\right) \cdot y - z, y, x\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
          (FPCore (x y z)
           :precision binary64
           (let* ((t_0 (* (cos y) x)))
             (if (<= y -9.5e+17)
               t_0
               (if (<= y 0.0055)
                 (fma (- (* (fma 0.16666666666666666 (* z y) (* -0.5 x)) y) z) y x)
                 t_0))))
          double code(double x, double y, double z) {
          	double t_0 = cos(y) * x;
          	double tmp;
          	if (y <= -9.5e+17) {
          		tmp = t_0;
          	} else if (y <= 0.0055) {
          		tmp = fma(((fma(0.16666666666666666, (z * y), (-0.5 * x)) * y) - z), y, x);
          	} else {
          		tmp = t_0;
          	}
          	return tmp;
          }
          
          function code(x, y, z)
          	t_0 = Float64(cos(y) * x)
          	tmp = 0.0
          	if (y <= -9.5e+17)
          		tmp = t_0;
          	elseif (y <= 0.0055)
          		tmp = fma(Float64(Float64(fma(0.16666666666666666, Float64(z * y), Float64(-0.5 * x)) * y) - z), y, x);
          	else
          		tmp = t_0;
          	end
          	return tmp
          end
          
          code[x_, y_, z_] := Block[{t$95$0 = N[(N[Cos[y], $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[y, -9.5e+17], t$95$0, If[LessEqual[y, 0.0055], N[(N[(N[(N[(0.16666666666666666 * N[(z * y), $MachinePrecision] + N[(-0.5 * x), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision] - z), $MachinePrecision] * y + x), $MachinePrecision], t$95$0]]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          t_0 := \cos y \cdot x\\
          \mathbf{if}\;y \leq -9.5 \cdot 10^{+17}:\\
          \;\;\;\;t\_0\\
          
          \mathbf{elif}\;y \leq 0.0055:\\
          \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, z \cdot y, -0.5 \cdot x\right) \cdot y - z, y, x\right)\\
          
          \mathbf{else}:\\
          \;\;\;\;t\_0\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if y < -9.5e17 or 0.0054999999999999997 < y

            1. Initial program 99.6%

              \[x \cdot \cos y - z \cdot \sin y \]
            2. Add Preprocessing
            3. Taylor expanded in z around 0

              \[\leadsto \color{blue}{x \cdot \cos y} \]
            4. Step-by-step derivation
              1. *-commutativeN/A

                \[\leadsto \color{blue}{\cos y \cdot x} \]
              2. lower-*.f64N/A

                \[\leadsto \color{blue}{\cos y \cdot x} \]
              3. lower-cos.f6454.0

                \[\leadsto \color{blue}{\cos y} \cdot x \]
            5. Applied rewrites54.0%

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

            if -9.5e17 < y < 0.0054999999999999997

            1. Initial program 100.0%

              \[x \cdot \cos y - z \cdot \sin y \]
            2. Add Preprocessing
            3. Taylor expanded in y around 0

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, z \cdot y, -0.5 \cdot x\right) \cdot y - z, y, x\right)} \]
          3. Recombined 2 regimes into one program.
          4. Add Preprocessing

          Alternative 6: 41.6% accurate, 10.7× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -5 \cdot 10^{-133}:\\ \;\;\;\;1 \cdot x\\ \mathbf{elif}\;x \leq 2.5 \cdot 10^{-279}:\\ \;\;\;\;\left(-z\right) \cdot y\\ \mathbf{else}:\\ \;\;\;\;1 \cdot x\\ \end{array} \end{array} \]
          (FPCore (x y z)
           :precision binary64
           (if (<= x -5e-133) (* 1.0 x) (if (<= x 2.5e-279) (* (- z) y) (* 1.0 x))))
          double code(double x, double y, double z) {
          	double tmp;
          	if (x <= -5e-133) {
          		tmp = 1.0 * x;
          	} else if (x <= 2.5e-279) {
          		tmp = -z * y;
          	} else {
          		tmp = 1.0 * x;
          	}
          	return tmp;
          }
          
          real(8) function code(x, y, z)
              real(8), intent (in) :: x
              real(8), intent (in) :: y
              real(8), intent (in) :: z
              real(8) :: tmp
              if (x <= (-5d-133)) then
                  tmp = 1.0d0 * x
              else if (x <= 2.5d-279) then
                  tmp = -z * y
              else
                  tmp = 1.0d0 * x
              end if
              code = tmp
          end function
          
          public static double code(double x, double y, double z) {
          	double tmp;
          	if (x <= -5e-133) {
          		tmp = 1.0 * x;
          	} else if (x <= 2.5e-279) {
          		tmp = -z * y;
          	} else {
          		tmp = 1.0 * x;
          	}
          	return tmp;
          }
          
          def code(x, y, z):
          	tmp = 0
          	if x <= -5e-133:
          		tmp = 1.0 * x
          	elif x <= 2.5e-279:
          		tmp = -z * y
          	else:
          		tmp = 1.0 * x
          	return tmp
          
          function code(x, y, z)
          	tmp = 0.0
          	if (x <= -5e-133)
          		tmp = Float64(1.0 * x);
          	elseif (x <= 2.5e-279)
          		tmp = Float64(Float64(-z) * y);
          	else
          		tmp = Float64(1.0 * x);
          	end
          	return tmp
          end
          
          function tmp_2 = code(x, y, z)
          	tmp = 0.0;
          	if (x <= -5e-133)
          		tmp = 1.0 * x;
          	elseif (x <= 2.5e-279)
          		tmp = -z * y;
          	else
          		tmp = 1.0 * x;
          	end
          	tmp_2 = tmp;
          end
          
          code[x_, y_, z_] := If[LessEqual[x, -5e-133], N[(1.0 * x), $MachinePrecision], If[LessEqual[x, 2.5e-279], N[((-z) * y), $MachinePrecision], N[(1.0 * x), $MachinePrecision]]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          \mathbf{if}\;x \leq -5 \cdot 10^{-133}:\\
          \;\;\;\;1 \cdot x\\
          
          \mathbf{elif}\;x \leq 2.5 \cdot 10^{-279}:\\
          \;\;\;\;\left(-z\right) \cdot y\\
          
          \mathbf{else}:\\
          \;\;\;\;1 \cdot x\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if x < -4.9999999999999999e-133 or 2.49999999999999984e-279 < x

            1. Initial program 99.8%

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

                \[\leadsto \color{blue}{x \cdot \cos y - z \cdot \sin y} \]
              2. sub-negN/A

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

                \[\leadsto \color{blue}{\left(\mathsf{neg}\left(z \cdot \sin y\right)\right) + x \cdot \cos y} \]
              4. flip-+N/A

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

                \[\leadsto \frac{\color{blue}{\left(z \cdot \sin y\right) \cdot \left(z \cdot \sin y\right)} - \left(x \cdot \cos y\right) \cdot \left(x \cdot \cos y\right)}{\left(\mathsf{neg}\left(z \cdot \sin y\right)\right) - x \cdot \cos y} \]
              6. clear-numN/A

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

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

                \[\leadsto \frac{1}{\color{blue}{\frac{\left(\mathsf{neg}\left(z \cdot \sin y\right)\right) - x \cdot \cos y}{\left(z \cdot \sin y\right) \cdot \left(z \cdot \sin y\right) - \left(x \cdot \cos y\right) \cdot \left(x \cdot \cos y\right)}}} \]
            4. Applied rewrites51.3%

              \[\leadsto \color{blue}{\frac{1}{\frac{\left(-z\right) \cdot \sin y - \cos y \cdot x}{{\left(\sin y \cdot z\right)}^{2} - {\left(\cos y \cdot x\right)}^{2}}}} \]
            5. Taylor expanded in x around inf

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

                \[\leadsto \color{blue}{\left(\cos y + -1 \cdot \frac{z \cdot \sin y}{x}\right) \cdot x} \]
              2. lower-*.f64N/A

                \[\leadsto \color{blue}{\left(\cos y + -1 \cdot \frac{z \cdot \sin y}{x}\right) \cdot x} \]
              3. +-commutativeN/A

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

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

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

                \[\leadsto \color{blue}{\mathsf{fma}\left(-1 \cdot z, \frac{\sin y}{x}, \cos y\right)} \cdot x \]
              7. mul-1-negN/A

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

                \[\leadsto \mathsf{fma}\left(\color{blue}{-z}, \frac{\sin y}{x}, \cos y\right) \cdot x \]
              9. lower-/.f64N/A

                \[\leadsto \mathsf{fma}\left(-z, \color{blue}{\frac{\sin y}{x}}, \cos y\right) \cdot x \]
              10. lower-sin.f64N/A

                \[\leadsto \mathsf{fma}\left(-z, \frac{\color{blue}{\sin y}}{x}, \cos y\right) \cdot x \]
              11. lower-cos.f6494.9

                \[\leadsto \mathsf{fma}\left(-z, \frac{\sin y}{x}, \color{blue}{\cos y}\right) \cdot x \]
            7. Applied rewrites94.9%

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

              \[\leadsto 1 \cdot x \]
            9. Step-by-step derivation
              1. Applied rewrites48.1%

                \[\leadsto 1 \cdot x \]

              if -4.9999999999999999e-133 < x < 2.49999999999999984e-279

              1. Initial program 99.9%

                \[x \cdot \cos y - z \cdot \sin y \]
              2. Add Preprocessing
              3. Taylor expanded in y around 0

                \[\leadsto \color{blue}{x + -1 \cdot \left(y \cdot z\right)} \]
              4. Step-by-step derivation
                1. mul-1-negN/A

                  \[\leadsto x + \color{blue}{\left(\mathsf{neg}\left(y \cdot z\right)\right)} \]
                2. unsub-negN/A

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

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

                  \[\leadsto x - \color{blue}{z \cdot y} \]
                5. lower-*.f6452.2

                  \[\leadsto x - \color{blue}{z \cdot y} \]
              5. Applied rewrites52.2%

                \[\leadsto \color{blue}{x - z \cdot y} \]
              6. Taylor expanded in z around inf

                \[\leadsto -1 \cdot \color{blue}{\left(y \cdot z\right)} \]
              7. Step-by-step derivation
                1. Applied rewrites41.7%

                  \[\leadsto \left(-z\right) \cdot \color{blue}{y} \]
              8. Recombined 2 regimes into one program.
              9. Add Preprocessing

              Alternative 7: 52.3% accurate, 23.8× speedup?

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

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

                  \[\leadsto \color{blue}{x \cdot \cos y - z \cdot \sin y} \]
                2. sub-negN/A

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

                  \[\leadsto \color{blue}{\left(\mathsf{neg}\left(z \cdot \sin y\right)\right) + x \cdot \cos y} \]
                4. flip-+N/A

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

                  \[\leadsto \frac{\color{blue}{\left(z \cdot \sin y\right) \cdot \left(z \cdot \sin y\right)} - \left(x \cdot \cos y\right) \cdot \left(x \cdot \cos y\right)}{\left(\mathsf{neg}\left(z \cdot \sin y\right)\right) - x \cdot \cos y} \]
                6. clear-numN/A

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

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

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

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

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

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

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

                  \[\leadsto \color{blue}{\left(-1 \cdot z\right) \cdot y} + x \]
                4. lower-fma.f64N/A

                  \[\leadsto \color{blue}{\mathsf{fma}\left(-1 \cdot z, y, x\right)} \]
                5. mul-1-negN/A

                  \[\leadsto \mathsf{fma}\left(\color{blue}{\mathsf{neg}\left(z\right)}, y, x\right) \]
                6. lower-neg.f6456.3

                  \[\leadsto \mathsf{fma}\left(\color{blue}{-z}, y, x\right) \]
              7. Applied rewrites56.3%

                \[\leadsto \color{blue}{\mathsf{fma}\left(-z, y, x\right)} \]
              8. Add Preprocessing

              Alternative 8: 52.3% accurate, 23.8× speedup?

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

                \[x \cdot \cos y - z \cdot \sin y \]
              2. Add Preprocessing
              3. Taylor expanded in y around 0

                \[\leadsto \color{blue}{x + -1 \cdot \left(y \cdot z\right)} \]
              4. Step-by-step derivation
                1. mul-1-negN/A

                  \[\leadsto x + \color{blue}{\left(\mathsf{neg}\left(y \cdot z\right)\right)} \]
                2. unsub-negN/A

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

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

                  \[\leadsto x - \color{blue}{z \cdot y} \]
                5. lower-*.f6456.3

                  \[\leadsto x - \color{blue}{z \cdot y} \]
              5. Applied rewrites56.3%

                \[\leadsto \color{blue}{x - z \cdot y} \]
              6. Add Preprocessing

              Alternative 9: 39.4% accurate, 35.7× speedup?

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

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

                  \[\leadsto \color{blue}{x \cdot \cos y - z \cdot \sin y} \]
                2. sub-negN/A

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

                  \[\leadsto \color{blue}{\left(\mathsf{neg}\left(z \cdot \sin y\right)\right) + x \cdot \cos y} \]
                4. flip-+N/A

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

                  \[\leadsto \frac{\color{blue}{\left(z \cdot \sin y\right) \cdot \left(z \cdot \sin y\right)} - \left(x \cdot \cos y\right) \cdot \left(x \cdot \cos y\right)}{\left(\mathsf{neg}\left(z \cdot \sin y\right)\right) - x \cdot \cos y} \]
                6. clear-numN/A

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

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

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

                \[\leadsto \color{blue}{\frac{1}{\frac{\left(-z\right) \cdot \sin y - \cos y \cdot x}{{\left(\sin y \cdot z\right)}^{2} - {\left(\cos y \cdot x\right)}^{2}}}} \]
              5. Taylor expanded in x around inf

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

                  \[\leadsto \color{blue}{\left(\cos y + -1 \cdot \frac{z \cdot \sin y}{x}\right) \cdot x} \]
                2. lower-*.f64N/A

                  \[\leadsto \color{blue}{\left(\cos y + -1 \cdot \frac{z \cdot \sin y}{x}\right) \cdot x} \]
                3. +-commutativeN/A

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

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

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

                  \[\leadsto \color{blue}{\mathsf{fma}\left(-1 \cdot z, \frac{\sin y}{x}, \cos y\right)} \cdot x \]
                7. mul-1-negN/A

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

                  \[\leadsto \mathsf{fma}\left(\color{blue}{-z}, \frac{\sin y}{x}, \cos y\right) \cdot x \]
                9. lower-/.f64N/A

                  \[\leadsto \mathsf{fma}\left(-z, \color{blue}{\frac{\sin y}{x}}, \cos y\right) \cdot x \]
                10. lower-sin.f64N/A

                  \[\leadsto \mathsf{fma}\left(-z, \frac{\color{blue}{\sin y}}{x}, \cos y\right) \cdot x \]
                11. lower-cos.f6493.5

                  \[\leadsto \mathsf{fma}\left(-z, \frac{\sin y}{x}, \color{blue}{\cos y}\right) \cdot x \]
              7. Applied rewrites93.5%

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

                \[\leadsto 1 \cdot x \]
              9. Step-by-step derivation
                1. Applied rewrites42.1%

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

                Reproduce

                ?
                herbie shell --seed 2024257 
                (FPCore (x y z)
                  :name "Diagrams.ThreeD.Transform:aboutX from diagrams-lib-1.3.0.3, A"
                  :precision binary64
                  (- (* x (cos y)) (* z (sin y))))