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

Percentage Accurate: 90.0% → 98.6%
Time: 4.9s
Alternatives: 8
Speedup: 0.8×

Specification

?
\[\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)} \]
(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]
\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)}

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.0% accurate, 1.0× speedup?

\[\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)} \]
(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]
\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)}

Alternative 1: 98.6% accurate, 0.4× speedup?

\[\begin{array}{l} t_0 := \mathsf{min}\left(\left|x\right|, \left|y\right|\right)\\ \mathsf{copysign}\left(1, x\right) \cdot \left(\mathsf{copysign}\left(1, y\right) \cdot \frac{\frac{1}{\mathsf{fma}\left(z, z \cdot t\_0, t\_0\right)}}{\mathsf{max}\left(\left|x\right|, \left|y\right|\right)}\right) \end{array} \]
(FPCore (x y z)
  :precision binary64
  (let* ((t_0 (fmin (fabs x) (fabs y))))
  (*
   (copysign 1.0 x)
   (*
    (copysign 1.0 y)
    (/ (/ 1.0 (fma z (* z t_0) t_0)) (fmax (fabs x) (fabs y)))))))
double code(double x, double y, double z) {
	double t_0 = fmin(fabs(x), fabs(y));
	return copysign(1.0, x) * (copysign(1.0, y) * ((1.0 / fma(z, (z * t_0), t_0)) / fmax(fabs(x), fabs(y))));
}
function code(x, y, z)
	t_0 = fmin(abs(x), abs(y))
	return Float64(copysign(1.0, x) * Float64(copysign(1.0, y) * Float64(Float64(1.0 / fma(z, Float64(z * t_0), t_0)) / fmax(abs(x), abs(y)))))
