Statistics.Distribution.CauchyLorentz:$cdensity from math-functions-0.1.5.2

Percentage Accurate: 90.3% → 97.7%
Time: 3.7s
Alternatives: 8
Speedup: 1.0×

Specification

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

\\
\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)}
\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 8 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: 90.3% accurate, 1.0× speedup?

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

\\
\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)}
\end{array}

Alternative 1: 97.7% accurate, 0.8× speedup?

\[\begin{array}{l} z_m = \left|z\right| \\ [x, y, z_m] = \mathsf{sort}([x, y, z_m])\\ \\ \begin{array}{l} \mathbf{if}\;z\_m \leq 9.4 \cdot 10^{+114}:\\ \;\;\;\;\frac{\frac{\frac{1}{x}}{\mathsf{fma}\left(z\_m, z\_m, 1\right)}}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{z\_m \cdot y}}{z\_m \cdot x}\\ \end{array} \end{array} \]
z_m = (fabs.f64 z)
NOTE: x, y, and z_m should be sorted in increasing order before calling this function.
(FPCore (x y z_m)
 :precision binary64
 (if (<= z_m 9.4e+114)
   (/ (/ (/ 1.0 x) (fma z_m z_m 1.0)) y)
   (/ (/ 1.0 (* z_m y)) (* z_m x))))
z_m = fabs(z);
assert(x < y && y < z_m);
double code(double x, double y, double z_m) {
	double tmp;
	if (z_m <= 9.4e+114) {
		tmp = ((1.0 / x) / fma(z_m, z_m, 1.0)) / y;
	} else {
		tmp = (1.0 / (z_m * y)) / (z_m * x);
	}
	return tmp;
}
z_m = abs(z)
x, y, z_m = sort([x, y, z_m])
function code(x, y, z_m)
	tmp = 0.0
	if (z_m <= 9.4e+114)
		tmp = Float64(Float64(Float64(1.0 / x) / fma(z_m, z_m, 1.0)) / y);
	else
		tmp = Float64(Float64(1.0 / Float64(z_m * y)) / Float64(z_m * x));
	end
	return tmp
