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

Percentage Accurate: 99.8% → 99.8%
Time: 8.3s
Alternatives: 10
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 10 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} \\ \mathsf{fma}\left(\sin y, -z, \cos y \cdot x\right) \end{array} \]
(FPCore (x y z) :precision binary64 (fma (sin y) (- z) (* (cos y) x)))
double code(double x, double y, double z) {
	return fma(sin(y), -z, (cos(y) * x));
}
function code(x, y, z)
	return fma(sin(y), Float64(-z), Float64(cos(y) * x))
end
code[x_, y_, z_] := N[(N[Sin[y], $MachinePrecision] * (-z) + N[(N[Cos[y], $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(\sin y, -z, \color{blue}{\cos y \cdot x}\right) \]
  4. Applied rewrites99.8%

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

Alternative 2: 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}
Derivation
  1. Initial program 99.8%

    \[x \cdot \cos y - z \cdot \sin y \]
  2. Add Preprocessing
  3. Add Preprocessing

Alternative 3: 85.2% accurate, 1.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -2.3 \cdot 10^{-56} \lor \neg \left(x \leq 4.5 \cdot 10^{+48}\right):\\ \;\;\;\;\cos y \cdot x\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\sin y, -z, 1 \cdot x\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= x -2.3e-56) (not (<= x 4.5e+48)))
   (* (cos y) x)
   (fma (sin y) (- z) (* 1.0 x))))
double code(double x, double y, double z) {
	double tmp;
	if ((x <= -2.3e-56) || !(x <= 4.5e+48)) {
		tmp = cos(y) * x;
	} else {
		tmp = fma(sin(y), -z, (1.0 * x));
	}
	return tmp;
}
function code(x, y, z)
	tmp = 0.0
	if ((x <= -2.3e-56) || !(x <= 4.5e+48))
		tmp = Float64(cos(y) * x);
	else
		tmp = fma(sin(y), Float64(-z), Float64(1.0 * x));
	end
	return tmp
