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

Percentage Accurate: 99.9% → 99.9%
Time: 10.6s
Alternatives: 12
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 12 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} \\ \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 2: 98.3% 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 -1000000000000:\\ \;\;\;\;\mathsf{fma}\left(\sin y, -z, x\right)\\ \mathbf{elif}\;t\_2 \leq 0.99:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;\left(x + 1\right) - t\_1\\ \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 (<= t_2 -1000000000000.0)
     (fma (sin y) (- z) x)
     (if (<= t_2 0.99) t_0 (- (+ x 1.0) t_1)))))
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 <= -1000000000000.0) {
		tmp = fma(sin(y), -z, x);
	} else if (t_2 <= 0.99) {
		tmp = t_0;
	} else {
		tmp = (x + 1.0) - t_1;
	}
	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 <= -1000000000000.0)
		tmp = fma(sin(y), Float64(-z), x);
	elseif (t_2 <= 0.99)
		tmp = t_0;
	else
		tmp = Float64(Float64(x + 1.0) - t_1);
	end
	return 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[LessEqual[t$95$2, -1000000000000.0], N[(N[Sin[y], $MachinePrecision] * (-z) + x), $MachinePrecision], If[LessEqual[t$95$2, 0.99], t$95$0, N[(N[(x + 1.0), $MachinePrecision] - t$95$1), $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 -1000000000000:\\
\;\;\;\;\mathsf{fma}\left(\sin y, -z, x\right)\\

\mathbf{elif}\;t\_2 \leq 0.99:\\
\;\;\;\;t\_0\\

\mathbf{else}:\\
\;\;\;\;\left(x + 1\right) - t\_1\\


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

    1. Initial program 99.9%

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

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

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

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

        \[\leadsto \left(x + \cos y\right) - \color{blue}{z \cdot \sin y} \]
      5. 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}} \]
      6. 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)}}} \]
      7. 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)}}} \]
      8. 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}}}} \]
      9. flip--N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\frac{1}{\color{blue}{x \cdot 1 - \frac{z \cdot \sin y}{1}}}} \]
      6. *-rgt-identityN/A

        \[\leadsto \frac{1}{\frac{1}{\color{blue}{x} - \frac{z \cdot \sin y}{1}}} \]
      7. /-rgt-identityN/A

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

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

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

        \[\leadsto \frac{1}{\frac{1}{\color{blue}{x + \left(\mathsf{neg}\left(z \cdot \sin y\right)\right)}}} \]
      11. remove-double-div99.8

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

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

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

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

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

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

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

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

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

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

    if -1e12 < (-.f64 (+.f64 x (cos.f64 y)) (*.f64 z (sin.f64 y))) < 0.98999999999999999

    1. Initial program 99.9%

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

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

        \[\leadsto \color{blue}{\cos y + x} \]
      2. lower-+.f64N/A

        \[\leadsto \color{blue}{\cos y + x} \]
      3. lower-cos.f6497.8

        \[\leadsto \color{blue}{\cos y} + x \]
    5. Applied rewrites97.8%

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

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

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

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

      \[\leadsto \color{blue}{\left(x + 1\right)} - z \cdot \sin y \]
  3. Recombined 3 regimes into one program.
  4. Final simplification99.6%

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

Alternative 3: 98.2% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x + \cos y\\ t_1 := t\_0 - z \cdot \sin y\\ t_2 := \mathsf{fma}\left(\sin y, -z, x\right)\\ \mathbf{if}\;t\_1 \leq -1000000000000:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+14}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;t\_2\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (+ x (cos y)))
        (t_1 (- t_0 (* z (sin y))))
        (t_2 (fma (sin y) (- z) x)))
   (if (<= t_1 -1000000000000.0) t_2 (if (<= t_1 5e+14) t_0 t_2))))
double code(double x, double y, double z) {
	double t_0 = x + cos(y);
	double t_1 = t_0 - (z * sin(y));
	double t_2 = fma(sin(y), -z, x);
	double tmp;
	if (t_1 <= -1000000000000.0) {
		tmp = t_2;
	} else if (t_1 <= 5e+14) {
		tmp = t_0;
	} else {
		tmp = t_2;
	}
	return tmp;
}
function code(x, y, z)
	t_0 = Float64(x + cos(y))
	t_1 = Float64(t_0 - Float64(z * sin(y)))
	t_2 = fma(sin(y), Float64(-z), x)
	tmp = 0.0
	if (t_1 <= -1000000000000.0)
		tmp = t_2;
	elseif (t_1 <= 5e+14)
		tmp = t_0;
	else
		tmp = t_2;
	end
	return tmp
