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

Percentage Accurate: 99.9% → 99.9%
Time: 7.0s
Alternatives: 9
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 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.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} \\ \mathsf{fma}\left(\cos y, z, \sin y + x\right) \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 fma(cos(y), z, Float64(sin(y) + x))
end
code[x_, y_, z_] := N[(N[Cos[y], $MachinePrecision] * z + N[(N[Sin[y], $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\mathsf{fma}\left(\cos y, z, \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. Step-by-step derivation
    1. lift-+.f64N/A

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

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

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

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

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

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

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

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

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

Alternative 2: 94.9% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.36 \cdot 10^{-11} \lor \neg \left(x \leq 4.3 \cdot 10^{-48}\right):\\
\;\;\;\;\left(-x\right) \cdot \mathsf{fma}\left(\frac{\cos y \cdot z}{x}, -1, -1\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.36e-11 or 4.3e-48 < x

    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. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(-x\right) \cdot \mathsf{fma}\left(\frac{z \cdot \cos y}{x}, -1, -1\right) \]
    9. Step-by-step derivation
      1. Applied rewrites98.8%

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

      if -1.36e-11 < x < 4.3e-48

      1. Initial program 99.9%

        \[\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.f6497.1

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

        \[\leadsto \color{blue}{\sin y} + z \cdot \cos y \]
    10. Recombined 2 regimes into one program.
    11. Final simplification98.1%

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

    Alternative 3: 94.9% accurate, 1.0× speedup?

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

      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. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(-x\right) \cdot \mathsf{fma}\left(\frac{z \cdot \cos y}{x}, -1, -1\right) \]
      9. Step-by-step derivation
        1. Applied rewrites98.8%

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

        if -1.36e-11 < x < 4.3e-48

        1. Initial program 99.9%

          \[\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.f6497.1

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

          \[\leadsto \color{blue}{\mathsf{fma}\left(\cos y, z, \sin y\right)} \]
      10. Recombined 2 regimes into one program.
      11. Final simplification98.1%

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

      Alternative 4: 92.4% accurate, 1.4× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos y \cdot z\\ t_1 := \left(-x\right) \cdot \mathsf{fma}\left(\frac{t\_0}{x}, -1, -1\right)\\ \mathbf{if}\;z \leq -5.3 \cdot 10^{+151}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq -520:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;z \leq 3.8 \cdot 10^{-24}:\\ \;\;\;\;\mathsf{fma}\left(1, z, \sin y + x\right)\\ \mathbf{elif}\;z \leq 2.05 \cdot 10^{+117}:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
      (FPCore (x y z)
       :precision binary64
       (let* ((t_0 (* (cos y) z)) (t_1 (* (- x) (fma (/ t_0 x) -1.0 -1.0))))
         (if (<= z -5.3e+151)
           t_0
           (if (<= z -520.0)
             t_1
             (if (<= z 3.8e-24)
               (fma 1.0 z (+ (sin y) x))
               (if (<= z 2.05e+117) t_1 t_0))))))
      double code(double x, double y, double z) {
      	double t_0 = cos(y) * z;
      	double t_1 = -x * fma((t_0 / x), -1.0, -1.0);
      	double tmp;
      	if (z <= -5.3e+151) {
      		tmp = t_0;
      	} else if (z <= -520.0) {
      		tmp = t_1;
      	} else if (z <= 3.8e-24) {
      		tmp = fma(1.0, z, (sin(y) + x));
      	} else if (z <= 2.05e+117) {
      		tmp = t_1;
      	} else {
      		tmp = t_0;
      	}
      	return tmp;
      }
      
      function code(x, y, z)
      	t_0 = Float64(cos(y) * z)
      	t_1 = Float64(Float64(-x) * fma(Float64(t_0 / x), -1.0, -1.0))
      	tmp = 0.0
      	if (z <= -5.3e+151)
      		tmp = t_0;
      	elseif (z <= -520.0)
      		tmp = t_1;
      	elseif (z <= 3.8e-24)
      		tmp = fma(1.0, z, Float64(sin(y) + x));
      	elseif (z <= 2.05e+117)
      		tmp = t_1;
      	else
      		tmp = t_0;
      	end
      	return tmp
      end
      
      code[x_, y_, z_] := Block[{t$95$0 = N[(N[Cos[y], $MachinePrecision] * z), $MachinePrecision]}, Block[{t$95$1 = N[((-x) * N[(N[(t$95$0 / x), $MachinePrecision] * -1.0 + -1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -5.3e+151], t$95$0, If[LessEqual[z, -520.0], t$95$1, If[LessEqual[z, 3.8e-24], N[(1.0 * z + N[(N[Sin[y], $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 2.05e+117], t$95$1, t$95$0]]]]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      t_0 := \cos y \cdot z\\
      t_1 := \left(-x\right) \cdot \mathsf{fma}\left(\frac{t\_0}{x}, -1, -1\right)\\
      \mathbf{if}\;z \leq -5.3 \cdot 10^{+151}:\\
      \;\;\;\;t\_0\\
      
      \mathbf{elif}\;z \leq -520:\\
      \;\;\;\;t\_1\\
      
      \mathbf{elif}\;z \leq 3.8 \cdot 10^{-24}:\\
      \;\;\;\;\mathsf{fma}\left(1, z, \sin y + x\right)\\
      
      \mathbf{elif}\;z \leq 2.05 \cdot 10^{+117}:\\
      \;\;\;\;t\_1\\
      
      \mathbf{else}:\\
      \;\;\;\;t\_0\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 3 regimes
      2. if z < -5.29999999999999999e151 or 2.05e117 < 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. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \color{blue}{\cos y} \cdot z \]
        7. Applied rewrites93.4%

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

        if -5.29999999999999999e151 < z < -520 or 3.80000000000000026e-24 < z < 2.05e117

        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. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \left(-x\right) \cdot \mathsf{fma}\left(\frac{z \cdot \cos y}{x}, -1, -1\right) \]
        9. Step-by-step derivation
          1. Applied rewrites95.9%

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

          if -520 < z < 3.80000000000000026e-24

          1. Initial program 100.0%

            \[\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. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

          Alternative 5: 74.8% accurate, 1.6× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos y \cdot z\\ \mathbf{if}\;x \leq -3.2:\\ \;\;\;\;z + x\\ \mathbf{elif}\;x \leq -2.6 \cdot 10^{-197}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq 1.25 \cdot 10^{-305}:\\ \;\;\;\;\mathsf{fma}\left(1, z, \sin y\right)\\ \mathbf{elif}\;x \leq 2.6 \cdot 10^{-49}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;z + x\\ \end{array} \end{array} \]
          (FPCore (x y z)
           :precision binary64
           (let* ((t_0 (* (cos y) z)))
             (if (<= x -3.2)
               (+ z x)
               (if (<= x -2.6e-197)
                 t_0
                 (if (<= x 1.25e-305)
                   (fma 1.0 z (sin y))
                   (if (<= x 2.6e-49) t_0 (+ z x)))))))
          double code(double x, double y, double z) {
          	double t_0 = cos(y) * z;
          	double tmp;
          	if (x <= -3.2) {
          		tmp = z + x;
          	} else if (x <= -2.6e-197) {
          		tmp = t_0;
          	} else if (x <= 1.25e-305) {
          		tmp = fma(1.0, z, sin(y));
          	} else if (x <= 2.6e-49) {
          		tmp = t_0;
          	} else {
          		tmp = z + x;
          	}
          	return tmp;
          }
          
          function code(x, y, z)
          	t_0 = Float64(cos(y) * z)
          	tmp = 0.0
          	if (x <= -3.2)
          		tmp = Float64(z + x);
          	elseif (x <= -2.6e-197)
          		tmp = t_0;
          	elseif (x <= 1.25e-305)
          		tmp = fma(1.0, z, sin(y));
          	elseif (x <= 2.6e-49)
          		tmp = t_0;
          	else
          		tmp = Float64(z + x);
          	end
          	return tmp
          end
          
          code[x_, y_, z_] := Block[{t$95$0 = N[(N[Cos[y], $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[x, -3.2], N[(z + x), $MachinePrecision], If[LessEqual[x, -2.6e-197], t$95$0, If[LessEqual[x, 1.25e-305], N[(1.0 * z + N[Sin[y], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.6e-49], t$95$0, N[(z + x), $MachinePrecision]]]]]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          t_0 := \cos y \cdot z\\
          \mathbf{if}\;x \leq -3.2:\\
          \;\;\;\;z + x\\
          
          \mathbf{elif}\;x \leq -2.6 \cdot 10^{-197}:\\
          \;\;\;\;t\_0\\
          
          \mathbf{elif}\;x \leq 1.25 \cdot 10^{-305}:\\
          \;\;\;\;\mathsf{fma}\left(1, z, \sin y\right)\\
          
          \mathbf{elif}\;x \leq 2.6 \cdot 10^{-49}:\\
          \;\;\;\;t\_0\\
          
          \mathbf{else}:\\
          \;\;\;\;z + x\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 3 regimes
          2. if x < -3.2000000000000002 or 2.59999999999999995e-49 < 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-+.f6487.1

                \[\leadsto \color{blue}{z + x} \]
            5. Applied rewrites87.1%

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

            if -3.2000000000000002 < x < -2.6000000000000001e-197 or 1.24999999999999996e-305 < x < 2.59999999999999995e-49

            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. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

                \[\leadsto \color{blue}{\cos y \cdot z} \]
              3. lower-cos.f6471.0

                \[\leadsto \color{blue}{\cos y} \cdot z \]
            7. Applied rewrites71.0%

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

            if -2.6000000000000001e-197 < x < 1.24999999999999996e-305

            1. Initial program 99.9%

              \[\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.f6499.9

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

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

              \[\leadsto \mathsf{fma}\left(1, z, \sin y\right) \]
            7. Step-by-step derivation
              1. Applied rewrites87.2%

                \[\leadsto \mathsf{fma}\left(1, z, \sin y\right) \]
            8. Recombined 3 regimes into one program.
            9. Final simplification82.0%

              \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -3.2:\\ \;\;\;\;z + x\\ \mathbf{elif}\;x \leq -2.6 \cdot 10^{-197}:\\ \;\;\;\;\cos y \cdot z\\ \mathbf{elif}\;x \leq 1.25 \cdot 10^{-305}:\\ \;\;\;\;\mathsf{fma}\left(1, z, \sin y\right)\\ \mathbf{elif}\;x \leq 2.6 \cdot 10^{-49}:\\ \;\;\;\;\cos y \cdot z\\ \mathbf{else}:\\ \;\;\;\;z + x\\ \end{array} \]
            10. Add Preprocessing

            Alternative 6: 89.5% accurate, 1.7× speedup?

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

              1. Initial program 99.7%

                \[\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. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto \color{blue}{\cos y} \cdot z \]
              7. Applied rewrites94.4%

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

              if -6.4999999999999995e169 < z < 1.1799999999999999e116

              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. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

                \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -6.5 \cdot 10^{+169} \lor \neg \left(z \leq 1.18 \cdot 10^{+116}\right):\\ \;\;\;\;\cos y \cdot z\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(1, z, \sin y + x\right)\\ \end{array} \]
              9. Add Preprocessing

              Alternative 7: 73.2% accurate, 1.8× speedup?

              \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -6.5 \cdot 10^{+169} \lor \neg \left(z \leq 1.18 \cdot 10^{+116}\right):\\ \;\;\;\;\cos y \cdot z\\ \mathbf{else}:\\ \;\;\;\;z + x\\ \end{array} \end{array} \]
              (FPCore (x y z)
               :precision binary64
               (if (or (<= z -6.5e+169) (not (<= z 1.18e+116))) (* (cos y) z) (+ z x)))
              double code(double x, double y, double z) {
              	double tmp;
              	if ((z <= -6.5e+169) || !(z <= 1.18e+116)) {
              		tmp = cos(y) * 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 ((z <= (-6.5d+169)) .or. (.not. (z <= 1.18d+116))) then
                      tmp = cos(y) * z
                  else
                      tmp = z + x
                  end if
                  code = tmp
              end function
              
              public static double code(double x, double y, double z) {
              	double tmp;
              	if ((z <= -6.5e+169) || !(z <= 1.18e+116)) {
              		tmp = Math.cos(y) * z;
              	} else {
              		tmp = z + x;
              	}
              	return tmp;
              }
              
              def code(x, y, z):
              	tmp = 0
              	if (z <= -6.5e+169) or not (z <= 1.18e+116):
              		tmp = math.cos(y) * z
              	else:
              		tmp = z + x
              	return tmp
              
              function code(x, y, z)
              	tmp = 0.0
              	if ((z <= -6.5e+169) || !(z <= 1.18e+116))
              		tmp = Float64(cos(y) * z);
              	else
              		tmp = Float64(z + x);
              	end
              	return tmp
              end
              
              function tmp_2 = code(x, y, z)
              	tmp = 0.0;
              	if ((z <= -6.5e+169) || ~((z <= 1.18e+116)))
              		tmp = cos(y) * z;
              	else
              		tmp = z + x;
              	end
              	tmp_2 = tmp;
              end
              
              code[x_, y_, z_] := If[Or[LessEqual[z, -6.5e+169], N[Not[LessEqual[z, 1.18e+116]], $MachinePrecision]], N[(N[Cos[y], $MachinePrecision] * z), $MachinePrecision], N[(z + x), $MachinePrecision]]
              
              \begin{array}{l}
              
              \\
              \begin{array}{l}
              \mathbf{if}\;z \leq -6.5 \cdot 10^{+169} \lor \neg \left(z \leq 1.18 \cdot 10^{+116}\right):\\
              \;\;\;\;\cos y \cdot z\\
              
              \mathbf{else}:\\
              \;\;\;\;z + x\\
              
              
              \end{array}
              \end{array}
              
              Derivation
              1. Split input into 2 regimes
              2. if z < -6.4999999999999995e169 or 1.1799999999999999e116 < z

                1. Initial program 99.7%

                  \[\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. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto \color{blue}{\cos y} \cdot z \]
                7. Applied rewrites94.4%

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

                if -6.4999999999999995e169 < z < 1.1799999999999999e116

                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-+.f6473.4

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

                  \[\leadsto \color{blue}{z + x} \]
              3. Recombined 2 regimes into one program.
              4. Final simplification78.7%

                \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -6.5 \cdot 10^{+169} \lor \neg \left(z \leq 1.18 \cdot 10^{+116}\right):\\ \;\;\;\;\cos y \cdot z\\ \mathbf{else}:\\ \;\;\;\;z + x\\ \end{array} \]
              5. Add Preprocessing

              Alternative 8: 67.1% 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-+.f6466.9

                  \[\leadsto \color{blue}{z + x} \]
              5. Applied rewrites66.9%

                \[\leadsto \color{blue}{z + x} \]
              6. Final simplification66.9%

                \[\leadsto z + x \]
              7. Add Preprocessing

              Alternative 9: 29.9% accurate, 53.0× speedup?

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

                \[\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.f6456.1

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

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

                \[\leadsto y + \color{blue}{z} \]
              7. Step-by-step derivation
                1. Applied rewrites25.0%

                  \[\leadsto z + \color{blue}{y} \]
                2. Final simplification25.0%

                  \[\leadsto z + y \]
                3. Add Preprocessing

                Reproduce

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