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

Percentage Accurate: 69.3% → 99.5%
Time: 3.9s
Alternatives: 10
Speedup: 6.7×

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 10 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 69.3% 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.5% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;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} \leq 2 \cdot 10^{+303}:\\ \;\;\;\;\mathsf{fma}\left(\frac{\mathsf{fma}\left(\mathsf{fma}\left(0.0692910599291889, z, 0.4917317610505968\right), z, 0.279195317918525\right)}{\mathsf{fma}\left(6.012459259764103 + z, z, 3.350343815022304\right)}, y, x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{0.07512208616047561}{z} + 0.0692910599291889, y, x\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<=
      (+
       x
       (/
        (*
         y
         (+
          (* (+ (* z 0.0692910599291889) 0.4917317610505968) z)
          0.279195317918525))
        (+ (* (+ z 6.012459259764103) z) 3.350343815022304)))
      2e+303)
   (fma
    (/
     (fma (fma 0.0692910599291889 z 0.4917317610505968) z 0.279195317918525)
     (fma (+ 6.012459259764103 z) z 3.350343815022304))
    y
    x)
   (fma (+ (/ 0.07512208616047561 z) 0.0692910599291889) y x)))
double code(double x, double y, double z) {
	double tmp;
	if ((x + ((y * ((((z * 0.0692910599291889) + 0.4917317610505968) * z) + 0.279195317918525)) / (((z + 6.012459259764103) * z) + 3.350343815022304))) <= 2e+303) {
		tmp = fma((fma(fma(0.0692910599291889, z, 0.4917317610505968), z, 0.279195317918525) / fma((6.012459259764103 + z), z, 3.350343815022304)), y, x);
	} else {
		tmp = fma(((0.07512208616047561 / z) + 0.0692910599291889), y, x);
	}
	return tmp;
}
function code(x, y, z)
	tmp = 0.0
	if (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))) <= 2e+303)
		tmp = fma(Float64(fma(fma(0.0692910599291889, z, 0.4917317610505968), z, 0.279195317918525) / fma(Float64(6.012459259764103 + z), z, 3.350343815022304)), y, x);
	else
		tmp = fma(Float64(Float64(0.07512208616047561 / z) + 0.0692910599291889), y, x);
	end
	return tmp
end
code[x_, y_, z_] := If[LessEqual[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], 2e+303], N[(N[(N[(N[(0.0692910599291889 * z + 0.4917317610505968), $MachinePrecision] * z + 0.279195317918525), $MachinePrecision] / N[(N[(6.012459259764103 + z), $MachinePrecision] * z + 3.350343815022304), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision], N[(N[(N[(0.07512208616047561 / z), $MachinePrecision] + 0.0692910599291889), $MachinePrecision] * y + x), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;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} \leq 2 \cdot 10^{+303}:\\
\;\;\;\;\mathsf{fma}\left(\frac{\mathsf{fma}\left(\mathsf{fma}\left(0.0692910599291889, z, 0.4917317610505968\right), z, 0.279195317918525\right)}{\mathsf{fma}\left(6.012459259764103 + z, z, 3.350343815022304\right)}, y, x\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (+.f64 x (/.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)))) < 2e303

    1. Initial program 95.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. Applied rewrites99.7%

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

    if 2e303 < (+.f64 x (/.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 2.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. Applied rewrites12.6%

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\frac{\frac{751220861604756070699018739433}{10000000000000000000000000000000} \cdot 1}{z} + \frac{692910599291889}{10000000000000000}, y, x\right) \]
      4. metadata-evalN/A

        \[\leadsto \mathsf{fma}\left(\frac{\frac{751220861604756070699018739433}{10000000000000000000000000000000}}{z} + \frac{692910599291889}{10000000000000000}, y, x\right) \]
      5. lower-/.f6498.9

        \[\leadsto \mathsf{fma}\left(\frac{0.07512208616047561}{z} + 0.0692910599291889, y, x\right) \]
    5. Applied rewrites98.9%

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

Alternative 2: 99.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(\left(-\frac{\frac{0.4046220386999212}{z} - 0.07512208616047561}{z}\right) + 0.0692910599291889, y, x\right)\\ \mathbf{if}\;z \leq -5.4:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq 2.7:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.0005951669793454025, z, 0.0007936505811533442\right) \cdot z - 0.00277777777751721, z, 0.08333333333333323\right), y, x\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0
         (fma
          (+
           (- (/ (- (/ 0.4046220386999212 z) 0.07512208616047561) z))
           0.0692910599291889)
          y
          x)))
   (if (<= z -5.4)
     t_0
     (if (<= z 2.7)
       (fma
        (fma
         (-
          (* (fma -0.0005951669793454025 z 0.0007936505811533442) z)
          0.00277777777751721)
         z
         0.08333333333333323)
        y
        x)
       t_0))))