end
code[x_, y_, z_] := Block[{t$95$0 = N[(x + N[Cos[y], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 - N[(z * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Sin[y], $MachinePrecision] * (-z) + x), $MachinePrecision]}, If[LessEqual[t$95$1, -1000000000000.0], t$95$2, If[LessEqual[t$95$1, 5e+14], t$95$0, t$95$2]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := x + \cos y\\
t_1 := t\_0 - z \cdot \sin y\\
t_2 := \mathsf{fma}\left(\sin y, -z, x\right)\\
\mathbf{if}\;t\_1 \leq -1000000000000:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+14}:\\
\;\;\;\;t\_0\\

\mathbf{else}:\\
\;\;\;\;t\_2\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (+.f64 x (cos.f64 y)) (*.f64 z (sin.f64 y))) < -1e12 or 5e14 < (-.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. Step-by-step derivation
      1. lift-cos.f64N/A

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

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

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

        \[\leadsto \left(x + \cos y\right) - \color{blue}{z \cdot \sin y} \]
      5. 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}} \]
      6. 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)}}} \]
      7. 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)}}} \]
      8. 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}}}} \]
      9. flip--N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\frac{1}{\color{blue}{x \cdot 1 - \frac{z \cdot \sin y}{1}}}} \]
      6. *-rgt-identityN/A

        \[\leadsto \frac{1}{\frac{1}{\color{blue}{x} - \frac{z \cdot \sin y}{1}}} \]
      7. /-rgt-identityN/A

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

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

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

        \[\leadsto \frac{1}{\frac{1}{\color{blue}{x + \left(\mathsf{neg}\left(z \cdot \sin y\right)\right)}}} \]
      11. remove-double-div99.9

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

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

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

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

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

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

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

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

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

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

    if -1e12 < (-.f64 (+.f64 x (cos.f64 y)) (*.f64 z (sin.f64 y))) < 5e14

    1. Initial program 100.0%

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

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

        \[\leadsto \color{blue}{\cos y + x} \]
      2. lower-+.f64N/A

        \[\leadsto \color{blue}{\cos y + x} \]
      3. lower-cos.f6496.8

        \[\leadsto \color{blue}{\cos y} + x \]
    5. Applied rewrites96.8%

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

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

Alternative 4: 74.1% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(x + \cos y\right) - z \cdot \sin y\\ t_1 := x - \mathsf{fma}\left(y, z, -1\right)\\ \mathbf{if}\;t\_0 \leq -10000000:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_0 \leq 0.99:\\ \;\;\;\;\cos y\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (- (+ x (cos y)) (* z (sin y)))) (t_1 (- x (fma y z -1.0))))
   (if (<= t_0 -10000000.0) t_1 (if (<= t_0 0.99) (cos y) t_1))))
