Optimisation.CirclePacking:place from circle-packing-0.1.0.4, H

Percentage Accurate: 100.0% → 100.0%
Time: 2.4s
Alternatives: 8
Speedup: 0.8×

Specification

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

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

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 8 alternatives:

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

Initial Program: 100.0% accurate, 1.0× speedup?

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

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

Alternative 1: 100.0% accurate, 0.8× speedup?

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

\\
y - \left(\left(y + x\right) \cdot z - x\right)
\end{array}
Derivation
  1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(y + \color{blue}{\left(\mathsf{neg}\left(z\right)\right)} \cdot \left(x + y\right)\right) + x \]
    15. fp-cancel-sub-signN/A

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

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

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

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

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

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

      \[\leadsto y - \left(\color{blue}{\left(y + x\right)} \cdot z - x\right) \]
    22. lower-+.f64100.0

      \[\leadsto y - \left(\color{blue}{\left(y + x\right)} \cdot z - x\right) \]
  3. Applied rewrites100.0%

    \[\leadsto \color{blue}{y - \left(\left(y + x\right) \cdot z - x\right)} \]
  4. Add Preprocessing

Alternative 2: 100.0% accurate, 1.0× speedup?

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

\\
\left(x + y\right) \cdot \left(1 - z\right)
\end{array}
Derivation
  1. Initial program 100.0%

    \[\left(x + y\right) \cdot \left(1 - z\right) \]
  2. Add Preprocessing

