Statistics.Distribution.Beta:$cvariance from math-functions-0.1.5.2

Percentage Accurate: 82.8% → 96.8%
Time: 5.1s
Alternatives: 11
Speedup: 1.0×

Specification

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

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

real(8) function code(x, y, z)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = (x * y) / ((z * z) * (z + 1.0d0))
end function
public static double code(double x, double y, double z) {
	return (x * y) / ((z * z) * (z + 1.0));
}
def code(x, y, z):
	return (x * y) / ((z * z) * (z + 1.0))
function code(x, y, z)
	return Float64(Float64(x * y) / Float64(Float64(z * z) * Float64(z + 1.0)))
end
function tmp = code(x, y, z)
	tmp = (x * y) / ((z * z) * (z + 1.0));
end
code[x_, y_, z_] := N[(N[(x * y), $MachinePrecision] / N[(N[(z * z), $MachinePrecision] * N[(z + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 11 alternatives:

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

Initial Program: 82.8% accurate, 1.0× speedup?

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

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

real(8) function code(x, y, z)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = (x * y) / ((z * z) * (z + 1.0d0))
end function
public static double code(double x, double y, double z) {
	return (x * y) / ((z * z) * (z + 1.0));
}
def code(x, y, z):
	return (x * y) / ((z * z) * (z + 1.0))
function code(x, y, z)
	return Float64(Float64(x * y) / Float64(Float64(z * z) * Float64(z + 1.0)))
end
function tmp = code(x, y, z)
	tmp = (x * y) / ((z * z) * (z + 1.0));
end
code[x_, y_, z_] := N[(N[(x * y), $MachinePrecision] / N[(N[(z * z), $MachinePrecision] * N[(z + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

Alternative 1: 96.8% accurate, 1.0× speedup?

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

\\
\frac{\frac{y}{z} \cdot \frac{x}{z}}{z - -1}
\end{array}
Derivation
  1. Initial program 82.8%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\frac{x}{z \cdot z} \cdot y}{\color{blue}{z - \left(\mathsf{neg}\left(1\right)\right)}} \]
    12. metadata-eval87.3

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 96.2% accurate, 1.0× speedup?

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

\\
\frac{\frac{x}{z}}{z - -1} \cdot \frac{y}{z}
\end{array}
Derivation
  1. Initial program 82.8%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{x}{z} \cdot \frac{y}{z \cdot z + \color{blue}{z}} \]
    13. lower-fma.f6494.2

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

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

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

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

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

      \[\leadsto \frac{\frac{x}{z} \cdot y}{\color{blue}{z \cdot z + z}} \]
    5. distribute-lft1-inN/A

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{x}{z}}{z - -1} \cdot \frac{y}{z}} \]
    12. lower-/.f6496.2

      \[\leadsto \color{blue}{\frac{\frac{x}{z}}{z - -1}} \cdot \frac{y}{z} \]
  5. Applied rewrites96.2%

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

Alternative 3: 94.2% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\frac{x}{z \cdot z} \cdot y}{\color{blue}{z - \left(\mathsf{neg}\left(1\right)\right)}} \]
    12. metadata-eval87.3

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\frac{y}{z} \cdot x}{\left(z - \color{blue}{\left(\mathsf{neg}\left(1\right)\right)}\right) \cdot z} \]
    10. add-flipN/A

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

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

      \[\leadsto \frac{\frac{y}{z} \cdot x}{\color{blue}{\mathsf{fma}\left(z, z, z\right)}} \]
    13. lower-/.f6494.2

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

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

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

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

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

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

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

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

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

Alternative 4: 94.2% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{x}{z} \cdot \frac{y}{z \cdot z + \color{blue}{z}} \]
    13. lower-fma.f6494.2

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

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

Alternative 5: 85.8% accurate, 0.5× speedup?

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

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

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


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

    1. Initial program 82.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{y}{\left(z \cdot z + \color{blue}{z}\right) \cdot z} \cdot x \]
      15. lower-fma.f6484.4

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

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

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

    1. Initial program 82.8%

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

      \[\leadsto \frac{x \cdot y}{\left(z \cdot z\right) \cdot \color{blue}{1}} \]
    3. Step-by-step derivation
      1. Applied rewrites70.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 6: 85.0% accurate, 0.5× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)} \leq 10^{+246}:\\ \;\;\;\;y \cdot \frac{x}{\mathsf{fma}\left(z, z, z\right) \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{z \cdot \frac{1 \cdot z}{x}}\\ \end{array} \end{array} \]
    (FPCore (x y z)
     :precision binary64
     (if (<= (/ (* x y) (* (* z z) (+ z 1.0))) 1e+246)
       (* y (/ x (* (fma z z z) z)))
       (/ y (* z (/ (* 1.0 z) x)))))
    double code(double x, double y, double z) {
    	double tmp;
    	if (((x * y) / ((z * z) * (z + 1.0))) <= 1e+246) {
    		tmp = y * (x / (fma(z, z, z) * z));
    	} else {
    		tmp = y / (z * ((1.0 * z) / x));
    	}
    	return tmp;
    }
    
    function code(x, y, z)
    	tmp = 0.0
    	if (Float64(Float64(x * y) / Float64(Float64(z * z) * Float64(z + 1.0))) <= 1e+246)
    		tmp = Float64(y * Float64(x / Float64(fma(z, z, z) * z)));
    	else
    		tmp = Float64(y / Float64(z * Float64(Float64(1.0 * z) / x)));
    	end
    	return tmp
    end
    
    code[x_, y_, z_] := If[LessEqual[N[(N[(x * y), $MachinePrecision] / N[(N[(z * z), $MachinePrecision] * N[(z + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1e+246], N[(y * N[(x / N[(N[(z * z + z), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y / N[(z * N[(N[(1.0 * z), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    \mathbf{if}\;\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)} \leq 10^{+246}:\\
    \;\;\;\;y \cdot \frac{x}{\mathsf{fma}\left(z, z, z\right) \cdot z}\\
    
    \mathbf{else}:\\
    \;\;\;\;\frac{y}{z \cdot \frac{1 \cdot z}{x}}\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if (/.f64 (*.f64 x y) (*.f64 (*.f64 z z) (+.f64 z #s(literal 1 binary64)))) < 1.00000000000000007e246

      1. Initial program 82.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      1. Initial program 82.8%

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

        \[\leadsto \frac{x \cdot y}{\left(z \cdot z\right) \cdot \color{blue}{1}} \]
      3. Step-by-step derivation
        1. Applied rewrites70.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      Alternative 7: 77.3% accurate, 1.2× speedup?

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

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

        \[\leadsto \frac{x \cdot y}{\left(z \cdot z\right) \cdot \color{blue}{1}} \]
      3. Step-by-step derivation
        1. Applied rewrites70.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        Alternative 8: 76.2% accurate, 0.8× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \cdot y \leq 5 \cdot 10^{-66}:\\ \;\;\;\;\frac{y}{z} \cdot \frac{x}{1 \cdot z}\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{x}{\left(1 \cdot z\right) \cdot z}\\ \end{array} \end{array} \]
        (FPCore (x y z)
         :precision binary64
         (if (<= (* x y) 5e-66)
           (* (/ y z) (/ x (* 1.0 z)))
           (* y (/ x (* (* 1.0 z) z)))))
        double code(double x, double y, double z) {
        	double tmp;
        	if ((x * y) <= 5e-66) {
        		tmp = (y / z) * (x / (1.0 * z));
        	} else {
        		tmp = y * (x / ((1.0 * 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 ((x * y) <= 5d-66) then
                tmp = (y / z) * (x / (1.0d0 * z))
            else
                tmp = y * (x / ((1.0d0 * z) * z))
            end if
            code = tmp
        end function
        
        public static double code(double x, double y, double z) {
        	double tmp;
        	if ((x * y) <= 5e-66) {
        		tmp = (y / z) * (x / (1.0 * z));
        	} else {
        		tmp = y * (x / ((1.0 * z) * z));
        	}
        	return tmp;
        }
        
        def code(x, y, z):
        	tmp = 0
        	if (x * y) <= 5e-66:
        		tmp = (y / z) * (x / (1.0 * z))
        	else:
        		tmp = y * (x / ((1.0 * z) * z))
        	return tmp
        
        function code(x, y, z)
        	tmp = 0.0
        	if (Float64(x * y) <= 5e-66)
        		tmp = Float64(Float64(y / z) * Float64(x / Float64(1.0 * z)));
        	else
        		tmp = Float64(y * Float64(x / Float64(Float64(1.0 * z) * z)));
        	end
        	return tmp
        end
        
        function tmp_2 = code(x, y, z)
        	tmp = 0.0;
        	if ((x * y) <= 5e-66)
        		tmp = (y / z) * (x / (1.0 * z));
        	else
        		tmp = y * (x / ((1.0 * z) * z));
        	end
        	tmp_2 = tmp;
        end
        
        code[x_, y_, z_] := If[LessEqual[N[(x * y), $MachinePrecision], 5e-66], N[(N[(y / z), $MachinePrecision] * N[(x / N[(1.0 * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y * N[(x / N[(N[(1.0 * z), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;x \cdot y \leq 5 \cdot 10^{-66}:\\
        \;\;\;\;\frac{y}{z} \cdot \frac{x}{1 \cdot z}\\
        
        \mathbf{else}:\\
        \;\;\;\;y \cdot \frac{x}{\left(1 \cdot z\right) \cdot z}\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if (*.f64 x y) < 4.99999999999999962e-66

          1. Initial program 82.8%

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

            \[\leadsto \frac{x \cdot y}{\left(z \cdot z\right) \cdot \color{blue}{1}} \]
          3. Step-by-step derivation
            1. Applied rewrites70.2%

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

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

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

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

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

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

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

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

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

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

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

                \[\leadsto \frac{y}{z} \cdot \frac{x}{\color{blue}{1 \cdot z}} \]
              12. lower-*.f6474.7

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

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

            if 4.99999999999999962e-66 < (*.f64 x y)

            1. Initial program 82.8%

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

              \[\leadsto \frac{x \cdot y}{\left(z \cdot z\right) \cdot \color{blue}{1}} \]
            3. Step-by-step derivation
              1. Applied rewrites70.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            Alternative 9: 75.3% accurate, 0.6× speedup?

            \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \cdot y \leq 5 \cdot 10^{-323}:\\ \;\;\;\;x \cdot \frac{\frac{y}{z}}{1 \cdot z}\\ \mathbf{elif}\;x \cdot y \leq 10^{-51}:\\ \;\;\;\;\frac{\frac{x \cdot y}{z}}{z}\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{x}{\left(1 \cdot z\right) \cdot z}\\ \end{array} \end{array} \]
            (FPCore (x y z)
             :precision binary64
             (if (<= (* x y) 5e-323)
               (* x (/ (/ y z) (* 1.0 z)))
               (if (<= (* x y) 1e-51) (/ (/ (* x y) z) z) (* y (/ x (* (* 1.0 z) z))))))
            double code(double x, double y, double z) {
            	double tmp;
            	if ((x * y) <= 5e-323) {
            		tmp = x * ((y / z) / (1.0 * z));
            	} else if ((x * y) <= 1e-51) {
            		tmp = ((x * y) / z) / z;
            	} else {
            		tmp = y * (x / ((1.0 * 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 ((x * y) <= 5d-323) then
                    tmp = x * ((y / z) / (1.0d0 * z))
                else if ((x * y) <= 1d-51) then
                    tmp = ((x * y) / z) / z
                else
                    tmp = y * (x / ((1.0d0 * z) * z))
                end if
                code = tmp
            end function
            
            public static double code(double x, double y, double z) {
            	double tmp;
            	if ((x * y) <= 5e-323) {
            		tmp = x * ((y / z) / (1.0 * z));
            	} else if ((x * y) <= 1e-51) {
            		tmp = ((x * y) / z) / z;
            	} else {
            		tmp = y * (x / ((1.0 * z) * z));
            	}
            	return tmp;
            }
            
            def code(x, y, z):
            	tmp = 0
            	if (x * y) <= 5e-323:
            		tmp = x * ((y / z) / (1.0 * z))
            	elif (x * y) <= 1e-51:
            		tmp = ((x * y) / z) / z
            	else:
            		tmp = y * (x / ((1.0 * z) * z))
            	return tmp
            
            function code(x, y, z)
            	tmp = 0.0
            	if (Float64(x * y) <= 5e-323)
            		tmp = Float64(x * Float64(Float64(y / z) / Float64(1.0 * z)));
            	elseif (Float64(x * y) <= 1e-51)
            		tmp = Float64(Float64(Float64(x * y) / z) / z);
            	else
            		tmp = Float64(y * Float64(x / Float64(Float64(1.0 * z) * z)));
            	end
            	return tmp
            end
            
            function tmp_2 = code(x, y, z)
            	tmp = 0.0;
            	if ((x * y) <= 5e-323)
            		tmp = x * ((y / z) / (1.0 * z));
            	elseif ((x * y) <= 1e-51)
            		tmp = ((x * y) / z) / z;
            	else
            		tmp = y * (x / ((1.0 * z) * z));
            	end
            	tmp_2 = tmp;
            end
            
            code[x_, y_, z_] := If[LessEqual[N[(x * y), $MachinePrecision], 5e-323], N[(x * N[(N[(y / z), $MachinePrecision] / N[(1.0 * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 1e-51], N[(N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision] / z), $MachinePrecision], N[(y * N[(x / N[(N[(1.0 * z), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
            
            \begin{array}{l}
            
            \\
            \begin{array}{l}
            \mathbf{if}\;x \cdot y \leq 5 \cdot 10^{-323}:\\
            \;\;\;\;x \cdot \frac{\frac{y}{z}}{1 \cdot z}\\
            
            \mathbf{elif}\;x \cdot y \leq 10^{-51}:\\
            \;\;\;\;\frac{\frac{x \cdot y}{z}}{z}\\
            
            \mathbf{else}:\\
            \;\;\;\;y \cdot \frac{x}{\left(1 \cdot z\right) \cdot z}\\
            
            
            \end{array}
            \end{array}
            
            Derivation
            1. Split input into 3 regimes
            2. if (*.f64 x y) < 4.94066e-323

              1. Initial program 82.8%

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

                \[\leadsto \frac{x \cdot y}{\left(z \cdot z\right) \cdot \color{blue}{1}} \]
              3. Step-by-step derivation
                1. Applied rewrites70.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                if 4.94066e-323 < (*.f64 x y) < 1e-51

                1. Initial program 82.8%

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

                  \[\leadsto \frac{x \cdot y}{\left(z \cdot z\right) \cdot \color{blue}{1}} \]
                3. Step-by-step derivation
                  1. Applied rewrites70.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                      \[\leadsto \frac{\frac{x \cdot y}{\color{blue}{z}}}{z} \]
                    2. lower-*.f6470.8

                      \[\leadsto \frac{\frac{x \cdot y}{z}}{z} \]
                  8. Applied rewrites70.8%

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

                  if 1e-51 < (*.f64 x y)

                  1. Initial program 82.8%

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

                    \[\leadsto \frac{x \cdot y}{\left(z \cdot z\right) \cdot \color{blue}{1}} \]
                  3. Step-by-step derivation
                    1. Applied rewrites70.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                  Alternative 10: 74.1% accurate, 0.5× speedup?

                  \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)} \leq 5000:\\ \;\;\;\;y \cdot \frac{x}{\left(1 \cdot z\right) \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x \cdot y}{z}}{z}\\ \end{array} \end{array} \]
                  (FPCore (x y z)
                   :precision binary64
                   (if (<= (/ (* x y) (* (* z z) (+ z 1.0))) 5000.0)
                     (* y (/ x (* (* 1.0 z) z)))
                     (/ (/ (* x y) z) z)))
                  double code(double x, double y, double z) {
                  	double tmp;
                  	if (((x * y) / ((z * z) * (z + 1.0))) <= 5000.0) {
                  		tmp = y * (x / ((1.0 * z) * z));
                  	} else {
                  		tmp = ((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 (((x * y) / ((z * z) * (z + 1.0d0))) <= 5000.0d0) then
                          tmp = y * (x / ((1.0d0 * z) * z))
                      else
                          tmp = ((x * y) / z) / z
                      end if
                      code = tmp
                  end function
                  
                  public static double code(double x, double y, double z) {
                  	double tmp;
                  	if (((x * y) / ((z * z) * (z + 1.0))) <= 5000.0) {
                  		tmp = y * (x / ((1.0 * z) * z));
                  	} else {
                  		tmp = ((x * y) / z) / z;
                  	}
                  	return tmp;
                  }
                  
                  def code(x, y, z):
                  	tmp = 0
                  	if ((x * y) / ((z * z) * (z + 1.0))) <= 5000.0:
                  		tmp = y * (x / ((1.0 * z) * z))
                  	else:
                  		tmp = ((x * y) / z) / z
                  	return tmp
                  
                  function code(x, y, z)
                  	tmp = 0.0
                  	if (Float64(Float64(x * y) / Float64(Float64(z * z) * Float64(z + 1.0))) <= 5000.0)
                  		tmp = Float64(y * Float64(x / Float64(Float64(1.0 * z) * z)));
                  	else
                  		tmp = Float64(Float64(Float64(x * y) / z) / z);
                  	end
                  	return tmp
                  end
                  
                  function tmp_2 = code(x, y, z)
                  	tmp = 0.0;
                  	if (((x * y) / ((z * z) * (z + 1.0))) <= 5000.0)
                  		tmp = y * (x / ((1.0 * z) * z));
                  	else
                  		tmp = ((x * y) / z) / z;
                  	end
                  	tmp_2 = tmp;
                  end
                  
                  code[x_, y_, z_] := If[LessEqual[N[(N[(x * y), $MachinePrecision] / N[(N[(z * z), $MachinePrecision] * N[(z + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 5000.0], N[(y * N[(x / N[(N[(1.0 * z), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision] / z), $MachinePrecision]]
                  
                  \begin{array}{l}
                  
                  \\
                  \begin{array}{l}
                  \mathbf{if}\;\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)} \leq 5000:\\
                  \;\;\;\;y \cdot \frac{x}{\left(1 \cdot z\right) \cdot z}\\
                  
                  \mathbf{else}:\\
                  \;\;\;\;\frac{\frac{x \cdot y}{z}}{z}\\
                  
                  
                  \end{array}
                  \end{array}
                  
                  Derivation
                  1. Split input into 2 regimes
                  2. if (/.f64 (*.f64 x y) (*.f64 (*.f64 z z) (+.f64 z #s(literal 1 binary64)))) < 5e3

                    1. Initial program 82.8%

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

                      \[\leadsto \frac{x \cdot y}{\left(z \cdot z\right) \cdot \color{blue}{1}} \]
                    3. Step-by-step derivation
                      1. Applied rewrites70.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                      1. Initial program 82.8%

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

                        \[\leadsto \frac{x \cdot y}{\left(z \cdot z\right) \cdot \color{blue}{1}} \]
                      3. Step-by-step derivation
                        1. Applied rewrites70.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                            \[\leadsto \frac{\frac{x \cdot y}{\color{blue}{z}}}{z} \]
                          2. lower-*.f6470.8

                            \[\leadsto \frac{\frac{x \cdot y}{z}}{z} \]
                        8. Applied rewrites70.8%

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

                      Alternative 11: 70.8% accurate, 1.5× speedup?

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

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

                        \[\leadsto \frac{x \cdot y}{\left(z \cdot z\right) \cdot \color{blue}{1}} \]
                      3. Step-by-step derivation
                        1. Applied rewrites70.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                            \[\leadsto \frac{\frac{x \cdot y}{\color{blue}{z}}}{z} \]
                          2. lower-*.f6470.8

                            \[\leadsto \frac{\frac{x \cdot y}{z}}{z} \]
                        8. Applied rewrites70.8%

                          \[\leadsto \frac{\color{blue}{\frac{x \cdot y}{z}}}{z} \]
                        9. Add Preprocessing

                        Reproduce

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