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

Percentage Accurate: 100.0% → 100.0%
Time: 2.5s
Alternatives: 7
Speedup: 1.0×

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 7 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, 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 2: 52.1% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x + y \leq -1 \cdot 10^{-270}:\\ \;\;\;\;\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) -1e-270) (* (- 1.0 z) x) (* y (- 1.0 z))))
double code(double x, double y, double z) {
	double tmp;
	if ((x + y) <= -1e-270) {
		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) <= (-1d-270)) 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) <= -1e-270) {
		tmp = (1.0 - z) * x;
	} else {
		tmp = y * (1.0 - z);
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (x + y) <= -1e-270:
		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) <= -1e-270)
		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) <= -1e-270)
		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], -1e-270], 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 -1 \cdot 10^{-270}:\\
\;\;\;\;\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) < -1e-270

    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--.f6451.8

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

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

    if -1e-270 < (+.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.3%

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

    Alternative 3: 39.9% accurate, 0.4× speedup?

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

      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--.f6451.8

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

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

      if 4.99999999999999989e-257 < (+.f64 x y) < 9.9999999999999992e-72 or 5.0000000000000002e191 < (+.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.3%

          \[\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.8

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

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

        if 9.9999999999999992e-72 < (+.f64 x y) < 5.0000000000000002e191

        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.3%

            \[\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.8

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

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

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

          Alternative 4: 37.6% accurate, 0.2× speedup?

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

            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--.f6451.8

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

              \[\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.f6427.7

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

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

            if -4.9999999999999998e290 < (*.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) z)) < -1e-270

            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--.f6451.8

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

              \[\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.f6427.7

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

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

                \[\leadsto 1 \cdot x \]

              if -1e-270 < (*.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) z)) < 4.99999999999999993e306

              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.3%

                  \[\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.8

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

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

                    \[\leadsto y \cdot \color{blue}{1} \]

                  if 4.99999999999999993e306 < (*.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.3%

                      \[\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.8

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

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

                  Alternative 5: 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^{+290}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_0 \leq -1 \cdot 10^{-270}:\\ \;\;\;\;1 \cdot x\\ \mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+306}:\\ \;\;\;\;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+290)
                       t_1
                       (if (<= t_0 -1e-270) (* 1.0 x) (if (<= t_0 5e+306) (* 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+290) {
                  		tmp = t_1;
                  	} else if (t_0 <= -1e-270) {
                  		tmp = 1.0 * x;
                  	} else if (t_0 <= 5e+306) {
                  		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+290)) then
                          tmp = t_1
                      else if (t_0 <= (-1d-270)) then
                          tmp = 1.0d0 * x
                      else if (t_0 <= 5d+306) 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+290) {
                  		tmp = t_1;
                  	} else if (t_0 <= -1e-270) {
                  		tmp = 1.0 * x;
                  	} else if (t_0 <= 5e+306) {
                  		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+290:
                  		tmp = t_1
                  	elif t_0 <= -1e-270:
                  		tmp = 1.0 * x
                  	elif t_0 <= 5e+306:
                  		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+290)
                  		tmp = t_1;
                  	elseif (t_0 <= -1e-270)
                  		tmp = Float64(1.0 * x);
                  	elseif (t_0 <= 5e+306)
                  		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+290)
                  		tmp = t_1;
                  	elseif (t_0 <= -1e-270)
                  		tmp = 1.0 * x;
                  	elseif (t_0 <= 5e+306)
                  		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+290], t$95$1, If[LessEqual[t$95$0, -1e-270], N[(1.0 * x), $MachinePrecision], If[LessEqual[t$95$0, 5e+306], 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^{+290}:\\
                  \;\;\;\;t\_1\\
                  
                  \mathbf{elif}\;t\_0 \leq -1 \cdot 10^{-270}:\\
                  \;\;\;\;1 \cdot x\\
                  
                  \mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+306}:\\
                  \;\;\;\;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)) < -4.9999999999999998e290 or 4.99999999999999993e306 < (*.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--.f6451.8

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

                      \[\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.f6427.7

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

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

                    if -4.9999999999999998e290 < (*.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) z)) < -1e-270

                    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--.f6451.8

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

                      \[\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.f6427.7

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

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

                        \[\leadsto 1 \cdot x \]

                      if -1e-270 < (*.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) z)) < 4.99999999999999993e306

                      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.3%

                          \[\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.8

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

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

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

                        Alternative 6: 26.6% accurate, 0.6× speedup?

                        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\left(x + y\right) \cdot \left(1 - z\right) \leq -1 \cdot 10^{-270}:\\ \;\;\;\;1 \cdot x\\ \mathbf{else}:\\ \;\;\;\;y \cdot 1\\ \end{array} \end{array} \]
                        (FPCore (x y z)
                         :precision binary64
                         (if (<= (* (+ x y) (- 1.0 z)) -1e-270) (* 1.0 x) (* y 1.0)))
                        double code(double x, double y, double z) {
                        	double tmp;
                        	if (((x + y) * (1.0 - z)) <= -1e-270) {
                        		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)) <= (-1d-270)) 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)) <= -1e-270) {
                        		tmp = 1.0 * x;
                        	} else {
                        		tmp = y * 1.0;
                        	}
                        	return tmp;
                        }
                        
                        def code(x, y, z):
                        	tmp = 0
                        	if ((x + y) * (1.0 - z)) <= -1e-270:
                        		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)) <= -1e-270)
                        		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)) <= -1e-270)
                        		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], -1e-270], 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 -1 \cdot 10^{-270}:\\
                        \;\;\;\;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)) < -1e-270

                          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--.f6451.8

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

                            \[\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.f6427.7

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

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

                              \[\leadsto 1 \cdot x \]

                            if -1e-270 < (*.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.3%

                                \[\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.8

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

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

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

                              Alternative 7: 26.2% 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--.f6451.8

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

                                \[\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.f6427.7

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

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

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

                                Reproduce

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