Numeric.SpecFunctions:logGamma from math-functions-0.1.5.2, B

Percentage Accurate: 69.2% → 99.4%
Time: 4.0s
Alternatives: 11
Speedup: 2.2×

Specification

?
\[\begin{array}{l} \\ x + \frac{y \cdot \left(\left(z \cdot 0.0692910599291889 + 0.4917317610505968\right) \cdot z + 0.279195317918525\right)}{\left(z + 6.012459259764103\right) \cdot z + 3.350343815022304} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (+
  x
  (/
   (*
    y
    (+
     (* (+ (* z 0.0692910599291889) 0.4917317610505968) z)
     0.279195317918525))
   (+ (* (+ z 6.012459259764103) z) 3.350343815022304))))
double code(double x, double y, double z) {
	return x + ((y * ((((z * 0.0692910599291889) + 0.4917317610505968) * z) + 0.279195317918525)) / (((z + 6.012459259764103) * z) + 3.350343815022304));
}
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 + ((y * ((((z * 0.0692910599291889d0) + 0.4917317610505968d0) * z) + 0.279195317918525d0)) / (((z + 6.012459259764103d0) * z) + 3.350343815022304d0))
end function
public static double code(double x, double y, double z) {
	return x + ((y * ((((z * 0.0692910599291889) + 0.4917317610505968) * z) + 0.279195317918525)) / (((z + 6.012459259764103) * z) + 3.350343815022304));
}
def code(x, y, z):
	return x + ((y * ((((z * 0.0692910599291889) + 0.4917317610505968) * z) + 0.279195317918525)) / (((z + 6.012459259764103) * z) + 3.350343815022304))
function code(x, y, z)
	return Float64(x + Float64(Float64(y * Float64(Float64(Float64(Float64(z * 0.0692910599291889) + 0.4917317610505968) * z) + 0.279195317918525)) / Float64(Float64(Float64(z + 6.012459259764103) * z) + 3.350343815022304)))
end
function tmp = code(x, y, z)
	tmp = x + ((y * ((((z * 0.0692910599291889) + 0.4917317610505968) * z) + 0.279195317918525)) / (((z + 6.012459259764103) * z) + 3.350343815022304));
