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

Percentage Accurate: 99.9% → 99.9%
Time: 6.5s
Alternatives: 8
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 8 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: 77.5% accurate, 1.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.8 \cdot 10^{+26}:\\
\;\;\;\;z + x\\

\mathbf{elif}\;x \leq -5 \cdot 10^{-93}:\\
\;\;\;\;\cos y \cdot z\\

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

\mathbf{else}:\\
\;\;\;\;z + x\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -4.80000000000000009e26 or 3.69999999999999999e-12 < 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-+.f6488.9

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

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

    if -4.80000000000000009e26 < x < -4.99999999999999994e-93

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\frac{\sin y + x}{z} + \color{blue}{\cos y}\right) \cdot z \]
    5. Applied rewrites99.8%

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

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

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

      if -4.99999999999999994e-93 < x < 3.69999999999999999e-12

      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.f6496.8

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

        \[\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 rewrites73.8%

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

        \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -4.8 \cdot 10^{+26}:\\ \;\;\;\;z + x\\ \mathbf{elif}\;x \leq -5 \cdot 10^{-93}:\\ \;\;\;\;\cos y \cdot z\\ \mathbf{elif}\;x \leq 3.7 \cdot 10^{-12}:\\ \;\;\;\;\mathsf{fma}\left(1, z, \sin y\right)\\ \mathbf{else}:\\ \;\;\;\;z + x\\ \end{array} \]
      10. Add Preprocessing

      Alternative 3: 89.7% accurate, 1.7× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -2.2 \cdot 10^{+138} \lor \neg \left(z \leq 8.8 \cdot 10^{+69}\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 -2.2e+138) (not (<= z 8.8e+69)))
         (* (cos y) z)
         (fma 1.0 z (+ (sin y) x))))
      double code(double x, double y, double z) {
      	double tmp;
      	if ((z <= -2.2e+138) || !(z <= 8.8e+69)) {
      		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 <= -2.2e+138) || !(z <= 8.8e+69))
      		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, -2.2e+138], N[Not[LessEqual[z, 8.8e+69]], $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 -2.2 \cdot 10^{+138} \lor \neg \left(z \leq 8.8 \cdot 10^{+69}\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 < -2.2000000000000001e138 or 8.8000000000000006e69 < z

        1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \left(\frac{\sin y + x}{z} + \color{blue}{\cos y}\right) \cdot z \]
        5. Applied rewrites99.8%

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

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

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

          if -2.2000000000000001e138 < z < 8.8000000000000006e69

          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 rewrites94.6%

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

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

          Alternative 4: 90.2% accurate, 1.7× speedup?

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

            1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

                \[\leadsto \left(\frac{\sin y + x}{z} + \color{blue}{\cos y}\right) \cdot z \]
            5. Applied rewrites99.8%

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

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

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

              if -2.2000000000000001e138 < z < 1.19999999999999995e45

              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 rewrites94.4%

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

                if 1.19999999999999995e45 < z

                1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

              Alternative 5: 73.6% accurate, 1.8× speedup?

              \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -2.2 \cdot 10^{+138} \lor \neg \left(z \leq 8.8 \cdot 10^{+69}\right):\\ \;\;\;\;\cos y \cdot z\\ \mathbf{else}:\\ \;\;\;\;z + x\\ \end{array} \end{array} \]
              (FPCore (x y z)
               :precision binary64
               (if (or (<= z -2.2e+138) (not (<= z 8.8e+69))) (* (cos y) z) (+ z x)))
              double code(double x, double y, double z) {
              	double tmp;
              	if ((z <= -2.2e+138) || !(z <= 8.8e+69)) {
              		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 <= (-2.2d+138)) .or. (.not. (z <= 8.8d+69))) 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 <= -2.2e+138) || !(z <= 8.8e+69)) {
              		tmp = Math.cos(y) * z;
              	} else {
              		tmp = z + x;
              	}
              	return tmp;
              }
              
              def code(x, y, z):
              	tmp = 0
              	if (z <= -2.2e+138) or not (z <= 8.8e+69):
              		tmp = math.cos(y) * z
              	else:
              		tmp = z + x
              	return tmp
              
              function code(x, y, z)
              	tmp = 0.0
              	if ((z <= -2.2e+138) || !(z <= 8.8e+69))
              		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 <= -2.2e+138) || ~((z <= 8.8e+69)))
              		tmp = cos(y) * z;
              	else
              		tmp = z + x;
              	end
              	tmp_2 = tmp;
              end
              
              code[x_, y_, z_] := If[Or[LessEqual[z, -2.2e+138], N[Not[LessEqual[z, 8.8e+69]], $MachinePrecision]], N[(N[Cos[y], $MachinePrecision] * z), $MachinePrecision], N[(z + x), $MachinePrecision]]
              
              \begin{array}{l}
              
              \\
              \begin{array}{l}
              \mathbf{if}\;z \leq -2.2 \cdot 10^{+138} \lor \neg \left(z \leq 8.8 \cdot 10^{+69}\right):\\
              \;\;\;\;\cos y \cdot z\\
              
              \mathbf{else}:\\
              \;\;\;\;z + x\\
              
              
              \end{array}
              \end{array}
              
              Derivation
              1. Split input into 2 regimes
              2. if z < -2.2000000000000001e138 or 8.8000000000000006e69 < z

                1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto \left(\frac{\sin y + x}{z} + \color{blue}{\cos y}\right) \cdot z \]
                5. Applied rewrites99.8%

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

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

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

                  if -2.2000000000000001e138 < z < 8.8000000000000006e69

                  1. Initial program 100.0%

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

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

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

                      \[\leadsto \color{blue}{z + x} \]
                  5. Applied rewrites70.0%

                    \[\leadsto \color{blue}{z + x} \]
                8. Recombined 2 regimes into one program.
                9. Final simplification77.0%

                  \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -2.2 \cdot 10^{+138} \lor \neg \left(z \leq 8.8 \cdot 10^{+69}\right):\\ \;\;\;\;\cos y \cdot z\\ \mathbf{else}:\\ \;\;\;\;z + x\\ \end{array} \]
                10. Add Preprocessing

                Alternative 6: 70.9% accurate, 5.4× speedup?

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

                  1. Initial program 99.8%

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

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

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

                      \[\leadsto \color{blue}{z + x} \]
                  5. Applied rewrites37.7%

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

                  if -65000 < y < 1.14999999999999992e28

                  1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                Alternative 7: 66.7% accurate, 53.0× speedup?

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

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

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

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

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

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

                Alternative 8: 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.f6460.4

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

                  \[\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 rewrites29.4%

                    \[\leadsto z + \color{blue}{y} \]
                  2. Add Preprocessing

                  Reproduce

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