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

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

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 9 alternatives:

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

Initial Program: 99.8% accurate, 1.0× speedup?

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

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

Alternative 1: 99.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \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), Float64(-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. sub-negN/A

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

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

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

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

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

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

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

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

Alternative 2: 99.8% accurate, 1.0× speedup?

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

\\
\mathsf{fma}\left(\cos y, x, -\sin y \cdot z\right)
\end{array}
Derivation
  1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

Alternative 3: 99.8% accurate, 1.0× speedup?

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

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

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

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

Alternative 4: 71.8% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sin y \cdot z\\ \mathbf{if}\;z \leq -1.6 \cdot 10^{-60}:\\ \;\;\;\;\mathsf{fma}\left(y \cdot \left(y \cdot x\right), \mathsf{fma}\left(y, y \cdot 0.041666666666666664, -0.5\right), x\right) - t\_0\\ \mathbf{elif}\;z \leq 1.35 \cdot 10^{+37}:\\ \;\;\;\;x \cdot \cos y\\ \mathbf{else}:\\ \;\;\;\;-t\_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* (sin y) z)))
   (if (<= z -1.6e-60)
     (- (fma (* y (* y x)) (fma y (* y 0.041666666666666664) -0.5) x) t_0)
     (if (<= z 1.35e+37) (* x (cos y)) (- t_0)))))
double code(double x, double y, double z) {
	double t_0 = sin(y) * z;
	double tmp;
	if (z <= -1.6e-60) {
		tmp = fma((y * (y * x)), fma(y, (y * 0.041666666666666664), -0.5), x) - t_0;
	} else if (z <= 1.35e+37) {
		tmp = x * cos(y);
	} else {
		tmp = -t_0;
	}
	return tmp;
}
function code(x, y, z)
	t_0 = Float64(sin(y) * z)
	tmp = 0.0
	if (z <= -1.6e-60)
		tmp = Float64(fma(Float64(y * Float64(y * x)), fma(y, Float64(y * 0.041666666666666664), -0.5), x) - t_0);
	elseif (z <= 1.35e+37)
		tmp = Float64(x * cos(y));
	else
		tmp = Float64(-t_0);
	end
	return tmp