end
z_m = N[Abs[z], $MachinePrecision]
NOTE: x, y, and z_m should be sorted in increasing order before calling this function.
code[x_, y_, z$95$m_] := If[LessEqual[z$95$m, 9.4e+114], N[(N[(N[(1.0 / x), $MachinePrecision] / N[(z$95$m * z$95$m + 1.0), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision], N[(N[(1.0 / N[(z$95$m * y), $MachinePrecision]), $MachinePrecision] / N[(z$95$m * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|
\\
[x, y, z_m] = \mathsf{sort}([x, y, z_m])\\
\\
\begin{array}{l}
\mathbf{if}\;z\_m \leq 9.4 \cdot 10^{+114}:\\
\;\;\;\;\frac{\frac{\frac{1}{x}}{\mathsf{fma}\left(z\_m, z\_m, 1\right)}}{y}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{z\_m \cdot y}}{z\_m \cdot x}\\


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

    1. Initial program 97.7%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{\frac{1}{x}}{1 + z \cdot z}}{y}} \]
      8. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{\frac{\frac{1}{x}}{1 + z \cdot z}}{y}} \]
      9. lower-/.f64N/A

        \[\leadsto \frac{\color{blue}{\frac{\frac{1}{x}}{1 + z \cdot z}}}{y} \]
      10. lift-/.f64N/A

        \[\leadsto \frac{\frac{\color{blue}{\frac{1}{x}}}{1 + z \cdot z}}{y} \]
      11. pow2N/A

        \[\leadsto \frac{\frac{\frac{1}{x}}{1 + \color{blue}{{z}^{2}}}}{y} \]
      12. +-commutativeN/A

        \[\leadsto \frac{\frac{\frac{1}{x}}{\color{blue}{{z}^{2} + 1}}}{y} \]
      13. pow2N/A

        \[\leadsto \frac{\frac{\frac{1}{x}}{\color{blue}{z \cdot z} + 1}}{y} \]
      14. lower-fma.f6498.1

        \[\leadsto \frac{\frac{\frac{1}{x}}{\color{blue}{\mathsf{fma}\left(z, z, 1\right)}}}{y} \]
    3. Applied rewrites98.1%

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

    if 9.4000000000000001e114 < z

    1. Initial program 74.5%

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

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{x}}{\color{blue}{y} + y \cdot {z}^{2}} \]
      7. +-commutativeN/A

        \[\leadsto \frac{\frac{1}{x}}{\color{blue}{y \cdot {z}^{2} + y}} \]
      8. pow2N/A

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

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

        \[\leadsto \frac{\frac{1}{x}}{\color{blue}{\mathsf{fma}\left(y \cdot z, z, y\right)}} \]
      11. lower-*.f6487.4

        \[\leadsto \frac{\frac{1}{x}}{\mathsf{fma}\left(\color{blue}{y \cdot z}, z, y\right)} \]
    3. Applied rewrites87.4%

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

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

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

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

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

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

        \[\leadsto \frac{1}{\left({z}^{2} \cdot y\right) \cdot x} \]
      6. pow2N/A

        \[\leadsto \frac{1}{\left(\left(z \cdot z\right) \cdot y\right) \cdot x} \]
      7. lift-*.f6474.4

        \[\leadsto \frac{1}{\left(\left(z \cdot z\right) \cdot y\right) \cdot x} \]
    6. Applied rewrites74.4%

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

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

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

        \[\leadsto \frac{1}{\left(\left(z \cdot z\right) \cdot y\right) \cdot x} \]
      4. associate-*l*N/A

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

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

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

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

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

        \[\leadsto \frac{1}{\left(y \cdot z\right) \cdot \left(\color{blue}{z} \cdot x\right)} \]
      10. lower-*.f6496.0

        \[\leadsto \frac{1}{\left(y \cdot z\right) \cdot \left(z \cdot \color{blue}{x}\right)} \]
    8. Applied rewrites96.0%

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{y \cdot z}}{\color{blue}{z \cdot x}} \]
      6. lower-/.f64N/A

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

        \[\leadsto \frac{\frac{1}{y \cdot z}}{\color{blue}{z} \cdot x} \]
      8. *-commutativeN/A

        \[\leadsto \frac{\frac{1}{z \cdot y}}{z \cdot x} \]
      9. lower-*.f64N/A

        \[\leadsto \frac{\frac{1}{z \cdot y}}{z \cdot x} \]
      10. lift-*.f6496.6

        \[\leadsto \frac{\frac{1}{z \cdot y}}{z \cdot \color{blue}{x}} \]
    10. Applied rewrites96.6%

      \[\leadsto \frac{\frac{1}{z \cdot y}}{\color{blue}{z \cdot x}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 2: 96.5% accurate, 0.6× speedup?

\[\begin{array}{l} z_m = \left|z\right| \\ [x, y, z_m] = \mathsf{sort}([x, y, z_m])\\ \\ \begin{array}{l} \mathbf{if}\;y \cdot \left(1 + z\_m \cdot z\_m\right) \leq 2 \cdot 10^{+302}:\\ \;\;\;\;\frac{1}{\left(\mathsf{fma}\left(z\_m, z\_m, 1\right) \cdot y\right) \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\left(\left(z\_m \cdot x\right) \cdot y\right) \cdot z\_m}\\ \end{array} \end{array} \]
z_m = (fabs.f64 z)
NOTE: x, y, and z_m should be sorted in increasing order before calling this function.
(FPCore (x y z_m)
 :precision binary64
 (if (<= (* y (+ 1.0 (* z_m z_m))) 2e+302)
   (/ 1.0 (* (* (fma z_m z_m 1.0) y) x))
   (/ 1.0 (* (* (* z_m x) y) z_m))))
z_m = fabs(z);
assert(x < y && y < z_m);
double code(double x, double y, double z_m) {
	double tmp;
	if ((y * (1.0 + (z_m * z_m))) <= 2e+302) {
		tmp = 1.0 / ((fma(z_m, z_m, 1.0) * y) * x);
	} else {
		tmp = 1.0 / (((z_m * x) * y) * z_m);
	}
	return tmp;
}
z_m = abs(z)
x, y, z_m = sort([x, y, z_m])
function code(x, y, z_m)
	tmp = 0.0
	if (Float64(y * Float64(1.0 + Float64(z_m * z_m))) <= 2e+302)
		tmp = Float64(1.0 / Float64(Float64(fma(z_m, z_m, 1.0) * y) * x));
	else
		tmp = Float64(1.0 / Float64(Float64(Float64(z_m * x) * y) * z_m));
	end
	return tmp
end
z_m = N[Abs[z], $MachinePrecision]
NOTE: x, y, and z_m should be sorted in increasing order before calling this function.
code[x_, y_, z$95$m_] := If[LessEqual[N[(y * N[(1.0 + N[(z$95$m * z$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2e+302], N[(1.0 / N[(N[(N[(z$95$m * z$95$m + 1.0), $MachinePrecision] * y), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(N[(z$95$m * x), $MachinePrecision] * y), $MachinePrecision] * z$95$m), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|
\\
[x, y, z_m] = \mathsf{sort}([x, y, z_m])\\
\\
\begin{array}{l}
\mathbf{if}\;y \cdot \left(1 + z\_m \cdot z\_m\right) \leq 2 \cdot 10^{+302}:\\
\;\;\;\;\frac{1}{\left(\mathsf{fma}\left(z\_m, z\_m, 1\right) \cdot y\right) \cdot x}\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{\left(\left(z\_m \cdot x\right) \cdot y\right) \cdot z\_m}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 y (+.f64 #s(literal 1 binary64) (*.f64 z z))) < 2.0000000000000002e302

    1. Initial program 97.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.0000000000000002e302 < (*.f64 y (+.f64 #s(literal 1 binary64) (*.f64 z z)))

    1. Initial program 70.4%

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

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{x}}{\color{blue}{y} + y \cdot {z}^{2}} \]
      7. +-commutativeN/A

        \[\leadsto \frac{\frac{1}{x}}{\color{blue}{y \cdot {z}^{2} + y}} \]
      8. pow2N/A

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

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

        \[\leadsto \frac{\frac{1}{x}}{\color{blue}{\mathsf{fma}\left(y \cdot z, z, y\right)}} \]
      11. lower-*.f6480.3

        \[\leadsto \frac{\frac{1}{x}}{\mathsf{fma}\left(\color{blue}{y \cdot z}, z, y\right)} \]
    3. Applied rewrites80.3%

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

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

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

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

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

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

        \[\leadsto \frac{1}{\left({z}^{2} \cdot y\right) \cdot x} \]
      6. pow2N/A

        \[\leadsto \frac{1}{\left(\left(z \cdot z\right) \cdot y\right) \cdot x} \]
      7. lift-*.f6468.5

        \[\leadsto \frac{1}{\left(\left(z \cdot z\right) \cdot y\right) \cdot x} \]
    6. Applied rewrites68.5%

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

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

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

        \[\leadsto \frac{1}{\left(\left(z \cdot z\right) \cdot y\right) \cdot x} \]
      4. associate-*l*N/A

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

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

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

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

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

        \[\leadsto \frac{1}{\left(y \cdot z\right) \cdot \left(\color{blue}{z} \cdot x\right)} \]
      10. lower-*.f6492.6

        \[\leadsto \frac{1}{\left(y \cdot z\right) \cdot \left(z \cdot \color{blue}{x}\right)} \]
    8. Applied rewrites92.6%

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\left(\left(z \cdot x\right) \cdot y\right) \cdot z} \]
      8. lift-*.f6495.6

        \[\leadsto \frac{1}{\left(\left(z \cdot x\right) \cdot y\right) \cdot z} \]
    10. Applied rewrites95.6%

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

Alternative 3: 96.5% accurate, 1.0× speedup?

\[\begin{array}{l} z_m = \left|z\right| \\ [x, y, z_m] = \mathsf{sort}([x, y, z_m])\\ \\ \begin{array}{l} \mathbf{if}\;z\_m \leq 0.86:\\ \;\;\;\;\frac{\frac{1 - z\_m \cdot z\_m}{y}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\left(\left(z\_m \cdot x\right) \cdot z\_m\right) \cdot y}\\ \end{array} \end{array} \]
z_m = (fabs.f64 z)
NOTE: x, y, and z_m should be sorted in increasing order before calling this function.
(FPCore (x y z_m)
 :precision binary64
 (if (<= z_m 0.86)
   (/ (/ (- 1.0 (* z_m z_m)) y) x)
   (/ 1.0 (* (* (* z_m x) z_m) y))))
z_m = fabs(z);
assert(x < y && y < z_m);
double code(double x, double y, double z_m) {
	double tmp;
	if (z_m <= 0.86) {
		tmp = ((1.0 - (z_m * z_m)) / y) / x;
	} else {
		tmp = 1.0 / (((z_m * x) * z_m) * y);
	}
	return tmp;
}
z_m =     private
NOTE: x, y, and z_m should be sorted in increasing order before calling this function.
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_m)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z_m
    real(8) :: tmp
    if (z_m <= 0.86d0) then
        tmp = ((1.0d0 - (z_m * z_m)) / y) / x
    else
        tmp = 1.0d0 / (((z_m * x) * z_m) * y)
    end if
    code = tmp
end function
z_m = Math.abs(z);
assert x < y && y < z_m;
public static double code(double x, double y, double z_m) {
	double tmp;
	if (z_m <= 0.86) {
		tmp = ((1.0 - (z_m * z_m)) / y) / x;
	} else {
		tmp = 1.0 / (((z_m * x) * z_m) * y);
	}
	return tmp;
}
z_m = math.fabs(z)
[x, y, z_m] = sort([x, y, z_m])
def code(x, y, z_m):
	tmp = 0
	if z_m <= 0.86:
		tmp = ((1.0 - (z_m * z_m)) / y) / x
	else:
		tmp = 1.0 / (((z_m * x) * z_m) * y)
	return tmp
z_m = abs(z)
x, y, z_m = sort([x, y, z_m])
function code(x, y, z_m)
	tmp = 0.0
	if (z_m <= 0.86)
		tmp = Float64(Float64(Float64(1.0 - Float64(z_m * z_m)) / y) / x);
	else
		tmp = Float64(1.0 / Float64(Float64(Float64(z_m * x) * z_m) * y));
	end
	return tmp
end
z_m = abs(z);
x, y, z_m = num2cell(sort([x, y, z_m])){:}
function tmp_2 = code(x, y, z_m)
	tmp = 0.0;
	if (z_m <= 0.86)
		tmp = ((1.0 - (z_m * z_m)) / y) / x;
	else
		tmp = 1.0 / (((z_m * x) * z_m) * y);
	end
	tmp_2 = tmp;
end
z_m = N[Abs[z], $MachinePrecision]
NOTE: x, y, and z_m should be sorted in increasing order before calling this function.
code[x_, y_, z$95$m_] := If[LessEqual[z$95$m, 0.86], N[(N[(N[(1.0 - N[(z$95$m * z$95$m), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision] / x), $MachinePrecision], N[(1.0 / N[(N[(N[(z$95$m * x), $MachinePrecision] * z$95$m), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|
\\
[x, y, z_m] = \mathsf{sort}([x, y, z_m])\\
\\
\begin{array}{l}
\mathbf{if}\;z\_m \leq 0.86:\\
\;\;\;\;\frac{\frac{1 - z\_m \cdot z\_m}{y}}{x}\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{\left(\left(z\_m \cdot x\right) \cdot z\_m\right) \cdot y}\\


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

    1. Initial program 99.7%

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

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

        \[\leadsto \frac{1}{x \cdot y} + \color{blue}{-1 \cdot \frac{{z}^{2}}{x \cdot y}} \]
      2. associate-*r/N/A

        \[\leadsto \frac{1}{x \cdot y} + \frac{-1 \cdot {z}^{2}}{\color{blue}{x \cdot y}} \]
      3. div-add-revN/A

        \[\leadsto \frac{1 + -1 \cdot {z}^{2}}{\color{blue}{x \cdot y}} \]
      4. mul-1-negN/A

        \[\leadsto \frac{1 + \left(\mathsf{neg}\left({z}^{2}\right)\right)}{x \cdot y} \]
      5. pow2N/A

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

        \[\leadsto \frac{1 + \left(\mathsf{neg}\left(z\right)\right) \cdot z}{x \cdot y} \]
      7. fp-cancel-sub-sign-invN/A

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

        \[\leadsto \frac{1 - {z}^{2}}{x \cdot y} \]
      9. lower-/.f64N/A

        \[\leadsto \frac{1 - {z}^{2}}{\color{blue}{x \cdot y}} \]
      10. lower--.f64N/A

        \[\leadsto \frac{1 - {z}^{2}}{\color{blue}{x} \cdot y} \]
      11. pow2N/A

        \[\leadsto \frac{1 - z \cdot z}{x \cdot y} \]
      12. lift-*.f64N/A

        \[\leadsto \frac{1 - z \cdot z}{x \cdot y} \]
      13. *-commutativeN/A

        \[\leadsto \frac{1 - z \cdot z}{y \cdot \color{blue}{x}} \]
      14. lower-*.f6498.8

        \[\leadsto \frac{1 - z \cdot z}{y \cdot \color{blue}{x}} \]
    4. Applied rewrites98.8%

      \[\leadsto \color{blue}{\frac{1 - z \cdot z}{y \cdot x}} \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{1 - z \cdot z}{y \cdot \color{blue}{x}} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{1 - z \cdot z}{\color{blue}{y \cdot x}} \]
      3. lift-*.f64N/A

        \[\leadsto \frac{1 - z \cdot z}{y \cdot x} \]
      4. lift--.f64N/A

        \[\leadsto \frac{1 - z \cdot z}{\color{blue}{y} \cdot x} \]
      5. associate-/r*N/A

        \[\leadsto \frac{\frac{1 - z \cdot z}{y}}{\color{blue}{x}} \]
      6. lower-/.f64N/A

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

        \[\leadsto \frac{\frac{1 - z \cdot z}{y}}{x} \]
      8. lift--.f64N/A

        \[\leadsto \frac{\frac{1 - z \cdot z}{y}}{x} \]
      9. lift-*.f6499.3

        \[\leadsto \frac{\frac{1 - z \cdot z}{y}}{x} \]
    6. Applied rewrites99.3%

      \[\leadsto \frac{\frac{1 - z \cdot z}{y}}{\color{blue}{x}} \]

    if 0.859999999999999987 < z

    1. Initial program 81.2%

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

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{x}}{\color{blue}{y} + y \cdot {z}^{2}} \]
      7. +-commutativeN/A

        \[\leadsto \frac{\frac{1}{x}}{\color{blue}{y \cdot {z}^{2} + y}} \]
      8. pow2N/A

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

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

        \[\leadsto \frac{\frac{1}{x}}{\color{blue}{\mathsf{fma}\left(y \cdot z, z, y\right)}} \]
      11. lower-*.f6489.3

        \[\leadsto \frac{\frac{1}{x}}{\mathsf{fma}\left(\color{blue}{y \cdot z}, z, y\right)} \]
    3. Applied rewrites89.3%

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

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

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

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

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

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

        \[\leadsto \frac{1}{\left({z}^{2} \cdot y\right) \cdot x} \]
      6. pow2N/A

        \[\leadsto \frac{1}{\left(\left(z \cdot z\right) \cdot y\right) \cdot x} \]
      7. lift-*.f6480.0

        \[\leadsto \frac{1}{\left(\left(z \cdot z\right) \cdot y\right) \cdot x} \]
    6. Applied rewrites80.0%

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

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

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

        \[\leadsto \frac{1}{\left(\left(z \cdot z\right) \cdot y\right) \cdot x} \]
      4. associate-*l*N/A

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

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

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

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

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

        \[\leadsto \frac{1}{\left(y \cdot z\right) \cdot \left(\color{blue}{z} \cdot x\right)} \]
      10. lower-*.f6493.9

        \[\leadsto \frac{1}{\left(y \cdot z\right) \cdot \left(z \cdot \color{blue}{x}\right)} \]
    8. Applied rewrites93.9%

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\left(\left(z \cdot x\right) \cdot z\right) \cdot y} \]
      8. lower-*.f64N/A

        \[\leadsto \frac{1}{\left(\left(z \cdot x\right) \cdot z\right) \cdot y} \]
      9. lift-*.f6487.8

        \[\leadsto \frac{1}{\left(\left(z \cdot x\right) \cdot z\right) \cdot y} \]
    10. Applied rewrites87.8%

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

Alternative 4: 96.3% accurate, 1.0× speedup?

\[\begin{array}{l} z_m = \left|z\right| \\ [x, y, z_m] = \mathsf{sort}([x, y, z_m])\\ \\ \begin{array}{l} \mathbf{if}\;z\_m \leq 0.86:\\ \;\;\;\;\frac{1 - z\_m \cdot z\_m}{y \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\left(\left(z\_m \cdot x\right) \cdot z\_m\right) \cdot y}\\ \end{array} \end{array} \]
z_m = (fabs.f64 z)
NOTE: x, y, and z_m should be sorted in increasing order before calling this function.
(FPCore (x y z_m)
 :precision binary64
 (if (<= z_m 0.86)
   (/ (- 1.0 (* z_m z_m)) (* y x))
   (/ 1.0 (* (* (* z_m x) z_m) y))))
z_m = fabs(z);
assert(x < y && y < z_m);
double code(double x, double y, double z_m) {
	double tmp;
	if (z_m <= 0.86) {
		tmp = (1.0 - (z_m * z_m)) / (y * x);
	} else {
		tmp = 1.0 / (((z_m * x) * z_m) * y);
	}
	return tmp;
}
z_m =     private
NOTE: x, y, and z_m should be sorted in increasing order before calling this function.
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_m)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z_m
    real(8) :: tmp
    if (z_m <= 0.86d0) then
        tmp = (1.0d0 - (z_m * z_m)) / (y * x)
    else
        tmp = 1.0d0 / (((z_m * x) * z_m) * y)
    end if
    code = tmp
end function
z_m = Math.abs(z);
assert x < y && y < z_m;
public static double code(double x, double y, double z_m) {
	double tmp;
	if (z_m <= 0.86) {
		tmp = (1.0 - (z_m * z_m)) / (y * x);
	} else {
		tmp = 1.0 / (((z_m * x) * z_m) * y);
	}
	return tmp;
}
z_m = math.fabs(z)
[x, y, z_m] = sort([x, y, z_m])
def code(x, y, z_m):
	tmp = 0
	if z_m <= 0.86:
		tmp = (1.0 - (z_m * z_m)) / (y * x)
	else:
		tmp = 1.0 / (((z_m * x) * z_m) * y)
	return tmp
z_m = abs(z)
x, y, z_m = sort([x, y, z_m])
function code(x, y, z_m)
	tmp = 0.0
	if (z_m <= 0.86)
		tmp = Float64(Float64(1.0 - Float64(z_m * z_m)) / Float64(y * x));
	else
		tmp = Float64(1.0 / Float64(Float64(Float64(z_m * x) * z_m) * y));
	end
	return tmp
end
z_m = abs(z);
x, y, z_m = num2cell(sort([x, y, z_m])){:}
function tmp_2 = code(x, y, z_m)
	tmp = 0.0;
	if (z_m <= 0.86)
		tmp = (1.0 - (z_m * z_m)) / (y * x);
	else
		tmp = 1.0 / (((z_m * x) * z_m) * y);
	end
	tmp_2 = tmp;
end
z_m = N[Abs[z], $MachinePrecision]
NOTE: x, y, and z_m should be sorted in increasing order before calling this function.
code[x_, y_, z$95$m_] := If[LessEqual[z$95$m, 0.86], N[(N[(1.0 - N[(z$95$m * z$95$m), $MachinePrecision]), $MachinePrecision] / N[(y * x), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(N[(z$95$m * x), $MachinePrecision] * z$95$m), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|
\\
[x, y, z_m] = \mathsf{sort}([x, y, z_m])\\
\\
\begin{array}{l}
\mathbf{if}\;z\_m \leq 0.86:\\
\;\;\;\;\frac{1 - z\_m \cdot z\_m}{y \cdot x}\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{\left(\left(z\_m \cdot x\right) \cdot z\_m\right) \cdot y}\\


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

    1. Initial program 99.7%

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

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

        \[\leadsto \frac{1}{x \cdot y} + \color{blue}{-1 \cdot \frac{{z}^{2}}{x \cdot y}} \]
      2. associate-*r/N/A

        \[\leadsto \frac{1}{x \cdot y} + \frac{-1 \cdot {z}^{2}}{\color{blue}{x \cdot y}} \]
      3. div-add-revN/A

        \[\leadsto \frac{1 + -1 \cdot {z}^{2}}{\color{blue}{x \cdot y}} \]
      4. mul-1-negN/A

        \[\leadsto \frac{1 + \left(\mathsf{neg}\left({z}^{2}\right)\right)}{x \cdot y} \]
      5. pow2N/A

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

        \[\leadsto \frac{1 + \left(\mathsf{neg}\left(z\right)\right) \cdot z}{x \cdot y} \]
      7. fp-cancel-sub-sign-invN/A

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

        \[\leadsto \frac{1 - {z}^{2}}{x \cdot y} \]
      9. lower-/.f64N/A

        \[\leadsto \frac{1 - {z}^{2}}{\color{blue}{x \cdot y}} \]
      10. lower--.f64N/A

        \[\leadsto \frac{1 - {z}^{2}}{\color{blue}{x} \cdot y} \]
      11. pow2N/A

        \[\leadsto \frac{1 - z \cdot z}{x \cdot y} \]
      12. lift-*.f64N/A

        \[\leadsto \frac{1 - z \cdot z}{x \cdot y} \]
      13. *-commutativeN/A

        \[\leadsto \frac{1 - z \cdot z}{y \cdot \color{blue}{x}} \]
      14. lower-*.f6498.8

        \[\leadsto \frac{1 - z \cdot z}{y \cdot \color{blue}{x}} \]
    4. Applied rewrites98.8%

      \[\leadsto \color{blue}{\frac{1 - z \cdot z}{y \cdot x}} \]

    if 0.859999999999999987 < z

    1. Initial program 81.2%

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

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{x}}{\color{blue}{y} + y \cdot {z}^{2}} \]
      7. +-commutativeN/A

        \[\leadsto \frac{\frac{1}{x}}{\color{blue}{y \cdot {z}^{2} + y}} \]
      8. pow2N/A

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

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

        \[\leadsto \frac{\frac{1}{x}}{\color{blue}{\mathsf{fma}\left(y \cdot z, z, y\right)}} \]
      11. lower-*.f6489.3

        \[\leadsto \frac{\frac{1}{x}}{\mathsf{fma}\left(\color{blue}{y \cdot z}, z, y\right)} \]
    3. Applied rewrites89.3%

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

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

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

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

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

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

        \[\leadsto \frac{1}{\left({z}^{2} \cdot y\right) \cdot x} \]
      6. pow2N/A

        \[\leadsto \frac{1}{\left(\left(z \cdot z\right) \cdot y\right) \cdot x} \]
      7. lift-*.f6480.0

        \[\leadsto \frac{1}{\left(\left(z \cdot z\right) \cdot y\right) \cdot x} \]
    6. Applied rewrites80.0%

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

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

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

        \[\leadsto \frac{1}{\left(\left(z \cdot z\right) \cdot y\right) \cdot x} \]
      4. associate-*l*N/A

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

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

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

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

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

        \[\leadsto \frac{1}{\left(y \cdot z\right) \cdot \left(\color{blue}{z} \cdot x\right)} \]
      10. lower-*.f6493.9

        \[\leadsto \frac{1}{\left(y \cdot z\right) \cdot \left(z \cdot \color{blue}{x}\right)} \]
    8. Applied rewrites93.9%

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\left(\left(z \cdot x\right) \cdot z\right) \cdot y} \]
      8. lower-*.f64N/A

        \[\leadsto \frac{1}{\left(\left(z \cdot x\right) \cdot z\right) \cdot y} \]
      9. lift-*.f6487.8

        \[\leadsto \frac{1}{\left(\left(z \cdot x\right) \cdot z\right) \cdot y} \]
    10. Applied rewrites87.8%

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

Alternative 5: 93.5% accurate, 1.0× speedup?

\[\begin{array}{l} z_m = \left|z\right| \\ [x, y, z_m] = \mathsf{sort}([x, y, z_m])\\ \\ \begin{array}{l} \mathbf{if}\;z\_m \leq 0.86:\\ \;\;\;\;\frac{1 - z\_m \cdot z\_m}{y \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\left(\left(z\_m \cdot x\right) \cdot y\right) \cdot z\_m}\\ \end{array} \end{array} \]
z_m = (fabs.f64 z)
NOTE: x, y, and z_m should be sorted in increasing order before calling this function.
(FPCore (x y z_m)
 :precision binary64
 (if (<= z_m 0.86)
   (/ (- 1.0 (* z_m z_m)) (* y x))
   (/ 1.0 (* (* (* z_m x) y) z_m))))
z_m = fabs(z);
assert(x < y && y < z_m);
double code(double x, double y, double z_m) {
	double tmp;
	if (z_m <= 0.86) {
		tmp = (1.0 - (z_m * z_m)) / (y * x);
	} else {
		tmp = 1.0 / (((z_m * x) * y) * z_m);
	}
	return tmp;
}
z_m =     private
NOTE: x, y, and z_m should be sorted in increasing order before calling this function.
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_m)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z_m
    real(8) :: tmp
    if (z_m <= 0.86d0) then
        tmp = (1.0d0 - (z_m * z_m)) / (y * x)
    else
        tmp = 1.0d0 / (((z_m * x) * y) * z_m)
    end if
    code = tmp
end function
z_m = Math.abs(z);
assert x < y && y < z_m;
public static double code(double x, double y, double z_m) {
	double tmp;
	if (z_m <= 0.86) {
		tmp = (1.0 - (z_m * z_m)) / (y * x);
	} else {
		tmp = 1.0 / (((z_m * x) * y) * z_m);
	}
	return tmp;
}
z_m = math.fabs(z)
[x, y, z_m] = sort([x, y, z_m])
def code(x, y, z_m):
	tmp = 0
	if z_m <= 0.86:
		tmp = (1.0 - (z_m * z_m)) / (y * x)
	else:
		tmp = 1.0 / (((z_m * x) * y) * z_m)
	return tmp
z_m = abs(z)
x, y, z_m = sort([x, y, z_m])
function code(x, y, z_m)
	tmp = 0.0
	if (z_m <= 0.86)
		tmp = Float64(Float64(1.0 - Float64(z_m * z_m)) / Float64(y * x));
	else
		tmp = Float64(1.0 / Float64(Float64(Float64(z_m * x) * y) * z_m));
	end
	return tmp
end
z_m = abs(z);
x, y, z_m = num2cell(sort([x, y, z_m])){:}
function tmp_2 = code(x, y, z_m)
	tmp = 0.0;
	if (z_m <= 0.86)
		tmp = (1.0 - (z_m * z_m)) / (y * x);
	else
		tmp = 1.0 / (((z_m * x) * y) * z_m);
	end
	tmp_2 = tmp;
end
z_m = N[Abs[z], $MachinePrecision]
NOTE: x, y, and z_m should be sorted in increasing order before calling this function.
code[x_, y_, z$95$m_] := If[LessEqual[z$95$m, 0.86], N[(N[(1.0 - N[(z$95$m * z$95$m), $MachinePrecision]), $MachinePrecision] / N[(y * x), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(N[(z$95$m * x), $MachinePrecision] * y), $MachinePrecision] * z$95$m), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|
\\
[x, y, z_m] = \mathsf{sort}([x, y, z_m])\\
\\
\begin{array}{l}
\mathbf{if}\;z\_m \leq 0.86:\\
\;\;\;\;\frac{1 - z\_m \cdot z\_m}{y \cdot x}\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{\left(\left(z\_m \cdot x\right) \cdot y\right) \cdot z\_m}\\


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

    1. Initial program 99.7%

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

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

        \[\leadsto \frac{1}{x \cdot y} + \color{blue}{-1 \cdot \frac{{z}^{2}}{x \cdot y}} \]
      2. associate-*r/N/A

        \[\leadsto \frac{1}{x \cdot y} + \frac{-1 \cdot {z}^{2}}{\color{blue}{x \cdot y}} \]
      3. div-add-revN/A

        \[\leadsto \frac{1 + -1 \cdot {z}^{2}}{\color{blue}{x \cdot y}} \]
      4. mul-1-negN/A

        \[\leadsto \frac{1 + \left(\mathsf{neg}\left({z}^{2}\right)\right)}{x \cdot y} \]
      5. pow2N/A

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

        \[\leadsto \frac{1 + \left(\mathsf{neg}\left(z\right)\right) \cdot z}{x \cdot y} \]
      7. fp-cancel-sub-sign-invN/A

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

        \[\leadsto \frac{1 - {z}^{2}}{x \cdot y} \]
      9. lower-/.f64N/A

        \[\leadsto \frac{1 - {z}^{2}}{\color{blue}{x \cdot y}} \]
      10. lower--.f64N/A

        \[\leadsto \frac{1 - {z}^{2}}{\color{blue}{x} \cdot y} \]
      11. pow2N/A

        \[\leadsto \frac{1 - z \cdot z}{x \cdot y} \]
      12. lift-*.f64N/A

        \[\leadsto \frac{1 - z \cdot z}{x \cdot y} \]
      13. *-commutativeN/A

        \[\leadsto \frac{1 - z \cdot z}{y \cdot \color{blue}{x}} \]
      14. lower-*.f6498.8

        \[\leadsto \frac{1 - z \cdot z}{y \cdot \color{blue}{x}} \]
    4. Applied rewrites98.8%

      \[\leadsto \color{blue}{\frac{1 - z \cdot z}{y \cdot x}} \]

    if 0.859999999999999987 < z

    1. Initial program 81.2%

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

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{x}}{\color{blue}{y} + y \cdot {z}^{2}} \]
      7. +-commutativeN/A

        \[\leadsto \frac{\frac{1}{x}}{\color{blue}{y \cdot {z}^{2} + y}} \]
      8. pow2N/A

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

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

        \[\leadsto \frac{\frac{1}{x}}{\color{blue}{\mathsf{fma}\left(y \cdot z, z, y\right)}} \]
      11. lower-*.f6489.3

        \[\leadsto \frac{\frac{1}{x}}{\mathsf{fma}\left(\color{blue}{y \cdot z}, z, y\right)} \]
    3. Applied rewrites89.3%

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

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

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

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

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

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

        \[\leadsto \frac{1}{\left({z}^{2} \cdot y\right) \cdot x} \]
      6. pow2N/A

        \[\leadsto \frac{1}{\left(\left(z \cdot z\right) \cdot y\right) \cdot x} \]
      7. lift-*.f6480.0

        \[\leadsto \frac{1}{\left(\left(z \cdot z\right) \cdot y\right) \cdot x} \]
    6. Applied rewrites80.0%

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

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

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

        \[\leadsto \frac{1}{\left(\left(z \cdot z\right) \cdot y\right) \cdot x} \]
      4. associate-*l*N/A

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

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

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

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

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

        \[\leadsto \frac{1}{\left(y \cdot z\right) \cdot \left(\color{blue}{z} \cdot x\right)} \]
      10. lower-*.f6493.9

        \[\leadsto \frac{1}{\left(y \cdot z\right) \cdot \left(z \cdot \color{blue}{x}\right)} \]
    8. Applied rewrites93.9%

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\left(\left(z \cdot x\right) \cdot y\right) \cdot z} \]
      8. lift-*.f6494.3

        \[\leadsto \frac{1}{\left(\left(z \cdot x\right) \cdot y\right) \cdot z} \]
    10. Applied rewrites94.3%

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

Alternative 6: 93.2% accurate, 1.0× speedup?

\[\begin{array}{l} z_m = \left|z\right| \\ [x, y, z_m] = \mathsf{sort}([x, y, z_m])\\ \\ \begin{array}{l} \mathbf{if}\;z\_m \leq 0.86:\\ \;\;\;\;\frac{1 - z\_m \cdot z\_m}{y \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\left(y \cdot z\_m\right) \cdot \left(z\_m \cdot x\right)}\\ \end{array} \end{array} \]
z_m = (fabs.f64 z)
NOTE: x, y, and z_m should be sorted in increasing order before calling this function.
(FPCore (x y z_m)
 :precision binary64
 (if (<= z_m 0.86)
   (/ (- 1.0 (* z_m z_m)) (* y x))
   (/ 1.0 (* (* y z_m) (* z_m x)))))
z_m = fabs(z);
assert(x < y && y < z_m);
double code(double x, double y, double z_m) {
	double tmp;
	if (z_m <= 0.86) {
		tmp = (1.0 - (z_m * z_m)) / (y * x);
	} else {
		tmp = 1.0 / ((y * z_m) * (z_m * x));
	}
	return tmp;
}
z_m =     private
NOTE: x, y, and z_m should be sorted in increasing order before calling this function.
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_m)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z_m
    real(8) :: tmp
    if (z_m <= 0.86d0) then
        tmp = (1.0d0 - (z_m * z_m)) / (y * x)
    else
        tmp = 1.0d0 / ((y * z_m) * (z_m * x))
    end if
    code = tmp
end function
z_m = Math.abs(z);
assert x < y && y < z_m;
public static double code(double x, double y, double z_m) {
	double tmp;
	if (z_m <= 0.86) {
		tmp = (1.0 - (z_m * z_m)) / (y * x);
	} else {
		tmp = 1.0 / ((y * z_m) * (z_m * x));
	}
	return tmp;
}
z_m = math.fabs(z)
[x, y, z_m] = sort([x, y, z_m])
def code(x, y, z_m):
	tmp = 0
	if z_m <= 0.86:
		tmp = (1.0 - (z_m * z_m)) / (y * x)
	else:
		tmp = 1.0 / ((y * z_m) * (z_m * x))
	return tmp
z_m = abs(z)
x, y, z_m = sort([x, y, z_m])
function code(x, y, z_m)
	tmp = 0.0
	if (z_m <= 0.86)
		tmp = Float64(Float64(1.0 - Float64(z_m * z_m)) / Float64(y * x));
	else
		tmp = Float64(1.0 / Float64(Float64(y * z_m) * Float64(z_m * x)));
	end
	return tmp
end
z_m = abs(z);
x, y, z_m = num2cell(sort([x, y, z_m])){:}
function tmp_2 = code(x, y, z_m)
	tmp = 0.0;
	if (z_m <= 0.86)
		tmp = (1.0 - (z_m * z_m)) / (y * x);
	else
		tmp = 1.0 / ((y * z_m) * (z_m * x));
	end
	tmp_2 = tmp;
end
z_m = N[Abs[z], $MachinePrecision]
NOTE: x, y, and z_m should be sorted in increasing order before calling this function.
code[x_, y_, z$95$m_] := If[LessEqual[z$95$m, 0.86], N[(N[(1.0 - N[(z$95$m * z$95$m), $MachinePrecision]), $MachinePrecision] / N[(y * x), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(y * z$95$m), $MachinePrecision] * N[(z$95$m * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|
\\
[x, y, z_m] = \mathsf{sort}([x, y, z_m])\\
\\
\begin{array}{l}
\mathbf{if}\;z\_m \leq 0.86:\\
\;\;\;\;\frac{1 - z\_m \cdot z\_m}{y \cdot x}\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{\left(y \cdot z\_m\right) \cdot \left(z\_m \cdot x\right)}\\


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

    1. Initial program 99.7%

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

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

        \[\leadsto \frac{1}{x \cdot y} + \color{blue}{-1 \cdot \frac{{z}^{2}}{x \cdot y}} \]
      2. associate-*r/N/A

        \[\leadsto \frac{1}{x \cdot y} + \frac{-1 \cdot {z}^{2}}{\color{blue}{x \cdot y}} \]
      3. div-add-revN/A

        \[\leadsto \frac{1 + -1 \cdot {z}^{2}}{\color{blue}{x \cdot y}} \]
      4. mul-1-negN/A

        \[\leadsto \frac{1 + \left(\mathsf{neg}\left({z}^{2}\right)\right)}{x \cdot y} \]
      5. pow2N/A

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

        \[\leadsto \frac{1 + \left(\mathsf{neg}\left(z\right)\right) \cdot z}{x \cdot y} \]
      7. fp-cancel-sub-sign-invN/A

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

        \[\leadsto \frac{1 - {z}^{2}}{x \cdot y} \]
      9. lower-/.f64N/A

        \[\leadsto \frac{1 - {z}^{2}}{\color{blue}{x \cdot y}} \]
      10. lower--.f64N/A

        \[\leadsto \frac{1 - {z}^{2}}{\color{blue}{x} \cdot y} \]
      11. pow2N/A

        \[\leadsto \frac{1 - z \cdot z}{x \cdot y} \]
      12. lift-*.f64N/A

        \[\leadsto \frac{1 - z \cdot z}{x \cdot y} \]
      13. *-commutativeN/A

        \[\leadsto \frac{1 - z \cdot z}{y \cdot \color{blue}{x}} \]
      14. lower-*.f6498.8

        \[\leadsto \frac{1 - z \cdot z}{y \cdot \color{blue}{x}} \]
    4. Applied rewrites98.8%

      \[\leadsto \color{blue}{\frac{1 - z \cdot z}{y \cdot x}} \]

    if 0.859999999999999987 < z

    1. Initial program 81.2%

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

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{x}}{\color{blue}{y} + y \cdot {z}^{2}} \]
      7. +-commutativeN/A

        \[\leadsto \frac{\frac{1}{x}}{\color{blue}{y \cdot {z}^{2} + y}} \]
      8. pow2N/A

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

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

        \[\leadsto \frac{\frac{1}{x}}{\color{blue}{\mathsf{fma}\left(y \cdot z, z, y\right)}} \]
      11. lower-*.f6489.3

        \[\leadsto \frac{\frac{1}{x}}{\mathsf{fma}\left(\color{blue}{y \cdot z}, z, y\right)} \]
    3. Applied rewrites89.3%

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

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

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

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

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

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

        \[\leadsto \frac{1}{\left({z}^{2} \cdot y\right) \cdot x} \]
      6. pow2N/A

        \[\leadsto \frac{1}{\left(\left(z \cdot z\right) \cdot y\right) \cdot x} \]
      7. lift-*.f6480.0

        \[\leadsto \frac{1}{\left(\left(z \cdot z\right) \cdot y\right) \cdot x} \]
    6. Applied rewrites80.0%

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

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

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

        \[\leadsto \frac{1}{\left(\left(z \cdot z\right) \cdot y\right) \cdot x} \]
      4. associate-*l*N/A

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

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

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

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

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

        \[\leadsto \frac{1}{\left(y \cdot z\right) \cdot \left(\color{blue}{z} \cdot x\right)} \]
      10. lower-*.f6493.9

        \[\leadsto \frac{1}{\left(y \cdot z\right) \cdot \left(z \cdot \color{blue}{x}\right)} \]
    8. Applied rewrites93.9%

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

Alternative 7: 89.3% accurate, 1.0× speedup?

\[\begin{array}{l} z_m = \left|z\right| \\ [x, y, z_m] = \mathsf{sort}([x, y, z_m])\\ \\ \begin{array}{l} \mathbf{if}\;z\_m \leq 0.86:\\ \;\;\;\;\frac{1 - z\_m \cdot z\_m}{y \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\left(\left(z\_m \cdot z\_m\right) \cdot y\right) \cdot x}\\ \end{array} \end{array} \]
z_m = (fabs.f64 z)
NOTE: x, y, and z_m should be sorted in increasing order before calling this function.
(FPCore (x y z_m)
 :precision binary64
 (if (<= z_m 0.86)
   (/ (- 1.0 (* z_m z_m)) (* y x))
   (/ 1.0 (* (* (* z_m z_m) y) x))))
z_m = fabs(z);
assert(x < y && y < z_m);
double code(double x, double y, double z_m) {
	double tmp;
	if (z_m <= 0.86) {
		tmp = (1.0 - (z_m * z_m)) / (y * x);
	} else {
		tmp = 1.0 / (((z_m * z_m) * y) * x);
	}
	return tmp;
}
z_m =     private
NOTE: x, y, and z_m should be sorted in increasing order before calling this function.
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_m)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z_m
    real(8) :: tmp
    if (z_m <= 0.86d0) then
        tmp = (1.0d0 - (z_m * z_m)) / (y * x)
    else
        tmp = 1.0d0 / (((z_m * z_m) * y) * x)
    end if
    code = tmp
end function
z_m = Math.abs(z);
assert x < y && y < z_m;
public static double code(double x, double y, double z_m) {
	double tmp;
	if (z_m <= 0.86) {
		tmp = (1.0 - (z_m * z_m)) / (y * x);
	} else {
		tmp = 1.0 / (((z_m * z_m) * y) * x);
	}
	return tmp;
}
z_m = math.fabs(z)
[x, y, z_m] = sort([x, y, z_m])
def code(x, y, z_m):
	tmp = 0
	if z_m <= 0.86:
		tmp = (1.0 - (z_m * z_m)) / (y * x)
	else:
		tmp = 1.0 / (((z_m * z_m) * y) * x)
	return tmp
z_m = abs(z)
x, y, z_m = sort([x, y, z_m])
function code(x, y, z_m)
	tmp = 0.0
	if (z_m <= 0.86)
		tmp = Float64(Float64(1.0 - Float64(z_m * z_m)) / Float64(y * x));
	else
		tmp = Float64(1.0 / Float64(Float64(Float64(z_m * z_m) * y) * x));
	end
	return tmp
end
z_m = abs(z);
x, y, z_m = num2cell(sort([x, y, z_m])){:}
function tmp_2 = code(x, y, z_m)
	tmp = 0.0;
	if (z_m <= 0.86)
		tmp = (1.0 - (z_m * z_m)) / (y * x);
	else
		tmp = 1.0 / (((z_m * z_m) * y) * x);
	end
	tmp_2 = tmp;
end
z_m = N[Abs[z], $MachinePrecision]
NOTE: x, y, and z_m should be sorted in increasing order before calling this function.
code[x_, y_, z$95$m_] := If[LessEqual[z$95$m, 0.86], N[(N[(1.0 - N[(z$95$m * z$95$m), $MachinePrecision]), $MachinePrecision] / N[(y * x), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(N[(z$95$m * z$95$m), $MachinePrecision] * y), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|
\\
[x, y, z_m] = \mathsf{sort}([x, y, z_m])\\
\\
\begin{array}{l}
\mathbf{if}\;z\_m \leq 0.86:\\
\;\;\;\;\frac{1 - z\_m \cdot z\_m}{y \cdot x}\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{\left(\left(z\_m \cdot z\_m\right) \cdot y\right) \cdot x}\\


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

    1. Initial program 99.7%

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

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

        \[\leadsto \frac{1}{x \cdot y} + \color{blue}{-1 \cdot \frac{{z}^{2}}{x \cdot y}} \]
      2. associate-*r/N/A

        \[\leadsto \frac{1}{x \cdot y} + \frac{-1 \cdot {z}^{2}}{\color{blue}{x \cdot y}} \]
      3. div-add-revN/A

        \[\leadsto \frac{1 + -1 \cdot {z}^{2}}{\color{blue}{x \cdot y}} \]
      4. mul-1-negN/A

        \[\leadsto \frac{1 + \left(\mathsf{neg}\left({z}^{2}\right)\right)}{x \cdot y} \]
      5. pow2N/A

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

        \[\leadsto \frac{1 + \left(\mathsf{neg}\left(z\right)\right) \cdot z}{x \cdot y} \]
      7. fp-cancel-sub-sign-invN/A

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

        \[\leadsto \frac{1 - {z}^{2}}{x \cdot y} \]
      9. lower-/.f64N/A

        \[\leadsto \frac{1 - {z}^{2}}{\color{blue}{x \cdot y}} \]
      10. lower--.f64N/A

        \[\leadsto \frac{1 - {z}^{2}}{\color{blue}{x} \cdot y} \]
      11. pow2N/A

        \[\leadsto \frac{1 - z \cdot z}{x \cdot y} \]
      12. lift-*.f64N/A

        \[\leadsto \frac{1 - z \cdot z}{x \cdot y} \]
      13. *-commutativeN/A

        \[\leadsto \frac{1 - z \cdot z}{y \cdot \color{blue}{x}} \]
      14. lower-*.f6498.8

        \[\leadsto \frac{1 - z \cdot z}{y \cdot \color{blue}{x}} \]
    4. Applied rewrites98.8%

      \[\leadsto \color{blue}{\frac{1 - z \cdot z}{y \cdot x}} \]

    if 0.859999999999999987 < z

    1. Initial program 81.2%

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

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

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

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

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

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

        \[\leadsto \frac{1}{\left({z}^{2} \cdot y\right) \cdot x} \]
      6. pow2N/A

        \[\leadsto \frac{1}{\left(\left(z \cdot z\right) \cdot y\right) \cdot x} \]
      7. lift-*.f6480.0

        \[\leadsto \frac{1}{\left(\left(z \cdot z\right) \cdot y\right) \cdot x} \]
    4. Applied rewrites80.0%

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

Alternative 8: 58.1% accurate, 2.2× speedup?

\[\begin{array}{l} z_m = \left|z\right| \\ [x, y, z_m] = \mathsf{sort}([x, y, z_m])\\ \\ \frac{1}{y \cdot x} \end{array} \]
z_m = (fabs.f64 z)
NOTE: x, y, and z_m should be sorted in increasing order before calling this function.
(FPCore (x y z_m) :precision binary64 (/ 1.0 (* y x)))
z_m = fabs(z);
assert(x < y && y < z_m);
double code(double x, double y, double z_m) {
	return 1.0 / (y * x);
}
z_m =     private
NOTE: x, y, and z_m should be sorted in increasing order before calling this function.
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_m)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z_m
    code = 1.0d0 / (y * x)
end function
z_m = Math.abs(z);
assert x < y && y < z_m;
public static double code(double x, double y, double z_m) {
	return 1.0 / (y * x);
}
z_m = math.fabs(z)
[x, y, z_m] = sort([x, y, z_m])
def code(x, y, z_m):
	return 1.0 / (y * x)
z_m = abs(z)
x, y, z_m = sort([x, y, z_m])
function code(x, y, z_m)
	return Float64(1.0 / Float64(y * x))
end
z_m = abs(z);
x, y, z_m = num2cell(sort([x, y, z_m])){:}
function tmp = code(x, y, z_m)
	tmp = 1.0 / (y * x);
end
z_m = N[Abs[z], $MachinePrecision]
NOTE: x, y, and z_m should be sorted in increasing order before calling this function.
code[x_, y_, z$95$m_] := N[(1.0 / N[(y * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
z_m = \left|z\right|
\\
[x, y, z_m] = \mathsf{sort}([x, y, z_m])\\
\\
\frac{1}{y \cdot x}
\end{array}
Derivation
  1. Initial program 90.3%

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

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

      \[\leadsto \frac{1}{\color{blue}{x \cdot y}} \]
    2. *-commutativeN/A

      \[\leadsto \frac{1}{y \cdot \color{blue}{x}} \]
    3. lower-*.f6458.1

      \[\leadsto \frac{1}{y \cdot \color{blue}{x}} \]
  4. Applied rewrites58.1%

    \[\leadsto \color{blue}{\frac{1}{y \cdot x}} \]
  5. Add Preprocessing

Reproduce

?
herbie shell --seed 2025120 
(FPCore (x y z)
  :name "Statistics.Distribution.CauchyLorentz:$cdensity from math-functions-0.1.5.2"
  :precision binary64
  (/ (/ 1.0 x) (* y (+ 1.0 (* z z)))))