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

Percentage Accurate: 90.3% → 97.4%
Time: 6.7s
Alternatives: 9
Speedup: 1.1×

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}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 9 alternatives:

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

Initial Program: 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.4% accurate, 1.1× speedup?

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

\\
\frac{1}{\mathsf{fma}\left(\left(x \cdot z\right) \cdot y, z, y \cdot x\right)}
\end{array}
Derivation
  1. Initial program 91.5%

    \[\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)} \]
  2. Add Preprocessing
  3. 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. associate-/l/N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 77.2% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)} \leq 0:\\
\;\;\;\;\frac{1}{\left(\left(x \cdot y\right) \cdot z\right) \cdot z}\\

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


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

    1. Initial program 87.8%

      \[\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)} \]
    2. Add Preprocessing
    3. 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. associate-/l/N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{x \cdot \left(y \cdot {z}^{2}\right)} \]
      2. distribute-rgt-outN/A

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

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

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

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

        \[\leadsto \frac{1}{x \cdot \left(y \cdot {z}^{2}\right)} \]
      7. distribute-lft1-inN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.0 < (/.f64 (/.f64 #s(literal 1 binary64) x) (*.f64 y (+.f64 #s(literal 1 binary64) (*.f64 z z))))

    1. Initial program 99.5%

      \[\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)} \]
    2. Add Preprocessing
    3. 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 \color{blue}{\left(1 + z \cdot z\right)}} \]
      3. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\color{blue}{\left(y \cdot \mathsf{fma}\left(z, z, 1\right)\right) \cdot x}} \]
      16. lift-/.f6498.3

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

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

Alternative 3: 77.2% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)} \leq 2 \cdot 10^{-319}:\\ \;\;\;\;\frac{1}{\left(\left(x \cdot y\right) \cdot z\right) \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\left(y \cdot \mathsf{fma}\left(z, z, 1\right)\right) \cdot x}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= (/ (/ 1.0 x) (* y (+ 1.0 (* z z)))) 2e-319)
   (/ 1.0 (* (* (* x y) z) z))
   (/ 1.0 (* (* y (fma z z 1.0)) x))))
double code(double x, double y, double z) {
	double tmp;
	if (((1.0 / x) / (y * (1.0 + (z * z)))) <= 2e-319) {
		tmp = 1.0 / (((x * y) * z) * z);
	} else {
		tmp = 1.0 / ((y * fma(z, z, 1.0)) * x);
	}
	return tmp;
}
function code(x, y, z)
	tmp = 0.0
	if (Float64(Float64(1.0 / x) / Float64(y * Float64(1.0 + Float64(z * z)))) <= 2e-319)
		tmp = Float64(1.0 / Float64(Float64(Float64(x * y) * z) * z));
	else
		tmp = Float64(1.0 / Float64(Float64(y * fma(z, z, 1.0)) * x));
	end
	return tmp