end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[Sin[y], $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[z, -1.6e-60], N[(N[(N[(y * N[(y * x), $MachinePrecision]), $MachinePrecision] * N[(y * N[(y * 0.041666666666666664), $MachinePrecision] + -0.5), $MachinePrecision] + x), $MachinePrecision] - t$95$0), $MachinePrecision], If[LessEqual[z, 1.35e+37], N[(x * N[Cos[y], $MachinePrecision]), $MachinePrecision], (-t$95$0)]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sin y \cdot z\\
\mathbf{if}\;z \leq -1.6 \cdot 10^{-60}:\\
\;\;\;\;\mathsf{fma}\left(y \cdot \left(y \cdot x\right), \mathsf{fma}\left(y, y \cdot 0.041666666666666664, -0.5\right), x\right) - t\_0\\

\mathbf{elif}\;z \leq 1.35 \cdot 10^{+37}:\\
\;\;\;\;x \cdot \cos y\\

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


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

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

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

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

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

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

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

        \[\leadsto \left(\left(\left(x \cdot {y}^{2}\right) \cdot \frac{-1}{2} + \color{blue}{\left(x \cdot {y}^{2}\right) \cdot \left(\frac{1}{24} \cdot {y}^{2}\right)}\right) + x\right) - z \cdot \sin y \]
      7. distribute-lft-outN/A

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

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

        \[\leadsto \left(\left(x \cdot {y}^{2}\right) \cdot \left(\frac{1}{24} \cdot {y}^{2} + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}\right) + x\right) - z \cdot \sin y \]
      10. sub-negN/A

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(x \cdot {y}^{2}, \frac{1}{24} \cdot {y}^{2} - \frac{1}{2}, x\right)} - z \cdot \sin y \]
    5. Applied rewrites70.4%

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

    if -1.6000000000000001e-60 < z < 1.34999999999999993e37

    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.f6488.9

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

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

    if 1.34999999999999993e37 < z

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.6 \cdot 10^{-60}:\\ \;\;\;\;\mathsf{fma}\left(y \cdot \left(y \cdot x\right), \mathsf{fma}\left(y, y \cdot 0.041666666666666664, -0.5\right), x\right) - \sin y \cdot z\\ \mathbf{elif}\;z \leq 1.35 \cdot 10^{+37}:\\ \;\;\;\;x \cdot \cos y\\ \mathbf{else}:\\ \;\;\;\;-\sin y \cdot z\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 73.8% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
t_0 := -\sin y \cdot z\\
\mathbf{if}\;z \leq -3 \cdot 10^{+66}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;z \leq 1.35 \cdot 10^{+37}:\\
\;\;\;\;x \cdot \cos y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -3.00000000000000002e66 or 1.34999999999999993e37 < z

    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.f6469.5

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

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

    if -3.00000000000000002e66 < z < 1.34999999999999993e37

    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.f6486.9

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -3 \cdot 10^{+66}:\\ \;\;\;\;-\sin y \cdot z\\ \mathbf{elif}\;z \leq 1.35 \cdot 10^{+37}:\\ \;\;\;\;x \cdot \cos y\\ \mathbf{else}:\\ \;\;\;\;-\sin y \cdot z\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 73.8% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x \cdot \cos y\\ \mathbf{if}\;y \leq -0.118:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq 3.6 \cdot 10^{-22}:\\ \;\;\;\;\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 (* x (cos y))))
   (if (<= y -0.118)
     t_0
     (if (<= y 3.6e-22)
       (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 = x * cos(y);
	double tmp;
	if (y <= -0.118) {
		tmp = t_0;
	} else if (y <= 3.6e-22) {
		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(x * cos(y))
	tmp = 0.0
	if (y <= -0.118)
		tmp = t_0;
	elseif (y <= 3.6e-22)
		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[(x * N[Cos[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -0.118], t$95$0, If[LessEqual[y, 3.6e-22], 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 := x \cdot \cos y\\
\mathbf{if}\;y \leq -0.118:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y \leq 3.6 \cdot 10^{-22}:\\
\;\;\;\;\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.11799999999999999 or 3.5999999999999998e-22 < 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.f6453.3

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

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

    if -0.11799999999999999 < y < 3.5999999999999998e-22

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

        \[\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. Applied rewrites99.8%

      \[\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. Add Preprocessing

Alternative 7: 41.2% accurate, 10.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := -y \cdot z\\ \mathbf{if}\;z \leq -2.25 \cdot 10^{+223}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq 3.5 \cdot 10^{+202}:\\ \;\;\;\;x \cdot 1\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (- (* y z))))
   (if (<= z -2.25e+223) t_0 (if (<= z 3.5e+202) (* x 1.0) t_0))))
double code(double x, double y, double z) {
	double t_0 = -(y * z);
	double tmp;
	if (z <= -2.25e+223) {
		tmp = t_0;
	} else if (z <= 3.5e+202) {
		tmp = x * 1.0;
	} 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 = -(y * z)
    if (z <= (-2.25d+223)) then
        tmp = t_0
    else if (z <= 3.5d+202) then
        tmp = x * 1.0d0
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = -(y * z);
	double tmp;
	if (z <= -2.25e+223) {
		tmp = t_0;
	} else if (z <= 3.5e+202) {
		tmp = x * 1.0;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = -(y * z)
	tmp = 0
	if z <= -2.25e+223:
		tmp = t_0
	elif z <= 3.5e+202:
		tmp = x * 1.0
	else:
		tmp = t_0
	return tmp
function code(x, y, z)
	t_0 = Float64(-Float64(y * z))
	tmp = 0.0
	if (z <= -2.25e+223)
		tmp = t_0;
	elseif (z <= 3.5e+202)
		tmp = Float64(x * 1.0);
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = -(y * z);
	tmp = 0.0;
	if (z <= -2.25e+223)
		tmp = t_0;
	elseif (z <= 3.5e+202)
		tmp = x * 1.0;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = (-N[(y * z), $MachinePrecision])}, If[LessEqual[z, -2.25e+223], t$95$0, If[LessEqual[z, 3.5e+202], N[(x * 1.0), $MachinePrecision], t$95$0]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := -y \cdot z\\
\mathbf{if}\;z \leq -2.25 \cdot 10^{+223}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;z \leq 3.5 \cdot 10^{+202}:\\
\;\;\;\;x \cdot 1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -2.25e223 or 3.49999999999999987e202 < z

    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.f6481.3

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

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

      \[\leadsto \mathsf{neg}\left(y \cdot z\right) \]
    7. Step-by-step derivation
      1. Applied rewrites42.1%

        \[\leadsto -y \cdot z \]

      if -2.25e223 < z < 3.49999999999999987e202

      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. div-subN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto x \cdot \mathsf{fma}\left(\frac{1}{2}, \frac{\cos \left(\color{blue}{\left(\mathsf{neg}\left(-2\right)\right)} \cdot y\right)}{\cos y}, \frac{1}{2} \cdot \frac{1}{\cos y}\right) \]
        7. distribute-lft-neg-inN/A

          \[\leadsto x \cdot \mathsf{fma}\left(\frac{1}{2}, \frac{\cos \color{blue}{\left(\mathsf{neg}\left(-2 \cdot y\right)\right)}}{\cos y}, \frac{1}{2} \cdot \frac{1}{\cos y}\right) \]
        8. cos-negN/A

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

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

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

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

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

          \[\leadsto x \cdot \mathsf{fma}\left(\frac{1}{2}, \frac{\cos \left(y \cdot -2\right)}{\cos y}, \color{blue}{\frac{\frac{1}{2} \cdot 1}{\cos y}}\right) \]
        14. metadata-evalN/A

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

          \[\leadsto x \cdot \mathsf{fma}\left(\frac{1}{2}, \frac{\cos \left(y \cdot -2\right)}{\cos y}, \color{blue}{\frac{\frac{1}{2}}{\cos y}}\right) \]
        16. lower-cos.f6471.0

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

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

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

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

      Alternative 8: 52.3% accurate, 23.8× speedup?

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

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

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

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

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

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

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

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

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

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

      Alternative 9: 38.7% accurate, 35.7× speedup?

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

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

          \[\leadsto \color{blue}{x \cdot \cos y - z \cdot \sin y} \]
        2. 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. div-subN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto x \cdot \mathsf{fma}\left(\frac{1}{2}, \frac{\cos \left(\color{blue}{\left(\mathsf{neg}\left(-2\right)\right)} \cdot y\right)}{\cos y}, \frac{1}{2} \cdot \frac{1}{\cos y}\right) \]
        7. distribute-lft-neg-inN/A

          \[\leadsto x \cdot \mathsf{fma}\left(\frac{1}{2}, \frac{\cos \color{blue}{\left(\mathsf{neg}\left(-2 \cdot y\right)\right)}}{\cos y}, \frac{1}{2} \cdot \frac{1}{\cos y}\right) \]
        8. cos-negN/A

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

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

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

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

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

          \[\leadsto x \cdot \mathsf{fma}\left(\frac{1}{2}, \frac{\cos \left(y \cdot -2\right)}{\cos y}, \color{blue}{\frac{\frac{1}{2} \cdot 1}{\cos y}}\right) \]
        14. metadata-evalN/A

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

          \[\leadsto x \cdot \mathsf{fma}\left(\frac{1}{2}, \frac{\cos \left(y \cdot -2\right)}{\cos y}, \color{blue}{\frac{\frac{1}{2}}{\cos y}}\right) \]
        16. lower-cos.f6461.5

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

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

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

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

        Reproduce

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