double code(double x, double y, double z) {
	double t_0 = (x + cos(y)) - (z * sin(y));
	double t_1 = x - fma(y, z, -1.0);
	double tmp;
	if (t_0 <= -10000000.0) {
		tmp = t_1;
	} else if (t_0 <= 0.99) {
		tmp = cos(y);
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(x, y, z)
	t_0 = Float64(Float64(x + cos(y)) - Float64(z * sin(y)))
	t_1 = Float64(x - fma(y, z, -1.0))
	tmp = 0.0
	if (t_0 <= -10000000.0)
		tmp = t_1;
	elseif (t_0 <= 0.99)
		tmp = cos(y);
	else
		tmp = t_1;
	end
	return tmp
end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x + N[Cos[y], $MachinePrecision]), $MachinePrecision] - N[(z * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x - N[(y * z + -1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -10000000.0], t$95$1, If[LessEqual[t$95$0, 0.99], N[Cos[y], $MachinePrecision], t$95$1]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(x + \cos y\right) - z \cdot \sin y\\
t_1 := x - \mathsf{fma}\left(y, z, -1\right)\\
\mathbf{if}\;t\_0 \leq -10000000:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t\_0 \leq 0.99:\\
\;\;\;\;\cos y\\

\mathbf{else}:\\
\;\;\;\;t\_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (+.f64 x (cos.f64 y)) (*.f64 z (sin.f64 y))) < -1e7 or 0.98999999999999999 < (-.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 \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. metadata-evalN/A

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

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

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

    if -1e7 < (-.f64 (+.f64 x (cos.f64 y)) (*.f64 z (sin.f64 y))) < 0.98999999999999999

    1. Initial program 99.9%

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

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

        \[\leadsto \color{blue}{\cos y + x} \]
      2. lower-+.f64N/A

        \[\leadsto \color{blue}{\cos y + x} \]
      3. lower-cos.f6497.7

        \[\leadsto \color{blue}{\cos y} + x \]
    5. Applied rewrites97.7%

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

      \[\leadsto \color{blue}{\cos y} \]
    7. Step-by-step derivation
      1. lower-cos.f6493.5

        \[\leadsto \color{blue}{\cos y} \]
    8. Applied rewrites93.5%

      \[\leadsto \color{blue}{\cos y} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 5: 81.6% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sin y \cdot \left(-z\right)\\ \mathbf{if}\;z \leq -1.35 \cdot 10^{+224}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq 1.1 \cdot 10^{+155}:\\ \;\;\;\;x + \cos y\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* (sin y) (- z))))
   (if (<= z -1.35e+224) t_0 (if (<= z 1.1e+155) (+ x (cos y)) t_0))))
