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

Percentage Accurate: 99.8% → 99.8%
Time: 6.0s
Alternatives: 10
Speedup: N/A×

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));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x, y, z)
use fmin_fmax_functions
    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));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x, y, z)
use fmin_fmax_functions
    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, N/A× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 99.8% accurate, N/A× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.8 \cdot 10^{+34}:\\
\;\;\;\;\mathsf{fma}\left(\sin y, \frac{z}{x}, \cos y\right) \cdot x\\

\mathbf{elif}\;x \leq 8000000:\\
\;\;\;\;\mathsf{fma}\left(\frac{\cos y \cdot x}{z}, 1, \sin y\right) \cdot z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -4.79999999999999974e34

    1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(1, \frac{\sin y \cdot z}{x}, \cos y\right) \cdot x \]
      10. lift-cos.f6499.7

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(\sin y, \frac{z}{x}, \cos y\right) \cdot x \]

    if -4.79999999999999974e34 < x < 8e6

    1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\frac{\cos y \cdot x}{z}, 1, \sin y\right) \cdot z \]
      11. lift-sin.f6499.8

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

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

    if 8e6 < x

    1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(1, \frac{\sin y \cdot z}{x}, \cos y\right) \cdot x \]
      10. lift-cos.f6499.7

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(z, \frac{\sin y}{x}, \cos y\right) \cdot x \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 3: 99.8% accurate, N/A× 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(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.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 99.7% accurate, N/A× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.8 \cdot 10^{+34}:\\
\;\;\;\;\mathsf{fma}\left(\sin y, \frac{z}{x}, \cos y\right) \cdot x\\

\mathbf{elif}\;x \leq 15000000:\\
\;\;\;\;\mathsf{fma}\left(\cos y \cdot \frac{x}{z}, 1, \sin y\right) \cdot z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -4.79999999999999974e34

    1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(1, \frac{\sin y \cdot z}{x}, \cos y\right) \cdot x \]
      10. lift-cos.f6499.7

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(\sin y, \frac{z}{x}, \cos y\right) \cdot x \]

    if -4.79999999999999974e34 < x < 1.5e7

    1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\frac{\cos y \cdot x}{z}, 1, \sin y\right) \cdot z \]
      11. lift-sin.f6499.8

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\frac{\cos y \cdot x}{z}, 1, \sin y\right) \cdot z \]
      4. associate-/l*N/A

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

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

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

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

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

    if 1.5e7 < x

    1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(1, \frac{\sin y \cdot z}{x}, \cos y\right) \cdot x \]
      10. lift-cos.f6499.7

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(z, \frac{\sin y}{x}, \cos y\right) \cdot x \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 5: 99.7% accurate, N/A× 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));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

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

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

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

Alternative 6: 99.6% accurate, N/A× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{\sin y}{x}\\
\mathbf{if}\;x \leq -4.8 \cdot 10^{+34}:\\
\;\;\;\;\mathsf{fma}\left(\sin y, \frac{z}{x}, \cos y\right) \cdot x\\