Alternative 3: 52.3% accurate, 0.7× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (+.f64 x y) < -5.0000000000000001e-248

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{x \cdot \left(1 - z\right)} \]
    3. Step-by-step derivation
      1. *-commutativeN/A

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

        \[\leadsto \left(1 - z\right) \cdot \color{blue}{x} \]
      3. lift--.f6452.1

        \[\leadsto \left(1 - z\right) \cdot x \]
    4. Applied rewrites52.1%

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

    if -5.0000000000000001e-248 < (+.f64 x y)

    1. Initial program 100.0%

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

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

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

    Alternative 4: 40.1% accurate, 0.7× speedup?

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

      1. Initial program 100.0%

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

        \[\leadsto \color{blue}{x \cdot \left(1 - z\right)} \]
      3. Step-by-step derivation
        1. *-commutativeN/A

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

          \[\leadsto \left(1 - z\right) \cdot \color{blue}{x} \]
        3. lift--.f6452.1

          \[\leadsto \left(1 - z\right) \cdot x \]
      4. Applied rewrites52.1%

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

      if 4.99999999999999976e-178 < (+.f64 x y)

      1. Initial program 100.0%

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

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

          \[\leadsto \color{blue}{y} \cdot \left(1 - z\right) \]
        2. Taylor expanded in z around inf

          \[\leadsto y \cdot \color{blue}{\left(-1 \cdot z\right)} \]
        3. Step-by-step derivation
          1. mul-1-negN/A

            \[\leadsto y \cdot \left(\mathsf{neg}\left(z\right)\right) \]
          2. lower-neg.f6426.9

            \[\leadsto y \cdot \left(-z\right) \]
        4. Applied rewrites26.9%

          \[\leadsto y \cdot \color{blue}{\left(-z\right)} \]
        5. Taylor expanded in z around 0

          \[\leadsto y \cdot \color{blue}{1} \]
        6. Step-by-step derivation
          1. Applied rewrites26.5%

            \[\leadsto y \cdot \color{blue}{1} \]
        7. Recombined 2 regimes into one program.
        8. Add Preprocessing

        Alternative 5: 37.9% accurate, 0.2× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(x + y\right) \cdot \left(1 - z\right)\\ t_1 := y \cdot \left(-z\right)\\ \mathbf{if}\;t\_0 \leq -5 \cdot 10^{+289}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_0 \leq -5 \cdot 10^{-248}:\\ \;\;\;\;1 \cdot x\\ \mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+304}:\\ \;\;\;\;y \cdot 1\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
        (FPCore (x y z)
         :precision binary64
         (let* ((t_0 (* (+ x y) (- 1.0 z))) (t_1 (* y (- z))))
           (if (<= t_0 -5e+289)
             t_1
             (if (<= t_0 -5e-248) (* 1.0 x) (if (<= t_0 5e+304) (* y 1.0) t_1)))))
        double code(double x, double y, double z) {
        	double t_0 = (x + y) * (1.0 - z);
        	double t_1 = y * -z;
        	double tmp;
        	if (t_0 <= -5e+289) {
        		tmp = t_1;
        	} else if (t_0 <= -5e-248) {
        		tmp = 1.0 * x;
        	} else if (t_0 <= 5e+304) {
        		tmp = y * 1.0;
        	} else {
        		tmp = t_1;
        	}
        	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) :: t_0
            real(8) :: t_1
            real(8) :: tmp
            t_0 = (x + y) * (1.0d0 - z)
            t_1 = y * -z
            if (t_0 <= (-5d+289)) then
                tmp = t_1
            else if (t_0 <= (-5d-248)) then
                tmp = 1.0d0 * x
            else if (t_0 <= 5d+304) then
                tmp = y * 1.0d0
            else
                tmp = t_1
            end if
            code = tmp
        end function
        
        public static double code(double x, double y, double z) {
        	double t_0 = (x + y) * (1.0 - z);
        	double t_1 = y * -z;
        	double tmp;
        	if (t_0 <= -5e+289) {
        		tmp = t_1;
        	} else if (t_0 <= -5e-248) {
        		tmp = 1.0 * x;
        	} else if (t_0 <= 5e+304) {
        		tmp = y * 1.0;
        	} else {
        		tmp = t_1;
        	}
        	return tmp;
        }
        
        def code(x, y, z):
        	t_0 = (x + y) * (1.0 - z)
        	t_1 = y * -z
        	tmp = 0
        	if t_0 <= -5e+289:
        		tmp = t_1
        	elif t_0 <= -5e-248:
        		tmp = 1.0 * x
        	elif t_0 <= 5e+304:
        		tmp = y * 1.0
        	else:
        		tmp = t_1
        	return tmp
        
        function code(x, y, z)
        	t_0 = Float64(Float64(x + y) * Float64(1.0 - z))
        	t_1 = Float64(y * Float64(-z))
        	tmp = 0.0
        	if (t_0 <= -5e+289)
        		tmp = t_1;
        	elseif (t_0 <= -5e-248)
        		tmp = Float64(1.0 * x);
        	elseif (t_0 <= 5e+304)
        		tmp = Float64(y * 1.0);
        	else
        		tmp = t_1;
        	end
        	return tmp
        end
        
        function tmp_2 = code(x, y, z)
        	t_0 = (x + y) * (1.0 - z);
        	t_1 = y * -z;
        	tmp = 0.0;
        	if (t_0 <= -5e+289)
        		tmp = t_1;
        	elseif (t_0 <= -5e-248)
        		tmp = 1.0 * x;
        	elseif (t_0 <= 5e+304)
        		tmp = y * 1.0;
        	else
        		tmp = t_1;
        	end
        	tmp_2 = tmp;
        end
        
        code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x + y), $MachinePrecision] * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(y * (-z)), $MachinePrecision]}, If[LessEqual[t$95$0, -5e+289], t$95$1, If[LessEqual[t$95$0, -5e-248], N[(1.0 * x), $MachinePrecision], If[LessEqual[t$95$0, 5e+304], N[(y * 1.0), $MachinePrecision], t$95$1]]]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        t_0 := \left(x + y\right) \cdot \left(1 - z\right)\\
        t_1 := y \cdot \left(-z\right)\\
        \mathbf{if}\;t\_0 \leq -5 \cdot 10^{+289}:\\
        \;\;\;\;t\_1\\
        
        \mathbf{elif}\;t\_0 \leq -5 \cdot 10^{-248}:\\
        \;\;\;\;1 \cdot x\\
        
        \mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+304}:\\
        \;\;\;\;y \cdot 1\\
        
        \mathbf{else}:\\
        \;\;\;\;t\_1\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 3 regimes
        2. if (*.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) z)) < -5.00000000000000031e289 or 4.9999999999999997e304 < (*.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) z))

          1. Initial program 100.0%

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

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

              \[\leadsto \color{blue}{y} \cdot \left(1 - z\right) \]
            2. Taylor expanded in z around inf

              \[\leadsto y \cdot \color{blue}{\left(-1 \cdot z\right)} \]
            3. Step-by-step derivation
              1. mul-1-negN/A

                \[\leadsto y \cdot \left(\mathsf{neg}\left(z\right)\right) \]
              2. lower-neg.f6426.9

                \[\leadsto y \cdot \left(-z\right) \]
            4. Applied rewrites26.9%

              \[\leadsto y \cdot \color{blue}{\left(-z\right)} \]

            if -5.00000000000000031e289 < (*.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) z)) < -5.0000000000000001e-248

            1. Initial program 100.0%

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

              \[\leadsto \color{blue}{x \cdot \left(1 - z\right)} \]
            3. Step-by-step derivation
              1. *-commutativeN/A

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

                \[\leadsto \left(1 - z\right) \cdot \color{blue}{x} \]
              3. lift--.f6452.1

                \[\leadsto \left(1 - z\right) \cdot x \]
            4. Applied rewrites52.1%

              \[\leadsto \color{blue}{\left(1 - z\right) \cdot x} \]
            5. Taylor expanded in z around inf

              \[\leadsto \left(-1 \cdot z\right) \cdot x \]
            6. Step-by-step derivation
              1. mul-1-negN/A

                \[\leadsto \left(\mathsf{neg}\left(z\right)\right) \cdot x \]
              2. lower-neg.f6428.1

                \[\leadsto \left(-z\right) \cdot x \]
            7. Applied rewrites28.1%

              \[\leadsto \left(-z\right) \cdot x \]
            8. Taylor expanded in z around 0

              \[\leadsto 1 \cdot x \]
            9. Step-by-step derivation
              1. Applied rewrites26.1%

                \[\leadsto 1 \cdot x \]

              if -5.0000000000000001e-248 < (*.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) z)) < 4.9999999999999997e304

              1. Initial program 100.0%

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

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

                  \[\leadsto \color{blue}{y} \cdot \left(1 - z\right) \]
                2. Taylor expanded in z around inf

                  \[\leadsto y \cdot \color{blue}{\left(-1 \cdot z\right)} \]
                3. Step-by-step derivation
                  1. mul-1-negN/A

                    \[\leadsto y \cdot \left(\mathsf{neg}\left(z\right)\right) \]
                  2. lower-neg.f6426.9

                    \[\leadsto y \cdot \left(-z\right) \]
                4. Applied rewrites26.9%

                  \[\leadsto y \cdot \color{blue}{\left(-z\right)} \]
                5. Taylor expanded in z around 0

                  \[\leadsto y \cdot \color{blue}{1} \]
                6. Step-by-step derivation
                  1. Applied rewrites26.5%

                    \[\leadsto y \cdot \color{blue}{1} \]
                7. Recombined 3 regimes into one program.
                8. Add Preprocessing

                Alternative 6: 37.3% accurate, 0.2× speedup?

                \[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(x + y\right) \cdot \left(1 - z\right)\\ t_1 := \left(-z\right) \cdot x\\ \mathbf{if}\;t\_0 \leq -5 \cdot 10^{+289}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_0 \leq -5 \cdot 10^{-248}:\\ \;\;\;\;1 \cdot x\\ \mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+304}:\\ \;\;\;\;y \cdot 1\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
                (FPCore (x y z)
                 :precision binary64
                 (let* ((t_0 (* (+ x y) (- 1.0 z))) (t_1 (* (- z) x)))
                   (if (<= t_0 -5e+289)
                     t_1
                     (if (<= t_0 -5e-248) (* 1.0 x) (if (<= t_0 5e+304) (* y 1.0) t_1)))))
                double code(double x, double y, double z) {
                	double t_0 = (x + y) * (1.0 - z);
                	double t_1 = -z * x;
                	double tmp;
                	if (t_0 <= -5e+289) {
                		tmp = t_1;
                	} else if (t_0 <= -5e-248) {
                		tmp = 1.0 * x;
                	} else if (t_0 <= 5e+304) {
                		tmp = y * 1.0;
                	} else {
                		tmp = t_1;
                	}
                	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) :: t_0
                    real(8) :: t_1
                    real(8) :: tmp
                    t_0 = (x + y) * (1.0d0 - z)
                    t_1 = -z * x
                    if (t_0 <= (-5d+289)) then
                        tmp = t_1
                    else if (t_0 <= (-5d-248)) then
                        tmp = 1.0d0 * x
                    else if (t_0 <= 5d+304) then
                        tmp = y * 1.0d0
                    else
                        tmp = t_1
                    end if
                    code = tmp
                end function
                
                public static double code(double x, double y, double z) {
                	double t_0 = (x + y) * (1.0 - z);
                	double t_1 = -z * x;
                	double tmp;
                	if (t_0 <= -5e+289) {
                		tmp = t_1;
                	} else if (t_0 <= -5e-248) {
                		tmp = 1.0 * x;
                	} else if (t_0 <= 5e+304) {
                		tmp = y * 1.0;
                	} else {
                		tmp = t_1;
                	}
                	return tmp;
                }
                
                def code(x, y, z):
                	t_0 = (x + y) * (1.0 - z)
                	t_1 = -z * x
                	tmp = 0
                	if t_0 <= -5e+289:
                		tmp = t_1
                	elif t_0 <= -5e-248:
                		tmp = 1.0 * x
                	elif t_0 <= 5e+304:
                		tmp = y * 1.0
                	else:
                		tmp = t_1
                	return tmp
                
                function code(x, y, z)
                	t_0 = Float64(Float64(x + y) * Float64(1.0 - z))
                	t_1 = Float64(Float64(-z) * x)
                	tmp = 0.0
                	if (t_0 <= -5e+289)
                		tmp = t_1;
                	elseif (t_0 <= -5e-248)
                		tmp = Float64(1.0 * x);
                	elseif (t_0 <= 5e+304)
                		tmp = Float64(y * 1.0);
                	else
                		tmp = t_1;
                	end
                	return tmp
                end
                
                function tmp_2 = code(x, y, z)
                	t_0 = (x + y) * (1.0 - z);
                	t_1 = -z * x;
                	tmp = 0.0;
                	if (t_0 <= -5e+289)
                		tmp = t_1;
                	elseif (t_0 <= -5e-248)
                		tmp = 1.0 * x;
                	elseif (t_0 <= 5e+304)
                		tmp = y * 1.0;
                	else
                		tmp = t_1;
                	end
                	tmp_2 = tmp;
                end
                
                code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x + y), $MachinePrecision] * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[((-z) * x), $MachinePrecision]}, If[LessEqual[t$95$0, -5e+289], t$95$1, If[LessEqual[t$95$0, -5e-248], N[(1.0 * x), $MachinePrecision], If[LessEqual[t$95$0, 5e+304], N[(y * 1.0), $MachinePrecision], t$95$1]]]]]
                
                \begin{array}{l}
                
                \\
                \begin{array}{l}
                t_0 := \left(x + y\right) \cdot \left(1 - z\right)\\
                t_1 := \left(-z\right) \cdot x\\
                \mathbf{if}\;t\_0 \leq -5 \cdot 10^{+289}:\\
                \;\;\;\;t\_1\\
                
                \mathbf{elif}\;t\_0 \leq -5 \cdot 10^{-248}:\\
                \;\;\;\;1 \cdot x\\
                
                \mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+304}:\\
                \;\;\;\;y \cdot 1\\
                
                \mathbf{else}:\\
                \;\;\;\;t\_1\\
                
                
                \end{array}
                \end{array}
                
                Derivation
                1. Split input into 3 regimes
                2. if (*.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) z)) < -5.00000000000000031e289 or 4.9999999999999997e304 < (*.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) z))

                  1. Initial program 100.0%

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

                    \[\leadsto \color{blue}{x \cdot \left(1 - z\right)} \]
                  3. Step-by-step derivation
                    1. *-commutativeN/A

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

                      \[\leadsto \left(1 - z\right) \cdot \color{blue}{x} \]
                    3. lift--.f6452.1

                      \[\leadsto \left(1 - z\right) \cdot x \]
                  4. Applied rewrites52.1%

                    \[\leadsto \color{blue}{\left(1 - z\right) \cdot x} \]
                  5. Taylor expanded in z around inf

                    \[\leadsto \left(-1 \cdot z\right) \cdot x \]
                  6. Step-by-step derivation
                    1. mul-1-negN/A

                      \[\leadsto \left(\mathsf{neg}\left(z\right)\right) \cdot x \]
                    2. lower-neg.f6428.1

                      \[\leadsto \left(-z\right) \cdot x \]
                  7. Applied rewrites28.1%

                    \[\leadsto \left(-z\right) \cdot x \]

                  if -5.00000000000000031e289 < (*.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) z)) < -5.0000000000000001e-248

                  1. Initial program 100.0%

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

                    \[\leadsto \color{blue}{x \cdot \left(1 - z\right)} \]
                  3. Step-by-step derivation
                    1. *-commutativeN/A

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

                      \[\leadsto \left(1 - z\right) \cdot \color{blue}{x} \]
                    3. lift--.f6452.1

                      \[\leadsto \left(1 - z\right) \cdot x \]
                  4. Applied rewrites52.1%

                    \[\leadsto \color{blue}{\left(1 - z\right) \cdot x} \]
                  5. Taylor expanded in z around inf

                    \[\leadsto \left(-1 \cdot z\right) \cdot x \]
                  6. Step-by-step derivation
                    1. mul-1-negN/A

                      \[\leadsto \left(\mathsf{neg}\left(z\right)\right) \cdot x \]
                    2. lower-neg.f6428.1

                      \[\leadsto \left(-z\right) \cdot x \]
                  7. Applied rewrites28.1%

                    \[\leadsto \left(-z\right) \cdot x \]
                  8. Taylor expanded in z around 0

                    \[\leadsto 1 \cdot x \]
                  9. Step-by-step derivation
                    1. Applied rewrites26.1%

                      \[\leadsto 1 \cdot x \]

                    if -5.0000000000000001e-248 < (*.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) z)) < 4.9999999999999997e304

                    1. Initial program 100.0%

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

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

                        \[\leadsto \color{blue}{y} \cdot \left(1 - z\right) \]
                      2. Taylor expanded in z around inf

                        \[\leadsto y \cdot \color{blue}{\left(-1 \cdot z\right)} \]
                      3. Step-by-step derivation
                        1. mul-1-negN/A

                          \[\leadsto y \cdot \left(\mathsf{neg}\left(z\right)\right) \]
                        2. lower-neg.f6426.9

                          \[\leadsto y \cdot \left(-z\right) \]
                      4. Applied rewrites26.9%

                        \[\leadsto y \cdot \color{blue}{\left(-z\right)} \]
                      5. Taylor expanded in z around 0

                        \[\leadsto y \cdot \color{blue}{1} \]
                      6. Step-by-step derivation
                        1. Applied rewrites26.5%

                          \[\leadsto y \cdot \color{blue}{1} \]
                      7. Recombined 3 regimes into one program.
                      8. Add Preprocessing

                      Alternative 7: 26.7% accurate, 0.6× speedup?

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

                        1. Initial program 100.0%

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

                          \[\leadsto \color{blue}{x \cdot \left(1 - z\right)} \]
                        3. Step-by-step derivation
                          1. *-commutativeN/A

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

                            \[\leadsto \left(1 - z\right) \cdot \color{blue}{x} \]
                          3. lift--.f6452.1

                            \[\leadsto \left(1 - z\right) \cdot x \]
                        4. Applied rewrites52.1%

                          \[\leadsto \color{blue}{\left(1 - z\right) \cdot x} \]
                        5. Taylor expanded in z around inf

                          \[\leadsto \left(-1 \cdot z\right) \cdot x \]
                        6. Step-by-step derivation
                          1. mul-1-negN/A

                            \[\leadsto \left(\mathsf{neg}\left(z\right)\right) \cdot x \]
                          2. lower-neg.f6428.1

                            \[\leadsto \left(-z\right) \cdot x \]
                        7. Applied rewrites28.1%

                          \[\leadsto \left(-z\right) \cdot x \]
                        8. Taylor expanded in z around 0

                          \[\leadsto 1 \cdot x \]
                        9. Step-by-step derivation
                          1. Applied rewrites26.1%

                            \[\leadsto 1 \cdot x \]

                          if -5.0000000000000001e-248 < (*.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) z))

                          1. Initial program 100.0%

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

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

                              \[\leadsto \color{blue}{y} \cdot \left(1 - z\right) \]
                            2. Taylor expanded in z around inf

                              \[\leadsto y \cdot \color{blue}{\left(-1 \cdot z\right)} \]
                            3. Step-by-step derivation
                              1. mul-1-negN/A

                                \[\leadsto y \cdot \left(\mathsf{neg}\left(z\right)\right) \]
                              2. lower-neg.f6426.9

                                \[\leadsto y \cdot \left(-z\right) \]
                            4. Applied rewrites26.9%

                              \[\leadsto y \cdot \color{blue}{\left(-z\right)} \]
                            5. Taylor expanded in z around 0

                              \[\leadsto y \cdot \color{blue}{1} \]
                            6. Step-by-step derivation
                              1. Applied rewrites26.5%

                                \[\leadsto y \cdot \color{blue}{1} \]
                            7. Recombined 2 regimes into one program.
                            8. Add Preprocessing

                            Alternative 8: 26.1% accurate, 2.4× speedup?

                            \[\begin{array}{l} \\ 1 \cdot x \end{array} \]
                            (FPCore (x y z) :precision binary64 (* 1.0 x))
                            double code(double x, double y, double z) {
                            	return 1.0 * x;
                            }
                            
                            module fmin_fmax_functions
                                implicit none
                                private
                                public fmax
                                public fmin
                            
                                interface fmax
                                    module procedure fmax88
                                    module procedure fmax44
                                    module procedure fmax84
                                    module procedure fmax48
                                end interface
                                interface fmin
                                    module procedure fmin88
                                    module procedure fmin44
                                    module procedure fmin84
                                    module procedure fmin48
                                end interface
                            contains
                                real(8) function fmax88(x, y) result (res)
                                    real(8), intent (in) :: x
                                    real(8), intent (in) :: y
                                    res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                end function
                                real(4) function fmax44(x, y) result (res)
                                    real(4), intent (in) :: x
                                    real(4), intent (in) :: y
                                    res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                end function
                                real(8) function fmax84(x, y) result(res)
                                    real(8), intent (in) :: x
                                    real(4), intent (in) :: y
                                    res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                                end function
                                real(8) function fmax48(x, y) result(res)
                                    real(4), intent (in) :: x
                                    real(8), intent (in) :: y
                                    res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                                end function
                                real(8) function fmin88(x, y) result (res)
                                    real(8), intent (in) :: x
                                    real(8), intent (in) :: y
                                    res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                end function
                                real(4) function fmin44(x, y) result (res)
                                    real(4), intent (in) :: x
                                    real(4), intent (in) :: y
                                    res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                end function
                                real(8) function fmin84(x, y) result(res)
                                    real(8), intent (in) :: x
                                    real(4), intent (in) :: y
                                    res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                                end function
                                real(8) function fmin48(x, y) result(res)
                                    real(4), intent (in) :: x
                                    real(8), intent (in) :: y
                                    res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                                end function
                            end module
                            
                            real(8) function code(x, y, z)
                            use fmin_fmax_functions
                                real(8), intent (in) :: x
                                real(8), intent (in) :: y
                                real(8), intent (in) :: z
                                code = 1.0d0 * x
                            end function
                            
                            public static double code(double x, double y, double z) {
                            	return 1.0 * x;
                            }
                            
                            def code(x, y, z):
                            	return 1.0 * x
                            
                            function code(x, y, z)
                            	return Float64(1.0 * x)
                            end
                            
                            function tmp = code(x, y, z)
                            	tmp = 1.0 * x;
                            end
                            
                            code[x_, y_, z_] := N[(1.0 * x), $MachinePrecision]
                            
                            \begin{array}{l}
                            
                            \\
                            1 \cdot x
                            \end{array}
                            
                            Derivation
                            1. Initial program 100.0%

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

                              \[\leadsto \color{blue}{x \cdot \left(1 - z\right)} \]
                            3. Step-by-step derivation
                              1. *-commutativeN/A

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

                                \[\leadsto \left(1 - z\right) \cdot \color{blue}{x} \]
                              3. lift--.f6452.1

                                \[\leadsto \left(1 - z\right) \cdot x \]
                            4. Applied rewrites52.1%

                              \[\leadsto \color{blue}{\left(1 - z\right) \cdot x} \]
                            5. Taylor expanded in z around inf

                              \[\leadsto \left(-1 \cdot z\right) \cdot x \]
                            6. Step-by-step derivation
                              1. mul-1-negN/A

                                \[\leadsto \left(\mathsf{neg}\left(z\right)\right) \cdot x \]
                              2. lower-neg.f6428.1

                                \[\leadsto \left(-z\right) \cdot x \]
                            7. Applied rewrites28.1%

                              \[\leadsto \left(-z\right) \cdot x \]
                            8. Taylor expanded in z around 0

                              \[\leadsto 1 \cdot x \]
                            9. Step-by-step derivation
                              1. Applied rewrites26.1%

                                \[\leadsto 1 \cdot x \]
                              2. Add Preprocessing

                              Reproduce

                              ?
                              herbie shell --seed 2025131 
                              (FPCore (x y z)
                                :name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, H"
                                :precision binary64
                                (* (+ x y) (- 1.0 z)))