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

Percentage Accurate: 99.8% → 99.8%
Time: 7.8s
Alternatives: 8
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 8 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 99.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ x \cdot \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: 86.1% accurate, 1.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 1 \cdot x - \sin y \cdot z\\ \mathbf{if}\;z \leq -7.8 \cdot 10^{-143}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq 1.52 \cdot 10^{-99}:\\ \;\;\;\;\cos y \cdot x\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (- (* 1.0 x) (* (sin y) z))))
   (if (<= z -7.8e-143) t_0 (if (<= z 1.52e-99) (* (cos y) x) t_0))))
double code(double x, double y, double z) {
	double t_0 = (1.0 * x) - (sin(y) * z);
	double tmp;
	if (z <= -7.8e-143) {
		tmp = t_0;
	} else if (z <= 1.52e-99) {
		tmp = cos(y) * x;
	} else {
		tmp = t_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) :: t_0
    real(8) :: tmp
    t_0 = (1.0d0 * x) - (sin(y) * z)
    if (z <= (-7.8d-143)) then
        tmp = t_0
    else if (z <= 1.52d-99) then
        tmp = cos(y) * x
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = (1.0 * x) - (Math.sin(y) * z);
	double tmp;
	if (z <= -7.8e-143) {
		tmp = t_0;
	} else if (z <= 1.52e-99) {
		tmp = Math.cos(y) * x;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = (1.0 * x) - (math.sin(y) * z)
	tmp = 0
	if z <= -7.8e-143:
		tmp = t_0
	elif z <= 1.52e-99:
		tmp = math.cos(y) * x
	else:
		tmp = t_0
	return tmp
function code(x, y, z)
	t_0 = Float64(Float64(1.0 * x) - Float64(sin(y) * z))
	tmp = 0.0
	if (z <= -7.8e-143)
		tmp = t_0;
	elseif (z <= 1.52e-99)
		tmp = Float64(cos(y) * x);
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = (1.0 * x) - (sin(y) * z);
	tmp = 0.0;
	if (z <= -7.8e-143)
		tmp = t_0;
	elseif (z <= 1.52e-99)
		tmp = cos(y) * x;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(1.0 * x), $MachinePrecision] - N[(N[Sin[y], $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -7.8e-143], t$95$0, If[LessEqual[z, 1.52e-99], N[(N[Cos[y], $MachinePrecision] * x), $MachinePrecision], t$95$0]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 1 \cdot x - \sin y \cdot z\\
\mathbf{if}\;z \leq -7.8 \cdot 10^{-143}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;z \leq 1.52 \cdot 10^{-99}:\\
\;\;\;\;\cos y \cdot x\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -7.80000000000000007e-143 or 1.51999999999999999e-99 < z

    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 rewrites85.6%

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

      if -7.80000000000000007e-143 < z < 1.51999999999999999e-99

      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. flip--N/A

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

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

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

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

          \[\leadsto \frac{1}{\frac{1}{\color{blue}{x \cdot \cos y - z \cdot \sin y}}} \]
        7. lift--.f64N/A

          \[\leadsto \frac{1}{\frac{1}{\color{blue}{x \cdot \cos y - z \cdot \sin y}}} \]
        8. inv-powN/A

          \[\leadsto \frac{1}{\color{blue}{{\left(x \cdot \cos y - z \cdot \sin y\right)}^{-1}}} \]
        9. lower-pow.f6499.6

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

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

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

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

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

          \[\leadsto \color{blue}{\mathsf{fma}\left(\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.f6499.8

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

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

        \[\leadsto \cos y \cdot x \]
      9. Step-by-step derivation
        1. Applied rewrites94.8%

          \[\leadsto \cos y \cdot x \]
      10. Recombined 2 regimes into one program.
      11. Final simplification88.5%

        \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -7.8 \cdot 10^{-143}:\\ \;\;\;\;1 \cdot x - \sin y \cdot z\\ \mathbf{elif}\;z \leq 1.52 \cdot 10^{-99}:\\ \;\;\;\;\cos y \cdot x\\ \mathbf{else}:\\ \;\;\;\;1 \cdot x - \sin y \cdot z\\ \end{array} \]
      12. Add Preprocessing

      Alternative 3: 73.8% accurate, 1.7× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos y \cdot x\\ \mathbf{if}\;y \leq -1.65 \cdot 10^{+171}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq -0.84:\\ \;\;\;\;\left(-z\right) \cdot \sin y\\ \mathbf{elif}\;y \leq 8 \cdot 10^{-20}:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.001388888888888889, y \cdot y, 0.041666666666666664\right), y \cdot y, -0.5\right), y \cdot y, 1\right) \cdot x - \left(\mathsf{fma}\left(-0.16666666666666666, y \cdot y, 1\right) \cdot z\right) \cdot y\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
      (FPCore (x y z)
       :precision binary64
       (let* ((t_0 (* (cos y) x)))
         (if (<= y -1.65e+171)
           t_0
           (if (<= y -0.84)
             (* (- z) (sin y))
             (if (<= y 8e-20)
               (-
                (*
                 (fma
                  (fma
                   (fma -0.001388888888888889 (* y y) 0.041666666666666664)
                   (* y y)
                   -0.5)
                  (* y y)
                  1.0)
                 x)
                (* (* (fma -0.16666666666666666 (* y y) 1.0) z) y))
               t_0)))))
      double code(double x, double y, double z) {
      	double t_0 = cos(y) * x;
      	double tmp;
      	if (y <= -1.65e+171) {
      		tmp = t_0;
      	} else if (y <= -0.84) {
      		tmp = -z * sin(y);
      	} else if (y <= 8e-20) {
      		tmp = (fma(fma(fma(-0.001388888888888889, (y * y), 0.041666666666666664), (y * y), -0.5), (y * y), 1.0) * x) - ((fma(-0.16666666666666666, (y * y), 1.0) * z) * y);
      	} else {
      		tmp = t_0;
      	}
      	return tmp;
      }
      
      function code(x, y, z)
      	t_0 = Float64(cos(y) * x)
      	tmp = 0.0
      	if (y <= -1.65e+171)
      		tmp = t_0;
      	elseif (y <= -0.84)
      		tmp = Float64(Float64(-z) * sin(y));
      	elseif (y <= 8e-20)
      		tmp = Float64(Float64(fma(fma(fma(-0.001388888888888889, Float64(y * y), 0.041666666666666664), Float64(y * y), -0.5), Float64(y * y), 1.0) * x) - Float64(Float64(fma(-0.16666666666666666, Float64(y * y), 1.0) * z) * y));
      	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, -1.65e+171], t$95$0, If[LessEqual[y, -0.84], N[((-z) * N[Sin[y], $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 8e-20], N[(N[(N[(N[(N[(-0.001388888888888889 * N[(y * y), $MachinePrecision] + 0.041666666666666664), $MachinePrecision] * N[(y * y), $MachinePrecision] + -0.5), $MachinePrecision] * N[(y * y), $MachinePrecision] + 1.0), $MachinePrecision] * x), $MachinePrecision] - N[(N[(N[(-0.16666666666666666 * N[(y * y), $MachinePrecision] + 1.0), $MachinePrecision] * z), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      t_0 := \cos y \cdot x\\
      \mathbf{if}\;y \leq -1.65 \cdot 10^{+171}:\\
      \;\;\;\;t\_0\\
      
      \mathbf{elif}\;y \leq -0.84:\\
      \;\;\;\;\left(-z\right) \cdot \sin y\\
      
      \mathbf{elif}\;y \leq 8 \cdot 10^{-20}:\\
      \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.001388888888888889, y \cdot y, 0.041666666666666664\right), y \cdot y, -0.5\right), y \cdot y, 1\right) \cdot x - \left(\mathsf{fma}\left(-0.16666666666666666, y \cdot y, 1\right) \cdot z\right) \cdot y\\
      
      \mathbf{else}:\\
      \;\;\;\;t\_0\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 3 regimes
      2. if y < -1.64999999999999996e171 or 7.99999999999999956e-20 < y

        1. Initial program 99.7%

          \[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. flip--N/A

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

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

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

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

            \[\leadsto \frac{1}{\frac{1}{\color{blue}{x \cdot \cos y - z \cdot \sin y}}} \]
          7. lift--.f64N/A

            \[\leadsto \frac{1}{\frac{1}{\color{blue}{x \cdot \cos y - z \cdot \sin y}}} \]
          8. inv-powN/A

            \[\leadsto \frac{1}{\color{blue}{{\left(x \cdot \cos y - z \cdot \sin y\right)}^{-1}}} \]
          9. lower-pow.f6499.6

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

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

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

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

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

            \[\leadsto \color{blue}{\mathsf{fma}\left(\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.f6492.0

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

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

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

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

          if -1.64999999999999996e171 < y < -0.839999999999999969

          1. Initial program 99.6%

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

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

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

          if -0.839999999999999969 < y < 7.99999999999999956e-20

          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 rewrites98.5%

              \[\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 + \frac{-1}{6} \cdot \left({y}^{2} \cdot z\right)\right)} \]
            3. Step-by-step derivation
              1. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                \[\leadsto x \cdot \mathsf{fma}\left(\color{blue}{\left(\frac{1}{24} + \frac{-1}{720} \cdot {y}^{2}\right) \cdot {y}^{2}} + \left(\mathsf{neg}\left(\frac{1}{2}\right)\right), {y}^{2}, 1\right) - \left(\mathsf{fma}\left(\frac{-1}{6}, y \cdot y, 1\right) \cdot z\right) \cdot y \]
              6. metadata-evalN/A

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

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

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

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

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

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

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

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

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

                \[\leadsto x \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.001388888888888889, y \cdot y, 0.041666666666666664\right), y \cdot y, -0.5\right), \color{blue}{y \cdot y}, 1\right) - \left(\mathsf{fma}\left(-0.16666666666666666, y \cdot y, 1\right) \cdot z\right) \cdot y \]
            7. Applied rewrites99.2%

              \[\leadsto x \cdot \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.001388888888888889, y \cdot y, 0.041666666666666664\right), y \cdot y, -0.5\right), y \cdot y, 1\right)} - \left(\mathsf{fma}\left(-0.16666666666666666, y \cdot y, 1\right) \cdot z\right) \cdot y \]
          5. Recombined 3 regimes into one program.
          6. Final simplification81.5%

            \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.65 \cdot 10^{+171}:\\ \;\;\;\;\cos y \cdot x\\ \mathbf{elif}\;y \leq -0.84:\\ \;\;\;\;\left(-z\right) \cdot \sin y\\ \mathbf{elif}\;y \leq 8 \cdot 10^{-20}:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.001388888888888889, y \cdot y, 0.041666666666666664\right), y \cdot y, -0.5\right), y \cdot y, 1\right) \cdot x - \left(\mathsf{fma}\left(-0.16666666666666666, y \cdot y, 1\right) \cdot z\right) \cdot y\\ \mathbf{else}:\\ \;\;\;\;\cos y \cdot x\\ \end{array} \]
          7. Add Preprocessing

          Alternative 4: 73.8% accurate, 1.8× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos y \cdot x\\ \mathbf{if}\;y \leq -2.75 \cdot 10^{-5}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq 8 \cdot 10^{-20}:\\ \;\;\;\;\mathsf{fma}\left(-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 -2.75e-5) t_0 (if (<= y 8e-20) (fma (- z) y x) t_0))))
          double code(double x, double y, double z) {
          	double t_0 = cos(y) * x;
          	double tmp;
          	if (y <= -2.75e-5) {
          		tmp = t_0;
          	} else if (y <= 8e-20) {
          		tmp = fma(-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 <= -2.75e-5)
          		tmp = t_0;
          	elseif (y <= 8e-20)
          		tmp = fma(Float64(-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, -2.75e-5], t$95$0, If[LessEqual[y, 8e-20], N[((-z) * y + x), $MachinePrecision], t$95$0]]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          t_0 := \cos y \cdot x\\
          \mathbf{if}\;y \leq -2.75 \cdot 10^{-5}:\\
          \;\;\;\;t\_0\\
          
          \mathbf{elif}\;y \leq 8 \cdot 10^{-20}:\\
          \;\;\;\;\mathsf{fma}\left(-z, y, x\right)\\
          
          \mathbf{else}:\\
          \;\;\;\;t\_0\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if y < -2.7500000000000001e-5 or 7.99999999999999956e-20 < y

            1. Initial program 99.7%

              \[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. flip--N/A

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

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

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

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

                \[\leadsto \frac{1}{\frac{1}{\color{blue}{x \cdot \cos y - z \cdot \sin y}}} \]
              7. lift--.f64N/A

                \[\leadsto \frac{1}{\frac{1}{\color{blue}{x \cdot \cos y - z \cdot \sin y}}} \]
              8. inv-powN/A

                \[\leadsto \frac{1}{\color{blue}{{\left(x \cdot \cos y - z \cdot \sin y\right)}^{-1}}} \]
              9. lower-pow.f6499.6

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

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

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

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

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

                \[\leadsto \color{blue}{\mathsf{fma}\left(\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.f6489.4

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

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

              \[\leadsto \cos y \cdot x \]
            9. Step-by-step derivation
              1. Applied rewrites57.3%

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

              if -2.7500000000000001e-5 < y < 7.99999999999999956e-20

              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 + -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-*.f64100.0

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

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

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

              Alternative 5: 41.6% accurate, 10.7× speedup?

              \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1.07 \cdot 10^{-192}:\\ \;\;\;\;1 \cdot x\\ \mathbf{elif}\;x \leq 8.5 \cdot 10^{-220}:\\ \;\;\;\;\left(-z\right) \cdot y\\ \mathbf{else}:\\ \;\;\;\;1 \cdot x\\ \end{array} \end{array} \]
              (FPCore (x y z)
               :precision binary64
               (if (<= x -1.07e-192) (* 1.0 x) (if (<= x 8.5e-220) (* (- z) y) (* 1.0 x))))
              double code(double x, double y, double z) {
              	double tmp;
              	if (x <= -1.07e-192) {
              		tmp = 1.0 * x;
              	} else if (x <= 8.5e-220) {
              		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 <= (-1.07d-192)) then
                      tmp = 1.0d0 * x
                  else if (x <= 8.5d-220) 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 <= -1.07e-192) {
              		tmp = 1.0 * x;
              	} else if (x <= 8.5e-220) {
              		tmp = -z * y;
              	} else {
              		tmp = 1.0 * x;
              	}
              	return tmp;
              }
              
              def code(x, y, z):
              	tmp = 0
              	if x <= -1.07e-192:
              		tmp = 1.0 * x
              	elif x <= 8.5e-220:
              		tmp = -z * y
              	else:
              		tmp = 1.0 * x
              	return tmp
              
              function code(x, y, z)
              	tmp = 0.0
              	if (x <= -1.07e-192)
              		tmp = Float64(1.0 * x);
              	elseif (x <= 8.5e-220)
              		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 <= -1.07e-192)
              		tmp = 1.0 * x;
              	elseif (x <= 8.5e-220)
              		tmp = -z * y;
              	else
              		tmp = 1.0 * x;
              	end
              	tmp_2 = tmp;
              end
              
              code[x_, y_, z_] := If[LessEqual[x, -1.07e-192], N[(1.0 * x), $MachinePrecision], If[LessEqual[x, 8.5e-220], N[((-z) * y), $MachinePrecision], N[(1.0 * x), $MachinePrecision]]]
              
              \begin{array}{l}
              
              \\
              \begin{array}{l}
              \mathbf{if}\;x \leq -1.07 \cdot 10^{-192}:\\
              \;\;\;\;1 \cdot x\\
              
              \mathbf{elif}\;x \leq 8.5 \cdot 10^{-220}:\\
              \;\;\;\;\left(-z\right) \cdot y\\
              
              \mathbf{else}:\\
              \;\;\;\;1 \cdot x\\
              
              
              \end{array}
              \end{array}
              
              Derivation
              1. Split input into 2 regimes
              2. if x < -1.07e-192 or 8.4999999999999996e-220 < 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. flip--N/A

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

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

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

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

                    \[\leadsto \frac{1}{\frac{1}{\color{blue}{x \cdot \cos y - z \cdot \sin y}}} \]
                  7. lift--.f64N/A

                    \[\leadsto \frac{1}{\frac{1}{\color{blue}{x \cdot \cos y - z \cdot \sin y}}} \]
                  8. inv-powN/A

                    \[\leadsto \frac{1}{\color{blue}{{\left(x \cdot \cos y - z \cdot \sin y\right)}^{-1}}} \]
                  9. lower-pow.f6499.7

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

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

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

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

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

                    \[\leadsto \color{blue}{\mathsf{fma}\left(\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.f6498.0

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

                  \[\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 rewrites47.1%

                    \[\leadsto 1 \cdot x \]

                  if -1.07e-192 < x < 8.4999999999999996e-220

                  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.4

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

                    \[\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 rewrites41.9%

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

                  Alternative 6: 52.1% 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-*.f6454.0

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

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

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

                    Alternative 7: 52.1% 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-*.f6454.0

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

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

                    Alternative 8: 38.8% 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. flip--N/A

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

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

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

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

                        \[\leadsto \frac{1}{\frac{1}{\color{blue}{x \cdot \cos y - z \cdot \sin y}}} \]
                      7. lift--.f64N/A

                        \[\leadsto \frac{1}{\frac{1}{\color{blue}{x \cdot \cos y - z \cdot \sin y}}} \]
                      8. inv-powN/A

                        \[\leadsto \frac{1}{\color{blue}{{\left(x \cdot \cos y - z \cdot \sin y\right)}^{-1}}} \]
                      9. lower-pow.f6499.7

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

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

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

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

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

                        \[\leadsto \color{blue}{\mathsf{fma}\left(\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.f6492.7

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

                      \[\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 rewrites40.7%

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

                      Reproduce

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