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

Percentage Accurate: 100.0% → 100.0%
Time: 4.5s
Alternatives: 6
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}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 6 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
  3. Add Preprocessing

Alternative 2: 74.9% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(-z\right) \cdot x\\ \mathbf{if}\;z \leq -105:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq 1:\\ \;\;\;\;x + y\\ \mathbf{elif}\;z \leq 3 \cdot 10^{+51} \lor \neg \left(z \leq 1.8 \cdot 10^{+141}\right):\\ \;\;\;\;\left(-y\right) \cdot z\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* (- z) x)))
   (if (<= z -105.0)
     t_0
     (if (<= z 1.0)
       (+ x y)
       (if (or (<= z 3e+51) (not (<= z 1.8e+141))) (* (- y) z) t_0)))))
double code(double x, double y, double z) {
	double t_0 = -z * x;
	double tmp;
	if (z <= -105.0) {
		tmp = t_0;
	} else if (z <= 1.0) {
		tmp = x + y;
	} else if ((z <= 3e+51) || !(z <= 1.8e+141)) {
		tmp = -y * z;
	} 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 = -z * x
    if (z <= (-105.0d0)) then
        tmp = t_0
    else if (z <= 1.0d0) then
        tmp = x + y
    else if ((z <= 3d+51) .or. (.not. (z <= 1.8d+141))) then
        tmp = -y * z
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = -z * x;
	double tmp;
	if (z <= -105.0) {
		tmp = t_0;
	} else if (z <= 1.0) {
		tmp = x + y;
	} else if ((z <= 3e+51) || !(z <= 1.8e+141)) {
		tmp = -y * z;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = -z * x
	tmp = 0
	if z <= -105.0:
		tmp = t_0
	elif z <= 1.0:
		tmp = x + y
	elif (z <= 3e+51) or not (z <= 1.8e+141):
		tmp = -y * z
	else:
		tmp = t_0
	return tmp
function code(x, y, z)
	t_0 = Float64(Float64(-z) * x)
	tmp = 0.0
	if (z <= -105.0)
		tmp = t_0;
	elseif (z <= 1.0)
		tmp = Float64(x + y);
	elseif ((z <= 3e+51) || !(z <= 1.8e+141))
		tmp = Float64(Float64(-y) * z);
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = -z * x;
	tmp = 0.0;
	if (z <= -105.0)
		tmp = t_0;
	elseif (z <= 1.0)
		tmp = x + y;
	elseif ((z <= 3e+51) || ~((z <= 1.8e+141)))
		tmp = -y * z;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[((-z) * x), $MachinePrecision]}, If[LessEqual[z, -105.0], t$95$0, If[LessEqual[z, 1.0], N[(x + y), $MachinePrecision], If[Or[LessEqual[z, 3e+51], N[Not[LessEqual[z, 1.8e+141]], $MachinePrecision]], N[((-y) * z), $MachinePrecision], t$95$0]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(-z\right) \cdot x\\
\mathbf{if}\;z \leq -105:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;z \leq 1:\\
\;\;\;\;x + y\\

\mathbf{elif}\;z \leq 3 \cdot 10^{+51} \lor \neg \left(z \leq 1.8 \cdot 10^{+141}\right):\\
\;\;\;\;\left(-y\right) \cdot z\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -105 or 3e51 < z < 1.8000000000000001e141

    1. Initial program 100.0%

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

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

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

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

        \[\leadsto \color{blue}{\left(1 - z\right)} \cdot x \]
    5. Applied rewrites49.6%

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

      \[\leadsto \left(-1 \cdot z\right) \cdot x \]
    7. Step-by-step derivation
      1. Applied rewrites49.6%

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

      if -105 < z < 1

      1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{y \cdot \left(1 - {z}^{2}\right)}{1 + z}} \]
      6. Applied rewrites51.9%

        \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(z, z, -1\right)}{-1 - z} \cdot y} \]
      7. Step-by-step derivation
        1. Applied rewrites51.9%

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

          \[\leadsto \color{blue}{x + y} \]
        3. Step-by-step derivation
          1. lower-+.f6498.3

            \[\leadsto \color{blue}{x + y} \]
        4. Applied rewrites98.3%

          \[\leadsto \color{blue}{x + y} \]

        if 1 < z < 3e51 or 1.8000000000000001e141 < z

        1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \frac{\left(1 - z \cdot z\right) \cdot \left(y + x\right)}{\color{blue}{z + 1}} \]
        4. Applied rewrites67.1%

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

          \[\leadsto \color{blue}{\frac{y \cdot \left(1 - {z}^{2}\right)}{1 + z}} \]
        6. Applied rewrites42.6%

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

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

            \[\leadsto \left(-y\right) \cdot \color{blue}{z} \]
        9. Recombined 3 regimes into one program.
        10. Final simplification73.1%

          \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -105:\\ \;\;\;\;\left(-z\right) \cdot x\\ \mathbf{elif}\;z \leq 1:\\ \;\;\;\;x + y\\ \mathbf{elif}\;z \leq 3 \cdot 10^{+51} \lor \neg \left(z \leq 1.8 \cdot 10^{+141}\right):\\ \;\;\;\;\left(-y\right) \cdot z\\ \mathbf{else}:\\ \;\;\;\;\left(-z\right) \cdot x\\ \end{array} \]
        11. Add Preprocessing

        Alternative 3: 75.2% accurate, 0.4× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -105:\\ \;\;\;\;\left(-z\right) \cdot x\\ \mathbf{elif}\;z \leq 5.2 \cdot 10^{-8}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;z \leq 1.8 \cdot 10^{+141}:\\ \;\;\;\;\mathsf{fma}\left(-z, x, x\right)\\ \mathbf{else}:\\ \;\;\;\;\left(-y\right) \cdot z\\ \end{array} \end{array} \]
        (FPCore (x y z)
         :precision binary64
         (if (<= z -105.0)
           (* (- z) x)
           (if (<= z 5.2e-8)
             (+ x y)
             (if (<= z 1.8e+141) (fma (- z) x x) (* (- y) z)))))
        double code(double x, double y, double z) {
        	double tmp;
        	if (z <= -105.0) {
        		tmp = -z * x;
        	} else if (z <= 5.2e-8) {
        		tmp = x + y;
        	} else if (z <= 1.8e+141) {
        		tmp = fma(-z, x, x);
        	} else {
        		tmp = -y * z;
        	}
        	return tmp;
        }
        
        function code(x, y, z)
        	tmp = 0.0
        	if (z <= -105.0)
        		tmp = Float64(Float64(-z) * x);
        	elseif (z <= 5.2e-8)
        		tmp = Float64(x + y);
        	elseif (z <= 1.8e+141)
        		tmp = fma(Float64(-z), x, x);
        	else
        		tmp = Float64(Float64(-y) * z);
        	end
        	return tmp
        end
        
        code[x_, y_, z_] := If[LessEqual[z, -105.0], N[((-z) * x), $MachinePrecision], If[LessEqual[z, 5.2e-8], N[(x + y), $MachinePrecision], If[LessEqual[z, 1.8e+141], N[((-z) * x + x), $MachinePrecision], N[((-y) * z), $MachinePrecision]]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;z \leq -105:\\
        \;\;\;\;\left(-z\right) \cdot x\\
        
        \mathbf{elif}\;z \leq 5.2 \cdot 10^{-8}:\\
        \;\;\;\;x + y\\
        
        \mathbf{elif}\;z \leq 1.8 \cdot 10^{+141}:\\
        \;\;\;\;\mathsf{fma}\left(-z, x, x\right)\\
        
        \mathbf{else}:\\
        \;\;\;\;\left(-y\right) \cdot z\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 4 regimes
        2. if z < -105

          1. Initial program 100.0%

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

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

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

              \[\leadsto \color{blue}{\left(1 - z\right) \cdot x} \]
            3. lower--.f6451.2

              \[\leadsto \color{blue}{\left(1 - z\right)} \cdot x \]
          5. Applied rewrites51.2%

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

            \[\leadsto \left(-1 \cdot z\right) \cdot x \]
          7. Step-by-step derivation
            1. Applied rewrites51.2%

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

            if -105 < z < 5.2000000000000002e-8

            1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \color{blue}{\frac{y \cdot \left(1 - {z}^{2}\right)}{1 + z}} \]
            6. Applied rewrites51.9%

              \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(z, z, -1\right)}{-1 - z} \cdot y} \]
            7. Step-by-step derivation
              1. Applied rewrites51.9%

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

                \[\leadsto \color{blue}{x + y} \]
              3. Step-by-step derivation
                1. lower-+.f6498.3

                  \[\leadsto \color{blue}{x + y} \]
              4. Applied rewrites98.3%

                \[\leadsto \color{blue}{x + y} \]

              if 5.2000000000000002e-8 < z < 1.8000000000000001e141

              1. Initial program 99.9%

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

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

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

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

                  \[\leadsto \color{blue}{\left(1 - z\right)} \cdot x \]
              5. Applied rewrites46.1%

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

                \[\leadsto x + \color{blue}{-1 \cdot \left(x \cdot z\right)} \]
              7. Step-by-step derivation
                1. Applied rewrites46.1%

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

                if 1.8000000000000001e141 < z

                1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto \frac{\left(1 - z \cdot z\right) \cdot \left(y + x\right)}{\color{blue}{z + 1}} \]
                4. Applied rewrites58.5%

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

                  \[\leadsto \color{blue}{\frac{y \cdot \left(1 - {z}^{2}\right)}{1 + z}} \]
                6. Applied rewrites39.8%

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

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

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

                Alternative 4: 75.0% accurate, 0.5× speedup?

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

                  1. Initial program 100.0%

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

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

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

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

                      \[\leadsto \color{blue}{\left(1 - z\right)} \cdot x \]
                  5. Applied rewrites54.6%

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

                    \[\leadsto \left(-1 \cdot z\right) \cdot x \]
                  7. Step-by-step derivation
                    1. Applied rewrites54.5%

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

                    if -20 < (-.f64 #s(literal 1 binary64) z) < 2

                    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                      \[\leadsto \color{blue}{\frac{y \cdot \left(1 - {z}^{2}\right)}{1 + z}} \]
                    6. Applied rewrites51.9%

                      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(z, z, -1\right)}{-1 - z} \cdot y} \]
                    7. Step-by-step derivation
                      1. Applied rewrites51.9%

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

                        \[\leadsto \color{blue}{x + y} \]
                      3. Step-by-step derivation
                        1. lower-+.f6498.3

                          \[\leadsto \color{blue}{x + y} \]
                      4. Applied rewrites98.3%

                        \[\leadsto \color{blue}{x + y} \]
                    8. Recombined 2 regimes into one program.
                    9. Final simplification76.5%

                      \[\leadsto \begin{array}{l} \mathbf{if}\;1 - z \leq -20 \lor \neg \left(1 - z \leq 2\right):\\ \;\;\;\;\left(-z\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;x + y\\ \end{array} \]
                    10. Add Preprocessing

                    Alternative 5: 51.7% accurate, 0.7× speedup?

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

                      1. Initial program 100.0%

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

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

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

                          \[\leadsto \color{blue}{\left(1 - z\right) \cdot x} \]
                        3. lower--.f6453.0

                          \[\leadsto \color{blue}{\left(1 - z\right)} \cdot x \]
                      5. Applied rewrites53.0%

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

                        \[\leadsto x + \color{blue}{-1 \cdot \left(x \cdot z\right)} \]
                      7. Step-by-step derivation
                        1. Applied rewrites53.0%

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

                        if -4.0000000000000001e-282 < (+.f64 x y)

                        1. Initial program 100.0%

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

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

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

                            \[\leadsto \color{blue}{\left(1 - z\right) \cdot y} \]
                          3. lower--.f6452.5

                            \[\leadsto \color{blue}{\left(1 - z\right)} \cdot y \]
                        5. Applied rewrites52.5%

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

                      Alternative 6: 51.1% accurate, 3.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                          \[\leadsto \frac{\left(1 - z \cdot z\right) \cdot \left(y + x\right)}{\color{blue}{z + 1}} \]
                      4. Applied rewrites86.1%

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

                        \[\leadsto \color{blue}{\frac{y \cdot \left(1 - {z}^{2}\right)}{1 + z}} \]
                      6. Applied rewrites50.4%

                        \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(z, z, -1\right)}{-1 - z} \cdot y} \]
                      7. Step-by-step derivation
                        1. Applied rewrites52.6%

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

                          \[\leadsto \color{blue}{x + y} \]
                        3. Step-by-step derivation
                          1. lower-+.f6451.2

                            \[\leadsto \color{blue}{x + y} \]
                        4. Applied rewrites51.2%

                          \[\leadsto \color{blue}{x + y} \]
                        5. Add Preprocessing

                        Reproduce

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