double code(double x, double y, double z) {
	double t_0 = fma((-(((0.4046220386999212 / z) - 0.07512208616047561) / z) + 0.0692910599291889), y, x);
	double tmp;
	if (z <= -5.4) {
		tmp = t_0;
	} else if (z <= 2.7) {
		tmp = fma(fma(((fma(-0.0005951669793454025, z, 0.0007936505811533442) * z) - 0.00277777777751721), z, 0.08333333333333323), y, x);
	} else {
		tmp = t_0;
	}
	return tmp;
}
function code(x, y, z)
	t_0 = fma(Float64(Float64(-Float64(Float64(Float64(0.4046220386999212 / z) - 0.07512208616047561) / z)) + 0.0692910599291889), y, x)
	tmp = 0.0
	if (z <= -5.4)
		tmp = t_0;
	elseif (z <= 2.7)
		tmp = fma(fma(Float64(Float64(fma(-0.0005951669793454025, z, 0.0007936505811533442) * z) - 0.00277777777751721), z, 0.08333333333333323), y, x);
	else
		tmp = t_0;
	end
	return tmp
end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[((-N[(N[(N[(0.4046220386999212 / z), $MachinePrecision] - 0.07512208616047561), $MachinePrecision] / z), $MachinePrecision]) + 0.0692910599291889), $MachinePrecision] * y + x), $MachinePrecision]}, If[LessEqual[z, -5.4], t$95$0, If[LessEqual[z, 2.7], N[(N[(N[(N[(N[(-0.0005951669793454025 * z + 0.0007936505811533442), $MachinePrecision] * z), $MachinePrecision] - 0.00277777777751721), $MachinePrecision] * z + 0.08333333333333323), $MachinePrecision] * y + x), $MachinePrecision], t$95$0]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\left(-\frac{\frac{0.4046220386999212}{z} - 0.07512208616047561}{z}\right) + 0.0692910599291889, y, x\right)\\
\mathbf{if}\;z \leq -5.4:\\
\;\;\;\;t\_0\\

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

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


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

    1. Initial program 38.7%

      \[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. Applied rewrites50.7%

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

      \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{692910599291889}{10000000000000000} + -1 \cdot \frac{\frac{4046220386999211718548694042263781576003973599}{10000000000000000000000000000000000000000000000} \cdot \frac{1}{z} - \frac{751220861604756070699018739433}{10000000000000000000000000000000}}{z}}, y, x\right) \]
    4. Step-by-step derivation
      1. +-commutativeN/A

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

        \[\leadsto \mathsf{fma}\left(-1 \cdot \frac{\frac{4046220386999211718548694042263781576003973599}{10000000000000000000000000000000000000000000000} \cdot \frac{1}{z} - \frac{751220861604756070699018739433}{10000000000000000000000000000000}}{z} + \color{blue}{\frac{692910599291889}{10000000000000000}}, y, x\right) \]
      3. mul-1-negN/A

        \[\leadsto \mathsf{fma}\left(\left(\mathsf{neg}\left(\frac{\frac{4046220386999211718548694042263781576003973599}{10000000000000000000000000000000000000000000000} \cdot \frac{1}{z} - \frac{751220861604756070699018739433}{10000000000000000000000000000000}}{z}\right)\right) + \frac{692910599291889}{10000000000000000}, y, x\right) \]
      4. lower-neg.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(-\frac{\frac{4046220386999211718548694042263781576003973599}{10000000000000000000000000000000000000000000000} \cdot \frac{1}{z} - \frac{751220861604756070699018739433}{10000000000000000000000000000000}}{z}\right) + \frac{692910599291889}{10000000000000000}, y, x\right) \]
      5. lower-/.f64N/A

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

        \[\leadsto \mathsf{fma}\left(\left(-\frac{\frac{4046220386999211718548694042263781576003973599}{10000000000000000000000000000000000000000000000} \cdot \frac{1}{z} - \frac{751220861604756070699018739433}{10000000000000000000000000000000}}{z}\right) + \frac{692910599291889}{10000000000000000}, y, x\right) \]
      7. associate-*r/N/A

        \[\leadsto \mathsf{fma}\left(\left(-\frac{\frac{\frac{4046220386999211718548694042263781576003973599}{10000000000000000000000000000000000000000000000} \cdot 1}{z} - \frac{751220861604756070699018739433}{10000000000000000000000000000000}}{z}\right) + \frac{692910599291889}{10000000000000000}, y, x\right) \]
      8. metadata-evalN/A

        \[\leadsto \mathsf{fma}\left(\left(-\frac{\frac{\frac{4046220386999211718548694042263781576003973599}{10000000000000000000000000000000000000000000000}}{z} - \frac{751220861604756070699018739433}{10000000000000000000000000000000}}{z}\right) + \frac{692910599291889}{10000000000000000}, y, x\right) \]
      9. lower-/.f6499.3

        \[\leadsto \mathsf{fma}\left(\left(-\frac{\frac{0.4046220386999212}{z} - 0.07512208616047561}{z}\right) + 0.0692910599291889, y, x\right) \]
    5. Applied rewrites99.3%

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

    if -5.4000000000000004 < z < 2.7000000000000002

    1. Initial program 99.7%

      \[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. Applied rewrites99.8%

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

      \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{279195317918525}{3350343815022304} + z \cdot \left(z \cdot \left(\frac{149233894885562575800992648418763933371314529}{188034757901510979839193143041976607183277752320} + \frac{-374943941275717765274452559944207169728571246668095556552487}{629981088144543617699065742275429975113587435159029727787745280} \cdot z\right) - \frac{155900051080628738716045985239}{56124018394291031809500087342080}\right)}, y, x\right) \]
    4. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \mathsf{fma}\left(z \cdot \left(z \cdot \left(\frac{149233894885562575800992648418763933371314529}{188034757901510979839193143041976607183277752320} + \frac{-374943941275717765274452559944207169728571246668095556552487}{629981088144543617699065742275429975113587435159029727787745280} \cdot z\right) - \frac{155900051080628738716045985239}{56124018394291031809500087342080}\right) + \color{blue}{\frac{279195317918525}{3350343815022304}}, y, x\right) \]
      2. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\left(z \cdot \left(\frac{149233894885562575800992648418763933371314529}{188034757901510979839193143041976607183277752320} + \frac{-374943941275717765274452559944207169728571246668095556552487}{629981088144543617699065742275429975113587435159029727787745280} \cdot z\right) - \frac{155900051080628738716045985239}{56124018394291031809500087342080}\right) \cdot z + \frac{279195317918525}{3350343815022304}, y, x\right) \]
      3. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(z \cdot \left(\frac{149233894885562575800992648418763933371314529}{188034757901510979839193143041976607183277752320} + \frac{-374943941275717765274452559944207169728571246668095556552487}{629981088144543617699065742275429975113587435159029727787745280} \cdot z\right) - \frac{155900051080628738716045985239}{56124018394291031809500087342080}, \color{blue}{z}, \frac{279195317918525}{3350343815022304}\right), y, x\right) \]
      4. lower--.f64N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(z \cdot \left(\frac{149233894885562575800992648418763933371314529}{188034757901510979839193143041976607183277752320} + \frac{-374943941275717765274452559944207169728571246668095556552487}{629981088144543617699065742275429975113587435159029727787745280} \cdot z\right) - \frac{155900051080628738716045985239}{56124018394291031809500087342080}, z, \frac{279195317918525}{3350343815022304}\right), y, x\right) \]
      5. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\left(\frac{149233894885562575800992648418763933371314529}{188034757901510979839193143041976607183277752320} + \frac{-374943941275717765274452559944207169728571246668095556552487}{629981088144543617699065742275429975113587435159029727787745280} \cdot z\right) \cdot z - \frac{155900051080628738716045985239}{56124018394291031809500087342080}, z, \frac{279195317918525}{3350343815022304}\right), y, x\right) \]
      6. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\left(\frac{149233894885562575800992648418763933371314529}{188034757901510979839193143041976607183277752320} + \frac{-374943941275717765274452559944207169728571246668095556552487}{629981088144543617699065742275429975113587435159029727787745280} \cdot z\right) \cdot z - \frac{155900051080628738716045985239}{56124018394291031809500087342080}, z, \frac{279195317918525}{3350343815022304}\right), y, x\right) \]
      7. +-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\left(\frac{-374943941275717765274452559944207169728571246668095556552487}{629981088144543617699065742275429975113587435159029727787745280} \cdot z + \frac{149233894885562575800992648418763933371314529}{188034757901510979839193143041976607183277752320}\right) \cdot z - \frac{155900051080628738716045985239}{56124018394291031809500087342080}, z, \frac{279195317918525}{3350343815022304}\right), y, x\right) \]
      8. lower-fma.f6499.6

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.0005951669793454025, z, 0.0007936505811533442\right) \cdot z - 0.00277777777751721, z, 0.08333333333333323\right), y, x\right) \]
    5. Applied rewrites99.6%

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

