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

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

Specification

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

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

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

Alternative 1: 99.8% accurate, 1.0× speedup?

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

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

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

Alternative 2: 99.8% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 84.3% accurate, 1.8× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -1.8e-40

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto 1 \cdot z + \color{blue}{x \cdot \sin y} \]
        3. *-lft-identityN/A

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

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

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

          \[\leadsto \color{blue}{\sin y \cdot x} + z \]
        7. lower-fma.f6488.9

          \[\leadsto \color{blue}{\mathsf{fma}\left(\sin y, x, z\right)} \]
      3. Applied egg-rr88.9%

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

      if -1.8e-40 < x < 3.3000000000000001e87

      1. Initial program 99.8%

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

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

          \[\leadsto \color{blue}{z \cdot \cos y} \]
        2. lower-cos.f6482.1

          \[\leadsto z \cdot \color{blue}{\cos y} \]
      5. Simplified82.1%

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

      if 3.3000000000000001e87 < x

      1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto 1 \cdot z + \color{blue}{x \cdot \sin y} \]
          3. *-lft-identityN/A

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

            \[\leadsto \color{blue}{x \cdot \sin y + z} \]
          5. lower-+.f6492.2

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

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

            \[\leadsto \color{blue}{\sin y \cdot x} + z \]
          8. lift-*.f6492.2

            \[\leadsto \color{blue}{\sin y \cdot x} + z \]
        3. Applied egg-rr92.2%

          \[\leadsto \color{blue}{\sin y \cdot x + z} \]
      7. Recombined 3 regimes into one program.
      8. Final simplification85.8%

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

      Alternative 4: 84.1% accurate, 1.8× speedup?

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

        1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto 1 \cdot z + \color{blue}{x \cdot \sin y} \]
            3. *-lft-identityN/A

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

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

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

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

              \[\leadsto \color{blue}{\mathsf{fma}\left(\sin y, x, z\right)} \]
          3. Applied egg-rr90.3%

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

          if -3.10000000000000011e-40 < x < 2.6999999999999999e93

          1. Initial program 99.8%

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

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

              \[\leadsto \color{blue}{z \cdot \cos y} \]
            2. lower-cos.f6482.1

              \[\leadsto z \cdot \color{blue}{\cos y} \]
          5. Simplified82.1%

            \[\leadsto \color{blue}{z \cdot \cos y} \]
        7. Recombined 2 regimes into one program.
        8. Add Preprocessing

        Alternative 5: 73.7% accurate, 1.8× speedup?

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

          1. Initial program 99.9%

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

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

              \[\leadsto \color{blue}{x \cdot \sin y} \]
            2. lower-sin.f6475.9

              \[\leadsto x \cdot \color{blue}{\sin y} \]
          5. Simplified75.9%

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

          if -2.8999999999999998e30 < x < 1.25e97

          1. Initial program 99.8%

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

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

              \[\leadsto \color{blue}{z \cdot \cos y} \]
            2. lower-cos.f6481.4

              \[\leadsto z \cdot \color{blue}{\cos y} \]
          5. Simplified81.4%

            \[\leadsto \color{blue}{z \cdot \cos y} \]
        3. Recombined 2 regimes into one program.
        4. Add Preprocessing

        Alternative 6: 75.1% accurate, 1.8× speedup?

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

          1. Initial program 99.7%

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

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

              \[\leadsto \color{blue}{x \cdot \sin y} \]
            2. lower-sin.f6450.4

              \[\leadsto x \cdot \color{blue}{\sin y} \]
          5. Simplified50.4%

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

          if -0.92000000000000004 < y < 0.450000000000000011

          1. Initial program 100.0%

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

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

              \[\leadsto x \cdot \sin y + \color{blue}{\left({y}^{2} \cdot \left(\frac{-1}{2} \cdot z + {y}^{2} \cdot \left(\frac{-1}{720} \cdot \left({y}^{2} \cdot z\right) + \frac{1}{24} \cdot z\right)\right) + z\right)} \]
          5. Simplified100.0%

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

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

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

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

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

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

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

              \[\leadsto x \cdot \color{blue}{\mathsf{fma}\left({y}^{2} \cdot \left(\frac{1}{120} + \frac{-1}{5040} \cdot {y}^{2}\right) - \frac{1}{6}, {y}^{2} \cdot y, y\right)} + \mathsf{fma}\left(z \cdot \left(y \cdot y\right), \mathsf{fma}\left(y \cdot y, \mathsf{fma}\left(y, y \cdot \frac{-1}{720}, \frac{1}{24}\right), \frac{-1}{2}\right), z\right) \]
          8. Simplified99.9%

            \[\leadsto x \cdot \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(y \cdot y, \mathsf{fma}\left(y \cdot y, -0.0001984126984126984, 0.008333333333333333\right), -0.16666666666666666\right), y \cdot \left(y \cdot y\right), y\right)} + \mathsf{fma}\left(z \cdot \left(y \cdot y\right), \mathsf{fma}\left(y \cdot y, \mathsf{fma}\left(y, y \cdot -0.001388888888888889, 0.041666666666666664\right), -0.5\right), z\right) \]
        3. Recombined 2 regimes into one program.
        4. Add Preprocessing

        Alternative 7: 40.3% accurate, 11.9× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1.14 \cdot 10^{+55}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;x \leq 3.8 \cdot 10^{+85}:\\ \;\;\;\;z\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \end{array} \]
        (FPCore (x y z)
         :precision binary64
         (if (<= x -1.14e+55) (* x y) (if (<= x 3.8e+85) z (* x y))))
        double code(double x, double y, double z) {
        	double tmp;
        	if (x <= -1.14e+55) {
        		tmp = x * y;
        	} else if (x <= 3.8e+85) {
        		tmp = z;
        	} else {
        		tmp = x * y;
        	}
        	return tmp;
        }
        
        real(8) function code(x, y, z)
            real(8), intent (in) :: x
            real(8), intent (in) :: y
            real(8), intent (in) :: z
            real(8) :: tmp
            if (x <= (-1.14d+55)) then
                tmp = x * y
            else if (x <= 3.8d+85) then
                tmp = z
            else
                tmp = x * y
            end if
            code = tmp
        end function
        
        public static double code(double x, double y, double z) {
        	double tmp;
        	if (x <= -1.14e+55) {
        		tmp = x * y;
        	} else if (x <= 3.8e+85) {
        		tmp = z;
        	} else {
        		tmp = x * y;
        	}
        	return tmp;
        }
        
        def code(x, y, z):
        	tmp = 0
        	if x <= -1.14e+55:
        		tmp = x * y
        	elif x <= 3.8e+85:
        		tmp = z
        	else:
        		tmp = x * y
        	return tmp
        
        function code(x, y, z)
        	tmp = 0.0
        	if (x <= -1.14e+55)
        		tmp = Float64(x * y);
        	elseif (x <= 3.8e+85)
        		tmp = z;
        	else
        		tmp = Float64(x * y);
        	end
        	return tmp
        end
        
        function tmp_2 = code(x, y, z)
        	tmp = 0.0;
        	if (x <= -1.14e+55)
        		tmp = x * y;
        	elseif (x <= 3.8e+85)
        		tmp = z;
        	else
        		tmp = x * y;
        	end
        	tmp_2 = tmp;
        end
        
        code[x_, y_, z_] := If[LessEqual[x, -1.14e+55], N[(x * y), $MachinePrecision], If[LessEqual[x, 3.8e+85], z, N[(x * y), $MachinePrecision]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;x \leq -1.14 \cdot 10^{+55}:\\
        \;\;\;\;x \cdot y\\
        
        \mathbf{elif}\;x \leq 3.8 \cdot 10^{+85}:\\
        \;\;\;\;z\\
        
        \mathbf{else}:\\
        \;\;\;\;x \cdot y\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if x < -1.1399999999999999e55 or 3.79999999999999992e85 < x

          1. Initial program 99.9%

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

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

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

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

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

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

            \[\leadsto \color{blue}{x \cdot y} \]
          7. Step-by-step derivation
            1. lower-*.f6432.9

              \[\leadsto \color{blue}{x \cdot y} \]
          8. Simplified32.9%

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

          if -1.1399999999999999e55 < x < 3.79999999999999992e85

          1. Initial program 99.8%

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

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

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

              \[\leadsto z \cdot \color{blue}{\cos y} \]
          5. Simplified80.8%

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

            \[\leadsto z \cdot \color{blue}{1} \]
          7. Step-by-step derivation
            1. Simplified48.6%

              \[\leadsto z \cdot \color{blue}{1} \]
            2. Step-by-step derivation
              1. *-rgt-identity48.6

                \[\leadsto \color{blue}{z} \]
            3. Applied egg-rr48.6%

              \[\leadsto \color{blue}{z} \]
          8. Recombined 2 regimes into one program.
          9. Add Preprocessing

          Alternative 8: 51.9% accurate, 30.6× speedup?

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

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

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

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

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

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

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

          Alternative 9: 38.3% accurate, 214.0× speedup?

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

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

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

              \[\leadsto \color{blue}{z \cdot \cos y} \]
            2. lower-cos.f6459.1

              \[\leadsto z \cdot \color{blue}{\cos y} \]
          5. Simplified59.1%

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

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

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

                \[\leadsto \color{blue}{z} \]
            3. Applied egg-rr35.8%

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

            Reproduce

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