end
code[x_, y_, z_] := Block[{t$95$0 = N[Min[N[Abs[x], $MachinePrecision], N[Abs[y], $MachinePrecision]], $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * N[(N[(1.0 / N[(z * N[(z * t$95$0), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision] / N[Max[N[Abs[x], $MachinePrecision], N[Abs[y], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
t_0 := \mathsf{min}\left(\left|x\right|, \left|y\right|\right)\\
\mathsf{copysign}\left(1, x\right) \cdot \left(\mathsf{copysign}\left(1, y\right) \cdot \frac{\frac{1}{\mathsf{fma}\left(z, z \cdot t\_0, t\_0\right)}}{\mathsf{max}\left(\left|x\right|, \left|y\right|\right)}\right)
\end{array}
Derivation
  1. Initial program 90.0%

    \[\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. mult-flipN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\frac{1}{\color{blue}{\mathsf{fma}\left(z, z, 1\right)} \cdot x}}{y \cdot 1} \]
    19. *-rgt-identity90.6%

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 98.2% accurate, 0.4× speedup?

\[\begin{array}{l} t_0 := \mathsf{min}\left(\left|x\right|, \left|y\right|\right)\\ \mathsf{copysign}\left(1, x\right) \cdot \left(\mathsf{copysign}\left(1, y\right) \cdot \frac{1}{\mathsf{fma}\left(z \cdot t\_0, z, t\_0\right) \cdot \mathsf{max}\left(\left|x\right|, \left|y\right|\right)}\right) \end{array} \]
(FPCore (x y z)
  :precision binary64
  (let* ((t_0 (fmin (fabs x) (fabs y))))
  (*
   (copysign 1.0 x)
   (*
    (copysign 1.0 y)
    (/ 1.0 (* (fma (* z t_0) z t_0) (fmax (fabs x) (fabs y))))))))
double code(double x, double y, double z) {
	double t_0 = fmin(fabs(x), fabs(y));
	return copysign(1.0, x) * (copysign(1.0, y) * (1.0 / (fma((z * t_0), z, t_0) * fmax(fabs(x), fabs(y)))));
}
function code(x, y, z)
	t_0 = fmin(abs(x), abs(y))
	return Float64(copysign(1.0, x) * Float64(copysign(1.0, y) * Float64(1.0 / Float64(fma(Float64(z * t_0), z, t_0) * fmax(abs(x), abs(y))))))
end
code[x_, y_, z_] := Block[{t$95$0 = N[Min[N[Abs[x], $MachinePrecision], N[Abs[y], $MachinePrecision]], $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * N[(1.0 / N[(N[(N[(z * t$95$0), $MachinePrecision] * z + t$95$0), $MachinePrecision] * N[Max[N[Abs[x], $MachinePrecision], N[Abs[y], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
t_0 := \mathsf{min}\left(\left|x\right|, \left|y\right|\right)\\
\mathsf{copysign}\left(1, x\right) \cdot \left(\mathsf{copysign}\left(1, y\right) \cdot \frac{1}{\mathsf{fma}\left(z \cdot t\_0, z, t\_0\right) \cdot \mathsf{max}\left(\left|x\right|, \left|y\right|\right)}\right)
\end{array}
Derivation
  1. Initial program 90.0%

    \[\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. 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-*.f6489.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 91.9% accurate, 0.5× speedup?

\[\mathsf{copysign}\left(1, x\right) \cdot \left(\mathsf{copysign}\left(1, y\right) \cdot \frac{1}{\left(\mathsf{fma}\left(z, z, 1\right) \cdot \mathsf{min}\left(\left|x\right|, \left|y\right|\right)\right) \cdot \mathsf{max}\left(\left|x\right|, \left|y\right|\right)}\right) \]
(FPCore (x y z)
  :precision binary64
  (*
 (copysign 1.0 x)
 (*
  (copysign 1.0 y)
  (/
   1.0
   (*
    (* (fma z z 1.0) (fmin (fabs x) (fabs y)))
    (fmax (fabs x) (fabs y)))))))
double code(double x, double y, double z) {
	return copysign(1.0, x) * (copysign(1.0, y) * (1.0 / ((fma(z, z, 1.0) * fmin(fabs(x), fabs(y))) * fmax(fabs(x), fabs(y)))));
}
function code(x, y, z)
	return Float64(copysign(1.0, x) * Float64(copysign(1.0, y) * Float64(1.0 / Float64(Float64(fma(z, z, 1.0) * fmin(abs(x), abs(y))) * fmax(abs(x), abs(y))))))
end
code[x_, y_, z_] := N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * N[(1.0 / N[(N[(N[(z * z + 1.0), $MachinePrecision] * N[Min[N[Abs[x], $MachinePrecision], N[Abs[y], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Max[N[Abs[x], $MachinePrecision], N[Abs[y], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\mathsf{copysign}\left(1, x\right) \cdot \left(\mathsf{copysign}\left(1, y\right) \cdot \frac{1}{\left(\mathsf{fma}\left(z, z, 1\right) \cdot \mathsf{min}\left(\left|x\right|, \left|y\right|\right)\right) \cdot \mathsf{max}\left(\left|x\right|, \left|y\right|\right)}\right)
Derivation
  1. Initial program 90.0%

    \[\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. 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-*.f6489.7%

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

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

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

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

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

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

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

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

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

Alternative 4: 90.1% accurate, 0.8× speedup?

\[\frac{1}{\left(\mathsf{max}\left(x, y\right) \cdot \mathsf{fma}\left(z, z, 1\right)\right) \cdot \mathsf{min}\left(x, y\right)} \]
(FPCore (x y z)
  :precision binary64
  (/ 1.0 (* (* (fmax x y) (fma z z 1.0)) (fmin x y))))
double code(double x, double y, double z) {
	return 1.0 / ((fmax(x, y) * fma(z, z, 1.0)) * fmin(x, y));
}
function code(x, y, z)
	return Float64(1.0 / Float64(Float64(fmax(x, y) * fma(z, z, 1.0)) * fmin(x, y)))
end
code[x_, y_, z_] := N[(1.0 / N[(N[(N[Max[x, y], $MachinePrecision] * N[(z * z + 1.0), $MachinePrecision]), $MachinePrecision] * N[Min[x, y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{1}{\left(\mathsf{max}\left(x, y\right) \cdot \mathsf{fma}\left(z, z, 1\right)\right) \cdot \mathsf{min}\left(x, y\right)}
Derivation
  1. Initial program 90.0%

    \[\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. 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-*.f6489.7%

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

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

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

Alternative 5: 61.0% accurate, 0.4× speedup?

\[\begin{array}{l} t_0 := \mathsf{max}\left(x, \left|y\right|\right)\\ t_1 := \mathsf{min}\left(x, \left|y\right|\right)\\ \mathsf{copysign}\left(1, y\right) \cdot \begin{array}{l} \mathbf{if}\;1 + z \cdot z \leq 7.7 \cdot 10^{+179}:\\ \;\;\;\;\frac{\frac{1}{t\_1}}{t\_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{t\_1 \cdot \frac{1}{t\_0}}{t\_1 \cdot t\_1}\\ \end{array} \end{array} \]
(FPCore (x y z)
  :precision binary64
  (let* ((t_0 (fmax x (fabs y))) (t_1 (fmin x (fabs y))))
  (*
   (copysign 1.0 y)
   (if (<= (+ 1.0 (* z z)) 7.7e+179)
     (/ (/ 1.0 t_1) t_0)
     (/ (* t_1 (/ 1.0 t_0)) (* t_1 t_1))))))
double code(double x, double y, double z) {
	double t_0 = fmax(x, fabs(y));
	double t_1 = fmin(x, fabs(y));
	double tmp;
	if ((1.0 + (z * z)) <= 7.7e+179) {
		tmp = (1.0 / t_1) / t_0;
	} else {
		tmp = (t_1 * (1.0 / t_0)) / (t_1 * t_1);
	}
	return copysign(1.0, y) * tmp;
}
public static double code(double x, double y, double z) {
	double t_0 = fmax(x, Math.abs(y));
	double t_1 = fmin(x, Math.abs(y));
	double tmp;
	if ((1.0 + (z * z)) <= 7.7e+179) {
		tmp = (1.0 / t_1) / t_0;
	} else {
		tmp = (t_1 * (1.0 / t_0)) / (t_1 * t_1);
	}
	return Math.copySign(1.0, y) * tmp;
}
def code(x, y, z):
	t_0 = fmax(x, math.fabs(y))
	t_1 = fmin(x, math.fabs(y))
	tmp = 0
	if (1.0 + (z * z)) <= 7.7e+179:
		tmp = (1.0 / t_1) / t_0
	else:
		tmp = (t_1 * (1.0 / t_0)) / (t_1 * t_1)
	return math.copysign(1.0, y) * tmp
function code(x, y, z)
	t_0 = fmax(x, abs(y))
	t_1 = fmin(x, abs(y))
	tmp = 0.0
	if (Float64(1.0 + Float64(z * z)) <= 7.7e+179)
		tmp = Float64(Float64(1.0 / t_1) / t_0);
	else
		tmp = Float64(Float64(t_1 * Float64(1.0 / t_0)) / Float64(t_1 * t_1));
	end
	return Float64(copysign(1.0, y) * tmp)
end
function tmp_2 = code(x, y, z)
	t_0 = max(x, abs(y));
	t_1 = min(x, abs(y));
	tmp = 0.0;
	if ((1.0 + (z * z)) <= 7.7e+179)
		tmp = (1.0 / t_1) / t_0;
	else
		tmp = (t_1 * (1.0 / t_0)) / (t_1 * t_1);
	end
	tmp_2 = (sign(y) * abs(1.0)) * tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[Max[x, N[Abs[y], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Min[x, N[Abs[y], $MachinePrecision]], $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision], 7.7e+179], N[(N[(1.0 / t$95$1), $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[(t$95$1 * N[(1.0 / t$95$0), $MachinePrecision]), $MachinePrecision] / N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]]]
\begin{array}{l}
t_0 := \mathsf{max}\left(x, \left|y\right|\right)\\
t_1 := \mathsf{min}\left(x, \left|y\right|\right)\\
\mathsf{copysign}\left(1, y\right) \cdot \begin{array}{l}
\mathbf{if}\;1 + z \cdot z \leq 7.7 \cdot 10^{+179}:\\
\;\;\;\;\frac{\frac{1}{t\_1}}{t\_0}\\

\mathbf{else}:\\
\;\;\;\;\frac{t\_1 \cdot \frac{1}{t\_0}}{t\_1 \cdot t\_1}\\


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

    1. Initial program 90.0%

      \[\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. lower-*.f6459.0%

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{x}}{y} \]
      5. lower-/.f6459.0%

        \[\leadsto \frac{\frac{1}{x}}{\color{blue}{y}} \]
    6. Applied rewrites59.0%

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

    if 7.7000000000000004e179 < (+.f64 #s(literal 1 binary64) (*.f64 z z))

    1. Initial program 90.0%

      \[\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. lower-*.f6459.0%

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{x}}{y} \]
      5. lower-/.f6459.0%

        \[\leadsto \frac{\frac{1}{x}}{\color{blue}{y}} \]
    6. Applied rewrites59.0%

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

        \[\leadsto \frac{\frac{1}{x}}{\color{blue}{y}} \]
      2. div-flip-revN/A

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

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

        \[\leadsto \frac{1}{y} \cdot \frac{1}{\color{blue}{x}} \]
      5. mult-flip-revN/A

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

        \[\leadsto \frac{\frac{1}{y}}{\color{blue}{x}} \]
      7. lower-/.f6459.0%

        \[\leadsto \frac{\frac{1}{y}}{x} \]
    8. Applied rewrites59.0%

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

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

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

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

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

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

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

        \[\leadsto \frac{x \cdot \frac{1}{y}}{\color{blue}{x \cdot x}} \]
      8. lower-*.f6444.7%

        \[\leadsto \frac{x \cdot \frac{1}{y}}{\color{blue}{x} \cdot x} \]
    10. Applied rewrites44.7%

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

Alternative 6: 60.9% accurate, 0.4× speedup?

\[\begin{array}{l} t_0 := \mathsf{max}\left(x, \left|y\right|\right)\\ t_1 := \mathsf{min}\left(x, \left|y\right|\right)\\ \mathsf{copysign}\left(1, y\right) \cdot \begin{array}{l} \mathbf{if}\;\left|z\right| \leq 9.2 \cdot 10^{+89}:\\ \;\;\;\;\frac{\frac{1}{t\_1}}{t\_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{t\_1}{t\_0} \cdot \frac{1}{t\_1 \cdot t\_1}\\ \end{array} \end{array} \]
(FPCore (x y z)
  :precision binary64
  (let* ((t_0 (fmax x (fabs y))) (t_1 (fmin x (fabs y))))
  (*
   (copysign 1.0 y)
   (if (<= (fabs z) 9.2e+89)
     (/ (/ 1.0 t_1) t_0)
     (* (/ t_1 t_0) (/ 1.0 (* t_1 t_1)))))))
double code(double x, double y, double z) {
	double t_0 = fmax(x, fabs(y));
	double t_1 = fmin(x, fabs(y));
	double tmp;
	if (fabs(z) <= 9.2e+89) {
		tmp = (1.0 / t_1) / t_0;
	} else {
		tmp = (t_1 / t_0) * (1.0 / (t_1 * t_1));
	}
	return copysign(1.0, y) * tmp;
}
public static double code(double x, double y, double z) {
	double t_0 = fmax(x, Math.abs(y));
	double t_1 = fmin(x, Math.abs(y));
	double tmp;
	if (Math.abs(z) <= 9.2e+89) {
		tmp = (1.0 / t_1) / t_0;
	} else {
		tmp = (t_1 / t_0) * (1.0 / (t_1 * t_1));
	}
	return Math.copySign(1.0, y) * tmp;
}
def code(x, y, z):
	t_0 = fmax(x, math.fabs(y))
	t_1 = fmin(x, math.fabs(y))
	tmp = 0
	if math.fabs(z) <= 9.2e+89:
		tmp = (1.0 / t_1) / t_0
	else:
		tmp = (t_1 / t_0) * (1.0 / (t_1 * t_1))
	return math.copysign(1.0, y) * tmp
function code(x, y, z)
	t_0 = fmax(x, abs(y))
	t_1 = fmin(x, abs(y))
	tmp = 0.0
	if (abs(z) <= 9.2e+89)
		tmp = Float64(Float64(1.0 / t_1) / t_0);
	else
		tmp = Float64(Float64(t_1 / t_0) * Float64(1.0 / Float64(t_1 * t_1)));
	end
	return Float64(copysign(1.0, y) * tmp)
end
function tmp_2 = code(x, y, z)
	t_0 = max(x, abs(y));
	t_1 = min(x, abs(y));
	tmp = 0.0;
	if (abs(z) <= 9.2e+89)
		tmp = (1.0 / t_1) / t_0;
	else
		tmp = (t_1 / t_0) * (1.0 / (t_1 * t_1));
	end
	tmp_2 = (sign(y) * abs(1.0)) * tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[Max[x, N[Abs[y], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Min[x, N[Abs[y], $MachinePrecision]], $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[Abs[z], $MachinePrecision], 9.2e+89], N[(N[(1.0 / t$95$1), $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[(t$95$1 / t$95$0), $MachinePrecision] * N[(1.0 / N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]]]
\begin{array}{l}
t_0 := \mathsf{max}\left(x, \left|y\right|\right)\\
t_1 := \mathsf{min}\left(x, \left|y\right|\right)\\
\mathsf{copysign}\left(1, y\right) \cdot \begin{array}{l}
\mathbf{if}\;\left|z\right| \leq 9.2 \cdot 10^{+89}:\\
\;\;\;\;\frac{\frac{1}{t\_1}}{t\_0}\\

\mathbf{else}:\\
\;\;\;\;\frac{t\_1}{t\_0} \cdot \frac{1}{t\_1 \cdot t\_1}\\


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

    1. Initial program 90.0%

      \[\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. lower-*.f6459.0%

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{x}}{y} \]
      5. lower-/.f6459.0%

        \[\leadsto \frac{\frac{1}{x}}{\color{blue}{y}} \]
    6. Applied rewrites59.0%

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

    if 9.1999999999999996e89 < z

    1. Initial program 90.0%

      \[\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. lower-*.f6459.0%

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{x}}{y} \]
      5. lower-/.f6459.0%

        \[\leadsto \frac{\frac{1}{x}}{\color{blue}{y}} \]
    6. Applied rewrites59.0%

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

        \[\leadsto \frac{\frac{1}{x}}{\color{blue}{y}} \]
      2. div-flip-revN/A

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

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

        \[\leadsto \frac{1}{y} \cdot \frac{1}{\color{blue}{x}} \]
      5. mult-flip-revN/A

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

        \[\leadsto \frac{\frac{1}{y}}{\color{blue}{x}} \]
      7. lower-/.f6459.0%

        \[\leadsto \frac{\frac{1}{y}}{x} \]
    8. Applied rewrites59.0%

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

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

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

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

        \[\leadsto \frac{\frac{x}{x}}{\color{blue}{y} \cdot x} \]
      5. mult-flipN/A

        \[\leadsto \frac{x \cdot \frac{1}{x}}{\color{blue}{y} \cdot x} \]
      6. times-fracN/A

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

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

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

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

        \[\leadsto \frac{x}{y} \cdot \frac{\color{blue}{1}}{x \cdot x} \]
      11. lower-/.f6444.4%

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

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

Alternative 7: 59.0% accurate, 0.6× speedup?

\[\mathsf{copysign}\left(1, x\right) \cdot \left(\mathsf{copysign}\left(1, y\right) \cdot \frac{\frac{1}{\mathsf{min}\left(\left|x\right|, \left|y\right|\right)}}{\mathsf{max}\left(\left|x\right|, \left|y\right|\right)}\right) \]
(FPCore (x y z)
  :precision binary64
  (*
 (copysign 1.0 x)
 (*
  (copysign 1.0 y)
  (/ (/ 1.0 (fmin (fabs x) (fabs y))) (fmax (fabs x) (fabs y))))))
double code(double x, double y, double z) {
	return copysign(1.0, x) * (copysign(1.0, y) * ((1.0 / fmin(fabs(x), fabs(y))) / fmax(fabs(x), fabs(y))));
}
public static double code(double x, double y, double z) {
	return Math.copySign(1.0, x) * (Math.copySign(1.0, y) * ((1.0 / fmin(Math.abs(x), Math.abs(y))) / fmax(Math.abs(x), Math.abs(y))));
}
def code(x, y, z):
	return math.copysign(1.0, x) * (math.copysign(1.0, y) * ((1.0 / fmin(math.fabs(x), math.fabs(y))) / fmax(math.fabs(x), math.fabs(y))))
function code(x, y, z)
	return Float64(copysign(1.0, x) * Float64(copysign(1.0, y) * Float64(Float64(1.0 / fmin(abs(x), abs(y))) / fmax(abs(x), abs(y)))))
end
function tmp = code(x, y, z)
	tmp = (sign(x) * abs(1.0)) * ((sign(y) * abs(1.0)) * ((1.0 / min(abs(x), abs(y))) / max(abs(x), abs(y))));
end
code[x_, y_, z_] := N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * N[(N[(1.0 / N[Min[N[Abs[x], $MachinePrecision], N[Abs[y], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[Max[N[Abs[x], $MachinePrecision], N[Abs[y], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\mathsf{copysign}\left(1, x\right) \cdot \left(\mathsf{copysign}\left(1, y\right) \cdot \frac{\frac{1}{\mathsf{min}\left(\left|x\right|, \left|y\right|\right)}}{\mathsf{max}\left(\left|x\right|, \left|y\right|\right)}\right)
Derivation
  1. Initial program 90.0%

    \[\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. lower-*.f6459.0%

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

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

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

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

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

      \[\leadsto \frac{\frac{1}{x}}{y} \]
    5. lower-/.f6459.0%

      \[\leadsto \frac{\frac{1}{x}}{\color{blue}{y}} \]
  6. Applied rewrites59.0%

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

Alternative 8: 59.0% accurate, 2.2× speedup?

\[\frac{1}{x \cdot y} \]
(FPCore (x y z)
  :precision binary64
  (/ 1.0 (* x y)))
double code(double x, double y, double z) {
	return 1.0 / (x * y);
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(x, y, z)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = 1.0d0 / (x * y)
end function
public static double code(double x, double y, double z) {
	return 1.0 / (x * y);
}
def code(x, y, z):
	return 1.0 / (x * y)
function code(x, y, z)
	return Float64(1.0 / Float64(x * y))
end
function tmp = code(x, y, z)
	tmp = 1.0 / (x * y);
end
code[x_, y_, z_] := N[(1.0 / N[(x * y), $MachinePrecision]), $MachinePrecision]
\frac{1}{x \cdot y}
Derivation
  1. Initial program 90.0%

    \[\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. lower-*.f6459.0%

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

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

Reproduce

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