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

Percentage Accurate: 99.8% → 99.8%
Time: 16.0s
Alternatives: 10
Speedup: 1.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 10 alternatives:

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

Initial Program: 99.8% accurate, 1.0× speedup?

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

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

Alternative 1: 99.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(\cos y, x, -z \cdot \sin y\right) \end{array} \]
(FPCore (x y z) :precision binary64 (fma (cos y) x (- (* z (sin y)))))
double code(double x, double y, double z) {
	return fma(cos(y), x, -(z * sin(y)));
}
function code(x, y, z)
	return fma(cos(y), x, Float64(-Float64(z * sin(y))))
end
code[x_, y_, z_] := N[(N[Cos[y], $MachinePrecision] * x + (-N[(z * N[Sin[y], $MachinePrecision]), $MachinePrecision])), $MachinePrecision]
\begin{array}{l}

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 99.8% accurate, 1.0× speedup?

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

\\
\cos y \cdot x - z \cdot \sin y
\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 - z \cdot \sin y \]
  4. Add Preprocessing

Alternative 3: 85.1% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos y \cdot x\\ \mathbf{if}\;x \leq -1 \cdot 10^{+80}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq 6.2 \cdot 10^{-78}:\\ \;\;\;\;\mathsf{fma}\left(\frac{-1}{\frac{1}{z}}, \sin y, x\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* (cos y) x)))
   (if (<= x -1e+80)
     t_0
     (if (<= x 6.2e-78) (fma (/ -1.0 (/ 1.0 z)) (sin y) x) t_0))))
