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

Percentage Accurate: 99.9% → 99.9%
Time: 7.9s
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(\sin y, -z, \cos y + x\right) \end{array} \]
(FPCore (x y z) :precision binary64 (fma (sin y) (- z) (+ (cos y) x)))
double code(double x, double y, double z) {
	return fma(sin(y), -z, (cos(y) + x));
}
function code(x, y, z)
	return fma(sin(y), Float64(-z), Float64(cos(y) + x))
end
code[x_, y_, z_] := N[(N[Sin[y], $MachinePrecision] * (-z) + N[(N[Cos[y], $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\mathsf{fma}\left(\sin y, -z, \cos y + x\right)
\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. sub-negN/A

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 92.5% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x + \cos y\\ t_1 := z \cdot \sin y\\ t_2 := t\_0 - t\_1\\ \mathbf{if}\;t\_2 \leq -1 \cdot 10^{+15} \lor \neg \left(t\_2 \leq 0.9841\right):\\ \;\;\;\;\left(x + 1\right) - t\_1\\ \mathbf{else}:\\ \;\;\;\;t\_0 - z \cdot y\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (+ x (cos y))) (t_1 (* z (sin y))) (t_2 (- t_0 t_1)))
   (if (or (<= t_2 -1e+15) (not (<= t_2 0.9841)))
     (- (+ x 1.0) t_1)
     (- t_0 (* z y)))))
double code(double x, double y, double z) {
	double t_0 = x + cos(y);
	double t_1 = z * sin(y);
	double t_2 = t_0 - t_1;
	double tmp;
	if ((t_2 <= -1e+15) || !(t_2 <= 0.9841)) {
		tmp = (x + 1.0) - t_1;
	} else {
		tmp = t_0 - (z * y);
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_0 = x + cos(y)
    t_1 = z * sin(y)
    t_2 = t_0 - t_1
    if ((t_2 <= (-1d+15)) .or. (.not. (t_2 <= 0.9841d0))) then
        tmp = (x + 1.0d0) - t_1
    else
        tmp = t_0 - (z * y)
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = x + Math.cos(y);
	double t_1 = z * Math.sin(y);
	double t_2 = t_0 - t_1;
	double tmp;
	if ((t_2 <= -1e+15) || !(t_2 <= 0.9841)) {
		tmp = (x + 1.0) - t_1;
	} else {
		tmp = t_0 - (z * y);
	}
	return tmp;
}
def code(x, y, z):
	t_0 = x + math.cos(y)
	t_1 = z * math.sin(y)
	t_2 = t_0 - t_1
	tmp = 0
	if (t_2 <= -1e+15) or not (t_2 <= 0.9841):
		tmp = (x + 1.0) - t_1
	else:
		tmp = t_0 - (z * y)
	return tmp
function code(x, y, z)
	t_0 = Float64(x + cos(y))
	t_1 = Float64(z * sin(y))
	t_2 = Float64(t_0 - t_1)
	tmp = 0.0
	if ((t_2 <= -1e+15) || !(t_2 <= 0.9841))
		tmp = Float64(Float64(x + 1.0) - t_1);
	else
		tmp = Float64(t_0 - Float64(z * y));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = x + cos(y);
	t_1 = z * sin(y);
	t_2 = t_0 - t_1;
	tmp = 0.0;
	if ((t_2 <= -1e+15) || ~((t_2 <= 0.9841)))
		tmp = (x + 1.0) - t_1;
	else
		tmp = t_0 - (z * y);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(x + N[Cos[y], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(z * N[Sin[y], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$0 - t$95$1), $MachinePrecision]}, If[Or[LessEqual[t$95$2, -1e+15], N[Not[LessEqual[t$95$2, 0.9841]], $MachinePrecision]], N[(N[(x + 1.0), $MachinePrecision] - t$95$1), $MachinePrecision], N[(t$95$0 - N[(z * y), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := x + \cos y\\
t_1 := z \cdot \sin y\\
t_2 := t\_0 - t\_1\\
\mathbf{if}\;t\_2 \leq -1 \cdot 10^{+15} \lor \neg \left(t\_2 \leq 0.9841\right):\\
\;\;\;\;\left(x + 1\right) - t\_1\\

\mathbf{else}:\\
\;\;\;\;t\_0 - z \cdot y\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (+.f64 x (cos.f64 y)) (*.f64 z (sin.f64 y))) < -1e15 or 0.98409999999999997 < (-.f64 (+.f64 x (cos.f64 y)) (*.f64 z (sin.f64 y)))

    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 \left(x + \color{blue}{1}\right) - z \cdot \sin y \]
    4. Step-by-step derivation
      1. Applied rewrites97.4%

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

      if -1e15 < (-.f64 (+.f64 x (cos.f64 y)) (*.f64 z (sin.f64 y))) < 0.98409999999999997

      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 \left(x + \cos y\right) - \color{blue}{y \cdot z} \]
      4. Step-by-step derivation
        1. *-commutativeN/A

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

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

        \[\leadsto \left(x + \cos y\right) - \color{blue}{z \cdot y} \]
    5. Recombined 2 regimes into one program.
    6. Final simplification94.2%

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

    Alternative 3: 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}
    
    Derivation
    1. Initial program 99.9%

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

    Alternative 4: 98.8% accurate, 1.6× speedup?

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

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

        if -520 < z < 3.80000000000000026e-24

        1. Initial program 100.0%

          \[\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. flip--N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \color{blue}{\frac{\cos y - z \cdot \sin y}{x}} \cdot x + x \]
          8. sub-negN/A

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

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

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

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

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

            \[\leadsto \mathsf{fma}\left(\frac{\cos y}{x}, x, x\right) \]
        10. Recombined 2 regimes into one program.
        11. Final simplification99.3%

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

        Alternative 5: 70.9% accurate, 1.8× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -7.6 \cdot 10^{+90} \lor \neg \left(z \leq 2.8 \cdot 10^{+123}\right):\\ \;\;\;\;\left(-z\right) \cdot \sin y\\ \mathbf{else}:\\ \;\;\;\;1 + x\\ \end{array} \end{array} \]
        (FPCore (x y z)
         :precision binary64
         (if (or (<= z -7.6e+90) (not (<= z 2.8e+123))) (* (- z) (sin y)) (+ 1.0 x)))
        double code(double x, double y, double z) {
        	double tmp;
        	if ((z <= -7.6e+90) || !(z <= 2.8e+123)) {
        		tmp = -z * sin(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 <= (-7.6d+90)) .or. (.not. (z <= 2.8d+123))) then
                tmp = -z * sin(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 <= -7.6e+90) || !(z <= 2.8e+123)) {
        		tmp = -z * Math.sin(y);
        	} else {
        		tmp = 1.0 + x;
        	}
        	return tmp;
        }
        
        def code(x, y, z):
        	tmp = 0
        	if (z <= -7.6e+90) or not (z <= 2.8e+123):
        		tmp = -z * math.sin(y)
        	else:
        		tmp = 1.0 + x
        	return tmp
        
        function code(x, y, z)
        	tmp = 0.0
        	if ((z <= -7.6e+90) || !(z <= 2.8e+123))
        		tmp = Float64(Float64(-z) * sin(y));
        	else
        		tmp = Float64(1.0 + x);
        	end
        	return tmp
        end
        
        function tmp_2 = code(x, y, z)
        	tmp = 0.0;
        	if ((z <= -7.6e+90) || ~((z <= 2.8e+123)))
        		tmp = -z * sin(y);
        	else
        		tmp = 1.0 + x;
        	end
        	tmp_2 = tmp;
        end
        
        code[x_, y_, z_] := If[Or[LessEqual[z, -7.6e+90], N[Not[LessEqual[z, 2.8e+123]], $MachinePrecision]], N[((-z) * N[Sin[y], $MachinePrecision]), $MachinePrecision], N[(1.0 + x), $MachinePrecision]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;z \leq -7.6 \cdot 10^{+90} \lor \neg \left(z \leq 2.8 \cdot 10^{+123}\right):\\
        \;\;\;\;\left(-z\right) \cdot \sin y\\
        
        \mathbf{else}:\\
        \;\;\;\;1 + x\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if z < -7.6000000000000002e90 or 2.80000000000000011e123 < z

          1. Initial program 99.7%

            \[\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.f6470.2

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

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

          if -7.6000000000000002e90 < z < 2.80000000000000011e123

          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-+.f6478.7

              \[\leadsto \color{blue}{1 + x} \]
          5. Applied rewrites78.7%

            \[\leadsto \color{blue}{1 + x} \]
        3. Recombined 2 regimes into one program.
        4. Final simplification75.8%

          \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -7.6 \cdot 10^{+90} \lor \neg \left(z \leq 2.8 \cdot 10^{+123}\right):\\ \;\;\;\;\left(-z\right) \cdot \sin y\\ \mathbf{else}:\\ \;\;\;\;1 + x\\ \end{array} \]
        5. Add Preprocessing

        Alternative 6: 88.2% accurate, 1.9× speedup?

        \[\begin{array}{l} \\ \left(x + 1\right) - z \cdot \sin y \end{array} \]
        (FPCore (x y z) :precision binary64 (- (+ x 1.0) (* z (sin y))))
        double code(double x, double y, double z) {
        	return (x + 1.0) - (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 + 1.0d0) - (z * sin(y))
        end function
        
        public static double code(double x, double y, double z) {
        	return (x + 1.0) - (z * Math.sin(y));
        }
        
        def code(x, y, z):
        	return (x + 1.0) - (z * math.sin(y))
        
        function code(x, y, z)
        	return Float64(Float64(x + 1.0) - Float64(z * sin(y)))
        end
        
        function tmp = code(x, y, z)
        	tmp = (x + 1.0) - (z * sin(y));
        end
        
        code[x_, y_, z_] := N[(N[(x + 1.0), $MachinePrecision] - N[(z * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
        
        \begin{array}{l}
        
        \\
        \left(x + 1\right) - z \cdot \sin y
        \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 \left(x + \color{blue}{1}\right) - z \cdot \sin y \]
        4. Step-by-step derivation
          1. Applied rewrites89.9%

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

          Alternative 7: 70.2% accurate, 9.6× speedup?

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

            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 + x} \]
            4. Step-by-step derivation
              1. lower-+.f6440.6

                \[\leadsto \color{blue}{1 + x} \]
            5. Applied rewrites40.6%

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

            if -9.50000000000000054e72 < y < 9e108

            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 + -1 \cdot \left(y \cdot z\right)\right)} \]
            4. Step-by-step derivation
              1. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

          Alternative 8: 67.7% accurate, 10.1× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -2.7 \cdot 10^{-31} \lor \neg \left(x \leq 0.75\right):\\ \;\;\;\;1 + x\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-z, y, 1\right)\\ \end{array} \end{array} \]
          (FPCore (x y z)
           :precision binary64
           (if (or (<= x -2.7e-31) (not (<= x 0.75))) (+ 1.0 x) (fma (- z) y 1.0)))
          double code(double x, double y, double z) {
          	double tmp;
          	if ((x <= -2.7e-31) || !(x <= 0.75)) {
          		tmp = 1.0 + x;
          	} else {
          		tmp = fma(-z, y, 1.0);
          	}
          	return tmp;
          }
          
          function code(x, y, z)
          	tmp = 0.0
          	if ((x <= -2.7e-31) || !(x <= 0.75))
          		tmp = Float64(1.0 + x);
          	else
          		tmp = fma(Float64(-z), y, 1.0);
          	end
          	return tmp
          end
          
          code[x_, y_, z_] := If[Or[LessEqual[x, -2.7e-31], N[Not[LessEqual[x, 0.75]], $MachinePrecision]], N[(1.0 + x), $MachinePrecision], N[((-z) * y + 1.0), $MachinePrecision]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          \mathbf{if}\;x \leq -2.7 \cdot 10^{-31} \lor \neg \left(x \leq 0.75\right):\\
          \;\;\;\;1 + x\\
          
          \mathbf{else}:\\
          \;\;\;\;\mathsf{fma}\left(-z, y, 1\right)\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if x < -2.70000000000000014e-31 or 0.75 < 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 + x} \]
            4. Step-by-step derivation
              1. lower-+.f6484.0

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

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

            if -2.70000000000000014e-31 < x < 0.75

            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 \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. lower--.f64N/A

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

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

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

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

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

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

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

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

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

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

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

                \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, z \cdot y, -0.5\right) \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 rewrites46.6%

                  \[\leadsto \mathsf{fma}\left(-z, y, 1\right) \]
              4. Recombined 2 regimes into one program.
              5. Final simplification67.4%

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

              Alternative 9: 62.5% 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.3

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

                \[\leadsto \color{blue}{1 + x} \]
              6. Final simplification62.3%

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

              Alternative 10: 22.1% 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.3

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

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

                \[\leadsto 1 \]
              7. Step-by-step derivation
                1. Applied rewrites17.8%

                  \[\leadsto 1 \]
                2. Final simplification17.8%

                  \[\leadsto 1 \]
                3. Add Preprocessing

                Reproduce

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