Graphics.Rasterific.Svg.PathConverter:segmentToBezier from rasterific-svg-0.2.3.1, C

Percentage Accurate: 99.9% → 99.9%
Time: 7.0s
Alternatives: 11
Speedup: 1.0×

Specification

?
\[\begin{array}{l} \\ \left(x + \sin y\right) + 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}

\\
\left(x + \sin y\right) + 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 11 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.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \left(x + \sin y\right) + 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}

\\
\left(x + \sin y\right) + z \cdot \cos y
\end{array}

Alternative 1: 99.9% accurate, 1.0× speedup?

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

\\
\cos y \cdot z + \left(\sin y + x\right)
\end{array}
Derivation
  1. Initial program 99.9%

    \[\left(x + \sin y\right) + z \cdot \cos y \]
  2. Add Preprocessing
  3. Final simplification99.9%

    \[\leadsto \cos y \cdot z + \left(\sin y + x\right) \]
  4. Add Preprocessing

Alternative 2: 87.0% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -14500000:\\
\;\;\;\;\mathsf{fma}\left(\cos y, z, y + x\right)\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -1.45e7

    1. Initial program 99.9%

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

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

        \[\leadsto \color{blue}{\left(y + x\right)} + z \cdot \cos y \]
      2. lower-+.f6485.0

        \[\leadsto \color{blue}{\left(y + x\right)} + z \cdot \cos y \]
    5. Applied rewrites85.0%

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

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

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

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

        \[\leadsto \color{blue}{\cos y \cdot z} + \left(y + x\right) \]
      5. lower-fma.f6485.0

        \[\leadsto \color{blue}{\mathsf{fma}\left(\cos y, z, y + x\right)} \]
    7. Applied rewrites85.0%

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

    if -1.45e7 < z < 7.7999999999999999e-19

    1. Initial program 100.0%

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

      \[\leadsto \left(x + \sin y\right) + z \cdot \color{blue}{1} \]
    4. Step-by-step derivation
      1. Applied rewrites100.0%

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

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

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

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

          \[\leadsto \color{blue}{1 \cdot z} + \left(x + \sin y\right) \]
        5. lower-fma.f64100.0

          \[\leadsto \color{blue}{\mathsf{fma}\left(1, z, x + \sin y\right)} \]
      3. Applied rewrites100.0%

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

      if 7.7999999999999999e-19 < z

      1. Initial program 99.8%

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

        \[\leadsto \color{blue}{\sin y} + z \cdot \cos y \]
      4. Step-by-step derivation
        1. lower-sin.f6493.1

          \[\leadsto \color{blue}{\sin y} + z \cdot \cos y \]
      5. Applied rewrites93.1%

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

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

    Alternative 3: 87.0% accurate, 1.0× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -14500000:\\ \;\;\;\;\mathsf{fma}\left(\cos y, z, y + x\right)\\ \mathbf{elif}\;z \leq 7.8 \cdot 10^{-19}:\\ \;\;\;\;\mathsf{fma}\left(1, z, \sin y + x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\cos y, z, \sin y\right)\\ \end{array} \end{array} \]
    (FPCore (x y z)
     :precision binary64
     (if (<= z -14500000.0)
       (fma (cos y) z (+ y x))
       (if (<= z 7.8e-19) (fma 1.0 z (+ (sin y) x)) (fma (cos y) z (sin y)))))
    double code(double x, double y, double z) {
    	double tmp;
    	if (z <= -14500000.0) {
    		tmp = fma(cos(y), z, (y + x));
    	} else if (z <= 7.8e-19) {
    		tmp = fma(1.0, z, (sin(y) + x));
    	} else {
    		tmp = fma(cos(y), z, sin(y));
    	}
    	return tmp;
    }
    
    function code(x, y, z)
    	tmp = 0.0
    	if (z <= -14500000.0)
    		tmp = fma(cos(y), z, Float64(y + x));
    	elseif (z <= 7.8e-19)
    		tmp = fma(1.0, z, Float64(sin(y) + x));
    	else
    		tmp = fma(cos(y), z, sin(y));
    	end
    	return tmp
    end
    
    code[x_, y_, z_] := If[LessEqual[z, -14500000.0], N[(N[Cos[y], $MachinePrecision] * z + N[(y + x), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 7.8e-19], N[(1.0 * z + N[(N[Sin[y], $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision], N[(N[Cos[y], $MachinePrecision] * z + N[Sin[y], $MachinePrecision]), $MachinePrecision]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    \mathbf{if}\;z \leq -14500000:\\
    \;\;\;\;\mathsf{fma}\left(\cos y, z, y + x\right)\\
    
    \mathbf{elif}\;z \leq 7.8 \cdot 10^{-19}:\\
    \;\;\;\;\mathsf{fma}\left(1, z, \sin y + x\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;\mathsf{fma}\left(\cos y, z, \sin y\right)\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 3 regimes
    2. if z < -1.45e7

      1. Initial program 99.9%

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

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

          \[\leadsto \color{blue}{\left(y + x\right)} + z \cdot \cos y \]
        2. lower-+.f6485.0

          \[\leadsto \color{blue}{\left(y + x\right)} + z \cdot \cos y \]
      5. Applied rewrites85.0%

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

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

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

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

          \[\leadsto \color{blue}{\cos y \cdot z} + \left(y + x\right) \]
        5. lower-fma.f6485.0

          \[\leadsto \color{blue}{\mathsf{fma}\left(\cos y, z, y + x\right)} \]
      7. Applied rewrites85.0%

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

      if -1.45e7 < z < 7.7999999999999999e-19

      1. Initial program 100.0%

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

        \[\leadsto \left(x + \sin y\right) + z \cdot \color{blue}{1} \]
      4. Step-by-step derivation
        1. Applied rewrites100.0%

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

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

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

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

            \[\leadsto \color{blue}{1 \cdot z} + \left(x + \sin y\right) \]
          5. lower-fma.f64100.0

            \[\leadsto \color{blue}{\mathsf{fma}\left(1, z, x + \sin y\right)} \]
        3. Applied rewrites100.0%

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

        if 7.7999999999999999e-19 < z

        1. Initial program 99.8%

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

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

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

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

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

            \[\leadsto \mathsf{fma}\left(\color{blue}{\cos y}, z, \sin y\right) \]
          5. lower-sin.f6493.1

            \[\leadsto \mathsf{fma}\left(\cos y, z, \color{blue}{\sin y}\right) \]
        5. Applied rewrites93.1%

          \[\leadsto \color{blue}{\mathsf{fma}\left(\cos y, z, \sin y\right)} \]
      5. Recombined 3 regimes into one program.
      6. Final simplification94.6%

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

      Alternative 4: 99.9% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

      Alternative 5: 76.1% accurate, 1.7× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -2.15 \cdot 10^{-23}:\\ \;\;\;\;z + x\\ \mathbf{elif}\;x \leq -7.5 \cdot 10^{-262}:\\ \;\;\;\;\cos y \cdot z\\ \mathbf{elif}\;x \leq 1.7 \cdot 10^{-16}:\\ \;\;\;\;\mathsf{fma}\left(1, z, \sin y\right)\\ \mathbf{else}:\\ \;\;\;\;z + x\\ \end{array} \end{array} \]
      (FPCore (x y z)
       :precision binary64
       (if (<= x -2.15e-23)
         (+ z x)
         (if (<= x -7.5e-262)
           (* (cos y) z)
           (if (<= x 1.7e-16) (fma 1.0 z (sin y)) (+ z x)))))
      double code(double x, double y, double z) {
      	double tmp;
      	if (x <= -2.15e-23) {
      		tmp = z + x;
      	} else if (x <= -7.5e-262) {
      		tmp = cos(y) * z;
      	} else if (x <= 1.7e-16) {
      		tmp = fma(1.0, z, sin(y));
      	} else {
      		tmp = z + x;
      	}
      	return tmp;
      }
      
      function code(x, y, z)
      	tmp = 0.0
      	if (x <= -2.15e-23)
      		tmp = Float64(z + x);
      	elseif (x <= -7.5e-262)
      		tmp = Float64(cos(y) * z);
      	elseif (x <= 1.7e-16)
      		tmp = fma(1.0, z, sin(y));
      	else
      		tmp = Float64(z + x);
      	end
      	return tmp
      end
      
      code[x_, y_, z_] := If[LessEqual[x, -2.15e-23], N[(z + x), $MachinePrecision], If[LessEqual[x, -7.5e-262], N[(N[Cos[y], $MachinePrecision] * z), $MachinePrecision], If[LessEqual[x, 1.7e-16], N[(1.0 * z + N[Sin[y], $MachinePrecision]), $MachinePrecision], N[(z + x), $MachinePrecision]]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;x \leq -2.15 \cdot 10^{-23}:\\
      \;\;\;\;z + x\\
      
      \mathbf{elif}\;x \leq -7.5 \cdot 10^{-262}:\\
      \;\;\;\;\cos y \cdot z\\
      
      \mathbf{elif}\;x \leq 1.7 \cdot 10^{-16}:\\
      \;\;\;\;\mathsf{fma}\left(1, z, \sin y\right)\\
      
      \mathbf{else}:\\
      \;\;\;\;z + x\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 3 regimes
      2. if x < -2.15000000000000001e-23 or 1.7e-16 < x

        1. Initial program 99.9%

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

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

            \[\leadsto \color{blue}{z + x} \]
          2. lower-+.f6489.8

            \[\leadsto \color{blue}{z + x} \]
        5. Applied rewrites89.8%

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

        if -2.15000000000000001e-23 < x < -7.5000000000000002e-262

        1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \color{blue}{\mathsf{fma}\left(\cos y, z, \sin y\right) + x} \]
          2. flip-+N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto z \cdot \color{blue}{\cos y} \]
        11. Step-by-step derivation
          1. Applied rewrites67.5%

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

          if -7.5000000000000002e-262 < x < 1.7e-16

          1. Initial program 99.9%

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

            \[\leadsto \left(x + \sin y\right) + z \cdot \color{blue}{1} \]
          4. Step-by-step derivation
            1. Applied rewrites82.0%

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

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

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

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

                \[\leadsto \color{blue}{1 \cdot z} + \left(x + \sin y\right) \]
              5. lower-fma.f6482.0

                \[\leadsto \color{blue}{\mathsf{fma}\left(1, z, x + \sin y\right)} \]
            3. Applied rewrites82.0%

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

              \[\leadsto \mathsf{fma}\left(1, z, \color{blue}{\sin y}\right) \]
            5. Step-by-step derivation
              1. lower-sin.f6479.6

                \[\leadsto \mathsf{fma}\left(1, z, \color{blue}{\sin y}\right) \]
            6. Applied rewrites79.6%

              \[\leadsto \mathsf{fma}\left(1, z, \color{blue}{\sin y}\right) \]
          5. Recombined 3 regimes into one program.
          6. Add Preprocessing

          Alternative 6: 88.7% accurate, 1.7× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -14500000:\\ \;\;\;\;\mathsf{fma}\left(\cos y, z, y + x\right)\\ \mathbf{elif}\;z \leq 5.3 \cdot 10^{+42}:\\ \;\;\;\;\mathsf{fma}\left(1, z, \sin y + x\right)\\ \mathbf{else}:\\ \;\;\;\;\cos y \cdot z\\ \end{array} \end{array} \]
          (FPCore (x y z)
           :precision binary64
           (if (<= z -14500000.0)
             (fma (cos y) z (+ y x))
             (if (<= z 5.3e+42) (fma 1.0 z (+ (sin y) x)) (* (cos y) z))))
          double code(double x, double y, double z) {
          	double tmp;
          	if (z <= -14500000.0) {
          		tmp = fma(cos(y), z, (y + x));
          	} else if (z <= 5.3e+42) {
          		tmp = fma(1.0, z, (sin(y) + x));
          	} else {
          		tmp = cos(y) * z;
          	}
          	return tmp;
          }
          
          function code(x, y, z)
          	tmp = 0.0
          	if (z <= -14500000.0)
          		tmp = fma(cos(y), z, Float64(y + x));
          	elseif (z <= 5.3e+42)
          		tmp = fma(1.0, z, Float64(sin(y) + x));
          	else
          		tmp = Float64(cos(y) * z);
          	end
          	return tmp
          end
          
          code[x_, y_, z_] := If[LessEqual[z, -14500000.0], N[(N[Cos[y], $MachinePrecision] * z + N[(y + x), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 5.3e+42], N[(1.0 * z + N[(N[Sin[y], $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision], N[(N[Cos[y], $MachinePrecision] * z), $MachinePrecision]]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          \mathbf{if}\;z \leq -14500000:\\
          \;\;\;\;\mathsf{fma}\left(\cos y, z, y + x\right)\\
          
          \mathbf{elif}\;z \leq 5.3 \cdot 10^{+42}:\\
          \;\;\;\;\mathsf{fma}\left(1, z, \sin y + x\right)\\
          
          \mathbf{else}:\\
          \;\;\;\;\cos y \cdot z\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 3 regimes
          2. if z < -1.45e7

            1. Initial program 99.9%

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

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

                \[\leadsto \color{blue}{\left(y + x\right)} + z \cdot \cos y \]
              2. lower-+.f6485.0

                \[\leadsto \color{blue}{\left(y + x\right)} + z \cdot \cos y \]
            5. Applied rewrites85.0%

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

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

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

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

                \[\leadsto \color{blue}{\cos y \cdot z} + \left(y + x\right) \]
              5. lower-fma.f6485.0

                \[\leadsto \color{blue}{\mathsf{fma}\left(\cos y, z, y + x\right)} \]
            7. Applied rewrites85.0%

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

            if -1.45e7 < z < 5.30000000000000028e42

            1. Initial program 100.0%

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

              \[\leadsto \left(x + \sin y\right) + z \cdot \color{blue}{1} \]
            4. Step-by-step derivation
              1. Applied rewrites97.0%

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

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

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

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

                  \[\leadsto \color{blue}{1 \cdot z} + \left(x + \sin y\right) \]
                5. lower-fma.f6497.0

                  \[\leadsto \color{blue}{\mathsf{fma}\left(1, z, x + \sin y\right)} \]
              3. Applied rewrites97.0%

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

              if 5.30000000000000028e42 < z

              1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto \color{blue}{\mathsf{fma}\left(\cos y, z, \sin y\right) + x} \]
                2. flip-+N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto \cos y \cdot \color{blue}{z} \]
              12. Recombined 3 regimes into one program.
              13. Final simplification93.7%

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

              Alternative 7: 88.5% accurate, 1.7× speedup?

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

                1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto \color{blue}{\mathsf{fma}\left(\cos y, z, \sin y\right) + x} \]
                  2. flip-+N/A

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto \left({\left(\mathsf{fma}\left(z, \cos y, \sin y\right)\right)}^{2} - x \cdot x\right) \cdot \color{blue}{{\left(\mathsf{fma}\left(\cos y, z, \sin y\right) - x\right)}^{-1}} \]
                6. Applied rewrites37.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto z \cdot \color{blue}{\cos y} \]
                11. Step-by-step derivation
                  1. Applied rewrites90.1%

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

                  if -6.99999999999999972e92 < z < 5.30000000000000028e42

                  1. Initial program 100.0%

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

                    \[\leadsto \left(x + \sin y\right) + z \cdot \color{blue}{1} \]
                  4. Step-by-step derivation
                    1. Applied rewrites94.8%

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

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

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

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

                        \[\leadsto \color{blue}{1 \cdot z} + \left(x + \sin y\right) \]
                      5. lower-fma.f6494.8

                        \[\leadsto \color{blue}{\mathsf{fma}\left(1, z, x + \sin y\right)} \]
                    3. Applied rewrites94.8%

                      \[\leadsto \color{blue}{\mathsf{fma}\left(1, z, x + \sin y\right)} \]
                  5. Recombined 2 regimes into one program.
                  6. Final simplification92.9%

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

                  Alternative 8: 70.3% accurate, 1.8× speedup?

                  \[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos y \cdot z\\ \mathbf{if}\;z \leq -7 \cdot 10^{+92}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq 7.8 \cdot 10^{-19}:\\ \;\;\;\;z + x\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
                  (FPCore (x y z)
                   :precision binary64
                   (let* ((t_0 (* (cos y) z)))
                     (if (<= z -7e+92) t_0 (if (<= z 7.8e-19) (+ z x) t_0))))
                  double code(double x, double y, double z) {
                  	double t_0 = cos(y) * z;
                  	double tmp;
                  	if (z <= -7e+92) {
                  		tmp = t_0;
                  	} else if (z <= 7.8e-19) {
                  		tmp = z + x;
                  	} else {
                  		tmp = t_0;
                  	}
                  	return tmp;
                  }
                  
                  real(8) function code(x, y, z)
                      real(8), intent (in) :: x
                      real(8), intent (in) :: y
                      real(8), intent (in) :: z
                      real(8) :: t_0
                      real(8) :: tmp
                      t_0 = cos(y) * z
                      if (z <= (-7d+92)) then
                          tmp = t_0
                      else if (z <= 7.8d-19) then
                          tmp = z + x
                      else
                          tmp = t_0
                      end if
                      code = tmp
                  end function
                  
                  public static double code(double x, double y, double z) {
                  	double t_0 = Math.cos(y) * z;
                  	double tmp;
                  	if (z <= -7e+92) {
                  		tmp = t_0;
                  	} else if (z <= 7.8e-19) {
                  		tmp = z + x;
                  	} else {
                  		tmp = t_0;
                  	}
                  	return tmp;
                  }
                  
                  def code(x, y, z):
                  	t_0 = math.cos(y) * z
                  	tmp = 0
                  	if z <= -7e+92:
                  		tmp = t_0
                  	elif z <= 7.8e-19:
                  		tmp = z + x
                  	else:
                  		tmp = t_0
                  	return tmp
                  
                  function code(x, y, z)
                  	t_0 = Float64(cos(y) * z)
                  	tmp = 0.0
                  	if (z <= -7e+92)
                  		tmp = t_0;
                  	elseif (z <= 7.8e-19)
                  		tmp = Float64(z + x);
                  	else
                  		tmp = t_0;
                  	end
                  	return tmp
                  end
                  
                  function tmp_2 = code(x, y, z)
                  	t_0 = cos(y) * z;
                  	tmp = 0.0;
                  	if (z <= -7e+92)
                  		tmp = t_0;
                  	elseif (z <= 7.8e-19)
                  		tmp = z + x;
                  	else
                  		tmp = t_0;
                  	end
                  	tmp_2 = tmp;
                  end
                  
                  code[x_, y_, z_] := Block[{t$95$0 = N[(N[Cos[y], $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[z, -7e+92], t$95$0, If[LessEqual[z, 7.8e-19], N[(z + x), $MachinePrecision], t$95$0]]]
                  
                  \begin{array}{l}
                  
                  \\
                  \begin{array}{l}
                  t_0 := \cos y \cdot z\\
                  \mathbf{if}\;z \leq -7 \cdot 10^{+92}:\\
                  \;\;\;\;t\_0\\
                  
                  \mathbf{elif}\;z \leq 7.8 \cdot 10^{-19}:\\
                  \;\;\;\;z + x\\
                  
                  \mathbf{else}:\\
                  \;\;\;\;t\_0\\
                  
                  
                  \end{array}
                  \end{array}
                  
                  Derivation
                  1. Split input into 2 regimes
                  2. if z < -6.99999999999999972e92 or 7.7999999999999999e-19 < z

                    1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

                        \[\leadsto \color{blue}{\mathsf{fma}\left(\cos y, z, \sin y\right) + x} \]
                      2. flip-+N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                      \[\leadsto z \cdot \color{blue}{\cos y} \]
                    11. Step-by-step derivation
                      1. Applied rewrites86.2%

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

                      if -6.99999999999999972e92 < z < 7.7999999999999999e-19

                      1. Initial program 100.0%

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

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

                          \[\leadsto \color{blue}{z + x} \]
                        2. lower-+.f6473.6

                          \[\leadsto \color{blue}{z + x} \]
                      5. Applied rewrites73.6%

                        \[\leadsto \color{blue}{z + x} \]
                    12. Recombined 2 regimes into one program.
                    13. Add Preprocessing

                    Alternative 9: 70.3% accurate, 6.4× speedup?

                    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -11:\\ \;\;\;\;z + x\\ \mathbf{elif}\;y \leq 7500:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-0.5 \cdot y, z, 1\right), y, z + x\right)\\ \mathbf{else}:\\ \;\;\;\;z + x\\ \end{array} \end{array} \]
                    (FPCore (x y z)
                     :precision binary64
                     (if (<= y -11.0)
                       (+ z x)
                       (if (<= y 7500.0) (fma (fma (* -0.5 y) z 1.0) y (+ z x)) (+ z x))))
                    double code(double x, double y, double z) {
                    	double tmp;
                    	if (y <= -11.0) {
                    		tmp = z + x;
                    	} else if (y <= 7500.0) {
                    		tmp = fma(fma((-0.5 * y), z, 1.0), y, (z + x));
                    	} else {
                    		tmp = z + x;
                    	}
                    	return tmp;
                    }
                    
                    function code(x, y, z)
                    	tmp = 0.0
                    	if (y <= -11.0)
                    		tmp = Float64(z + x);
                    	elseif (y <= 7500.0)
                    		tmp = fma(fma(Float64(-0.5 * y), z, 1.0), y, Float64(z + x));
                    	else
                    		tmp = Float64(z + x);
                    	end
                    	return tmp
                    end
                    
                    code[x_, y_, z_] := If[LessEqual[y, -11.0], N[(z + x), $MachinePrecision], If[LessEqual[y, 7500.0], N[(N[(N[(-0.5 * y), $MachinePrecision] * z + 1.0), $MachinePrecision] * y + N[(z + x), $MachinePrecision]), $MachinePrecision], N[(z + x), $MachinePrecision]]]
                    
                    \begin{array}{l}
                    
                    \\
                    \begin{array}{l}
                    \mathbf{if}\;y \leq -11:\\
                    \;\;\;\;z + x\\
                    
                    \mathbf{elif}\;y \leq 7500:\\
                    \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-0.5 \cdot y, z, 1\right), y, z + x\right)\\
                    
                    \mathbf{else}:\\
                    \;\;\;\;z + x\\
                    
                    
                    \end{array}
                    \end{array}
                    
                    Derivation
                    1. Split input into 2 regimes
                    2. if y < -11 or 7500 < y

                      1. Initial program 99.8%

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

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

                          \[\leadsto \color{blue}{z + x} \]
                        2. lower-+.f6442.8

                          \[\leadsto \color{blue}{z + x} \]
                      5. Applied rewrites42.8%

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

                      if -11 < y < 7500

                      1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    Alternative 10: 69.9% accurate, 11.1× speedup?

                    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -1.05 \cdot 10^{+61}:\\ \;\;\;\;z + x\\ \mathbf{elif}\;y \leq 4.6 \cdot 10^{+65}:\\ \;\;\;\;\left(y + x\right) + z\\ \mathbf{else}:\\ \;\;\;\;z + x\\ \end{array} \end{array} \]
                    (FPCore (x y z)
                     :precision binary64
                     (if (<= y -1.05e+61) (+ z x) (if (<= y 4.6e+65) (+ (+ y x) z) (+ z x))))
                    double code(double x, double y, double z) {
                    	double tmp;
                    	if (y <= -1.05e+61) {
                    		tmp = z + x;
                    	} else if (y <= 4.6e+65) {
                    		tmp = (y + x) + z;
                    	} else {
                    		tmp = z + x;
                    	}
                    	return tmp;
                    }
                    
                    real(8) function code(x, y, z)
                        real(8), intent (in) :: x
                        real(8), intent (in) :: y
                        real(8), intent (in) :: z
                        real(8) :: tmp
                        if (y <= (-1.05d+61)) then
                            tmp = z + x
                        else if (y <= 4.6d+65) then
                            tmp = (y + x) + z
                        else
                            tmp = z + x
                        end if
                        code = tmp
                    end function
                    
                    public static double code(double x, double y, double z) {
                    	double tmp;
                    	if (y <= -1.05e+61) {
                    		tmp = z + x;
                    	} else if (y <= 4.6e+65) {
                    		tmp = (y + x) + z;
                    	} else {
                    		tmp = z + x;
                    	}
                    	return tmp;
                    }
                    
                    def code(x, y, z):
                    	tmp = 0
                    	if y <= -1.05e+61:
                    		tmp = z + x
                    	elif y <= 4.6e+65:
                    		tmp = (y + x) + z
                    	else:
                    		tmp = z + x
                    	return tmp
                    
                    function code(x, y, z)
                    	tmp = 0.0
                    	if (y <= -1.05e+61)
                    		tmp = Float64(z + x);
                    	elseif (y <= 4.6e+65)
                    		tmp = Float64(Float64(y + x) + z);
                    	else
                    		tmp = Float64(z + x);
                    	end
                    	return tmp
                    end
                    
                    function tmp_2 = code(x, y, z)
                    	tmp = 0.0;
                    	if (y <= -1.05e+61)
                    		tmp = z + x;
                    	elseif (y <= 4.6e+65)
                    		tmp = (y + x) + z;
                    	else
                    		tmp = z + x;
                    	end
                    	tmp_2 = tmp;
                    end
                    
                    code[x_, y_, z_] := If[LessEqual[y, -1.05e+61], N[(z + x), $MachinePrecision], If[LessEqual[y, 4.6e+65], N[(N[(y + x), $MachinePrecision] + z), $MachinePrecision], N[(z + x), $MachinePrecision]]]
                    
                    \begin{array}{l}
                    
                    \\
                    \begin{array}{l}
                    \mathbf{if}\;y \leq -1.05 \cdot 10^{+61}:\\
                    \;\;\;\;z + x\\
                    
                    \mathbf{elif}\;y \leq 4.6 \cdot 10^{+65}:\\
                    \;\;\;\;\left(y + x\right) + z\\
                    
                    \mathbf{else}:\\
                    \;\;\;\;z + x\\
                    
                    
                    \end{array}
                    \end{array}
                    
                    Derivation
                    1. Split input into 2 regimes
                    2. if y < -1.0500000000000001e61 or 4.6e65 < y

                      1. Initial program 99.8%

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

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

                          \[\leadsto \color{blue}{z + x} \]
                        2. lower-+.f6443.2

                          \[\leadsto \color{blue}{z + x} \]
                      5. Applied rewrites43.2%

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

                      if -1.0500000000000001e61 < y < 4.6e65

                      1. Initial program 100.0%

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

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

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

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

                          \[\leadsto \color{blue}{\left(y + x\right)} + z \]
                        4. lower-+.f6486.5

                          \[\leadsto \color{blue}{\left(y + x\right)} + z \]
                      5. Applied rewrites86.5%

                        \[\leadsto \color{blue}{\left(y + x\right) + z} \]
                    3. Recombined 2 regimes into one program.
                    4. Add Preprocessing

                    Alternative 11: 66.7% accurate, 53.0× speedup?

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

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

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

                        \[\leadsto \color{blue}{z + x} \]
                      2. lower-+.f6468.3

                        \[\leadsto \color{blue}{z + x} \]
                    5. Applied rewrites68.3%

                      \[\leadsto \color{blue}{z + x} \]
                    6. Add Preprocessing

                    Reproduce

                    ?
                    herbie shell --seed 2024296 
                    (FPCore (x y z)
                      :name "Graphics.Rasterific.Svg.PathConverter:segmentToBezier from rasterific-svg-0.2.3.1, C"
                      :precision binary64
                      (+ (+ x (sin y)) (* z (cos y))))