Alternative 3: 99.4% accurate, 1.2× speedup?

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

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

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

\mathbf{else}:\\
\;\;\;\;y \cdot \frac{\mathsf{fma}\left(z, 0.0692910599291889, 0.07512208616047561\right)}{z} + x\\


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

    1. Initial program 38.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. Applied rewrites49.9%

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\frac{\frac{751220861604756070699018739433}{10000000000000000000000000000000} \cdot 1}{z} + \frac{692910599291889}{10000000000000000}, y, x\right) \]
      4. metadata-evalN/A

        \[\leadsto \mathsf{fma}\left(\frac{\frac{751220861604756070699018739433}{10000000000000000000000000000000}}{z} + \frac{692910599291889}{10000000000000000}, y, x\right) \]
      5. lower-/.f6499.1

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

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

    if -5.4000000000000004 < z < 2.7000000000000002

    1. Initial program 99.7%

      \[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. Applied rewrites99.8%

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

      \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{279195317918525}{3350343815022304} + z \cdot \left(z \cdot \left(\frac{149233894885562575800992648418763933371314529}{188034757901510979839193143041976607183277752320} + \frac{-374943941275717765274452559944207169728571246668095556552487}{629981088144543617699065742275429975113587435159029727787745280} \cdot z\right) - \frac{155900051080628738716045985239}{56124018394291031809500087342080}\right)}, y, x\right) \]
    4. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \mathsf{fma}\left(z \cdot \left(z \cdot \left(\frac{149233894885562575800992648418763933371314529}{188034757901510979839193143041976607183277752320} + \frac{-374943941275717765274452559944207169728571246668095556552487}{629981088144543617699065742275429975113587435159029727787745280} \cdot z\right) - \frac{155900051080628738716045985239}{56124018394291031809500087342080}\right) + \color{blue}{\frac{279195317918525}{3350343815022304}}, y, x\right) \]
      2. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\left(z \cdot \left(\frac{149233894885562575800992648418763933371314529}{188034757901510979839193143041976607183277752320} + \frac{-374943941275717765274452559944207169728571246668095556552487}{629981088144543617699065742275429975113587435159029727787745280} \cdot z\right) - \frac{155900051080628738716045985239}{56124018394291031809500087342080}\right) \cdot z + \frac{279195317918525}{3350343815022304}, y, x\right) \]
      3. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(z \cdot \left(\frac{149233894885562575800992648418763933371314529}{188034757901510979839193143041976607183277752320} + \frac{-374943941275717765274452559944207169728571246668095556552487}{629981088144543617699065742275429975113587435159029727787745280} \cdot z\right) - \frac{155900051080628738716045985239}{56124018394291031809500087342080}, \color{blue}{z}, \frac{279195317918525}{3350343815022304}\right), y, x\right) \]
      4. lower--.f64N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(z \cdot \left(\frac{149233894885562575800992648418763933371314529}{188034757901510979839193143041976607183277752320} + \frac{-374943941275717765274452559944207169728571246668095556552487}{629981088144543617699065742275429975113587435159029727787745280} \cdot z\right) - \frac{155900051080628738716045985239}{56124018394291031809500087342080}, z, \frac{279195317918525}{3350343815022304}\right), y, x\right) \]
      5. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\left(\frac{149233894885562575800992648418763933371314529}{188034757901510979839193143041976607183277752320} + \frac{-374943941275717765274452559944207169728571246668095556552487}{629981088144543617699065742275429975113587435159029727787745280} \cdot z\right) \cdot z - \frac{155900051080628738716045985239}{56124018394291031809500087342080}, z, \frac{279195317918525}{3350343815022304}\right), y, x\right) \]
      6. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\left(\frac{149233894885562575800992648418763933371314529}{188034757901510979839193143041976607183277752320} + \frac{-374943941275717765274452559944207169728571246668095556552487}{629981088144543617699065742275429975113587435159029727787745280} \cdot z\right) \cdot z - \frac{155900051080628738716045985239}{56124018394291031809500087342080}, z, \frac{279195317918525}{3350343815022304}\right), y, x\right) \]
      7. +-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\left(\frac{-374943941275717765274452559944207169728571246668095556552487}{629981088144543617699065742275429975113587435159029727787745280} \cdot z + \frac{149233894885562575800992648418763933371314529}{188034757901510979839193143041976607183277752320}\right) \cdot z - \frac{155900051080628738716045985239}{56124018394291031809500087342080}, z, \frac{279195317918525}{3350343815022304}\right), y, x\right) \]
      8. lower-fma.f6499.6

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.0005951669793454025, z, 0.0007936505811533442\right) \cdot z - 0.00277777777751721, z, 0.08333333333333323\right), y, x\right) \]
    5. Applied rewrites99.6%

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

    if 2.7000000000000002 < z

    1. Initial program 39.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 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)} \]
    5. Taylor expanded in z around 0

      \[\leadsto x + \frac{\frac{692910599291889}{10000000000000000} \cdot \left(y \cdot z\right) + \frac{751220861604756070699018739433}{10000000000000000000000000000000} \cdot y}{\color{blue}{z}} \]
    6. Step-by-step derivation
      1. lower-/.f64N/A

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

        \[\leadsto x + \frac{\frac{751220861604756070699018739433}{10000000000000000000000000000000} \cdot y + \frac{692910599291889}{10000000000000000} \cdot \left(y \cdot z\right)}{z} \]
      3. lower-fma.f64N/A

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

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

        \[\leadsto x + \frac{\mathsf{fma}\left(\frac{751220861604756070699018739433}{10000000000000000000000000000000}, y, \left(y \cdot z\right) \cdot \frac{692910599291889}{10000000000000000}\right)}{z} \]
      6. lower-*.f6475.7

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

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

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

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

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

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