end
code[x_, y_, z_] := If[LessEqual[N[(N[(1.0 / x), $MachinePrecision] / N[(y * N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2e-319], N[(1.0 / N[(N[(N[(x * y), $MachinePrecision] * z), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(y * N[(z * z + 1.0), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)} \leq 2 \cdot 10^{-319}:\\
\;\;\;\;\frac{1}{\left(\left(x \cdot y\right) \cdot z\right) \cdot z}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (/.f64 #s(literal 1 binary64) x) (*.f64 y (+.f64 #s(literal 1 binary64) (*.f64 z z)))) < 1.99998e-319

    1. Initial program 87.9%

      \[\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)} \]
    2. Add Preprocessing
    3. 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. associate-/l/N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{x \cdot \left(y \cdot {z}^{2}\right)} \]
      2. distribute-rgt-outN/A

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

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

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

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

        \[\leadsto \frac{1}{x \cdot \left(y \cdot {z}^{2}\right)} \]
      7. distribute-lft1-inN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.99998e-319 < (/.f64 (/.f64 #s(literal 1 binary64) x) (*.f64 y (+.f64 #s(literal 1 binary64) (*.f64 z z))))

    1. Initial program 99.5%

      \[\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)} \]
    2. Add Preprocessing
    3. 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. associate-/l/N/A

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

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

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

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

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

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

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

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

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

Alternative 4: 96.0% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq 8.6 \cdot 10^{-100}:\\ \;\;\;\;\frac{1}{\mathsf{fma}\left(z \cdot y, z, y\right) \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{fma}\left(z, z \cdot \left(y \cdot x\right), y \cdot x\right)}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= y 8.6e-100)
   (/ 1.0 (* (fma (* z y) z y) x))
   (/ 1.0 (fma z (* z (* y x)) (* y x)))))
double code(double x, double y, double z) {
	double tmp;
	if (y <= 8.6e-100) {
		tmp = 1.0 / (fma((z * y), z, y) * x);
	} else {
		tmp = 1.0 / fma(z, (z * (y * x)), (y * x));
	}
	return tmp;
}
function code(x, y, z)
	tmp = 0.0
	if (y <= 8.6e-100)
		tmp = Float64(1.0 / Float64(fma(Float64(z * y), z, y) * x));
	else
		tmp = Float64(1.0 / fma(z, Float64(z * Float64(y * x)), Float64(y * x)));
	end
	return tmp
end
code[x_, y_, z_] := If[LessEqual[y, 8.6e-100], N[(1.0 / N[(N[(N[(z * y), $MachinePrecision] * z + y), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(z * N[(z * N[(y * x), $MachinePrecision]), $MachinePrecision] + N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq 8.6 \cdot 10^{-100}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(z \cdot y, z, y\right) \cdot x}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 8.59999999999999997e-100

    1. Initial program 91.9%

      \[\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)} \]
    2. Add Preprocessing
    3. 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 \color{blue}{\left(1 + z \cdot z\right)}} \]
      3. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\color{blue}{\left(y \cdot \mathsf{fma}\left(z, z, 1\right)\right) \cdot x}} \]
      16. lift-/.f6491.5

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

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

    if 8.59999999999999997e-100 < y

    1. Initial program 90.8%

      \[\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)} \]
    2. Add Preprocessing
    3. 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. associate-/l/N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 73.4% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq 0.88:\\ \;\;\;\;\frac{1 - z \cdot z}{x \cdot y}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\left(\left(x \cdot y\right) \cdot z\right) \cdot z}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= z 0.88) (/ (- 1.0 (* z z)) (* x y)) (/ 1.0 (* (* (* x y) z) z))))
double code(double x, double y, double z) {
	double tmp;
	if (z <= 0.88) {
		tmp = (1.0 - (z * z)) / (x * y);
	} else {
		tmp = 1.0 / (((x * y) * z) * z);
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(x, y, z)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (z <= 0.88d0) then
        tmp = (1.0d0 - (z * z)) / (x * y)
    else
        tmp = 1.0d0 / (((x * y) * z) * z)
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (z <= 0.88) {
		tmp = (1.0 - (z * z)) / (x * y);
	} else {
		tmp = 1.0 / (((x * y) * z) * z);
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if z <= 0.88:
		tmp = (1.0 - (z * z)) / (x * y)
	else:
		tmp = 1.0 / (((x * y) * z) * z)
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (z <= 0.88)
		tmp = Float64(Float64(1.0 - Float64(z * z)) / Float64(x * y));
	else
		tmp = Float64(1.0 / Float64(Float64(Float64(x * y) * z) * z));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (z <= 0.88)
		tmp = (1.0 - (z * z)) / (x * y);
	else
		tmp = 1.0 / (((x * y) * z) * z);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[z, 0.88], N[(N[(1.0 - N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(x * y), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(N[(x * y), $MachinePrecision] * z), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq 0.88:\\
\;\;\;\;\frac{1 - z \cdot z}{x \cdot y}\\

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


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

    1. Initial program 95.5%

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

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

        \[\leadsto \frac{\frac{1}{x}}{y \cdot \left(z \cdot \color{blue}{z}\right)} \]
      2. lower-*.f6436.8

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\color{blue}{\left(y \cdot x\right)} \cdot \left(z \cdot z\right)} \]
    7. Applied rewrites42.3%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{z \cdot z}}{\color{blue}{x \cdot y}} \]
    9. Applied rewrites42.3%

      \[\leadsto \color{blue}{\frac{\frac{1}{z \cdot z}}{x \cdot y}} \]
    10. Taylor expanded in z around 0

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1 - z \cdot \color{blue}{z}}{x \cdot y} \]
    12. Applied rewrites72.3%

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

    if 0.880000000000000004 < z

    1. Initial program 79.3%

      \[\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)} \]
    2. Add Preprocessing
    3. 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. associate-/l/N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{x \cdot \left(y \cdot {z}^{2}\right)} \]
      2. distribute-rgt-outN/A

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

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

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

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

        \[\leadsto \frac{1}{x \cdot \left(y \cdot {z}^{2}\right)} \]
      7. distribute-lft1-inN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 71.3% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq 0.88:\\ \;\;\;\;\frac{1 - z \cdot z}{x \cdot y}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\left(\left(z \cdot z\right) \cdot y\right) \cdot x}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= z 0.88) (/ (- 1.0 (* z z)) (* x y)) (/ 1.0 (* (* (* z z) y) x))))