double code(double x, double y, double z) {
	double t_0 = sin(y) * -z;
	double tmp;
	if (z <= -1.35e+224) {
		tmp = t_0;
	} else if (z <= 1.1e+155) {
		tmp = x + cos(y);
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: tmp
    t_0 = sin(y) * -z
    if (z <= (-1.35d+224)) then
        tmp = t_0
    else if (z <= 1.1d+155) then
        tmp = x + cos(y)
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = Math.sin(y) * -z;
	double tmp;
	if (z <= -1.35e+224) {
		tmp = t_0;
	} else if (z <= 1.1e+155) {
		tmp = x + Math.cos(y);
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = math.sin(y) * -z
	tmp = 0
	if z <= -1.35e+224:
		tmp = t_0
	elif z <= 1.1e+155:
		tmp = x + math.cos(y)
	else:
		tmp = t_0
	return tmp
function code(x, y, z)
	t_0 = Float64(sin(y) * Float64(-z))
	tmp = 0.0
	if (z <= -1.35e+224)
		tmp = t_0;
	elseif (z <= 1.1e+155)
		tmp = Float64(x + cos(y));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = sin(y) * -z;
	tmp = 0.0;
	if (z <= -1.35e+224)
		tmp = t_0;
	elseif (z <= 1.1e+155)
		tmp = x + cos(y);
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[Sin[y], $MachinePrecision] * (-z)), $MachinePrecision]}, If[LessEqual[z, -1.35e+224], t$95$0, If[LessEqual[z, 1.1e+155], N[(x + N[Cos[y], $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sin y \cdot \left(-z\right)\\
\mathbf{if}\;z \leq -1.35 \cdot 10^{+224}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;z \leq 1.1 \cdot 10^{+155}:\\
\;\;\;\;x + \cos y\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -1.3499999999999999e224 or 1.1000000000000001e155 < z

    1. Initial program 99.9%

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

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

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

        \[\leadsto -z \cdot \color{blue}{\sin y} \]
    5. Applied rewrites78.1%

      \[\leadsto \color{blue}{-z \cdot \sin y} \]

    if -1.3499999999999999e224 < z < 1.1000000000000001e155

    1. Initial program 99.9%

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

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

        \[\leadsto \color{blue}{\cos y + x} \]
      2. lower-+.f64N/A

        \[\leadsto \color{blue}{\cos y + x} \]
      3. lower-cos.f6487.3

        \[\leadsto \color{blue}{\cos y} + x \]
    5. Applied rewrites87.3%

      \[\leadsto \color{blue}{\cos y + x} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification85.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.35 \cdot 10^{+224}:\\ \;\;\;\;\sin y \cdot \left(-z\right)\\ \mathbf{elif}\;z \leq 1.1 \cdot 10^{+155}:\\ \;\;\;\;x + \cos y\\ \mathbf{else}:\\ \;\;\;\;\sin y \cdot \left(-z\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 80.5% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x + \cos y\\ \mathbf{if}\;y \leq -2.25 \cdot 10^{+50}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq 0.0305:\\ \;\;\;\;\mathsf{fma}\left(y, y \cdot -0.5 - z, x + 1\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (+ x (cos y))))
   (if (<= y -2.25e+50)
     t_0
     (if (<= y 0.0305) (fma y (- (* y -0.5) z) (+ x 1.0)) t_0))))
double code(double x, double y, double z) {
	double t_0 = x + cos(y);
	double tmp;
	if (y <= -2.25e+50) {
		tmp = t_0;
	} else if (y <= 0.0305) {
		tmp = fma(y, ((y * -0.5) - z), (x + 1.0));
	} else {
		tmp = t_0;
	}
	return tmp;
}
function code(x, y, z)
	t_0 = Float64(x + cos(y))
	tmp = 0.0
	if (y <= -2.25e+50)
		tmp = t_0;
	elseif (y <= 0.0305)
		tmp = fma(y, Float64(Float64(y * -0.5) - z), Float64(x + 1.0));
	else
		tmp = t_0;
	end
	return tmp
end
code[x_, y_, z_] := Block[{t$95$0 = N[(x + N[Cos[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -2.25e+50], t$95$0, If[LessEqual[y, 0.0305], N[(y * N[(N[(y * -0.5), $MachinePrecision] - z), $MachinePrecision] + N[(x + 1.0), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := x + \cos y\\
\mathbf{if}\;y \leq -2.25 \cdot 10^{+50}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y \leq 0.0305:\\
\;\;\;\;\mathsf{fma}\left(y, y \cdot -0.5 - z, x + 1\right)\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -2.25000000000000007e50 or 0.030499999999999999 < y

    1. Initial program 99.9%

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

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

        \[\leadsto \color{blue}{\cos y + x} \]
      2. lower-+.f64N/A

        \[\leadsto \color{blue}{\cos y + x} \]
      3. lower-cos.f6464.7

        \[\leadsto \color{blue}{\cos y} + x \]
    5. Applied rewrites64.7%

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

    if -2.25000000000000007e50 < y < 0.030499999999999999

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2.25 \cdot 10^{+50}:\\ \;\;\;\;x + \cos y\\ \mathbf{elif}\;y \leq 0.0305:\\ \;\;\;\;\mathsf{fma}\left(y, y \cdot -0.5 - z, x + 1\right)\\ \mathbf{else}:\\ \;\;\;\;x + \cos y\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 70.4% accurate, 7.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -8.2 \cdot 10^{+17}:\\
\;\;\;\;x + 1\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -8.2e17 or 4.4e15 < 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 \color{blue}{1 + x} \]
    4. Step-by-step derivation
      1. +-commutativeN/A

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

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

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

    if -8.2e17 < y < 4.4e15

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

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

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

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

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

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

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

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

Alternative 8: 70.2% accurate, 9.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.75 \cdot 10^{+20}:\\
\;\;\;\;x + 1\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -2.75e20 or 2.65e67 < y

    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 + x} \]
    4. Step-by-step derivation
      1. +-commutativeN/A

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

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

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

    if -2.75e20 < y < 2.65e67

    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. metadata-evalN/A

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

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

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

Alternative 9: 67.4% accurate, 10.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -8.2 \cdot 10^{-9}:\\
\;\;\;\;x + 1\\

\mathbf{elif}\;x \leq 0.48:\\
\;\;\;\;\mathsf{fma}\left(z, -y, 1\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -8.2000000000000006e-9 or 0.47999999999999998 < x

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

        \[\leadsto \color{blue}{x + 1} \]
      2. lower-+.f6488.6

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

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

    if -8.2000000000000006e-9 < x < 0.47999999999999998

    1. Initial program 99.9%

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

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

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

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

        \[\leadsto \left(x + \cos y\right) - \color{blue}{z \cdot \sin y} \]
      5. 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}} \]
      6. 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)}}} \]
      7. 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)}}} \]
      8. 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}}}} \]
      9. flip--N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\frac{1}{x + \color{blue}{\left(1 - y \cdot z\right)}}} \]
      8. lower-*.f6452.2

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

      \[\leadsto \frac{1}{\frac{1}{\color{blue}{x + \left(1 - y \cdot z\right)}}} \]
    8. Taylor expanded in x around 0

      \[\leadsto \color{blue}{1 - y \cdot z} \]
    9. Step-by-step derivation
      1. cancel-sign-sub-invN/A

        \[\leadsto \color{blue}{1 + \left(\mathsf{neg}\left(y\right)\right) \cdot z} \]
      2. lft-mult-inverseN/A

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

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

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

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

        \[\leadsto \color{blue}{z \cdot \left(-1 \cdot y\right) + z \cdot \frac{1}{z}} \]
      7. rgt-mult-inverseN/A

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

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

        \[\leadsto \mathsf{fma}\left(z, \color{blue}{\mathsf{neg}\left(y\right)}, 1\right) \]
      10. lower-neg.f6451.7

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

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