\mathbf{elif}\;x \leq 11000000:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{z}, \cos y, x \cdot t\_0\right) \cdot z\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, t\_0, \cos y\right) \cdot x\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -4.79999999999999974e34

    1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(1, \frac{\sin y \cdot z}{x}, \cos y\right) \cdot x \]
      10. lift-cos.f6499.7

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(\sin y, \frac{z}{x}, \cos y\right) \cdot x \]

    if -4.79999999999999974e34 < x < 1.1e7

    1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\frac{\cos y \cdot x}{z}, 1, \sin y\right) \cdot z \]
      11. lift-sin.f6499.8

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

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

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

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

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

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

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

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

        \[\leadsto \frac{{\left(\frac{\cos y \cdot x}{z} \cdot 1\right)}^{3} + {\sin y}^{3}}{\left(\frac{\cos y \cdot x}{z} \cdot 1\right) \cdot \left(\frac{\cos y \cdot x}{z} \cdot 1\right) + \left(\sin y \cdot \sin y - \left(\frac{\cos y \cdot x}{z} \cdot 1\right) \cdot \sin y\right)} \cdot z \]
    7. Applied rewrites64.2%

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

      \[\leadsto \left(x \cdot \left(\frac{\cos y}{z} + \frac{\sin y}{x}\right)\right) \cdot z \]
    9. Step-by-step derivation
      1. Applied rewrites99.7%

        \[\leadsto \mathsf{fma}\left(\frac{x}{z}, \cos y, x \cdot \frac{\sin y}{x}\right) \cdot z \]

      if 1.1e7 < x

      1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \mathsf{fma}\left(1, \frac{\sin y \cdot z}{x}, \cos y\right) \cdot x \]
        10. lift-cos.f6499.7

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(z, \frac{\sin y}{x}, \cos y\right) \cdot x \]
    10. Recombined 3 regimes into one program.
    11. Add Preprocessing

    Alternative 7: 99.6% accurate, N/A× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\sin y}{x}\\ \mathbf{if}\;x \leq -5 \cdot 10^{+34} \lor \neg \left(x \leq 11000000\right):\\ \;\;\;\;\mathsf{fma}\left(z, t\_0, \cos y\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{z}, \cos y, x \cdot t\_0\right) \cdot z\\ \end{array} \end{array} \]
    (FPCore (x y z)
     :precision binary64
     (let* ((t_0 (/ (sin y) x)))
       (if (or (<= x -5e+34) (not (<= x 11000000.0)))
         (* (fma z t_0 (cos y)) x)
         (* (fma (/ x z) (cos y) (* x t_0)) z))))
    double code(double x, double y, double z) {
    	double t_0 = sin(y) / x;
    	double tmp;
    	if ((x <= -5e+34) || !(x <= 11000000.0)) {
    		tmp = fma(z, t_0, cos(y)) * x;
    	} else {
    		tmp = fma((x / z), cos(y), (x * t_0)) * z;
    	}
    	return tmp;
    }
    
    function code(x, y, z)
    	t_0 = Float64(sin(y) / x)
    	tmp = 0.0
    	if ((x <= -5e+34) || !(x <= 11000000.0))
    		tmp = Float64(fma(z, t_0, cos(y)) * x);
    	else
    		tmp = Float64(fma(Float64(x / z), cos(y), Float64(x * t_0)) * z);
    	end
    	return tmp
    end
    
    code[x_, y_, z_] := Block[{t$95$0 = N[(N[Sin[y], $MachinePrecision] / x), $MachinePrecision]}, If[Or[LessEqual[x, -5e+34], N[Not[LessEqual[x, 11000000.0]], $MachinePrecision]], N[(N[(z * t$95$0 + N[Cos[y], $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], N[(N[(N[(x / z), $MachinePrecision] * N[Cos[y], $MachinePrecision] + N[(x * t$95$0), $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := \frac{\sin y}{x}\\
    \mathbf{if}\;x \leq -5 \cdot 10^{+34} \lor \neg \left(x \leq 11000000\right):\\
    \;\;\;\;\mathsf{fma}\left(z, t\_0, \cos y\right) \cdot x\\
    
    \mathbf{else}:\\
    \;\;\;\;\mathsf{fma}\left(\frac{x}{z}, \cos y, x \cdot t\_0\right) \cdot z\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if x < -4.9999999999999998e34 or 1.1e7 < x

      1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \mathsf{fma}\left(1, \frac{\sin y \cdot z}{x}, \cos y\right) \cdot x \]
        10. lift-cos.f6499.7

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(z, \frac{\sin y}{x}, \cos y\right) \cdot x \]

      if -4.9999999999999998e34 < x < 1.1e7

      1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \mathsf{fma}\left(\frac{\cos y \cdot x}{z}, 1, \sin y\right) \cdot z \]
        11. lift-sin.f6499.8

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

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

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

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

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

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

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

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

          \[\leadsto \frac{{\left(\frac{\cos y \cdot x}{z} \cdot 1\right)}^{3} + {\sin y}^{3}}{\left(\frac{\cos y \cdot x}{z} \cdot 1\right) \cdot \left(\frac{\cos y \cdot x}{z} \cdot 1\right) + \left(\sin y \cdot \sin y - \left(\frac{\cos y \cdot x}{z} \cdot 1\right) \cdot \sin y\right)} \cdot z \]
      7. Applied rewrites64.2%

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

        \[\leadsto \left(x \cdot \left(\frac{\cos y}{z} + \frac{\sin y}{x}\right)\right) \cdot z \]
      9. Step-by-step derivation
        1. Applied rewrites99.7%

          \[\leadsto \mathsf{fma}\left(\frac{x}{z}, \cos y, x \cdot \frac{\sin y}{x}\right) \cdot z \]
      10. Recombined 2 regimes into one program.
      11. Final simplification99.7%

        \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -5 \cdot 10^{+34} \lor \neg \left(x \leq 11000000\right):\\ \;\;\;\;\mathsf{fma}\left(z, \frac{\sin y}{x}, \cos y\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{z}, \cos y, x \cdot \frac{\sin y}{x}\right) \cdot z\\ \end{array} \]
      12. Add Preprocessing

      Alternative 8: 99.2% accurate, N/A× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1 \cdot 10^{-123} \lor \neg \left(x \leq 10000000\right):\\ \;\;\;\;\mathsf{fma}\left(1, \frac{\sin y \cdot z}{x}, \cos y\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{z}, \cos y, x \cdot \frac{\sin y}{x}\right) \cdot z\\ \end{array} \end{array} \]
      (FPCore (x y z)
       :precision binary64
       (if (or (<= x -1e-123) (not (<= x 10000000.0)))
         (* (fma 1.0 (/ (* (sin y) z) x) (cos y)) x)
         (* (fma (/ x z) (cos y) (* x (/ (sin y) x))) z)))
      double code(double x, double y, double z) {
      	double tmp;
      	if ((x <= -1e-123) || !(x <= 10000000.0)) {
      		tmp = fma(1.0, ((sin(y) * z) / x), cos(y)) * x;
      	} else {
      		tmp = fma((x / z), cos(y), (x * (sin(y) / x))) * z;
      	}
      	return tmp;
      }
      
      function code(x, y, z)
      	tmp = 0.0
      	if ((x <= -1e-123) || !(x <= 10000000.0))
      		tmp = Float64(fma(1.0, Float64(Float64(sin(y) * z) / x), cos(y)) * x);
      	else
      		tmp = Float64(fma(Float64(x / z), cos(y), Float64(x * Float64(sin(y) / x))) * z);
      	end
      	return tmp
      end
      
      code[x_, y_, z_] := If[Or[LessEqual[x, -1e-123], N[Not[LessEqual[x, 10000000.0]], $MachinePrecision]], N[(N[(1.0 * N[(N[(N[Sin[y], $MachinePrecision] * z), $MachinePrecision] / x), $MachinePrecision] + N[Cos[y], $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], N[(N[(N[(x / z), $MachinePrecision] * N[Cos[y], $MachinePrecision] + N[(x * N[(N[Sin[y], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;x \leq -1 \cdot 10^{-123} \lor \neg \left(x \leq 10000000\right):\\
      \;\;\;\;\mathsf{fma}\left(1, \frac{\sin y \cdot z}{x}, \cos y\right) \cdot x\\
      
      \mathbf{else}:\\
      \;\;\;\;\mathsf{fma}\left(\frac{x}{z}, \cos y, x \cdot \frac{\sin y}{x}\right) \cdot z\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if x < -1.0000000000000001e-123 or 1e7 < x

        1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \mathsf{fma}\left(1, \frac{\sin y \cdot z}{x}, \cos y\right) \cdot x \]
          10. lift-cos.f6499.7

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

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

        if -1.0000000000000001e-123 < x < 1e7

        1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \mathsf{fma}\left(\frac{\cos y \cdot x}{z}, 1, \sin y\right) \cdot z \]
          11. lift-sin.f6499.7

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

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

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

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

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

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

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

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

            \[\leadsto \frac{{\left(\frac{\cos y \cdot x}{z} \cdot 1\right)}^{3} + {\sin y}^{3}}{\left(\frac{\cos y \cdot x}{z} \cdot 1\right) \cdot \left(\frac{\cos y \cdot x}{z} \cdot 1\right) + \left(\sin y \cdot \sin y - \left(\frac{\cos y \cdot x}{z} \cdot 1\right) \cdot \sin y\right)} \cdot z \]
        7. Applied rewrites66.1%

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

          \[\leadsto \left(x \cdot \left(\frac{\cos y}{z} + \frac{\sin y}{x}\right)\right) \cdot z \]
        9. Step-by-step derivation
          1. Applied rewrites99.7%

            \[\leadsto \mathsf{fma}\left(\frac{x}{z}, \cos y, x \cdot \frac{\sin y}{x}\right) \cdot z \]
        10. Recombined 2 regimes into one program.
        11. Final simplification99.7%

          \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1 \cdot 10^{-123} \lor \neg \left(x \leq 10000000\right):\\ \;\;\;\;\mathsf{fma}\left(1, \frac{\sin y \cdot z}{x}, \cos y\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{z}, \cos y, x \cdot \frac{\sin y}{x}\right) \cdot z\\ \end{array} \]
        12. Add Preprocessing

        Alternative 9: 99.1% accurate, N/A× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -2 \cdot 10^{+78} \lor \neg \left(z \leq 1.65 \cdot 10^{-87}\right):\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{z}, \cos y, x \cdot \frac{\sin y}{x}\right) \cdot z\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(z, \frac{\cos y}{z}, \frac{\sin y \cdot z}{x}\right) \cdot x\\ \end{array} \end{array} \]
        (FPCore (x y z)
         :precision binary64
         (if (or (<= z -2e+78) (not (<= z 1.65e-87)))
           (* (fma (/ x z) (cos y) (* x (/ (sin y) x))) z)
           (* (fma z (/ (cos y) z) (/ (* (sin y) z) x)) x)))
        double code(double x, double y, double z) {
        	double tmp;
        	if ((z <= -2e+78) || !(z <= 1.65e-87)) {
        		tmp = fma((x / z), cos(y), (x * (sin(y) / x))) * z;
        	} else {
        		tmp = fma(z, (cos(y) / z), ((sin(y) * z) / x)) * x;
        	}
        	return tmp;
        }
        
        function code(x, y, z)
        	tmp = 0.0
        	if ((z <= -2e+78) || !(z <= 1.65e-87))
        		tmp = Float64(fma(Float64(x / z), cos(y), Float64(x * Float64(sin(y) / x))) * z);
        	else
        		tmp = Float64(fma(z, Float64(cos(y) / z), Float64(Float64(sin(y) * z) / x)) * x);
        	end
        	return tmp
        end
        
        code[x_, y_, z_] := If[Or[LessEqual[z, -2e+78], N[Not[LessEqual[z, 1.65e-87]], $MachinePrecision]], N[(N[(N[(x / z), $MachinePrecision] * N[Cos[y], $MachinePrecision] + N[(x * N[(N[Sin[y], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision], N[(N[(z * N[(N[Cos[y], $MachinePrecision] / z), $MachinePrecision] + N[(N[(N[Sin[y], $MachinePrecision] * z), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;z \leq -2 \cdot 10^{+78} \lor \neg \left(z \leq 1.65 \cdot 10^{-87}\right):\\
        \;\;\;\;\mathsf{fma}\left(\frac{x}{z}, \cos y, x \cdot \frac{\sin y}{x}\right) \cdot z\\
        
        \mathbf{else}:\\
        \;\;\;\;\mathsf{fma}\left(z, \frac{\cos y}{z}, \frac{\sin y \cdot z}{x}\right) \cdot x\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if z < -2.00000000000000002e78 or 1.65e-87 < z

          1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \mathsf{fma}\left(\frac{\cos y \cdot x}{z}, 1, \sin y\right) \cdot z \]
            11. lift-sin.f6499.7

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

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

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

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

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

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

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

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

              \[\leadsto \frac{{\left(\frac{\cos y \cdot x}{z} \cdot 1\right)}^{3} + {\sin y}^{3}}{\left(\frac{\cos y \cdot x}{z} \cdot 1\right) \cdot \left(\frac{\cos y \cdot x}{z} \cdot 1\right) + \left(\sin y \cdot \sin y - \left(\frac{\cos y \cdot x}{z} \cdot 1\right) \cdot \sin y\right)} \cdot z \]
          7. Applied rewrites63.9%

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

            \[\leadsto \left(x \cdot \left(\frac{\cos y}{z} + \frac{\sin y}{x}\right)\right) \cdot z \]
          9. Step-by-step derivation
            1. Applied rewrites99.6%

              \[\leadsto \mathsf{fma}\left(\frac{x}{z}, \cos y, x \cdot \frac{\sin y}{x}\right) \cdot z \]

            if -2.00000000000000002e78 < z < 1.65e-87

            1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

                \[\leadsto \mathsf{fma}\left(1, \frac{\sin y \cdot z}{x}, \cos y\right) \cdot x \]
              10. lift-cos.f6499.7

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \mathsf{fma}\left(z, \frac{\cos y}{z}, \frac{\sin y \cdot z}{x}\right) \cdot x \]
          10. Recombined 2 regimes into one program.
          11. Final simplification99.6%

            \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -2 \cdot 10^{+78} \lor \neg \left(z \leq 1.65 \cdot 10^{-87}\right):\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{z}, \cos y, x \cdot \frac{\sin y}{x}\right) \cdot z\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(z, \frac{\cos y}{z}, \frac{\sin y \cdot z}{x}\right) \cdot x\\ \end{array} \]
          12. Add Preprocessing

          Alternative 10: 91.9% accurate, N/A× speedup?

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \mathsf{fma}\left(1, \frac{\sin y \cdot z}{x}, \cos y\right) \cdot x \]
            10. lift-cos.f6492.4

              \[\leadsto \mathsf{fma}\left(1, \frac{\sin y \cdot z}{x}, \cos y\right) \cdot x \]
          5. Applied rewrites92.4%

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

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

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

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

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

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

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

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

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

              \[\leadsto \mathsf{fma}\left(z, \frac{\cos y}{z}, \frac{\sin y \cdot z}{x}\right) \cdot x \]
            9. lift-*.f6492.2

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

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

          Reproduce

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