end
code[x_, y_, z_] := If[Or[LessEqual[x, -2.3e-56], N[Not[LessEqual[x, 4.5e+48]], $MachinePrecision]], N[(N[Cos[y], $MachinePrecision] * x), $MachinePrecision], N[(N[Sin[y], $MachinePrecision] * (-z) + N[(1.0 * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.3 \cdot 10^{-56} \lor \neg \left(x \leq 4.5 \cdot 10^{+48}\right):\\
\;\;\;\;\cos y \cdot x\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -2.30000000000000002e-56 or 4.49999999999999995e48 < x

    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-*.f6449.8

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

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

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

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

        \[\leadsto \color{blue}{x \cdot \left(\cos y + -1 \cdot \frac{z \cdot \sin y}{x}\right)} \]
      3. 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. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \cos y \cdot x \]
      6. Step-by-step derivation
        1. Applied rewrites87.5%

          \[\leadsto \cos y \cdot x \]

        if -2.30000000000000002e-56 < x < 4.49999999999999995e48

        1. Initial program 99.8%

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

          \[\leadsto x \cdot \color{blue}{1} - z \cdot \sin y \]
        4. Step-by-step derivation
          1. Applied rewrites91.3%

            \[\leadsto x \cdot \color{blue}{1} - z \cdot \sin y \]
          2. Step-by-step derivation
            1. lift--.f64N/A

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

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

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

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

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

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

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

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

              \[\leadsto \sin y \cdot \color{blue}{\left(-z\right)} + x \cdot 1 \]
            10. lower-fma.f6491.4

              \[\leadsto \color{blue}{\mathsf{fma}\left(\sin y, -z, x \cdot 1\right)} \]
            11. lift-*.f64N/A

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

              \[\leadsto \mathsf{fma}\left(\sin y, -z, \color{blue}{1 \cdot x}\right) \]
            13. lower-*.f6491.4

              \[\leadsto \mathsf{fma}\left(\sin y, -z, \color{blue}{1 \cdot x}\right) \]
          3. Applied rewrites91.4%

            \[\leadsto \color{blue}{\mathsf{fma}\left(\sin y, -z, 1 \cdot x\right)} \]
        5. Recombined 2 regimes into one program.
        6. Final simplification89.5%

          \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.3 \cdot 10^{-56} \lor \neg \left(x \leq 4.5 \cdot 10^{+48}\right):\\ \;\;\;\;\cos y \cdot x\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\sin y, -z, 1 \cdot x\right)\\ \end{array} \]
        7. Add Preprocessing

        Alternative 4: 85.2% accurate, 1.7× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -2.3 \cdot 10^{-56} \lor \neg \left(x \leq 4.5 \cdot 10^{+48}\right):\\ \;\;\;\;\cos y \cdot x\\ \mathbf{else}:\\ \;\;\;\;x \cdot 1 - z \cdot \sin y\\ \end{array} \end{array} \]
        (FPCore (x y z)
         :precision binary64
         (if (or (<= x -2.3e-56) (not (<= x 4.5e+48)))
           (* (cos y) x)
           (- (* x 1.0) (* z (sin y)))))
        double code(double x, double y, double z) {
        	double tmp;
        	if ((x <= -2.3e-56) || !(x <= 4.5e+48)) {
        		tmp = cos(y) * x;
        	} else {
        		tmp = (x * 1.0) - (z * sin(y));
        	}
        	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 <= (-2.3d-56)) .or. (.not. (x <= 4.5d+48))) then
                tmp = cos(y) * x
            else
                tmp = (x * 1.0d0) - (z * sin(y))
            end if
            code = tmp
        end function
        
        public static double code(double x, double y, double z) {
        	double tmp;
        	if ((x <= -2.3e-56) || !(x <= 4.5e+48)) {
        		tmp = Math.cos(y) * x;
        	} else {
        		tmp = (x * 1.0) - (z * Math.sin(y));
        	}
        	return tmp;
        }
        
        def code(x, y, z):
        	tmp = 0
        	if (x <= -2.3e-56) or not (x <= 4.5e+48):
        		tmp = math.cos(y) * x
        	else:
        		tmp = (x * 1.0) - (z * math.sin(y))
        	return tmp
        
        function code(x, y, z)
        	tmp = 0.0
        	if ((x <= -2.3e-56) || !(x <= 4.5e+48))
        		tmp = Float64(cos(y) * x);
        	else
        		tmp = Float64(Float64(x * 1.0) - Float64(z * sin(y)));
        	end
        	return tmp
        end
        
        function tmp_2 = code(x, y, z)
        	tmp = 0.0;
        	if ((x <= -2.3e-56) || ~((x <= 4.5e+48)))
        		tmp = cos(y) * x;
        	else
        		tmp = (x * 1.0) - (z * sin(y));
        	end
        	tmp_2 = tmp;
        end
        
        code[x_, y_, z_] := If[Or[LessEqual[x, -2.3e-56], N[Not[LessEqual[x, 4.5e+48]], $MachinePrecision]], N[(N[Cos[y], $MachinePrecision] * x), $MachinePrecision], N[(N[(x * 1.0), $MachinePrecision] - N[(z * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;x \leq -2.3 \cdot 10^{-56} \lor \neg \left(x \leq 4.5 \cdot 10^{+48}\right):\\
        \;\;\;\;\cos y \cdot x\\
        
        \mathbf{else}:\\
        \;\;\;\;x \cdot 1 - z \cdot \sin y\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if x < -2.30000000000000002e-56 or 4.49999999999999995e48 < x

          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-*.f6449.8

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

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

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

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

              \[\leadsto \color{blue}{x \cdot \left(\cos y + -1 \cdot \frac{z \cdot \sin y}{x}\right)} \]
            3. 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. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \cos y \cdot x \]
            6. Step-by-step derivation
              1. Applied rewrites87.5%

                \[\leadsto \cos y \cdot x \]

              if -2.30000000000000002e-56 < x < 4.49999999999999995e48

              1. Initial program 99.8%

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

                \[\leadsto x \cdot \color{blue}{1} - z \cdot \sin y \]
              4. Step-by-step derivation
                1. Applied rewrites91.3%

                  \[\leadsto x \cdot \color{blue}{1} - z \cdot \sin y \]
              5. Recombined 2 regimes into one program.
              6. Final simplification89.5%

                \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.3 \cdot 10^{-56} \lor \neg \left(x \leq 4.5 \cdot 10^{+48}\right):\\ \;\;\;\;\cos y \cdot x\\ \mathbf{else}:\\ \;\;\;\;x \cdot 1 - z \cdot \sin y\\ \end{array} \]
              7. Add Preprocessing

              Alternative 5: 73.1% accurate, 1.8× speedup?

              \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1.55 \cdot 10^{-59} \lor \neg \left(x \leq 1.05 \cdot 10^{-182}\right):\\ \;\;\;\;\cos y \cdot x\\ \mathbf{else}:\\ \;\;\;\;\left(-z\right) \cdot \sin y\\ \end{array} \end{array} \]
              (FPCore (x y z)
               :precision binary64
               (if (or (<= x -1.55e-59) (not (<= x 1.05e-182)))
                 (* (cos y) x)
                 (* (- z) (sin y))))
              double code(double x, double y, double z) {
              	double tmp;
              	if ((x <= -1.55e-59) || !(x <= 1.05e-182)) {
              		tmp = cos(y) * x;
              	} else {
              		tmp = -z * sin(y);
              	}
              	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 <= (-1.55d-59)) .or. (.not. (x <= 1.05d-182))) then
                      tmp = cos(y) * x
                  else
                      tmp = -z * sin(y)
                  end if
                  code = tmp
              end function
              
              public static double code(double x, double y, double z) {
              	double tmp;
              	if ((x <= -1.55e-59) || !(x <= 1.05e-182)) {
              		tmp = Math.cos(y) * x;
              	} else {
              		tmp = -z * Math.sin(y);
              	}
              	return tmp;
              }
              
              def code(x, y, z):
              	tmp = 0
              	if (x <= -1.55e-59) or not (x <= 1.05e-182):
              		tmp = math.cos(y) * x
              	else:
              		tmp = -z * math.sin(y)
              	return tmp
              
              function code(x, y, z)
              	tmp = 0.0
              	if ((x <= -1.55e-59) || !(x <= 1.05e-182))
              		tmp = Float64(cos(y) * x);
              	else
              		tmp = Float64(Float64(-z) * sin(y));
              	end
              	return tmp
              end
              
              function tmp_2 = code(x, y, z)
              	tmp = 0.0;
              	if ((x <= -1.55e-59) || ~((x <= 1.05e-182)))
              		tmp = cos(y) * x;
              	else
              		tmp = -z * sin(y);
              	end
              	tmp_2 = tmp;
              end
              
              code[x_, y_, z_] := If[Or[LessEqual[x, -1.55e-59], N[Not[LessEqual[x, 1.05e-182]], $MachinePrecision]], N[(N[Cos[y], $MachinePrecision] * x), $MachinePrecision], N[((-z) * N[Sin[y], $MachinePrecision]), $MachinePrecision]]
              
              \begin{array}{l}
              
              \\
              \begin{array}{l}
              \mathbf{if}\;x \leq -1.55 \cdot 10^{-59} \lor \neg \left(x \leq 1.05 \cdot 10^{-182}\right):\\
              \;\;\;\;\cos y \cdot x\\
              
              \mathbf{else}:\\
              \;\;\;\;\left(-z\right) \cdot \sin y\\
              
              
              \end{array}
              \end{array}
              
              Derivation
              1. Split input into 2 regimes
              2. if x < -1.55e-59 or 1.05e-182 < x

                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-*.f6450.6

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

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

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

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

                    \[\leadsto \color{blue}{x \cdot \left(\cos y + -1 \cdot \frac{z \cdot \sin y}{x}\right)} \]
                  3. 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. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto \cos y \cdot x \]
                  6. Step-by-step derivation
                    1. Applied rewrites79.4%

                      \[\leadsto \cos y \cdot x \]

                    if -1.55e-59 < x < 1.05e-182

                    1. Initial program 99.7%

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

                      \[\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.f6475.5

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

                      \[\leadsto \color{blue}{\left(-z\right) \cdot \sin y} \]
                  7. Recombined 2 regimes into one program.
                  8. Final simplification78.0%

                    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.55 \cdot 10^{-59} \lor \neg \left(x \leq 1.05 \cdot 10^{-182}\right):\\ \;\;\;\;\cos y \cdot x\\ \mathbf{else}:\\ \;\;\;\;\left(-z\right) \cdot \sin y\\ \end{array} \]
                  9. Add Preprocessing

                  Alternative 6: 75.3% accurate, 1.8× speedup?

                  \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -0.055 \lor \neg \left(y \leq 6300\right):\\ \;\;\;\;\cos y \cdot x\\ \mathbf{else}:\\ \;\;\;\;x \cdot 1 - \mathsf{fma}\left(z \cdot \mathsf{fma}\left(0.008333333333333333, y \cdot y, -0.16666666666666666\right), y \cdot y, z\right) \cdot y\\ \end{array} \end{array} \]
                  (FPCore (x y z)
                   :precision binary64
                   (if (or (<= y -0.055) (not (<= y 6300.0)))
                     (* (cos y) x)
                     (-
                      (* x 1.0)
                      (*
                       (fma
                        (* z (fma 0.008333333333333333 (* y y) -0.16666666666666666))
                        (* y y)
                        z)
                       y))))
                  double code(double x, double y, double z) {
                  	double tmp;
                  	if ((y <= -0.055) || !(y <= 6300.0)) {
                  		tmp = cos(y) * x;
                  	} else {
                  		tmp = (x * 1.0) - (fma((z * fma(0.008333333333333333, (y * y), -0.16666666666666666)), (y * y), z) * y);
                  	}
                  	return tmp;
                  }
                  
                  function code(x, y, z)
                  	tmp = 0.0
                  	if ((y <= -0.055) || !(y <= 6300.0))
                  		tmp = Float64(cos(y) * x);
                  	else
                  		tmp = Float64(Float64(x * 1.0) - Float64(fma(Float64(z * fma(0.008333333333333333, Float64(y * y), -0.16666666666666666)), Float64(y * y), z) * y));
                  	end
                  	return tmp
                  end
                  
                  code[x_, y_, z_] := If[Or[LessEqual[y, -0.055], N[Not[LessEqual[y, 6300.0]], $MachinePrecision]], N[(N[Cos[y], $MachinePrecision] * x), $MachinePrecision], N[(N[(x * 1.0), $MachinePrecision] - N[(N[(N[(z * N[(0.008333333333333333 * N[(y * y), $MachinePrecision] + -0.16666666666666666), $MachinePrecision]), $MachinePrecision] * N[(y * y), $MachinePrecision] + z), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]]
                  
                  \begin{array}{l}
                  
                  \\
                  \begin{array}{l}
                  \mathbf{if}\;y \leq -0.055 \lor \neg \left(y \leq 6300\right):\\
                  \;\;\;\;\cos y \cdot x\\
                  
                  \mathbf{else}:\\
                  \;\;\;\;x \cdot 1 - \mathsf{fma}\left(z \cdot \mathsf{fma}\left(0.008333333333333333, y \cdot y, -0.16666666666666666\right), y \cdot y, z\right) \cdot y\\
                  
                  
                  \end{array}
                  \end{array}
                  
                  Derivation
                  1. Split input into 2 regimes
                  2. if y < -0.0550000000000000003 or 6300 < y

                    1. Initial program 99.6%

                      \[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-*.f647.2

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

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

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

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

                        \[\leadsto \color{blue}{x \cdot \left(\cos y + -1 \cdot \frac{z \cdot \sin y}{x}\right)} \]
                      3. 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. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

                        \[\leadsto \cos y \cdot x \]
                      6. Step-by-step derivation
                        1. Applied rewrites52.1%

                          \[\leadsto \cos y \cdot x \]

                        if -0.0550000000000000003 < y < 6300

                        1. Initial program 100.0%

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

                          \[\leadsto x \cdot \color{blue}{1} - z \cdot \sin y \]
                        4. Step-by-step derivation
                          1. Applied rewrites100.0%

                            \[\leadsto x \cdot \color{blue}{1} - z \cdot \sin y \]
                          2. Taylor expanded in y around 0

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

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

                              \[\leadsto x \cdot 1 - \color{blue}{\left(z + {y}^{2} \cdot \left(\frac{-1}{6} \cdot z + \frac{1}{120} \cdot \left({y}^{2} \cdot z\right)\right)\right) \cdot y} \]
                          4. Applied rewrites98.6%

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

                          \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -0.055 \lor \neg \left(y \leq 6300\right):\\ \;\;\;\;\cos y \cdot x\\ \mathbf{else}:\\ \;\;\;\;x \cdot 1 - \mathsf{fma}\left(z \cdot \mathsf{fma}\left(0.008333333333333333, y \cdot y, -0.16666666666666666\right), y \cdot y, z\right) \cdot y\\ \end{array} \]
                        7. Add Preprocessing

                        Alternative 7: 42.0% accurate, 10.7× speedup?

                        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -2.3 \cdot 10^{+201} \lor \neg \left(z \leq 1.95 \cdot 10^{+86}\right):\\ \;\;\;\;\left(-y\right) \cdot z\\ \mathbf{else}:\\ \;\;\;\;\left(-x\right) \cdot -1\\ \end{array} \end{array} \]
                        (FPCore (x y z)
                         :precision binary64
                         (if (or (<= z -2.3e+201) (not (<= z 1.95e+86))) (* (- y) z) (* (- x) -1.0)))
                        double code(double x, double y, double z) {
                        	double tmp;
                        	if ((z <= -2.3e+201) || !(z <= 1.95e+86)) {
                        		tmp = -y * z;
                        	} else {
                        		tmp = -x * -1.0;
                        	}
                        	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 ((z <= (-2.3d+201)) .or. (.not. (z <= 1.95d+86))) then
                                tmp = -y * z
                            else
                                tmp = -x * (-1.0d0)
                            end if
                            code = tmp
                        end function
                        
                        public static double code(double x, double y, double z) {
                        	double tmp;
                        	if ((z <= -2.3e+201) || !(z <= 1.95e+86)) {
                        		tmp = -y * z;
                        	} else {
                        		tmp = -x * -1.0;
                        	}
                        	return tmp;
                        }
                        
                        def code(x, y, z):
                        	tmp = 0
                        	if (z <= -2.3e+201) or not (z <= 1.95e+86):
                        		tmp = -y * z
                        	else:
                        		tmp = -x * -1.0
                        	return tmp
                        
                        function code(x, y, z)
                        	tmp = 0.0
                        	if ((z <= -2.3e+201) || !(z <= 1.95e+86))
                        		tmp = Float64(Float64(-y) * z);
                        	else
                        		tmp = Float64(Float64(-x) * -1.0);
                        	end
                        	return tmp
                        end
                        
                        function tmp_2 = code(x, y, z)
                        	tmp = 0.0;
                        	if ((z <= -2.3e+201) || ~((z <= 1.95e+86)))
                        		tmp = -y * z;
                        	else
                        		tmp = -x * -1.0;
                        	end
                        	tmp_2 = tmp;
                        end
                        
                        code[x_, y_, z_] := If[Or[LessEqual[z, -2.3e+201], N[Not[LessEqual[z, 1.95e+86]], $MachinePrecision]], N[((-y) * z), $MachinePrecision], N[((-x) * -1.0), $MachinePrecision]]
                        
                        \begin{array}{l}
                        
                        \\
                        \begin{array}{l}
                        \mathbf{if}\;z \leq -2.3 \cdot 10^{+201} \lor \neg \left(z \leq 1.95 \cdot 10^{+86}\right):\\
                        \;\;\;\;\left(-y\right) \cdot z\\
                        
                        \mathbf{else}:\\
                        \;\;\;\;\left(-x\right) \cdot -1\\
                        
                        
                        \end{array}
                        \end{array}
                        
                        Derivation
                        1. Split input into 2 regimes
                        2. if z < -2.3000000000000001e201 or 1.9500000000000001e86 < z

                          1. Initial program 99.7%

                            \[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.6

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

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

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

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

                            if -2.3000000000000001e201 < z < 1.9500000000000001e86

                            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. lift-*.f64N/A

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

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

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

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

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

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

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

                                \[\leadsto \mathsf{fma}\left(\sin y, -z, \color{blue}{\cos y \cdot x}\right) \]
                            4. Applied rewrites99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                              \[\leadsto \left(-x\right) \cdot -1 \]
                            9. Step-by-step derivation
                              1. Applied rewrites44.5%

                                \[\leadsto \left(-x\right) \cdot -1 \]
                            10. Recombined 2 regimes into one program.
                            11. Final simplification42.5%

                              \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -2.3 \cdot 10^{+201} \lor \neg \left(z \leq 1.95 \cdot 10^{+86}\right):\\ \;\;\;\;\left(-y\right) \cdot z\\ \mathbf{else}:\\ \;\;\;\;\left(-x\right) \cdot -1\\ \end{array} \]
                            12. Add Preprocessing

                            Alternative 8: 53.2% 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. 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-*.f6451.1

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

                              \[\leadsto \color{blue}{x - z \cdot y} \]
                            6. Step-by-step derivation
                              1. Applied rewrites51.1%

                                \[\leadsto \color{blue}{\mathsf{fma}\left(-z, y, x\right)} \]
                              2. Final simplification51.1%

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

                              Alternative 9: 53.2% 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-*.f6451.1

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

                                \[\leadsto \color{blue}{x - z \cdot y} \]
                              6. Final simplification51.1%

                                \[\leadsto x - z \cdot y \]
                              7. Add Preprocessing

                              Alternative 10: 38.7% accurate, 26.8× speedup?

                              \[\begin{array}{l} \\ \left(-x\right) \cdot -1 \end{array} \]
                              (FPCore (x y z) :precision binary64 (* (- x) -1.0))
                              double code(double x, double y, double z) {
                              	return -x * -1.0;
                              }
                              
                              real(8) function code(x, y, z)
                                  real(8), intent (in) :: x
                                  real(8), intent (in) :: y
                                  real(8), intent (in) :: z
                                  code = -x * (-1.0d0)
                              end function
                              
                              public static double code(double x, double y, double z) {
                              	return -x * -1.0;
                              }
                              
                              def code(x, y, z):
                              	return -x * -1.0
                              
                              function code(x, y, z)
                              	return Float64(Float64(-x) * -1.0)
                              end
                              
                              function tmp = code(x, y, z)
                              	tmp = -x * -1.0;
                              end
                              
                              code[x_, y_, z_] := N[((-x) * -1.0), $MachinePrecision]
                              
                              \begin{array}{l}
                              
                              \\
                              \left(-x\right) \cdot -1
                              \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. lift-*.f64N/A

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

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

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

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

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

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

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

                                  \[\leadsto \mathsf{fma}\left(\sin y, -z, \color{blue}{\cos y \cdot x}\right) \]
                              4. Applied rewrites99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                \[\leadsto \left(-x\right) \cdot -1 \]
                              9. Step-by-step derivation
                                1. Applied rewrites37.9%

                                  \[\leadsto \left(-x\right) \cdot -1 \]
                                2. Add Preprocessing

                                Reproduce

                                ?
                                herbie shell --seed 2024311 
                                (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))))