Alternative 10: 62.4% accurate, 15.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq 1.8 \cdot 10^{+206}:\\
\;\;\;\;x + 1\\

\mathbf{else}:\\
\;\;\;\;y \cdot \left(-z\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < 1.80000000000000014e206

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

        \[\leadsto \color{blue}{x + 1} \]
      2. lower-+.f6470.3

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

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

    if 1.80000000000000014e206 < z

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

        \[\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)} \]
      2. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(z \cdot y\right)} \cdot \left(\frac{1}{6} \cdot {y}^{2} - 1\right) \]
      3. associate-*l*N/A

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

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

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

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

        \[\leadsto z \cdot \left(y \cdot \left(\color{blue}{{y}^{2} \cdot \frac{1}{6}} + \left(\mathsf{neg}\left(1\right)\right)\right)\right) \]
      8. unpow2N/A

        \[\leadsto z \cdot \left(y \cdot \left(\color{blue}{\left(y \cdot y\right)} \cdot \frac{1}{6} + \left(\mathsf{neg}\left(1\right)\right)\right)\right) \]
      9. associate-*l*N/A

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

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

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

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

        \[\leadsto z \cdot \left(y \cdot \mathsf{fma}\left(y, \color{blue}{y \cdot \frac{1}{6}}, -1\right)\right) \]
      14. lower-*.f6440.0

        \[\leadsto z \cdot \left(y \cdot \mathsf{fma}\left(y, \color{blue}{y \cdot 0.16666666666666666}, -1\right)\right) \]
    8. Applied rewrites40.0%

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

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

        \[\leadsto z \cdot \color{blue}{\left(\mathsf{neg}\left(y\right)\right)} \]
      2. lower-neg.f6441.7

        \[\leadsto z \cdot \color{blue}{\left(-y\right)} \]
    11. Applied rewrites41.7%

      \[\leadsto z \cdot \color{blue}{\left(-y\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification67.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq 1.8 \cdot 10^{+206}:\\ \;\;\;\;x + 1\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(-z\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 61.6% accurate, 53.0× speedup?

\[\begin{array}{l} \\ x + 1 \end{array} \]
(FPCore (x y z) :precision binary64 (+ x 1.0))
double code(double x, double y, double z) {
	return x + 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 = x + 1.0d0
end function
public static double code(double x, double y, double z) {
	return x + 1.0;
}
def code(x, y, z):
	return x + 1.0
function code(x, y, z)
	return Float64(x + 1.0)
end
function tmp = code(x, y, z)
	tmp = x + 1.0;
end
code[x_, y_, z_] := N[(x + 1.0), $MachinePrecision]
\begin{array}{l}

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

      \[\leadsto \color{blue}{x + 1} \]
    2. lower-+.f6465.3

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

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

Alternative 12: 21.2% 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. +-commutativeN/A

      \[\leadsto \color{blue}{x + 1} \]
    2. lower-+.f6465.3

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

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

    \[\leadsto \color{blue}{1} \]
  7. Step-by-step derivation
    1. Applied rewrites20.6%

      \[\leadsto \color{blue}{1} \]
    2. Add Preprocessing

    Reproduce

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