Alternative 4: 99.3% accurate, 1.2× speedup?

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

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

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

\mathbf{else}:\\
\;\;\;\;y \cdot \frac{\mathsf{fma}\left(z, 0.0692910599291889, 0.07512208616047561\right)}{z} + x\\


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

    1. Initial program 38.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. Applied rewrites49.9%

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\frac{\frac{751220861604756070699018739433}{10000000000000000000000000000000} \cdot 1}{z} + \frac{692910599291889}{10000000000000000}, y, x\right) \]
      4. metadata-evalN/A

        \[\leadsto \mathsf{fma}\left(\frac{\frac{751220861604756070699018739433}{10000000000000000000000000000000}}{z} + \frac{692910599291889}{10000000000000000}, y, x\right) \]
      5. lower-/.f6499.1

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

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

    if -5.4000000000000004 < z < 2.7000000000000002

    1. Initial program 99.7%

      \[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. Applied rewrites99.8%

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

      \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{279195317918525}{3350343815022304} + z \cdot \left(\frac{149233894885562575800992648418763933371314529}{188034757901510979839193143041976607183277752320} \cdot z - \frac{155900051080628738716045985239}{56124018394291031809500087342080}\right)}, y, x\right) \]
    4. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \mathsf{fma}\left(z \cdot \left(\frac{149233894885562575800992648418763933371314529}{188034757901510979839193143041976607183277752320} \cdot z - \frac{155900051080628738716045985239}{56124018394291031809500087342080}\right) + \color{blue}{\frac{279195317918525}{3350343815022304}}, y, x\right) \]
      2. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{149233894885562575800992648418763933371314529}{188034757901510979839193143041976607183277752320} \cdot z - \frac{155900051080628738716045985239}{56124018394291031809500087342080}\right) \cdot z + \frac{279195317918525}{3350343815022304}, y, x\right) \]
      3. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\frac{149233894885562575800992648418763933371314529}{188034757901510979839193143041976607183277752320} \cdot z - \frac{155900051080628738716045985239}{56124018394291031809500087342080}, \color{blue}{z}, \frac{279195317918525}{3350343815022304}\right), y, x\right) \]
      4. lower--.f64N/A

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

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

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

    if 2.7000000000000002 < z

    1. Initial program 39.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 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)} \]
    5. Taylor expanded in z around 0

      \[\leadsto x + \frac{\frac{692910599291889}{10000000000000000} \cdot \left(y \cdot z\right) + \frac{751220861604756070699018739433}{10000000000000000000000000000000} \cdot y}{\color{blue}{z}} \]
    6. Step-by-step derivation
      1. lower-/.f64N/A

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

        \[\leadsto x + \frac{\frac{751220861604756070699018739433}{10000000000000000000000000000000} \cdot y + \frac{692910599291889}{10000000000000000} \cdot \left(y \cdot z\right)}{z} \]
      3. lower-fma.f64N/A

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

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

        \[\leadsto x + \frac{\mathsf{fma}\left(\frac{751220861604756070699018739433}{10000000000000000000000000000000}, y, \left(y \cdot z\right) \cdot \frac{692910599291889}{10000000000000000}\right)}{z} \]
      6. lower-*.f6475.7

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

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

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

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

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

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