double code(double x, double y, double z) {
	double tmp;
	if (z <= 0.88) {
		tmp = (1.0 - (z * z)) / (x * y);
	} else {
		tmp = 1.0 / (((z * z) * y) * x);
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(x, y, z)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (z <= 0.88d0) then
        tmp = (1.0d0 - (z * z)) / (x * y)
    else
        tmp = 1.0d0 / (((z * z) * y) * x)
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (z <= 0.88) {
		tmp = (1.0 - (z * z)) / (x * y);
	} else {
		tmp = 1.0 / (((z * z) * y) * x);
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if z <= 0.88:
		tmp = (1.0 - (z * z)) / (x * y)
	else:
		tmp = 1.0 / (((z * z) * y) * x)
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (z <= 0.88)
		tmp = Float64(Float64(1.0 - Float64(z * z)) / Float64(x * y));
	else
		tmp = Float64(1.0 / Float64(Float64(Float64(z * z) * y) * x));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (z <= 0.88)
		tmp = (1.0 - (z * z)) / (x * y);
	else
		tmp = 1.0 / (((z * z) * y) * x);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[z, 0.88], N[(N[(1.0 - N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(x * y), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(N[(z * z), $MachinePrecision] * y), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq 0.88:\\
\;\;\;\;\frac{1 - z \cdot z}{x \cdot y}\\

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


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

    1. Initial program 95.5%

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

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

        \[\leadsto \frac{\frac{1}{x}}{y \cdot \left(z \cdot \color{blue}{z}\right)} \]
      2. lower-*.f6436.8

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\color{blue}{\left(y \cdot x\right)} \cdot \left(z \cdot z\right)} \]
    7. Applied rewrites42.3%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{z \cdot z}}{\color{blue}{x \cdot y}} \]
    9. Applied rewrites42.3%

      \[\leadsto \color{blue}{\frac{\frac{1}{z \cdot z}}{x \cdot y}} \]
    10. Taylor expanded in z around 0

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1 - z \cdot \color{blue}{z}}{x \cdot y} \]
    12. Applied rewrites72.3%

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

    if 0.880000000000000004 < z

    1. Initial program 79.3%

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

      \[\leadsto \color{blue}{\frac{1}{x \cdot \left(y \cdot {z}^{2}\right)}} \]
    4. 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. unpow2N/A

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

        \[\leadsto \frac{1}{\left(\left(z \cdot z\right) \cdot y\right) \cdot x} \]
    5. Applied rewrites79.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 7: 97.4% accurate, 1.1× speedup?

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

\\
\frac{1}{\mathsf{fma}\left(z \cdot y, z \cdot x, y \cdot x\right)}
\end{array}
Derivation
  1. Initial program 91.5%

    \[\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)} \]
  2. Add Preprocessing
  3. 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. associate-/l/N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 97.4% accurate, 1.1× speedup?

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

\\
\frac{1}{\mathsf{fma}\left(x \cdot \left(z \cdot y\right), z, y \cdot x\right)}
\end{array}
Derivation
  1. Initial program 91.5%

    \[\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)} \]
  2. Add Preprocessing
  3. 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. associate-/l/N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 58.7% accurate, 2.1× speedup?

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

