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

Percentage Accurate: 99.9% → 99.9%
Time: 9.9s
Alternatives: 12
Speedup: 1.0×

Specification

?
\[\begin{array}{l} \\ \left(x + \sin y\right) + z \cdot \cos y \end{array} \]
(FPCore (x y z) :precision binary64 (+ (+ x (sin y)) (* z (cos y))))
double code(double x, double y, double z) {
	return (x + sin(y)) + (z * cos(y));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 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 + \sin y\right) + z \cdot \cos y \end{array} \]
(FPCore (x y z) :precision binary64 (+ (+ x (sin y)) (* z (cos y))))
double code(double x, double y, double z) {
	return (x + sin(y)) + (z * cos(y));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

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

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

Alternative 1: 99.9% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 94.0% accurate, 0.2× speedup?

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

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

\mathbf{elif}\;t\_1 \leq -5000000000:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;t\_1 \leq 50:\\
\;\;\;\;\mathsf{fma}\left(1, z, \sin y + x\right)\\

\mathbf{elif}\;t\_1 \leq 10^{+154}:\\
\;\;\;\;t\_0\\

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

    if -5.0000000000000005e229 < (+.f64 (+.f64 x (sin.f64 y)) (*.f64 z (cos.f64 y))) < -5e9 or 50 < (+.f64 (+.f64 x (sin.f64 y)) (*.f64 z (cos.f64 y))) < 1.00000000000000004e154

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        if -5e9 < (+.f64 (+.f64 x (sin.f64 y)) (*.f64 z (cos.f64 y))) < 50

        1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

        Alternative 3: 80.7% accurate, 0.2× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(1, z, \sin y\right)\\ t_1 := \left(x + \sin y\right) + z \cdot \cos y\\ \mathbf{if}\;t\_1 \leq -50000:\\ \;\;\;\;z + x\\ \mathbf{elif}\;t\_1 \leq -0.05:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-24}:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.16666666666666666, y, -0.5 \cdot z\right), y, 1\right), y, z + x\right)\\ \mathbf{elif}\;t\_1 \leq 1:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;z + x\\ \end{array} \end{array} \]
        (FPCore (x y z)
         :precision binary64
         (let* ((t_0 (fma 1.0 z (sin y))) (t_1 (+ (+ x (sin y)) (* z (cos y)))))
           (if (<= t_1 -50000.0)
             (+ z x)
             (if (<= t_1 -0.05)
               t_0
               (if (<= t_1 5e-24)
                 (fma (fma (fma -0.16666666666666666 y (* -0.5 z)) y 1.0) y (+ z x))
                 (if (<= t_1 1.0) t_0 (+ z x)))))))
        double code(double x, double y, double z) {
        	double t_0 = fma(1.0, z, sin(y));
        	double t_1 = (x + sin(y)) + (z * cos(y));
        	double tmp;
        	if (t_1 <= -50000.0) {
        		tmp = z + x;
        	} else if (t_1 <= -0.05) {
        		tmp = t_0;
        	} else if (t_1 <= 5e-24) {
        		tmp = fma(fma(fma(-0.16666666666666666, y, (-0.5 * z)), y, 1.0), y, (z + x));
        	} else if (t_1 <= 1.0) {
        		tmp = t_0;
        	} else {
        		tmp = z + x;
        	}
        	return tmp;
        }
        
        function code(x, y, z)
        	t_0 = fma(1.0, z, sin(y))
        	t_1 = Float64(Float64(x + sin(y)) + Float64(z * cos(y)))
        	tmp = 0.0
        	if (t_1 <= -50000.0)
        		tmp = Float64(z + x);
        	elseif (t_1 <= -0.05)
        		tmp = t_0;
        	elseif (t_1 <= 5e-24)
        		tmp = fma(fma(fma(-0.16666666666666666, y, Float64(-0.5 * z)), y, 1.0), y, Float64(z + x));
        	elseif (t_1 <= 1.0)
        		tmp = t_0;
        	else
        		tmp = Float64(z + x);
        	end
        	return tmp
        end
        
        code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 * z + N[Sin[y], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision] + N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -50000.0], N[(z + x), $MachinePrecision], If[LessEqual[t$95$1, -0.05], t$95$0, If[LessEqual[t$95$1, 5e-24], N[(N[(N[(-0.16666666666666666 * y + N[(-0.5 * z), $MachinePrecision]), $MachinePrecision] * y + 1.0), $MachinePrecision] * y + N[(z + x), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1.0], t$95$0, N[(z + x), $MachinePrecision]]]]]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        t_0 := \mathsf{fma}\left(1, z, \sin y\right)\\
        t_1 := \left(x + \sin y\right) + z \cdot \cos y\\
        \mathbf{if}\;t\_1 \leq -50000:\\
        \;\;\;\;z + x\\
        
        \mathbf{elif}\;t\_1 \leq -0.05:\\
        \;\;\;\;t\_0\\
        
        \mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-24}:\\
        \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.16666666666666666, y, -0.5 \cdot z\right), y, 1\right), y, z + x\right)\\
        
        \mathbf{elif}\;t\_1 \leq 1:\\
        \;\;\;\;t\_0\\
        
        \mathbf{else}:\\
        \;\;\;\;z + x\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 3 regimes
        2. if (+.f64 (+.f64 x (sin.f64 y)) (*.f64 z (cos.f64 y))) < -5e4 or 1 < (+.f64 (+.f64 x (sin.f64 y)) (*.f64 z (cos.f64 y)))

          1. Initial program 100.0%

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

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

              \[\leadsto \color{blue}{z + x} \]
            2. lower-+.f6477.5

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

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

          if -5e4 < (+.f64 (+.f64 x (sin.f64 y)) (*.f64 z (cos.f64 y))) < -0.050000000000000003 or 4.9999999999999998e-24 < (+.f64 (+.f64 x (sin.f64 y)) (*.f64 z (cos.f64 y))) < 1

          1. Initial program 100.0%

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

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

              \[\leadsto \color{blue}{z \cdot \cos y + \sin y} \]
            2. *-commutativeN/A

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

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

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

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

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

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

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

            if -0.050000000000000003 < (+.f64 (+.f64 x (sin.f64 y)) (*.f64 z (cos.f64 y))) < 4.9999999999999998e-24

            1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          Alternative 4: 89.0% accurate, 1.7× speedup?

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

            1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

            if -1.50000000000000001e146 < z < 1.7e21

            1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

            Alternative 5: 88.3% accurate, 1.7× speedup?

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

              1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                  if -4.1000000000000001e93 < z < 9.79999999999999962e36

                  1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

                  Alternative 6: 72.7% accurate, 1.8× speedup?

                  \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -2000 \lor \neg \left(x \leq 3.5 \cdot 10^{-81}\right):\\ \;\;\;\;z + x\\ \mathbf{else}:\\ \;\;\;\;\cos y \cdot z\\ \end{array} \end{array} \]
                  (FPCore (x y z)
                   :precision binary64
                   (if (or (<= x -2000.0) (not (<= x 3.5e-81))) (+ z x) (* (cos y) z)))
                  double code(double x, double y, double z) {
                  	double tmp;
                  	if ((x <= -2000.0) || !(x <= 3.5e-81)) {
                  		tmp = z + x;
                  	} else {
                  		tmp = cos(y) * z;
                  	}
                  	return tmp;
                  }
                  
                  module fmin_fmax_functions
                      implicit none
                      private
                      public fmax
                      public fmin
                  
                      interface fmax
                          module procedure fmax88
                          module procedure fmax44
                          module procedure fmax84
                          module procedure fmax48
                      end interface
                      interface fmin
                          module procedure fmin88
                          module procedure fmin44
                          module procedure fmin84
                          module procedure fmin48
                      end interface
                  contains
                      real(8) function fmax88(x, y) result (res)
                          real(8), intent (in) :: x
                          real(8), intent (in) :: y
                          res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                      end function
                      real(4) function fmax44(x, y) result (res)
                          real(4), intent (in) :: x
                          real(4), intent (in) :: y
                          res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                      end function
                      real(8) function fmax84(x, y) result(res)
                          real(8), intent (in) :: x
                          real(4), intent (in) :: y
                          res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                      end function
                      real(8) function fmax48(x, y) result(res)
                          real(4), intent (in) :: x
                          real(8), intent (in) :: y
                          res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                      end function
                      real(8) function fmin88(x, y) result (res)
                          real(8), intent (in) :: x
                          real(8), intent (in) :: y
                          res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                      end function
                      real(4) function fmin44(x, y) result (res)
                          real(4), intent (in) :: x
                          real(4), intent (in) :: y
                          res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                      end function
                      real(8) function fmin84(x, y) result(res)
                          real(8), intent (in) :: x
                          real(4), intent (in) :: y
                          res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                      end function
                      real(8) function fmin48(x, y) result(res)
                          real(4), intent (in) :: x
                          real(8), intent (in) :: y
                          res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                      end function
                  end module
                  
                  real(8) function code(x, y, z)
                  use fmin_fmax_functions
                      real(8), intent (in) :: x
                      real(8), intent (in) :: y
                      real(8), intent (in) :: z
                      real(8) :: tmp
                      if ((x <= (-2000.0d0)) .or. (.not. (x <= 3.5d-81))) then
                          tmp = z + x
                      else
                          tmp = cos(y) * z
                      end if
                      code = tmp
                  end function
                  
                  public static double code(double x, double y, double z) {
                  	double tmp;
                  	if ((x <= -2000.0) || !(x <= 3.5e-81)) {
                  		tmp = z + x;
                  	} else {
                  		tmp = Math.cos(y) * z;
                  	}
                  	return tmp;
                  }
                  
                  def code(x, y, z):
                  	tmp = 0
                  	if (x <= -2000.0) or not (x <= 3.5e-81):
                  		tmp = z + x
                  	else:
                  		tmp = math.cos(y) * z
                  	return tmp
                  
                  function code(x, y, z)
                  	tmp = 0.0
                  	if ((x <= -2000.0) || !(x <= 3.5e-81))
                  		tmp = Float64(z + x);
                  	else
                  		tmp = Float64(cos(y) * z);
                  	end
                  	return tmp
                  end
                  
                  function tmp_2 = code(x, y, z)
                  	tmp = 0.0;
                  	if ((x <= -2000.0) || ~((x <= 3.5e-81)))
                  		tmp = z + x;
                  	else
                  		tmp = cos(y) * z;
                  	end
                  	tmp_2 = tmp;
                  end
                  
                  code[x_, y_, z_] := If[Or[LessEqual[x, -2000.0], N[Not[LessEqual[x, 3.5e-81]], $MachinePrecision]], N[(z + x), $MachinePrecision], N[(N[Cos[y], $MachinePrecision] * z), $MachinePrecision]]
                  
                  \begin{array}{l}
                  
                  \\
                  \begin{array}{l}
                  \mathbf{if}\;x \leq -2000 \lor \neg \left(x \leq 3.5 \cdot 10^{-81}\right):\\
                  \;\;\;\;z + x\\
                  
                  \mathbf{else}:\\
                  \;\;\;\;\cos y \cdot z\\
                  
                  
                  \end{array}
                  \end{array}
                  
                  Derivation
                  1. Split input into 2 regimes
                  2. if x < -2e3 or 3.49999999999999986e-81 < x

                    1. Initial program 100.0%

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

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

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

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

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

                    if -2e3 < x < 3.49999999999999986e-81

                    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                          \[\leadsto \cos y \cdot \color{blue}{z} \]
                      4. Recombined 2 regimes into one program.
                      5. Final simplification76.4%

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

                      Alternative 7: 69.8% accurate, 3.4× speedup?

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

                        1. Initial program 99.9%

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

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

                            \[\leadsto \color{blue}{z + x} \]
                          2. lower-+.f6446.6

                            \[\leadsto \color{blue}{z + x} \]
                        5. Applied rewrites46.6%

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

                        if -1.7e18 < y < 54000

                        1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                          \[\leadsto \left(y + x\right) + \color{blue}{\left(z + {y}^{2} \cdot \left(\frac{-1}{2} \cdot z + {y}^{2} \cdot \left(\frac{-1}{720} \cdot \left({y}^{2} \cdot z\right) + \frac{1}{24} \cdot z\right)\right)\right)} \]
                        10. Step-by-step derivation
                          1. +-commutativeN/A

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

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

                            \[\leadsto \left(y + x\right) + \color{blue}{\mathsf{fma}\left(\frac{-1}{2} \cdot z + {y}^{2} \cdot \left(\frac{-1}{720} \cdot \left({y}^{2} \cdot z\right) + \frac{1}{24} \cdot z\right), {y}^{2}, z\right)} \]
                        11. Applied rewrites98.0%

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

                        \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.7 \cdot 10^{+18} \lor \neg \left(y \leq 54000\right):\\ \;\;\;\;z + x\\ \mathbf{else}:\\ \;\;\;\;\left(y + x\right) + \mathsf{fma}\left(\mathsf{fma}\left(z \cdot \mathsf{fma}\left(-0.001388888888888889, y \cdot y, 0.041666666666666664\right), y \cdot y, -0.5 \cdot z\right), y \cdot y, z\right)\\ \end{array} \]
                      5. Add Preprocessing

                      Alternative 8: 69.8% accurate, 5.4× speedup?

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

                        1. Initial program 99.9%

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

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

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

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

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

                        if -1.6e10 < y < 1.1e5

                        1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                      Alternative 9: 69.7% accurate, 6.4× speedup?

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

                        1. Initial program 99.9%

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

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

                            \[\leadsto \color{blue}{z + x} \]
                          2. lower-+.f6446.6

                            \[\leadsto \color{blue}{z + x} \]
                        5. Applied rewrites46.6%

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

                        if -6.4e18 < y < 1.1e5

                        1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                        Alternative 10: 69.7% accurate, 11.1× speedup?

                        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -1.7 \cdot 10^{+18} \lor \neg \left(y \leq 70000\right):\\ \;\;\;\;z + x\\ \mathbf{else}:\\ \;\;\;\;\left(z + y\right) + x\\ \end{array} \end{array} \]
                        (FPCore (x y z)
                         :precision binary64
                         (if (or (<= y -1.7e+18) (not (<= y 70000.0))) (+ z x) (+ (+ z y) x)))
                        double code(double x, double y, double z) {
                        	double tmp;
                        	if ((y <= -1.7e+18) || !(y <= 70000.0)) {
                        		tmp = z + x;
                        	} else {
                        		tmp = (z + y) + x;
                        	}
                        	return tmp;
                        }
                        
                        module fmin_fmax_functions
                            implicit none
                            private
                            public fmax
                            public fmin
                        
                            interface fmax
                                module procedure fmax88
                                module procedure fmax44
                                module procedure fmax84
                                module procedure fmax48
                            end interface
                            interface fmin
                                module procedure fmin88
                                module procedure fmin44
                                module procedure fmin84
                                module procedure fmin48
                            end interface
                        contains
                            real(8) function fmax88(x, y) result (res)
                                real(8), intent (in) :: x
                                real(8), intent (in) :: y
                                res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                            end function
                            real(4) function fmax44(x, y) result (res)
                                real(4), intent (in) :: x
                                real(4), intent (in) :: y
                                res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                            end function
                            real(8) function fmax84(x, y) result(res)
                                real(8), intent (in) :: x
                                real(4), intent (in) :: y
                                res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                            end function
                            real(8) function fmax48(x, y) result(res)
                                real(4), intent (in) :: x
                                real(8), intent (in) :: y
                                res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                            end function
                            real(8) function fmin88(x, y) result (res)
                                real(8), intent (in) :: x
                                real(8), intent (in) :: y
                                res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                            end function
                            real(4) function fmin44(x, y) result (res)
                                real(4), intent (in) :: x
                                real(4), intent (in) :: y
                                res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                            end function
                            real(8) function fmin84(x, y) result(res)
                                real(8), intent (in) :: x
                                real(4), intent (in) :: y
                                res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                            end function
                            real(8) function fmin48(x, y) result(res)
                                real(4), intent (in) :: x
                                real(8), intent (in) :: y
                                res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                            end function
                        end module
                        
                        real(8) function code(x, y, z)
                        use fmin_fmax_functions
                            real(8), intent (in) :: x
                            real(8), intent (in) :: y
                            real(8), intent (in) :: z
                            real(8) :: tmp
                            if ((y <= (-1.7d+18)) .or. (.not. (y <= 70000.0d0))) then
                                tmp = z + x
                            else
                                tmp = (z + y) + x
                            end if
                            code = tmp
                        end function
                        
                        public static double code(double x, double y, double z) {
                        	double tmp;
                        	if ((y <= -1.7e+18) || !(y <= 70000.0)) {
                        		tmp = z + x;
                        	} else {
                        		tmp = (z + y) + x;
                        	}
                        	return tmp;
                        }
                        
                        def code(x, y, z):
                        	tmp = 0
                        	if (y <= -1.7e+18) or not (y <= 70000.0):
                        		tmp = z + x
                        	else:
                        		tmp = (z + y) + x
                        	return tmp
                        
                        function code(x, y, z)
                        	tmp = 0.0
                        	if ((y <= -1.7e+18) || !(y <= 70000.0))
                        		tmp = Float64(z + x);
                        	else
                        		tmp = Float64(Float64(z + y) + x);
                        	end
                        	return tmp
                        end
                        
                        function tmp_2 = code(x, y, z)
                        	tmp = 0.0;
                        	if ((y <= -1.7e+18) || ~((y <= 70000.0)))
                        		tmp = z + x;
                        	else
                        		tmp = (z + y) + x;
                        	end
                        	tmp_2 = tmp;
                        end
                        
                        code[x_, y_, z_] := If[Or[LessEqual[y, -1.7e+18], N[Not[LessEqual[y, 70000.0]], $MachinePrecision]], N[(z + x), $MachinePrecision], N[(N[(z + y), $MachinePrecision] + x), $MachinePrecision]]
                        
                        \begin{array}{l}
                        
                        \\
                        \begin{array}{l}
                        \mathbf{if}\;y \leq -1.7 \cdot 10^{+18} \lor \neg \left(y \leq 70000\right):\\
                        \;\;\;\;z + x\\
                        
                        \mathbf{else}:\\
                        \;\;\;\;\left(z + y\right) + x\\
                        
                        
                        \end{array}
                        \end{array}
                        
                        Derivation
                        1. Split input into 2 regimes
                        2. if y < -1.7e18 or 7e4 < y

                          1. Initial program 99.9%

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

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

                              \[\leadsto \color{blue}{z + x} \]
                            2. lower-+.f6446.6

                              \[\leadsto \color{blue}{z + x} \]
                          5. Applied rewrites46.6%

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

                          if -1.7e18 < y < 7e4

                          1. Initial program 100.0%

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

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

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

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

                              \[\leadsto \color{blue}{\left(z + y\right)} + x \]
                            4. lower-+.f6497.3

                              \[\leadsto \color{blue}{\left(z + y\right)} + x \]
                          5. Applied rewrites97.3%

                            \[\leadsto \color{blue}{\left(z + y\right) + x} \]
                        3. Recombined 2 regimes into one program.
                        4. Final simplification73.7%

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

                        Alternative 11: 67.3% accurate, 13.2× speedup?

                        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1.1 \cdot 10^{-189} \lor \neg \left(x \leq 8.2 \cdot 10^{-201}\right):\\ \;\;\;\;z + x\\ \mathbf{else}:\\ \;\;\;\;z + y\\ \end{array} \end{array} \]
                        (FPCore (x y z)
                         :precision binary64
                         (if (or (<= x -1.1e-189) (not (<= x 8.2e-201))) (+ z x) (+ z y)))
                        double code(double x, double y, double z) {
                        	double tmp;
                        	if ((x <= -1.1e-189) || !(x <= 8.2e-201)) {
                        		tmp = z + x;
                        	} else {
                        		tmp = z + y;
                        	}
                        	return tmp;
                        }
                        
                        module fmin_fmax_functions
                            implicit none
                            private
                            public fmax
                            public fmin
                        
                            interface fmax
                                module procedure fmax88
                                module procedure fmax44
                                module procedure fmax84
                                module procedure fmax48
                            end interface
                            interface fmin
                                module procedure fmin88
                                module procedure fmin44
                                module procedure fmin84
                                module procedure fmin48
                            end interface
                        contains
                            real(8) function fmax88(x, y) result (res)
                                real(8), intent (in) :: x
                                real(8), intent (in) :: y
                                res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                            end function
                            real(4) function fmax44(x, y) result (res)
                                real(4), intent (in) :: x
                                real(4), intent (in) :: y
                                res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                            end function
                            real(8) function fmax84(x, y) result(res)
                                real(8), intent (in) :: x
                                real(4), intent (in) :: y
                                res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                            end function
                            real(8) function fmax48(x, y) result(res)
                                real(4), intent (in) :: x
                                real(8), intent (in) :: y
                                res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                            end function
                            real(8) function fmin88(x, y) result (res)
                                real(8), intent (in) :: x
                                real(8), intent (in) :: y
                                res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                            end function
                            real(4) function fmin44(x, y) result (res)
                                real(4), intent (in) :: x
                                real(4), intent (in) :: y
                                res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                            end function
                            real(8) function fmin84(x, y) result(res)
                                real(8), intent (in) :: x
                                real(4), intent (in) :: y
                                res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                            end function
                            real(8) function fmin48(x, y) result(res)
                                real(4), intent (in) :: x
                                real(8), intent (in) :: y
                                res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                            end function
                        end module
                        
                        real(8) function code(x, y, z)
                        use fmin_fmax_functions
                            real(8), intent (in) :: x
                            real(8), intent (in) :: y
                            real(8), intent (in) :: z
                            real(8) :: tmp
                            if ((x <= (-1.1d-189)) .or. (.not. (x <= 8.2d-201))) then
                                tmp = z + x
                            else
                                tmp = z + y
                            end if
                            code = tmp
                        end function
                        
                        public static double code(double x, double y, double z) {
                        	double tmp;
                        	if ((x <= -1.1e-189) || !(x <= 8.2e-201)) {
                        		tmp = z + x;
                        	} else {
                        		tmp = z + y;
                        	}
                        	return tmp;
                        }
                        
                        def code(x, y, z):
                        	tmp = 0
                        	if (x <= -1.1e-189) or not (x <= 8.2e-201):
                        		tmp = z + x
                        	else:
                        		tmp = z + y
                        	return tmp
                        
                        function code(x, y, z)
                        	tmp = 0.0
                        	if ((x <= -1.1e-189) || !(x <= 8.2e-201))
                        		tmp = Float64(z + x);
                        	else
                        		tmp = Float64(z + y);
                        	end
                        	return tmp
                        end
                        
                        function tmp_2 = code(x, y, z)
                        	tmp = 0.0;
                        	if ((x <= -1.1e-189) || ~((x <= 8.2e-201)))
                        		tmp = z + x;
                        	else
                        		tmp = z + y;
                        	end
                        	tmp_2 = tmp;
                        end
                        
                        code[x_, y_, z_] := If[Or[LessEqual[x, -1.1e-189], N[Not[LessEqual[x, 8.2e-201]], $MachinePrecision]], N[(z + x), $MachinePrecision], N[(z + y), $MachinePrecision]]
                        
                        \begin{array}{l}
                        
                        \\
                        \begin{array}{l}
                        \mathbf{if}\;x \leq -1.1 \cdot 10^{-189} \lor \neg \left(x \leq 8.2 \cdot 10^{-201}\right):\\
                        \;\;\;\;z + x\\
                        
                        \mathbf{else}:\\
                        \;\;\;\;z + y\\
                        
                        
                        \end{array}
                        \end{array}
                        
                        Derivation
                        1. Split input into 2 regimes
                        2. if x < -1.1000000000000001e-189 or 8.20000000000000003e-201 < x

                          1. Initial program 100.0%

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

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

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

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

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

                          if -1.1000000000000001e-189 < x < 8.20000000000000003e-201

                          1. Initial program 99.9%

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

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

                              \[\leadsto \color{blue}{z \cdot \cos y + \sin y} \]
                            2. *-commutativeN/A

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

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

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

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

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

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

                              \[\leadsto z + \color{blue}{y} \]
                          8. Recombined 2 regimes into one program.
                          9. Final simplification72.5%

                            \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.1 \cdot 10^{-189} \lor \neg \left(x \leq 8.2 \cdot 10^{-201}\right):\\ \;\;\;\;z + x\\ \mathbf{else}:\\ \;\;\;\;z + y\\ \end{array} \]
                          10. Add Preprocessing

                          Alternative 12: 28.4% accurate, 53.0× speedup?

                          \[\begin{array}{l} \\ z + y \end{array} \]
                          (FPCore (x y z) :precision binary64 (+ z y))
                          double code(double x, double y, double z) {
                          	return z + y;
                          }
                          
                          module fmin_fmax_functions
                              implicit none
                              private
                              public fmax
                              public fmin
                          
                              interface fmax
                                  module procedure fmax88
                                  module procedure fmax44
                                  module procedure fmax84
                                  module procedure fmax48
                              end interface
                              interface fmin
                                  module procedure fmin88
                                  module procedure fmin44
                                  module procedure fmin84
                                  module procedure fmin48
                              end interface
                          contains
                              real(8) function fmax88(x, y) result (res)
                                  real(8), intent (in) :: x
                                  real(8), intent (in) :: y
                                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                              end function
                              real(4) function fmax44(x, y) result (res)
                                  real(4), intent (in) :: x
                                  real(4), intent (in) :: y
                                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                              end function
                              real(8) function fmax84(x, y) result(res)
                                  real(8), intent (in) :: x
                                  real(4), intent (in) :: y
                                  res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                              end function
                              real(8) function fmax48(x, y) result(res)
                                  real(4), intent (in) :: x
                                  real(8), intent (in) :: y
                                  res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                              end function
                              real(8) function fmin88(x, y) result (res)
                                  real(8), intent (in) :: x
                                  real(8), intent (in) :: y
                                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                              end function
                              real(4) function fmin44(x, y) result (res)
                                  real(4), intent (in) :: x
                                  real(4), intent (in) :: y
                                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                              end function
                              real(8) function fmin84(x, y) result(res)
                                  real(8), intent (in) :: x
                                  real(4), intent (in) :: y
                                  res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                              end function
                              real(8) function fmin48(x, y) result(res)
                                  real(4), intent (in) :: x
                                  real(8), intent (in) :: y
                                  res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                              end function
                          end module
                          
                          real(8) function code(x, y, z)
                          use fmin_fmax_functions
                              real(8), intent (in) :: x
                              real(8), intent (in) :: y
                              real(8), intent (in) :: z
                              code = z + y
                          end function
                          
                          public static double code(double x, double y, double z) {
                          	return z + y;
                          }
                          
                          def code(x, y, z):
                          	return z + y
                          
                          function code(x, y, z)
                          	return Float64(z + y)
                          end
                          
                          function tmp = code(x, y, z)
                          	tmp = z + y;
                          end
                          
                          code[x_, y_, z_] := N[(z + y), $MachinePrecision]
                          
                          \begin{array}{l}
                          
                          \\
                          z + y
                          \end{array}
                          
                          Derivation
                          1. Initial program 100.0%

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

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

                              \[\leadsto \color{blue}{z \cdot \cos y + \sin y} \]
                            2. *-commutativeN/A

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

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

                              \[\leadsto \mathsf{fma}\left(\color{blue}{\cos y}, z, \sin y\right) \]
                            5. lower-sin.f6452.5

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

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

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

                              \[\leadsto z + \color{blue}{y} \]
                            2. Final simplification26.5%

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

                            Reproduce

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