Alternative 5: 99.3% accurate, 1.4× speedup?

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

\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\frac{0.07512208616047561}{z} + 0.0692910599291889, y, x\right)\\
\mathbf{if}\;z \leq -5.4:\\
\;\;\;\;t\_0\\

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

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


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

    1. Initial program 38.7%

      \[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. Applied rewrites50.7%

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\frac{\frac{751220861604756070699018739433}{10000000000000000000000000000000} \cdot 1}{z} + \frac{692910599291889}{10000000000000000}, y, x\right) \]
      4. metadata-evalN/A

        \[\leadsto \mathsf{fma}\left(\frac{\frac{751220861604756070699018739433}{10000000000000000000000000000000}}{z} + \frac{692910599291889}{10000000000000000}, y, x\right) \]
      5. lower-/.f6499.1

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

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

    if -5.4000000000000004 < z < 2.7000000000000002

    1. Initial program 99.7%

      \[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. Applied rewrites99.8%

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

      \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{279195317918525}{3350343815022304} + z \cdot \left(\frac{149233894885562575800992648418763933371314529}{188034757901510979839193143041976607183277752320} \cdot z - \frac{155900051080628738716045985239}{56124018394291031809500087342080}\right)}, y, x\right) \]
    4. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \mathsf{fma}\left(z \cdot \left(\frac{149233894885562575800992648418763933371314529}{188034757901510979839193143041976607183277752320} \cdot z - \frac{155900051080628738716045985239}{56124018394291031809500087342080}\right) + \color{blue}{\frac{279195317918525}{3350343815022304}}, y, x\right) \]
      2. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{149233894885562575800992648418763933371314529}{188034757901510979839193143041976607183277752320} \cdot z - \frac{155900051080628738716045985239}{56124018394291031809500087342080}\right) \cdot z + \frac{279195317918525}{3350343815022304}, y, x\right) \]
      3. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\frac{149233894885562575800992648418763933371314529}{188034757901510979839193143041976607183277752320} \cdot z - \frac{155900051080628738716045985239}{56124018394291031809500087342080}, \color{blue}{z}, \frac{279195317918525}{3350343815022304}\right), y, x\right) \]
      4. lower--.f64N/A

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

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

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