\\
\frac{1}{y \cdot x}
\end{array}
Derivation
  1. Initial program 91.5%

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

    \[\leadsto \frac{\frac{1}{x}}{\color{blue}{y}} \]
  4. Step-by-step derivation
    1. Applied rewrites59.9%

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

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

        \[\leadsto \frac{\color{blue}{\frac{1}{x}}}{y} \]
      3. associate-/l/N/A

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

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

        \[\leadsto \frac{1}{\color{blue}{y \cdot x}} \]
      6. lower-*.f6460.0

        \[\leadsto \frac{1}{\color{blue}{y \cdot x}} \]
    3. Applied rewrites60.0%

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

    Developer Target 1: 91.3% accurate, 0.5× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := 1 + z \cdot z\\ t_1 := y \cdot t\_0\\ t_2 := \frac{\frac{1}{y}}{t\_0 \cdot x}\\ \mathbf{if}\;t\_1 < -\infty:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;t\_1 < 8.680743250567252 \cdot 10^{+305}:\\ \;\;\;\;\frac{\frac{1}{x}}{t\_0 \cdot y}\\ \mathbf{else}:\\ \;\;\;\;t\_2\\ \end{array} \end{array} \]
    (FPCore (x y z)
     :precision binary64
     (let* ((t_0 (+ 1.0 (* z z))) (t_1 (* y t_0)) (t_2 (/ (/ 1.0 y) (* t_0 x))))
       (if (< t_1 (- INFINITY))
         t_2
         (if (< t_1 8.680743250567252e+305) (/ (/ 1.0 x) (* t_0 y)) t_2))))
    double code(double x, double y, double z) {
    	double t_0 = 1.0 + (z * z);
    	double t_1 = y * t_0;
    	double t_2 = (1.0 / y) / (t_0 * x);
    	double tmp;
    	if (t_1 < -((double) INFINITY)) {
    		tmp = t_2;
    	} else if (t_1 < 8.680743250567252e+305) {
    		tmp = (1.0 / x) / (t_0 * y);
    	} else {
    		tmp = t_2;
    	}
    	return tmp;
    }
    
    public static double code(double x, double y, double z) {
    	double t_0 = 1.0 + (z * z);
    	double t_1 = y * t_0;
    	double t_2 = (1.0 / y) / (t_0 * x);
    	double tmp;
    	if (t_1 < -Double.POSITIVE_INFINITY) {
    		tmp = t_2;
    	} else if (t_1 < 8.680743250567252e+305) {
    		tmp = (1.0 / x) / (t_0 * y);
    	} else {
    		tmp = t_2;
    	}
    	return tmp;
    }
    
    def code(x, y, z):
    	t_0 = 1.0 + (z * z)
    	t_1 = y * t_0
    	t_2 = (1.0 / y) / (t_0 * x)
    	tmp = 0
    	if t_1 < -math.inf:
    		tmp = t_2
    	elif t_1 < 8.680743250567252e+305:
    		tmp = (1.0 / x) / (t_0 * y)
    	else:
    		tmp = t_2
    	return tmp
    
    function code(x, y, z)
    	t_0 = Float64(1.0 + Float64(z * z))
    	t_1 = Float64(y * t_0)
    	t_2 = Float64(Float64(1.0 / y) / Float64(t_0 * x))
    	tmp = 0.0
    	if (t_1 < Float64(-Inf))
    		tmp = t_2;
    	elseif (t_1 < 8.680743250567252e+305)
    		tmp = Float64(Float64(1.0 / x) / Float64(t_0 * y));
    	else
    		tmp = t_2;
    	end
    	return tmp
    end
    
    function tmp_2 = code(x, y, z)
    	t_0 = 1.0 + (z * z);
    	t_1 = y * t_0;
    	t_2 = (1.0 / y) / (t_0 * x);
    	tmp = 0.0;
    	if (t_1 < -Inf)
    		tmp = t_2;
    	elseif (t_1 < 8.680743250567252e+305)
    		tmp = (1.0 / x) / (t_0 * y);
    	else
    		tmp = t_2;
    	end
    	tmp_2 = tmp;
    end
    
    code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(y * t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(N[(1.0 / y), $MachinePrecision] / N[(t$95$0 * x), $MachinePrecision]), $MachinePrecision]}, If[Less[t$95$1, (-Infinity)], t$95$2, If[Less[t$95$1, 8.680743250567252e+305], N[(N[(1.0 / x), $MachinePrecision] / N[(t$95$0 * y), $MachinePrecision]), $MachinePrecision], t$95$2]]]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := 1 + z \cdot z\\
    t_1 := y \cdot t\_0\\
    t_2 := \frac{\frac{1}{y}}{t\_0 \cdot x}\\
    \mathbf{if}\;t\_1 < -\infty:\\
    \;\;\;\;t\_2\\
    
    \mathbf{elif}\;t\_1 < 8.680743250567252 \cdot 10^{+305}:\\
    \;\;\;\;\frac{\frac{1}{x}}{t\_0 \cdot y}\\
    
    \mathbf{else}:\\
    \;\;\;\;t\_2\\
    
    
    \end{array}
    \end{array}
    

    Reproduce

    ?
    herbie shell --seed 2025026 
    (FPCore (x y z)
      :name "Statistics.Distribution.CauchyLorentz:$cdensity from math-functions-0.1.5.2"
      :precision binary64
    
      :alt
      (! :herbie-platform default (if (< (* y (+ 1 (* z z))) -inf.0) (/ (/ 1 y) (* (+ 1 (* z z)) x)) (if (< (* y (+ 1 (* z z))) 868074325056725200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (/ (/ 1 x) (* (+ 1 (* z z)) y)) (/ (/ 1 y) (* (+ 1 (* z z)) x)))))
    
      (/ (/ 1.0 x) (* y (+ 1.0 (* z z)))))