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

Percentage Accurate: 99.9% → 99.9%
Time: 7.6s
Alternatives: 10
Speedup: 1.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 10 alternatives:

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

Initial Program: 99.9% accurate, 1.0× speedup?

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

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

Alternative 1: 99.9% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

      \[\leadsto \left(\cos y - \color{blue}{z \cdot \sin y}\right) + x \]
    7. fp-cancel-sub-sign-invN/A

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

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

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

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

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

Alternative 2: 96.1% accurate, 1.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -1.36 \cdot 10^{+79} \lor \neg \left(z \leq 1.65 \cdot 10^{-68}\right):\\ \;\;\;\;\left(x + 1\right) - z \cdot \sin y\\ \mathbf{else}:\\ \;\;\;\;\cos y + x\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= z -1.36e+79) (not (<= z 1.65e-68)))
   (- (+ x 1.0) (* z (sin y)))
   (+ (cos y) x)))
double code(double x, double y, double z) {
	double tmp;
	if ((z <= -1.36e+79) || !(z <= 1.65e-68)) {
		tmp = (x + 1.0) - (z * sin(y));
	} else {
		tmp = cos(y) + 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 <= (-1.36d+79)) .or. (.not. (z <= 1.65d-68))) then
        tmp = (x + 1.0d0) - (z * sin(y))
    else
        tmp = cos(y) + x
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if ((z <= -1.36e+79) || !(z <= 1.65e-68)) {
		tmp = (x + 1.0) - (z * Math.sin(y));
	} else {
		tmp = Math.cos(y) + x;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (z <= -1.36e+79) or not (z <= 1.65e-68):
		tmp = (x + 1.0) - (z * math.sin(y))
	else:
		tmp = math.cos(y) + x
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((z <= -1.36e+79) || !(z <= 1.65e-68))
		tmp = Float64(Float64(x + 1.0) - Float64(z * sin(y)));
	else
		tmp = Float64(cos(y) + x);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((z <= -1.36e+79) || ~((z <= 1.65e-68)))
		tmp = (x + 1.0) - (z * sin(y));
	else
		tmp = cos(y) + x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.36e+79], N[Not[LessEqual[z, 1.65e-68]], $MachinePrecision]], N[(N[(x + 1.0), $MachinePrecision] - N[(z * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Cos[y], $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.36 \cdot 10^{+79} \lor \neg \left(z \leq 1.65 \cdot 10^{-68}\right):\\
\;\;\;\;\left(x + 1\right) - z \cdot \sin y\\

\mathbf{else}:\\
\;\;\;\;\cos y + x\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -1.36000000000000003e79 or 1.6499999999999999e-68 < z

    1. Initial program 99.8%

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

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

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

      if -1.36000000000000003e79 < z < 1.6499999999999999e-68

      1. Initial program 100.0%

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

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

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

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

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

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

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

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

          \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{\cos y - z \cdot \sin y}{x}}, x, x\right) \]
        8. fp-cancel-sub-sign-invN/A

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\sin y, \frac{-z}{x}, \frac{\cos y}{x}\right), x, x\right) \]
        2. Taylor expanded in z around 0

          \[\leadsto x + \color{blue}{\cos y} \]
        3. Step-by-step derivation
          1. Applied rewrites99.6%

            \[\leadsto \cos y + \color{blue}{x} \]
        4. Recombined 2 regimes into one program.
        5. Final simplification99.7%

          \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.36 \cdot 10^{+79} \lor \neg \left(z \leq 1.65 \cdot 10^{-68}\right):\\ \;\;\;\;\left(x + 1\right) - z \cdot \sin y\\ \mathbf{else}:\\ \;\;\;\;\cos y + x\\ \end{array} \]
        6. Add Preprocessing

        Alternative 3: 82.2% accurate, 1.8× speedup?

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

          1. Initial program 99.8%

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

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

              \[\leadsto \color{blue}{\mathsf{neg}\left(z \cdot \sin y\right)} \]
            2. distribute-lft-neg-inN/A

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

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

              \[\leadsto \color{blue}{\left(-z\right)} \cdot \sin y \]
            5. lower-sin.f6475.9

              \[\leadsto \left(-z\right) \cdot \color{blue}{\sin y} \]
          5. Applied rewrites75.9%

            \[\leadsto \color{blue}{\left(-z\right) \cdot \sin y} \]

          if -2.49999999999999983e168 < z < 3.3000000000000001e128

          1. Initial program 100.0%

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

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

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

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

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

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

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

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

              \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{\cos y - z \cdot \sin y}{x}}, x, x\right) \]
            8. fp-cancel-sub-sign-invN/A

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\sin y, \frac{-z}{x}, \frac{\cos y}{x}\right), x, x\right) \]
            2. Taylor expanded in z around 0

              \[\leadsto x + \color{blue}{\cos y} \]
            3. Step-by-step derivation
              1. Applied rewrites90.3%

                \[\leadsto \cos y + \color{blue}{x} \]
            4. Recombined 2 regimes into one program.
            5. Final simplification86.9%

              \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -2.5 \cdot 10^{+168} \lor \neg \left(z \leq 3.3 \cdot 10^{+128}\right):\\ \;\;\;\;\left(-z\right) \cdot \sin y\\ \mathbf{else}:\\ \;\;\;\;\cos y + x\\ \end{array} \]
            6. Add Preprocessing

            Alternative 4: 81.1% accurate, 1.8× speedup?

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

              1. Initial program 99.9%

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

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

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

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

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

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

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

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

                  \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{\cos y - z \cdot \sin y}{x}}, x, x\right) \]
                8. fp-cancel-sub-sign-invN/A

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\sin y, \frac{-z}{x}, \frac{\cos y}{x}\right), x, x\right) \]
                2. Taylor expanded in z around 0

                  \[\leadsto x + \color{blue}{\cos y} \]
                3. Step-by-step derivation
                  1. Applied rewrites65.0%

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

                  if -0.5 < y < 2.49999999999999985e-12

                  1. Initial program 100.0%

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

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

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

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

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

                      \[\leadsto \color{blue}{\mathsf{fma}\left(y \cdot \left(\frac{1}{6} \cdot \left(y \cdot z\right) - \frac{1}{2}\right) - z, y, 1 + x\right)} \]
                  5. Applied rewrites100.0%

                    \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(\left(0.16666666666666666 \cdot z\right) \cdot y - 0.5, y, -z\right), y, 1 + x\right)} \]
                4. Recombined 2 regimes into one program.
                5. Final simplification82.7%

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

                Alternative 5: 64.4% accurate, 10.1× speedup?

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

                  1. Initial program 99.9%

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

                    \[\leadsto \color{blue}{1 + x} \]
                  4. Step-by-step derivation
                    1. lower-+.f6484.3

                      \[\leadsto \color{blue}{1 + x} \]
                  5. Applied rewrites84.3%

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

                  if -3.44999999999999994e-13 < x < 2.1999999999999998e-19

                  1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

                      \[\leadsto \mathsf{fma}\left(-0.5 \cdot y - z, y, 1\right) \]
                    2. Taylor expanded in y around 0

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

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

                      if 2.1999999999999998e-19 < x

                      1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

                        \[\leadsto 1 + \color{blue}{\left(x + y \cdot \left(\frac{-1}{2} \cdot y - z\right)\right)} \]
                      7. Step-by-step derivation
                        1. Applied rewrites57.6%

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

                          \[\leadsto x - y \cdot z \]
                        3. Step-by-step derivation
                          1. Applied rewrites74.3%

                            \[\leadsto x - z \cdot y \]
                        4. Recombined 3 regimes into one program.
                        5. Add Preprocessing

                        Alternative 6: 65.3% accurate, 11.8× speedup?

                        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -5.2 \cdot 10^{+48}:\\ \;\;\;\;1 + x\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-z, y, 1\right) + x\\ \end{array} \end{array} \]
                        (FPCore (x y z)
                         :precision binary64
                         (if (<= x -5.2e+48) (+ 1.0 x) (+ (fma (- z) y 1.0) x)))
                        double code(double x, double y, double z) {
                        	double tmp;
                        	if (x <= -5.2e+48) {
                        		tmp = 1.0 + x;
                        	} else {
                        		tmp = fma(-z, y, 1.0) + x;
                        	}
                        	return tmp;
                        }
                        
                        function code(x, y, z)
                        	tmp = 0.0
                        	if (x <= -5.2e+48)
                        		tmp = Float64(1.0 + x);
                        	else
                        		tmp = Float64(fma(Float64(-z), y, 1.0) + x);
                        	end
                        	return tmp
                        end
                        
                        code[x_, y_, z_] := If[LessEqual[x, -5.2e+48], N[(1.0 + x), $MachinePrecision], N[(N[((-z) * y + 1.0), $MachinePrecision] + x), $MachinePrecision]]
                        
                        \begin{array}{l}
                        
                        \\
                        \begin{array}{l}
                        \mathbf{if}\;x \leq -5.2 \cdot 10^{+48}:\\
                        \;\;\;\;1 + x\\
                        
                        \mathbf{else}:\\
                        \;\;\;\;\mathsf{fma}\left(-z, y, 1\right) + x\\
                        
                        
                        \end{array}
                        \end{array}
                        
                        Derivation
                        1. Split input into 2 regimes
                        2. if x < -5.1999999999999999e48

                          1. Initial program 99.9%

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

                            \[\leadsto \color{blue}{1 + x} \]
                          4. Step-by-step derivation
                            1. lower-+.f6488.4

                              \[\leadsto \color{blue}{1 + x} \]
                          5. Applied rewrites88.4%

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

                          if -5.1999999999999999e48 < x

                          1. Initial program 99.9%

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

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

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

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

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

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

                              \[\leadsto \left(\cos y - \color{blue}{z \cdot \sin y}\right) + x \]
                            7. fp-cancel-sub-sign-invN/A

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

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

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

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

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

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

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

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

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

                              \[\leadsto \color{blue}{\mathsf{fma}\left(-1 \cdot z, y, 1\right)} + x \]
                            5. mul-1-negN/A

                              \[\leadsto \mathsf{fma}\left(\color{blue}{\mathsf{neg}\left(z\right)}, y, 1\right) + x \]
                            6. lower-neg.f6463.7

                              \[\leadsto \mathsf{fma}\left(\color{blue}{-z}, y, 1\right) + x \]
                          7. Applied rewrites63.7%

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

                        Alternative 7: 65.3% accurate, 11.8× speedup?

                        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -5.2 \cdot 10^{+48}:\\ \;\;\;\;1 + x\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-z, y, 1 + x\right)\\ \end{array} \end{array} \]
                        (FPCore (x y z)
                         :precision binary64
                         (if (<= x -5.2e+48) (+ 1.0 x) (fma (- z) y (+ 1.0 x))))
                        double code(double x, double y, double z) {
                        	double tmp;
                        	if (x <= -5.2e+48) {
                        		tmp = 1.0 + x;
                        	} else {
                        		tmp = fma(-z, y, (1.0 + x));
                        	}
                        	return tmp;
                        }
                        
                        function code(x, y, z)
                        	tmp = 0.0
                        	if (x <= -5.2e+48)
                        		tmp = Float64(1.0 + x);
                        	else
                        		tmp = fma(Float64(-z), y, Float64(1.0 + x));
                        	end
                        	return tmp
                        end
                        
                        code[x_, y_, z_] := If[LessEqual[x, -5.2e+48], N[(1.0 + x), $MachinePrecision], N[((-z) * y + N[(1.0 + x), $MachinePrecision]), $MachinePrecision]]
                        
                        \begin{array}{l}
                        
                        \\
                        \begin{array}{l}
                        \mathbf{if}\;x \leq -5.2 \cdot 10^{+48}:\\
                        \;\;\;\;1 + x\\
                        
                        \mathbf{else}:\\
                        \;\;\;\;\mathsf{fma}\left(-z, y, 1 + x\right)\\
                        
                        
                        \end{array}
                        \end{array}
                        
                        Derivation
                        1. Split input into 2 regimes
                        2. if x < -5.1999999999999999e48

                          1. Initial program 99.9%

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

                            \[\leadsto \color{blue}{1 + x} \]
                          4. Step-by-step derivation
                            1. lower-+.f6488.4

                              \[\leadsto \color{blue}{1 + x} \]
                          5. Applied rewrites88.4%

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

                          if -5.1999999999999999e48 < x

                          1. Initial program 99.9%

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

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

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

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

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

                              \[\leadsto \left(\mathsf{neg}\left(\color{blue}{z \cdot y}\right)\right) + \left(1 + x\right) \]
                            5. distribute-lft-neg-inN/A

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

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

                              \[\leadsto \mathsf{fma}\left(\color{blue}{-z}, y, 1 + x\right) \]
                            8. lower-+.f6463.7

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

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

                        Alternative 8: 63.5% accurate, 14.1× speedup?

                        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -2.6 \cdot 10^{+168}:\\ \;\;\;\;x - z \cdot y\\ \mathbf{else}:\\ \;\;\;\;1 + x\\ \end{array} \end{array} \]
                        (FPCore (x y z)
                         :precision binary64
                         (if (<= z -2.6e+168) (- x (* z y)) (+ 1.0 x)))
                        double code(double x, double y, double z) {
                        	double tmp;
                        	if (z <= -2.6e+168) {
                        		tmp = x - (z * y);
                        	} else {
                        		tmp = 1.0 + 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 <= (-2.6d+168)) then
                                tmp = x - (z * y)
                            else
                                tmp = 1.0d0 + x
                            end if
                            code = tmp
                        end function
                        
                        public static double code(double x, double y, double z) {
                        	double tmp;
                        	if (z <= -2.6e+168) {
                        		tmp = x - (z * y);
                        	} else {
                        		tmp = 1.0 + x;
                        	}
                        	return tmp;
                        }
                        
                        def code(x, y, z):
                        	tmp = 0
                        	if z <= -2.6e+168:
                        		tmp = x - (z * y)
                        	else:
                        		tmp = 1.0 + x
                        	return tmp
                        
                        function code(x, y, z)
                        	tmp = 0.0
                        	if (z <= -2.6e+168)
                        		tmp = Float64(x - Float64(z * y));
                        	else
                        		tmp = Float64(1.0 + x);
                        	end
                        	return tmp
                        end
                        
                        function tmp_2 = code(x, y, z)
                        	tmp = 0.0;
                        	if (z <= -2.6e+168)
                        		tmp = x - (z * y);
                        	else
                        		tmp = 1.0 + x;
                        	end
                        	tmp_2 = tmp;
                        end
                        
                        code[x_, y_, z_] := If[LessEqual[z, -2.6e+168], N[(x - N[(z * y), $MachinePrecision]), $MachinePrecision], N[(1.0 + x), $MachinePrecision]]
                        
                        \begin{array}{l}
                        
                        \\
                        \begin{array}{l}
                        \mathbf{if}\;z \leq -2.6 \cdot 10^{+168}:\\
                        \;\;\;\;x - z \cdot y\\
                        
                        \mathbf{else}:\\
                        \;\;\;\;1 + x\\
                        
                        
                        \end{array}
                        \end{array}
                        
                        Derivation
                        1. Split input into 2 regimes
                        2. if z < -2.6e168

                          1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

                            \[\leadsto 1 + \color{blue}{\left(x + y \cdot \left(\frac{-1}{2} \cdot y - z\right)\right)} \]
                          7. Step-by-step derivation
                            1. Applied rewrites55.1%

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

                              \[\leadsto x - y \cdot z \]
                            3. Step-by-step derivation
                              1. Applied rewrites52.1%

                                \[\leadsto x - z \cdot y \]

                              if -2.6e168 < z

                              1. Initial program 100.0%

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

                                \[\leadsto \color{blue}{1 + x} \]
                              4. Step-by-step derivation
                                1. lower-+.f6467.8

                                  \[\leadsto \color{blue}{1 + x} \]
                              5. Applied rewrites67.8%

                                \[\leadsto \color{blue}{1 + x} \]
                            4. Recombined 2 regimes into one program.
                            5. Add Preprocessing

                            Alternative 9: 61.6% accurate, 53.0× speedup?

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

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

                              \[\leadsto \color{blue}{1 + x} \]
                            4. Step-by-step derivation
                              1. lower-+.f6462.4

                                \[\leadsto \color{blue}{1 + x} \]
                            5. Applied rewrites62.4%

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

                            Alternative 10: 21.3% accurate, 212.0× speedup?

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

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

                              \[\leadsto \color{blue}{1 + x} \]
                            4. Step-by-step derivation
                              1. lower-+.f6462.4

                                \[\leadsto \color{blue}{1 + x} \]
                            5. Applied rewrites62.4%

                              \[\leadsto \color{blue}{1 + x} \]
                            6. Taylor expanded in x around 0

                              \[\leadsto 1 \]
                            7. Step-by-step derivation
                              1. Applied rewrites22.6%

                                \[\leadsto 1 \]
                              2. Add Preprocessing

                              Reproduce

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