Alternative 6: 99.3% accurate, 1.4× speedup?

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

\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\frac{0.07512208616047561}{z} + 0.0692910599291889, y, x\right)\\
\mathbf{if}\;z \leq -5.4:\\
\;\;\;\;t\_0\\

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

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


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

    1. Initial program 38.7%

      \[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. Applied rewrites50.7%

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\frac{\frac{751220861604756070699018739433}{10000000000000000000000000000000} \cdot 1}{z} + \frac{692910599291889}{10000000000000000}, y, x\right) \]
      4. metadata-evalN/A

        \[\leadsto \mathsf{fma}\left(\frac{\frac{751220861604756070699018739433}{10000000000000000000000000000000}}{z} + \frac{692910599291889}{10000000000000000}, y, x\right) \]
      5. lower-/.f6499.1

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

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

    if -5.4000000000000004 < z < 2.7000000000000002

    1. Initial program 99.7%

      \[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. Applied rewrites99.8%

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

      \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{279195317918525}{3350343815022304} + \frac{-155900051080628738716045985239}{56124018394291031809500087342080} \cdot z}, y, x\right) \]
    4. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\frac{-155900051080628738716045985239}{56124018394291031809500087342080} \cdot z + \color{blue}{\frac{279195317918525}{3350343815022304}}, y, x\right) \]
      2. lower-fma.f6499.4

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

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

