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

Percentage Accurate: 99.9% → 99.9%
Time: 6.6s
Alternatives: 9
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 9 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 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. Add Preprocessing

Alternative 2: 83.4% accurate, 1.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := z \cdot \cos y\\ \mathbf{if}\;z \leq -3.2 \cdot 10^{+24}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq 3.8 \cdot 10^{-28}:\\ \;\;\;\;\sin y + x\\ \mathbf{elif}\;z \leq 6.2 \cdot 10^{+62}:\\ \;\;\;\;z + x\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* z (cos y))))
   (if (<= z -3.2e+24)
     t_0
     (if (<= z 3.8e-28) (+ (sin y) x) (if (<= z 6.2e+62) (+ z x) t_0)))))
double code(double x, double y, double z) {
	double t_0 = z * cos(y);
	double tmp;
	if (z <= -3.2e+24) {
		tmp = t_0;
	} else if (z <= 3.8e-28) {
		tmp = sin(y) + x;
	} else if (z <= 6.2e+62) {
		tmp = z + x;
	} else {
		tmp = t_0;
	}
	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) :: t_0
    real(8) :: tmp
    t_0 = z * cos(y)
    if (z <= (-3.2d+24)) then
        tmp = t_0
    else if (z <= 3.8d-28) then
        tmp = sin(y) + x
    else if (z <= 6.2d+62) then
        tmp = z + x
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = z * Math.cos(y);
	double tmp;
	if (z <= -3.2e+24) {
		tmp = t_0;
	} else if (z <= 3.8e-28) {
		tmp = Math.sin(y) + x;
	} else if (z <= 6.2e+62) {
		tmp = z + x;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = z * math.cos(y)
	tmp = 0
	if z <= -3.2e+24:
		tmp = t_0
	elif z <= 3.8e-28:
		tmp = math.sin(y) + x
	elif z <= 6.2e+62:
		tmp = z + x
	else:
		tmp = t_0
	return tmp
function code(x, y, z)
	t_0 = Float64(z * cos(y))
	tmp = 0.0
	if (z <= -3.2e+24)
		tmp = t_0;
	elseif (z <= 3.8e-28)
		tmp = Float64(sin(y) + x);
	elseif (z <= 6.2e+62)
		tmp = Float64(z + x);
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = z * cos(y);
	tmp = 0.0;
	if (z <= -3.2e+24)
		tmp = t_0;
	elseif (z <= 3.8e-28)
		tmp = sin(y) + x;
	elseif (z <= 6.2e+62)
		tmp = z + x;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -3.2e+24], t$95$0, If[LessEqual[z, 3.8e-28], N[(N[Sin[y], $MachinePrecision] + x), $MachinePrecision], If[LessEqual[z, 6.2e+62], N[(z + x), $MachinePrecision], t$95$0]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := z \cdot \cos y\\
\mathbf{if}\;z \leq -3.2 \cdot 10^{+24}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;z \leq 3.8 \cdot 10^{-28}:\\
\;\;\;\;\sin y + x\\

\mathbf{elif}\;z \leq 6.2 \cdot 10^{+62}:\\
\;\;\;\;z + x\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -3.1999999999999997e24 or 6.20000000000000029e62 < 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 y around 0

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

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

        \[\leadsto \color{blue}{z \cdot \cos y} \]
      3. Step-by-step derivation
        1. lower-*.f64N/A

          \[\leadsto \color{blue}{z \cdot \cos y} \]
        2. lower-cos.f6476.9

          \[\leadsto z \cdot \color{blue}{\cos y} \]
      4. Applied rewrites76.9%

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

      if -3.1999999999999997e24 < z < 3.80000000000000009e-28

      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-+.f6468.5

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

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

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

          \[\leadsto \mathsf{fma}\left(\frac{z}{x}, \color{blue}{x}, x\right) \]
        2. Step-by-step derivation
          1. Applied rewrites68.4%

            \[\leadsto \left(\frac{z}{x} + 1\right) \cdot x \]
          2. Taylor expanded in z around 0

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

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

              \[\leadsto \color{blue}{\sin y + x} \]
            3. lower-sin.f6490.6

              \[\leadsto \color{blue}{\sin y} + x \]
          4. Applied rewrites90.6%

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

          if 3.80000000000000009e-28 < z < 6.20000000000000029e62

          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-+.f6492.8

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

            \[\leadsto \color{blue}{z + x} \]
        3. Recombined 3 regimes into one program.
        4. Final simplification85.9%

          \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -3.2 \cdot 10^{+24}:\\ \;\;\;\;z \cdot \cos y\\ \mathbf{elif}\;z \leq 3.8 \cdot 10^{-28}:\\ \;\;\;\;\sin y + x\\ \mathbf{elif}\;z \leq 6.2 \cdot 10^{+62}:\\ \;\;\;\;z + x\\ \mathbf{else}:\\ \;\;\;\;z \cdot \cos y\\ \end{array} \]
        5. Add Preprocessing

        Alternative 3: 89.3% accurate, 1.7× speedup?

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

          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 y around 0

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

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

              \[\leadsto \color{blue}{z \cdot \cos y} \]
            3. Step-by-step derivation
              1. lower-*.f64N/A

                \[\leadsto \color{blue}{z \cdot \cos y} \]
              2. lower-cos.f6492.6

                \[\leadsto z \cdot \color{blue}{\cos y} \]
            4. Applied rewrites92.6%

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

            if -5.8000000000000002e131 < z < 3.7999999999999999e95

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

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

              if 3.7999999999999999e95 < 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-+.f6486.3

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

                \[\leadsto \color{blue}{\left(y + x\right)} + z \cdot \cos y \]
            7. Recombined 3 regimes into one program.
            8. Add Preprocessing

            Alternative 4: 88.6% accurate, 1.7× speedup?

            \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -5.8 \cdot 10^{+131} \lor \neg \left(z \leq 6.2 \cdot 10^{+62}\right):\\ \;\;\;\;z \cdot \cos y\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(1, z, \sin y + x\right)\\ \end{array} \end{array} \]
            (FPCore (x y z)
             :precision binary64
             (if (or (<= z -5.8e+131) (not (<= z 6.2e+62)))
               (* z (cos y))
               (fma 1.0 z (+ (sin y) x))))
            double code(double x, double y, double z) {
            	double tmp;
            	if ((z <= -5.8e+131) || !(z <= 6.2e+62)) {
            		tmp = z * cos(y);
            	} else {
            		tmp = fma(1.0, z, (sin(y) + x));
            	}
            	return tmp;
            }
            
            function code(x, y, z)
            	tmp = 0.0
            	if ((z <= -5.8e+131) || !(z <= 6.2e+62))
            		tmp = Float64(z * cos(y));
            	else
            		tmp = fma(1.0, z, Float64(sin(y) + x));
            	end
            	return tmp
            end
            
            code[x_, y_, z_] := If[Or[LessEqual[z, -5.8e+131], N[Not[LessEqual[z, 6.2e+62]], $MachinePrecision]], N[(z * N[Cos[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 -5.8 \cdot 10^{+131} \lor \neg \left(z \leq 6.2 \cdot 10^{+62}\right):\\
            \;\;\;\;z \cdot \cos y\\
            
            \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 < -5.8000000000000002e131 or 6.20000000000000029e62 < 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 y around 0

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

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

                  \[\leadsto \color{blue}{z \cdot \cos y} \]
                3. Step-by-step derivation
                  1. lower-*.f64N/A

                    \[\leadsto \color{blue}{z \cdot \cos y} \]
                  2. lower-cos.f6479.1

                    \[\leadsto z \cdot \color{blue}{\cos y} \]
                4. Applied rewrites79.1%

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

                if -5.8000000000000002e131 < z < 6.20000000000000029e62

                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 rewrites95.5%

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

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

                Alternative 5: 89.3% accurate, 1.7× speedup?

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

                  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 y around 0

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

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

                      \[\leadsto \color{blue}{z \cdot \cos y} \]
                    3. Step-by-step derivation
                      1. lower-*.f64N/A

                        \[\leadsto \color{blue}{z \cdot \cos y} \]
                      2. lower-cos.f6492.6

                        \[\leadsto z \cdot \color{blue}{\cos y} \]
                    4. Applied rewrites92.6%

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

                    if -5.8000000000000002e131 < z < 3.7999999999999999e95

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

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

                      if 3.7999999999999999e95 < 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-+.f6486.3

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

                        \[\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.f6486.3

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

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

                    Alternative 6: 80.5% accurate, 1.8× speedup?

                    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -1.02 \cdot 10^{-5} \lor \neg \left(y \leq 850000000\right):\\ \;\;\;\;\sin y + x\\ \mathbf{else}:\\ \;\;\;\;\left(y + x\right) + z \cdot \mathsf{fma}\left(0.041666666666666664 \cdot \left(y \cdot y\right) - 0.5, y \cdot y, 1\right)\\ \end{array} \end{array} \]
                    (FPCore (x y z)
                     :precision binary64
                     (if (or (<= y -1.02e-5) (not (<= y 850000000.0)))
                       (+ (sin y) x)
                       (+
                        (+ y x)
                        (* z (fma (- (* 0.041666666666666664 (* y y)) 0.5) (* y y) 1.0)))))
                    double code(double x, double y, double z) {
                    	double tmp;
                    	if ((y <= -1.02e-5) || !(y <= 850000000.0)) {
                    		tmp = sin(y) + x;
                    	} else {
                    		tmp = (y + x) + (z * fma(((0.041666666666666664 * (y * y)) - 0.5), (y * y), 1.0));
                    	}
                    	return tmp;
                    }
                    
                    function code(x, y, z)
                    	tmp = 0.0
                    	if ((y <= -1.02e-5) || !(y <= 850000000.0))
                    		tmp = Float64(sin(y) + x);
                    	else
                    		tmp = Float64(Float64(y + x) + Float64(z * fma(Float64(Float64(0.041666666666666664 * Float64(y * y)) - 0.5), Float64(y * y), 1.0)));
                    	end
                    	return tmp
                    end
                    
                    code[x_, y_, z_] := If[Or[LessEqual[y, -1.02e-5], N[Not[LessEqual[y, 850000000.0]], $MachinePrecision]], N[(N[Sin[y], $MachinePrecision] + x), $MachinePrecision], N[(N[(y + x), $MachinePrecision] + N[(z * N[(N[(N[(0.041666666666666664 * N[(y * y), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision] * N[(y * y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
                    
                    \begin{array}{l}
                    
                    \\
                    \begin{array}{l}
                    \mathbf{if}\;y \leq -1.02 \cdot 10^{-5} \lor \neg \left(y \leq 850000000\right):\\
                    \;\;\;\;\sin y + x\\
                    
                    \mathbf{else}:\\
                    \;\;\;\;\left(y + x\right) + z \cdot \mathsf{fma}\left(0.041666666666666664 \cdot \left(y \cdot y\right) - 0.5, y \cdot y, 1\right)\\
                    
                    
                    \end{array}
                    \end{array}
                    
                    Derivation
                    1. Split input into 2 regimes
                    2. if y < -1.0200000000000001e-5 or 8.5e8 < 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-+.f6445.2

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

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

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

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

                            \[\leadsto \left(\frac{z}{x} + 1\right) \cdot x \]
                          2. Taylor expanded in z around 0

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

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

                              \[\leadsto \color{blue}{\sin y + x} \]
                            3. lower-sin.f6471.0

                              \[\leadsto \color{blue}{\sin y} + x \]
                          4. Applied rewrites71.0%

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

                          if -1.0200000000000001e-5 < y < 8.5e8

                          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-+.f6499.6

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                        Alternative 7: 51.3% accurate, 13.2× speedup?

                        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -9.2 \cdot 10^{-43} \lor \neg \left(x \leq 5.2 \cdot 10^{+44}\right):\\ \;\;\;\;y + x\\ \mathbf{else}:\\ \;\;\;\;z + y\\ \end{array} \end{array} \]
                        (FPCore (x y z)
                         :precision binary64
                         (if (or (<= x -9.2e-43) (not (<= x 5.2e+44))) (+ y x) (+ z y)))
                        double code(double x, double y, double z) {
                        	double tmp;
                        	if ((x <= -9.2e-43) || !(x <= 5.2e+44)) {
                        		tmp = y + 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 <= (-9.2d-43)) .or. (.not. (x <= 5.2d+44))) then
                                tmp = y + 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 <= -9.2e-43) || !(x <= 5.2e+44)) {
                        		tmp = y + x;
                        	} else {
                        		tmp = z + y;
                        	}
                        	return tmp;
                        }
                        
                        def code(x, y, z):
                        	tmp = 0
                        	if (x <= -9.2e-43) or not (x <= 5.2e+44):
                        		tmp = y + x
                        	else:
                        		tmp = z + y
                        	return tmp
                        
                        function code(x, y, z)
                        	tmp = 0.0
                        	if ((x <= -9.2e-43) || !(x <= 5.2e+44))
                        		tmp = Float64(y + x);
                        	else
                        		tmp = Float64(z + y);
                        	end
                        	return tmp
                        end
                        
                        function tmp_2 = code(x, y, z)
                        	tmp = 0.0;
                        	if ((x <= -9.2e-43) || ~((x <= 5.2e+44)))
                        		tmp = y + x;
                        	else
                        		tmp = z + y;
                        	end
                        	tmp_2 = tmp;
                        end
                        
                        code[x_, y_, z_] := If[Or[LessEqual[x, -9.2e-43], N[Not[LessEqual[x, 5.2e+44]], $MachinePrecision]], N[(y + x), $MachinePrecision], N[(z + y), $MachinePrecision]]
                        
                        \begin{array}{l}
                        
                        \\
                        \begin{array}{l}
                        \mathbf{if}\;x \leq -9.2 \cdot 10^{-43} \lor \neg \left(x \leq 5.2 \cdot 10^{+44}\right):\\
                        \;\;\;\;y + x\\
                        
                        \mathbf{else}:\\
                        \;\;\;\;z + y\\
                        
                        
                        \end{array}
                        \end{array}
                        
                        Derivation
                        1. Split input into 2 regimes
                        2. if x < -9.1999999999999995e-43 or 5.1999999999999998e44 < x

                          1. Initial program 99.9%

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

                            \[\leadsto \color{blue}{x + \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-+.f6468.2

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

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

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

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

                            if -9.1999999999999995e-43 < x < 5.1999999999999998e44

                            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.f6485.5

                                \[\leadsto \mathsf{fma}\left(\cos y, z, \color{blue}{\sin y}\right) \]
                            5. Applied rewrites85.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 rewrites40.1%

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

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

                            Alternative 8: 66.3% accurate, 53.0× speedup?

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

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

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

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

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

                              \[\leadsto \color{blue}{z + x} \]
                            6. Final simplification68.9%

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

                            Alternative 9: 29.8% 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 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.f6453.5

                                \[\leadsto \mathsf{fma}\left(\cos y, z, \color{blue}{\sin y}\right) \]
                            5. Applied rewrites53.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 rewrites25.9%

                                \[\leadsto z + \color{blue}{y} \]
                              2. Final simplification25.9%

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

                              Reproduce

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