end
code[x_, y_, z_] := N[(x + N[(N[(y * N[(N[(N[(N[(z * 0.0692910599291889), $MachinePrecision] + 0.4917317610505968), $MachinePrecision] * z), $MachinePrecision] + 0.279195317918525), $MachinePrecision]), $MachinePrecision] / N[(N[(N[(z + 6.012459259764103), $MachinePrecision] * z), $MachinePrecision] + 3.350343815022304), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
x + \frac{y \cdot \left(\left(z \cdot 0.0692910599291889 + 0.4917317610505968\right) \cdot z + 0.279195317918525\right)}{\left(z + 6.012459259764103\right) \cdot z + 3.350343815022304}
\end{array}

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 11 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: 69.2% accurate, 1.0× speedup?

\[\begin{array}{l} \\ x + \frac{y \cdot \left(\left(z \cdot 0.0692910599291889 + 0.4917317610505968\right) \cdot z + 0.279195317918525\right)}{\left(z + 6.012459259764103\right) \cdot z + 3.350343815022304} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (+
  x
  (/
   (*
    y
    (+
     (* (+ (* z 0.0692910599291889) 0.4917317610505968) z)
     0.279195317918525))
   (+ (* (+ z 6.012459259764103) z) 3.350343815022304))))
double code(double x, double y, double z) {
	return x + ((y * ((((z * 0.0692910599291889) + 0.4917317610505968) * z) + 0.279195317918525)) / (((z + 6.012459259764103) * z) + 3.350343815022304));
}
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 + ((y * ((((z * 0.0692910599291889d0) + 0.4917317610505968d0) * z) + 0.279195317918525d0)) / (((z + 6.012459259764103d0) * z) + 3.350343815022304d0))
end function
public static double code(double x, double y, double z) {
	return x + ((y * ((((z * 0.0692910599291889) + 0.4917317610505968) * z) + 0.279195317918525)) / (((z + 6.012459259764103) * z) + 3.350343815022304));
}
def code(x, y, z):
	return x + ((y * ((((z * 0.0692910599291889) + 0.4917317610505968) * z) + 0.279195317918525)) / (((z + 6.012459259764103) * z) + 3.350343815022304))
function code(x, y, z)
	return Float64(x + Float64(Float64(y * Float64(Float64(Float64(Float64(z * 0.0692910599291889) + 0.4917317610505968) * z) + 0.279195317918525)) / Float64(Float64(Float64(z + 6.012459259764103) * z) + 3.350343815022304)))
end
function tmp = code(x, y, z)
	tmp = x + ((y * ((((z * 0.0692910599291889) + 0.4917317610505968) * z) + 0.279195317918525)) / (((z + 6.012459259764103) * z) + 3.350343815022304));
end
code[x_, y_, z_] := N[(x + N[(N[(y * N[(N[(N[(N[(z * 0.0692910599291889), $MachinePrecision] + 0.4917317610505968), $MachinePrecision] * z), $MachinePrecision] + 0.279195317918525), $MachinePrecision]), $MachinePrecision] / N[(N[(N[(z + 6.012459259764103), $MachinePrecision] * z), $MachinePrecision] + 3.350343815022304), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
x + \frac{y \cdot \left(\left(z \cdot 0.0692910599291889 + 0.4917317610505968\right) \cdot z + 0.279195317918525\right)}{\left(z + 6.012459259764103\right) \cdot z + 3.350343815022304}
\end{array}

Alternative 1: 99.4% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -130000000:\\ \;\;\;\;x + \mathsf{fma}\left(0.0692910599291889, y, \frac{y \cdot 0.07512208616047561}{z}\right)\\ \mathbf{elif}\;z \leq 860:\\ \;\;\;\;x + \frac{y \cdot \left(\left(z \cdot 0.0692910599291889 + 0.4917317610505968\right) \cdot z + 0.279195317918525\right)}{\left(z + 6.012459259764103\right) \cdot z + 3.350343815022304}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(0.0692910599291889, y, x\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= z -130000000.0)
   (+ x (fma 0.0692910599291889 y (/ (* y 0.07512208616047561) z)))
   (if (<= z 860.0)
     (+
      x
      (/
       (*
        y
        (+
         (* (+ (* z 0.0692910599291889) 0.4917317610505968) z)
         0.279195317918525))
       (+ (* (+ z 6.012459259764103) z) 3.350343815022304)))
     (fma 0.0692910599291889 y x))))
double code(double x, double y, double z) {
	double tmp;
	if (z <= -130000000.0) {
		tmp = x + fma(0.0692910599291889, y, ((y * 0.07512208616047561) / z));
	} else if (z <= 860.0) {
		tmp = x + ((y * ((((z * 0.0692910599291889) + 0.4917317610505968) * z) + 0.279195317918525)) / (((z + 6.012459259764103) * z) + 3.350343815022304));
	} else {
		tmp = fma(0.0692910599291889, y, x);
	}
	return tmp;
}
function code(x, y, z)
	tmp = 0.0
	if (z <= -130000000.0)
		tmp = Float64(x + fma(0.0692910599291889, y, Float64(Float64(y * 0.07512208616047561) / z)));
	elseif (z <= 860.0)
		tmp = Float64(x + Float64(Float64(y * Float64(Float64(Float64(Float64(z * 0.0692910599291889) + 0.4917317610505968) * z) + 0.279195317918525)) / Float64(Float64(Float64(z + 6.012459259764103) * z) + 3.350343815022304)));
	else
		tmp = fma(0.0692910599291889, y, x);
	end
	return tmp
end
code[x_, y_, z_] := If[LessEqual[z, -130000000.0], N[(x + N[(0.0692910599291889 * y + N[(N[(y * 0.07512208616047561), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 860.0], N[(x + N[(N[(y * N[(N[(N[(N[(z * 0.0692910599291889), $MachinePrecision] + 0.4917317610505968), $MachinePrecision] * z), $MachinePrecision] + 0.279195317918525), $MachinePrecision]), $MachinePrecision] / N[(N[(N[(z + 6.012459259764103), $MachinePrecision] * z), $MachinePrecision] + 3.350343815022304), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.0692910599291889 * y + x), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -130000000:\\
\;\;\;\;x + \mathsf{fma}\left(0.0692910599291889, y, \frac{y \cdot 0.07512208616047561}{z}\right)\\

\mathbf{elif}\;z \leq 860:\\
\;\;\;\;x + \frac{y \cdot \left(\left(z \cdot 0.0692910599291889 + 0.4917317610505968\right) \cdot z + 0.279195317918525\right)}{\left(z + 6.012459259764103\right) \cdot z + 3.350343815022304}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(0.0692910599291889, y, x\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -1.3e8

    1. Initial program 37.6%

      \[x + \frac{y \cdot \left(\left(z \cdot 0.0692910599291889 + 0.4917317610505968\right) \cdot z + 0.279195317918525\right)}{\left(z + 6.012459259764103\right) \cdot z + 3.350343815022304} \]
    2. Taylor expanded in z around inf

      \[\leadsto x + \color{blue}{\left(\left(\frac{692910599291889}{10000000000000000} \cdot y + \frac{307332350656623}{625000000000000} \cdot \frac{y}{z}\right) - \frac{4166096748901211929300981260567}{10000000000000000000000000000000} \cdot \frac{y}{z}\right)} \]
    3. Step-by-step derivation
      1. associate--l+N/A

        \[\leadsto x + \left(\frac{692910599291889}{10000000000000000} \cdot y + \color{blue}{\left(\frac{307332350656623}{625000000000000} \cdot \frac{y}{z} - \frac{4166096748901211929300981260567}{10000000000000000000000000000000} \cdot \frac{y}{z}\right)}\right) \]
      2. lower-fma.f64N/A

        \[\leadsto x + \mathsf{fma}\left(\frac{692910599291889}{10000000000000000}, \color{blue}{y}, \frac{307332350656623}{625000000000000} \cdot \frac{y}{z} - \frac{4166096748901211929300981260567}{10000000000000000000000000000000} \cdot \frac{y}{z}\right) \]
      3. associate-*r/N/A

        \[\leadsto x + \mathsf{fma}\left(\frac{692910599291889}{10000000000000000}, y, \frac{\frac{307332350656623}{625000000000000} \cdot y}{z} - \frac{4166096748901211929300981260567}{10000000000000000000000000000000} \cdot \frac{y}{z}\right) \]
      4. associate-*r/N/A

        \[\leadsto x + \mathsf{fma}\left(\frac{692910599291889}{10000000000000000}, y, \frac{\frac{307332350656623}{625000000000000} \cdot y}{z} - \frac{\frac{4166096748901211929300981260567}{10000000000000000000000000000000} \cdot y}{z}\right) \]
      5. sub-divN/A

        \[\leadsto x + \mathsf{fma}\left(\frac{692910599291889}{10000000000000000}, y, \frac{\frac{307332350656623}{625000000000000} \cdot y - \frac{4166096748901211929300981260567}{10000000000000000000000000000000} \cdot y}{z}\right) \]
      6. lower-/.f64N/A

        \[\leadsto x + \mathsf{fma}\left(\frac{692910599291889}{10000000000000000}, y, \frac{\frac{307332350656623}{625000000000000} \cdot y - \frac{4166096748901211929300981260567}{10000000000000000000000000000000} \cdot y}{z}\right) \]
      7. distribute-rgt-out--N/A

        \[\leadsto x + \mathsf{fma}\left(\frac{692910599291889}{10000000000000000}, y, \frac{y \cdot \left(\frac{307332350656623}{625000000000000} - \frac{4166096748901211929300981260567}{10000000000000000000000000000000}\right)}{z}\right) \]
      8. lower-*.f64N/A

        \[\leadsto x + \mathsf{fma}\left(\frac{692910599291889}{10000000000000000}, y, \frac{y \cdot \left(\frac{307332350656623}{625000000000000} - \frac{4166096748901211929300981260567}{10000000000000000000000000000000}\right)}{z}\right) \]
      9. metadata-eval99.6

        \[\leadsto x + \mathsf{fma}\left(0.0692910599291889, y, \frac{y \cdot 0.07512208616047561}{z}\right) \]
    4. Applied rewrites99.6%

      \[\leadsto x + \color{blue}{\mathsf{fma}\left(0.0692910599291889, y, \frac{y \cdot 0.07512208616047561}{z}\right)} \]

    if -1.3e8 < z < 860

    1. Initial program 99.6%

      \[x + \frac{y \cdot \left(\left(z \cdot 0.0692910599291889 + 0.4917317610505968\right) \cdot z + 0.279195317918525\right)}{\left(z + 6.012459259764103\right) \cdot z + 3.350343815022304} \]

    if 860 < z

    1. Initial program 39.5%

      \[x + \frac{y \cdot \left(\left(z \cdot 0.0692910599291889 + 0.4917317610505968\right) \cdot z + 0.279195317918525\right)}{\left(z + 6.012459259764103\right) \cdot z + 3.350343815022304} \]
    2. Taylor expanded in z around inf

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

        \[\leadsto \frac{692910599291889}{10000000000000000} \cdot y + \color{blue}{x} \]
      2. lower-fma.f6498.9

        \[\leadsto \mathsf{fma}\left(0.0692910599291889, \color{blue}{y}, x\right) \]
    4. Applied rewrites98.9%

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

Alternative 2: 99.1% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -5.5:\\ \;\;\;\;x + \mathsf{fma}\left(0.0692910599291889, y, \frac{y \cdot 0.07512208616047561}{z}\right)\\ \mathbf{elif}\;z \leq 5:\\ \;\;\;\;x + \mathsf{fma}\left(y \cdot -0.00277777777751721, z, 0.08333333333333323 \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(0.0692910599291889, y, x\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= z -5.5)
   (+ x (fma 0.0692910599291889 y (/ (* y 0.07512208616047561) z)))
   (if (<= z 5.0)
     (+ x (fma (* y -0.00277777777751721) z (* 0.08333333333333323 y)))
     (fma 0.0692910599291889 y x))))
double code(double x, double y, double z) {
	double tmp;
	if (z <= -5.5) {
		tmp = x + fma(0.0692910599291889, y, ((y * 0.07512208616047561) / z));
	} else if (z <= 5.0) {
		tmp = x + fma((y * -0.00277777777751721), z, (0.08333333333333323 * y));
	} else {
		tmp = fma(0.0692910599291889, y, x);
	}
	return tmp;
}
function code(x, y, z)
	tmp = 0.0
	if (z <= -5.5)
		tmp = Float64(x + fma(0.0692910599291889, y, Float64(Float64(y * 0.07512208616047561) / z)));
	elseif (z <= 5.0)
		tmp = Float64(x + fma(Float64(y * -0.00277777777751721), z, Float64(0.08333333333333323 * y)));
	else
		tmp = fma(0.0692910599291889, y, x);
	end
	return tmp
end
code[x_, y_, z_] := If[LessEqual[z, -5.5], N[(x + N[(0.0692910599291889 * y + N[(N[(y * 0.07512208616047561), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 5.0], N[(x + N[(N[(y * -0.00277777777751721), $MachinePrecision] * z + N[(0.08333333333333323 * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.0692910599291889 * y + x), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.5:\\
\;\;\;\;x + \mathsf{fma}\left(0.0692910599291889, y, \frac{y \cdot 0.07512208616047561}{z}\right)\\

\mathbf{elif}\;z \leq 5:\\
\;\;\;\;x + \mathsf{fma}\left(y \cdot -0.00277777777751721, z, 0.08333333333333323 \cdot y\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(0.0692910599291889, y, x\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -5.5

    1. Initial program 39.0%

      \[x + \frac{y \cdot \left(\left(z \cdot 0.0692910599291889 + 0.4917317610505968\right) \cdot z + 0.279195317918525\right)}{\left(z + 6.012459259764103\right) \cdot z + 3.350343815022304} \]
    2. Taylor expanded in z around inf

      \[\leadsto x + \color{blue}{\left(\left(\frac{692910599291889}{10000000000000000} \cdot y + \frac{307332350656623}{625000000000000} \cdot \frac{y}{z}\right) - \frac{4166096748901211929300981260567}{10000000000000000000000000000000} \cdot \frac{y}{z}\right)} \]
    3. Step-by-step derivation
      1. associate--l+N/A

        \[\leadsto x + \left(\frac{692910599291889}{10000000000000000} \cdot y + \color{blue}{\left(\frac{307332350656623}{625000000000000} \cdot \frac{y}{z} - \frac{4166096748901211929300981260567}{10000000000000000000000000000000} \cdot \frac{y}{z}\right)}\right) \]
      2. lower-fma.f64N/A

        \[\leadsto x + \mathsf{fma}\left(\frac{692910599291889}{10000000000000000}, \color{blue}{y}, \frac{307332350656623}{625000000000000} \cdot \frac{y}{z} - \frac{4166096748901211929300981260567}{10000000000000000000000000000000} \cdot \frac{y}{z}\right) \]
      3. associate-*r/N/A

        \[\leadsto x + \mathsf{fma}\left(\frac{692910599291889}{10000000000000000}, y, \frac{\frac{307332350656623}{625000000000000} \cdot y}{z} - \frac{4166096748901211929300981260567}{10000000000000000000000000000000} \cdot \frac{y}{z}\right) \]
      4. associate-*r/N/A

        \[\leadsto x + \mathsf{fma}\left(\frac{692910599291889}{10000000000000000}, y, \frac{\frac{307332350656623}{625000000000000} \cdot y}{z} - \frac{\frac{4166096748901211929300981260567}{10000000000000000000000000000000} \cdot y}{z}\right) \]
      5. sub-divN/A

        \[\leadsto x + \mathsf{fma}\left(\frac{692910599291889}{10000000000000000}, y, \frac{\frac{307332350656623}{625000000000000} \cdot y - \frac{4166096748901211929300981260567}{10000000000000000000000000000000} \cdot y}{z}\right) \]
      6. lower-/.f64N/A

        \[\leadsto x + \mathsf{fma}\left(\frac{692910599291889}{10000000000000000}, y, \frac{\frac{307332350656623}{625000000000000} \cdot y - \frac{4166096748901211929300981260567}{10000000000000000000000000000000} \cdot y}{z}\right) \]
      7. distribute-rgt-out--N/A

        \[\leadsto x + \mathsf{fma}\left(\frac{692910599291889}{10000000000000000}, y, \frac{y \cdot \left(\frac{307332350656623}{625000000000000} - \frac{4166096748901211929300981260567}{10000000000000000000000000000000}\right)}{z}\right) \]
      8. lower-*.f64N/A

        \[\leadsto x + \mathsf{fma}\left(\frac{692910599291889}{10000000000000000}, y, \frac{y \cdot \left(\frac{307332350656623}{625000000000000} - \frac{4166096748901211929300981260567}{10000000000000000000000000000000}\right)}{z}\right) \]
      9. metadata-eval99.2

        \[\leadsto x + \mathsf{fma}\left(0.0692910599291889, y, \frac{y \cdot 0.07512208616047561}{z}\right) \]
    4. Applied rewrites99.2%

      \[\leadsto x + \color{blue}{\mathsf{fma}\left(0.0692910599291889, y, \frac{y \cdot 0.07512208616047561}{z}\right)} \]

    if -5.5 < z < 5

    1. Initial program 99.6%

      \[x + \frac{y \cdot \left(\left(z \cdot 0.0692910599291889 + 0.4917317610505968\right) \cdot z + 0.279195317918525\right)}{\left(z + 6.012459259764103\right) \cdot z + 3.350343815022304} \]
    2. Taylor expanded in z around 0

      \[\leadsto x + \color{blue}{\left(\frac{279195317918525}{3350343815022304} \cdot y + z \cdot \left(\frac{307332350656623}{2093964884388940} \cdot y - \frac{1678650474502018223880473708075}{11224803678858206361900017468416} \cdot y\right)\right)} \]
    3. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto x + \left(z \cdot \left(\frac{307332350656623}{2093964884388940} \cdot y - \frac{1678650474502018223880473708075}{11224803678858206361900017468416} \cdot y\right) + \color{blue}{\frac{279195317918525}{3350343815022304} \cdot y}\right) \]
      2. *-commutativeN/A

        \[\leadsto x + \left(\left(\frac{307332350656623}{2093964884388940} \cdot y - \frac{1678650474502018223880473708075}{11224803678858206361900017468416} \cdot y\right) \cdot z + \color{blue}{\frac{279195317918525}{3350343815022304}} \cdot y\right) \]
      3. lower-fma.f64N/A

        \[\leadsto x + \mathsf{fma}\left(\frac{307332350656623}{2093964884388940} \cdot y - \frac{1678650474502018223880473708075}{11224803678858206361900017468416} \cdot y, \color{blue}{z}, \frac{279195317918525}{3350343815022304} \cdot y\right) \]
      4. distribute-rgt-out--N/A

        \[\leadsto x + \mathsf{fma}\left(y \cdot \left(\frac{307332350656623}{2093964884388940} - \frac{1678650474502018223880473708075}{11224803678858206361900017468416}\right), z, \frac{279195317918525}{3350343815022304} \cdot y\right) \]
      5. lower-*.f64N/A

        \[\leadsto x + \mathsf{fma}\left(y \cdot \left(\frac{307332350656623}{2093964884388940} - \frac{1678650474502018223880473708075}{11224803678858206361900017468416}\right), z, \frac{279195317918525}{3350343815022304} \cdot y\right) \]
      6. metadata-evalN/A

        \[\leadsto x + \mathsf{fma}\left(y \cdot \frac{-155900051080628738716045985239}{56124018394291031809500087342080}, z, \frac{279195317918525}{3350343815022304} \cdot y\right) \]
      7. lower-*.f6499.3

        \[\leadsto x + \mathsf{fma}\left(y \cdot -0.00277777777751721, z, 0.08333333333333323 \cdot y\right) \]
    4. Applied rewrites99.3%

      \[\leadsto x + \color{blue}{\mathsf{fma}\left(y \cdot -0.00277777777751721, z, 0.08333333333333323 \cdot y\right)} \]

    if 5 < z

    1. Initial program 39.8%

      \[x + \frac{y \cdot \left(\left(z \cdot 0.0692910599291889 + 0.4917317610505968\right) \cdot z + 0.279195317918525\right)}{\left(z + 6.012459259764103\right) \cdot z + 3.350343815022304} \]
    2. Taylor expanded in z around inf

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

        \[\leadsto \frac{692910599291889}{10000000000000000} \cdot y + \color{blue}{x} \]
      2. lower-fma.f6498.6

        \[\leadsto \mathsf{fma}\left(0.0692910599291889, \color{blue}{y}, x\right) \]
    4. Applied rewrites98.6%

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

Alternative 3: 99.1% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -5.5:\\ \;\;\;\;\left(\frac{0.07512208616047561}{z} + 0.0692910599291889\right) \cdot y + x\\ \mathbf{elif}\;z \leq 5:\\ \;\;\;\;x + \mathsf{fma}\left(y \cdot -0.00277777777751721, z, 0.08333333333333323 \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(0.0692910599291889, y, x\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= z -5.5)
   (+ (* (+ (/ 0.07512208616047561 z) 0.0692910599291889) y) x)
   (if (<= z 5.0)
     (+ x (fma (* y -0.00277777777751721) z (* 0.08333333333333323 y)))
     (fma 0.0692910599291889 y x))))
double code(double x, double y, double z) {
	double tmp;
	if (z <= -5.5) {
		tmp = (((0.07512208616047561 / z) + 0.0692910599291889) * y) + x;
	} else if (z <= 5.0) {
		tmp = x + fma((y * -0.00277777777751721), z, (0.08333333333333323 * y));
	} else {
		tmp = fma(0.0692910599291889, y, x);
	}
	return tmp;
}
function code(x, y, z)
	tmp = 0.0
	if (z <= -5.5)
		tmp = Float64(Float64(Float64(Float64(0.07512208616047561 / z) + 0.0692910599291889) * y) + x);
	elseif (z <= 5.0)
		tmp = Float64(x + fma(Float64(y * -0.00277777777751721), z, Float64(0.08333333333333323 * y)));
	else
		tmp = fma(0.0692910599291889, y, x);
	end
	return tmp
end
code[x_, y_, z_] := If[LessEqual[z, -5.5], N[(N[(N[(N[(0.07512208616047561 / z), $MachinePrecision] + 0.0692910599291889), $MachinePrecision] * y), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[z, 5.0], N[(x + N[(N[(y * -0.00277777777751721), $MachinePrecision] * z + N[(0.08333333333333323 * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.0692910599291889 * y + x), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.5:\\
\;\;\;\;\left(\frac{0.07512208616047561}{z} + 0.0692910599291889\right) \cdot y + x\\

\mathbf{elif}\;z \leq 5:\\
\;\;\;\;x + \mathsf{fma}\left(y \cdot -0.00277777777751721, z, 0.08333333333333323 \cdot y\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(0.0692910599291889, y, x\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -5.5

    1. Initial program 39.0%

      \[x + \frac{y \cdot \left(\left(z \cdot 0.0692910599291889 + 0.4917317610505968\right) \cdot z + 0.279195317918525\right)}{\left(z + 6.012459259764103\right) \cdot z + 3.350343815022304} \]
    2. Taylor expanded in z around 0

      \[\leadsto x + \color{blue}{\frac{279195317918525}{3350343815022304} \cdot y} \]
    3. Step-by-step derivation
      1. lower-*.f6460.1

        \[\leadsto x + 0.08333333333333323 \cdot \color{blue}{y} \]
    4. Applied rewrites60.1%

      \[\leadsto x + \color{blue}{0.08333333333333323 \cdot y} \]
    5. Taylor expanded in z around inf

      \[\leadsto x + \color{blue}{\left(\left(\frac{692910599291889}{10000000000000000} \cdot y + \frac{307332350656623}{625000000000000} \cdot \frac{y}{z}\right) - \frac{4166096748901211929300981260567}{10000000000000000000000000000000} \cdot \frac{y}{z}\right)} \]
    6. Step-by-step derivation
      1. distribute-lft-inN/A

        \[\leadsto x + \left(\left(\color{blue}{\frac{692910599291889}{10000000000000000} \cdot y} + \frac{307332350656623}{625000000000000} \cdot \frac{y}{z}\right) - \frac{4166096748901211929300981260567}{10000000000000000000000000000000} \cdot \frac{y}{z}\right) \]
      2. *-commutativeN/A

        \[\leadsto x + \left(\left(\frac{692910599291889}{10000000000000000} \cdot y + \frac{307332350656623}{625000000000000} \cdot \frac{y}{z}\right) - \frac{4166096748901211929300981260567}{10000000000000000000000000000000} \cdot \frac{y}{z}\right) \]
      3. *-commutativeN/A

        \[\leadsto x + \left(\left(\color{blue}{\frac{692910599291889}{10000000000000000}} \cdot y + \frac{307332350656623}{625000000000000} \cdot \frac{y}{z}\right) - \frac{4166096748901211929300981260567}{10000000000000000000000000000000} \cdot \frac{y}{z}\right) \]
      4. +-commutativeN/A

        \[\leadsto x + \left(\left(\color{blue}{\frac{692910599291889}{10000000000000000} \cdot y} + \frac{307332350656623}{625000000000000} \cdot \frac{y}{z}\right) - \frac{4166096748901211929300981260567}{10000000000000000000000000000000} \cdot \frac{y}{z}\right) \]
      5. associate--l+N/A

        \[\leadsto x + \left(\frac{692910599291889}{10000000000000000} \cdot y + \color{blue}{\left(\frac{307332350656623}{625000000000000} \cdot \frac{y}{z} - \frac{4166096748901211929300981260567}{10000000000000000000000000000000} \cdot \frac{y}{z}\right)}\right) \]
      6. lower-fma.f64N/A

        \[\leadsto x + \mathsf{fma}\left(\frac{692910599291889}{10000000000000000}, \color{blue}{y}, \frac{307332350656623}{625000000000000} \cdot \frac{y}{z} - \frac{4166096748901211929300981260567}{10000000000000000000000000000000} \cdot \frac{y}{z}\right) \]
      7. associate-*r/N/A

        \[\leadsto x + \mathsf{fma}\left(\frac{692910599291889}{10000000000000000}, y, \frac{\frac{307332350656623}{625000000000000} \cdot y}{z} - \frac{4166096748901211929300981260567}{10000000000000000000000000000000} \cdot \frac{y}{z}\right) \]
      8. associate-*r/N/A

        \[\leadsto x + \mathsf{fma}\left(\frac{692910599291889}{10000000000000000}, y, \frac{\frac{307332350656623}{625000000000000} \cdot y}{z} - \frac{\frac{4166096748901211929300981260567}{10000000000000000000000000000000} \cdot y}{z}\right) \]
      9. sub-divN/A

        \[\leadsto x + \mathsf{fma}\left(\frac{692910599291889}{10000000000000000}, y, \frac{\frac{307332350656623}{625000000000000} \cdot y - \frac{4166096748901211929300981260567}{10000000000000000000000000000000} \cdot y}{z}\right) \]
      10. lower-/.f64N/A

        \[\leadsto x + \mathsf{fma}\left(\frac{692910599291889}{10000000000000000}, y, \frac{\frac{307332350656623}{625000000000000} \cdot y - \frac{4166096748901211929300981260567}{10000000000000000000000000000000} \cdot y}{z}\right) \]
      11. distribute-rgt-out--N/A

        \[\leadsto x + \mathsf{fma}\left(\frac{692910599291889}{10000000000000000}, y, \frac{y \cdot \left(\frac{307332350656623}{625000000000000} - \frac{4166096748901211929300981260567}{10000000000000000000000000000000}\right)}{z}\right) \]
      12. lower-*.f64N/A

        \[\leadsto x + \mathsf{fma}\left(\frac{692910599291889}{10000000000000000}, y, \frac{y \cdot \left(\frac{307332350656623}{625000000000000} - \frac{4166096748901211929300981260567}{10000000000000000000000000000000}\right)}{z}\right) \]
      13. metadata-eval99.2

        \[\leadsto x + \mathsf{fma}\left(0.0692910599291889, y, \frac{y \cdot 0.07512208616047561}{z}\right) \]
    7. Applied rewrites99.2%

      \[\leadsto x + \color{blue}{\mathsf{fma}\left(0.0692910599291889, y, \frac{y \cdot 0.07512208616047561}{z}\right)} \]
    8. Step-by-step derivation
      1. lift-+.f64N/A

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{692910599291889}{10000000000000000}, y, \frac{y \cdot \frac{751220861604756070699018739433}{10000000000000000000000000000000}}{z}\right) + x} \]
      3. lower-+.f6499.2

        \[\leadsto \color{blue}{\mathsf{fma}\left(0.0692910599291889, y, \frac{y \cdot 0.07512208616047561}{z}\right) + x} \]
    9. Applied rewrites99.2%

      \[\leadsto \color{blue}{\left(\frac{0.07512208616047561}{z} + 0.0692910599291889\right) \cdot y + x} \]

    if -5.5 < z < 5

    1. Initial program 99.6%

      \[x + \frac{y \cdot \left(\left(z \cdot 0.0692910599291889 + 0.4917317610505968\right) \cdot z + 0.279195317918525\right)}{\left(z + 6.012459259764103\right) \cdot z + 3.350343815022304} \]
    2. Taylor expanded in z around 0

      \[\leadsto x + \color{blue}{\left(\frac{279195317918525}{3350343815022304} \cdot y + z \cdot \left(\frac{307332350656623}{2093964884388940} \cdot y - \frac{1678650474502018223880473708075}{11224803678858206361900017468416} \cdot y\right)\right)} \]
    3. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto x + \left(z \cdot \left(\frac{307332350656623}{2093964884388940} \cdot y - \frac{1678650474502018223880473708075}{11224803678858206361900017468416} \cdot y\right) + \color{blue}{\frac{279195317918525}{3350343815022304} \cdot y}\right) \]
      2. *-commutativeN/A

        \[\leadsto x + \left(\left(\frac{307332350656623}{2093964884388940} \cdot y - \frac{1678650474502018223880473708075}{11224803678858206361900017468416} \cdot y\right) \cdot z + \color{blue}{\frac{279195317918525}{3350343815022304}} \cdot y\right) \]
      3. lower-fma.f64N/A

        \[\leadsto x + \mathsf{fma}\left(\frac{307332350656623}{2093964884388940} \cdot y - \frac{1678650474502018223880473708075}{11224803678858206361900017468416} \cdot y, \color{blue}{z}, \frac{279195317918525}{3350343815022304} \cdot y\right) \]
      4. distribute-rgt-out--N/A

        \[\leadsto x + \mathsf{fma}\left(y \cdot \left(\frac{307332350656623}{2093964884388940} - \frac{1678650474502018223880473708075}{11224803678858206361900017468416}\right), z, \frac{279195317918525}{3350343815022304} \cdot y\right) \]
      5. lower-*.f64N/A

        \[\leadsto x + \mathsf{fma}\left(y \cdot \left(\frac{307332350656623}{2093964884388940} - \frac{1678650474502018223880473708075}{11224803678858206361900017468416}\right), z, \frac{279195317918525}{3350343815022304} \cdot y\right) \]
      6. metadata-evalN/A

        \[\leadsto x + \mathsf{fma}\left(y \cdot \frac{-155900051080628738716045985239}{56124018394291031809500087342080}, z, \frac{279195317918525}{3350343815022304} \cdot y\right) \]
      7. lower-*.f6499.3

        \[\leadsto x + \mathsf{fma}\left(y \cdot -0.00277777777751721, z, 0.08333333333333323 \cdot y\right) \]
    4. Applied rewrites99.3%

      \[\leadsto x + \color{blue}{\mathsf{fma}\left(y \cdot -0.00277777777751721, z, 0.08333333333333323 \cdot y\right)} \]

    if 5 < z

    1. Initial program 39.8%

      \[x + \frac{y \cdot \left(\left(z \cdot 0.0692910599291889 + 0.4917317610505968\right) \cdot z + 0.279195317918525\right)}{\left(z + 6.012459259764103\right) \cdot z + 3.350343815022304} \]
    2. Taylor expanded in z around inf

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

        \[\leadsto \frac{692910599291889}{10000000000000000} \cdot y + \color{blue}{x} \]
      2. lower-fma.f6498.6

        \[\leadsto \mathsf{fma}\left(0.0692910599291889, \color{blue}{y}, x\right) \]
    4. Applied rewrites98.6%

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

Alternative 4: 98.9% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -5.5:\\ \;\;\;\;\left(\frac{0.07512208616047561}{z} + 0.0692910599291889\right) \cdot y + x\\ \mathbf{elif}\;z \leq 6:\\ \;\;\;\;x - -0.08333333333333323 \cdot y\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(0.0692910599291889, y, x\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= z -5.5)
   (+ (* (+ (/ 0.07512208616047561 z) 0.0692910599291889) y) x)
   (if (<= z 6.0)
     (- x (* -0.08333333333333323 y))
     (fma 0.0692910599291889 y x))))
double code(double x, double y, double z) {
	double tmp;
	if (z <= -5.5) {
		tmp = (((0.07512208616047561 / z) + 0.0692910599291889) * y) + x;
	} else if (z <= 6.0) {
		tmp = x - (-0.08333333333333323 * y);
	} else {
		tmp = fma(0.0692910599291889, y, x);
	}
	return tmp;
}
function code(x, y, z)
	tmp = 0.0
	if (z <= -5.5)
		tmp = Float64(Float64(Float64(Float64(0.07512208616047561 / z) + 0.0692910599291889) * y) + x);
	elseif (z <= 6.0)
		tmp = Float64(x - Float64(-0.08333333333333323 * y));
	else
		tmp = fma(0.0692910599291889, y, x);
	end
	return tmp
end
code[x_, y_, z_] := If[LessEqual[z, -5.5], N[(N[(N[(N[(0.07512208616047561 / z), $MachinePrecision] + 0.0692910599291889), $MachinePrecision] * y), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[z, 6.0], N[(x - N[(-0.08333333333333323 * y), $MachinePrecision]), $MachinePrecision], N[(0.0692910599291889 * y + x), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.5:\\
\;\;\;\;\left(\frac{0.07512208616047561}{z} + 0.0692910599291889\right) \cdot y + x\\

\mathbf{elif}\;z \leq 6:\\
\;\;\;\;x - -0.08333333333333323 \cdot y\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(0.0692910599291889, y, x\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -5.5

    1. Initial program 39.0%

      \[x + \frac{y \cdot \left(\left(z \cdot 0.0692910599291889 + 0.4917317610505968\right) \cdot z + 0.279195317918525\right)}{\left(z + 6.012459259764103\right) \cdot z + 3.350343815022304} \]
    2. Taylor expanded in z around 0

      \[\leadsto x + \color{blue}{\frac{279195317918525}{3350343815022304} \cdot y} \]
    3. Step-by-step derivation
      1. lower-*.f6460.1

        \[\leadsto x + 0.08333333333333323 \cdot \color{blue}{y} \]
    4. Applied rewrites60.1%

      \[\leadsto x + \color{blue}{0.08333333333333323 \cdot y} \]
    5. Taylor expanded in z around inf

      \[\leadsto x + \color{blue}{\left(\left(\frac{692910599291889}{10000000000000000} \cdot y + \frac{307332350656623}{625000000000000} \cdot \frac{y}{z}\right) - \frac{4166096748901211929300981260567}{10000000000000000000000000000000} \cdot \frac{y}{z}\right)} \]
    6. Step-by-step derivation
      1. distribute-lft-inN/A

        \[\leadsto x + \left(\left(\color{blue}{\frac{692910599291889}{10000000000000000} \cdot y} + \frac{307332350656623}{625000000000000} \cdot \frac{y}{z}\right) - \frac{4166096748901211929300981260567}{10000000000000000000000000000000} \cdot \frac{y}{z}\right) \]
      2. *-commutativeN/A

        \[\leadsto x + \left(\left(\frac{692910599291889}{10000000000000000} \cdot y + \frac{307332350656623}{625000000000000} \cdot \frac{y}{z}\right) - \frac{4166096748901211929300981260567}{10000000000000000000000000000000} \cdot \frac{y}{z}\right) \]
      3. *-commutativeN/A

        \[\leadsto x + \left(\left(\color{blue}{\frac{692910599291889}{10000000000000000}} \cdot y + \frac{307332350656623}{625000000000000} \cdot \frac{y}{z}\right) - \frac{4166096748901211929300981260567}{10000000000000000000000000000000} \cdot \frac{y}{z}\right) \]
      4. +-commutativeN/A

        \[\leadsto x + \left(\left(\color{blue}{\frac{692910599291889}{10000000000000000} \cdot y} + \frac{307332350656623}{625000000000000} \cdot \frac{y}{z}\right) - \frac{4166096748901211929300981260567}{10000000000000000000000000000000} \cdot \frac{y}{z}\right) \]
      5. associate--l+N/A

        \[\leadsto x + \left(\frac{692910599291889}{10000000000000000} \cdot y + \color{blue}{\left(\frac{307332350656623}{625000000000000} \cdot \frac{y}{z} - \frac{4166096748901211929300981260567}{10000000000000000000000000000000} \cdot \frac{y}{z}\right)}\right) \]
      6. lower-fma.f64N/A

        \[\leadsto x + \mathsf{fma}\left(\frac{692910599291889}{10000000000000000}, \color{blue}{y}, \frac{307332350656623}{625000000000000} \cdot \frac{y}{z} - \frac{4166096748901211929300981260567}{10000000000000000000000000000000} \cdot \frac{y}{z}\right) \]
      7. associate-*r/N/A

        \[\leadsto x + \mathsf{fma}\left(\frac{692910599291889}{10000000000000000}, y, \frac{\frac{307332350656623}{625000000000000} \cdot y}{z} - \frac{4166096748901211929300981260567}{10000000000000000000000000000000} \cdot \frac{y}{z}\right) \]
      8. associate-*r/N/A

        \[\leadsto x + \mathsf{fma}\left(\frac{692910599291889}{10000000000000000}, y, \frac{\frac{307332350656623}{625000000000000} \cdot y}{z} - \frac{\frac{4166096748901211929300981260567}{10000000000000000000000000000000} \cdot y}{z}\right) \]
      9. sub-divN/A

        \[\leadsto x + \mathsf{fma}\left(\frac{692910599291889}{10000000000000000}, y, \frac{\frac{307332350656623}{625000000000000} \cdot y - \frac{4166096748901211929300981260567}{10000000000000000000000000000000} \cdot y}{z}\right) \]
      10. lower-/.f64N/A

        \[\leadsto x + \mathsf{fma}\left(\frac{692910599291889}{10000000000000000}, y, \frac{\frac{307332350656623}{625000000000000} \cdot y - \frac{4166096748901211929300981260567}{10000000000000000000000000000000} \cdot y}{z}\right) \]
      11. distribute-rgt-out--N/A

        \[\leadsto x + \mathsf{fma}\left(\frac{692910599291889}{10000000000000000}, y, \frac{y \cdot \left(\frac{307332350656623}{625000000000000} - \frac{4166096748901211929300981260567}{10000000000000000000000000000000}\right)}{z}\right) \]
      12. lower-*.f64N/A

        \[\leadsto x + \mathsf{fma}\left(\frac{692910599291889}{10000000000000000}, y, \frac{y \cdot \left(\frac{307332350656623}{625000000000000} - \frac{4166096748901211929300981260567}{10000000000000000000000000000000}\right)}{z}\right) \]
      13. metadata-eval99.2

        \[\leadsto x + \mathsf{fma}\left(0.0692910599291889, y, \frac{y \cdot 0.07512208616047561}{z}\right) \]
    7. Applied rewrites99.2%

      \[\leadsto x + \color{blue}{\mathsf{fma}\left(0.0692910599291889, y, \frac{y \cdot 0.07512208616047561}{z}\right)} \]
    8. Step-by-step derivation
      1. lift-+.f64N/A

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{692910599291889}{10000000000000000}, y, \frac{y \cdot \frac{751220861604756070699018739433}{10000000000000000000000000000000}}{z}\right) + x} \]
      3. lower-+.f6499.2

        \[\leadsto \color{blue}{\mathsf{fma}\left(0.0692910599291889, y, \frac{y \cdot 0.07512208616047561}{z}\right) + x} \]
    9. Applied rewrites99.2%

      \[\leadsto \color{blue}{\left(\frac{0.07512208616047561}{z} + 0.0692910599291889\right) \cdot y + x} \]

    if -5.5 < z < 6

    1. Initial program 99.6%

      \[x + \frac{y \cdot \left(\left(z \cdot 0.0692910599291889 + 0.4917317610505968\right) \cdot z + 0.279195317918525\right)}{\left(z + 6.012459259764103\right) \cdot z + 3.350343815022304} \]
    2. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto x + \frac{\color{blue}{y \cdot \left(\left(z \cdot \frac{692910599291889}{10000000000000000} + \frac{307332350656623}{625000000000000}\right) \cdot z + \frac{11167812716741}{40000000000000}\right)}}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      2. lift-+.f64N/A

        \[\leadsto x + \frac{y \cdot \color{blue}{\left(\left(z \cdot \frac{692910599291889}{10000000000000000} + \frac{307332350656623}{625000000000000}\right) \cdot z + \frac{11167812716741}{40000000000000}\right)}}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      3. lift-*.f64N/A

        \[\leadsto x + \frac{y \cdot \left(\color{blue}{\left(z \cdot \frac{692910599291889}{10000000000000000} + \frac{307332350656623}{625000000000000}\right) \cdot z} + \frac{11167812716741}{40000000000000}\right)}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      4. lift-*.f64N/A

        \[\leadsto x + \frac{y \cdot \left(\left(\color{blue}{z \cdot \frac{692910599291889}{10000000000000000}} + \frac{307332350656623}{625000000000000}\right) \cdot z + \frac{11167812716741}{40000000000000}\right)}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      5. lift-+.f64N/A

        \[\leadsto x + \frac{y \cdot \left(\color{blue}{\left(z \cdot \frac{692910599291889}{10000000000000000} + \frac{307332350656623}{625000000000000}\right)} \cdot z + \frac{11167812716741}{40000000000000}\right)}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      6. +-commutativeN/A

        \[\leadsto x + \frac{y \cdot \left(\color{blue}{\left(\frac{307332350656623}{625000000000000} + z \cdot \frac{692910599291889}{10000000000000000}\right)} \cdot z + \frac{11167812716741}{40000000000000}\right)}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      7. *-commutativeN/A

        \[\leadsto x + \frac{y \cdot \left(\left(\frac{307332350656623}{625000000000000} + \color{blue}{\frac{692910599291889}{10000000000000000} \cdot z}\right) \cdot z + \frac{11167812716741}{40000000000000}\right)}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      8. *-commutativeN/A

        \[\leadsto x + \frac{y \cdot \left(\color{blue}{z \cdot \left(\frac{307332350656623}{625000000000000} + \frac{692910599291889}{10000000000000000} \cdot z\right)} + \frac{11167812716741}{40000000000000}\right)}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      9. +-commutativeN/A

        \[\leadsto x + \frac{y \cdot \color{blue}{\left(\frac{11167812716741}{40000000000000} + z \cdot \left(\frac{307332350656623}{625000000000000} + \frac{692910599291889}{10000000000000000} \cdot z\right)\right)}}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      10. distribute-rgt-inN/A

        \[\leadsto x + \frac{\color{blue}{\frac{11167812716741}{40000000000000} \cdot y + \left(z \cdot \left(\frac{307332350656623}{625000000000000} + \frac{692910599291889}{10000000000000000} \cdot z\right)\right) \cdot y}}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      11. *-commutativeN/A

        \[\leadsto x + \frac{\color{blue}{y \cdot \frac{11167812716741}{40000000000000}} + \left(z \cdot \left(\frac{307332350656623}{625000000000000} + \frac{692910599291889}{10000000000000000} \cdot z\right)\right) \cdot y}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      12. *-commutativeN/A

        \[\leadsto x + \frac{y \cdot \frac{11167812716741}{40000000000000} + \color{blue}{\left(\left(\frac{307332350656623}{625000000000000} + \frac{692910599291889}{10000000000000000} \cdot z\right) \cdot z\right)} \cdot y}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      13. *-commutativeN/A

        \[\leadsto x + \frac{y \cdot \frac{11167812716741}{40000000000000} + \left(\left(\frac{307332350656623}{625000000000000} + \color{blue}{z \cdot \frac{692910599291889}{10000000000000000}}\right) \cdot z\right) \cdot y}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      14. +-commutativeN/A

        \[\leadsto x + \frac{y \cdot \frac{11167812716741}{40000000000000} + \left(\color{blue}{\left(z \cdot \frac{692910599291889}{10000000000000000} + \frac{307332350656623}{625000000000000}\right)} \cdot z\right) \cdot y}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      15. lower-fma.f64N/A

        \[\leadsto x + \frac{\color{blue}{\mathsf{fma}\left(y, \frac{11167812716741}{40000000000000}, \left(\left(z \cdot \frac{692910599291889}{10000000000000000} + \frac{307332350656623}{625000000000000}\right) \cdot z\right) \cdot y\right)}}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      16. lower-*.f64N/A

        \[\leadsto x + \frac{\mathsf{fma}\left(y, \frac{11167812716741}{40000000000000}, \color{blue}{\left(\left(z \cdot \frac{692910599291889}{10000000000000000} + \frac{307332350656623}{625000000000000}\right) \cdot z\right) \cdot y}\right)}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      17. lower-*.f64N/A

        \[\leadsto x + \frac{\mathsf{fma}\left(y, \frac{11167812716741}{40000000000000}, \color{blue}{\left(\left(z \cdot \frac{692910599291889}{10000000000000000} + \frac{307332350656623}{625000000000000}\right) \cdot z\right)} \cdot y\right)}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      18. *-commutativeN/A

        \[\leadsto x + \frac{\mathsf{fma}\left(y, \frac{11167812716741}{40000000000000}, \left(\left(\color{blue}{\frac{692910599291889}{10000000000000000} \cdot z} + \frac{307332350656623}{625000000000000}\right) \cdot z\right) \cdot y\right)}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      19. lower-fma.f6499.6

        \[\leadsto x + \frac{\mathsf{fma}\left(y, 0.279195317918525, \left(\color{blue}{\mathsf{fma}\left(0.0692910599291889, z, 0.4917317610505968\right)} \cdot z\right) \cdot y\right)}{\left(z + 6.012459259764103\right) \cdot z + 3.350343815022304} \]
    3. Applied rewrites99.6%

      \[\leadsto x + \frac{\color{blue}{\mathsf{fma}\left(y, 0.279195317918525, \left(\mathsf{fma}\left(0.0692910599291889, z, 0.4917317610505968\right) \cdot z\right) \cdot y\right)}}{\left(z + 6.012459259764103\right) \cdot z + 3.350343815022304} \]
    4. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto x + \frac{\mathsf{fma}\left(y, \frac{11167812716741}{40000000000000}, \color{blue}{\left(\mathsf{fma}\left(\frac{692910599291889}{10000000000000000}, z, \frac{307332350656623}{625000000000000}\right) \cdot z\right) \cdot y}\right)}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      2. lift-*.f64N/A

        \[\leadsto x + \frac{\mathsf{fma}\left(y, \frac{11167812716741}{40000000000000}, \color{blue}{\left(\mathsf{fma}\left(\frac{692910599291889}{10000000000000000}, z, \frac{307332350656623}{625000000000000}\right) \cdot z\right)} \cdot y\right)}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      3. lift-fma.f64N/A

        \[\leadsto x + \frac{\mathsf{fma}\left(y, \frac{11167812716741}{40000000000000}, \left(\color{blue}{\left(\frac{692910599291889}{10000000000000000} \cdot z + \frac{307332350656623}{625000000000000}\right)} \cdot z\right) \cdot y\right)}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      4. lower-fma.f64N/A

        \[\leadsto x + \frac{\color{blue}{y \cdot \frac{11167812716741}{40000000000000} + \left(\left(\frac{692910599291889}{10000000000000000} \cdot z + \frac{307332350656623}{625000000000000}\right) \cdot z\right) \cdot y}}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      5. +-commutativeN/A

        \[\leadsto x + \frac{\color{blue}{\left(\left(\frac{692910599291889}{10000000000000000} \cdot z + \frac{307332350656623}{625000000000000}\right) \cdot z\right) \cdot y + y \cdot \frac{11167812716741}{40000000000000}}}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      6. associate-*l*N/A

        \[\leadsto x + \frac{\color{blue}{\left(\frac{692910599291889}{10000000000000000} \cdot z + \frac{307332350656623}{625000000000000}\right) \cdot \left(z \cdot y\right)} + y \cdot \frac{11167812716741}{40000000000000}}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      7. *-commutativeN/A

        \[\leadsto x + \frac{\left(\frac{692910599291889}{10000000000000000} \cdot z + \frac{307332350656623}{625000000000000}\right) \cdot \color{blue}{\left(y \cdot z\right)} + y \cdot \frac{11167812716741}{40000000000000}}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      8. *-commutativeN/A

        \[\leadsto x + \frac{\left(\frac{692910599291889}{10000000000000000} \cdot z + \frac{307332350656623}{625000000000000}\right) \cdot \left(y \cdot z\right) + \color{blue}{\frac{11167812716741}{40000000000000} \cdot y}}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      9. lower-fma.f64N/A

        \[\leadsto x + \frac{\color{blue}{\mathsf{fma}\left(\frac{692910599291889}{10000000000000000} \cdot z + \frac{307332350656623}{625000000000000}, y \cdot z, \frac{11167812716741}{40000000000000} \cdot y\right)}}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      10. lift-fma.f64N/A

        \[\leadsto x + \frac{\mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(\frac{692910599291889}{10000000000000000}, z, \frac{307332350656623}{625000000000000}\right)}, y \cdot z, \frac{11167812716741}{40000000000000} \cdot y\right)}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      11. *-commutativeN/A

        \[\leadsto x + \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{692910599291889}{10000000000000000}, z, \frac{307332350656623}{625000000000000}\right), \color{blue}{z \cdot y}, \frac{11167812716741}{40000000000000} \cdot y\right)}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      12. lower-*.f64N/A

        \[\leadsto x + \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{692910599291889}{10000000000000000}, z, \frac{307332350656623}{625000000000000}\right), \color{blue}{z \cdot y}, \frac{11167812716741}{40000000000000} \cdot y\right)}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      13. lower-*.f6499.6

        \[\leadsto x + \frac{\mathsf{fma}\left(\mathsf{fma}\left(0.0692910599291889, z, 0.4917317610505968\right), z \cdot y, \color{blue}{0.279195317918525 \cdot y}\right)}{\left(z + 6.012459259764103\right) \cdot z + 3.350343815022304} \]
    5. Applied rewrites99.6%

      \[\leadsto x + \frac{\color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(0.0692910599291889, z, 0.4917317610505968\right), z \cdot y, 0.279195317918525 \cdot y\right)}}{\left(z + 6.012459259764103\right) \cdot z + 3.350343815022304} \]
    6. Taylor expanded in z around 0

      \[\leadsto \color{blue}{x + \frac{279195317918525}{3350343815022304} \cdot y} \]
    7. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \frac{279195317918525}{3350343815022304} \cdot y + \color{blue}{x} \]
      2. lower-fma.f6498.8

        \[\leadsto \mathsf{fma}\left(0.08333333333333323, \color{blue}{y}, x\right) \]
    8. Applied rewrites98.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(0.08333333333333323, y, x\right)} \]
    9. Step-by-step derivation
      1. lift-fma.f64N/A

        \[\leadsto \frac{279195317918525}{3350343815022304} \cdot y + \color{blue}{x} \]
      2. +-commutativeN/A

        \[\leadsto x + \color{blue}{\frac{279195317918525}{3350343815022304} \cdot y} \]
      3. fp-cancel-sign-sub-invN/A

        \[\leadsto x - \color{blue}{\left(\mathsf{neg}\left(\frac{279195317918525}{3350343815022304}\right)\right) \cdot y} \]
      4. lower--.f64N/A

        \[\leadsto x - \color{blue}{\left(\mathsf{neg}\left(\frac{279195317918525}{3350343815022304}\right)\right) \cdot y} \]
      5. metadata-evalN/A

        \[\leadsto x - \frac{-279195317918525}{3350343815022304} \cdot y \]
      6. lower-*.f6498.8

        \[\leadsto x - -0.08333333333333323 \cdot \color{blue}{y} \]
    10. Applied rewrites98.8%

      \[\leadsto x - \color{blue}{-0.08333333333333323 \cdot y} \]

    if 6 < z

    1. Initial program 39.8%

      \[x + \frac{y \cdot \left(\left(z \cdot 0.0692910599291889 + 0.4917317610505968\right) \cdot z + 0.279195317918525\right)}{\left(z + 6.012459259764103\right) \cdot z + 3.350343815022304} \]
    2. Taylor expanded in z around inf

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

        \[\leadsto \frac{692910599291889}{10000000000000000} \cdot y + \color{blue}{x} \]
      2. lower-fma.f6498.6

        \[\leadsto \mathsf{fma}\left(0.0692910599291889, \color{blue}{y}, x\right) \]
    4. Applied rewrites98.6%

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

Alternative 5: 98.8% accurate, 2.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -5.5:\\ \;\;\;\;x - -0.0692910599291889 \cdot y\\ \mathbf{elif}\;z \leq 6:\\ \;\;\;\;x - -0.08333333333333323 \cdot y\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(0.0692910599291889, y, x\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= z -5.5)
   (- x (* -0.0692910599291889 y))
   (if (<= z 6.0)
     (- x (* -0.08333333333333323 y))
     (fma 0.0692910599291889 y x))))
double code(double x, double y, double z) {
	double tmp;
	if (z <= -5.5) {
		tmp = x - (-0.0692910599291889 * y);
	} else if (z <= 6.0) {
		tmp = x - (-0.08333333333333323 * y);
	} else {
		tmp = fma(0.0692910599291889, y, x);
	}
	return tmp;
}
function code(x, y, z)
	tmp = 0.0
	if (z <= -5.5)
		tmp = Float64(x - Float64(-0.0692910599291889 * y));
	elseif (z <= 6.0)
		tmp = Float64(x - Float64(-0.08333333333333323 * y));
	else
		tmp = fma(0.0692910599291889, y, x);
	end
	return tmp
end
code[x_, y_, z_] := If[LessEqual[z, -5.5], N[(x - N[(-0.0692910599291889 * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 6.0], N[(x - N[(-0.08333333333333323 * y), $MachinePrecision]), $MachinePrecision], N[(0.0692910599291889 * y + x), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.5:\\
\;\;\;\;x - -0.0692910599291889 \cdot y\\

\mathbf{elif}\;z \leq 6:\\
\;\;\;\;x - -0.08333333333333323 \cdot y\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(0.0692910599291889, y, x\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -5.5

    1. Initial program 39.0%

      \[x + \frac{y \cdot \left(\left(z \cdot 0.0692910599291889 + 0.4917317610505968\right) \cdot z + 0.279195317918525\right)}{\left(z + 6.012459259764103\right) \cdot z + 3.350343815022304} \]
    2. Taylor expanded in z around 0

      \[\leadsto x + \color{blue}{\frac{279195317918525}{3350343815022304} \cdot y} \]
    3. Step-by-step derivation
      1. lower-*.f6460.1

        \[\leadsto x + 0.08333333333333323 \cdot \color{blue}{y} \]
    4. Applied rewrites60.1%

      \[\leadsto x + \color{blue}{0.08333333333333323 \cdot y} \]
    5. Taylor expanded in z around inf

      \[\leadsto \color{blue}{x + \frac{692910599291889}{10000000000000000} \cdot y} \]
    6. Step-by-step derivation
      1. distribute-lft-inN/A

        \[\leadsto x + \frac{692910599291889}{10000000000000000} \cdot y \]
      2. *-commutativeN/A

        \[\leadsto x + \frac{692910599291889}{10000000000000000} \cdot y \]
      3. *-commutativeN/A

        \[\leadsto x + \frac{692910599291889}{10000000000000000} \cdot y \]
      4. +-commutativeN/A

        \[\leadsto x + \frac{692910599291889}{10000000000000000} \cdot y \]
      5. +-commutativeN/A

        \[\leadsto \frac{692910599291889}{10000000000000000} \cdot y + \color{blue}{x} \]
      6. lower-fma.f6498.8

        \[\leadsto \mathsf{fma}\left(0.0692910599291889, \color{blue}{y}, x\right) \]
    7. Applied rewrites98.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(0.0692910599291889, y, x\right)} \]
    8. Step-by-step derivation
      1. lift-fma.f64N/A

        \[\leadsto \frac{692910599291889}{10000000000000000} \cdot y + \color{blue}{x} \]
      2. +-commutativeN/A

        \[\leadsto x + \color{blue}{\frac{692910599291889}{10000000000000000} \cdot y} \]
      3. fp-cancel-sign-sub-invN/A

        \[\leadsto x - \color{blue}{\left(\mathsf{neg}\left(\frac{692910599291889}{10000000000000000}\right)\right) \cdot y} \]
      4. lower--.f64N/A

        \[\leadsto x - \color{blue}{\left(\mathsf{neg}\left(\frac{692910599291889}{10000000000000000}\right)\right) \cdot y} \]
      5. metadata-evalN/A

        \[\leadsto x - \frac{-692910599291889}{10000000000000000} \cdot y \]
      6. lower-*.f6498.8

        \[\leadsto x - -0.0692910599291889 \cdot \color{blue}{y} \]
    9. Applied rewrites98.8%

      \[\leadsto x - \color{blue}{-0.0692910599291889 \cdot y} \]

    if -5.5 < z < 6

    1. Initial program 99.6%

      \[x + \frac{y \cdot \left(\left(z \cdot 0.0692910599291889 + 0.4917317610505968\right) \cdot z + 0.279195317918525\right)}{\left(z + 6.012459259764103\right) \cdot z + 3.350343815022304} \]
    2. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto x + \frac{\color{blue}{y \cdot \left(\left(z \cdot \frac{692910599291889}{10000000000000000} + \frac{307332350656623}{625000000000000}\right) \cdot z + \frac{11167812716741}{40000000000000}\right)}}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      2. lift-+.f64N/A

        \[\leadsto x + \frac{y \cdot \color{blue}{\left(\left(z \cdot \frac{692910599291889}{10000000000000000} + \frac{307332350656623}{625000000000000}\right) \cdot z + \frac{11167812716741}{40000000000000}\right)}}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      3. lift-*.f64N/A

        \[\leadsto x + \frac{y \cdot \left(\color{blue}{\left(z \cdot \frac{692910599291889}{10000000000000000} + \frac{307332350656623}{625000000000000}\right) \cdot z} + \frac{11167812716741}{40000000000000}\right)}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      4. lift-*.f64N/A

        \[\leadsto x + \frac{y \cdot \left(\left(\color{blue}{z \cdot \frac{692910599291889}{10000000000000000}} + \frac{307332350656623}{625000000000000}\right) \cdot z + \frac{11167812716741}{40000000000000}\right)}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      5. lift-+.f64N/A

        \[\leadsto x + \frac{y \cdot \left(\color{blue}{\left(z \cdot \frac{692910599291889}{10000000000000000} + \frac{307332350656623}{625000000000000}\right)} \cdot z + \frac{11167812716741}{40000000000000}\right)}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      6. +-commutativeN/A

        \[\leadsto x + \frac{y \cdot \left(\color{blue}{\left(\frac{307332350656623}{625000000000000} + z \cdot \frac{692910599291889}{10000000000000000}\right)} \cdot z + \frac{11167812716741}{40000000000000}\right)}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      7. *-commutativeN/A

        \[\leadsto x + \frac{y \cdot \left(\left(\frac{307332350656623}{625000000000000} + \color{blue}{\frac{692910599291889}{10000000000000000} \cdot z}\right) \cdot z + \frac{11167812716741}{40000000000000}\right)}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      8. *-commutativeN/A

        \[\leadsto x + \frac{y \cdot \left(\color{blue}{z \cdot \left(\frac{307332350656623}{625000000000000} + \frac{692910599291889}{10000000000000000} \cdot z\right)} + \frac{11167812716741}{40000000000000}\right)}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      9. +-commutativeN/A

        \[\leadsto x + \frac{y \cdot \color{blue}{\left(\frac{11167812716741}{40000000000000} + z \cdot \left(\frac{307332350656623}{625000000000000} + \frac{692910599291889}{10000000000000000} \cdot z\right)\right)}}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      10. distribute-rgt-inN/A

        \[\leadsto x + \frac{\color{blue}{\frac{11167812716741}{40000000000000} \cdot y + \left(z \cdot \left(\frac{307332350656623}{625000000000000} + \frac{692910599291889}{10000000000000000} \cdot z\right)\right) \cdot y}}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      11. *-commutativeN/A

        \[\leadsto x + \frac{\color{blue}{y \cdot \frac{11167812716741}{40000000000000}} + \left(z \cdot \left(\frac{307332350656623}{625000000000000} + \frac{692910599291889}{10000000000000000} \cdot z\right)\right) \cdot y}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      12. *-commutativeN/A

        \[\leadsto x + \frac{y \cdot \frac{11167812716741}{40000000000000} + \color{blue}{\left(\left(\frac{307332350656623}{625000000000000} + \frac{692910599291889}{10000000000000000} \cdot z\right) \cdot z\right)} \cdot y}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      13. *-commutativeN/A

        \[\leadsto x + \frac{y \cdot \frac{11167812716741}{40000000000000} + \left(\left(\frac{307332350656623}{625000000000000} + \color{blue}{z \cdot \frac{692910599291889}{10000000000000000}}\right) \cdot z\right) \cdot y}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      14. +-commutativeN/A

        \[\leadsto x + \frac{y \cdot \frac{11167812716741}{40000000000000} + \left(\color{blue}{\left(z \cdot \frac{692910599291889}{10000000000000000} + \frac{307332350656623}{625000000000000}\right)} \cdot z\right) \cdot y}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      15. lower-fma.f64N/A

        \[\leadsto x + \frac{\color{blue}{\mathsf{fma}\left(y, \frac{11167812716741}{40000000000000}, \left(\left(z \cdot \frac{692910599291889}{10000000000000000} + \frac{307332350656623}{625000000000000}\right) \cdot z\right) \cdot y\right)}}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      16. lower-*.f64N/A

        \[\leadsto x + \frac{\mathsf{fma}\left(y, \frac{11167812716741}{40000000000000}, \color{blue}{\left(\left(z \cdot \frac{692910599291889}{10000000000000000} + \frac{307332350656623}{625000000000000}\right) \cdot z\right) \cdot y}\right)}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      17. lower-*.f64N/A

        \[\leadsto x + \frac{\mathsf{fma}\left(y, \frac{11167812716741}{40000000000000}, \color{blue}{\left(\left(z \cdot \frac{692910599291889}{10000000000000000} + \frac{307332350656623}{625000000000000}\right) \cdot z\right)} \cdot y\right)}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      18. *-commutativeN/A

        \[\leadsto x + \frac{\mathsf{fma}\left(y, \frac{11167812716741}{40000000000000}, \left(\left(\color{blue}{\frac{692910599291889}{10000000000000000} \cdot z} + \frac{307332350656623}{625000000000000}\right) \cdot z\right) \cdot y\right)}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      19. lower-fma.f6499.6

        \[\leadsto x + \frac{\mathsf{fma}\left(y, 0.279195317918525, \left(\color{blue}{\mathsf{fma}\left(0.0692910599291889, z, 0.4917317610505968\right)} \cdot z\right) \cdot y\right)}{\left(z + 6.012459259764103\right) \cdot z + 3.350343815022304} \]
    3. Applied rewrites99.6%

      \[\leadsto x + \frac{\color{blue}{\mathsf{fma}\left(y, 0.279195317918525, \left(\mathsf{fma}\left(0.0692910599291889, z, 0.4917317610505968\right) \cdot z\right) \cdot y\right)}}{\left(z + 6.012459259764103\right) \cdot z + 3.350343815022304} \]
    4. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto x + \frac{\mathsf{fma}\left(y, \frac{11167812716741}{40000000000000}, \color{blue}{\left(\mathsf{fma}\left(\frac{692910599291889}{10000000000000000}, z, \frac{307332350656623}{625000000000000}\right) \cdot z\right) \cdot y}\right)}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      2. lift-*.f64N/A

        \[\leadsto x + \frac{\mathsf{fma}\left(y, \frac{11167812716741}{40000000000000}, \color{blue}{\left(\mathsf{fma}\left(\frac{692910599291889}{10000000000000000}, z, \frac{307332350656623}{625000000000000}\right) \cdot z\right)} \cdot y\right)}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      3. lift-fma.f64N/A

        \[\leadsto x + \frac{\mathsf{fma}\left(y, \frac{11167812716741}{40000000000000}, \left(\color{blue}{\left(\frac{692910599291889}{10000000000000000} \cdot z + \frac{307332350656623}{625000000000000}\right)} \cdot z\right) \cdot y\right)}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      4. lower-fma.f64N/A

        \[\leadsto x + \frac{\color{blue}{y \cdot \frac{11167812716741}{40000000000000} + \left(\left(\frac{692910599291889}{10000000000000000} \cdot z + \frac{307332350656623}{625000000000000}\right) \cdot z\right) \cdot y}}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      5. +-commutativeN/A

        \[\leadsto x + \frac{\color{blue}{\left(\left(\frac{692910599291889}{10000000000000000} \cdot z + \frac{307332350656623}{625000000000000}\right) \cdot z\right) \cdot y + y \cdot \frac{11167812716741}{40000000000000}}}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      6. associate-*l*N/A

        \[\leadsto x + \frac{\color{blue}{\left(\frac{692910599291889}{10000000000000000} \cdot z + \frac{307332350656623}{625000000000000}\right) \cdot \left(z \cdot y\right)} + y \cdot \frac{11167812716741}{40000000000000}}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      7. *-commutativeN/A

        \[\leadsto x + \frac{\left(\frac{692910599291889}{10000000000000000} \cdot z + \frac{307332350656623}{625000000000000}\right) \cdot \color{blue}{\left(y \cdot z\right)} + y \cdot \frac{11167812716741}{40000000000000}}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      8. *-commutativeN/A

        \[\leadsto x + \frac{\left(\frac{692910599291889}{10000000000000000} \cdot z + \frac{307332350656623}{625000000000000}\right) \cdot \left(y \cdot z\right) + \color{blue}{\frac{11167812716741}{40000000000000} \cdot y}}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      9. lower-fma.f64N/A

        \[\leadsto x + \frac{\color{blue}{\mathsf{fma}\left(\frac{692910599291889}{10000000000000000} \cdot z + \frac{307332350656623}{625000000000000}, y \cdot z, \frac{11167812716741}{40000000000000} \cdot y\right)}}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      10. lift-fma.f64N/A

        \[\leadsto x + \frac{\mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(\frac{692910599291889}{10000000000000000}, z, \frac{307332350656623}{625000000000000}\right)}, y \cdot z, \frac{11167812716741}{40000000000000} \cdot y\right)}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      11. *-commutativeN/A

        \[\leadsto x + \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{692910599291889}{10000000000000000}, z, \frac{307332350656623}{625000000000000}\right), \color{blue}{z \cdot y}, \frac{11167812716741}{40000000000000} \cdot y\right)}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      12. lower-*.f64N/A

        \[\leadsto x + \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{692910599291889}{10000000000000000}, z, \frac{307332350656623}{625000000000000}\right), \color{blue}{z \cdot y}, \frac{11167812716741}{40000000000000} \cdot y\right)}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      13. lower-*.f6499.6

        \[\leadsto x + \frac{\mathsf{fma}\left(\mathsf{fma}\left(0.0692910599291889, z, 0.4917317610505968\right), z \cdot y, \color{blue}{0.279195317918525 \cdot y}\right)}{\left(z + 6.012459259764103\right) \cdot z + 3.350343815022304} \]
    5. Applied rewrites99.6%

      \[\leadsto x + \frac{\color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(0.0692910599291889, z, 0.4917317610505968\right), z \cdot y, 0.279195317918525 \cdot y\right)}}{\left(z + 6.012459259764103\right) \cdot z + 3.350343815022304} \]
    6. Taylor expanded in z around 0

      \[\leadsto \color{blue}{x + \frac{279195317918525}{3350343815022304} \cdot y} \]
    7. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \frac{279195317918525}{3350343815022304} \cdot y + \color{blue}{x} \]
      2. lower-fma.f6498.8

        \[\leadsto \mathsf{fma}\left(0.08333333333333323, \color{blue}{y}, x\right) \]
    8. Applied rewrites98.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(0.08333333333333323, y, x\right)} \]
    9. Step-by-step derivation
      1. lift-fma.f64N/A

        \[\leadsto \frac{279195317918525}{3350343815022304} \cdot y + \color{blue}{x} \]
      2. +-commutativeN/A

        \[\leadsto x + \color{blue}{\frac{279195317918525}{3350343815022304} \cdot y} \]
      3. fp-cancel-sign-sub-invN/A

        \[\leadsto x - \color{blue}{\left(\mathsf{neg}\left(\frac{279195317918525}{3350343815022304}\right)\right) \cdot y} \]
      4. lower--.f64N/A

        \[\leadsto x - \color{blue}{\left(\mathsf{neg}\left(\frac{279195317918525}{3350343815022304}\right)\right) \cdot y} \]
      5. metadata-evalN/A

        \[\leadsto x - \frac{-279195317918525}{3350343815022304} \cdot y \]
      6. lower-*.f6498.8

        \[\leadsto x - -0.08333333333333323 \cdot \color{blue}{y} \]
    10. Applied rewrites98.8%

      \[\leadsto x - \color{blue}{-0.08333333333333323 \cdot y} \]

    if 6 < z

    1. Initial program 39.8%

      \[x + \frac{y \cdot \left(\left(z \cdot 0.0692910599291889 + 0.4917317610505968\right) \cdot z + 0.279195317918525\right)}{\left(z + 6.012459259764103\right) \cdot z + 3.350343815022304} \]
    2. Taylor expanded in z around inf

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

        \[\leadsto \frac{692910599291889}{10000000000000000} \cdot y + \color{blue}{x} \]
      2. lower-fma.f6498.6

        \[\leadsto \mathsf{fma}\left(0.0692910599291889, \color{blue}{y}, x\right) \]
    4. Applied rewrites98.6%

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

Alternative 6: 98.8% accurate, 2.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -5.5:\\ \;\;\;\;x - -0.0692910599291889 \cdot y\\ \mathbf{elif}\;z \leq 6:\\ \;\;\;\;\mathsf{fma}\left(0.08333333333333323, y, x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(0.0692910599291889, y, x\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= z -5.5)
   (- x (* -0.0692910599291889 y))
   (if (<= z 6.0) (fma 0.08333333333333323 y x) (fma 0.0692910599291889 y x))))
double code(double x, double y, double z) {
	double tmp;
	if (z <= -5.5) {
		tmp = x - (-0.0692910599291889 * y);
	} else if (z <= 6.0) {
		tmp = fma(0.08333333333333323, y, x);
	} else {
		tmp = fma(0.0692910599291889, y, x);
	}
	return tmp;
}
function code(x, y, z)
	tmp = 0.0
	if (z <= -5.5)
		tmp = Float64(x - Float64(-0.0692910599291889 * y));
	elseif (z <= 6.0)
		tmp = fma(0.08333333333333323, y, x);
	else
		tmp = fma(0.0692910599291889, y, x);
	end
	return tmp
end
code[x_, y_, z_] := If[LessEqual[z, -5.5], N[(x - N[(-0.0692910599291889 * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 6.0], N[(0.08333333333333323 * y + x), $MachinePrecision], N[(0.0692910599291889 * y + x), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.5:\\
\;\;\;\;x - -0.0692910599291889 \cdot y\\

\mathbf{elif}\;z \leq 6:\\
\;\;\;\;\mathsf{fma}\left(0.08333333333333323, y, x\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(0.0692910599291889, y, x\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -5.5

    1. Initial program 39.0%

      \[x + \frac{y \cdot \left(\left(z \cdot 0.0692910599291889 + 0.4917317610505968\right) \cdot z + 0.279195317918525\right)}{\left(z + 6.012459259764103\right) \cdot z + 3.350343815022304} \]
    2. Taylor expanded in z around 0

      \[\leadsto x + \color{blue}{\frac{279195317918525}{3350343815022304} \cdot y} \]
    3. Step-by-step derivation
      1. lower-*.f6460.1

        \[\leadsto x + 0.08333333333333323 \cdot \color{blue}{y} \]
    4. Applied rewrites60.1%

      \[\leadsto x + \color{blue}{0.08333333333333323 \cdot y} \]
    5. Taylor expanded in z around inf

      \[\leadsto \color{blue}{x + \frac{692910599291889}{10000000000000000} \cdot y} \]
    6. Step-by-step derivation
      1. distribute-lft-inN/A

        \[\leadsto x + \frac{692910599291889}{10000000000000000} \cdot y \]
      2. *-commutativeN/A

        \[\leadsto x + \frac{692910599291889}{10000000000000000} \cdot y \]
      3. *-commutativeN/A

        \[\leadsto x + \frac{692910599291889}{10000000000000000} \cdot y \]
      4. +-commutativeN/A

        \[\leadsto x + \frac{692910599291889}{10000000000000000} \cdot y \]
      5. +-commutativeN/A

        \[\leadsto \frac{692910599291889}{10000000000000000} \cdot y + \color{blue}{x} \]
      6. lower-fma.f6498.8

        \[\leadsto \mathsf{fma}\left(0.0692910599291889, \color{blue}{y}, x\right) \]
    7. Applied rewrites98.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(0.0692910599291889, y, x\right)} \]
    8. Step-by-step derivation
      1. lift-fma.f64N/A

        \[\leadsto \frac{692910599291889}{10000000000000000} \cdot y + \color{blue}{x} \]
      2. +-commutativeN/A

        \[\leadsto x + \color{blue}{\frac{692910599291889}{10000000000000000} \cdot y} \]
      3. fp-cancel-sign-sub-invN/A

        \[\leadsto x - \color{blue}{\left(\mathsf{neg}\left(\frac{692910599291889}{10000000000000000}\right)\right) \cdot y} \]
      4. lower--.f64N/A

        \[\leadsto x - \color{blue}{\left(\mathsf{neg}\left(\frac{692910599291889}{10000000000000000}\right)\right) \cdot y} \]
      5. metadata-evalN/A

        \[\leadsto x - \frac{-692910599291889}{10000000000000000} \cdot y \]
      6. lower-*.f6498.8

        \[\leadsto x - -0.0692910599291889 \cdot \color{blue}{y} \]
    9. Applied rewrites98.8%

      \[\leadsto x - \color{blue}{-0.0692910599291889 \cdot y} \]

    if -5.5 < z < 6

    1. Initial program 99.6%

      \[x + \frac{y \cdot \left(\left(z \cdot 0.0692910599291889 + 0.4917317610505968\right) \cdot z + 0.279195317918525\right)}{\left(z + 6.012459259764103\right) \cdot z + 3.350343815022304} \]
    2. Taylor expanded in z around 0

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

        \[\leadsto \frac{279195317918525}{3350343815022304} \cdot y + \color{blue}{x} \]
      2. lower-fma.f6498.8

        \[\leadsto \mathsf{fma}\left(0.08333333333333323, \color{blue}{y}, x\right) \]
    4. Applied rewrites98.8%

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

    if 6 < z

    1. Initial program 39.8%

      \[x + \frac{y \cdot \left(\left(z \cdot 0.0692910599291889 + 0.4917317610505968\right) \cdot z + 0.279195317918525\right)}{\left(z + 6.012459259764103\right) \cdot z + 3.350343815022304} \]
    2. Taylor expanded in z around inf

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

        \[\leadsto \frac{692910599291889}{10000000000000000} \cdot y + \color{blue}{x} \]
      2. lower-fma.f6498.6

        \[\leadsto \mathsf{fma}\left(0.0692910599291889, \color{blue}{y}, x\right) \]
    4. Applied rewrites98.6%

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

Alternative 7: 98.8% accurate, 2.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -5.5:\\ \;\;\;\;\mathsf{fma}\left(0.0692910599291889, y, x\right)\\ \mathbf{elif}\;z \leq 6:\\ \;\;\;\;\mathsf{fma}\left(0.08333333333333323, y, x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(0.0692910599291889, y, x\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= z -5.5)
   (fma 0.0692910599291889 y x)
   (if (<= z 6.0) (fma 0.08333333333333323 y x) (fma 0.0692910599291889 y x))))
double code(double x, double y, double z) {
	double tmp;
	if (z <= -5.5) {
		tmp = fma(0.0692910599291889, y, x);
	} else if (z <= 6.0) {
		tmp = fma(0.08333333333333323, y, x);
	} else {
		tmp = fma(0.0692910599291889, y, x);
	}
	return tmp;
}
function code(x, y, z)
	tmp = 0.0
	if (z <= -5.5)
		tmp = fma(0.0692910599291889, y, x);
	elseif (z <= 6.0)
		tmp = fma(0.08333333333333323, y, x);
	else
		tmp = fma(0.0692910599291889, y, x);
	end
	return tmp
end
code[x_, y_, z_] := If[LessEqual[z, -5.5], N[(0.0692910599291889 * y + x), $MachinePrecision], If[LessEqual[z, 6.0], N[(0.08333333333333323 * y + x), $MachinePrecision], N[(0.0692910599291889 * y + x), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.5:\\
\;\;\;\;\mathsf{fma}\left(0.0692910599291889, y, x\right)\\

\mathbf{elif}\;z \leq 6:\\
\;\;\;\;\mathsf{fma}\left(0.08333333333333323, y, x\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(0.0692910599291889, y, x\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -5.5 or 6 < z

    1. Initial program 39.4%

      \[x + \frac{y \cdot \left(\left(z \cdot 0.0692910599291889 + 0.4917317610505968\right) \cdot z + 0.279195317918525\right)}{\left(z + 6.012459259764103\right) \cdot z + 3.350343815022304} \]
    2. Taylor expanded in z around inf

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

        \[\leadsto \frac{692910599291889}{10000000000000000} \cdot y + \color{blue}{x} \]
      2. lower-fma.f6498.7

        \[\leadsto \mathsf{fma}\left(0.0692910599291889, \color{blue}{y}, x\right) \]
    4. Applied rewrites98.7%

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

    if -5.5 < z < 6

    1. Initial program 99.6%

      \[x + \frac{y \cdot \left(\left(z \cdot 0.0692910599291889 + 0.4917317610505968\right) \cdot z + 0.279195317918525\right)}{\left(z + 6.012459259764103\right) \cdot z + 3.350343815022304} \]
    2. Taylor expanded in z around 0

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

        \[\leadsto \frac{279195317918525}{3350343815022304} \cdot y + \color{blue}{x} \]
      2. lower-fma.f6498.8

        \[\leadsto \mathsf{fma}\left(0.08333333333333323, \color{blue}{y}, x\right) \]
    4. Applied rewrites98.8%

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

Alternative 8: 81.8% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{y \cdot \left(\left(z \cdot 0.0692910599291889 + 0.4917317610505968\right) \cdot z + 0.279195317918525\right)}{\left(z + 6.012459259764103\right) \cdot z + 3.350343815022304}\\ \mathbf{if}\;t\_0 \leq -\infty:\\ \;\;\;\;y \cdot 0.0692910599291889\\ \mathbf{elif}\;t\_0 \leq -2 \cdot 10^{+153}:\\ \;\;\;\;0.08333333333333323 \cdot y\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(0.0692910599291889, y, x\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0
         (/
          (*
           y
           (+
            (* (+ (* z 0.0692910599291889) 0.4917317610505968) z)
            0.279195317918525))
          (+ (* (+ z 6.012459259764103) z) 3.350343815022304))))
   (if (<= t_0 (- INFINITY))
     (* y 0.0692910599291889)
     (if (<= t_0 -2e+153)
       (* 0.08333333333333323 y)
       (fma 0.0692910599291889 y x)))))
double code(double x, double y, double z) {
	double t_0 = (y * ((((z * 0.0692910599291889) + 0.4917317610505968) * z) + 0.279195317918525)) / (((z + 6.012459259764103) * z) + 3.350343815022304);
	double tmp;
	if (t_0 <= -((double) INFINITY)) {
		tmp = y * 0.0692910599291889;
	} else if (t_0 <= -2e+153) {
		tmp = 0.08333333333333323 * y;
	} else {
		tmp = fma(0.0692910599291889, y, x);
	}
	return tmp;
}
function code(x, y, z)
	t_0 = Float64(Float64(y * Float64(Float64(Float64(Float64(z * 0.0692910599291889) + 0.4917317610505968) * z) + 0.279195317918525)) / Float64(Float64(Float64(z + 6.012459259764103) * z) + 3.350343815022304))
	tmp = 0.0
	if (t_0 <= Float64(-Inf))
		tmp = Float64(y * 0.0692910599291889);
	elseif (t_0 <= -2e+153)
		tmp = Float64(0.08333333333333323 * y);
	else
		tmp = fma(0.0692910599291889, y, x);
	end
	return tmp
end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(y * N[(N[(N[(N[(z * 0.0692910599291889), $MachinePrecision] + 0.4917317610505968), $MachinePrecision] * z), $MachinePrecision] + 0.279195317918525), $MachinePrecision]), $MachinePrecision] / N[(N[(N[(z + 6.012459259764103), $MachinePrecision] * z), $MachinePrecision] + 3.350343815022304), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(y * 0.0692910599291889), $MachinePrecision], If[LessEqual[t$95$0, -2e+153], N[(0.08333333333333323 * y), $MachinePrecision], N[(0.0692910599291889 * y + x), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{y \cdot \left(\left(z \cdot 0.0692910599291889 + 0.4917317610505968\right) \cdot z + 0.279195317918525\right)}{\left(z + 6.012459259764103\right) \cdot z + 3.350343815022304}\\
\mathbf{if}\;t\_0 \leq -\infty:\\
\;\;\;\;y \cdot 0.0692910599291889\\

\mathbf{elif}\;t\_0 \leq -2 \cdot 10^{+153}:\\
\;\;\;\;0.08333333333333323 \cdot y\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(0.0692910599291889, y, x\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (/.f64 (*.f64 y (+.f64 (*.f64 (+.f64 (*.f64 z #s(literal 692910599291889/10000000000000000 binary64)) #s(literal 307332350656623/625000000000000 binary64)) z) #s(literal 11167812716741/40000000000000 binary64))) (+.f64 (*.f64 (+.f64 z #s(literal 6012459259764103/1000000000000000 binary64)) z) #s(literal 104698244219447/31250000000000 binary64))) < -inf.0

    1. Initial program 6.2%

      \[x + \frac{y \cdot \left(\left(z \cdot 0.0692910599291889 + 0.4917317610505968\right) \cdot z + 0.279195317918525\right)}{\left(z + 6.012459259764103\right) \cdot z + 3.350343815022304} \]
    2. Taylor expanded in z around 0

      \[\leadsto x + \color{blue}{\frac{279195317918525}{3350343815022304} \cdot y} \]
    3. Step-by-step derivation
      1. lower-*.f6433.8

        \[\leadsto x + 0.08333333333333323 \cdot \color{blue}{y} \]
    4. Applied rewrites33.8%

      \[\leadsto x + \color{blue}{0.08333333333333323 \cdot y} \]
    5. Taylor expanded in z around inf

      \[\leadsto \color{blue}{x + \frac{692910599291889}{10000000000000000} \cdot y} \]
    6. Step-by-step derivation
      1. distribute-lft-inN/A

        \[\leadsto x + \frac{692910599291889}{10000000000000000} \cdot y \]
      2. *-commutativeN/A

        \[\leadsto x + \frac{692910599291889}{10000000000000000} \cdot y \]
      3. *-commutativeN/A

        \[\leadsto x + \frac{692910599291889}{10000000000000000} \cdot y \]
      4. +-commutativeN/A

        \[\leadsto x + \frac{692910599291889}{10000000000000000} \cdot y \]
      5. +-commutativeN/A

        \[\leadsto \frac{692910599291889}{10000000000000000} \cdot y + \color{blue}{x} \]
      6. lower-fma.f6499.3

        \[\leadsto \mathsf{fma}\left(0.0692910599291889, \color{blue}{y}, x\right) \]
    7. Applied rewrites99.3%

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

      \[\leadsto \frac{692910599291889}{10000000000000000} \cdot \color{blue}{y} \]
    9. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto y \cdot \frac{692910599291889}{10000000000000000} \]
      2. lower-*.f6481.9

        \[\leadsto y \cdot 0.0692910599291889 \]
    10. Applied rewrites81.9%

      \[\leadsto y \cdot \color{blue}{0.0692910599291889} \]

    if -inf.0 < (/.f64 (*.f64 y (+.f64 (*.f64 (+.f64 (*.f64 z #s(literal 692910599291889/10000000000000000 binary64)) #s(literal 307332350656623/625000000000000 binary64)) z) #s(literal 11167812716741/40000000000000 binary64))) (+.f64 (*.f64 (+.f64 z #s(literal 6012459259764103/1000000000000000 binary64)) z) #s(literal 104698244219447/31250000000000 binary64))) < -2e153

    1. Initial program 99.3%

      \[x + \frac{y \cdot \left(\left(z \cdot 0.0692910599291889 + 0.4917317610505968\right) \cdot z + 0.279195317918525\right)}{\left(z + 6.012459259764103\right) \cdot z + 3.350343815022304} \]
    2. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto x + \frac{\color{blue}{y \cdot \left(\left(z \cdot \frac{692910599291889}{10000000000000000} + \frac{307332350656623}{625000000000000}\right) \cdot z + \frac{11167812716741}{40000000000000}\right)}}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      2. lift-+.f64N/A

        \[\leadsto x + \frac{y \cdot \color{blue}{\left(\left(z \cdot \frac{692910599291889}{10000000000000000} + \frac{307332350656623}{625000000000000}\right) \cdot z + \frac{11167812716741}{40000000000000}\right)}}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      3. lift-*.f64N/A

        \[\leadsto x + \frac{y \cdot \left(\color{blue}{\left(z \cdot \frac{692910599291889}{10000000000000000} + \frac{307332350656623}{625000000000000}\right) \cdot z} + \frac{11167812716741}{40000000000000}\right)}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      4. lift-*.f64N/A

        \[\leadsto x + \frac{y \cdot \left(\left(\color{blue}{z \cdot \frac{692910599291889}{10000000000000000}} + \frac{307332350656623}{625000000000000}\right) \cdot z + \frac{11167812716741}{40000000000000}\right)}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      5. lift-+.f64N/A

        \[\leadsto x + \frac{y \cdot \left(\color{blue}{\left(z \cdot \frac{692910599291889}{10000000000000000} + \frac{307332350656623}{625000000000000}\right)} \cdot z + \frac{11167812716741}{40000000000000}\right)}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      6. +-commutativeN/A

        \[\leadsto x + \frac{y \cdot \left(\color{blue}{\left(\frac{307332350656623}{625000000000000} + z \cdot \frac{692910599291889}{10000000000000000}\right)} \cdot z + \frac{11167812716741}{40000000000000}\right)}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      7. *-commutativeN/A

        \[\leadsto x + \frac{y \cdot \left(\left(\frac{307332350656623}{625000000000000} + \color{blue}{\frac{692910599291889}{10000000000000000} \cdot z}\right) \cdot z + \frac{11167812716741}{40000000000000}\right)}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      8. *-commutativeN/A

        \[\leadsto x + \frac{y \cdot \left(\color{blue}{z \cdot \left(\frac{307332350656623}{625000000000000} + \frac{692910599291889}{10000000000000000} \cdot z\right)} + \frac{11167812716741}{40000000000000}\right)}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      9. +-commutativeN/A

        \[\leadsto x + \frac{y \cdot \color{blue}{\left(\frac{11167812716741}{40000000000000} + z \cdot \left(\frac{307332350656623}{625000000000000} + \frac{692910599291889}{10000000000000000} \cdot z\right)\right)}}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      10. distribute-rgt-inN/A

        \[\leadsto x + \frac{\color{blue}{\frac{11167812716741}{40000000000000} \cdot y + \left(z \cdot \left(\frac{307332350656623}{625000000000000} + \frac{692910599291889}{10000000000000000} \cdot z\right)\right) \cdot y}}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      11. *-commutativeN/A

        \[\leadsto x + \frac{\color{blue}{y \cdot \frac{11167812716741}{40000000000000}} + \left(z \cdot \left(\frac{307332350656623}{625000000000000} + \frac{692910599291889}{10000000000000000} \cdot z\right)\right) \cdot y}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      12. *-commutativeN/A

        \[\leadsto x + \frac{y \cdot \frac{11167812716741}{40000000000000} + \color{blue}{\left(\left(\frac{307332350656623}{625000000000000} + \frac{692910599291889}{10000000000000000} \cdot z\right) \cdot z\right)} \cdot y}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      13. *-commutativeN/A

        \[\leadsto x + \frac{y \cdot \frac{11167812716741}{40000000000000} + \left(\left(\frac{307332350656623}{625000000000000} + \color{blue}{z \cdot \frac{692910599291889}{10000000000000000}}\right) \cdot z\right) \cdot y}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      14. +-commutativeN/A

        \[\leadsto x + \frac{y \cdot \frac{11167812716741}{40000000000000} + \left(\color{blue}{\left(z \cdot \frac{692910599291889}{10000000000000000} + \frac{307332350656623}{625000000000000}\right)} \cdot z\right) \cdot y}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      15. lower-fma.f64N/A

        \[\leadsto x + \frac{\color{blue}{\mathsf{fma}\left(y, \frac{11167812716741}{40000000000000}, \left(\left(z \cdot \frac{692910599291889}{10000000000000000} + \frac{307332350656623}{625000000000000}\right) \cdot z\right) \cdot y\right)}}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      16. lower-*.f64N/A

        \[\leadsto x + \frac{\mathsf{fma}\left(y, \frac{11167812716741}{40000000000000}, \color{blue}{\left(\left(z \cdot \frac{692910599291889}{10000000000000000} + \frac{307332350656623}{625000000000000}\right) \cdot z\right) \cdot y}\right)}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      17. lower-*.f64N/A

        \[\leadsto x + \frac{\mathsf{fma}\left(y, \frac{11167812716741}{40000000000000}, \color{blue}{\left(\left(z \cdot \frac{692910599291889}{10000000000000000} + \frac{307332350656623}{625000000000000}\right) \cdot z\right)} \cdot y\right)}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      18. *-commutativeN/A

        \[\leadsto x + \frac{\mathsf{fma}\left(y, \frac{11167812716741}{40000000000000}, \left(\left(\color{blue}{\frac{692910599291889}{10000000000000000} \cdot z} + \frac{307332350656623}{625000000000000}\right) \cdot z\right) \cdot y\right)}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      19. lower-fma.f6499.3

        \[\leadsto x + \frac{\mathsf{fma}\left(y, 0.279195317918525, \left(\color{blue}{\mathsf{fma}\left(0.0692910599291889, z, 0.4917317610505968\right)} \cdot z\right) \cdot y\right)}{\left(z + 6.012459259764103\right) \cdot z + 3.350343815022304} \]
    3. Applied rewrites99.3%

      \[\leadsto x + \frac{\color{blue}{\mathsf{fma}\left(y, 0.279195317918525, \left(\mathsf{fma}\left(0.0692910599291889, z, 0.4917317610505968\right) \cdot z\right) \cdot y\right)}}{\left(z + 6.012459259764103\right) \cdot z + 3.350343815022304} \]
    4. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto x + \frac{\mathsf{fma}\left(y, \frac{11167812716741}{40000000000000}, \color{blue}{\left(\mathsf{fma}\left(\frac{692910599291889}{10000000000000000}, z, \frac{307332350656623}{625000000000000}\right) \cdot z\right) \cdot y}\right)}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      2. lift-*.f64N/A

        \[\leadsto x + \frac{\mathsf{fma}\left(y, \frac{11167812716741}{40000000000000}, \color{blue}{\left(\mathsf{fma}\left(\frac{692910599291889}{10000000000000000}, z, \frac{307332350656623}{625000000000000}\right) \cdot z\right)} \cdot y\right)}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      3. lift-fma.f64N/A

        \[\leadsto x + \frac{\mathsf{fma}\left(y, \frac{11167812716741}{40000000000000}, \left(\color{blue}{\left(\frac{692910599291889}{10000000000000000} \cdot z + \frac{307332350656623}{625000000000000}\right)} \cdot z\right) \cdot y\right)}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      4. lower-fma.f64N/A

        \[\leadsto x + \frac{\color{blue}{y \cdot \frac{11167812716741}{40000000000000} + \left(\left(\frac{692910599291889}{10000000000000000} \cdot z + \frac{307332350656623}{625000000000000}\right) \cdot z\right) \cdot y}}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      5. +-commutativeN/A

        \[\leadsto x + \frac{\color{blue}{\left(\left(\frac{692910599291889}{10000000000000000} \cdot z + \frac{307332350656623}{625000000000000}\right) \cdot z\right) \cdot y + y \cdot \frac{11167812716741}{40000000000000}}}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      6. associate-*l*N/A

        \[\leadsto x + \frac{\color{blue}{\left(\frac{692910599291889}{10000000000000000} \cdot z + \frac{307332350656623}{625000000000000}\right) \cdot \left(z \cdot y\right)} + y \cdot \frac{11167812716741}{40000000000000}}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      7. *-commutativeN/A

        \[\leadsto x + \frac{\left(\frac{692910599291889}{10000000000000000} \cdot z + \frac{307332350656623}{625000000000000}\right) \cdot \color{blue}{\left(y \cdot z\right)} + y \cdot \frac{11167812716741}{40000000000000}}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      8. *-commutativeN/A

        \[\leadsto x + \frac{\left(\frac{692910599291889}{10000000000000000} \cdot z + \frac{307332350656623}{625000000000000}\right) \cdot \left(y \cdot z\right) + \color{blue}{\frac{11167812716741}{40000000000000} \cdot y}}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      9. lower-fma.f64N/A

        \[\leadsto x + \frac{\color{blue}{\mathsf{fma}\left(\frac{692910599291889}{10000000000000000} \cdot z + \frac{307332350656623}{625000000000000}, y \cdot z, \frac{11167812716741}{40000000000000} \cdot y\right)}}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      10. lift-fma.f64N/A

        \[\leadsto x + \frac{\mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(\frac{692910599291889}{10000000000000000}, z, \frac{307332350656623}{625000000000000}\right)}, y \cdot z, \frac{11167812716741}{40000000000000} \cdot y\right)}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      11. *-commutativeN/A

        \[\leadsto x + \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{692910599291889}{10000000000000000}, z, \frac{307332350656623}{625000000000000}\right), \color{blue}{z \cdot y}, \frac{11167812716741}{40000000000000} \cdot y\right)}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      12. lower-*.f64N/A

        \[\leadsto x + \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{692910599291889}{10000000000000000}, z, \frac{307332350656623}{625000000000000}\right), \color{blue}{z \cdot y}, \frac{11167812716741}{40000000000000} \cdot y\right)}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
      13. lower-*.f6499.3

        \[\leadsto x + \frac{\mathsf{fma}\left(\mathsf{fma}\left(0.0692910599291889, z, 0.4917317610505968\right), z \cdot y, \color{blue}{0.279195317918525 \cdot y}\right)}{\left(z + 6.012459259764103\right) \cdot z + 3.350343815022304} \]
    5. Applied rewrites99.3%

      \[\leadsto x + \frac{\color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(0.0692910599291889, z, 0.4917317610505968\right), z \cdot y, 0.279195317918525 \cdot y\right)}}{\left(z + 6.012459259764103\right) \cdot z + 3.350343815022304} \]
    6. Taylor expanded in z around 0

      \[\leadsto \color{blue}{x + \frac{279195317918525}{3350343815022304} \cdot y} \]
    7. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \frac{279195317918525}{3350343815022304} \cdot y + \color{blue}{x} \]
      2. lower-fma.f6490.0

        \[\leadsto \mathsf{fma}\left(0.08333333333333323, \color{blue}{y}, x\right) \]
    8. Applied rewrites90.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(0.08333333333333323, y, x\right)} \]
    9. Taylor expanded in x around 0

      \[\leadsto \frac{279195317918525}{3350343815022304} \cdot \color{blue}{y} \]
    10. Step-by-step derivation
      1. lower-*.f6477.7

        \[\leadsto 0.08333333333333323 \cdot y \]
    11. Applied rewrites77.7%

      \[\leadsto 0.08333333333333323 \cdot \color{blue}{y} \]

    if -2e153 < (/.f64 (*.f64 y (+.f64 (*.f64 (+.f64 (*.f64 z #s(literal 692910599291889/10000000000000000 binary64)) #s(literal 307332350656623/625000000000000 binary64)) z) #s(literal 11167812716741/40000000000000 binary64))) (+.f64 (*.f64 (+.f64 z #s(literal 6012459259764103/1000000000000000 binary64)) z) #s(literal 104698244219447/31250000000000 binary64)))

    1. Initial program 69.1%

      \[x + \frac{y \cdot \left(\left(z \cdot 0.0692910599291889 + 0.4917317610505968\right) \cdot z + 0.279195317918525\right)}{\left(z + 6.012459259764103\right) \cdot z + 3.350343815022304} \]
    2. Taylor expanded in z around inf

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

        \[\leadsto \frac{692910599291889}{10000000000000000} \cdot y + \color{blue}{x} \]
      2. lower-fma.f6482.1

        \[\leadsto \mathsf{fma}\left(0.0692910599291889, \color{blue}{y}, x\right) \]
    4. Applied rewrites82.1%

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

Alternative 9: 60.3% accurate, 2.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1.55 \cdot 10^{-148}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 7.8 \cdot 10^{-103}:\\ \;\;\;\;0.08333333333333323 \cdot y\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= x -1.55e-148) x (if (<= x 7.8e-103) (* 0.08333333333333323 y) x)))
double code(double x, double y, double z) {
	double tmp;
	if (x <= -1.55e-148) {
		tmp = x;
	} else if (x <= 7.8e-103) {
		tmp = 0.08333333333333323 * y;
	} else {
		tmp = 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 (x <= (-1.55d-148)) then
        tmp = x
    else if (x <= 7.8d-103) then
        tmp = 0.08333333333333323d0 * y
    else
        tmp = x
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (x <= -1.55e-148) {
		tmp = x;
	} else if (x <= 7.8e-103) {
		tmp = 0.08333333333333323 * y;
	} else {
		tmp = x;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if x <= -1.55e-148:
		tmp = x
	elif x <= 7.8e-103:
		tmp = 0.08333333333333323 * y
	else:
		tmp = x
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (x <= -1.55e-148)
		tmp = x;
	elseif (x <= 7.8e-103)
		tmp = Float64(0.08333333333333323 * y);
	else
		tmp = x;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (x <= -1.55e-148)
		tmp = x;
	elseif (x <= 7.8e-103)
		tmp = 0.08333333333333323 * y;
	else
		tmp = x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[x, -1.55e-148], x, If[LessEqual[x, 7.8e-103], N[(0.08333333333333323 * y), $MachinePrecision], x]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.55 \cdot 10^{-148}:\\
\;\;\;\;x\\

\mathbf{elif}\;x \leq 7.8 \cdot 10^{-103}:\\
\;\;\;\;0.08333333333333323 \cdot y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.5500000000000001e-148 or 7.8000000000000004e-103 < x

    1. Initial program 69.3%

      \[x + \frac{y \cdot \left(\left(z \cdot 0.0692910599291889 + 0.4917317610505968\right) \cdot z + 0.279195317918525\right)}{\left(z + 6.012459259764103\right) \cdot z + 3.350343815022304} \]
    2. Taylor expanded in x around inf

      \[\leadsto \color{blue}{x} \]
    3. Step-by-step derivation
      1. Applied rewrites64.0%

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

      if -1.5500000000000001e-148 < x < 7.8000000000000004e-103

      1. Initial program 69.2%

        \[x + \frac{y \cdot \left(\left(z \cdot 0.0692910599291889 + 0.4917317610505968\right) \cdot z + 0.279195317918525\right)}{\left(z + 6.012459259764103\right) \cdot z + 3.350343815022304} \]
      2. Step-by-step derivation
        1. lift-*.f64N/A

          \[\leadsto x + \frac{\color{blue}{y \cdot \left(\left(z \cdot \frac{692910599291889}{10000000000000000} + \frac{307332350656623}{625000000000000}\right) \cdot z + \frac{11167812716741}{40000000000000}\right)}}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
        2. lift-+.f64N/A

          \[\leadsto x + \frac{y \cdot \color{blue}{\left(\left(z \cdot \frac{692910599291889}{10000000000000000} + \frac{307332350656623}{625000000000000}\right) \cdot z + \frac{11167812716741}{40000000000000}\right)}}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
        3. lift-*.f64N/A

          \[\leadsto x + \frac{y \cdot \left(\color{blue}{\left(z \cdot \frac{692910599291889}{10000000000000000} + \frac{307332350656623}{625000000000000}\right) \cdot z} + \frac{11167812716741}{40000000000000}\right)}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
        4. lift-*.f64N/A

          \[\leadsto x + \frac{y \cdot \left(\left(\color{blue}{z \cdot \frac{692910599291889}{10000000000000000}} + \frac{307332350656623}{625000000000000}\right) \cdot z + \frac{11167812716741}{40000000000000}\right)}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
        5. lift-+.f64N/A

          \[\leadsto x + \frac{y \cdot \left(\color{blue}{\left(z \cdot \frac{692910599291889}{10000000000000000} + \frac{307332350656623}{625000000000000}\right)} \cdot z + \frac{11167812716741}{40000000000000}\right)}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
        6. +-commutativeN/A

          \[\leadsto x + \frac{y \cdot \left(\color{blue}{\left(\frac{307332350656623}{625000000000000} + z \cdot \frac{692910599291889}{10000000000000000}\right)} \cdot z + \frac{11167812716741}{40000000000000}\right)}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
        7. *-commutativeN/A

          \[\leadsto x + \frac{y \cdot \left(\left(\frac{307332350656623}{625000000000000} + \color{blue}{\frac{692910599291889}{10000000000000000} \cdot z}\right) \cdot z + \frac{11167812716741}{40000000000000}\right)}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
        8. *-commutativeN/A

          \[\leadsto x + \frac{y \cdot \left(\color{blue}{z \cdot \left(\frac{307332350656623}{625000000000000} + \frac{692910599291889}{10000000000000000} \cdot z\right)} + \frac{11167812716741}{40000000000000}\right)}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
        9. +-commutativeN/A

          \[\leadsto x + \frac{y \cdot \color{blue}{\left(\frac{11167812716741}{40000000000000} + z \cdot \left(\frac{307332350656623}{625000000000000} + \frac{692910599291889}{10000000000000000} \cdot z\right)\right)}}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
        10. distribute-rgt-inN/A

          \[\leadsto x + \frac{\color{blue}{\frac{11167812716741}{40000000000000} \cdot y + \left(z \cdot \left(\frac{307332350656623}{625000000000000} + \frac{692910599291889}{10000000000000000} \cdot z\right)\right) \cdot y}}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
        11. *-commutativeN/A

          \[\leadsto x + \frac{\color{blue}{y \cdot \frac{11167812716741}{40000000000000}} + \left(z \cdot \left(\frac{307332350656623}{625000000000000} + \frac{692910599291889}{10000000000000000} \cdot z\right)\right) \cdot y}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
        12. *-commutativeN/A

          \[\leadsto x + \frac{y \cdot \frac{11167812716741}{40000000000000} + \color{blue}{\left(\left(\frac{307332350656623}{625000000000000} + \frac{692910599291889}{10000000000000000} \cdot z\right) \cdot z\right)} \cdot y}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
        13. *-commutativeN/A

          \[\leadsto x + \frac{y \cdot \frac{11167812716741}{40000000000000} + \left(\left(\frac{307332350656623}{625000000000000} + \color{blue}{z \cdot \frac{692910599291889}{10000000000000000}}\right) \cdot z\right) \cdot y}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
        14. +-commutativeN/A

          \[\leadsto x + \frac{y \cdot \frac{11167812716741}{40000000000000} + \left(\color{blue}{\left(z \cdot \frac{692910599291889}{10000000000000000} + \frac{307332350656623}{625000000000000}\right)} \cdot z\right) \cdot y}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
        15. lower-fma.f64N/A

          \[\leadsto x + \frac{\color{blue}{\mathsf{fma}\left(y, \frac{11167812716741}{40000000000000}, \left(\left(z \cdot \frac{692910599291889}{10000000000000000} + \frac{307332350656623}{625000000000000}\right) \cdot z\right) \cdot y\right)}}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
        16. lower-*.f64N/A

          \[\leadsto x + \frac{\mathsf{fma}\left(y, \frac{11167812716741}{40000000000000}, \color{blue}{\left(\left(z \cdot \frac{692910599291889}{10000000000000000} + \frac{307332350656623}{625000000000000}\right) \cdot z\right) \cdot y}\right)}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
        17. lower-*.f64N/A

          \[\leadsto x + \frac{\mathsf{fma}\left(y, \frac{11167812716741}{40000000000000}, \color{blue}{\left(\left(z \cdot \frac{692910599291889}{10000000000000000} + \frac{307332350656623}{625000000000000}\right) \cdot z\right)} \cdot y\right)}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
        18. *-commutativeN/A

          \[\leadsto x + \frac{\mathsf{fma}\left(y, \frac{11167812716741}{40000000000000}, \left(\left(\color{blue}{\frac{692910599291889}{10000000000000000} \cdot z} + \frac{307332350656623}{625000000000000}\right) \cdot z\right) \cdot y\right)}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
        19. lower-fma.f6469.2

          \[\leadsto x + \frac{\mathsf{fma}\left(y, 0.279195317918525, \left(\color{blue}{\mathsf{fma}\left(0.0692910599291889, z, 0.4917317610505968\right)} \cdot z\right) \cdot y\right)}{\left(z + 6.012459259764103\right) \cdot z + 3.350343815022304} \]
      3. Applied rewrites69.2%

        \[\leadsto x + \frac{\color{blue}{\mathsf{fma}\left(y, 0.279195317918525, \left(\mathsf{fma}\left(0.0692910599291889, z, 0.4917317610505968\right) \cdot z\right) \cdot y\right)}}{\left(z + 6.012459259764103\right) \cdot z + 3.350343815022304} \]
      4. Step-by-step derivation
        1. lift-*.f64N/A

          \[\leadsto x + \frac{\mathsf{fma}\left(y, \frac{11167812716741}{40000000000000}, \color{blue}{\left(\mathsf{fma}\left(\frac{692910599291889}{10000000000000000}, z, \frac{307332350656623}{625000000000000}\right) \cdot z\right) \cdot y}\right)}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
        2. lift-*.f64N/A

          \[\leadsto x + \frac{\mathsf{fma}\left(y, \frac{11167812716741}{40000000000000}, \color{blue}{\left(\mathsf{fma}\left(\frac{692910599291889}{10000000000000000}, z, \frac{307332350656623}{625000000000000}\right) \cdot z\right)} \cdot y\right)}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
        3. lift-fma.f64N/A

          \[\leadsto x + \frac{\mathsf{fma}\left(y, \frac{11167812716741}{40000000000000}, \left(\color{blue}{\left(\frac{692910599291889}{10000000000000000} \cdot z + \frac{307332350656623}{625000000000000}\right)} \cdot z\right) \cdot y\right)}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
        4. lower-fma.f64N/A

          \[\leadsto x + \frac{\color{blue}{y \cdot \frac{11167812716741}{40000000000000} + \left(\left(\frac{692910599291889}{10000000000000000} \cdot z + \frac{307332350656623}{625000000000000}\right) \cdot z\right) \cdot y}}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
        5. +-commutativeN/A

          \[\leadsto x + \frac{\color{blue}{\left(\left(\frac{692910599291889}{10000000000000000} \cdot z + \frac{307332350656623}{625000000000000}\right) \cdot z\right) \cdot y + y \cdot \frac{11167812716741}{40000000000000}}}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
        6. associate-*l*N/A

          \[\leadsto x + \frac{\color{blue}{\left(\frac{692910599291889}{10000000000000000} \cdot z + \frac{307332350656623}{625000000000000}\right) \cdot \left(z \cdot y\right)} + y \cdot \frac{11167812716741}{40000000000000}}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
        7. *-commutativeN/A

          \[\leadsto x + \frac{\left(\frac{692910599291889}{10000000000000000} \cdot z + \frac{307332350656623}{625000000000000}\right) \cdot \color{blue}{\left(y \cdot z\right)} + y \cdot \frac{11167812716741}{40000000000000}}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
        8. *-commutativeN/A

          \[\leadsto x + \frac{\left(\frac{692910599291889}{10000000000000000} \cdot z + \frac{307332350656623}{625000000000000}\right) \cdot \left(y \cdot z\right) + \color{blue}{\frac{11167812716741}{40000000000000} \cdot y}}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
        9. lower-fma.f64N/A

          \[\leadsto x + \frac{\color{blue}{\mathsf{fma}\left(\frac{692910599291889}{10000000000000000} \cdot z + \frac{307332350656623}{625000000000000}, y \cdot z, \frac{11167812716741}{40000000000000} \cdot y\right)}}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
        10. lift-fma.f64N/A

          \[\leadsto x + \frac{\mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(\frac{692910599291889}{10000000000000000}, z, \frac{307332350656623}{625000000000000}\right)}, y \cdot z, \frac{11167812716741}{40000000000000} \cdot y\right)}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
        11. *-commutativeN/A

          \[\leadsto x + \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{692910599291889}{10000000000000000}, z, \frac{307332350656623}{625000000000000}\right), \color{blue}{z \cdot y}, \frac{11167812716741}{40000000000000} \cdot y\right)}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
        12. lower-*.f64N/A

          \[\leadsto x + \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{692910599291889}{10000000000000000}, z, \frac{307332350656623}{625000000000000}\right), \color{blue}{z \cdot y}, \frac{11167812716741}{40000000000000} \cdot y\right)}{\left(z + \frac{6012459259764103}{1000000000000000}\right) \cdot z + \frac{104698244219447}{31250000000000}} \]
        13. lower-*.f6471.9

          \[\leadsto x + \frac{\mathsf{fma}\left(\mathsf{fma}\left(0.0692910599291889, z, 0.4917317610505968\right), z \cdot y, \color{blue}{0.279195317918525 \cdot y}\right)}{\left(z + 6.012459259764103\right) \cdot z + 3.350343815022304} \]
      5. Applied rewrites71.9%

        \[\leadsto x + \frac{\color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(0.0692910599291889, z, 0.4917317610505968\right), z \cdot y, 0.279195317918525 \cdot y\right)}}{\left(z + 6.012459259764103\right) \cdot z + 3.350343815022304} \]
      6. Taylor expanded in z around 0

        \[\leadsto \color{blue}{x + \frac{279195317918525}{3350343815022304} \cdot y} \]
      7. Step-by-step derivation
        1. +-commutativeN/A

          \[\leadsto \frac{279195317918525}{3350343815022304} \cdot y + \color{blue}{x} \]
        2. lower-fma.f6464.4

          \[\leadsto \mathsf{fma}\left(0.08333333333333323, \color{blue}{y}, x\right) \]
      8. Applied rewrites64.4%

        \[\leadsto \color{blue}{\mathsf{fma}\left(0.08333333333333323, y, x\right)} \]
      9. Taylor expanded in x around 0

        \[\leadsto \frac{279195317918525}{3350343815022304} \cdot \color{blue}{y} \]
      10. Step-by-step derivation
        1. lower-*.f6449.9

          \[\leadsto 0.08333333333333323 \cdot y \]
      11. Applied rewrites49.9%

        \[\leadsto 0.08333333333333323 \cdot \color{blue}{y} \]
    4. Recombined 2 regimes into one program.
    5. Add Preprocessing

    Alternative 10: 59.9% accurate, 2.6× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1.7 \cdot 10^{-148}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.82 \cdot 10^{-103}:\\ \;\;\;\;y \cdot 0.0692910599291889\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \end{array} \]
    (FPCore (x y z)
     :precision binary64
     (if (<= x -1.7e-148) x (if (<= x 1.82e-103) (* y 0.0692910599291889) x)))
    double code(double x, double y, double z) {
    	double tmp;
    	if (x <= -1.7e-148) {
    		tmp = x;
    	} else if (x <= 1.82e-103) {
    		tmp = y * 0.0692910599291889;
    	} else {
    		tmp = 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 (x <= (-1.7d-148)) then
            tmp = x
        else if (x <= 1.82d-103) then
            tmp = y * 0.0692910599291889d0
        else
            tmp = x
        end if
        code = tmp
    end function
    
    public static double code(double x, double y, double z) {
    	double tmp;
    	if (x <= -1.7e-148) {
    		tmp = x;
    	} else if (x <= 1.82e-103) {
    		tmp = y * 0.0692910599291889;
    	} else {
    		tmp = x;
    	}
    	return tmp;
    }
    
    def code(x, y, z):
    	tmp = 0
    	if x <= -1.7e-148:
    		tmp = x
    	elif x <= 1.82e-103:
    		tmp = y * 0.0692910599291889
    	else:
    		tmp = x
    	return tmp
    
    function code(x, y, z)
    	tmp = 0.0
    	if (x <= -1.7e-148)
    		tmp = x;
    	elseif (x <= 1.82e-103)
    		tmp = Float64(y * 0.0692910599291889);
    	else
    		tmp = x;
    	end
    	return tmp
    end
    
    function tmp_2 = code(x, y, z)
    	tmp = 0.0;
    	if (x <= -1.7e-148)
    		tmp = x;
    	elseif (x <= 1.82e-103)
    		tmp = y * 0.0692910599291889;
    	else
    		tmp = x;
    	end
    	tmp_2 = tmp;
    end
    
    code[x_, y_, z_] := If[LessEqual[x, -1.7e-148], x, If[LessEqual[x, 1.82e-103], N[(y * 0.0692910599291889), $MachinePrecision], x]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    \mathbf{if}\;x \leq -1.7 \cdot 10^{-148}:\\
    \;\;\;\;x\\
    
    \mathbf{elif}\;x \leq 1.82 \cdot 10^{-103}:\\
    \;\;\;\;y \cdot 0.0692910599291889\\
    
    \mathbf{else}:\\
    \;\;\;\;x\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if x < -1.7000000000000001e-148 or 1.8199999999999999e-103 < x

      1. Initial program 69.3%

        \[x + \frac{y \cdot \left(\left(z \cdot 0.0692910599291889 + 0.4917317610505968\right) \cdot z + 0.279195317918525\right)}{\left(z + 6.012459259764103\right) \cdot z + 3.350343815022304} \]
      2. Taylor expanded in x around inf

        \[\leadsto \color{blue}{x} \]
      3. Step-by-step derivation
        1. Applied rewrites64.0%

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

        if -1.7000000000000001e-148 < x < 1.8199999999999999e-103

        1. Initial program 69.2%

          \[x + \frac{y \cdot \left(\left(z \cdot 0.0692910599291889 + 0.4917317610505968\right) \cdot z + 0.279195317918525\right)}{\left(z + 6.012459259764103\right) \cdot z + 3.350343815022304} \]
        2. Taylor expanded in z around 0

          \[\leadsto x + \color{blue}{\frac{279195317918525}{3350343815022304} \cdot y} \]
        3. Step-by-step derivation
          1. lower-*.f6464.4

            \[\leadsto x + 0.08333333333333323 \cdot \color{blue}{y} \]
        4. Applied rewrites64.4%

          \[\leadsto x + \color{blue}{0.08333333333333323 \cdot y} \]
        5. Taylor expanded in z around inf

          \[\leadsto \color{blue}{x + \frac{692910599291889}{10000000000000000} \cdot y} \]
        6. Step-by-step derivation
          1. distribute-lft-inN/A

            \[\leadsto x + \frac{692910599291889}{10000000000000000} \cdot y \]
          2. *-commutativeN/A

            \[\leadsto x + \frac{692910599291889}{10000000000000000} \cdot y \]
          3. *-commutativeN/A

            \[\leadsto x + \frac{692910599291889}{10000000000000000} \cdot y \]
          4. +-commutativeN/A

            \[\leadsto x + \frac{692910599291889}{10000000000000000} \cdot y \]
          5. +-commutativeN/A

            \[\leadsto \frac{692910599291889}{10000000000000000} \cdot y + \color{blue}{x} \]
          6. lower-fma.f6466.1

            \[\leadsto \mathsf{fma}\left(0.0692910599291889, \color{blue}{y}, x\right) \]
        7. Applied rewrites66.1%

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

          \[\leadsto \frac{692910599291889}{10000000000000000} \cdot \color{blue}{y} \]
        9. Step-by-step derivation
          1. *-commutativeN/A

            \[\leadsto y \cdot \frac{692910599291889}{10000000000000000} \]
          2. lower-*.f6451.5

            \[\leadsto y \cdot 0.0692910599291889 \]
        10. Applied rewrites51.5%

          \[\leadsto y \cdot \color{blue}{0.0692910599291889} \]
      4. Recombined 2 regimes into one program.
      5. Add Preprocessing

      Alternative 11: 50.2% accurate, 29.9× speedup?

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

        \[x + \frac{y \cdot \left(\left(z \cdot 0.0692910599291889 + 0.4917317610505968\right) \cdot z + 0.279195317918525\right)}{\left(z + 6.012459259764103\right) \cdot z + 3.350343815022304} \]
      2. Taylor expanded in x around inf

        \[\leadsto \color{blue}{x} \]
      3. Step-by-step derivation
        1. Applied rewrites50.2%

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

        Reproduce

        ?
        herbie shell --seed 2025106 
        (FPCore (x y z)
          :name "Numeric.SpecFunctions:logGamma from math-functions-0.1.5.2, B"
          :precision binary64
          (+ x (/ (* y (+ (* (+ (* z 0.0692910599291889) 0.4917317610505968) z) 0.279195317918525)) (+ (* (+ z 6.012459259764103) z) 3.350343815022304))))