Alternative 7: 99.0% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -5.4:\\ \;\;\;\;\mathsf{fma}\left(0.0692910599291889, y, x\right)\\ \mathbf{elif}\;z \leq 2.7:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-0.00277777777751721, z, 0.08333333333333323\right), 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.4)
   (fma 0.0692910599291889 y x)
   (if (<= z 2.7)
     (fma (fma -0.00277777777751721 z 0.08333333333333323) y x)
     (fma 0.0692910599291889 y x))))
double code(double x, double y, double z) {
	double tmp;
	if (z <= -5.4) {
		tmp = fma(0.0692910599291889, y, x);
	} else if (z <= 2.7) {
		tmp = fma(fma(-0.00277777777751721, z, 0.08333333333333323), y, x);
	} else {
		tmp = fma(0.0692910599291889, y, x);
	}
	return tmp;
}
function code(x, y, z)
	tmp = 0.0
	if (z <= -5.4)
		tmp = fma(0.0692910599291889, y, x);
	elseif (z <= 2.7)
		tmp = fma(fma(-0.00277777777751721, z, 0.08333333333333323), y, x);
	else
		tmp = fma(0.0692910599291889, y, x);
	end
	return tmp
end
code[x_, y_, z_] := If[LessEqual[z, -5.4], N[(0.0692910599291889 * y + x), $MachinePrecision], If[LessEqual[z, 2.7], N[(N[(-0.00277777777751721 * z + 0.08333333333333323), $MachinePrecision] * y + x), $MachinePrecision], N[(0.0692910599291889 * y + x), $MachinePrecision]]]
\begin{array}{l}

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

\mathbf{elif}\;z \leq 2.7:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-0.00277777777751721, z, 0.08333333333333323\right), 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.4000000000000004 or 2.7000000000000002 < z

    1. Initial program 38.7%

      \[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.4000000000000004 < z < 2.7000000000000002

    1. Initial program 99.7%

      \[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. Applied rewrites99.8%

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

      \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{279195317918525}{3350343815022304} + \frac{-155900051080628738716045985239}{56124018394291031809500087342080} \cdot z}, y, x\right) \]
    4. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\frac{-155900051080628738716045985239}{56124018394291031809500087342080} \cdot z + \color{blue}{\frac{279195317918525}{3350343815022304}}, y, x\right) \]
      2. lower-fma.f6499.4

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

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

Alternative 8: 98.8% accurate, 2.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -5.4:\\ \;\;\;\;\mathsf{fma}\left(0.0692910599291889, y, x\right)\\ \mathbf{elif}\;z \leq 2.7:\\ \;\;\;\;\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.4)
   (fma 0.0692910599291889 y x)
   (if (<= z 2.7) (fma 0.08333333333333323 y x) (fma 0.0692910599291889 y x))))
double code(double x, double y, double z) {
	double tmp;
	if (z <= -5.4) {
		tmp = fma(0.0692910599291889, y, x);
	} else if (z <= 2.7) {
		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.4)
		tmp = fma(0.0692910599291889, y, x);
	elseif (z <= 2.7)
		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.4], N[(0.0692910599291889 * y + x), $MachinePrecision], If[LessEqual[z, 2.7], N[(0.08333333333333323 * y + x), $MachinePrecision], N[(0.0692910599291889 * y + x), $MachinePrecision]]]
\begin{array}{l}

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

\mathbf{elif}\;z \leq 2.7:\\
\;\;\;\;\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.4000000000000004 or 2.7000000000000002 < z

    1. Initial program 38.7%

      \[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.4000000000000004 < z < 2.7000000000000002

    1. Initial program 99.7%

      \[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.f6499.0

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

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

Alternative 9: 79.6% accurate, 6.7× speedup?

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

\\
\mathsf{fma}\left(0.0692910599291889, y, x\right)
\end{array}
Derivation
  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 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.f6479.6

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

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

Alternative 10: 50.7% accurate, 47.0× 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.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 rewrites50.7%

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

    Reproduce

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