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

Percentage Accurate: 92.9% → 97.7%
Time: 3.6s
Alternatives: 10
Speedup: 1.1×

Specification

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

\\
x + \frac{y \cdot \left(z - x\right)}{t}
\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 10 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: 92.9% accurate, 1.0× speedup?

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

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

Alternative 1: 97.7% accurate, 1.1× speedup?

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(\color{blue}{z - x}, \frac{y}{t}, x\right) \]
    10. lower-/.f6498.0

      \[\leadsto \mathsf{fma}\left(z - x, \color{blue}{\frac{y}{t}}, x\right) \]
  4. Applied rewrites98.0%

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

Alternative 2: 85.6% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1.6 \cdot 10^{+19} \lor \neg \left(x \leq 3.7 \cdot 10^{+106}\right):\\ \;\;\;\;\left(1 - \frac{y}{t}\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y}{t} \cdot z\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (or (<= x -1.6e+19) (not (<= x 3.7e+106)))
   (* (- 1.0 (/ y t)) x)
   (+ x (* (/ y t) z))))
double code(double x, double y, double z, double t) {
	double tmp;
	if ((x <= -1.6e+19) || !(x <= 3.7e+106)) {
		tmp = (1.0 - (y / t)) * x;
	} else {
		tmp = x + ((y / t) * 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, t)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: tmp
    if ((x <= (-1.6d+19)) .or. (.not. (x <= 3.7d+106))) then
        tmp = (1.0d0 - (y / t)) * x
    else
        tmp = x + ((y / t) * z)
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double tmp;
	if ((x <= -1.6e+19) || !(x <= 3.7e+106)) {
		tmp = (1.0 - (y / t)) * x;
	} else {
		tmp = x + ((y / t) * z);
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if (x <= -1.6e+19) or not (x <= 3.7e+106):
		tmp = (1.0 - (y / t)) * x
	else:
		tmp = x + ((y / t) * z)
	return tmp
function code(x, y, z, t)
	tmp = 0.0
	if ((x <= -1.6e+19) || !(x <= 3.7e+106))
		tmp = Float64(Float64(1.0 - Float64(y / t)) * x);
	else
		tmp = Float64(x + Float64(Float64(y / t) * z));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if ((x <= -1.6e+19) || ~((x <= 3.7e+106)))
		tmp = (1.0 - (y / t)) * x;
	else
		tmp = x + ((y / t) * z);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := If[Or[LessEqual[x, -1.6e+19], N[Not[LessEqual[x, 3.7e+106]], $MachinePrecision]], N[(N[(1.0 - N[(y / t), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], N[(x + N[(N[(y / t), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.6 \cdot 10^{+19} \lor \neg \left(x \leq 3.7 \cdot 10^{+106}\right):\\
\;\;\;\;\left(1 - \frac{y}{t}\right) \cdot x\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.6e19 or 3.69999999999999995e106 < x

    1. Initial program 92.6%

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

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

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

        \[\leadsto \left(1 + -1 \cdot \frac{y}{t}\right) \cdot \color{blue}{x} \]
      3. cancel-sign-subN/A

        \[\leadsto \left(1 - \left(\mathsf{neg}\left(-1\right)\right) \cdot \frac{y}{t}\right) \cdot x \]
      4. metadata-evalN/A

        \[\leadsto \left(1 - 1 \cdot \frac{y}{t}\right) \cdot x \]
      5. *-lft-identityN/A

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

        \[\leadsto \left(1 - \frac{y}{t}\right) \cdot x \]
      7. lower-/.f6494.4

        \[\leadsto \left(1 - \frac{y}{t}\right) \cdot x \]
    5. Applied rewrites94.4%

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

    if -1.6e19 < x < 3.69999999999999995e106

    1. Initial program 91.7%

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

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

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

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

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

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

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

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

        \[\leadsto x + \mathsf{fma}\left(\frac{-1 \cdot x}{t}, \frac{y}{z}, \frac{y}{t}\right) \cdot z \]
      8. mul-1-negN/A

        \[\leadsto x + \mathsf{fma}\left(\frac{\mathsf{neg}\left(x\right)}{t}, \frac{y}{z}, \frac{y}{t}\right) \cdot z \]
      9. lower-neg.f64N/A

        \[\leadsto x + \mathsf{fma}\left(\frac{-x}{t}, \frac{y}{z}, \frac{y}{t}\right) \cdot z \]
      10. lower-/.f64N/A

        \[\leadsto x + \mathsf{fma}\left(\frac{-x}{t}, \frac{y}{z}, \frac{y}{t}\right) \cdot z \]
      11. lower-/.f6482.4

        \[\leadsto x + \mathsf{fma}\left(\frac{-x}{t}, \frac{y}{z}, \frac{y}{t}\right) \cdot z \]
    5. Applied rewrites82.4%

      \[\leadsto x + \color{blue}{\mathsf{fma}\left(\frac{-x}{t}, \frac{y}{z}, \frac{y}{t}\right) \cdot z} \]
    6. Taylor expanded in x around 0

      \[\leadsto x + \frac{y}{t} \cdot z \]
    7. Step-by-step derivation
      1. lift-/.f6486.8

        \[\leadsto x + \frac{y}{t} \cdot z \]
    8. Applied rewrites86.8%

      \[\leadsto x + \frac{y}{t} \cdot z \]
  3. Recombined 2 regimes into one program.
  4. Final simplification89.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.6 \cdot 10^{+19} \lor \neg \left(x \leq 3.7 \cdot 10^{+106}\right):\\ \;\;\;\;\left(1 - \frac{y}{t}\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y}{t} \cdot z\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 84.3% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;t \leq -1.18 \cdot 10^{-33} \lor \neg \left(t \leq 11500\right):\\ \;\;\;\;\mathsf{fma}\left(y, \frac{z}{t}, x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(z - x\right) \cdot y}{t}\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (or (<= t -1.18e-33) (not (<= t 11500.0)))
   (fma y (/ z t) x)
   (/ (* (- z x) y) t)))
double code(double x, double y, double z, double t) {
	double tmp;
	if ((t <= -1.18e-33) || !(t <= 11500.0)) {
		tmp = fma(y, (z / t), x);
	} else {
		tmp = ((z - x) * y) / t;
	}
	return tmp;
}
function code(x, y, z, t)
	tmp = 0.0
	if ((t <= -1.18e-33) || !(t <= 11500.0))
		tmp = fma(y, Float64(z / t), x);
	else
		tmp = Float64(Float64(Float64(z - x) * y) / t);
	end
	return tmp
end
code[x_, y_, z_, t_] := If[Or[LessEqual[t, -1.18e-33], N[Not[LessEqual[t, 11500.0]], $MachinePrecision]], N[(y * N[(z / t), $MachinePrecision] + x), $MachinePrecision], N[(N[(N[(z - x), $MachinePrecision] * y), $MachinePrecision] / t), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.18 \cdot 10^{-33} \lor \neg \left(t \leq 11500\right):\\
\;\;\;\;\mathsf{fma}\left(y, \frac{z}{t}, x\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{\left(z - x\right) \cdot y}{t}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < -1.18e-33 or 11500 < t

    1. Initial program 86.5%

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

      \[\leadsto x + \frac{y \cdot \color{blue}{z}}{t} \]
    4. Step-by-step derivation
      1. Applied rewrites82.2%

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

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

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

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

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

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

          \[\leadsto \color{blue}{\mathsf{fma}\left(y, \frac{z}{t}, x\right)} \]
        7. lower-/.f6487.4

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

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

      if -1.18e-33 < t < 11500

      1. Initial program 99.8%

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

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

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

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

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

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

          \[\leadsto \frac{\left(z - x\right) \cdot y}{t} \]
        6. lift--.f6489.0

          \[\leadsto \frac{\left(z - x\right) \cdot y}{t} \]
      5. Applied rewrites89.0%

        \[\leadsto \color{blue}{\frac{\left(z - x\right) \cdot y}{t}} \]
    5. Recombined 2 regimes into one program.
    6. Final simplification88.1%

      \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -1.18 \cdot 10^{-33} \lor \neg \left(t \leq 11500\right):\\ \;\;\;\;\mathsf{fma}\left(y, \frac{z}{t}, x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(z - x\right) \cdot y}{t}\\ \end{array} \]
    7. Add Preprocessing

    Alternative 4: 83.8% accurate, 0.7× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -1.7 \cdot 10^{-35} \lor \neg \left(z \leq 2.8 \cdot 10^{-114}\right):\\ \;\;\;\;\mathsf{fma}\left(y, \frac{z}{t}, x\right)\\ \mathbf{else}:\\ \;\;\;\;\left(1 - \frac{y}{t}\right) \cdot x\\ \end{array} \end{array} \]
    (FPCore (x y z t)
     :precision binary64
     (if (or (<= z -1.7e-35) (not (<= z 2.8e-114)))
       (fma y (/ z t) x)
       (* (- 1.0 (/ y t)) x)))
    double code(double x, double y, double z, double t) {
    	double tmp;
    	if ((z <= -1.7e-35) || !(z <= 2.8e-114)) {
    		tmp = fma(y, (z / t), x);
    	} else {
    		tmp = (1.0 - (y / t)) * x;
    	}
    	return tmp;
    }
    
    function code(x, y, z, t)
    	tmp = 0.0
    	if ((z <= -1.7e-35) || !(z <= 2.8e-114))
    		tmp = fma(y, Float64(z / t), x);
    	else
    		tmp = Float64(Float64(1.0 - Float64(y / t)) * x);
    	end
    	return tmp
    end
    
    code[x_, y_, z_, t_] := If[Or[LessEqual[z, -1.7e-35], N[Not[LessEqual[z, 2.8e-114]], $MachinePrecision]], N[(y * N[(z / t), $MachinePrecision] + x), $MachinePrecision], N[(N[(1.0 - N[(y / t), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    \mathbf{if}\;z \leq -1.7 \cdot 10^{-35} \lor \neg \left(z \leq 2.8 \cdot 10^{-114}\right):\\
    \;\;\;\;\mathsf{fma}\left(y, \frac{z}{t}, x\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;\left(1 - \frac{y}{t}\right) \cdot x\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if z < -1.7000000000000001e-35 or 2.8000000000000001e-114 < z

      1. Initial program 89.6%

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

        \[\leadsto x + \frac{y \cdot \color{blue}{z}}{t} \]
      4. Step-by-step derivation
        1. Applied rewrites81.6%

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

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

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

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

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

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

            \[\leadsto \color{blue}{\mathsf{fma}\left(y, \frac{z}{t}, x\right)} \]
          7. lower-/.f6483.0

            \[\leadsto \mathsf{fma}\left(y, \color{blue}{\frac{z}{t}}, x\right) \]
        3. Applied rewrites83.0%

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

        if -1.7000000000000001e-35 < z < 2.8000000000000001e-114

        1. Initial program 95.4%

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

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

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

            \[\leadsto \left(1 + -1 \cdot \frac{y}{t}\right) \cdot \color{blue}{x} \]
          3. cancel-sign-subN/A

            \[\leadsto \left(1 - \left(\mathsf{neg}\left(-1\right)\right) \cdot \frac{y}{t}\right) \cdot x \]
          4. metadata-evalN/A

            \[\leadsto \left(1 - 1 \cdot \frac{y}{t}\right) \cdot x \]
          5. *-lft-identityN/A

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

            \[\leadsto \left(1 - \frac{y}{t}\right) \cdot x \]
          7. lower-/.f6491.8

            \[\leadsto \left(1 - \frac{y}{t}\right) \cdot x \]
        5. Applied rewrites91.8%

          \[\leadsto \color{blue}{\left(1 - \frac{y}{t}\right) \cdot x} \]
      5. Recombined 2 regimes into one program.
      6. Final simplification86.7%

        \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.7 \cdot 10^{-35} \lor \neg \left(z \leq 2.8 \cdot 10^{-114}\right):\\ \;\;\;\;\mathsf{fma}\left(y, \frac{z}{t}, x\right)\\ \mathbf{else}:\\ \;\;\;\;\left(1 - \frac{y}{t}\right) \cdot x\\ \end{array} \]
      7. Add Preprocessing

      Alternative 5: 85.6% accurate, 0.7× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1.6 \cdot 10^{+19}:\\ \;\;\;\;\mathsf{fma}\left(-x, \frac{y}{t}, x\right)\\ \mathbf{elif}\;x \leq 3.7 \cdot 10^{+106}:\\ \;\;\;\;x + \frac{y}{t} \cdot z\\ \mathbf{else}:\\ \;\;\;\;\left(1 - \frac{y}{t}\right) \cdot x\\ \end{array} \end{array} \]
      (FPCore (x y z t)
       :precision binary64
       (if (<= x -1.6e+19)
         (fma (- x) (/ y t) x)
         (if (<= x 3.7e+106) (+ x (* (/ y t) z)) (* (- 1.0 (/ y t)) x))))
      double code(double x, double y, double z, double t) {
      	double tmp;
      	if (x <= -1.6e+19) {
      		tmp = fma(-x, (y / t), x);
      	} else if (x <= 3.7e+106) {
      		tmp = x + ((y / t) * z);
      	} else {
      		tmp = (1.0 - (y / t)) * x;
      	}
      	return tmp;
      }
      
      function code(x, y, z, t)
      	tmp = 0.0
      	if (x <= -1.6e+19)
      		tmp = fma(Float64(-x), Float64(y / t), x);
      	elseif (x <= 3.7e+106)
      		tmp = Float64(x + Float64(Float64(y / t) * z));
      	else
      		tmp = Float64(Float64(1.0 - Float64(y / t)) * x);
      	end
      	return tmp
      end
      
      code[x_, y_, z_, t_] := If[LessEqual[x, -1.6e+19], N[((-x) * N[(y / t), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[x, 3.7e+106], N[(x + N[(N[(y / t), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - N[(y / t), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;x \leq -1.6 \cdot 10^{+19}:\\
      \;\;\;\;\mathsf{fma}\left(-x, \frac{y}{t}, x\right)\\
      
      \mathbf{elif}\;x \leq 3.7 \cdot 10^{+106}:\\
      \;\;\;\;x + \frac{y}{t} \cdot z\\
      
      \mathbf{else}:\\
      \;\;\;\;\left(1 - \frac{y}{t}\right) \cdot x\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 3 regimes
      2. if x < -1.6e19

        1. Initial program 91.3%

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

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

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

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

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

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

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

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

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

            \[\leadsto \mathsf{fma}\left(\color{blue}{z - x}, \frac{y}{t}, x\right) \]
          10. lower-/.f6499.9

            \[\leadsto \mathsf{fma}\left(z - x, \color{blue}{\frac{y}{t}}, x\right) \]
        4. Applied rewrites99.9%

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

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

            \[\leadsto \mathsf{fma}\left(\mathsf{neg}\left(x\right), \frac{y}{t}, x\right) \]
          2. lower-neg.f6491.2

            \[\leadsto \mathsf{fma}\left(-x, \frac{y}{t}, x\right) \]
        7. Applied rewrites91.2%

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

        if -1.6e19 < x < 3.69999999999999995e106

        1. Initial program 91.7%

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

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

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

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

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

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

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

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

            \[\leadsto x + \mathsf{fma}\left(\frac{-1 \cdot x}{t}, \frac{y}{z}, \frac{y}{t}\right) \cdot z \]
          8. mul-1-negN/A

            \[\leadsto x + \mathsf{fma}\left(\frac{\mathsf{neg}\left(x\right)}{t}, \frac{y}{z}, \frac{y}{t}\right) \cdot z \]
          9. lower-neg.f64N/A

            \[\leadsto x + \mathsf{fma}\left(\frac{-x}{t}, \frac{y}{z}, \frac{y}{t}\right) \cdot z \]
          10. lower-/.f64N/A

            \[\leadsto x + \mathsf{fma}\left(\frac{-x}{t}, \frac{y}{z}, \frac{y}{t}\right) \cdot z \]
          11. lower-/.f6482.4

            \[\leadsto x + \mathsf{fma}\left(\frac{-x}{t}, \frac{y}{z}, \frac{y}{t}\right) \cdot z \]
        5. Applied rewrites82.4%

          \[\leadsto x + \color{blue}{\mathsf{fma}\left(\frac{-x}{t}, \frac{y}{z}, \frac{y}{t}\right) \cdot z} \]
        6. Taylor expanded in x around 0

          \[\leadsto x + \frac{y}{t} \cdot z \]
        7. Step-by-step derivation
          1. lift-/.f6486.8

            \[\leadsto x + \frac{y}{t} \cdot z \]
        8. Applied rewrites86.8%

          \[\leadsto x + \frac{y}{t} \cdot z \]

        if 3.69999999999999995e106 < x

        1. Initial program 94.8%

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

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

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

            \[\leadsto \left(1 + -1 \cdot \frac{y}{t}\right) \cdot \color{blue}{x} \]
          3. cancel-sign-subN/A

            \[\leadsto \left(1 - \left(\mathsf{neg}\left(-1\right)\right) \cdot \frac{y}{t}\right) \cdot x \]
          4. metadata-evalN/A

            \[\leadsto \left(1 - 1 \cdot \frac{y}{t}\right) \cdot x \]
          5. *-lft-identityN/A

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

            \[\leadsto \left(1 - \frac{y}{t}\right) \cdot x \]
          7. lower-/.f64100.0

            \[\leadsto \left(1 - \frac{y}{t}\right) \cdot x \]
        5. Applied rewrites100.0%

          \[\leadsto \color{blue}{\left(1 - \frac{y}{t}\right) \cdot x} \]
      3. Recombined 3 regimes into one program.
      4. Final simplification89.9%

        \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.6 \cdot 10^{+19}:\\ \;\;\;\;\mathsf{fma}\left(-x, \frac{y}{t}, x\right)\\ \mathbf{elif}\;x \leq 3.7 \cdot 10^{+106}:\\ \;\;\;\;x + \frac{y}{t} \cdot z\\ \mathbf{else}:\\ \;\;\;\;\left(1 - \frac{y}{t}\right) \cdot x\\ \end{array} \]
      5. Add Preprocessing

      Alternative 6: 50.4% accurate, 0.8× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -9.5 \cdot 10^{-88}:\\ \;\;\;\;\frac{z \cdot y}{t}\\ \mathbf{elif}\;z \leq 2.65 \cdot 10^{-110}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{z}{t}\\ \end{array} \end{array} \]
      (FPCore (x y z t)
       :precision binary64
       (if (<= z -9.5e-88) (/ (* z y) t) (if (<= z 2.65e-110) x (* y (/ z t)))))
      double code(double x, double y, double z, double t) {
      	double tmp;
      	if (z <= -9.5e-88) {
      		tmp = (z * y) / t;
      	} else if (z <= 2.65e-110) {
      		tmp = x;
      	} else {
      		tmp = y * (z / t);
      	}
      	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, t)
      use fmin_fmax_functions
          real(8), intent (in) :: x
          real(8), intent (in) :: y
          real(8), intent (in) :: z
          real(8), intent (in) :: t
          real(8) :: tmp
          if (z <= (-9.5d-88)) then
              tmp = (z * y) / t
          else if (z <= 2.65d-110) then
              tmp = x
          else
              tmp = y * (z / t)
          end if
          code = tmp
      end function
      
      public static double code(double x, double y, double z, double t) {
      	double tmp;
      	if (z <= -9.5e-88) {
      		tmp = (z * y) / t;
      	} else if (z <= 2.65e-110) {
      		tmp = x;
      	} else {
      		tmp = y * (z / t);
      	}
      	return tmp;
      }
      
      def code(x, y, z, t):
      	tmp = 0
      	if z <= -9.5e-88:
      		tmp = (z * y) / t
      	elif z <= 2.65e-110:
      		tmp = x
      	else:
      		tmp = y * (z / t)
      	return tmp
      
      function code(x, y, z, t)
      	tmp = 0.0
      	if (z <= -9.5e-88)
      		tmp = Float64(Float64(z * y) / t);
      	elseif (z <= 2.65e-110)
      		tmp = x;
      	else
      		tmp = Float64(y * Float64(z / t));
      	end
      	return tmp
      end
      
      function tmp_2 = code(x, y, z, t)
      	tmp = 0.0;
      	if (z <= -9.5e-88)
      		tmp = (z * y) / t;
      	elseif (z <= 2.65e-110)
      		tmp = x;
      	else
      		tmp = y * (z / t);
      	end
      	tmp_2 = tmp;
      end
      
      code[x_, y_, z_, t_] := If[LessEqual[z, -9.5e-88], N[(N[(z * y), $MachinePrecision] / t), $MachinePrecision], If[LessEqual[z, 2.65e-110], x, N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;z \leq -9.5 \cdot 10^{-88}:\\
      \;\;\;\;\frac{z \cdot y}{t}\\
      
      \mathbf{elif}\;z \leq 2.65 \cdot 10^{-110}:\\
      \;\;\;\;x\\
      
      \mathbf{else}:\\
      \;\;\;\;y \cdot \frac{z}{t}\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 3 regimes
      2. if z < -9.5e-88

        1. Initial program 92.9%

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

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

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

            \[\leadsto \frac{z \cdot y}{t} \]
          3. lower-*.f6456.6

            \[\leadsto \frac{z \cdot y}{t} \]
        5. Applied rewrites56.6%

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

        if -9.5e-88 < z < 2.65e-110

        1. Initial program 94.7%

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

          \[\leadsto \color{blue}{x} \]
        4. Step-by-step derivation
          1. Applied rewrites59.1%

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

          if 2.65e-110 < z

          1. Initial program 87.8%

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

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

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

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

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

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

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

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

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

              \[\leadsto \mathsf{fma}\left(\color{blue}{z - x}, \frac{y}{t}, x\right) \]
            10. lower-/.f6496.3

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

            \[\leadsto \color{blue}{\mathsf{fma}\left(z - x, \frac{y}{t}, x\right)} \]
          5. Taylor expanded in x around 0

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

              \[\leadsto \frac{y \cdot z}{\color{blue}{t}} \]
            2. lower-*.f6448.3

              \[\leadsto \frac{y \cdot z}{t} \]
          7. Applied rewrites48.3%

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

              \[\leadsto \frac{y \cdot z}{t} \]
            2. lift-/.f64N/A

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

              \[\leadsto y \cdot \color{blue}{\frac{z}{t}} \]
            4. lower-*.f64N/A

              \[\leadsto y \cdot \color{blue}{\frac{z}{t}} \]
            5. lower-/.f6456.8

              \[\leadsto y \cdot \frac{z}{\color{blue}{t}} \]
          9. Applied rewrites56.8%

            \[\leadsto y \cdot \color{blue}{\frac{z}{t}} \]
        5. Recombined 3 regimes into one program.
        6. Final simplification57.6%

          \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -9.5 \cdot 10^{-88}:\\ \;\;\;\;\frac{z \cdot y}{t}\\ \mathbf{elif}\;z \leq 2.65 \cdot 10^{-110}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{z}{t}\\ \end{array} \]
        7. Add Preprocessing

        Alternative 7: 54.8% accurate, 0.8× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;t \leq -2.5 \cdot 10^{-51}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq 26:\\ \;\;\;\;\frac{z \cdot y}{t}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \end{array} \]
        (FPCore (x y z t)
         :precision binary64
         (if (<= t -2.5e-51) x (if (<= t 26.0) (/ (* z y) t) x)))
        double code(double x, double y, double z, double t) {
        	double tmp;
        	if (t <= -2.5e-51) {
        		tmp = x;
        	} else if (t <= 26.0) {
        		tmp = (z * y) / t;
        	} else {
        		tmp = x;
        	}
        	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, t)
        use fmin_fmax_functions
            real(8), intent (in) :: x
            real(8), intent (in) :: y
            real(8), intent (in) :: z
            real(8), intent (in) :: t
            real(8) :: tmp
            if (t <= (-2.5d-51)) then
                tmp = x
            else if (t <= 26.0d0) then
                tmp = (z * y) / t
            else
                tmp = x
            end if
            code = tmp
        end function
        
        public static double code(double x, double y, double z, double t) {
        	double tmp;
        	if (t <= -2.5e-51) {
        		tmp = x;
        	} else if (t <= 26.0) {
        		tmp = (z * y) / t;
        	} else {
        		tmp = x;
        	}
        	return tmp;
        }
        
        def code(x, y, z, t):
        	tmp = 0
        	if t <= -2.5e-51:
        		tmp = x
        	elif t <= 26.0:
        		tmp = (z * y) / t
        	else:
        		tmp = x
        	return tmp
        
        function code(x, y, z, t)
        	tmp = 0.0
        	if (t <= -2.5e-51)
        		tmp = x;
        	elseif (t <= 26.0)
        		tmp = Float64(Float64(z * y) / t);
        	else
        		tmp = x;
        	end
        	return tmp
        end
        
        function tmp_2 = code(x, y, z, t)
        	tmp = 0.0;
        	if (t <= -2.5e-51)
        		tmp = x;
        	elseif (t <= 26.0)
        		tmp = (z * y) / t;
        	else
        		tmp = x;
        	end
        	tmp_2 = tmp;
        end
        
        code[x_, y_, z_, t_] := If[LessEqual[t, -2.5e-51], x, If[LessEqual[t, 26.0], N[(N[(z * y), $MachinePrecision] / t), $MachinePrecision], x]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;t \leq -2.5 \cdot 10^{-51}:\\
        \;\;\;\;x\\
        
        \mathbf{elif}\;t \leq 26:\\
        \;\;\;\;\frac{z \cdot y}{t}\\
        
        \mathbf{else}:\\
        \;\;\;\;x\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if t < -2.50000000000000002e-51 or 26 < t

          1. Initial program 86.9%

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

            \[\leadsto \color{blue}{x} \]
          4. Step-by-step derivation
            1. Applied rewrites58.2%

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

            if -2.50000000000000002e-51 < t < 26

            1. Initial program 99.8%

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

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

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

                \[\leadsto \frac{z \cdot y}{t} \]
              3. lower-*.f6453.1

                \[\leadsto \frac{z \cdot y}{t} \]
            5. Applied rewrites53.1%

              \[\leadsto \color{blue}{\frac{z \cdot y}{t}} \]
          5. Recombined 2 regimes into one program.
          6. Final simplification56.2%

            \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -2.5 \cdot 10^{-51}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq 26:\\ \;\;\;\;\frac{z \cdot y}{t}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
          7. Add Preprocessing

          Alternative 8: 74.0% accurate, 0.9× speedup?

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

            1. Initial program 76.4%

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

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

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

                \[\leadsto \left(1 + -1 \cdot \frac{y}{t}\right) \cdot \color{blue}{x} \]
              3. cancel-sign-subN/A

                \[\leadsto \left(1 - \left(\mathsf{neg}\left(-1\right)\right) \cdot \frac{y}{t}\right) \cdot x \]
              4. metadata-evalN/A

                \[\leadsto \left(1 - 1 \cdot \frac{y}{t}\right) \cdot x \]
              5. *-lft-identityN/A

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

                \[\leadsto \left(1 - \frac{y}{t}\right) \cdot x \]
              7. lower-/.f6483.5

                \[\leadsto \left(1 - \frac{y}{t}\right) \cdot x \]
            5. Applied rewrites83.5%

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

              \[\leadsto \left(-1 \cdot \frac{y}{t}\right) \cdot x \]
            7. Step-by-step derivation
              1. associate-*r/N/A

                \[\leadsto \frac{-1 \cdot y}{t} \cdot x \]
              2. lower-/.f64N/A

                \[\leadsto \frac{-1 \cdot y}{t} \cdot x \]
              3. mul-1-negN/A

                \[\leadsto \frac{\mathsf{neg}\left(y\right)}{t} \cdot x \]
              4. lower-neg.f6483.5

                \[\leadsto \frac{-y}{t} \cdot x \]
            8. Applied rewrites83.5%

              \[\leadsto \frac{-y}{t} \cdot x \]

            if -5.19999999999999947e232 < y

            1. Initial program 92.8%

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

              \[\leadsto x + \frac{y \cdot \color{blue}{z}}{t} \]
            4. Step-by-step derivation
              1. Applied rewrites75.3%

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

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

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

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

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

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

                  \[\leadsto \color{blue}{\mathsf{fma}\left(y, \frac{z}{t}, x\right)} \]
                7. lower-/.f6474.7

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

                \[\leadsto \color{blue}{\mathsf{fma}\left(y, \frac{z}{t}, x\right)} \]
            5. Recombined 2 regimes into one program.
            6. Final simplification75.1%

              \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -5.2 \cdot 10^{+232}:\\ \;\;\;\;\frac{-y}{t} \cdot x\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(y, \frac{z}{t}, x\right)\\ \end{array} \]
            7. Add Preprocessing

            Alternative 9: 74.0% accurate, 1.3× speedup?

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

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

              \[\leadsto x + \frac{y \cdot \color{blue}{z}}{t} \]
            4. Step-by-step derivation
              1. Applied rewrites73.4%

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

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

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

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

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

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

                  \[\leadsto \color{blue}{\mathsf{fma}\left(y, \frac{z}{t}, x\right)} \]
                7. lower-/.f6473.3

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

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

              Alternative 10: 39.0% accurate, 23.0× speedup?

              \[\begin{array}{l} \\ x \end{array} \]
              (FPCore (x y z t) :precision binary64 x)
              double code(double x, double y, double z, double t) {
              	return 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, t)
              use fmin_fmax_functions
                  real(8), intent (in) :: x
                  real(8), intent (in) :: y
                  real(8), intent (in) :: z
                  real(8), intent (in) :: t
                  code = x
              end function
              
              public static double code(double x, double y, double z, double t) {
              	return x;
              }
              
              def code(x, y, z, t):
              	return x
              
              function code(x, y, z, t)
              	return x
              end
              
              function tmp = code(x, y, z, t)
              	tmp = x;
              end
              
              code[x_, y_, z_, t_] := x
              
              \begin{array}{l}
              
              \\
              x
              \end{array}
              
              Derivation
              1. Initial program 92.0%

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

                \[\leadsto \color{blue}{x} \]
              4. Step-by-step derivation
                1. Applied rewrites39.9%

                  \[\leadsto \color{blue}{x} \]
                2. Final simplification39.9%

                  \[\leadsto x \]
                3. Add Preprocessing

                Developer Target 1: 91.0% accurate, 0.6× speedup?

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

                Reproduce

                ?
                herbie shell --seed 2025051 
                (FPCore (x y z t)
                  :name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, D"
                  :precision binary64
                
                  :alt
                  (! :herbie-platform default (- x (+ (* x (/ y t)) (* (- z) (/ y t)))))
                
                  (+ x (/ (* y (- z x)) t)))