Diagrams.ThreeD.Transform:aboutY from diagrams-lib-1.3.0.3

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

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

      \[\leadsto \color{blue}{z \cdot \sin y + x \cdot \cos y} \]
    3. lift-*.f64N/A

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

      \[\leadsto \color{blue}{\sin y \cdot z} + x \cdot \cos y \]
    5. lower-fma.f6499.8

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

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

      \[\leadsto \mathsf{fma}\left(\sin y, z, \color{blue}{\cos y \cdot x}\right) \]
    8. 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. Final simplification99.8%

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

Alternative 2: 86.2% accurate, 1.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -2.9 \cdot 10^{-62}:\\ \;\;\;\;\mathsf{fma}\left(\sin y, z, 1 \cdot x\right)\\ \mathbf{elif}\;z \leq 1.2 \cdot 10^{-20}:\\ \;\;\;\;\cos y \cdot x\\ \mathbf{else}:\\ \;\;\;\;z \cdot \sin y + 1 \cdot x\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= z -2.9e-62)
   (fma (sin y) z (* 1.0 x))
   (if (<= z 1.2e-20) (* (cos y) x) (+ (* z (sin y)) (* 1.0 x)))))
double code(double x, double y, double z) {
	double tmp;
	if (z <= -2.9e-62) {
		tmp = fma(sin(y), z, (1.0 * x));
	} else if (z <= 1.2e-20) {
		tmp = cos(y) * x;
	} else {
		tmp = (z * sin(y)) + (1.0 * x);
	}
	return tmp;
}
function code(x, y, z)
	tmp = 0.0
	if (z <= -2.9e-62)
		tmp = fma(sin(y), z, Float64(1.0 * x));
	elseif (z <= 1.2e-20)
		tmp = Float64(cos(y) * x);
	else
		tmp = Float64(Float64(z * sin(y)) + Float64(1.0 * x));
	end
	return tmp