double code(double x, double y, double z) {
	double t_0 = cos(y) * x;
	double tmp;
	if (x <= -1e+80) {
		tmp = t_0;
	} else if (x <= 6.2e-78) {
		tmp = fma((-1.0 / (1.0 / z)), sin(y), x);
	} else {
		tmp = t_0;
	}
	return tmp;
}
function code(x, y, z)
	t_0 = Float64(cos(y) * x)
	tmp = 0.0
	if (x <= -1e+80)
		tmp = t_0;
	elseif (x <= 6.2e-78)
		tmp = fma(Float64(-1.0 / Float64(1.0 / z)), sin(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[x, -1e+80], t$95$0, If[LessEqual[x, 6.2e-78], N[(N[(-1.0 / N[(1.0 / z), $MachinePrecision]), $MachinePrecision] * N[Sin[y], $MachinePrecision] + x), $MachinePrecision], t$95$0]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \cos y \cdot x\\
\mathbf{if}\;x \leq -1 \cdot 10^{+80}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq 6.2 \cdot 10^{-78}:\\
\;\;\;\;\mathsf{fma}\left(\frac{-1}{\frac{1}{z}}, \sin y, x\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1e80 or 6.20000000000000035e-78 < x

    1. Initial program 99.9%

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

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

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

        \[\leadsto x \cdot \color{blue}{\cos y} \]
    5. Simplified89.7%

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

    if -1e80 < x < 6.20000000000000035e-78

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(\left(z \cdot \sin y\right) \cdot \left(z \cdot \sin y\right)\right)}}{0 + z \cdot \sin y} + x \cdot \cos y \]
      11. div-invN/A

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{neg}\left(\left(z \cdot \sin y\right) \cdot \left(z \cdot \sin y\right)\right), \frac{1}{0 + z \cdot \sin y}, x \cdot \cos y\right)} \]
    4. Applied egg-rr47.1%

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

      \[\leadsto \mathsf{fma}\left(\left(\frac{1}{2} - \frac{1}{2} \cdot \cos \left(y + y\right)\right) \cdot \left(\mathsf{neg}\left(z \cdot z\right)\right), \frac{1}{0 + z \cdot \sin y}, x \cdot \color{blue}{1}\right) \]
    6. Step-by-step derivation
      1. Simplified39.7%

        \[\leadsto \mathsf{fma}\left(\left(0.5 - 0.5 \cdot \cos \left(y + y\right)\right) \cdot \left(-z \cdot z\right), \frac{1}{0 + z \cdot \sin y}, x \cdot \color{blue}{1}\right) \]
      2. Applied egg-rr91.6%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{-1}{\frac{1}{z}}, \sin y, x\right)} \]
    7. Recombined 2 regimes into one program.
    8. Final simplification90.7%

      \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1 \cdot 10^{+80}:\\ \;\;\;\;\cos y \cdot x\\ \mathbf{elif}\;x \leq 6.2 \cdot 10^{-78}:\\ \;\;\;\;\mathsf{fma}\left(\frac{-1}{\frac{1}{z}}, \sin y, x\right)\\ \mathbf{else}:\\ \;\;\;\;\cos y \cdot x\\ \end{array} \]
    9. Add Preprocessing

    Alternative 4: 77.7% accurate, 1.6× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos y \cdot x\\ \mathbf{if}\;x \leq -1 \cdot 10^{+80}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq 6.2 \cdot 10^{-78}:\\ \;\;\;\;x - x \cdot \left(z \cdot \frac{\sin y}{x}\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
    (FPCore (x y z)
     :precision binary64
     (let* ((t_0 (* (cos y) x)))
       (if (<= x -1e+80)
         t_0
         (if (<= x 6.2e-78) (- x (* x (* z (/ (sin y) x)))) t_0))))
    double code(double x, double y, double z) {
    	double t_0 = cos(y) * x;
    	double tmp;
    	if (x <= -1e+80) {
    		tmp = t_0;
    	} else if (x <= 6.2e-78) {
    		tmp = x - (x * (z * (sin(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 = cos(y) * x
        if (x <= (-1d+80)) then
            tmp = t_0
        else if (x <= 6.2d-78) then
            tmp = x - (x * (z * (sin(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 = Math.cos(y) * x;
    	double tmp;
    	if (x <= -1e+80) {
    		tmp = t_0;
    	} else if (x <= 6.2e-78) {
    		tmp = x - (x * (z * (Math.sin(y) / x)));
    	} else {
    		tmp = t_0;
    	}
    	return tmp;
    }
    
    def code(x, y, z):
    	t_0 = math.cos(y) * x
    	tmp = 0
    	if x <= -1e+80:
    		tmp = t_0
    	elif x <= 6.2e-78:
    		tmp = x - (x * (z * (math.sin(y) / x)))
    	else:
    		tmp = t_0
    	return tmp
    
    function code(x, y, z)
    	t_0 = Float64(cos(y) * x)
    	tmp = 0.0
    	if (x <= -1e+80)
    		tmp = t_0;
    	elseif (x <= 6.2e-78)
    		tmp = Float64(x - Float64(x * Float64(z * Float64(sin(y) / x))));
    	else
    		tmp = t_0;
    	end
    	return tmp
    end
    
    function tmp_2 = code(x, y, z)
    	t_0 = cos(y) * x;
    	tmp = 0.0;
    	if (x <= -1e+80)
    		tmp = t_0;
    	elseif (x <= 6.2e-78)
    		tmp = x - (x * (z * (sin(y) / x)));
    	else
    		tmp = t_0;
    	end
    	tmp_2 = tmp;
    end
    
    code[x_, y_, z_] := Block[{t$95$0 = N[(N[Cos[y], $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[x, -1e+80], t$95$0, If[LessEqual[x, 6.2e-78], N[(x - N[(x * N[(z * N[(N[Sin[y], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := \cos y \cdot x\\
    \mathbf{if}\;x \leq -1 \cdot 10^{+80}:\\
    \;\;\;\;t\_0\\
    
    \mathbf{elif}\;x \leq 6.2 \cdot 10^{-78}:\\
    \;\;\;\;x - x \cdot \left(z \cdot \frac{\sin y}{x}\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;t\_0\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if x < -1e80 or 6.20000000000000035e-78 < x

      1. Initial program 99.9%

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

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

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

          \[\leadsto x \cdot \color{blue}{\cos y} \]
      5. Simplified89.7%

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

      if -1e80 < x < 6.20000000000000035e-78

      1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \color{blue}{x \cdot \left(1 + -1 \cdot \frac{z \cdot \sin y}{x}\right)} \]
        3. Step-by-step derivation
          1. distribute-rgt-inN/A

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

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

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

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

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

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

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

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

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

            \[\leadsto x - \left(z \cdot \color{blue}{\frac{\sin y}{x}}\right) \cdot x \]
          11. lower-sin.f6475.0

            \[\leadsto x - \left(z \cdot \frac{\color{blue}{\sin y}}{x}\right) \cdot x \]
        4. Simplified75.0%

          \[\leadsto \color{blue}{x - \left(z \cdot \frac{\sin y}{x}\right) \cdot x} \]
      8. Recombined 2 regimes into one program.
      9. Final simplification81.9%

        \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1 \cdot 10^{+80}:\\ \;\;\;\;\cos y \cdot x\\ \mathbf{elif}\;x \leq 6.2 \cdot 10^{-78}:\\ \;\;\;\;x - x \cdot \left(z \cdot \frac{\sin y}{x}\right)\\ \mathbf{else}:\\ \;\;\;\;\cos y \cdot x\\ \end{array} \]
      10. Add Preprocessing

      Alternative 5: 75.1% accurate, 1.7× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} t_0 := -z \cdot \sin y\\ \mathbf{if}\;y \leq -4.3 \cdot 10^{+265}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq -0.075:\\ \;\;\;\;\cos y \cdot x\\ \mathbf{elif}\;y \leq 0.1:\\ \;\;\;\;\mathsf{fma}\left(y, \mathsf{fma}\left(y, \mathsf{fma}\left(z, y \cdot 0.16666666666666666, x \cdot -0.5\right), -z\right), x\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
      (FPCore (x y z)
       :precision binary64
       (let* ((t_0 (- (* z (sin y)))))
         (if (<= y -4.3e+265)
           t_0
           (if (<= y -0.075)
             (* (cos y) x)
             (if (<= y 0.1)
               (fma y (fma y (fma z (* y 0.16666666666666666) (* x -0.5)) (- z)) x)
               t_0)))))
      double code(double x, double y, double z) {
      	double t_0 = -(z * sin(y));
      	double tmp;
      	if (y <= -4.3e+265) {
      		tmp = t_0;
      	} else if (y <= -0.075) {
      		tmp = cos(y) * x;
      	} else if (y <= 0.1) {
      		tmp = fma(y, fma(y, fma(z, (y * 0.16666666666666666), (x * -0.5)), -z), x);
      	} else {
      		tmp = t_0;
      	}
      	return tmp;
      }
      
      function code(x, y, z)
      	t_0 = Float64(-Float64(z * sin(y)))
      	tmp = 0.0
      	if (y <= -4.3e+265)
      		tmp = t_0;
      	elseif (y <= -0.075)
      		tmp = Float64(cos(y) * x);
      	elseif (y <= 0.1)
      		tmp = fma(y, fma(y, fma(z, Float64(y * 0.16666666666666666), Float64(x * -0.5)), Float64(-z)), 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, -4.3e+265], t$95$0, If[LessEqual[y, -0.075], N[(N[Cos[y], $MachinePrecision] * x), $MachinePrecision], If[LessEqual[y, 0.1], N[(y * N[(y * N[(z * N[(y * 0.16666666666666666), $MachinePrecision] + N[(x * -0.5), $MachinePrecision]), $MachinePrecision] + (-z)), $MachinePrecision] + x), $MachinePrecision], t$95$0]]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      t_0 := -z \cdot \sin y\\
      \mathbf{if}\;y \leq -4.3 \cdot 10^{+265}:\\
      \;\;\;\;t\_0\\
      
      \mathbf{elif}\;y \leq -0.075:\\
      \;\;\;\;\cos y \cdot x\\
      
      \mathbf{elif}\;y \leq 0.1:\\
      \;\;\;\;\mathsf{fma}\left(y, \mathsf{fma}\left(y, \mathsf{fma}\left(z, y \cdot 0.16666666666666666, x \cdot -0.5\right), -z\right), x\right)\\
      
      \mathbf{else}:\\
      \;\;\;\;t\_0\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 3 regimes
      2. if y < -4.29999999999999973e265 or 0.10000000000000001 < 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}{-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. lower-neg.f64N/A

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

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

            \[\leadsto -z \cdot \color{blue}{\sin y} \]
        5. Simplified59.8%

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

        if -4.29999999999999973e265 < y < -0.0749999999999999972

        1. Initial program 99.5%

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

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

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

            \[\leadsto x \cdot \color{blue}{\cos y} \]
        5. Simplified63.5%

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

        if -0.0749999999999999972 < y < 0.10000000000000001

        1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -4.3 \cdot 10^{+265}:\\ \;\;\;\;-z \cdot \sin y\\ \mathbf{elif}\;y \leq -0.075:\\ \;\;\;\;\cos y \cdot x\\ \mathbf{elif}\;y \leq 0.1:\\ \;\;\;\;\mathsf{fma}\left(y, \mathsf{fma}\left(y, \mathsf{fma}\left(z, y \cdot 0.16666666666666666, x \cdot -0.5\right), -z\right), x\right)\\ \mathbf{else}:\\ \;\;\;\;-z \cdot \sin y\\ \end{array} \]
      5. Add Preprocessing

      Alternative 6: 75.3% accurate, 1.8× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos y \cdot x\\ \mathbf{if}\;y \leq -0.075:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq 25:\\ \;\;\;\;\mathsf{fma}\left(y, \mathsf{fma}\left(y, \mathsf{fma}\left(z, y \cdot 0.16666666666666666, x \cdot -0.5\right), -z\right), x\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
      (FPCore (x y z)
       :precision binary64
       (let* ((t_0 (* (cos y) x)))
         (if (<= y -0.075)
           t_0
           (if (<= y 25.0)
             (fma y (fma y (fma z (* y 0.16666666666666666) (* x -0.5)) (- z)) x)
             t_0))))
      double code(double x, double y, double z) {
      	double t_0 = cos(y) * x;
      	double tmp;
      	if (y <= -0.075) {
      		tmp = t_0;
      	} else if (y <= 25.0) {
      		tmp = fma(y, fma(y, fma(z, (y * 0.16666666666666666), (x * -0.5)), -z), x);
      	} else {
      		tmp = t_0;
      	}
      	return tmp;
      }
      
      function code(x, y, z)
      	t_0 = Float64(cos(y) * x)
      	tmp = 0.0
      	if (y <= -0.075)
      		tmp = t_0;
      	elseif (y <= 25.0)
      		tmp = fma(y, fma(y, fma(z, Float64(y * 0.16666666666666666), Float64(x * -0.5)), Float64(-z)), 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, -0.075], t$95$0, If[LessEqual[y, 25.0], N[(y * N[(y * N[(z * N[(y * 0.16666666666666666), $MachinePrecision] + N[(x * -0.5), $MachinePrecision]), $MachinePrecision] + (-z)), $MachinePrecision] + x), $MachinePrecision], t$95$0]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      t_0 := \cos y \cdot x\\
      \mathbf{if}\;y \leq -0.075:\\
      \;\;\;\;t\_0\\
      
      \mathbf{elif}\;y \leq 25:\\
      \;\;\;\;\mathsf{fma}\left(y, \mathsf{fma}\left(y, \mathsf{fma}\left(z, y \cdot 0.16666666666666666, x \cdot -0.5\right), -z\right), x\right)\\
      
      \mathbf{else}:\\
      \;\;\;\;t\_0\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if y < -0.0749999999999999972 or 25 < y

        1. Initial program 99.6%

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

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

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

            \[\leadsto x \cdot \color{blue}{\cos y} \]
        5. Simplified52.8%

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

        if -0.0749999999999999972 < y < 25

        1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      Alternative 7: 53.4% accurate, 3.5× speedup?

      \[\begin{array}{l} \\ \mathsf{fma}\left(1, x, \frac{-1}{\frac{\mathsf{fma}\left(0.16666666666666666, \frac{y \cdot y}{z}, \frac{1}{z}\right)}{y}}\right) \end{array} \]
      (FPCore (x y z)
       :precision binary64
       (fma 1.0 x (/ -1.0 (/ (fma 0.16666666666666666 (/ (* y y) z) (/ 1.0 z)) y))))
      double code(double x, double y, double z) {
      	return fma(1.0, x, (-1.0 / (fma(0.16666666666666666, ((y * y) / z), (1.0 / z)) / y)));
      }
      
      function code(x, y, z)
      	return fma(1.0, x, Float64(-1.0 / Float64(fma(0.16666666666666666, Float64(Float64(y * y) / z), Float64(1.0 / z)) / y)))
      end
      
      code[x_, y_, z_] := N[(1.0 * x + N[(-1.0 / N[(N[(0.16666666666666666 * N[(N[(y * y), $MachinePrecision] / z), $MachinePrecision] + N[(1.0 / z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
      
      \begin{array}{l}
      
      \\
      \mathsf{fma}\left(1, x, \frac{-1}{\frac{\mathsf{fma}\left(0.16666666666666666, \frac{y \cdot y}{z}, \frac{1}{z}\right)}{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-cos.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        Alternative 8: 53.0% accurate, 14.3× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -5.2 \cdot 10^{+28}:\\ \;\;\;\;-x\\ \mathbf{else}:\\ \;\;\;\;x - y \cdot z\\ \end{array} \end{array} \]
        (FPCore (x y z) :precision binary64 (if (<= y -5.2e+28) (- x) (- x (* y z))))
        double code(double x, double y, double z) {
        	double tmp;
        	if (y <= -5.2e+28) {
        		tmp = -x;
        	} else {
        		tmp = x - (y * z);
        	}
        	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 (y <= (-5.2d+28)) then
                tmp = -x
            else
                tmp = x - (y * z)
            end if
            code = tmp
        end function
        
        public static double code(double x, double y, double z) {
        	double tmp;
        	if (y <= -5.2e+28) {
        		tmp = -x;
        	} else {
        		tmp = x - (y * z);
        	}
        	return tmp;
        }
        
        def code(x, y, z):
        	tmp = 0
        	if y <= -5.2e+28:
        		tmp = -x
        	else:
        		tmp = x - (y * z)
        	return tmp
        
        function code(x, y, z)
        	tmp = 0.0
        	if (y <= -5.2e+28)
        		tmp = Float64(-x);
        	else
        		tmp = Float64(x - Float64(y * z));
        	end
        	return tmp
        end
        
        function tmp_2 = code(x, y, z)
        	tmp = 0.0;
        	if (y <= -5.2e+28)
        		tmp = -x;
        	else
        		tmp = x - (y * z);
        	end
        	tmp_2 = tmp;
        end
        
        code[x_, y_, z_] := If[LessEqual[y, -5.2e+28], (-x), N[(x - N[(y * z), $MachinePrecision]), $MachinePrecision]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;y \leq -5.2 \cdot 10^{+28}:\\
        \;\;\;\;-x\\
        
        \mathbf{else}:\\
        \;\;\;\;x - y \cdot z\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if y < -5.2000000000000004e28

          1. Initial program 99.5%

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

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

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

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

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

              \[\leadsto \color{blue}{\frac{{x}^{3} + {\left(\mathsf{neg}\left(z \cdot y\right)\right)}^{3}}{x \cdot x + \left(\left(\mathsf{neg}\left(z \cdot y\right)\right) \cdot \left(\mathsf{neg}\left(z \cdot y\right)\right) - x \cdot \left(\mathsf{neg}\left(z \cdot y\right)\right)\right)}} \]
            4. cube-negN/A

              \[\leadsto \frac{{x}^{3} + \color{blue}{\left(\mathsf{neg}\left({\left(z \cdot y\right)}^{3}\right)\right)}}{x \cdot x + \left(\left(\mathsf{neg}\left(z \cdot y\right)\right) \cdot \left(\mathsf{neg}\left(z \cdot y\right)\right) - x \cdot \left(\mathsf{neg}\left(z \cdot y\right)\right)\right)} \]
            5. sub-negN/A

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

              \[\leadsto \color{blue}{\frac{{x}^{3} - {\left(z \cdot y\right)}^{3}}{x \cdot x + \left(\left(\mathsf{neg}\left(z \cdot y\right)\right) \cdot \left(\mathsf{neg}\left(z \cdot y\right)\right) - x \cdot \left(\mathsf{neg}\left(z \cdot y\right)\right)\right)}} \]
          7. Applied egg-rr1.0%

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

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

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

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

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

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

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

              \[\leadsto \frac{\left(x \cdot \left(\color{blue}{z \cdot y} + x\right)\right) \cdot \mathsf{fma}\left(y, \mathsf{neg}\left(z\right), x\right)}{\mathsf{fma}\left(x, x, y \cdot \left(z \cdot \left(y \cdot z\right)\right) - x \cdot \left(y \cdot \left(\mathsf{neg}\left(z\right)\right)\right)\right)} \]
            7. lower-fma.f642.7

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

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

            \[\leadsto \color{blue}{-1 \cdot x} \]
          12. Step-by-step derivation
            1. mul-1-negN/A

              \[\leadsto \color{blue}{\mathsf{neg}\left(x\right)} \]
            2. lower-neg.f6411.0

              \[\leadsto \color{blue}{-x} \]
          13. Simplified11.0%

            \[\leadsto \color{blue}{-x} \]

          if -5.2000000000000004e28 < y

          1. Initial program 99.9%

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

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

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

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

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

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

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

            \[\leadsto \color{blue}{x - z \cdot y} \]
        3. Recombined 2 regimes into one program.
        4. Final simplification57.3%

          \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -5.2 \cdot 10^{+28}:\\ \;\;\;\;-x\\ \mathbf{else}:\\ \;\;\;\;x - y \cdot z\\ \end{array} \]
        5. Add Preprocessing

        Alternative 9: 39.9% accurate, 15.3× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq 1.15 \cdot 10^{+241}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(-z\right)\\ \end{array} \end{array} \]
        (FPCore (x y z) :precision binary64 (if (<= z 1.15e+241) x (* y (- z))))
        double code(double x, double y, double z) {
        	double tmp;
        	if (z <= 1.15e+241) {
        		tmp = x;
        	} else {
        		tmp = y * -z;
        	}
        	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 <= 1.15d+241) then
                tmp = x
            else
                tmp = y * -z
            end if
            code = tmp
        end function
        
        public static double code(double x, double y, double z) {
        	double tmp;
        	if (z <= 1.15e+241) {
        		tmp = x;
        	} else {
        		tmp = y * -z;
        	}
        	return tmp;
        }
        
        def code(x, y, z):
        	tmp = 0
        	if z <= 1.15e+241:
        		tmp = x
        	else:
        		tmp = y * -z
        	return tmp
        
        function code(x, y, z)
        	tmp = 0.0
        	if (z <= 1.15e+241)
        		tmp = x;
        	else
        		tmp = Float64(y * Float64(-z));
        	end
        	return tmp
        end
        
        function tmp_2 = code(x, y, z)
        	tmp = 0.0;
        	if (z <= 1.15e+241)
        		tmp = x;
        	else
        		tmp = y * -z;
        	end
        	tmp_2 = tmp;
        end
        
        code[x_, y_, z_] := If[LessEqual[z, 1.15e+241], x, N[(y * (-z)), $MachinePrecision]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;z \leq 1.15 \cdot 10^{+241}:\\
        \;\;\;\;x\\
        
        \mathbf{else}:\\
        \;\;\;\;y \cdot \left(-z\right)\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if z < 1.15e241

          1. Initial program 99.8%

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

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

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

              \[\leadsto x \cdot \color{blue}{\cos y} \]
          5. Simplified67.7%

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

            \[\leadsto x \cdot \color{blue}{1} \]
          7. Step-by-step derivation
            1. Simplified44.3%

              \[\leadsto x \cdot \color{blue}{1} \]
            2. Step-by-step derivation
              1. *-rgt-identity44.3

                \[\leadsto \color{blue}{x} \]
            3. Applied egg-rr44.3%

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

            if 1.15e241 < 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 \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-*.f6466.2

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

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

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

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

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

                \[\leadsto \color{blue}{y \cdot \left(\mathsf{neg}\left(z\right)\right)} \]
              4. lower-neg.f6449.5

                \[\leadsto y \cdot \color{blue}{\left(-z\right)} \]
            8. Simplified49.5%

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

          Alternative 10: 38.9% accurate, 214.0× speedup?

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

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

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

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

              \[\leadsto x \cdot \color{blue}{\cos y} \]
          5. Simplified64.5%

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

            \[\leadsto x \cdot \color{blue}{1} \]
          7. Step-by-step derivation
            1. Simplified42.8%

              \[\leadsto x \cdot \color{blue}{1} \]
            2. Step-by-step derivation
              1. *-rgt-identity42.8

                \[\leadsto \color{blue}{x} \]
            3. Applied egg-rr42.8%

              \[\leadsto \color{blue}{x} \]
            4. Add Preprocessing

            Reproduce

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