end
code[x_, y_, z_] := If[LessEqual[z, -2.9e-62], N[(N[Sin[y], $MachinePrecision] * z + N[(1.0 * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.2e-20], N[(N[Cos[y], $MachinePrecision] * x), $MachinePrecision], N[(N[(z * N[Sin[y], $MachinePrecision]), $MachinePrecision] + N[(1.0 * x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.9 \cdot 10^{-62}:\\
\;\;\;\;\mathsf{fma}\left(\sin y, z, 1 \cdot x\right)\\

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

\mathbf{else}:\\
\;\;\;\;z \cdot \sin y + 1 \cdot x\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -2.89999999999999986e-62

    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. +-commutativeN/A

        \[\leadsto \color{blue}{z \cdot \sin y + x \cdot \cos y} \]
      3. lift-*.f64N/A

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

        \[\leadsto \color{blue}{\sin y \cdot z} + x \cdot \cos y \]
      5. lower-fma.f6499.8

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

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

        \[\leadsto \mathsf{fma}\left(\sin y, z, \color{blue}{\cos y \cdot x}\right) \]
      8. 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 y around 0

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

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

      if -2.89999999999999986e-62 < z < 1.19999999999999996e-20

      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(\sin y, z, \cos y \cdot x\right)\right)}^{-1}}} \]
      5. Step-by-step derivation
        1. lift-pow.f64N/A

          \[\leadsto \frac{1}{\color{blue}{{\left(\mathsf{fma}\left(\sin y, z, \cos y \cdot x\right)\right)}^{-1}}} \]
        2. unpow-1N/A

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

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

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

          \[\leadsto \frac{1}{\frac{1}{\color{blue}{z \cdot \sin y} + \cos y \cdot x}} \]
        6. lower-fma.f6499.7

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        if 1.19999999999999996e-20 < z

        1. Initial program 99.9%

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

            \[\leadsto x \cdot \color{blue}{1} + z \cdot \sin y \]
        5. Recombined 3 regimes into one program.
        6. Final simplification92.9%

          \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -2.9 \cdot 10^{-62}:\\ \;\;\;\;\mathsf{fma}\left(\sin y, z, 1 \cdot x\right)\\ \mathbf{elif}\;z \leq 1.2 \cdot 10^{-20}:\\ \;\;\;\;\cos y \cdot x\\ \mathbf{else}:\\ \;\;\;\;z \cdot \sin y + 1 \cdot x\\ \end{array} \]
        7. Add Preprocessing

        Alternative 3: 75.0% accurate, 1.7× speedup?

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

          1. Initial program 99.3%

            \[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(\sin y, z, \cos y \cdot x\right)\right)}^{-1}}} \]
          5. Step-by-step derivation
            1. lift-pow.f64N/A

              \[\leadsto \frac{1}{\color{blue}{{\left(\mathsf{fma}\left(\sin y, z, \cos y \cdot x\right)\right)}^{-1}}} \]
            2. unpow-1N/A

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

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

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

              \[\leadsto \frac{1}{\frac{1}{\color{blue}{z \cdot \sin y} + \cos y \cdot x}} \]
            6. lower-fma.f6499.6

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            if -1.05000000000000003e259 < y < -1e-3 or 0.012 < y

            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}{z \cdot \sin y} \]
            4. Step-by-step derivation
              1. *-commutativeN/A

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

                \[\leadsto \color{blue}{\sin y \cdot z} \]
              3. lower-sin.f6460.4

                \[\leadsto \color{blue}{\sin y} \cdot z \]
            5. Applied rewrites60.4%

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

            if -1e-3 < y < 0.012

            1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(y \cdot x, -0.5, z\right), y, x\right)} \]
          12. Recombined 3 regimes into one program.
          13. Final simplification83.2%

            \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.05 \cdot 10^{+259}:\\ \;\;\;\;\cos y \cdot x\\ \mathbf{elif}\;y \leq -0.001:\\ \;\;\;\;z \cdot \sin y\\ \mathbf{elif}\;y \leq 0.012:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(x \cdot y, -0.5, z\right), y, x\right)\\ \mathbf{else}:\\ \;\;\;\;z \cdot \sin y\\ \end{array} \]
          14. Add Preprocessing

          Alternative 4: 86.2% accurate, 1.7× speedup?

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

            1. Initial program 99.8%

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

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

                \[\leadsto \color{blue}{z \cdot \sin y + x \cdot \cos y} \]
              3. lift-*.f64N/A

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

                \[\leadsto \color{blue}{\sin y \cdot z} + x \cdot \cos y \]
              5. lower-fma.f6499.9

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

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

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

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

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

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

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

              if -2.89999999999999986e-62 < z < 1.19999999999999996e-20

              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(\sin y, z, \cos y \cdot x\right)\right)}^{-1}}} \]
              5. Step-by-step derivation
                1. lift-pow.f64N/A

                  \[\leadsto \frac{1}{\color{blue}{{\left(\mathsf{fma}\left(\sin y, z, \cos y \cdot x\right)\right)}^{-1}}} \]
                2. unpow-1N/A

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

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

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

                  \[\leadsto \frac{1}{\frac{1}{\color{blue}{z \cdot \sin y} + \cos y \cdot x}} \]
                6. lower-fma.f6499.7

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto \cos y \cdot x \]
              12. Recombined 2 regimes into one program.
              13. Add Preprocessing

              Alternative 5: 74.8% accurate, 1.8× speedup?

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

                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}{z \cdot \sin y} \]
                4. Step-by-step derivation
                  1. *-commutativeN/A

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

                    \[\leadsto \color{blue}{\sin y \cdot z} \]
                  3. lower-sin.f6457.6

                    \[\leadsto \color{blue}{\sin y} \cdot z \]
                5. Applied rewrites57.6%

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

                if -1e-3 < y < 0.012

                1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

                \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -0.001:\\ \;\;\;\;z \cdot \sin y\\ \mathbf{elif}\;y \leq 0.012:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(x \cdot y, -0.5, z\right), y, x\right)\\ \mathbf{else}:\\ \;\;\;\;z \cdot \sin y\\ \end{array} \]
              5. Add Preprocessing

              Alternative 6: 40.2% accurate, 11.9× speedup?

              \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -2.2 \cdot 10^{+18}:\\ \;\;\;\;z \cdot y\\ \mathbf{elif}\;z \leq 2.4 \cdot 10^{+151}:\\ \;\;\;\;1 \cdot x\\ \mathbf{else}:\\ \;\;\;\;z \cdot y\\ \end{array} \end{array} \]
              (FPCore (x y z)
               :precision binary64
               (if (<= z -2.2e+18) (* z y) (if (<= z 2.4e+151) (* 1.0 x) (* z y))))
              double code(double x, double y, double z) {
              	double tmp;
              	if (z <= -2.2e+18) {
              		tmp = z * y;
              	} else if (z <= 2.4e+151) {
              		tmp = 1.0 * x;
              	} else {
              		tmp = z * 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 (z <= (-2.2d+18)) then
                      tmp = z * y
                  else if (z <= 2.4d+151) then
                      tmp = 1.0d0 * x
                  else
                      tmp = z * y
                  end if
                  code = tmp
              end function
              
              public static double code(double x, double y, double z) {
              	double tmp;
              	if (z <= -2.2e+18) {
              		tmp = z * y;
              	} else if (z <= 2.4e+151) {
              		tmp = 1.0 * x;
              	} else {
              		tmp = z * y;
              	}
              	return tmp;
              }
              
              def code(x, y, z):
              	tmp = 0
              	if z <= -2.2e+18:
              		tmp = z * y
              	elif z <= 2.4e+151:
              		tmp = 1.0 * x
              	else:
              		tmp = z * y
              	return tmp
              
              function code(x, y, z)
              	tmp = 0.0
              	if (z <= -2.2e+18)
              		tmp = Float64(z * y);
              	elseif (z <= 2.4e+151)
              		tmp = Float64(1.0 * x);
              	else
              		tmp = Float64(z * y);
              	end
              	return tmp
              end
              
              function tmp_2 = code(x, y, z)
              	tmp = 0.0;
              	if (z <= -2.2e+18)
              		tmp = z * y;
              	elseif (z <= 2.4e+151)
              		tmp = 1.0 * x;
              	else
              		tmp = z * y;
              	end
              	tmp_2 = tmp;
              end
              
              code[x_, y_, z_] := If[LessEqual[z, -2.2e+18], N[(z * y), $MachinePrecision], If[LessEqual[z, 2.4e+151], N[(1.0 * x), $MachinePrecision], N[(z * y), $MachinePrecision]]]
              
              \begin{array}{l}
              
              \\
              \begin{array}{l}
              \mathbf{if}\;z \leq -2.2 \cdot 10^{+18}:\\
              \;\;\;\;z \cdot y\\
              
              \mathbf{elif}\;z \leq 2.4 \cdot 10^{+151}:\\
              \;\;\;\;1 \cdot x\\
              
              \mathbf{else}:\\
              \;\;\;\;z \cdot y\\
              
              
              \end{array}
              \end{array}
              
              Derivation
              1. Split input into 2 regimes
              2. if z < -2.2e18 or 2.4000000000000001e151 < 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 \color{blue}{x + y \cdot z} \]
                4. Step-by-step derivation
                  1. +-commutativeN/A

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

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

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

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

                  \[\leadsto y \cdot \color{blue}{z} \]
                7. Step-by-step derivation
                  1. Applied rewrites39.9%

                    \[\leadsto z \cdot \color{blue}{y} \]

                  if -2.2e18 < z < 2.4000000000000001e151

                  1. Initial program 99.9%

                    \[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(\sin y, z, \cos y \cdot x\right)\right)}^{-1}}} \]
                  5. Step-by-step derivation
                    1. lift-pow.f64N/A

                      \[\leadsto \frac{1}{\color{blue}{{\left(\mathsf{fma}\left(\sin y, z, \cos y \cdot x\right)\right)}^{-1}}} \]
                    2. unpow-1N/A

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

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

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

                      \[\leadsto \frac{1}{\frac{1}{\color{blue}{z \cdot \sin y} + \cos y \cdot x}} \]
                    6. lower-fma.f6499.7

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto 1 \cdot x \]
                  11. Step-by-step derivation
                    1. Applied rewrites54.4%

                      \[\leadsto 1 \cdot x \]
                  12. Recombined 2 regimes into one program.
                  13. Add Preprocessing

                  Alternative 7: 51.8% accurate, 30.6× 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(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 + y \cdot z} \]
                  4. Step-by-step derivation
                    1. +-commutativeN/A

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

                      \[\leadsto \color{blue}{z \cdot y} + x \]
                    3. lower-fma.f6458.8

                      \[\leadsto \color{blue}{\mathsf{fma}\left(z, y, x\right)} \]
                  5. Applied rewrites58.8%

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

                  Alternative 8: 16.9% accurate, 35.7× speedup?

                  \[\begin{array}{l} \\ z \cdot y \end{array} \]
                  (FPCore (x y z) :precision binary64 (* z y))
                  double code(double x, double y, double z) {
                  	return 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 = z * y
                  end function
                  
                  public static double code(double x, double y, double z) {
                  	return z * y;
                  }
                  
                  def code(x, y, z):
                  	return z * y
                  
                  function code(x, y, z)
                  	return Float64(z * y)
                  end
                  
                  function tmp = code(x, y, z)
                  	tmp = z * y;
                  end
                  
                  code[x_, y_, z_] := N[(z * y), $MachinePrecision]
                  
                  \begin{array}{l}
                  
                  \\
                  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 + y \cdot z} \]
                  4. Step-by-step derivation
                    1. +-commutativeN/A

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

                      \[\leadsto \color{blue}{z \cdot y} + x \]
                    3. lower-fma.f6458.8

                      \[\leadsto \color{blue}{\mathsf{fma}\left(z, y, x\right)} \]
                  5. Applied rewrites58.8%

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

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

                      \[\leadsto z \cdot \color{blue}{y} \]
                    2. Add Preprocessing

                    Reproduce

                    ?
                    herbie shell --seed 2024308 
                    (FPCore (x y z)
                      :name "Diagrams.ThreeD.Transform:aboutY from diagrams-lib-1.3.0.3"
                      :precision binary64
                      (+ (* x (cos y)) (* z (sin y))))