(- z0 (* (- z0 1) (exp (/ -2 z1))))

Percentage Accurate: 76.8% → 99.9%
Time: 3.1s
Alternatives: 22
Speedup: 1.4×

Specification

?
\[z0 - \left(z0 - 1\right) \cdot e^{\frac{-2}{z1}} \]
(FPCore (z0 z1)
  :precision binary64
  (- z0 (* (- z0 1.0) (exp (/ -2.0 z1)))))
double code(double z0, double z1) {
	return z0 - ((z0 - 1.0) * exp((-2.0 / z1)));
}
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(z0, z1)
use fmin_fmax_functions
    real(8), intent (in) :: z0
    real(8), intent (in) :: z1
    code = z0 - ((z0 - 1.0d0) * exp(((-2.0d0) / z1)))
end function
public static double code(double z0, double z1) {
	return z0 - ((z0 - 1.0) * Math.exp((-2.0 / z1)));
}
def code(z0, z1):
	return z0 - ((z0 - 1.0) * math.exp((-2.0 / z1)))
function code(z0, z1)
	return Float64(z0 - Float64(Float64(z0 - 1.0) * exp(Float64(-2.0 / z1))))
end
function tmp = code(z0, z1)
	tmp = z0 - ((z0 - 1.0) * exp((-2.0 / z1)));
end
code[z0_, z1_] := N[(z0 - N[(N[(z0 - 1.0), $MachinePrecision] * N[Exp[N[(-2.0 / z1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
z0 - \left(z0 - 1\right) \cdot e^{\frac{-2}{z1}}

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 22 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: 76.8% accurate, 1.0× speedup?

\[z0 - \left(z0 - 1\right) \cdot e^{\frac{-2}{z1}} \]
(FPCore (z0 z1)
  :precision binary64
  (- z0 (* (- z0 1.0) (exp (/ -2.0 z1)))))
double code(double z0, double z1) {
	return z0 - ((z0 - 1.0) * exp((-2.0 / z1)));
}
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(z0, z1)
use fmin_fmax_functions
    real(8), intent (in) :: z0
    real(8), intent (in) :: z1
    code = z0 - ((z0 - 1.0d0) * exp(((-2.0d0) / z1)))
end function
public static double code(double z0, double z1) {
	return z0 - ((z0 - 1.0) * Math.exp((-2.0 / z1)));
}
def code(z0, z1):
	return z0 - ((z0 - 1.0) * math.exp((-2.0 / z1)))
function code(z0, z1)
	return Float64(z0 - Float64(Float64(z0 - 1.0) * exp(Float64(-2.0 / z1))))
end
function tmp = code(z0, z1)
	tmp = z0 - ((z0 - 1.0) * exp((-2.0 / z1)));
end
code[z0_, z1_] := N[(z0 - N[(N[(z0 - 1.0), $MachinePrecision] * N[Exp[N[(-2.0 / z1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
z0 - \left(z0 - 1\right) \cdot e^{\frac{-2}{z1}}

Alternative 1: 99.9% accurate, 0.9× speedup?

\[\begin{array}{l} t_0 := 1 + -1 \cdot \frac{\frac{z0 \cdot \left(2 - 1.3333333333333333 \cdot \frac{1}{z1}\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}\\ \mathbf{if}\;z1 \leq -13500:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z1 \leq 15000000:\\ \;\;\;\;z0 - \left(z0 - 1\right) \cdot {7.38905609893065}^{\left(\frac{-1}{z1}\right)}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \]
(FPCore (z0 z1)
  :precision binary64
  (let* ((t_0
        (+
         1.0
         (*
          -1.0
          (/
           (-
            (/ (* z0 (- 2.0 (* 1.3333333333333333 (/ 1.0 z1)))) z1)
            (* 2.0 (- z0 1.0)))
           z1)))))
  (if (<= z1 -13500.0)
    t_0
    (if (<= z1 15000000.0)
      (- z0 (* (- z0 1.0) (pow 7.38905609893065 (/ -1.0 z1))))
      t_0))))
double code(double z0, double z1) {
	double t_0 = 1.0 + (-1.0 * ((((z0 * (2.0 - (1.3333333333333333 * (1.0 / z1)))) / z1) - (2.0 * (z0 - 1.0))) / z1));
	double tmp;
	if (z1 <= -13500.0) {
		tmp = t_0;
	} else if (z1 <= 15000000.0) {
		tmp = z0 - ((z0 - 1.0) * pow(7.38905609893065, (-1.0 / z1)));
	} 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(z0, z1)
use fmin_fmax_functions
    real(8), intent (in) :: z0
    real(8), intent (in) :: z1
    real(8) :: t_0
    real(8) :: tmp
    t_0 = 1.0d0 + ((-1.0d0) * ((((z0 * (2.0d0 - (1.3333333333333333d0 * (1.0d0 / z1)))) / z1) - (2.0d0 * (z0 - 1.0d0))) / z1))
    if (z1 <= (-13500.0d0)) then
        tmp = t_0
    else if (z1 <= 15000000.0d0) then
        tmp = z0 - ((z0 - 1.0d0) * (7.38905609893065d0 ** ((-1.0d0) / z1)))
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double z0, double z1) {
	double t_0 = 1.0 + (-1.0 * ((((z0 * (2.0 - (1.3333333333333333 * (1.0 / z1)))) / z1) - (2.0 * (z0 - 1.0))) / z1));
	double tmp;
	if (z1 <= -13500.0) {
		tmp = t_0;
	} else if (z1 <= 15000000.0) {
		tmp = z0 - ((z0 - 1.0) * Math.pow(7.38905609893065, (-1.0 / z1)));
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(z0, z1):
	t_0 = 1.0 + (-1.0 * ((((z0 * (2.0 - (1.3333333333333333 * (1.0 / z1)))) / z1) - (2.0 * (z0 - 1.0))) / z1))
	tmp = 0
	if z1 <= -13500.0:
		tmp = t_0
	elif z1 <= 15000000.0:
		tmp = z0 - ((z0 - 1.0) * math.pow(7.38905609893065, (-1.0 / z1)))
	else:
		tmp = t_0
	return tmp
function code(z0, z1)
	t_0 = Float64(1.0 + Float64(-1.0 * Float64(Float64(Float64(Float64(z0 * Float64(2.0 - Float64(1.3333333333333333 * Float64(1.0 / z1)))) / z1) - Float64(2.0 * Float64(z0 - 1.0))) / z1)))
	tmp = 0.0
	if (z1 <= -13500.0)
		tmp = t_0;
	elseif (z1 <= 15000000.0)
		tmp = Float64(z0 - Float64(Float64(z0 - 1.0) * (7.38905609893065 ^ Float64(-1.0 / z1))));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(z0, z1)
	t_0 = 1.0 + (-1.0 * ((((z0 * (2.0 - (1.3333333333333333 * (1.0 / z1)))) / z1) - (2.0 * (z0 - 1.0))) / z1));
	tmp = 0.0;
	if (z1 <= -13500.0)
		tmp = t_0;
	elseif (z1 <= 15000000.0)
		tmp = z0 - ((z0 - 1.0) * (7.38905609893065 ^ (-1.0 / z1)));
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[z0_, z1_] := Block[{t$95$0 = N[(1.0 + N[(-1.0 * N[(N[(N[(N[(z0 * N[(2.0 - N[(1.3333333333333333 * N[(1.0 / z1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z1), $MachinePrecision] - N[(2.0 * N[(z0 - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z1, -13500.0], t$95$0, If[LessEqual[z1, 15000000.0], N[(z0 - N[(N[(z0 - 1.0), $MachinePrecision] * N[Power[7.38905609893065, N[(-1.0 / z1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := 1 + -1 \cdot \frac{\frac{z0 \cdot \left(2 - 1.3333333333333333 \cdot \frac{1}{z1}\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}\\
\mathbf{if}\;z1 \leq -13500:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;z1 \leq 15000000:\\
\;\;\;\;z0 - \left(z0 - 1\right) \cdot {7.38905609893065}^{\left(\frac{-1}{z1}\right)}\\

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


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z1 < -13500 or 1.5e7 < z1

    1. Initial program 76.8%

      \[z0 - \left(z0 - 1\right) \cdot e^{\frac{-2}{z1}} \]
    2. Taylor expanded in z1 around -inf

      \[\leadsto \color{blue}{1 + -1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
    3. Step-by-step derivation
      1. lower-+.f64N/A

        \[\leadsto 1 + \color{blue}{-1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
      2. lower-*.f64N/A

        \[\leadsto 1 + -1 \cdot \color{blue}{\frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
      3. lower-/.f64N/A

        \[\leadsto 1 + -1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{\color{blue}{z1}} \]
    4. Applied rewrites71.0%

      \[\leadsto \color{blue}{1 + -1 \cdot \frac{-1 \cdot \frac{1.3333333333333333 \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
    5. Taylor expanded in z0 around -inf

      \[\leadsto 1 + -1 \cdot \frac{\frac{z0 \cdot \left(2 - \frac{4}{3} \cdot \frac{1}{z1}\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} \]
    6. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto 1 + -1 \cdot \frac{\frac{z0 \cdot \left(2 - \frac{4}{3} \cdot \frac{1}{z1}\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} \]
      2. lower-*.f64N/A

        \[\leadsto 1 + -1 \cdot \frac{\frac{z0 \cdot \left(2 - \frac{4}{3} \cdot \frac{1}{z1}\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} \]
      3. lower--.f64N/A

        \[\leadsto 1 + -1 \cdot \frac{\frac{z0 \cdot \left(2 - \frac{4}{3} \cdot \frac{1}{z1}\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} \]
      4. lower-*.f64N/A

        \[\leadsto 1 + -1 \cdot \frac{\frac{z0 \cdot \left(2 - \frac{4}{3} \cdot \frac{1}{z1}\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} \]
      5. lower-/.f6465.2%

        \[\leadsto 1 + -1 \cdot \frac{\frac{z0 \cdot \left(2 - 1.3333333333333333 \cdot \frac{1}{z1}\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} \]
    7. Applied rewrites65.2%

      \[\leadsto 1 + -1 \cdot \frac{\frac{z0 \cdot \left(2 - 1.3333333333333333 \cdot \frac{1}{z1}\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} \]

    if -13500 < z1 < 1.5e7

    1. Initial program 76.8%

      \[z0 - \left(z0 - 1\right) \cdot e^{\frac{-2}{z1}} \]
    2. Step-by-step derivation
      1. lift-exp.f64N/A

        \[\leadsto z0 - \left(z0 - 1\right) \cdot \color{blue}{e^{\frac{-2}{z1}}} \]
      2. lift-/.f64N/A

        \[\leadsto z0 - \left(z0 - 1\right) \cdot e^{\color{blue}{\frac{-2}{z1}}} \]
      3. frac-2negN/A

        \[\leadsto z0 - \left(z0 - 1\right) \cdot e^{\color{blue}{\frac{\mathsf{neg}\left(-2\right)}{\mathsf{neg}\left(z1\right)}}} \]
      4. mult-flipN/A

        \[\leadsto z0 - \left(z0 - 1\right) \cdot e^{\color{blue}{\left(\mathsf{neg}\left(-2\right)\right) \cdot \frac{1}{\mathsf{neg}\left(z1\right)}}} \]
      5. exp-prodN/A

        \[\leadsto z0 - \left(z0 - 1\right) \cdot \color{blue}{{\left(e^{\mathsf{neg}\left(-2\right)}\right)}^{\left(\frac{1}{\mathsf{neg}\left(z1\right)}\right)}} \]
      6. lower-pow.f64N/A

        \[\leadsto z0 - \left(z0 - 1\right) \cdot \color{blue}{{\left(e^{\mathsf{neg}\left(-2\right)}\right)}^{\left(\frac{1}{\mathsf{neg}\left(z1\right)}\right)}} \]
      7. lower-exp.f64N/A

        \[\leadsto z0 - \left(z0 - 1\right) \cdot {\color{blue}{\left(e^{\mathsf{neg}\left(-2\right)}\right)}}^{\left(\frac{1}{\mathsf{neg}\left(z1\right)}\right)} \]
      8. metadata-evalN/A

        \[\leadsto z0 - \left(z0 - 1\right) \cdot {\left(e^{\color{blue}{2}}\right)}^{\left(\frac{1}{\mathsf{neg}\left(z1\right)}\right)} \]
      9. frac-2negN/A

        \[\leadsto z0 - \left(z0 - 1\right) \cdot {\left(e^{2}\right)}^{\color{blue}{\left(\frac{\mathsf{neg}\left(1\right)}{\mathsf{neg}\left(\left(\mathsf{neg}\left(z1\right)\right)\right)}\right)}} \]
      10. remove-double-negN/A

        \[\leadsto z0 - \left(z0 - 1\right) \cdot {\left(e^{2}\right)}^{\left(\frac{\mathsf{neg}\left(1\right)}{\color{blue}{z1}}\right)} \]
      11. lower-/.f64N/A

        \[\leadsto z0 - \left(z0 - 1\right) \cdot {\left(e^{2}\right)}^{\color{blue}{\left(\frac{\mathsf{neg}\left(1\right)}{z1}\right)}} \]
      12. metadata-eval76.8%

        \[\leadsto z0 - \left(z0 - 1\right) \cdot {\left(e^{2}\right)}^{\left(\frac{\color{blue}{-1}}{z1}\right)} \]
    3. Applied rewrites76.8%

      \[\leadsto z0 - \left(z0 - 1\right) \cdot \color{blue}{{\left(e^{2}\right)}^{\left(\frac{-1}{z1}\right)}} \]
    4. Evaluated real constant76.8%

      \[\leadsto z0 - \left(z0 - 1\right) \cdot {\color{blue}{7.38905609893065}}^{\left(\frac{-1}{z1}\right)} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 2: 99.9% accurate, 0.9× speedup?

\[\begin{array}{l} t_0 := 1 + -1 \cdot \frac{\frac{z0 \cdot \left(2 - 1.3333333333333333 \cdot \frac{1}{z1}\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}\\ \mathbf{if}\;z1 \leq -13500:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z1 \leq 15000000:\\ \;\;\;\;z0 - \left(z0 - 1\right) \cdot e^{\frac{-2}{z1}}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \]
(FPCore (z0 z1)
  :precision binary64
  (let* ((t_0
        (+
         1.0
         (*
          -1.0
          (/
           (-
            (/ (* z0 (- 2.0 (* 1.3333333333333333 (/ 1.0 z1)))) z1)
            (* 2.0 (- z0 1.0)))
           z1)))))
  (if (<= z1 -13500.0)
    t_0
    (if (<= z1 15000000.0)
      (- z0 (* (- z0 1.0) (exp (/ -2.0 z1))))
      t_0))))
double code(double z0, double z1) {
	double t_0 = 1.0 + (-1.0 * ((((z0 * (2.0 - (1.3333333333333333 * (1.0 / z1)))) / z1) - (2.0 * (z0 - 1.0))) / z1));
	double tmp;
	if (z1 <= -13500.0) {
		tmp = t_0;
	} else if (z1 <= 15000000.0) {
		tmp = z0 - ((z0 - 1.0) * exp((-2.0 / z1)));
	} 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(z0, z1)
use fmin_fmax_functions
    real(8), intent (in) :: z0
    real(8), intent (in) :: z1
    real(8) :: t_0
    real(8) :: tmp
    t_0 = 1.0d0 + ((-1.0d0) * ((((z0 * (2.0d0 - (1.3333333333333333d0 * (1.0d0 / z1)))) / z1) - (2.0d0 * (z0 - 1.0d0))) / z1))
    if (z1 <= (-13500.0d0)) then
        tmp = t_0
    else if (z1 <= 15000000.0d0) then
        tmp = z0 - ((z0 - 1.0d0) * exp(((-2.0d0) / z1)))
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double z0, double z1) {
	double t_0 = 1.0 + (-1.0 * ((((z0 * (2.0 - (1.3333333333333333 * (1.0 / z1)))) / z1) - (2.0 * (z0 - 1.0))) / z1));
	double tmp;
	if (z1 <= -13500.0) {
		tmp = t_0;
	} else if (z1 <= 15000000.0) {
		tmp = z0 - ((z0 - 1.0) * Math.exp((-2.0 / z1)));
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(z0, z1):
	t_0 = 1.0 + (-1.0 * ((((z0 * (2.0 - (1.3333333333333333 * (1.0 / z1)))) / z1) - (2.0 * (z0 - 1.0))) / z1))
	tmp = 0
	if z1 <= -13500.0:
		tmp = t_0
	elif z1 <= 15000000.0:
		tmp = z0 - ((z0 - 1.0) * math.exp((-2.0 / z1)))
	else:
		tmp = t_0
	return tmp
function code(z0, z1)
	t_0 = Float64(1.0 + Float64(-1.0 * Float64(Float64(Float64(Float64(z0 * Float64(2.0 - Float64(1.3333333333333333 * Float64(1.0 / z1)))) / z1) - Float64(2.0 * Float64(z0 - 1.0))) / z1)))
	tmp = 0.0
	if (z1 <= -13500.0)
		tmp = t_0;
	elseif (z1 <= 15000000.0)
		tmp = Float64(z0 - Float64(Float64(z0 - 1.0) * exp(Float64(-2.0 / z1))));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(z0, z1)
	t_0 = 1.0 + (-1.0 * ((((z0 * (2.0 - (1.3333333333333333 * (1.0 / z1)))) / z1) - (2.0 * (z0 - 1.0))) / z1));
	tmp = 0.0;
	if (z1 <= -13500.0)
		tmp = t_0;
	elseif (z1 <= 15000000.0)
		tmp = z0 - ((z0 - 1.0) * exp((-2.0 / z1)));
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[z0_, z1_] := Block[{t$95$0 = N[(1.0 + N[(-1.0 * N[(N[(N[(N[(z0 * N[(2.0 - N[(1.3333333333333333 * N[(1.0 / z1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z1), $MachinePrecision] - N[(2.0 * N[(z0 - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z1, -13500.0], t$95$0, If[LessEqual[z1, 15000000.0], N[(z0 - N[(N[(z0 - 1.0), $MachinePrecision] * N[Exp[N[(-2.0 / z1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := 1 + -1 \cdot \frac{\frac{z0 \cdot \left(2 - 1.3333333333333333 \cdot \frac{1}{z1}\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}\\
\mathbf{if}\;z1 \leq -13500:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;z1 \leq 15000000:\\
\;\;\;\;z0 - \left(z0 - 1\right) \cdot e^{\frac{-2}{z1}}\\

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


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z1 < -13500 or 1.5e7 < z1

    1. Initial program 76.8%

      \[z0 - \left(z0 - 1\right) \cdot e^{\frac{-2}{z1}} \]
    2. Taylor expanded in z1 around -inf

      \[\leadsto \color{blue}{1 + -1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
    3. Step-by-step derivation
      1. lower-+.f64N/A

        \[\leadsto 1 + \color{blue}{-1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
      2. lower-*.f64N/A

        \[\leadsto 1 + -1 \cdot \color{blue}{\frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
      3. lower-/.f64N/A

        \[\leadsto 1 + -1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{\color{blue}{z1}} \]
    4. Applied rewrites71.0%

      \[\leadsto \color{blue}{1 + -1 \cdot \frac{-1 \cdot \frac{1.3333333333333333 \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
    5. Taylor expanded in z0 around -inf

      \[\leadsto 1 + -1 \cdot \frac{\frac{z0 \cdot \left(2 - \frac{4}{3} \cdot \frac{1}{z1}\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} \]
    6. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto 1 + -1 \cdot \frac{\frac{z0 \cdot \left(2 - \frac{4}{3} \cdot \frac{1}{z1}\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} \]
      2. lower-*.f64N/A

        \[\leadsto 1 + -1 \cdot \frac{\frac{z0 \cdot \left(2 - \frac{4}{3} \cdot \frac{1}{z1}\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} \]
      3. lower--.f64N/A

        \[\leadsto 1 + -1 \cdot \frac{\frac{z0 \cdot \left(2 - \frac{4}{3} \cdot \frac{1}{z1}\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} \]
      4. lower-*.f64N/A

        \[\leadsto 1 + -1 \cdot \frac{\frac{z0 \cdot \left(2 - \frac{4}{3} \cdot \frac{1}{z1}\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} \]
      5. lower-/.f6465.2%

        \[\leadsto 1 + -1 \cdot \frac{\frac{z0 \cdot \left(2 - 1.3333333333333333 \cdot \frac{1}{z1}\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} \]
    7. Applied rewrites65.2%

      \[\leadsto 1 + -1 \cdot \frac{\frac{z0 \cdot \left(2 - 1.3333333333333333 \cdot \frac{1}{z1}\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} \]

    if -13500 < z1 < 1.5e7

    1. Initial program 76.8%

      \[z0 - \left(z0 - 1\right) \cdot e^{\frac{-2}{z1}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 3: 97.3% accurate, 0.7× speedup?

\[\begin{array}{l} t_0 := z0 \cdot \left(1 - e^{\frac{-2}{z1}}\right)\\ t_1 := 2 \cdot \left(z0 - 1\right)\\ \mathbf{if}\;\frac{-2}{z1} \leq -0.02:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;\frac{-2}{z1} \leq 0.0002:\\ \;\;\;\;1 + -1 \cdot \frac{-1 \cdot \frac{1.3333333333333333 \cdot \frac{z0 - 1}{z1} - t\_1}{z1} - t\_1}{z1}\\ \mathbf{elif}\;\frac{-2}{z1} \leq 2 \cdot 10^{+62}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;z0 - \left(z0 - 1\right) \cdot \left(\left(\left(z1 + z1\right) \cdot \frac{z1}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1} - \frac{2}{z1}\right) - -1\right)\\ \end{array} \]
(FPCore (z0 z1)
  :precision binary64
  (let* ((t_0 (* z0 (- 1.0 (exp (/ -2.0 z1)))))
       (t_1 (* 2.0 (- z0 1.0))))
  (if (<= (/ -2.0 z1) -0.02)
    t_0
    (if (<= (/ -2.0 z1) 0.0002)
      (+
       1.0
       (*
        -1.0
        (/
         (-
          (*
           -1.0
           (/ (- (* 1.3333333333333333 (/ (- z0 1.0) z1)) t_1) z1))
          t_1)
         z1)))
      (if (<= (/ -2.0 z1) 2e+62)
        t_0
        (-
         z0
         (*
          (- z0 1.0)
          (-
           (- (* (+ z1 z1) (/ z1 (* (* (* z1 z1) z1) z1))) (/ 2.0 z1))
           -1.0))))))))
double code(double z0, double z1) {
	double t_0 = z0 * (1.0 - exp((-2.0 / z1)));
	double t_1 = 2.0 * (z0 - 1.0);
	double tmp;
	if ((-2.0 / z1) <= -0.02) {
		tmp = t_0;
	} else if ((-2.0 / z1) <= 0.0002) {
		tmp = 1.0 + (-1.0 * (((-1.0 * (((1.3333333333333333 * ((z0 - 1.0) / z1)) - t_1) / z1)) - t_1) / z1));
	} else if ((-2.0 / z1) <= 2e+62) {
		tmp = t_0;
	} else {
		tmp = z0 - ((z0 - 1.0) * ((((z1 + z1) * (z1 / (((z1 * z1) * z1) * z1))) - (2.0 / z1)) - -1.0));
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(z0, z1)
use fmin_fmax_functions
    real(8), intent (in) :: z0
    real(8), intent (in) :: z1
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = z0 * (1.0d0 - exp(((-2.0d0) / z1)))
    t_1 = 2.0d0 * (z0 - 1.0d0)
    if (((-2.0d0) / z1) <= (-0.02d0)) then
        tmp = t_0
    else if (((-2.0d0) / z1) <= 0.0002d0) then
        tmp = 1.0d0 + ((-1.0d0) * ((((-1.0d0) * (((1.3333333333333333d0 * ((z0 - 1.0d0) / z1)) - t_1) / z1)) - t_1) / z1))
    else if (((-2.0d0) / z1) <= 2d+62) then
        tmp = t_0
    else
        tmp = z0 - ((z0 - 1.0d0) * ((((z1 + z1) * (z1 / (((z1 * z1) * z1) * z1))) - (2.0d0 / z1)) - (-1.0d0)))
    end if
    code = tmp
end function
public static double code(double z0, double z1) {
	double t_0 = z0 * (1.0 - Math.exp((-2.0 / z1)));
	double t_1 = 2.0 * (z0 - 1.0);
	double tmp;
	if ((-2.0 / z1) <= -0.02) {
		tmp = t_0;
	} else if ((-2.0 / z1) <= 0.0002) {
		tmp = 1.0 + (-1.0 * (((-1.0 * (((1.3333333333333333 * ((z0 - 1.0) / z1)) - t_1) / z1)) - t_1) / z1));
	} else if ((-2.0 / z1) <= 2e+62) {
		tmp = t_0;
	} else {
		tmp = z0 - ((z0 - 1.0) * ((((z1 + z1) * (z1 / (((z1 * z1) * z1) * z1))) - (2.0 / z1)) - -1.0));
	}
	return tmp;
}
def code(z0, z1):
	t_0 = z0 * (1.0 - math.exp((-2.0 / z1)))
	t_1 = 2.0 * (z0 - 1.0)
	tmp = 0
	if (-2.0 / z1) <= -0.02:
		tmp = t_0
	elif (-2.0 / z1) <= 0.0002:
		tmp = 1.0 + (-1.0 * (((-1.0 * (((1.3333333333333333 * ((z0 - 1.0) / z1)) - t_1) / z1)) - t_1) / z1))
	elif (-2.0 / z1) <= 2e+62:
		tmp = t_0
	else:
		tmp = z0 - ((z0 - 1.0) * ((((z1 + z1) * (z1 / (((z1 * z1) * z1) * z1))) - (2.0 / z1)) - -1.0))
	return tmp
function code(z0, z1)
	t_0 = Float64(z0 * Float64(1.0 - exp(Float64(-2.0 / z1))))
	t_1 = Float64(2.0 * Float64(z0 - 1.0))
	tmp = 0.0
	if (Float64(-2.0 / z1) <= -0.02)
		tmp = t_0;
	elseif (Float64(-2.0 / z1) <= 0.0002)
		tmp = Float64(1.0 + Float64(-1.0 * Float64(Float64(Float64(-1.0 * Float64(Float64(Float64(1.3333333333333333 * Float64(Float64(z0 - 1.0) / z1)) - t_1) / z1)) - t_1) / z1)));
	elseif (Float64(-2.0 / z1) <= 2e+62)
		tmp = t_0;
	else
		tmp = Float64(z0 - Float64(Float64(z0 - 1.0) * Float64(Float64(Float64(Float64(z1 + z1) * Float64(z1 / Float64(Float64(Float64(z1 * z1) * z1) * z1))) - Float64(2.0 / z1)) - -1.0)));
	end
	return tmp
end
function tmp_2 = code(z0, z1)
	t_0 = z0 * (1.0 - exp((-2.0 / z1)));
	t_1 = 2.0 * (z0 - 1.0);
	tmp = 0.0;
	if ((-2.0 / z1) <= -0.02)
		tmp = t_0;
	elseif ((-2.0 / z1) <= 0.0002)
		tmp = 1.0 + (-1.0 * (((-1.0 * (((1.3333333333333333 * ((z0 - 1.0) / z1)) - t_1) / z1)) - t_1) / z1));
	elseif ((-2.0 / z1) <= 2e+62)
		tmp = t_0;
	else
		tmp = z0 - ((z0 - 1.0) * ((((z1 + z1) * (z1 / (((z1 * z1) * z1) * z1))) - (2.0 / z1)) - -1.0));
	end
	tmp_2 = tmp;
end
code[z0_, z1_] := Block[{t$95$0 = N[(z0 * N[(1.0 - N[Exp[N[(-2.0 / z1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(2.0 * N[(z0 - 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(-2.0 / z1), $MachinePrecision], -0.02], t$95$0, If[LessEqual[N[(-2.0 / z1), $MachinePrecision], 0.0002], N[(1.0 + N[(-1.0 * N[(N[(N[(-1.0 * N[(N[(N[(1.3333333333333333 * N[(N[(z0 - 1.0), $MachinePrecision] / z1), $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision] / z1), $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision] / z1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(-2.0 / z1), $MachinePrecision], 2e+62], t$95$0, N[(z0 - N[(N[(z0 - 1.0), $MachinePrecision] * N[(N[(N[(N[(z1 + z1), $MachinePrecision] * N[(z1 / N[(N[(N[(z1 * z1), $MachinePrecision] * z1), $MachinePrecision] * z1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(2.0 / z1), $MachinePrecision]), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
t_0 := z0 \cdot \left(1 - e^{\frac{-2}{z1}}\right)\\
t_1 := 2 \cdot \left(z0 - 1\right)\\
\mathbf{if}\;\frac{-2}{z1} \leq -0.02:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;\frac{-2}{z1} \leq 0.0002:\\
\;\;\;\;1 + -1 \cdot \frac{-1 \cdot \frac{1.3333333333333333 \cdot \frac{z0 - 1}{z1} - t\_1}{z1} - t\_1}{z1}\\

\mathbf{elif}\;\frac{-2}{z1} \leq 2 \cdot 10^{+62}:\\
\;\;\;\;t\_0\\

\mathbf{else}:\\
\;\;\;\;z0 - \left(z0 - 1\right) \cdot \left(\left(\left(z1 + z1\right) \cdot \frac{z1}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1} - \frac{2}{z1}\right) - -1\right)\\


\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (/.f64 #s(literal -2 binary64) z1) < -0.02 or 2.0000000000000001e-4 < (/.f64 #s(literal -2 binary64) z1) < 2.0000000000000001e62

    1. Initial program 76.8%

      \[z0 - \left(z0 - 1\right) \cdot e^{\frac{-2}{z1}} \]
    2. Taylor expanded in z0 around inf

      \[\leadsto \color{blue}{z0 \cdot \left(1 - e^{\frac{-2}{z1}}\right)} \]
    3. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto z0 \cdot \color{blue}{\left(1 - e^{\frac{-2}{z1}}\right)} \]
      2. lower--.f64N/A

        \[\leadsto z0 \cdot \left(1 - \color{blue}{e^{\frac{-2}{z1}}}\right) \]
      3. lower-exp.f64N/A

        \[\leadsto z0 \cdot \left(1 - e^{\frac{-2}{z1}}\right) \]
      4. lower-/.f6444.5%

        \[\leadsto z0 \cdot \left(1 - e^{\frac{-2}{z1}}\right) \]
    4. Applied rewrites44.5%

      \[\leadsto \color{blue}{z0 \cdot \left(1 - e^{\frac{-2}{z1}}\right)} \]

    if -0.02 < (/.f64 #s(literal -2 binary64) z1) < 2.0000000000000001e-4

    1. Initial program 76.8%

      \[z0 - \left(z0 - 1\right) \cdot e^{\frac{-2}{z1}} \]
    2. Taylor expanded in z1 around -inf

      \[\leadsto \color{blue}{1 + -1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
    3. Step-by-step derivation
      1. lower-+.f64N/A

        \[\leadsto 1 + \color{blue}{-1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
      2. lower-*.f64N/A

        \[\leadsto 1 + -1 \cdot \color{blue}{\frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
      3. lower-/.f64N/A

        \[\leadsto 1 + -1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{\color{blue}{z1}} \]
    4. Applied rewrites71.0%

      \[\leadsto \color{blue}{1 + -1 \cdot \frac{-1 \cdot \frac{1.3333333333333333 \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]

    if 2.0000000000000001e62 < (/.f64 #s(literal -2 binary64) z1)

    1. Initial program 76.8%

      \[z0 - \left(z0 - 1\right) \cdot e^{\frac{-2}{z1}} \]
    2. Taylor expanded in z1 around -inf

      \[\leadsto z0 - \left(z0 - 1\right) \cdot \color{blue}{\left(1 + -1 \cdot \frac{2 - 2 \cdot \frac{1}{z1}}{z1}\right)} \]
    3. Step-by-step derivation
      1. lower-+.f64N/A

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

        \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(1 + -1 \cdot \color{blue}{\frac{2 - 2 \cdot \frac{1}{z1}}{z1}}\right) \]
      3. lower-/.f64N/A

        \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(1 + -1 \cdot \frac{2 - 2 \cdot \frac{1}{z1}}{\color{blue}{z1}}\right) \]
      4. lower--.f64N/A

        \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(1 + -1 \cdot \frac{2 - 2 \cdot \frac{1}{z1}}{z1}\right) \]
      5. lower-*.f64N/A

        \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(1 + -1 \cdot \frac{2 - 2 \cdot \frac{1}{z1}}{z1}\right) \]
      6. lower-/.f6443.7%

        \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(1 + -1 \cdot \frac{2 - 2 \cdot \frac{1}{z1}}{z1}\right) \]
    4. Applied rewrites43.7%

      \[\leadsto z0 - \left(z0 - 1\right) \cdot \color{blue}{\left(1 + -1 \cdot \frac{2 - 2 \cdot \frac{1}{z1}}{z1}\right)} \]
    5. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(1 + \color{blue}{-1 \cdot \frac{2 - 2 \cdot \frac{1}{z1}}{z1}}\right) \]
      2. +-commutativeN/A

        \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(-1 \cdot \frac{2 - 2 \cdot \frac{1}{z1}}{z1} + \color{blue}{1}\right) \]
      3. add-flipN/A

        \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(-1 \cdot \frac{2 - 2 \cdot \frac{1}{z1}}{z1} - \color{blue}{\left(\mathsf{neg}\left(1\right)\right)}\right) \]
      4. metadata-evalN/A

        \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(-1 \cdot \frac{2 - 2 \cdot \frac{1}{z1}}{z1} - -1\right) \]
      5. lower--.f6443.7%

        \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(-1 \cdot \frac{2 - 2 \cdot \frac{1}{z1}}{z1} - \color{blue}{-1}\right) \]
      6. lift-*.f64N/A

        \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(-1 \cdot \frac{2 - 2 \cdot \frac{1}{z1}}{z1} - -1\right) \]
      7. mul-1-negN/A

        \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\left(\mathsf{neg}\left(\frac{2 - 2 \cdot \frac{1}{z1}}{z1}\right)\right) - -1\right) \]
      8. lift-/.f64N/A

        \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\left(\mathsf{neg}\left(\frac{2 - 2 \cdot \frac{1}{z1}}{z1}\right)\right) - -1\right) \]
      9. distribute-neg-fracN/A

        \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\frac{\mathsf{neg}\left(\left(2 - 2 \cdot \frac{1}{z1}\right)\right)}{z1} - -1\right) \]
      10. lower-/.f64N/A

        \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\frac{\mathsf{neg}\left(\left(2 - 2 \cdot \frac{1}{z1}\right)\right)}{z1} - -1\right) \]
      11. lift--.f64N/A

        \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\frac{\mathsf{neg}\left(\left(2 - 2 \cdot \frac{1}{z1}\right)\right)}{z1} - -1\right) \]
      12. sub-negate-revN/A

        \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\frac{2 \cdot \frac{1}{z1} - 2}{z1} - -1\right) \]
      13. lower--.f6443.7%

        \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\frac{2 \cdot \frac{1}{z1} - 2}{z1} - -1\right) \]
      14. lift-*.f64N/A

        \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\frac{2 \cdot \frac{1}{z1} - 2}{z1} - -1\right) \]
      15. lift-/.f64N/A

        \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\frac{2 \cdot \frac{1}{z1} - 2}{z1} - -1\right) \]
      16. mult-flip-revN/A

        \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\frac{\frac{2}{z1} - 2}{z1} - -1\right) \]
      17. lower-/.f6443.7%

        \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\frac{\frac{2}{z1} - 2}{z1} - -1\right) \]
    6. Applied rewrites43.7%

      \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\frac{\frac{2}{z1} - 2}{z1} - \color{blue}{-1}\right) \]
    7. Applied rewrites17.8%

      \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\frac{\left(z1 + z1\right) \cdot z1 - \left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot 2}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1} - -1\right) \]
    8. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\frac{\left(z1 + z1\right) \cdot z1 - \left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot 2}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1} - -1\right) \]
      2. lift--.f64N/A

        \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\frac{\left(z1 + z1\right) \cdot z1 - \left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot 2}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1} - -1\right) \]
      3. div-subN/A

        \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\left(\frac{\left(z1 + z1\right) \cdot z1}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1} - \frac{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot 2}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1}\right) - -1\right) \]
      4. lift-*.f64N/A

        \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\left(\frac{\left(z1 + z1\right) \cdot z1}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1} - \frac{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot 2}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1}\right) - -1\right) \]
      5. *-commutativeN/A

        \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\left(\frac{\left(z1 + z1\right) \cdot z1}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1} - \frac{2 \cdot \left(\left(z1 \cdot z1\right) \cdot z1\right)}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1}\right) - -1\right) \]
      6. associate-/l*N/A

        \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\left(\frac{\left(z1 + z1\right) \cdot z1}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1} - 2 \cdot \frac{\left(z1 \cdot z1\right) \cdot z1}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1}\right) - -1\right) \]
      7. lift-*.f64N/A

        \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\left(\frac{\left(z1 + z1\right) \cdot z1}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1} - 2 \cdot \frac{\left(z1 \cdot z1\right) \cdot z1}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1}\right) - -1\right) \]
      8. lift-*.f64N/A

        \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\left(\frac{\left(z1 + z1\right) \cdot z1}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1} - 2 \cdot \frac{\left(z1 \cdot z1\right) \cdot z1}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1}\right) - -1\right) \]
      9. pow3N/A

        \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\left(\frac{\left(z1 + z1\right) \cdot z1}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1} - 2 \cdot \frac{{z1}^{3}}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1}\right) - -1\right) \]
      10. lift-*.f64N/A

        \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\left(\frac{\left(z1 + z1\right) \cdot z1}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1} - 2 \cdot \frac{{z1}^{3}}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1}\right) - -1\right) \]
      11. lift-*.f64N/A

        \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\left(\frac{\left(z1 + z1\right) \cdot z1}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1} - 2 \cdot \frac{{z1}^{3}}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1}\right) - -1\right) \]
      12. associate-*l*N/A

        \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\left(\frac{\left(z1 + z1\right) \cdot z1}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1} - 2 \cdot \frac{{z1}^{3}}{\left(z1 \cdot z1\right) \cdot \left(z1 \cdot z1\right)}\right) - -1\right) \]
      13. lift-*.f64N/A

        \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\left(\frac{\left(z1 + z1\right) \cdot z1}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1} - 2 \cdot \frac{{z1}^{3}}{\left(z1 \cdot z1\right) \cdot \left(z1 \cdot z1\right)}\right) - -1\right) \]
      14. pow2N/A

        \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\left(\frac{\left(z1 + z1\right) \cdot z1}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1} - 2 \cdot \frac{{z1}^{3}}{{z1}^{2} \cdot \left(z1 \cdot z1\right)}\right) - -1\right) \]
      15. pow2N/A

        \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\left(\frac{\left(z1 + z1\right) \cdot z1}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1} - 2 \cdot \frac{{z1}^{3}}{{z1}^{2} \cdot {z1}^{2}}\right) - -1\right) \]
      16. pow-prod-upN/A

        \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\left(\frac{\left(z1 + z1\right) \cdot z1}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1} - 2 \cdot \frac{{z1}^{3}}{{z1}^{\left(2 + 2\right)}}\right) - -1\right) \]
      17. pow-divN/A

        \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\left(\frac{\left(z1 + z1\right) \cdot z1}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1} - 2 \cdot {z1}^{\left(3 - \left(2 + 2\right)\right)}\right) - -1\right) \]
      18. metadata-evalN/A

        \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\left(\frac{\left(z1 + z1\right) \cdot z1}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1} - 2 \cdot {z1}^{\left(3 - 4\right)}\right) - -1\right) \]
      19. metadata-evalN/A

        \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\left(\frac{\left(z1 + z1\right) \cdot z1}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1} - 2 \cdot {z1}^{-1}\right) - -1\right) \]
      20. inv-powN/A

        \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\left(\frac{\left(z1 + z1\right) \cdot z1}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1} - 2 \cdot \frac{1}{z1}\right) - -1\right) \]
    9. Applied rewrites47.7%

      \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\left(\left(z1 + z1\right) \cdot \frac{z1}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1} - \frac{2}{z1}\right) - -1\right) \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 4: 85.5% accurate, 0.8× speedup?

\[\begin{array}{l} t_0 := 1.3333333333333333 \cdot \frac{z0 - 1}{z1}\\ t_1 := 2 \cdot \left(z0 - 1\right)\\ \mathbf{if}\;\frac{-2}{z1} \leq -20:\\ \;\;\;\;z0 - -1 \cdot 1\\ \mathbf{elif}\;\frac{-2}{z1} \leq 0.0002:\\ \;\;\;\;1 + -1 \cdot \frac{-1 \cdot \frac{t\_0 - t\_1}{z1} - t\_1}{z1}\\ \mathbf{elif}\;\frac{-2}{z1} \leq 10^{+88}:\\ \;\;\;\;e^{\frac{-2}{z1}}\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{t\_0 \cdot 1}{z1 \cdot z1}\\ \end{array} \]
(FPCore (z0 z1)
  :precision binary64
  (let* ((t_0 (* 1.3333333333333333 (/ (- z0 1.0) z1)))
       (t_1 (* 2.0 (- z0 1.0))))
  (if (<= (/ -2.0 z1) -20.0)
    (- z0 (* -1.0 1.0))
    (if (<= (/ -2.0 z1) 0.0002)
      (+ 1.0 (* -1.0 (/ (- (* -1.0 (/ (- t_0 t_1) z1)) t_1) z1)))
      (if (<= (/ -2.0 z1) 1e+88)
        (exp (/ -2.0 z1))
        (+ 1.0 (/ (* t_0 1.0) (* z1 z1))))))))
double code(double z0, double z1) {
	double t_0 = 1.3333333333333333 * ((z0 - 1.0) / z1);
	double t_1 = 2.0 * (z0 - 1.0);
	double tmp;
	if ((-2.0 / z1) <= -20.0) {
		tmp = z0 - (-1.0 * 1.0);
	} else if ((-2.0 / z1) <= 0.0002) {
		tmp = 1.0 + (-1.0 * (((-1.0 * ((t_0 - t_1) / z1)) - t_1) / z1));
	} else if ((-2.0 / z1) <= 1e+88) {
		tmp = exp((-2.0 / z1));
	} else {
		tmp = 1.0 + ((t_0 * 1.0) / (z1 * z1));
	}
	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(z0, z1)
use fmin_fmax_functions
    real(8), intent (in) :: z0
    real(8), intent (in) :: z1
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = 1.3333333333333333d0 * ((z0 - 1.0d0) / z1)
    t_1 = 2.0d0 * (z0 - 1.0d0)
    if (((-2.0d0) / z1) <= (-20.0d0)) then
        tmp = z0 - ((-1.0d0) * 1.0d0)
    else if (((-2.0d0) / z1) <= 0.0002d0) then
        tmp = 1.0d0 + ((-1.0d0) * ((((-1.0d0) * ((t_0 - t_1) / z1)) - t_1) / z1))
    else if (((-2.0d0) / z1) <= 1d+88) then
        tmp = exp(((-2.0d0) / z1))
    else
        tmp = 1.0d0 + ((t_0 * 1.0d0) / (z1 * z1))
    end if
    code = tmp
end function
public static double code(double z0, double z1) {
	double t_0 = 1.3333333333333333 * ((z0 - 1.0) / z1);
	double t_1 = 2.0 * (z0 - 1.0);
	double tmp;
	if ((-2.0 / z1) <= -20.0) {
		tmp = z0 - (-1.0 * 1.0);
	} else if ((-2.0 / z1) <= 0.0002) {
		tmp = 1.0 + (-1.0 * (((-1.0 * ((t_0 - t_1) / z1)) - t_1) / z1));
	} else if ((-2.0 / z1) <= 1e+88) {
		tmp = Math.exp((-2.0 / z1));
	} else {
		tmp = 1.0 + ((t_0 * 1.0) / (z1 * z1));
	}
	return tmp;
}
def code(z0, z1):
	t_0 = 1.3333333333333333 * ((z0 - 1.0) / z1)
	t_1 = 2.0 * (z0 - 1.0)
	tmp = 0
	if (-2.0 / z1) <= -20.0:
		tmp = z0 - (-1.0 * 1.0)
	elif (-2.0 / z1) <= 0.0002:
		tmp = 1.0 + (-1.0 * (((-1.0 * ((t_0 - t_1) / z1)) - t_1) / z1))
	elif (-2.0 / z1) <= 1e+88:
		tmp = math.exp((-2.0 / z1))
	else:
		tmp = 1.0 + ((t_0 * 1.0) / (z1 * z1))
	return tmp
function code(z0, z1)
	t_0 = Float64(1.3333333333333333 * Float64(Float64(z0 - 1.0) / z1))
	t_1 = Float64(2.0 * Float64(z0 - 1.0))
	tmp = 0.0
	if (Float64(-2.0 / z1) <= -20.0)
		tmp = Float64(z0 - Float64(-1.0 * 1.0));
	elseif (Float64(-2.0 / z1) <= 0.0002)
		tmp = Float64(1.0 + Float64(-1.0 * Float64(Float64(Float64(-1.0 * Float64(Float64(t_0 - t_1) / z1)) - t_1) / z1)));
	elseif (Float64(-2.0 / z1) <= 1e+88)
		tmp = exp(Float64(-2.0 / z1));
	else
		tmp = Float64(1.0 + Float64(Float64(t_0 * 1.0) / Float64(z1 * z1)));
	end
	return tmp
end
function tmp_2 = code(z0, z1)
	t_0 = 1.3333333333333333 * ((z0 - 1.0) / z1);
	t_1 = 2.0 * (z0 - 1.0);
	tmp = 0.0;
	if ((-2.0 / z1) <= -20.0)
		tmp = z0 - (-1.0 * 1.0);
	elseif ((-2.0 / z1) <= 0.0002)
		tmp = 1.0 + (-1.0 * (((-1.0 * ((t_0 - t_1) / z1)) - t_1) / z1));
	elseif ((-2.0 / z1) <= 1e+88)
		tmp = exp((-2.0 / z1));
	else
		tmp = 1.0 + ((t_0 * 1.0) / (z1 * z1));
	end
	tmp_2 = tmp;
end
code[z0_, z1_] := Block[{t$95$0 = N[(1.3333333333333333 * N[(N[(z0 - 1.0), $MachinePrecision] / z1), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(2.0 * N[(z0 - 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(-2.0 / z1), $MachinePrecision], -20.0], N[(z0 - N[(-1.0 * 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(-2.0 / z1), $MachinePrecision], 0.0002], N[(1.0 + N[(-1.0 * N[(N[(N[(-1.0 * N[(N[(t$95$0 - t$95$1), $MachinePrecision] / z1), $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision] / z1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(-2.0 / z1), $MachinePrecision], 1e+88], N[Exp[N[(-2.0 / z1), $MachinePrecision]], $MachinePrecision], N[(1.0 + N[(N[(t$95$0 * 1.0), $MachinePrecision] / N[(z1 * z1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
t_0 := 1.3333333333333333 \cdot \frac{z0 - 1}{z1}\\
t_1 := 2 \cdot \left(z0 - 1\right)\\
\mathbf{if}\;\frac{-2}{z1} \leq -20:\\
\;\;\;\;z0 - -1 \cdot 1\\

\mathbf{elif}\;\frac{-2}{z1} \leq 0.0002:\\
\;\;\;\;1 + -1 \cdot \frac{-1 \cdot \frac{t\_0 - t\_1}{z1} - t\_1}{z1}\\

\mathbf{elif}\;\frac{-2}{z1} \leq 10^{+88}:\\
\;\;\;\;e^{\frac{-2}{z1}}\\

\mathbf{else}:\\
\;\;\;\;1 + \frac{t\_0 \cdot 1}{z1 \cdot z1}\\


\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (/.f64 #s(literal -2 binary64) z1) < -20

    1. Initial program 76.8%

      \[z0 - \left(z0 - 1\right) \cdot e^{\frac{-2}{z1}} \]
    2. Taylor expanded in z1 around inf

      \[\leadsto z0 - \left(z0 - 1\right) \cdot \color{blue}{1} \]
    3. Step-by-step derivation
      1. Applied rewrites27.8%

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

        \[\leadsto z0 - \color{blue}{-1} \cdot 1 \]
      3. Step-by-step derivation
        1. Applied rewrites37.4%

          \[\leadsto z0 - \color{blue}{-1} \cdot 1 \]

        if -20 < (/.f64 #s(literal -2 binary64) z1) < 2.0000000000000001e-4

        1. Initial program 76.8%

          \[z0 - \left(z0 - 1\right) \cdot e^{\frac{-2}{z1}} \]
        2. Taylor expanded in z1 around -inf

          \[\leadsto \color{blue}{1 + -1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
        3. Step-by-step derivation
          1. lower-+.f64N/A

            \[\leadsto 1 + \color{blue}{-1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
          2. lower-*.f64N/A

            \[\leadsto 1 + -1 \cdot \color{blue}{\frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
          3. lower-/.f64N/A

            \[\leadsto 1 + -1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{\color{blue}{z1}} \]
        4. Applied rewrites71.0%

          \[\leadsto \color{blue}{1 + -1 \cdot \frac{-1 \cdot \frac{1.3333333333333333 \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]

        if 2.0000000000000001e-4 < (/.f64 #s(literal -2 binary64) z1) < 9.9999999999999996e87

        1. Initial program 76.8%

          \[z0 - \left(z0 - 1\right) \cdot e^{\frac{-2}{z1}} \]
        2. Taylor expanded in z0 around 0

          \[\leadsto \color{blue}{e^{\frac{-2}{z1}}} \]
        3. Step-by-step derivation
          1. lower-exp.f64N/A

            \[\leadsto e^{\frac{-2}{z1}} \]
          2. lower-/.f6458.1%

            \[\leadsto e^{\frac{-2}{z1}} \]
        4. Applied rewrites58.1%

          \[\leadsto \color{blue}{e^{\frac{-2}{z1}}} \]

        if 9.9999999999999996e87 < (/.f64 #s(literal -2 binary64) z1)

        1. Initial program 76.8%

          \[z0 - \left(z0 - 1\right) \cdot e^{\frac{-2}{z1}} \]
        2. Taylor expanded in z1 around -inf

          \[\leadsto \color{blue}{1 + -1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
        3. Step-by-step derivation
          1. lower-+.f64N/A

            \[\leadsto 1 + \color{blue}{-1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
          2. lower-*.f64N/A

            \[\leadsto 1 + -1 \cdot \color{blue}{\frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
          3. lower-/.f64N/A

            \[\leadsto 1 + -1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{\color{blue}{z1}} \]
        4. Applied rewrites71.0%

          \[\leadsto \color{blue}{1 + -1 \cdot \frac{-1 \cdot \frac{1.3333333333333333 \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
        5. Step-by-step derivation
          1. lift-*.f64N/A

            \[\leadsto 1 + -1 \cdot \color{blue}{\frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
          2. lift-/.f64N/A

            \[\leadsto 1 + -1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{\color{blue}{z1}} \]
          3. associate-*r/N/A

            \[\leadsto 1 + \frac{-1 \cdot \left(-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)\right)}{\color{blue}{z1}} \]
          4. mult-flipN/A

            \[\leadsto 1 + \left(-1 \cdot \left(-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)\right)\right) \cdot \color{blue}{\frac{1}{z1}} \]
        6. Applied rewrites57.8%

          \[\leadsto 1 + \frac{\left(\left(2 \cdot \left(z0 - 1\right)\right) \cdot z1 - \left(2 \cdot \left(z0 - 1\right) - \frac{z0 - 1}{z1} \cdot 1.3333333333333333\right)\right) \cdot 1}{\color{blue}{z1 \cdot z1}} \]
        7. Taylor expanded in z0 around 0

          \[\leadsto 1 + \frac{\left(\left(2 + -2 \cdot z1\right) - \frac{4}{3} \cdot \frac{1}{z1}\right) \cdot 1}{z1 \cdot z1} \]
        8. Step-by-step derivation
          1. lower--.f64N/A

            \[\leadsto 1 + \frac{\left(\left(2 + -2 \cdot z1\right) - \frac{4}{3} \cdot \frac{1}{z1}\right) \cdot 1}{z1 \cdot z1} \]
          2. lower-+.f64N/A

            \[\leadsto 1 + \frac{\left(\left(2 + -2 \cdot z1\right) - \frac{4}{3} \cdot \frac{1}{z1}\right) \cdot 1}{z1 \cdot z1} \]
          3. lower-*.f64N/A

            \[\leadsto 1 + \frac{\left(\left(2 + -2 \cdot z1\right) - \frac{4}{3} \cdot \frac{1}{z1}\right) \cdot 1}{z1 \cdot z1} \]
          4. lower-*.f64N/A

            \[\leadsto 1 + \frac{\left(\left(2 + -2 \cdot z1\right) - \frac{4}{3} \cdot \frac{1}{z1}\right) \cdot 1}{z1 \cdot z1} \]
          5. lower-/.f6451.4%

            \[\leadsto 1 + \frac{\left(\left(2 + -2 \cdot z1\right) - 1.3333333333333333 \cdot \frac{1}{z1}\right) \cdot 1}{z1 \cdot z1} \]
        9. Applied rewrites51.4%

          \[\leadsto 1 + \frac{\left(\left(2 + -2 \cdot z1\right) - 1.3333333333333333 \cdot \frac{1}{z1}\right) \cdot 1}{z1 \cdot z1} \]
        10. Taylor expanded in z1 around 0

          \[\leadsto 1 + \frac{\left(\frac{4}{3} \cdot \frac{z0 - 1}{z1}\right) \cdot 1}{z1 \cdot z1} \]
        11. Step-by-step derivation
          1. lower-*.f64N/A

            \[\leadsto 1 + \frac{\left(\frac{4}{3} \cdot \frac{z0 - 1}{z1}\right) \cdot 1}{z1 \cdot z1} \]
          2. lower-/.f64N/A

            \[\leadsto 1 + \frac{\left(\frac{4}{3} \cdot \frac{z0 - 1}{z1}\right) \cdot 1}{z1 \cdot z1} \]
          3. lower--.f6457.9%

            \[\leadsto 1 + \frac{\left(1.3333333333333333 \cdot \frac{z0 - 1}{z1}\right) \cdot 1}{z1 \cdot z1} \]
        12. Applied rewrites57.9%

          \[\leadsto 1 + \frac{\left(1.3333333333333333 \cdot \frac{z0 - 1}{z1}\right) \cdot 1}{z1 \cdot z1} \]
      4. Recombined 4 regimes into one program.
      5. Add Preprocessing

      Alternative 5: 82.7% accurate, 1.2× speedup?

      \[\begin{array}{l} \mathbf{if}\;\frac{-2}{z1} \leq -20:\\ \;\;\;\;z0 - -1 \cdot 1\\ \mathbf{elif}\;\frac{-2}{z1} \leq 2 \cdot 10^{+58}:\\ \;\;\;\;1 + -1 \cdot \frac{\frac{z0 \cdot \left(2 - 1.3333333333333333 \cdot \frac{1}{z1}\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}\\ \mathbf{else}:\\ \;\;\;\;z0 - \left(z0 - 1\right) \cdot \left(\left(\left(z1 + z1\right) \cdot \frac{z1}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1} - \frac{2}{z1}\right) - -1\right)\\ \end{array} \]
      (FPCore (z0 z1)
        :precision binary64
        (if (<= (/ -2.0 z1) -20.0)
        (- z0 (* -1.0 1.0))
        (if (<= (/ -2.0 z1) 2e+58)
          (+
           1.0
           (*
            -1.0
            (/
             (-
              (/ (* z0 (- 2.0 (* 1.3333333333333333 (/ 1.0 z1)))) z1)
              (* 2.0 (- z0 1.0)))
             z1)))
          (-
           z0
           (*
            (- z0 1.0)
            (-
             (- (* (+ z1 z1) (/ z1 (* (* (* z1 z1) z1) z1))) (/ 2.0 z1))
             -1.0))))))
      double code(double z0, double z1) {
      	double tmp;
      	if ((-2.0 / z1) <= -20.0) {
      		tmp = z0 - (-1.0 * 1.0);
      	} else if ((-2.0 / z1) <= 2e+58) {
      		tmp = 1.0 + (-1.0 * ((((z0 * (2.0 - (1.3333333333333333 * (1.0 / z1)))) / z1) - (2.0 * (z0 - 1.0))) / z1));
      	} else {
      		tmp = z0 - ((z0 - 1.0) * ((((z1 + z1) * (z1 / (((z1 * z1) * z1) * z1))) - (2.0 / z1)) - -1.0));
      	}
      	return tmp;
      }
      
      module fmin_fmax_functions
          implicit none
          private
          public fmax
          public fmin
      
          interface fmax
              module procedure fmax88
              module procedure fmax44
              module procedure fmax84
              module procedure fmax48
          end interface
          interface fmin
              module procedure fmin88
              module procedure fmin44
              module procedure fmin84
              module procedure fmin48
          end interface
      contains
          real(8) function fmax88(x, y) result (res)
              real(8), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
          end function
          real(4) function fmax44(x, y) result (res)
              real(4), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
          end function
          real(8) function fmax84(x, y) result(res)
              real(8), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
          end function
          real(8) function fmax48(x, y) result(res)
              real(4), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
          end function
          real(8) function fmin88(x, y) result (res)
              real(8), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
          end function
          real(4) function fmin44(x, y) result (res)
              real(4), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
          end function
          real(8) function fmin84(x, y) result(res)
              real(8), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
          end function
          real(8) function fmin48(x, y) result(res)
              real(4), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
          end function
      end module
      
      real(8) function code(z0, z1)
      use fmin_fmax_functions
          real(8), intent (in) :: z0
          real(8), intent (in) :: z1
          real(8) :: tmp
          if (((-2.0d0) / z1) <= (-20.0d0)) then
              tmp = z0 - ((-1.0d0) * 1.0d0)
          else if (((-2.0d0) / z1) <= 2d+58) then
              tmp = 1.0d0 + ((-1.0d0) * ((((z0 * (2.0d0 - (1.3333333333333333d0 * (1.0d0 / z1)))) / z1) - (2.0d0 * (z0 - 1.0d0))) / z1))
          else
              tmp = z0 - ((z0 - 1.0d0) * ((((z1 + z1) * (z1 / (((z1 * z1) * z1) * z1))) - (2.0d0 / z1)) - (-1.0d0)))
          end if
          code = tmp
      end function
      
      public static double code(double z0, double z1) {
      	double tmp;
      	if ((-2.0 / z1) <= -20.0) {
      		tmp = z0 - (-1.0 * 1.0);
      	} else if ((-2.0 / z1) <= 2e+58) {
      		tmp = 1.0 + (-1.0 * ((((z0 * (2.0 - (1.3333333333333333 * (1.0 / z1)))) / z1) - (2.0 * (z0 - 1.0))) / z1));
      	} else {
      		tmp = z0 - ((z0 - 1.0) * ((((z1 + z1) * (z1 / (((z1 * z1) * z1) * z1))) - (2.0 / z1)) - -1.0));
      	}
      	return tmp;
      }
      
      def code(z0, z1):
      	tmp = 0
      	if (-2.0 / z1) <= -20.0:
      		tmp = z0 - (-1.0 * 1.0)
      	elif (-2.0 / z1) <= 2e+58:
      		tmp = 1.0 + (-1.0 * ((((z0 * (2.0 - (1.3333333333333333 * (1.0 / z1)))) / z1) - (2.0 * (z0 - 1.0))) / z1))
      	else:
      		tmp = z0 - ((z0 - 1.0) * ((((z1 + z1) * (z1 / (((z1 * z1) * z1) * z1))) - (2.0 / z1)) - -1.0))
      	return tmp
      
      function code(z0, z1)
      	tmp = 0.0
      	if (Float64(-2.0 / z1) <= -20.0)
      		tmp = Float64(z0 - Float64(-1.0 * 1.0));
      	elseif (Float64(-2.0 / z1) <= 2e+58)
      		tmp = Float64(1.0 + Float64(-1.0 * Float64(Float64(Float64(Float64(z0 * Float64(2.0 - Float64(1.3333333333333333 * Float64(1.0 / z1)))) / z1) - Float64(2.0 * Float64(z0 - 1.0))) / z1)));
      	else
      		tmp = Float64(z0 - Float64(Float64(z0 - 1.0) * Float64(Float64(Float64(Float64(z1 + z1) * Float64(z1 / Float64(Float64(Float64(z1 * z1) * z1) * z1))) - Float64(2.0 / z1)) - -1.0)));
      	end
      	return tmp
      end
      
      function tmp_2 = code(z0, z1)
      	tmp = 0.0;
      	if ((-2.0 / z1) <= -20.0)
      		tmp = z0 - (-1.0 * 1.0);
      	elseif ((-2.0 / z1) <= 2e+58)
      		tmp = 1.0 + (-1.0 * ((((z0 * (2.0 - (1.3333333333333333 * (1.0 / z1)))) / z1) - (2.0 * (z0 - 1.0))) / z1));
      	else
      		tmp = z0 - ((z0 - 1.0) * ((((z1 + z1) * (z1 / (((z1 * z1) * z1) * z1))) - (2.0 / z1)) - -1.0));
      	end
      	tmp_2 = tmp;
      end
      
      code[z0_, z1_] := If[LessEqual[N[(-2.0 / z1), $MachinePrecision], -20.0], N[(z0 - N[(-1.0 * 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(-2.0 / z1), $MachinePrecision], 2e+58], N[(1.0 + N[(-1.0 * N[(N[(N[(N[(z0 * N[(2.0 - N[(1.3333333333333333 * N[(1.0 / z1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z1), $MachinePrecision] - N[(2.0 * N[(z0 - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z0 - N[(N[(z0 - 1.0), $MachinePrecision] * N[(N[(N[(N[(z1 + z1), $MachinePrecision] * N[(z1 / N[(N[(N[(z1 * z1), $MachinePrecision] * z1), $MachinePrecision] * z1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(2.0 / z1), $MachinePrecision]), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
      
      \begin{array}{l}
      \mathbf{if}\;\frac{-2}{z1} \leq -20:\\
      \;\;\;\;z0 - -1 \cdot 1\\
      
      \mathbf{elif}\;\frac{-2}{z1} \leq 2 \cdot 10^{+58}:\\
      \;\;\;\;1 + -1 \cdot \frac{\frac{z0 \cdot \left(2 - 1.3333333333333333 \cdot \frac{1}{z1}\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}\\
      
      \mathbf{else}:\\
      \;\;\;\;z0 - \left(z0 - 1\right) \cdot \left(\left(\left(z1 + z1\right) \cdot \frac{z1}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1} - \frac{2}{z1}\right) - -1\right)\\
      
      
      \end{array}
      
      Derivation
      1. Split input into 3 regimes
      2. if (/.f64 #s(literal -2 binary64) z1) < -20

        1. Initial program 76.8%

          \[z0 - \left(z0 - 1\right) \cdot e^{\frac{-2}{z1}} \]
        2. Taylor expanded in z1 around inf

          \[\leadsto z0 - \left(z0 - 1\right) \cdot \color{blue}{1} \]
        3. Step-by-step derivation
          1. Applied rewrites27.8%

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

            \[\leadsto z0 - \color{blue}{-1} \cdot 1 \]
          3. Step-by-step derivation
            1. Applied rewrites37.4%

              \[\leadsto z0 - \color{blue}{-1} \cdot 1 \]

            if -20 < (/.f64 #s(literal -2 binary64) z1) < 1.9999999999999999e58

            1. Initial program 76.8%

              \[z0 - \left(z0 - 1\right) \cdot e^{\frac{-2}{z1}} \]
            2. Taylor expanded in z1 around -inf

              \[\leadsto \color{blue}{1 + -1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
            3. Step-by-step derivation
              1. lower-+.f64N/A

                \[\leadsto 1 + \color{blue}{-1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
              2. lower-*.f64N/A

                \[\leadsto 1 + -1 \cdot \color{blue}{\frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
              3. lower-/.f64N/A

                \[\leadsto 1 + -1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{\color{blue}{z1}} \]
            4. Applied rewrites71.0%

              \[\leadsto \color{blue}{1 + -1 \cdot \frac{-1 \cdot \frac{1.3333333333333333 \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
            5. Taylor expanded in z0 around -inf

              \[\leadsto 1 + -1 \cdot \frac{\frac{z0 \cdot \left(2 - \frac{4}{3} \cdot \frac{1}{z1}\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} \]
            6. Step-by-step derivation
              1. lower-/.f64N/A

                \[\leadsto 1 + -1 \cdot \frac{\frac{z0 \cdot \left(2 - \frac{4}{3} \cdot \frac{1}{z1}\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} \]
              2. lower-*.f64N/A

                \[\leadsto 1 + -1 \cdot \frac{\frac{z0 \cdot \left(2 - \frac{4}{3} \cdot \frac{1}{z1}\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} \]
              3. lower--.f64N/A

                \[\leadsto 1 + -1 \cdot \frac{\frac{z0 \cdot \left(2 - \frac{4}{3} \cdot \frac{1}{z1}\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} \]
              4. lower-*.f64N/A

                \[\leadsto 1 + -1 \cdot \frac{\frac{z0 \cdot \left(2 - \frac{4}{3} \cdot \frac{1}{z1}\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} \]
              5. lower-/.f6465.2%

                \[\leadsto 1 + -1 \cdot \frac{\frac{z0 \cdot \left(2 - 1.3333333333333333 \cdot \frac{1}{z1}\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} \]
            7. Applied rewrites65.2%

              \[\leadsto 1 + -1 \cdot \frac{\frac{z0 \cdot \left(2 - 1.3333333333333333 \cdot \frac{1}{z1}\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} \]

            if 1.9999999999999999e58 < (/.f64 #s(literal -2 binary64) z1)

            1. Initial program 76.8%

              \[z0 - \left(z0 - 1\right) \cdot e^{\frac{-2}{z1}} \]
            2. Taylor expanded in z1 around -inf

              \[\leadsto z0 - \left(z0 - 1\right) \cdot \color{blue}{\left(1 + -1 \cdot \frac{2 - 2 \cdot \frac{1}{z1}}{z1}\right)} \]
            3. Step-by-step derivation
              1. lower-+.f64N/A

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

                \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(1 + -1 \cdot \color{blue}{\frac{2 - 2 \cdot \frac{1}{z1}}{z1}}\right) \]
              3. lower-/.f64N/A

                \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(1 + -1 \cdot \frac{2 - 2 \cdot \frac{1}{z1}}{\color{blue}{z1}}\right) \]
              4. lower--.f64N/A

                \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(1 + -1 \cdot \frac{2 - 2 \cdot \frac{1}{z1}}{z1}\right) \]
              5. lower-*.f64N/A

                \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(1 + -1 \cdot \frac{2 - 2 \cdot \frac{1}{z1}}{z1}\right) \]
              6. lower-/.f6443.7%

                \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(1 + -1 \cdot \frac{2 - 2 \cdot \frac{1}{z1}}{z1}\right) \]
            4. Applied rewrites43.7%

              \[\leadsto z0 - \left(z0 - 1\right) \cdot \color{blue}{\left(1 + -1 \cdot \frac{2 - 2 \cdot \frac{1}{z1}}{z1}\right)} \]
            5. Step-by-step derivation
              1. lift-+.f64N/A

                \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(1 + \color{blue}{-1 \cdot \frac{2 - 2 \cdot \frac{1}{z1}}{z1}}\right) \]
              2. +-commutativeN/A

                \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(-1 \cdot \frac{2 - 2 \cdot \frac{1}{z1}}{z1} + \color{blue}{1}\right) \]
              3. add-flipN/A

                \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(-1 \cdot \frac{2 - 2 \cdot \frac{1}{z1}}{z1} - \color{blue}{\left(\mathsf{neg}\left(1\right)\right)}\right) \]
              4. metadata-evalN/A

                \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(-1 \cdot \frac{2 - 2 \cdot \frac{1}{z1}}{z1} - -1\right) \]
              5. lower--.f6443.7%

                \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(-1 \cdot \frac{2 - 2 \cdot \frac{1}{z1}}{z1} - \color{blue}{-1}\right) \]
              6. lift-*.f64N/A

                \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(-1 \cdot \frac{2 - 2 \cdot \frac{1}{z1}}{z1} - -1\right) \]
              7. mul-1-negN/A

                \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\left(\mathsf{neg}\left(\frac{2 - 2 \cdot \frac{1}{z1}}{z1}\right)\right) - -1\right) \]
              8. lift-/.f64N/A

                \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\left(\mathsf{neg}\left(\frac{2 - 2 \cdot \frac{1}{z1}}{z1}\right)\right) - -1\right) \]
              9. distribute-neg-fracN/A

                \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\frac{\mathsf{neg}\left(\left(2 - 2 \cdot \frac{1}{z1}\right)\right)}{z1} - -1\right) \]
              10. lower-/.f64N/A

                \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\frac{\mathsf{neg}\left(\left(2 - 2 \cdot \frac{1}{z1}\right)\right)}{z1} - -1\right) \]
              11. lift--.f64N/A

                \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\frac{\mathsf{neg}\left(\left(2 - 2 \cdot \frac{1}{z1}\right)\right)}{z1} - -1\right) \]
              12. sub-negate-revN/A

                \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\frac{2 \cdot \frac{1}{z1} - 2}{z1} - -1\right) \]
              13. lower--.f6443.7%

                \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\frac{2 \cdot \frac{1}{z1} - 2}{z1} - -1\right) \]
              14. lift-*.f64N/A

                \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\frac{2 \cdot \frac{1}{z1} - 2}{z1} - -1\right) \]
              15. lift-/.f64N/A

                \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\frac{2 \cdot \frac{1}{z1} - 2}{z1} - -1\right) \]
              16. mult-flip-revN/A

                \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\frac{\frac{2}{z1} - 2}{z1} - -1\right) \]
              17. lower-/.f6443.7%

                \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\frac{\frac{2}{z1} - 2}{z1} - -1\right) \]
            6. Applied rewrites43.7%

              \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\frac{\frac{2}{z1} - 2}{z1} - \color{blue}{-1}\right) \]
            7. Applied rewrites17.8%

              \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\frac{\left(z1 + z1\right) \cdot z1 - \left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot 2}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1} - -1\right) \]
            8. Step-by-step derivation
              1. lift-/.f64N/A

                \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\frac{\left(z1 + z1\right) \cdot z1 - \left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot 2}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1} - -1\right) \]
              2. lift--.f64N/A

                \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\frac{\left(z1 + z1\right) \cdot z1 - \left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot 2}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1} - -1\right) \]
              3. div-subN/A

                \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\left(\frac{\left(z1 + z1\right) \cdot z1}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1} - \frac{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot 2}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1}\right) - -1\right) \]
              4. lift-*.f64N/A

                \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\left(\frac{\left(z1 + z1\right) \cdot z1}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1} - \frac{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot 2}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1}\right) - -1\right) \]
              5. *-commutativeN/A

                \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\left(\frac{\left(z1 + z1\right) \cdot z1}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1} - \frac{2 \cdot \left(\left(z1 \cdot z1\right) \cdot z1\right)}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1}\right) - -1\right) \]
              6. associate-/l*N/A

                \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\left(\frac{\left(z1 + z1\right) \cdot z1}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1} - 2 \cdot \frac{\left(z1 \cdot z1\right) \cdot z1}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1}\right) - -1\right) \]
              7. lift-*.f64N/A

                \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\left(\frac{\left(z1 + z1\right) \cdot z1}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1} - 2 \cdot \frac{\left(z1 \cdot z1\right) \cdot z1}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1}\right) - -1\right) \]
              8. lift-*.f64N/A

                \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\left(\frac{\left(z1 + z1\right) \cdot z1}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1} - 2 \cdot \frac{\left(z1 \cdot z1\right) \cdot z1}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1}\right) - -1\right) \]
              9. pow3N/A

                \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\left(\frac{\left(z1 + z1\right) \cdot z1}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1} - 2 \cdot \frac{{z1}^{3}}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1}\right) - -1\right) \]
              10. lift-*.f64N/A

                \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\left(\frac{\left(z1 + z1\right) \cdot z1}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1} - 2 \cdot \frac{{z1}^{3}}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1}\right) - -1\right) \]
              11. lift-*.f64N/A

                \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\left(\frac{\left(z1 + z1\right) \cdot z1}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1} - 2 \cdot \frac{{z1}^{3}}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1}\right) - -1\right) \]
              12. associate-*l*N/A

                \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\left(\frac{\left(z1 + z1\right) \cdot z1}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1} - 2 \cdot \frac{{z1}^{3}}{\left(z1 \cdot z1\right) \cdot \left(z1 \cdot z1\right)}\right) - -1\right) \]
              13. lift-*.f64N/A

                \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\left(\frac{\left(z1 + z1\right) \cdot z1}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1} - 2 \cdot \frac{{z1}^{3}}{\left(z1 \cdot z1\right) \cdot \left(z1 \cdot z1\right)}\right) - -1\right) \]
              14. pow2N/A

                \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\left(\frac{\left(z1 + z1\right) \cdot z1}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1} - 2 \cdot \frac{{z1}^{3}}{{z1}^{2} \cdot \left(z1 \cdot z1\right)}\right) - -1\right) \]
              15. pow2N/A

                \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\left(\frac{\left(z1 + z1\right) \cdot z1}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1} - 2 \cdot \frac{{z1}^{3}}{{z1}^{2} \cdot {z1}^{2}}\right) - -1\right) \]
              16. pow-prod-upN/A

                \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\left(\frac{\left(z1 + z1\right) \cdot z1}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1} - 2 \cdot \frac{{z1}^{3}}{{z1}^{\left(2 + 2\right)}}\right) - -1\right) \]
              17. pow-divN/A

                \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\left(\frac{\left(z1 + z1\right) \cdot z1}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1} - 2 \cdot {z1}^{\left(3 - \left(2 + 2\right)\right)}\right) - -1\right) \]
              18. metadata-evalN/A

                \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\left(\frac{\left(z1 + z1\right) \cdot z1}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1} - 2 \cdot {z1}^{\left(3 - 4\right)}\right) - -1\right) \]
              19. metadata-evalN/A

                \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\left(\frac{\left(z1 + z1\right) \cdot z1}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1} - 2 \cdot {z1}^{-1}\right) - -1\right) \]
              20. inv-powN/A

                \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\left(\frac{\left(z1 + z1\right) \cdot z1}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1} - 2 \cdot \frac{1}{z1}\right) - -1\right) \]
            9. Applied rewrites47.7%

              \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\left(\left(z1 + z1\right) \cdot \frac{z1}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1} - \frac{2}{z1}\right) - -1\right) \]
          4. Recombined 3 regimes into one program.
          5. Add Preprocessing

          Alternative 6: 82.4% accurate, 1.3× speedup?

          \[\begin{array}{l} \mathbf{if}\;\frac{-2}{z1} \leq -40000:\\ \;\;\;\;z0 - -1 \cdot 1\\ \mathbf{elif}\;\frac{-2}{z1} \leq 2 \cdot 10^{+58}:\\ \;\;\;\;1 + \frac{z0 \cdot \left(2 + -1 \cdot \frac{2 - 1.3333333333333333 \cdot \frac{1}{z1}}{z1}\right)}{z1}\\ \mathbf{else}:\\ \;\;\;\;z0 - \left(z0 - 1\right) \cdot \left(\left(\left(z1 + z1\right) \cdot \frac{z1}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1} - \frac{2}{z1}\right) - -1\right)\\ \end{array} \]
          (FPCore (z0 z1)
            :precision binary64
            (if (<= (/ -2.0 z1) -40000.0)
            (- z0 (* -1.0 1.0))
            (if (<= (/ -2.0 z1) 2e+58)
              (+
               1.0
               (/
                (*
                 z0
                 (+
                  2.0
                  (* -1.0 (/ (- 2.0 (* 1.3333333333333333 (/ 1.0 z1))) z1))))
                z1))
              (-
               z0
               (*
                (- z0 1.0)
                (-
                 (- (* (+ z1 z1) (/ z1 (* (* (* z1 z1) z1) z1))) (/ 2.0 z1))
                 -1.0))))))
          double code(double z0, double z1) {
          	double tmp;
          	if ((-2.0 / z1) <= -40000.0) {
          		tmp = z0 - (-1.0 * 1.0);
          	} else if ((-2.0 / z1) <= 2e+58) {
          		tmp = 1.0 + ((z0 * (2.0 + (-1.0 * ((2.0 - (1.3333333333333333 * (1.0 / z1))) / z1)))) / z1);
          	} else {
          		tmp = z0 - ((z0 - 1.0) * ((((z1 + z1) * (z1 / (((z1 * z1) * z1) * z1))) - (2.0 / z1)) - -1.0));
          	}
          	return tmp;
          }
          
          module fmin_fmax_functions
              implicit none
              private
              public fmax
              public fmin
          
              interface fmax
                  module procedure fmax88
                  module procedure fmax44
                  module procedure fmax84
                  module procedure fmax48
              end interface
              interface fmin
                  module procedure fmin88
                  module procedure fmin44
                  module procedure fmin84
                  module procedure fmin48
              end interface
          contains
              real(8) function fmax88(x, y) result (res)
                  real(8), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
              end function
              real(4) function fmax44(x, y) result (res)
                  real(4), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
              end function
              real(8) function fmax84(x, y) result(res)
                  real(8), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
              end function
              real(8) function fmax48(x, y) result(res)
                  real(4), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
              end function
              real(8) function fmin88(x, y) result (res)
                  real(8), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
              end function
              real(4) function fmin44(x, y) result (res)
                  real(4), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
              end function
              real(8) function fmin84(x, y) result(res)
                  real(8), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
              end function
              real(8) function fmin48(x, y) result(res)
                  real(4), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
              end function
          end module
          
          real(8) function code(z0, z1)
          use fmin_fmax_functions
              real(8), intent (in) :: z0
              real(8), intent (in) :: z1
              real(8) :: tmp
              if (((-2.0d0) / z1) <= (-40000.0d0)) then
                  tmp = z0 - ((-1.0d0) * 1.0d0)
              else if (((-2.0d0) / z1) <= 2d+58) then
                  tmp = 1.0d0 + ((z0 * (2.0d0 + ((-1.0d0) * ((2.0d0 - (1.3333333333333333d0 * (1.0d0 / z1))) / z1)))) / z1)
              else
                  tmp = z0 - ((z0 - 1.0d0) * ((((z1 + z1) * (z1 / (((z1 * z1) * z1) * z1))) - (2.0d0 / z1)) - (-1.0d0)))
              end if
              code = tmp
          end function
          
          public static double code(double z0, double z1) {
          	double tmp;
          	if ((-2.0 / z1) <= -40000.0) {
          		tmp = z0 - (-1.0 * 1.0);
          	} else if ((-2.0 / z1) <= 2e+58) {
          		tmp = 1.0 + ((z0 * (2.0 + (-1.0 * ((2.0 - (1.3333333333333333 * (1.0 / z1))) / z1)))) / z1);
          	} else {
          		tmp = z0 - ((z0 - 1.0) * ((((z1 + z1) * (z1 / (((z1 * z1) * z1) * z1))) - (2.0 / z1)) - -1.0));
          	}
          	return tmp;
          }
          
          def code(z0, z1):
          	tmp = 0
          	if (-2.0 / z1) <= -40000.0:
          		tmp = z0 - (-1.0 * 1.0)
          	elif (-2.0 / z1) <= 2e+58:
          		tmp = 1.0 + ((z0 * (2.0 + (-1.0 * ((2.0 - (1.3333333333333333 * (1.0 / z1))) / z1)))) / z1)
          	else:
          		tmp = z0 - ((z0 - 1.0) * ((((z1 + z1) * (z1 / (((z1 * z1) * z1) * z1))) - (2.0 / z1)) - -1.0))
          	return tmp
          
          function code(z0, z1)
          	tmp = 0.0
          	if (Float64(-2.0 / z1) <= -40000.0)
          		tmp = Float64(z0 - Float64(-1.0 * 1.0));
          	elseif (Float64(-2.0 / z1) <= 2e+58)
          		tmp = Float64(1.0 + Float64(Float64(z0 * Float64(2.0 + Float64(-1.0 * Float64(Float64(2.0 - Float64(1.3333333333333333 * Float64(1.0 / z1))) / z1)))) / z1));
          	else
          		tmp = Float64(z0 - Float64(Float64(z0 - 1.0) * Float64(Float64(Float64(Float64(z1 + z1) * Float64(z1 / Float64(Float64(Float64(z1 * z1) * z1) * z1))) - Float64(2.0 / z1)) - -1.0)));
          	end
          	return tmp
          end
          
          function tmp_2 = code(z0, z1)
          	tmp = 0.0;
          	if ((-2.0 / z1) <= -40000.0)
          		tmp = z0 - (-1.0 * 1.0);
          	elseif ((-2.0 / z1) <= 2e+58)
          		tmp = 1.0 + ((z0 * (2.0 + (-1.0 * ((2.0 - (1.3333333333333333 * (1.0 / z1))) / z1)))) / z1);
          	else
          		tmp = z0 - ((z0 - 1.0) * ((((z1 + z1) * (z1 / (((z1 * z1) * z1) * z1))) - (2.0 / z1)) - -1.0));
          	end
          	tmp_2 = tmp;
          end
          
          code[z0_, z1_] := If[LessEqual[N[(-2.0 / z1), $MachinePrecision], -40000.0], N[(z0 - N[(-1.0 * 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(-2.0 / z1), $MachinePrecision], 2e+58], N[(1.0 + N[(N[(z0 * N[(2.0 + N[(-1.0 * N[(N[(2.0 - N[(1.3333333333333333 * N[(1.0 / z1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z1), $MachinePrecision]), $MachinePrecision], N[(z0 - N[(N[(z0 - 1.0), $MachinePrecision] * N[(N[(N[(N[(z1 + z1), $MachinePrecision] * N[(z1 / N[(N[(N[(z1 * z1), $MachinePrecision] * z1), $MachinePrecision] * z1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(2.0 / z1), $MachinePrecision]), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
          
          \begin{array}{l}
          \mathbf{if}\;\frac{-2}{z1} \leq -40000:\\
          \;\;\;\;z0 - -1 \cdot 1\\
          
          \mathbf{elif}\;\frac{-2}{z1} \leq 2 \cdot 10^{+58}:\\
          \;\;\;\;1 + \frac{z0 \cdot \left(2 + -1 \cdot \frac{2 - 1.3333333333333333 \cdot \frac{1}{z1}}{z1}\right)}{z1}\\
          
          \mathbf{else}:\\
          \;\;\;\;z0 - \left(z0 - 1\right) \cdot \left(\left(\left(z1 + z1\right) \cdot \frac{z1}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1} - \frac{2}{z1}\right) - -1\right)\\
          
          
          \end{array}
          
          Derivation
          1. Split input into 3 regimes
          2. if (/.f64 #s(literal -2 binary64) z1) < -4e4

            1. Initial program 76.8%

              \[z0 - \left(z0 - 1\right) \cdot e^{\frac{-2}{z1}} \]
            2. Taylor expanded in z1 around inf

              \[\leadsto z0 - \left(z0 - 1\right) \cdot \color{blue}{1} \]
            3. Step-by-step derivation
              1. Applied rewrites27.8%

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

                \[\leadsto z0 - \color{blue}{-1} \cdot 1 \]
              3. Step-by-step derivation
                1. Applied rewrites37.4%

                  \[\leadsto z0 - \color{blue}{-1} \cdot 1 \]

                if -4e4 < (/.f64 #s(literal -2 binary64) z1) < 1.9999999999999999e58

                1. Initial program 76.8%

                  \[z0 - \left(z0 - 1\right) \cdot e^{\frac{-2}{z1}} \]
                2. Taylor expanded in z1 around -inf

                  \[\leadsto \color{blue}{1 + -1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                3. Step-by-step derivation
                  1. lower-+.f64N/A

                    \[\leadsto 1 + \color{blue}{-1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                  2. lower-*.f64N/A

                    \[\leadsto 1 + -1 \cdot \color{blue}{\frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                  3. lower-/.f64N/A

                    \[\leadsto 1 + -1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{\color{blue}{z1}} \]
                4. Applied rewrites71.0%

                  \[\leadsto \color{blue}{1 + -1 \cdot \frac{-1 \cdot \frac{1.3333333333333333 \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                5. Taylor expanded in z0 around -inf

                  \[\leadsto 1 + \frac{z0 \cdot \left(2 + -1 \cdot \frac{2 - \frac{4}{3} \cdot \frac{1}{z1}}{z1}\right)}{\color{blue}{z1}} \]
                6. Step-by-step derivation
                  1. lower-/.f64N/A

                    \[\leadsto 1 + \frac{z0 \cdot \left(2 + -1 \cdot \frac{2 - \frac{4}{3} \cdot \frac{1}{z1}}{z1}\right)}{z1} \]
                  2. lower-*.f64N/A

                    \[\leadsto 1 + \frac{z0 \cdot \left(2 + -1 \cdot \frac{2 - \frac{4}{3} \cdot \frac{1}{z1}}{z1}\right)}{z1} \]
                  3. lower-+.f64N/A

                    \[\leadsto 1 + \frac{z0 \cdot \left(2 + -1 \cdot \frac{2 - \frac{4}{3} \cdot \frac{1}{z1}}{z1}\right)}{z1} \]
                  4. lower-*.f64N/A

                    \[\leadsto 1 + \frac{z0 \cdot \left(2 + -1 \cdot \frac{2 - \frac{4}{3} \cdot \frac{1}{z1}}{z1}\right)}{z1} \]
                  5. lower-/.f64N/A

                    \[\leadsto 1 + \frac{z0 \cdot \left(2 + -1 \cdot \frac{2 - \frac{4}{3} \cdot \frac{1}{z1}}{z1}\right)}{z1} \]
                  6. lower--.f64N/A

                    \[\leadsto 1 + \frac{z0 \cdot \left(2 + -1 \cdot \frac{2 - \frac{4}{3} \cdot \frac{1}{z1}}{z1}\right)}{z1} \]
                  7. lower-*.f64N/A

                    \[\leadsto 1 + \frac{z0 \cdot \left(2 + -1 \cdot \frac{2 - \frac{4}{3} \cdot \frac{1}{z1}}{z1}\right)}{z1} \]
                  8. lower-/.f6465.2%

                    \[\leadsto 1 + \frac{z0 \cdot \left(2 + -1 \cdot \frac{2 - 1.3333333333333333 \cdot \frac{1}{z1}}{z1}\right)}{z1} \]
                7. Applied rewrites65.2%

                  \[\leadsto 1 + \frac{z0 \cdot \left(2 + -1 \cdot \frac{2 - 1.3333333333333333 \cdot \frac{1}{z1}}{z1}\right)}{\color{blue}{z1}} \]

                if 1.9999999999999999e58 < (/.f64 #s(literal -2 binary64) z1)

                1. Initial program 76.8%

                  \[z0 - \left(z0 - 1\right) \cdot e^{\frac{-2}{z1}} \]
                2. Taylor expanded in z1 around -inf

                  \[\leadsto z0 - \left(z0 - 1\right) \cdot \color{blue}{\left(1 + -1 \cdot \frac{2 - 2 \cdot \frac{1}{z1}}{z1}\right)} \]
                3. Step-by-step derivation
                  1. lower-+.f64N/A

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

                    \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(1 + -1 \cdot \color{blue}{\frac{2 - 2 \cdot \frac{1}{z1}}{z1}}\right) \]
                  3. lower-/.f64N/A

                    \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(1 + -1 \cdot \frac{2 - 2 \cdot \frac{1}{z1}}{\color{blue}{z1}}\right) \]
                  4. lower--.f64N/A

                    \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(1 + -1 \cdot \frac{2 - 2 \cdot \frac{1}{z1}}{z1}\right) \]
                  5. lower-*.f64N/A

                    \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(1 + -1 \cdot \frac{2 - 2 \cdot \frac{1}{z1}}{z1}\right) \]
                  6. lower-/.f6443.7%

                    \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(1 + -1 \cdot \frac{2 - 2 \cdot \frac{1}{z1}}{z1}\right) \]
                4. Applied rewrites43.7%

                  \[\leadsto z0 - \left(z0 - 1\right) \cdot \color{blue}{\left(1 + -1 \cdot \frac{2 - 2 \cdot \frac{1}{z1}}{z1}\right)} \]
                5. Step-by-step derivation
                  1. lift-+.f64N/A

                    \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(1 + \color{blue}{-1 \cdot \frac{2 - 2 \cdot \frac{1}{z1}}{z1}}\right) \]
                  2. +-commutativeN/A

                    \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(-1 \cdot \frac{2 - 2 \cdot \frac{1}{z1}}{z1} + \color{blue}{1}\right) \]
                  3. add-flipN/A

                    \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(-1 \cdot \frac{2 - 2 \cdot \frac{1}{z1}}{z1} - \color{blue}{\left(\mathsf{neg}\left(1\right)\right)}\right) \]
                  4. metadata-evalN/A

                    \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(-1 \cdot \frac{2 - 2 \cdot \frac{1}{z1}}{z1} - -1\right) \]
                  5. lower--.f6443.7%

                    \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(-1 \cdot \frac{2 - 2 \cdot \frac{1}{z1}}{z1} - \color{blue}{-1}\right) \]
                  6. lift-*.f64N/A

                    \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(-1 \cdot \frac{2 - 2 \cdot \frac{1}{z1}}{z1} - -1\right) \]
                  7. mul-1-negN/A

                    \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\left(\mathsf{neg}\left(\frac{2 - 2 \cdot \frac{1}{z1}}{z1}\right)\right) - -1\right) \]
                  8. lift-/.f64N/A

                    \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\left(\mathsf{neg}\left(\frac{2 - 2 \cdot \frac{1}{z1}}{z1}\right)\right) - -1\right) \]
                  9. distribute-neg-fracN/A

                    \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\frac{\mathsf{neg}\left(\left(2 - 2 \cdot \frac{1}{z1}\right)\right)}{z1} - -1\right) \]
                  10. lower-/.f64N/A

                    \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\frac{\mathsf{neg}\left(\left(2 - 2 \cdot \frac{1}{z1}\right)\right)}{z1} - -1\right) \]
                  11. lift--.f64N/A

                    \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\frac{\mathsf{neg}\left(\left(2 - 2 \cdot \frac{1}{z1}\right)\right)}{z1} - -1\right) \]
                  12. sub-negate-revN/A

                    \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\frac{2 \cdot \frac{1}{z1} - 2}{z1} - -1\right) \]
                  13. lower--.f6443.7%

                    \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\frac{2 \cdot \frac{1}{z1} - 2}{z1} - -1\right) \]
                  14. lift-*.f64N/A

                    \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\frac{2 \cdot \frac{1}{z1} - 2}{z1} - -1\right) \]
                  15. lift-/.f64N/A

                    \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\frac{2 \cdot \frac{1}{z1} - 2}{z1} - -1\right) \]
                  16. mult-flip-revN/A

                    \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\frac{\frac{2}{z1} - 2}{z1} - -1\right) \]
                  17. lower-/.f6443.7%

                    \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\frac{\frac{2}{z1} - 2}{z1} - -1\right) \]
                6. Applied rewrites43.7%

                  \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\frac{\frac{2}{z1} - 2}{z1} - \color{blue}{-1}\right) \]
                7. Applied rewrites17.8%

                  \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\frac{\left(z1 + z1\right) \cdot z1 - \left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot 2}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1} - -1\right) \]
                8. Step-by-step derivation
                  1. lift-/.f64N/A

                    \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\frac{\left(z1 + z1\right) \cdot z1 - \left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot 2}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1} - -1\right) \]
                  2. lift--.f64N/A

                    \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\frac{\left(z1 + z1\right) \cdot z1 - \left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot 2}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1} - -1\right) \]
                  3. div-subN/A

                    \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\left(\frac{\left(z1 + z1\right) \cdot z1}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1} - \frac{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot 2}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1}\right) - -1\right) \]
                  4. lift-*.f64N/A

                    \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\left(\frac{\left(z1 + z1\right) \cdot z1}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1} - \frac{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot 2}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1}\right) - -1\right) \]
                  5. *-commutativeN/A

                    \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\left(\frac{\left(z1 + z1\right) \cdot z1}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1} - \frac{2 \cdot \left(\left(z1 \cdot z1\right) \cdot z1\right)}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1}\right) - -1\right) \]
                  6. associate-/l*N/A

                    \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\left(\frac{\left(z1 + z1\right) \cdot z1}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1} - 2 \cdot \frac{\left(z1 \cdot z1\right) \cdot z1}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1}\right) - -1\right) \]
                  7. lift-*.f64N/A

                    \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\left(\frac{\left(z1 + z1\right) \cdot z1}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1} - 2 \cdot \frac{\left(z1 \cdot z1\right) \cdot z1}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1}\right) - -1\right) \]
                  8. lift-*.f64N/A

                    \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\left(\frac{\left(z1 + z1\right) \cdot z1}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1} - 2 \cdot \frac{\left(z1 \cdot z1\right) \cdot z1}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1}\right) - -1\right) \]
                  9. pow3N/A

                    \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\left(\frac{\left(z1 + z1\right) \cdot z1}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1} - 2 \cdot \frac{{z1}^{3}}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1}\right) - -1\right) \]
                  10. lift-*.f64N/A

                    \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\left(\frac{\left(z1 + z1\right) \cdot z1}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1} - 2 \cdot \frac{{z1}^{3}}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1}\right) - -1\right) \]
                  11. lift-*.f64N/A

                    \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\left(\frac{\left(z1 + z1\right) \cdot z1}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1} - 2 \cdot \frac{{z1}^{3}}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1}\right) - -1\right) \]
                  12. associate-*l*N/A

                    \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\left(\frac{\left(z1 + z1\right) \cdot z1}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1} - 2 \cdot \frac{{z1}^{3}}{\left(z1 \cdot z1\right) \cdot \left(z1 \cdot z1\right)}\right) - -1\right) \]
                  13. lift-*.f64N/A

                    \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\left(\frac{\left(z1 + z1\right) \cdot z1}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1} - 2 \cdot \frac{{z1}^{3}}{\left(z1 \cdot z1\right) \cdot \left(z1 \cdot z1\right)}\right) - -1\right) \]
                  14. pow2N/A

                    \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\left(\frac{\left(z1 + z1\right) \cdot z1}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1} - 2 \cdot \frac{{z1}^{3}}{{z1}^{2} \cdot \left(z1 \cdot z1\right)}\right) - -1\right) \]
                  15. pow2N/A

                    \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\left(\frac{\left(z1 + z1\right) \cdot z1}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1} - 2 \cdot \frac{{z1}^{3}}{{z1}^{2} \cdot {z1}^{2}}\right) - -1\right) \]
                  16. pow-prod-upN/A

                    \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\left(\frac{\left(z1 + z1\right) \cdot z1}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1} - 2 \cdot \frac{{z1}^{3}}{{z1}^{\left(2 + 2\right)}}\right) - -1\right) \]
                  17. pow-divN/A

                    \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\left(\frac{\left(z1 + z1\right) \cdot z1}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1} - 2 \cdot {z1}^{\left(3 - \left(2 + 2\right)\right)}\right) - -1\right) \]
                  18. metadata-evalN/A

                    \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\left(\frac{\left(z1 + z1\right) \cdot z1}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1} - 2 \cdot {z1}^{\left(3 - 4\right)}\right) - -1\right) \]
                  19. metadata-evalN/A

                    \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\left(\frac{\left(z1 + z1\right) \cdot z1}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1} - 2 \cdot {z1}^{-1}\right) - -1\right) \]
                  20. inv-powN/A

                    \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\left(\frac{\left(z1 + z1\right) \cdot z1}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1} - 2 \cdot \frac{1}{z1}\right) - -1\right) \]
                9. Applied rewrites47.7%

                  \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(\left(\left(z1 + z1\right) \cdot \frac{z1}{\left(\left(z1 \cdot z1\right) \cdot z1\right) \cdot z1} - \frac{2}{z1}\right) - -1\right) \]
              4. Recombined 3 regimes into one program.
              5. Add Preprocessing

              Alternative 7: 82.0% accurate, 0.6× speedup?

              \[\begin{array}{l} t_0 := 2 \cdot \left(z0 - 1\right)\\ \mathbf{if}\;e^{\frac{-2}{z1}} \leq 4 \cdot 10^{-15}:\\ \;\;\;\;z0 - -1 \cdot 1\\ \mathbf{else}:\\ \;\;\;\;1 + -1 \cdot \frac{-1 \cdot \frac{1.3333333333333333 \cdot \frac{z0 - 1}{z1} - t\_0}{z1} - t\_0}{z1}\\ \end{array} \]
              (FPCore (z0 z1)
                :precision binary64
                (let* ((t_0 (* 2.0 (- z0 1.0))))
                (if (<= (exp (/ -2.0 z1)) 4e-15)
                  (- z0 (* -1.0 1.0))
                  (+
                   1.0
                   (*
                    -1.0
                    (/
                     (-
                      (*
                       -1.0
                       (/ (- (* 1.3333333333333333 (/ (- z0 1.0) z1)) t_0) z1))
                      t_0)
                     z1))))))
              double code(double z0, double z1) {
              	double t_0 = 2.0 * (z0 - 1.0);
              	double tmp;
              	if (exp((-2.0 / z1)) <= 4e-15) {
              		tmp = z0 - (-1.0 * 1.0);
              	} else {
              		tmp = 1.0 + (-1.0 * (((-1.0 * (((1.3333333333333333 * ((z0 - 1.0) / z1)) - t_0) / z1)) - t_0) / z1));
              	}
              	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(z0, z1)
              use fmin_fmax_functions
                  real(8), intent (in) :: z0
                  real(8), intent (in) :: z1
                  real(8) :: t_0
                  real(8) :: tmp
                  t_0 = 2.0d0 * (z0 - 1.0d0)
                  if (exp(((-2.0d0) / z1)) <= 4d-15) then
                      tmp = z0 - ((-1.0d0) * 1.0d0)
                  else
                      tmp = 1.0d0 + ((-1.0d0) * ((((-1.0d0) * (((1.3333333333333333d0 * ((z0 - 1.0d0) / z1)) - t_0) / z1)) - t_0) / z1))
                  end if
                  code = tmp
              end function
              
              public static double code(double z0, double z1) {
              	double t_0 = 2.0 * (z0 - 1.0);
              	double tmp;
              	if (Math.exp((-2.0 / z1)) <= 4e-15) {
              		tmp = z0 - (-1.0 * 1.0);
              	} else {
              		tmp = 1.0 + (-1.0 * (((-1.0 * (((1.3333333333333333 * ((z0 - 1.0) / z1)) - t_0) / z1)) - t_0) / z1));
              	}
              	return tmp;
              }
              
              def code(z0, z1):
              	t_0 = 2.0 * (z0 - 1.0)
              	tmp = 0
              	if math.exp((-2.0 / z1)) <= 4e-15:
              		tmp = z0 - (-1.0 * 1.0)
              	else:
              		tmp = 1.0 + (-1.0 * (((-1.0 * (((1.3333333333333333 * ((z0 - 1.0) / z1)) - t_0) / z1)) - t_0) / z1))
              	return tmp
              
              function code(z0, z1)
              	t_0 = Float64(2.0 * Float64(z0 - 1.0))
              	tmp = 0.0
              	if (exp(Float64(-2.0 / z1)) <= 4e-15)
              		tmp = Float64(z0 - Float64(-1.0 * 1.0));
              	else
              		tmp = Float64(1.0 + Float64(-1.0 * Float64(Float64(Float64(-1.0 * Float64(Float64(Float64(1.3333333333333333 * Float64(Float64(z0 - 1.0) / z1)) - t_0) / z1)) - t_0) / z1)));
              	end
              	return tmp
              end
              
              function tmp_2 = code(z0, z1)
              	t_0 = 2.0 * (z0 - 1.0);
              	tmp = 0.0;
              	if (exp((-2.0 / z1)) <= 4e-15)
              		tmp = z0 - (-1.0 * 1.0);
              	else
              		tmp = 1.0 + (-1.0 * (((-1.0 * (((1.3333333333333333 * ((z0 - 1.0) / z1)) - t_0) / z1)) - t_0) / z1));
              	end
              	tmp_2 = tmp;
              end
              
              code[z0_, z1_] := Block[{t$95$0 = N[(2.0 * N[(z0 - 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Exp[N[(-2.0 / z1), $MachinePrecision]], $MachinePrecision], 4e-15], N[(z0 - N[(-1.0 * 1.0), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(-1.0 * N[(N[(N[(-1.0 * N[(N[(N[(1.3333333333333333 * N[(N[(z0 - 1.0), $MachinePrecision] / z1), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision] / z1), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision] / z1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
              
              \begin{array}{l}
              t_0 := 2 \cdot \left(z0 - 1\right)\\
              \mathbf{if}\;e^{\frac{-2}{z1}} \leq 4 \cdot 10^{-15}:\\
              \;\;\;\;z0 - -1 \cdot 1\\
              
              \mathbf{else}:\\
              \;\;\;\;1 + -1 \cdot \frac{-1 \cdot \frac{1.3333333333333333 \cdot \frac{z0 - 1}{z1} - t\_0}{z1} - t\_0}{z1}\\
              
              
              \end{array}
              
              Derivation
              1. Split input into 2 regimes
              2. if (exp.f64 (/.f64 #s(literal -2 binary64) z1)) < 4.0000000000000003e-15

                1. Initial program 76.8%

                  \[z0 - \left(z0 - 1\right) \cdot e^{\frac{-2}{z1}} \]
                2. Taylor expanded in z1 around inf

                  \[\leadsto z0 - \left(z0 - 1\right) \cdot \color{blue}{1} \]
                3. Step-by-step derivation
                  1. Applied rewrites27.8%

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

                    \[\leadsto z0 - \color{blue}{-1} \cdot 1 \]
                  3. Step-by-step derivation
                    1. Applied rewrites37.4%

                      \[\leadsto z0 - \color{blue}{-1} \cdot 1 \]

                    if 4.0000000000000003e-15 < (exp.f64 (/.f64 #s(literal -2 binary64) z1))

                    1. Initial program 76.8%

                      \[z0 - \left(z0 - 1\right) \cdot e^{\frac{-2}{z1}} \]
                    2. Taylor expanded in z1 around -inf

                      \[\leadsto \color{blue}{1 + -1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                    3. Step-by-step derivation
                      1. lower-+.f64N/A

                        \[\leadsto 1 + \color{blue}{-1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                      2. lower-*.f64N/A

                        \[\leadsto 1 + -1 \cdot \color{blue}{\frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                      3. lower-/.f64N/A

                        \[\leadsto 1 + -1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{\color{blue}{z1}} \]
                    4. Applied rewrites71.0%

                      \[\leadsto \color{blue}{1 + -1 \cdot \frac{-1 \cdot \frac{1.3333333333333333 \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                  4. Recombined 2 regimes into one program.
                  5. Add Preprocessing

                  Alternative 8: 81.9% accurate, 1.3× speedup?

                  \[\begin{array}{l} \mathbf{if}\;\frac{-2}{z1} \leq -40000:\\ \;\;\;\;z0 - -1 \cdot 1\\ \mathbf{elif}\;\frac{-2}{z1} \leq 2 \cdot 10^{+58}:\\ \;\;\;\;1 + \frac{z0 \cdot \left(2 + -1 \cdot \frac{2 - 1.3333333333333333 \cdot \frac{1}{z1}}{z1}\right)}{z1}\\ \mathbf{else}:\\ \;\;\;\;\left(1 - \frac{\left(1 - \frac{2 - \frac{2}{z1}}{z1}\right) \cdot \left(z0 - 1\right)}{z0}\right) \cdot z0\\ \end{array} \]
                  (FPCore (z0 z1)
                    :precision binary64
                    (if (<= (/ -2.0 z1) -40000.0)
                    (- z0 (* -1.0 1.0))
                    (if (<= (/ -2.0 z1) 2e+58)
                      (+
                       1.0
                       (/
                        (*
                         z0
                         (+
                          2.0
                          (* -1.0 (/ (- 2.0 (* 1.3333333333333333 (/ 1.0 z1))) z1))))
                        z1))
                      (*
                       (- 1.0 (/ (* (- 1.0 (/ (- 2.0 (/ 2.0 z1)) z1)) (- z0 1.0)) z0))
                       z0))))
                  double code(double z0, double z1) {
                  	double tmp;
                  	if ((-2.0 / z1) <= -40000.0) {
                  		tmp = z0 - (-1.0 * 1.0);
                  	} else if ((-2.0 / z1) <= 2e+58) {
                  		tmp = 1.0 + ((z0 * (2.0 + (-1.0 * ((2.0 - (1.3333333333333333 * (1.0 / z1))) / z1)))) / z1);
                  	} else {
                  		tmp = (1.0 - (((1.0 - ((2.0 - (2.0 / z1)) / z1)) * (z0 - 1.0)) / z0)) * z0;
                  	}
                  	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(z0, z1)
                  use fmin_fmax_functions
                      real(8), intent (in) :: z0
                      real(8), intent (in) :: z1
                      real(8) :: tmp
                      if (((-2.0d0) / z1) <= (-40000.0d0)) then
                          tmp = z0 - ((-1.0d0) * 1.0d0)
                      else if (((-2.0d0) / z1) <= 2d+58) then
                          tmp = 1.0d0 + ((z0 * (2.0d0 + ((-1.0d0) * ((2.0d0 - (1.3333333333333333d0 * (1.0d0 / z1))) / z1)))) / z1)
                      else
                          tmp = (1.0d0 - (((1.0d0 - ((2.0d0 - (2.0d0 / z1)) / z1)) * (z0 - 1.0d0)) / z0)) * z0
                      end if
                      code = tmp
                  end function
                  
                  public static double code(double z0, double z1) {
                  	double tmp;
                  	if ((-2.0 / z1) <= -40000.0) {
                  		tmp = z0 - (-1.0 * 1.0);
                  	} else if ((-2.0 / z1) <= 2e+58) {
                  		tmp = 1.0 + ((z0 * (2.0 + (-1.0 * ((2.0 - (1.3333333333333333 * (1.0 / z1))) / z1)))) / z1);
                  	} else {
                  		tmp = (1.0 - (((1.0 - ((2.0 - (2.0 / z1)) / z1)) * (z0 - 1.0)) / z0)) * z0;
                  	}
                  	return tmp;
                  }
                  
                  def code(z0, z1):
                  	tmp = 0
                  	if (-2.0 / z1) <= -40000.0:
                  		tmp = z0 - (-1.0 * 1.0)
                  	elif (-2.0 / z1) <= 2e+58:
                  		tmp = 1.0 + ((z0 * (2.0 + (-1.0 * ((2.0 - (1.3333333333333333 * (1.0 / z1))) / z1)))) / z1)
                  	else:
                  		tmp = (1.0 - (((1.0 - ((2.0 - (2.0 / z1)) / z1)) * (z0 - 1.0)) / z0)) * z0
                  	return tmp
                  
                  function code(z0, z1)
                  	tmp = 0.0
                  	if (Float64(-2.0 / z1) <= -40000.0)
                  		tmp = Float64(z0 - Float64(-1.0 * 1.0));
                  	elseif (Float64(-2.0 / z1) <= 2e+58)
                  		tmp = Float64(1.0 + Float64(Float64(z0 * Float64(2.0 + Float64(-1.0 * Float64(Float64(2.0 - Float64(1.3333333333333333 * Float64(1.0 / z1))) / z1)))) / z1));
                  	else
                  		tmp = Float64(Float64(1.0 - Float64(Float64(Float64(1.0 - Float64(Float64(2.0 - Float64(2.0 / z1)) / z1)) * Float64(z0 - 1.0)) / z0)) * z0);
                  	end
                  	return tmp
                  end
                  
                  function tmp_2 = code(z0, z1)
                  	tmp = 0.0;
                  	if ((-2.0 / z1) <= -40000.0)
                  		tmp = z0 - (-1.0 * 1.0);
                  	elseif ((-2.0 / z1) <= 2e+58)
                  		tmp = 1.0 + ((z0 * (2.0 + (-1.0 * ((2.0 - (1.3333333333333333 * (1.0 / z1))) / z1)))) / z1);
                  	else
                  		tmp = (1.0 - (((1.0 - ((2.0 - (2.0 / z1)) / z1)) * (z0 - 1.0)) / z0)) * z0;
                  	end
                  	tmp_2 = tmp;
                  end
                  
                  code[z0_, z1_] := If[LessEqual[N[(-2.0 / z1), $MachinePrecision], -40000.0], N[(z0 - N[(-1.0 * 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(-2.0 / z1), $MachinePrecision], 2e+58], N[(1.0 + N[(N[(z0 * N[(2.0 + N[(-1.0 * N[(N[(2.0 - N[(1.3333333333333333 * N[(1.0 / z1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z1), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - N[(N[(N[(1.0 - N[(N[(2.0 - N[(2.0 / z1), $MachinePrecision]), $MachinePrecision] / z1), $MachinePrecision]), $MachinePrecision] * N[(z0 - 1.0), $MachinePrecision]), $MachinePrecision] / z0), $MachinePrecision]), $MachinePrecision] * z0), $MachinePrecision]]]
                  
                  \begin{array}{l}
                  \mathbf{if}\;\frac{-2}{z1} \leq -40000:\\
                  \;\;\;\;z0 - -1 \cdot 1\\
                  
                  \mathbf{elif}\;\frac{-2}{z1} \leq 2 \cdot 10^{+58}:\\
                  \;\;\;\;1 + \frac{z0 \cdot \left(2 + -1 \cdot \frac{2 - 1.3333333333333333 \cdot \frac{1}{z1}}{z1}\right)}{z1}\\
                  
                  \mathbf{else}:\\
                  \;\;\;\;\left(1 - \frac{\left(1 - \frac{2 - \frac{2}{z1}}{z1}\right) \cdot \left(z0 - 1\right)}{z0}\right) \cdot z0\\
                  
                  
                  \end{array}
                  
                  Derivation
                  1. Split input into 3 regimes
                  2. if (/.f64 #s(literal -2 binary64) z1) < -4e4

                    1. Initial program 76.8%

                      \[z0 - \left(z0 - 1\right) \cdot e^{\frac{-2}{z1}} \]
                    2. Taylor expanded in z1 around inf

                      \[\leadsto z0 - \left(z0 - 1\right) \cdot \color{blue}{1} \]
                    3. Step-by-step derivation
                      1. Applied rewrites27.8%

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

                        \[\leadsto z0 - \color{blue}{-1} \cdot 1 \]
                      3. Step-by-step derivation
                        1. Applied rewrites37.4%

                          \[\leadsto z0 - \color{blue}{-1} \cdot 1 \]

                        if -4e4 < (/.f64 #s(literal -2 binary64) z1) < 1.9999999999999999e58

                        1. Initial program 76.8%

                          \[z0 - \left(z0 - 1\right) \cdot e^{\frac{-2}{z1}} \]
                        2. Taylor expanded in z1 around -inf

                          \[\leadsto \color{blue}{1 + -1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                        3. Step-by-step derivation
                          1. lower-+.f64N/A

                            \[\leadsto 1 + \color{blue}{-1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                          2. lower-*.f64N/A

                            \[\leadsto 1 + -1 \cdot \color{blue}{\frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                          3. lower-/.f64N/A

                            \[\leadsto 1 + -1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{\color{blue}{z1}} \]
                        4. Applied rewrites71.0%

                          \[\leadsto \color{blue}{1 + -1 \cdot \frac{-1 \cdot \frac{1.3333333333333333 \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                        5. Taylor expanded in z0 around -inf

                          \[\leadsto 1 + \frac{z0 \cdot \left(2 + -1 \cdot \frac{2 - \frac{4}{3} \cdot \frac{1}{z1}}{z1}\right)}{\color{blue}{z1}} \]
                        6. Step-by-step derivation
                          1. lower-/.f64N/A

                            \[\leadsto 1 + \frac{z0 \cdot \left(2 + -1 \cdot \frac{2 - \frac{4}{3} \cdot \frac{1}{z1}}{z1}\right)}{z1} \]
                          2. lower-*.f64N/A

                            \[\leadsto 1 + \frac{z0 \cdot \left(2 + -1 \cdot \frac{2 - \frac{4}{3} \cdot \frac{1}{z1}}{z1}\right)}{z1} \]
                          3. lower-+.f64N/A

                            \[\leadsto 1 + \frac{z0 \cdot \left(2 + -1 \cdot \frac{2 - \frac{4}{3} \cdot \frac{1}{z1}}{z1}\right)}{z1} \]
                          4. lower-*.f64N/A

                            \[\leadsto 1 + \frac{z0 \cdot \left(2 + -1 \cdot \frac{2 - \frac{4}{3} \cdot \frac{1}{z1}}{z1}\right)}{z1} \]
                          5. lower-/.f64N/A

                            \[\leadsto 1 + \frac{z0 \cdot \left(2 + -1 \cdot \frac{2 - \frac{4}{3} \cdot \frac{1}{z1}}{z1}\right)}{z1} \]
                          6. lower--.f64N/A

                            \[\leadsto 1 + \frac{z0 \cdot \left(2 + -1 \cdot \frac{2 - \frac{4}{3} \cdot \frac{1}{z1}}{z1}\right)}{z1} \]
                          7. lower-*.f64N/A

                            \[\leadsto 1 + \frac{z0 \cdot \left(2 + -1 \cdot \frac{2 - \frac{4}{3} \cdot \frac{1}{z1}}{z1}\right)}{z1} \]
                          8. lower-/.f6465.2%

                            \[\leadsto 1 + \frac{z0 \cdot \left(2 + -1 \cdot \frac{2 - 1.3333333333333333 \cdot \frac{1}{z1}}{z1}\right)}{z1} \]
                        7. Applied rewrites65.2%

                          \[\leadsto 1 + \frac{z0 \cdot \left(2 + -1 \cdot \frac{2 - 1.3333333333333333 \cdot \frac{1}{z1}}{z1}\right)}{\color{blue}{z1}} \]

                        if 1.9999999999999999e58 < (/.f64 #s(literal -2 binary64) z1)

                        1. Initial program 76.8%

                          \[z0 - \left(z0 - 1\right) \cdot e^{\frac{-2}{z1}} \]
                        2. Taylor expanded in z1 around -inf

                          \[\leadsto z0 - \left(z0 - 1\right) \cdot \color{blue}{\left(1 + -1 \cdot \frac{2 - 2 \cdot \frac{1}{z1}}{z1}\right)} \]
                        3. Step-by-step derivation
                          1. lower-+.f64N/A

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

                            \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(1 + -1 \cdot \color{blue}{\frac{2 - 2 \cdot \frac{1}{z1}}{z1}}\right) \]
                          3. lower-/.f64N/A

                            \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(1 + -1 \cdot \frac{2 - 2 \cdot \frac{1}{z1}}{\color{blue}{z1}}\right) \]
                          4. lower--.f64N/A

                            \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(1 + -1 \cdot \frac{2 - 2 \cdot \frac{1}{z1}}{z1}\right) \]
                          5. lower-*.f64N/A

                            \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(1 + -1 \cdot \frac{2 - 2 \cdot \frac{1}{z1}}{z1}\right) \]
                          6. lower-/.f6443.7%

                            \[\leadsto z0 - \left(z0 - 1\right) \cdot \left(1 + -1 \cdot \frac{2 - 2 \cdot \frac{1}{z1}}{z1}\right) \]
                        4. Applied rewrites43.7%

                          \[\leadsto z0 - \left(z0 - 1\right) \cdot \color{blue}{\left(1 + -1 \cdot \frac{2 - 2 \cdot \frac{1}{z1}}{z1}\right)} \]
                        5. Step-by-step derivation
                          1. lift--.f64N/A

                            \[\leadsto \color{blue}{z0 - \left(z0 - 1\right) \cdot \left(1 + -1 \cdot \frac{2 - 2 \cdot \frac{1}{z1}}{z1}\right)} \]
                          2. sub-to-multN/A

                            \[\leadsto \color{blue}{\left(1 - \frac{\left(z0 - 1\right) \cdot \left(1 + -1 \cdot \frac{2 - 2 \cdot \frac{1}{z1}}{z1}\right)}{z0}\right) \cdot z0} \]
                          3. lower-unsound-*.f64N/A

                            \[\leadsto \color{blue}{\left(1 - \frac{\left(z0 - 1\right) \cdot \left(1 + -1 \cdot \frac{2 - 2 \cdot \frac{1}{z1}}{z1}\right)}{z0}\right) \cdot z0} \]
                        6. Applied rewrites46.6%

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

                      Alternative 9: 81.9% accurate, 0.4× speedup?

                      \[\begin{array}{l} t_0 := e^{\frac{-2}{z1}}\\ t_1 := \frac{z0 - 1}{z1}\\ \mathbf{if}\;t\_0 \leq 4 \cdot 10^{-15}:\\ \;\;\;\;z0 - -1 \cdot 1\\ \mathbf{elif}\;t\_0 \leq 1.0001:\\ \;\;\;\;1 + \left(\frac{\left(1 - z0\right) \cdot 2}{z1 \cdot z1} - t\_1 \cdot -2\right)\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{\left(-2 \cdot z1 - \left(-2 - t\_1 \cdot 1.3333333333333333\right)\right) \cdot 1}{z1 \cdot z1}\\ \end{array} \]
                      (FPCore (z0 z1)
                        :precision binary64
                        (let* ((t_0 (exp (/ -2.0 z1))) (t_1 (/ (- z0 1.0) z1)))
                        (if (<= t_0 4e-15)
                          (- z0 (* -1.0 1.0))
                          (if (<= t_0 1.0001)
                            (+ 1.0 (- (/ (* (- 1.0 z0) 2.0) (* z1 z1)) (* t_1 -2.0)))
                            (+
                             1.0
                             (/
                              (* (- (* -2.0 z1) (- -2.0 (* t_1 1.3333333333333333))) 1.0)
                              (* z1 z1)))))))
                      double code(double z0, double z1) {
                      	double t_0 = exp((-2.0 / z1));
                      	double t_1 = (z0 - 1.0) / z1;
                      	double tmp;
                      	if (t_0 <= 4e-15) {
                      		tmp = z0 - (-1.0 * 1.0);
                      	} else if (t_0 <= 1.0001) {
                      		tmp = 1.0 + ((((1.0 - z0) * 2.0) / (z1 * z1)) - (t_1 * -2.0));
                      	} else {
                      		tmp = 1.0 + ((((-2.0 * z1) - (-2.0 - (t_1 * 1.3333333333333333))) * 1.0) / (z1 * z1));
                      	}
                      	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(z0, z1)
                      use fmin_fmax_functions
                          real(8), intent (in) :: z0
                          real(8), intent (in) :: z1
                          real(8) :: t_0
                          real(8) :: t_1
                          real(8) :: tmp
                          t_0 = exp(((-2.0d0) / z1))
                          t_1 = (z0 - 1.0d0) / z1
                          if (t_0 <= 4d-15) then
                              tmp = z0 - ((-1.0d0) * 1.0d0)
                          else if (t_0 <= 1.0001d0) then
                              tmp = 1.0d0 + ((((1.0d0 - z0) * 2.0d0) / (z1 * z1)) - (t_1 * (-2.0d0)))
                          else
                              tmp = 1.0d0 + (((((-2.0d0) * z1) - ((-2.0d0) - (t_1 * 1.3333333333333333d0))) * 1.0d0) / (z1 * z1))
                          end if
                          code = tmp
                      end function
                      
                      public static double code(double z0, double z1) {
                      	double t_0 = Math.exp((-2.0 / z1));
                      	double t_1 = (z0 - 1.0) / z1;
                      	double tmp;
                      	if (t_0 <= 4e-15) {
                      		tmp = z0 - (-1.0 * 1.0);
                      	} else if (t_0 <= 1.0001) {
                      		tmp = 1.0 + ((((1.0 - z0) * 2.0) / (z1 * z1)) - (t_1 * -2.0));
                      	} else {
                      		tmp = 1.0 + ((((-2.0 * z1) - (-2.0 - (t_1 * 1.3333333333333333))) * 1.0) / (z1 * z1));
                      	}
                      	return tmp;
                      }
                      
                      def code(z0, z1):
                      	t_0 = math.exp((-2.0 / z1))
                      	t_1 = (z0 - 1.0) / z1
                      	tmp = 0
                      	if t_0 <= 4e-15:
                      		tmp = z0 - (-1.0 * 1.0)
                      	elif t_0 <= 1.0001:
                      		tmp = 1.0 + ((((1.0 - z0) * 2.0) / (z1 * z1)) - (t_1 * -2.0))
                      	else:
                      		tmp = 1.0 + ((((-2.0 * z1) - (-2.0 - (t_1 * 1.3333333333333333))) * 1.0) / (z1 * z1))
                      	return tmp
                      
                      function code(z0, z1)
                      	t_0 = exp(Float64(-2.0 / z1))
                      	t_1 = Float64(Float64(z0 - 1.0) / z1)
                      	tmp = 0.0
                      	if (t_0 <= 4e-15)
                      		tmp = Float64(z0 - Float64(-1.0 * 1.0));
                      	elseif (t_0 <= 1.0001)
                      		tmp = Float64(1.0 + Float64(Float64(Float64(Float64(1.0 - z0) * 2.0) / Float64(z1 * z1)) - Float64(t_1 * -2.0)));
                      	else
                      		tmp = Float64(1.0 + Float64(Float64(Float64(Float64(-2.0 * z1) - Float64(-2.0 - Float64(t_1 * 1.3333333333333333))) * 1.0) / Float64(z1 * z1)));
                      	end
                      	return tmp
                      end
                      
                      function tmp_2 = code(z0, z1)
                      	t_0 = exp((-2.0 / z1));
                      	t_1 = (z0 - 1.0) / z1;
                      	tmp = 0.0;
                      	if (t_0 <= 4e-15)
                      		tmp = z0 - (-1.0 * 1.0);
                      	elseif (t_0 <= 1.0001)
                      		tmp = 1.0 + ((((1.0 - z0) * 2.0) / (z1 * z1)) - (t_1 * -2.0));
                      	else
                      		tmp = 1.0 + ((((-2.0 * z1) - (-2.0 - (t_1 * 1.3333333333333333))) * 1.0) / (z1 * z1));
                      	end
                      	tmp_2 = tmp;
                      end
                      
                      code[z0_, z1_] := Block[{t$95$0 = N[Exp[N[(-2.0 / z1), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(z0 - 1.0), $MachinePrecision] / z1), $MachinePrecision]}, If[LessEqual[t$95$0, 4e-15], N[(z0 - N[(-1.0 * 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1.0001], N[(1.0 + N[(N[(N[(N[(1.0 - z0), $MachinePrecision] * 2.0), $MachinePrecision] / N[(z1 * z1), $MachinePrecision]), $MachinePrecision] - N[(t$95$1 * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[(N[(N[(-2.0 * z1), $MachinePrecision] - N[(-2.0 - N[(t$95$1 * 1.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision] / N[(z1 * z1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
                      
                      \begin{array}{l}
                      t_0 := e^{\frac{-2}{z1}}\\
                      t_1 := \frac{z0 - 1}{z1}\\
                      \mathbf{if}\;t\_0 \leq 4 \cdot 10^{-15}:\\
                      \;\;\;\;z0 - -1 \cdot 1\\
                      
                      \mathbf{elif}\;t\_0 \leq 1.0001:\\
                      \;\;\;\;1 + \left(\frac{\left(1 - z0\right) \cdot 2}{z1 \cdot z1} - t\_1 \cdot -2\right)\\
                      
                      \mathbf{else}:\\
                      \;\;\;\;1 + \frac{\left(-2 \cdot z1 - \left(-2 - t\_1 \cdot 1.3333333333333333\right)\right) \cdot 1}{z1 \cdot z1}\\
                      
                      
                      \end{array}
                      
                      Derivation
                      1. Split input into 3 regimes
                      2. if (exp.f64 (/.f64 #s(literal -2 binary64) z1)) < 4.0000000000000003e-15

                        1. Initial program 76.8%

                          \[z0 - \left(z0 - 1\right) \cdot e^{\frac{-2}{z1}} \]
                        2. Taylor expanded in z1 around inf

                          \[\leadsto z0 - \left(z0 - 1\right) \cdot \color{blue}{1} \]
                        3. Step-by-step derivation
                          1. Applied rewrites27.8%

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

                            \[\leadsto z0 - \color{blue}{-1} \cdot 1 \]
                          3. Step-by-step derivation
                            1. Applied rewrites37.4%

                              \[\leadsto z0 - \color{blue}{-1} \cdot 1 \]

                            if 4.0000000000000003e-15 < (exp.f64 (/.f64 #s(literal -2 binary64) z1)) < 1.0001

                            1. Initial program 76.8%

                              \[z0 - \left(z0 - 1\right) \cdot e^{\frac{-2}{z1}} \]
                            2. Taylor expanded in z1 around -inf

                              \[\leadsto \color{blue}{1 + -1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                            3. Step-by-step derivation
                              1. lower-+.f64N/A

                                \[\leadsto 1 + \color{blue}{-1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                              2. lower-*.f64N/A

                                \[\leadsto 1 + -1 \cdot \color{blue}{\frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                              3. lower-/.f64N/A

                                \[\leadsto 1 + -1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{\color{blue}{z1}} \]
                            4. Applied rewrites71.0%

                              \[\leadsto \color{blue}{1 + -1 \cdot \frac{-1 \cdot \frac{1.3333333333333333 \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                            5. Step-by-step derivation
                              1. lift-*.f64N/A

                                \[\leadsto 1 + -1 \cdot \color{blue}{\frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                              2. lift-/.f64N/A

                                \[\leadsto 1 + -1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{\color{blue}{z1}} \]
                              3. associate-*r/N/A

                                \[\leadsto 1 + \frac{-1 \cdot \left(-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)\right)}{\color{blue}{z1}} \]
                              4. mult-flipN/A

                                \[\leadsto 1 + \left(-1 \cdot \left(-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)\right)\right) \cdot \color{blue}{\frac{1}{z1}} \]
                            6. Applied rewrites57.8%

                              \[\leadsto 1 + \frac{\left(\left(2 \cdot \left(z0 - 1\right)\right) \cdot z1 - \left(2 \cdot \left(z0 - 1\right) - \frac{z0 - 1}{z1} \cdot 1.3333333333333333\right)\right) \cdot 1}{\color{blue}{z1 \cdot z1}} \]
                            7. Taylor expanded in z1 around inf

                              \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{\color{blue}{z1}} \]
                            8. Step-by-step derivation
                              1. lower-/.f64N/A

                                \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                              2. lower-+.f64N/A

                                \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                              3. lower-*.f64N/A

                                \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                              4. lower-/.f64N/A

                                \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                              5. lower--.f64N/A

                                \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                              6. lower-*.f64N/A

                                \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                              7. lower--.f6466.8%

                                \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                            9. Applied rewrites66.8%

                              \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{\color{blue}{z1}} \]
                            10. Step-by-step derivation
                              1. lift-/.f64N/A

                                \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                              2. lift-+.f64N/A

                                \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                              3. lift-*.f64N/A

                                \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                              4. fp-cancel-sign-sub-invN/A

                                \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} - \left(\mathsf{neg}\left(2\right)\right) \cdot \left(z0 - 1\right)}{z1} \]
                              5. div-subN/A

                                \[\leadsto 1 + \left(\frac{-2 \cdot \frac{z0 - 1}{z1}}{z1} - \frac{\left(\mathsf{neg}\left(2\right)\right) \cdot \left(z0 - 1\right)}{\color{blue}{z1}}\right) \]
                              6. metadata-evalN/A

                                \[\leadsto 1 + \left(\frac{-2 \cdot \frac{z0 - 1}{z1}}{z1} - \frac{-2 \cdot \left(z0 - 1\right)}{z1}\right) \]
                              7. associate-*r/N/A

                                \[\leadsto 1 + \left(\frac{-2 \cdot \frac{z0 - 1}{z1}}{z1} - -2 \cdot \frac{z0 - 1}{\color{blue}{z1}}\right) \]
                              8. lift-/.f64N/A

                                \[\leadsto 1 + \left(\frac{-2 \cdot \frac{z0 - 1}{z1}}{z1} - -2 \cdot \frac{z0 - 1}{z1}\right) \]
                              9. lift-*.f64N/A

                                \[\leadsto 1 + \left(\frac{-2 \cdot \frac{z0 - 1}{z1}}{z1} - -2 \cdot \frac{z0 - 1}{\color{blue}{z1}}\right) \]
                              10. lower--.f64N/A

                                \[\leadsto 1 + \left(\frac{-2 \cdot \frac{z0 - 1}{z1}}{z1} - -2 \cdot \color{blue}{\frac{z0 - 1}{z1}}\right) \]
                            11. Applied rewrites66.8%

                              \[\leadsto 1 + \left(\frac{\left(1 - z0\right) \cdot 2}{z1 \cdot z1} - \frac{z0 - 1}{z1} \cdot \color{blue}{-2}\right) \]

                            if 1.0001 < (exp.f64 (/.f64 #s(literal -2 binary64) z1))

                            1. Initial program 76.8%

                              \[z0 - \left(z0 - 1\right) \cdot e^{\frac{-2}{z1}} \]
                            2. Taylor expanded in z1 around -inf

                              \[\leadsto \color{blue}{1 + -1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                            3. Step-by-step derivation
                              1. lower-+.f64N/A

                                \[\leadsto 1 + \color{blue}{-1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                              2. lower-*.f64N/A

                                \[\leadsto 1 + -1 \cdot \color{blue}{\frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                              3. lower-/.f64N/A

                                \[\leadsto 1 + -1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{\color{blue}{z1}} \]
                            4. Applied rewrites71.0%

                              \[\leadsto \color{blue}{1 + -1 \cdot \frac{-1 \cdot \frac{1.3333333333333333 \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                            5. Step-by-step derivation
                              1. lift-*.f64N/A

                                \[\leadsto 1 + -1 \cdot \color{blue}{\frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                              2. lift-/.f64N/A

                                \[\leadsto 1 + -1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{\color{blue}{z1}} \]
                              3. associate-*r/N/A

                                \[\leadsto 1 + \frac{-1 \cdot \left(-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)\right)}{\color{blue}{z1}} \]
                              4. mult-flipN/A

                                \[\leadsto 1 + \left(-1 \cdot \left(-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)\right)\right) \cdot \color{blue}{\frac{1}{z1}} \]
                            6. Applied rewrites57.8%

                              \[\leadsto 1 + \frac{\left(\left(2 \cdot \left(z0 - 1\right)\right) \cdot z1 - \left(2 \cdot \left(z0 - 1\right) - \frac{z0 - 1}{z1} \cdot 1.3333333333333333\right)\right) \cdot 1}{\color{blue}{z1 \cdot z1}} \]
                            7. Taylor expanded in z0 around 0

                              \[\leadsto 1 + \frac{\left(-2 \cdot z1 - \left(2 \cdot \left(z0 - 1\right) - \frac{z0 - 1}{z1} \cdot 1.3333333333333333\right)\right) \cdot 1}{z1 \cdot z1} \]
                            8. Step-by-step derivation
                              1. Applied rewrites58.2%

                                \[\leadsto 1 + \frac{\left(-2 \cdot z1 - \left(2 \cdot \left(z0 - 1\right) - \frac{z0 - 1}{z1} \cdot 1.3333333333333333\right)\right) \cdot 1}{z1 \cdot z1} \]
                              2. Taylor expanded in z0 around 0

                                \[\leadsto 1 + \frac{\left(-2 \cdot z1 - \left(-2 - \frac{z0 - 1}{z1} \cdot 1.3333333333333333\right)\right) \cdot 1}{z1 \cdot z1} \]
                              3. Step-by-step derivation
                                1. Applied rewrites58.3%

                                  \[\leadsto 1 + \frac{\left(-2 \cdot z1 - \left(-2 - \frac{z0 - 1}{z1} \cdot 1.3333333333333333\right)\right) \cdot 1}{z1 \cdot z1} \]
                              4. Recombined 3 regimes into one program.
                              5. Add Preprocessing

                              Alternative 10: 81.8% accurate, 0.4× speedup?

                              \[\begin{array}{l} t_0 := e^{\frac{-2}{z1}}\\ t_1 := \frac{z0 - 1}{z1}\\ \mathbf{if}\;t\_0 \leq 4 \cdot 10^{-15}:\\ \;\;\;\;z0 - -1 \cdot 1\\ \mathbf{elif}\;t\_0 \leq 2:\\ \;\;\;\;1 + \left(\frac{\left(1 - z0\right) \cdot 2}{z1 \cdot z1} - t\_1 \cdot -2\right)\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{\left(1.3333333333333333 \cdot t\_1\right) \cdot 1}{z1 \cdot z1}\\ \end{array} \]
                              (FPCore (z0 z1)
                                :precision binary64
                                (let* ((t_0 (exp (/ -2.0 z1))) (t_1 (/ (- z0 1.0) z1)))
                                (if (<= t_0 4e-15)
                                  (- z0 (* -1.0 1.0))
                                  (if (<= t_0 2.0)
                                    (+ 1.0 (- (/ (* (- 1.0 z0) 2.0) (* z1 z1)) (* t_1 -2.0)))
                                    (+ 1.0 (/ (* (* 1.3333333333333333 t_1) 1.0) (* z1 z1)))))))
                              double code(double z0, double z1) {
                              	double t_0 = exp((-2.0 / z1));
                              	double t_1 = (z0 - 1.0) / z1;
                              	double tmp;
                              	if (t_0 <= 4e-15) {
                              		tmp = z0 - (-1.0 * 1.0);
                              	} else if (t_0 <= 2.0) {
                              		tmp = 1.0 + ((((1.0 - z0) * 2.0) / (z1 * z1)) - (t_1 * -2.0));
                              	} else {
                              		tmp = 1.0 + (((1.3333333333333333 * t_1) * 1.0) / (z1 * z1));
                              	}
                              	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(z0, z1)
                              use fmin_fmax_functions
                                  real(8), intent (in) :: z0
                                  real(8), intent (in) :: z1
                                  real(8) :: t_0
                                  real(8) :: t_1
                                  real(8) :: tmp
                                  t_0 = exp(((-2.0d0) / z1))
                                  t_1 = (z0 - 1.0d0) / z1
                                  if (t_0 <= 4d-15) then
                                      tmp = z0 - ((-1.0d0) * 1.0d0)
                                  else if (t_0 <= 2.0d0) then
                                      tmp = 1.0d0 + ((((1.0d0 - z0) * 2.0d0) / (z1 * z1)) - (t_1 * (-2.0d0)))
                                  else
                                      tmp = 1.0d0 + (((1.3333333333333333d0 * t_1) * 1.0d0) / (z1 * z1))
                                  end if
                                  code = tmp
                              end function
                              
                              public static double code(double z0, double z1) {
                              	double t_0 = Math.exp((-2.0 / z1));
                              	double t_1 = (z0 - 1.0) / z1;
                              	double tmp;
                              	if (t_0 <= 4e-15) {
                              		tmp = z0 - (-1.0 * 1.0);
                              	} else if (t_0 <= 2.0) {
                              		tmp = 1.0 + ((((1.0 - z0) * 2.0) / (z1 * z1)) - (t_1 * -2.0));
                              	} else {
                              		tmp = 1.0 + (((1.3333333333333333 * t_1) * 1.0) / (z1 * z1));
                              	}
                              	return tmp;
                              }
                              
                              def code(z0, z1):
                              	t_0 = math.exp((-2.0 / z1))
                              	t_1 = (z0 - 1.0) / z1
                              	tmp = 0
                              	if t_0 <= 4e-15:
                              		tmp = z0 - (-1.0 * 1.0)
                              	elif t_0 <= 2.0:
                              		tmp = 1.0 + ((((1.0 - z0) * 2.0) / (z1 * z1)) - (t_1 * -2.0))
                              	else:
                              		tmp = 1.0 + (((1.3333333333333333 * t_1) * 1.0) / (z1 * z1))
                              	return tmp
                              
                              function code(z0, z1)
                              	t_0 = exp(Float64(-2.0 / z1))
                              	t_1 = Float64(Float64(z0 - 1.0) / z1)
                              	tmp = 0.0
                              	if (t_0 <= 4e-15)
                              		tmp = Float64(z0 - Float64(-1.0 * 1.0));
                              	elseif (t_0 <= 2.0)
                              		tmp = Float64(1.0 + Float64(Float64(Float64(Float64(1.0 - z0) * 2.0) / Float64(z1 * z1)) - Float64(t_1 * -2.0)));
                              	else
                              		tmp = Float64(1.0 + Float64(Float64(Float64(1.3333333333333333 * t_1) * 1.0) / Float64(z1 * z1)));
                              	end
                              	return tmp
                              end
                              
                              function tmp_2 = code(z0, z1)
                              	t_0 = exp((-2.0 / z1));
                              	t_1 = (z0 - 1.0) / z1;
                              	tmp = 0.0;
                              	if (t_0 <= 4e-15)
                              		tmp = z0 - (-1.0 * 1.0);
                              	elseif (t_0 <= 2.0)
                              		tmp = 1.0 + ((((1.0 - z0) * 2.0) / (z1 * z1)) - (t_1 * -2.0));
                              	else
                              		tmp = 1.0 + (((1.3333333333333333 * t_1) * 1.0) / (z1 * z1));
                              	end
                              	tmp_2 = tmp;
                              end
                              
                              code[z0_, z1_] := Block[{t$95$0 = N[Exp[N[(-2.0 / z1), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(z0 - 1.0), $MachinePrecision] / z1), $MachinePrecision]}, If[LessEqual[t$95$0, 4e-15], N[(z0 - N[(-1.0 * 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 2.0], N[(1.0 + N[(N[(N[(N[(1.0 - z0), $MachinePrecision] * 2.0), $MachinePrecision] / N[(z1 * z1), $MachinePrecision]), $MachinePrecision] - N[(t$95$1 * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[(N[(1.3333333333333333 * t$95$1), $MachinePrecision] * 1.0), $MachinePrecision] / N[(z1 * z1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
                              
                              \begin{array}{l}
                              t_0 := e^{\frac{-2}{z1}}\\
                              t_1 := \frac{z0 - 1}{z1}\\
                              \mathbf{if}\;t\_0 \leq 4 \cdot 10^{-15}:\\
                              \;\;\;\;z0 - -1 \cdot 1\\
                              
                              \mathbf{elif}\;t\_0 \leq 2:\\
                              \;\;\;\;1 + \left(\frac{\left(1 - z0\right) \cdot 2}{z1 \cdot z1} - t\_1 \cdot -2\right)\\
                              
                              \mathbf{else}:\\
                              \;\;\;\;1 + \frac{\left(1.3333333333333333 \cdot t\_1\right) \cdot 1}{z1 \cdot z1}\\
                              
                              
                              \end{array}
                              
                              Derivation
                              1. Split input into 3 regimes
                              2. if (exp.f64 (/.f64 #s(literal -2 binary64) z1)) < 4.0000000000000003e-15

                                1. Initial program 76.8%

                                  \[z0 - \left(z0 - 1\right) \cdot e^{\frac{-2}{z1}} \]
                                2. Taylor expanded in z1 around inf

                                  \[\leadsto z0 - \left(z0 - 1\right) \cdot \color{blue}{1} \]
                                3. Step-by-step derivation
                                  1. Applied rewrites27.8%

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

                                    \[\leadsto z0 - \color{blue}{-1} \cdot 1 \]
                                  3. Step-by-step derivation
                                    1. Applied rewrites37.4%

                                      \[\leadsto z0 - \color{blue}{-1} \cdot 1 \]

                                    if 4.0000000000000003e-15 < (exp.f64 (/.f64 #s(literal -2 binary64) z1)) < 2

                                    1. Initial program 76.8%

                                      \[z0 - \left(z0 - 1\right) \cdot e^{\frac{-2}{z1}} \]
                                    2. Taylor expanded in z1 around -inf

                                      \[\leadsto \color{blue}{1 + -1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                    3. Step-by-step derivation
                                      1. lower-+.f64N/A

                                        \[\leadsto 1 + \color{blue}{-1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                      2. lower-*.f64N/A

                                        \[\leadsto 1 + -1 \cdot \color{blue}{\frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                      3. lower-/.f64N/A

                                        \[\leadsto 1 + -1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{\color{blue}{z1}} \]
                                    4. Applied rewrites71.0%

                                      \[\leadsto \color{blue}{1 + -1 \cdot \frac{-1 \cdot \frac{1.3333333333333333 \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                    5. Step-by-step derivation
                                      1. lift-*.f64N/A

                                        \[\leadsto 1 + -1 \cdot \color{blue}{\frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                      2. lift-/.f64N/A

                                        \[\leadsto 1 + -1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{\color{blue}{z1}} \]
                                      3. associate-*r/N/A

                                        \[\leadsto 1 + \frac{-1 \cdot \left(-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)\right)}{\color{blue}{z1}} \]
                                      4. mult-flipN/A

                                        \[\leadsto 1 + \left(-1 \cdot \left(-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)\right)\right) \cdot \color{blue}{\frac{1}{z1}} \]
                                    6. Applied rewrites57.8%

                                      \[\leadsto 1 + \frac{\left(\left(2 \cdot \left(z0 - 1\right)\right) \cdot z1 - \left(2 \cdot \left(z0 - 1\right) - \frac{z0 - 1}{z1} \cdot 1.3333333333333333\right)\right) \cdot 1}{\color{blue}{z1 \cdot z1}} \]
                                    7. Taylor expanded in z1 around inf

                                      \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{\color{blue}{z1}} \]
                                    8. Step-by-step derivation
                                      1. lower-/.f64N/A

                                        \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                      2. lower-+.f64N/A

                                        \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                      3. lower-*.f64N/A

                                        \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                      4. lower-/.f64N/A

                                        \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                      5. lower--.f64N/A

                                        \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                      6. lower-*.f64N/A

                                        \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                      7. lower--.f6466.8%

                                        \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                    9. Applied rewrites66.8%

                                      \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{\color{blue}{z1}} \]
                                    10. Step-by-step derivation
                                      1. lift-/.f64N/A

                                        \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                      2. lift-+.f64N/A

                                        \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                      3. lift-*.f64N/A

                                        \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                      4. fp-cancel-sign-sub-invN/A

                                        \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} - \left(\mathsf{neg}\left(2\right)\right) \cdot \left(z0 - 1\right)}{z1} \]
                                      5. div-subN/A

                                        \[\leadsto 1 + \left(\frac{-2 \cdot \frac{z0 - 1}{z1}}{z1} - \frac{\left(\mathsf{neg}\left(2\right)\right) \cdot \left(z0 - 1\right)}{\color{blue}{z1}}\right) \]
                                      6. metadata-evalN/A

                                        \[\leadsto 1 + \left(\frac{-2 \cdot \frac{z0 - 1}{z1}}{z1} - \frac{-2 \cdot \left(z0 - 1\right)}{z1}\right) \]
                                      7. associate-*r/N/A

                                        \[\leadsto 1 + \left(\frac{-2 \cdot \frac{z0 - 1}{z1}}{z1} - -2 \cdot \frac{z0 - 1}{\color{blue}{z1}}\right) \]
                                      8. lift-/.f64N/A

                                        \[\leadsto 1 + \left(\frac{-2 \cdot \frac{z0 - 1}{z1}}{z1} - -2 \cdot \frac{z0 - 1}{z1}\right) \]
                                      9. lift-*.f64N/A

                                        \[\leadsto 1 + \left(\frac{-2 \cdot \frac{z0 - 1}{z1}}{z1} - -2 \cdot \frac{z0 - 1}{\color{blue}{z1}}\right) \]
                                      10. lower--.f64N/A

                                        \[\leadsto 1 + \left(\frac{-2 \cdot \frac{z0 - 1}{z1}}{z1} - -2 \cdot \color{blue}{\frac{z0 - 1}{z1}}\right) \]
                                    11. Applied rewrites66.8%

                                      \[\leadsto 1 + \left(\frac{\left(1 - z0\right) \cdot 2}{z1 \cdot z1} - \frac{z0 - 1}{z1} \cdot \color{blue}{-2}\right) \]

                                    if 2 < (exp.f64 (/.f64 #s(literal -2 binary64) z1))

                                    1. Initial program 76.8%

                                      \[z0 - \left(z0 - 1\right) \cdot e^{\frac{-2}{z1}} \]
                                    2. Taylor expanded in z1 around -inf

                                      \[\leadsto \color{blue}{1 + -1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                    3. Step-by-step derivation
                                      1. lower-+.f64N/A

                                        \[\leadsto 1 + \color{blue}{-1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                      2. lower-*.f64N/A

                                        \[\leadsto 1 + -1 \cdot \color{blue}{\frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                      3. lower-/.f64N/A

                                        \[\leadsto 1 + -1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{\color{blue}{z1}} \]
                                    4. Applied rewrites71.0%

                                      \[\leadsto \color{blue}{1 + -1 \cdot \frac{-1 \cdot \frac{1.3333333333333333 \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                    5. Step-by-step derivation
                                      1. lift-*.f64N/A

                                        \[\leadsto 1 + -1 \cdot \color{blue}{\frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                      2. lift-/.f64N/A

                                        \[\leadsto 1 + -1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{\color{blue}{z1}} \]
                                      3. associate-*r/N/A

                                        \[\leadsto 1 + \frac{-1 \cdot \left(-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)\right)}{\color{blue}{z1}} \]
                                      4. mult-flipN/A

                                        \[\leadsto 1 + \left(-1 \cdot \left(-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)\right)\right) \cdot \color{blue}{\frac{1}{z1}} \]
                                    6. Applied rewrites57.8%

                                      \[\leadsto 1 + \frac{\left(\left(2 \cdot \left(z0 - 1\right)\right) \cdot z1 - \left(2 \cdot \left(z0 - 1\right) - \frac{z0 - 1}{z1} \cdot 1.3333333333333333\right)\right) \cdot 1}{\color{blue}{z1 \cdot z1}} \]
                                    7. Taylor expanded in z0 around 0

                                      \[\leadsto 1 + \frac{\left(\left(2 + -2 \cdot z1\right) - \frac{4}{3} \cdot \frac{1}{z1}\right) \cdot 1}{z1 \cdot z1} \]
                                    8. Step-by-step derivation
                                      1. lower--.f64N/A

                                        \[\leadsto 1 + \frac{\left(\left(2 + -2 \cdot z1\right) - \frac{4}{3} \cdot \frac{1}{z1}\right) \cdot 1}{z1 \cdot z1} \]
                                      2. lower-+.f64N/A

                                        \[\leadsto 1 + \frac{\left(\left(2 + -2 \cdot z1\right) - \frac{4}{3} \cdot \frac{1}{z1}\right) \cdot 1}{z1 \cdot z1} \]
                                      3. lower-*.f64N/A

                                        \[\leadsto 1 + \frac{\left(\left(2 + -2 \cdot z1\right) - \frac{4}{3} \cdot \frac{1}{z1}\right) \cdot 1}{z1 \cdot z1} \]
                                      4. lower-*.f64N/A

                                        \[\leadsto 1 + \frac{\left(\left(2 + -2 \cdot z1\right) - \frac{4}{3} \cdot \frac{1}{z1}\right) \cdot 1}{z1 \cdot z1} \]
                                      5. lower-/.f6451.4%

                                        \[\leadsto 1 + \frac{\left(\left(2 + -2 \cdot z1\right) - 1.3333333333333333 \cdot \frac{1}{z1}\right) \cdot 1}{z1 \cdot z1} \]
                                    9. Applied rewrites51.4%

                                      \[\leadsto 1 + \frac{\left(\left(2 + -2 \cdot z1\right) - 1.3333333333333333 \cdot \frac{1}{z1}\right) \cdot 1}{z1 \cdot z1} \]
                                    10. Taylor expanded in z1 around 0

                                      \[\leadsto 1 + \frac{\left(\frac{4}{3} \cdot \frac{z0 - 1}{z1}\right) \cdot 1}{z1 \cdot z1} \]
                                    11. Step-by-step derivation
                                      1. lower-*.f64N/A

                                        \[\leadsto 1 + \frac{\left(\frac{4}{3} \cdot \frac{z0 - 1}{z1}\right) \cdot 1}{z1 \cdot z1} \]
                                      2. lower-/.f64N/A

                                        \[\leadsto 1 + \frac{\left(\frac{4}{3} \cdot \frac{z0 - 1}{z1}\right) \cdot 1}{z1 \cdot z1} \]
                                      3. lower--.f6457.9%

                                        \[\leadsto 1 + \frac{\left(1.3333333333333333 \cdot \frac{z0 - 1}{z1}\right) \cdot 1}{z1 \cdot z1} \]
                                    12. Applied rewrites57.9%

                                      \[\leadsto 1 + \frac{\left(1.3333333333333333 \cdot \frac{z0 - 1}{z1}\right) \cdot 1}{z1 \cdot z1} \]
                                  4. Recombined 3 regimes into one program.
                                  5. Add Preprocessing

                                  Alternative 11: 81.4% accurate, 0.4× speedup?

                                  \[\begin{array}{l} t_0 := e^{\frac{-2}{z1}}\\ t_1 := \frac{z0 - 1}{z1}\\ \mathbf{if}\;t\_0 \leq 4 \cdot 10^{-15}:\\ \;\;\;\;z0 - -1 \cdot 1\\ \mathbf{elif}\;t\_0 \leq 2:\\ \;\;\;\;\frac{-2 \cdot \left(t\_1 - \left(z0 - 1\right)\right)}{z1} - -1\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{\left(1.3333333333333333 \cdot t\_1\right) \cdot 1}{z1 \cdot z1}\\ \end{array} \]
                                  (FPCore (z0 z1)
                                    :precision binary64
                                    (let* ((t_0 (exp (/ -2.0 z1))) (t_1 (/ (- z0 1.0) z1)))
                                    (if (<= t_0 4e-15)
                                      (- z0 (* -1.0 1.0))
                                      (if (<= t_0 2.0)
                                        (- (/ (* -2.0 (- t_1 (- z0 1.0))) z1) -1.0)
                                        (+ 1.0 (/ (* (* 1.3333333333333333 t_1) 1.0) (* z1 z1)))))))
                                  double code(double z0, double z1) {
                                  	double t_0 = exp((-2.0 / z1));
                                  	double t_1 = (z0 - 1.0) / z1;
                                  	double tmp;
                                  	if (t_0 <= 4e-15) {
                                  		tmp = z0 - (-1.0 * 1.0);
                                  	} else if (t_0 <= 2.0) {
                                  		tmp = ((-2.0 * (t_1 - (z0 - 1.0))) / z1) - -1.0;
                                  	} else {
                                  		tmp = 1.0 + (((1.3333333333333333 * t_1) * 1.0) / (z1 * z1));
                                  	}
                                  	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(z0, z1)
                                  use fmin_fmax_functions
                                      real(8), intent (in) :: z0
                                      real(8), intent (in) :: z1
                                      real(8) :: t_0
                                      real(8) :: t_1
                                      real(8) :: tmp
                                      t_0 = exp(((-2.0d0) / z1))
                                      t_1 = (z0 - 1.0d0) / z1
                                      if (t_0 <= 4d-15) then
                                          tmp = z0 - ((-1.0d0) * 1.0d0)
                                      else if (t_0 <= 2.0d0) then
                                          tmp = (((-2.0d0) * (t_1 - (z0 - 1.0d0))) / z1) - (-1.0d0)
                                      else
                                          tmp = 1.0d0 + (((1.3333333333333333d0 * t_1) * 1.0d0) / (z1 * z1))
                                      end if
                                      code = tmp
                                  end function
                                  
                                  public static double code(double z0, double z1) {
                                  	double t_0 = Math.exp((-2.0 / z1));
                                  	double t_1 = (z0 - 1.0) / z1;
                                  	double tmp;
                                  	if (t_0 <= 4e-15) {
                                  		tmp = z0 - (-1.0 * 1.0);
                                  	} else if (t_0 <= 2.0) {
                                  		tmp = ((-2.0 * (t_1 - (z0 - 1.0))) / z1) - -1.0;
                                  	} else {
                                  		tmp = 1.0 + (((1.3333333333333333 * t_1) * 1.0) / (z1 * z1));
                                  	}
                                  	return tmp;
                                  }
                                  
                                  def code(z0, z1):
                                  	t_0 = math.exp((-2.0 / z1))
                                  	t_1 = (z0 - 1.0) / z1
                                  	tmp = 0
                                  	if t_0 <= 4e-15:
                                  		tmp = z0 - (-1.0 * 1.0)
                                  	elif t_0 <= 2.0:
                                  		tmp = ((-2.0 * (t_1 - (z0 - 1.0))) / z1) - -1.0
                                  	else:
                                  		tmp = 1.0 + (((1.3333333333333333 * t_1) * 1.0) / (z1 * z1))
                                  	return tmp
                                  
                                  function code(z0, z1)
                                  	t_0 = exp(Float64(-2.0 / z1))
                                  	t_1 = Float64(Float64(z0 - 1.0) / z1)
                                  	tmp = 0.0
                                  	if (t_0 <= 4e-15)
                                  		tmp = Float64(z0 - Float64(-1.0 * 1.0));
                                  	elseif (t_0 <= 2.0)
                                  		tmp = Float64(Float64(Float64(-2.0 * Float64(t_1 - Float64(z0 - 1.0))) / z1) - -1.0);
                                  	else
                                  		tmp = Float64(1.0 + Float64(Float64(Float64(1.3333333333333333 * t_1) * 1.0) / Float64(z1 * z1)));
                                  	end
                                  	return tmp
                                  end
                                  
                                  function tmp_2 = code(z0, z1)
                                  	t_0 = exp((-2.0 / z1));
                                  	t_1 = (z0 - 1.0) / z1;
                                  	tmp = 0.0;
                                  	if (t_0 <= 4e-15)
                                  		tmp = z0 - (-1.0 * 1.0);
                                  	elseif (t_0 <= 2.0)
                                  		tmp = ((-2.0 * (t_1 - (z0 - 1.0))) / z1) - -1.0;
                                  	else
                                  		tmp = 1.0 + (((1.3333333333333333 * t_1) * 1.0) / (z1 * z1));
                                  	end
                                  	tmp_2 = tmp;
                                  end
                                  
                                  code[z0_, z1_] := Block[{t$95$0 = N[Exp[N[(-2.0 / z1), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(z0 - 1.0), $MachinePrecision] / z1), $MachinePrecision]}, If[LessEqual[t$95$0, 4e-15], N[(z0 - N[(-1.0 * 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 2.0], N[(N[(N[(-2.0 * N[(t$95$1 - N[(z0 - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z1), $MachinePrecision] - -1.0), $MachinePrecision], N[(1.0 + N[(N[(N[(1.3333333333333333 * t$95$1), $MachinePrecision] * 1.0), $MachinePrecision] / N[(z1 * z1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
                                  
                                  \begin{array}{l}
                                  t_0 := e^{\frac{-2}{z1}}\\
                                  t_1 := \frac{z0 - 1}{z1}\\
                                  \mathbf{if}\;t\_0 \leq 4 \cdot 10^{-15}:\\
                                  \;\;\;\;z0 - -1 \cdot 1\\
                                  
                                  \mathbf{elif}\;t\_0 \leq 2:\\
                                  \;\;\;\;\frac{-2 \cdot \left(t\_1 - \left(z0 - 1\right)\right)}{z1} - -1\\
                                  
                                  \mathbf{else}:\\
                                  \;\;\;\;1 + \frac{\left(1.3333333333333333 \cdot t\_1\right) \cdot 1}{z1 \cdot z1}\\
                                  
                                  
                                  \end{array}
                                  
                                  Derivation
                                  1. Split input into 3 regimes
                                  2. if (exp.f64 (/.f64 #s(literal -2 binary64) z1)) < 4.0000000000000003e-15

                                    1. Initial program 76.8%

                                      \[z0 - \left(z0 - 1\right) \cdot e^{\frac{-2}{z1}} \]
                                    2. Taylor expanded in z1 around inf

                                      \[\leadsto z0 - \left(z0 - 1\right) \cdot \color{blue}{1} \]
                                    3. Step-by-step derivation
                                      1. Applied rewrites27.8%

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

                                        \[\leadsto z0 - \color{blue}{-1} \cdot 1 \]
                                      3. Step-by-step derivation
                                        1. Applied rewrites37.4%

                                          \[\leadsto z0 - \color{blue}{-1} \cdot 1 \]

                                        if 4.0000000000000003e-15 < (exp.f64 (/.f64 #s(literal -2 binary64) z1)) < 2

                                        1. Initial program 76.8%

                                          \[z0 - \left(z0 - 1\right) \cdot e^{\frac{-2}{z1}} \]
                                        2. Taylor expanded in z1 around -inf

                                          \[\leadsto \color{blue}{1 + -1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                        3. Step-by-step derivation
                                          1. lower-+.f64N/A

                                            \[\leadsto 1 + \color{blue}{-1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                          2. lower-*.f64N/A

                                            \[\leadsto 1 + -1 \cdot \color{blue}{\frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                          3. lower-/.f64N/A

                                            \[\leadsto 1 + -1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{\color{blue}{z1}} \]
                                        4. Applied rewrites71.0%

                                          \[\leadsto \color{blue}{1 + -1 \cdot \frac{-1 \cdot \frac{1.3333333333333333 \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                        5. Step-by-step derivation
                                          1. lift-*.f64N/A

                                            \[\leadsto 1 + -1 \cdot \color{blue}{\frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                          2. lift-/.f64N/A

                                            \[\leadsto 1 + -1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{\color{blue}{z1}} \]
                                          3. associate-*r/N/A

                                            \[\leadsto 1 + \frac{-1 \cdot \left(-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)\right)}{\color{blue}{z1}} \]
                                          4. mult-flipN/A

                                            \[\leadsto 1 + \left(-1 \cdot \left(-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)\right)\right) \cdot \color{blue}{\frac{1}{z1}} \]
                                        6. Applied rewrites57.8%

                                          \[\leadsto 1 + \frac{\left(\left(2 \cdot \left(z0 - 1\right)\right) \cdot z1 - \left(2 \cdot \left(z0 - 1\right) - \frac{z0 - 1}{z1} \cdot 1.3333333333333333\right)\right) \cdot 1}{\color{blue}{z1 \cdot z1}} \]
                                        7. Taylor expanded in z1 around inf

                                          \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{\color{blue}{z1}} \]
                                        8. Step-by-step derivation
                                          1. lower-/.f64N/A

                                            \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                          2. lower-+.f64N/A

                                            \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                          3. lower-*.f64N/A

                                            \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                          4. lower-/.f64N/A

                                            \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                          5. lower--.f64N/A

                                            \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                          6. lower-*.f64N/A

                                            \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                          7. lower--.f6466.8%

                                            \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                        9. Applied rewrites66.8%

                                          \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{\color{blue}{z1}} \]
                                        10. Step-by-step derivation
                                          1. lift--.f64N/A

                                            \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                          2. *-commutativeN/A

                                            \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                          3. *-commutativeN/A

                                            \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                          4. sinh-+-cosh-revN/A

                                            \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                          5. sinh-+-cosh-revN/A

                                            \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                          6. metadata-evalN/A

                                            \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                          7. associate-*r/N/A

                                            \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                          8. pow-expN/A

                                            \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                          9. lift--.f6466.8%

                                            \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                          10. lift-+.f64N/A

                                            \[\leadsto 1 + \color{blue}{\frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                        11. Applied rewrites66.8%

                                          \[\leadsto \color{blue}{\frac{-2 \cdot \left(\frac{z0 - 1}{z1} - \left(z0 - 1\right)\right)}{z1} - -1} \]

                                        if 2 < (exp.f64 (/.f64 #s(literal -2 binary64) z1))

                                        1. Initial program 76.8%

                                          \[z0 - \left(z0 - 1\right) \cdot e^{\frac{-2}{z1}} \]
                                        2. Taylor expanded in z1 around -inf

                                          \[\leadsto \color{blue}{1 + -1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                        3. Step-by-step derivation
                                          1. lower-+.f64N/A

                                            \[\leadsto 1 + \color{blue}{-1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                          2. lower-*.f64N/A

                                            \[\leadsto 1 + -1 \cdot \color{blue}{\frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                          3. lower-/.f64N/A

                                            \[\leadsto 1 + -1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{\color{blue}{z1}} \]
                                        4. Applied rewrites71.0%

                                          \[\leadsto \color{blue}{1 + -1 \cdot \frac{-1 \cdot \frac{1.3333333333333333 \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                        5. Step-by-step derivation
                                          1. lift-*.f64N/A

                                            \[\leadsto 1 + -1 \cdot \color{blue}{\frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                          2. lift-/.f64N/A

                                            \[\leadsto 1 + -1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{\color{blue}{z1}} \]
                                          3. associate-*r/N/A

                                            \[\leadsto 1 + \frac{-1 \cdot \left(-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)\right)}{\color{blue}{z1}} \]
                                          4. mult-flipN/A

                                            \[\leadsto 1 + \left(-1 \cdot \left(-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)\right)\right) \cdot \color{blue}{\frac{1}{z1}} \]
                                        6. Applied rewrites57.8%

                                          \[\leadsto 1 + \frac{\left(\left(2 \cdot \left(z0 - 1\right)\right) \cdot z1 - \left(2 \cdot \left(z0 - 1\right) - \frac{z0 - 1}{z1} \cdot 1.3333333333333333\right)\right) \cdot 1}{\color{blue}{z1 \cdot z1}} \]
                                        7. Taylor expanded in z0 around 0

                                          \[\leadsto 1 + \frac{\left(\left(2 + -2 \cdot z1\right) - \frac{4}{3} \cdot \frac{1}{z1}\right) \cdot 1}{z1 \cdot z1} \]
                                        8. Step-by-step derivation
                                          1. lower--.f64N/A

                                            \[\leadsto 1 + \frac{\left(\left(2 + -2 \cdot z1\right) - \frac{4}{3} \cdot \frac{1}{z1}\right) \cdot 1}{z1 \cdot z1} \]
                                          2. lower-+.f64N/A

                                            \[\leadsto 1 + \frac{\left(\left(2 + -2 \cdot z1\right) - \frac{4}{3} \cdot \frac{1}{z1}\right) \cdot 1}{z1 \cdot z1} \]
                                          3. lower-*.f64N/A

                                            \[\leadsto 1 + \frac{\left(\left(2 + -2 \cdot z1\right) - \frac{4}{3} \cdot \frac{1}{z1}\right) \cdot 1}{z1 \cdot z1} \]
                                          4. lower-*.f64N/A

                                            \[\leadsto 1 + \frac{\left(\left(2 + -2 \cdot z1\right) - \frac{4}{3} \cdot \frac{1}{z1}\right) \cdot 1}{z1 \cdot z1} \]
                                          5. lower-/.f6451.4%

                                            \[\leadsto 1 + \frac{\left(\left(2 + -2 \cdot z1\right) - 1.3333333333333333 \cdot \frac{1}{z1}\right) \cdot 1}{z1 \cdot z1} \]
                                        9. Applied rewrites51.4%

                                          \[\leadsto 1 + \frac{\left(\left(2 + -2 \cdot z1\right) - 1.3333333333333333 \cdot \frac{1}{z1}\right) \cdot 1}{z1 \cdot z1} \]
                                        10. Taylor expanded in z1 around 0

                                          \[\leadsto 1 + \frac{\left(\frac{4}{3} \cdot \frac{z0 - 1}{z1}\right) \cdot 1}{z1 \cdot z1} \]
                                        11. Step-by-step derivation
                                          1. lower-*.f64N/A

                                            \[\leadsto 1 + \frac{\left(\frac{4}{3} \cdot \frac{z0 - 1}{z1}\right) \cdot 1}{z1 \cdot z1} \]
                                          2. lower-/.f64N/A

                                            \[\leadsto 1 + \frac{\left(\frac{4}{3} \cdot \frac{z0 - 1}{z1}\right) \cdot 1}{z1 \cdot z1} \]
                                          3. lower--.f6457.9%

                                            \[\leadsto 1 + \frac{\left(1.3333333333333333 \cdot \frac{z0 - 1}{z1}\right) \cdot 1}{z1 \cdot z1} \]
                                        12. Applied rewrites57.9%

                                          \[\leadsto 1 + \frac{\left(1.3333333333333333 \cdot \frac{z0 - 1}{z1}\right) \cdot 1}{z1 \cdot z1} \]
                                      4. Recombined 3 regimes into one program.
                                      5. Add Preprocessing

                                      Alternative 12: 79.7% accurate, 1.2× speedup?

                                      \[\begin{array}{l} t_0 := \frac{z0 - 1}{z1}\\ \mathbf{if}\;\frac{-2}{z1} \leq -20:\\ \;\;\;\;z0 - -1 \cdot 1\\ \mathbf{elif}\;\frac{-2}{z1} \leq 0.0002:\\ \;\;\;\;1 + 2 \cdot t\_0\\ \mathbf{elif}\;\frac{-2}{z1} \leq 4 \cdot 10^{+96}:\\ \;\;\;\;z0 - \frac{z0 \cdot z0 - 1 \cdot 1}{z0 + 1} \cdot 1\\ \mathbf{elif}\;\frac{-2}{z1} \leq 10^{+150}:\\ \;\;\;\;1 + \frac{\frac{-1.3333333333333333}{z1} \cdot 1}{z1 \cdot z1}\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{-2 \cdot t\_0 + -2}{z1}\\ \end{array} \]
                                      (FPCore (z0 z1)
                                        :precision binary64
                                        (let* ((t_0 (/ (- z0 1.0) z1)))
                                        (if (<= (/ -2.0 z1) -20.0)
                                          (- z0 (* -1.0 1.0))
                                          (if (<= (/ -2.0 z1) 0.0002)
                                            (+ 1.0 (* 2.0 t_0))
                                            (if (<= (/ -2.0 z1) 4e+96)
                                              (- z0 (* (/ (- (* z0 z0) (* 1.0 1.0)) (+ z0 1.0)) 1.0))
                                              (if (<= (/ -2.0 z1) 1e+150)
                                                (+ 1.0 (/ (* (/ -1.3333333333333333 z1) 1.0) (* z1 z1)))
                                                (+ 1.0 (/ (+ (* -2.0 t_0) -2.0) z1))))))))
                                      double code(double z0, double z1) {
                                      	double t_0 = (z0 - 1.0) / z1;
                                      	double tmp;
                                      	if ((-2.0 / z1) <= -20.0) {
                                      		tmp = z0 - (-1.0 * 1.0);
                                      	} else if ((-2.0 / z1) <= 0.0002) {
                                      		tmp = 1.0 + (2.0 * t_0);
                                      	} else if ((-2.0 / z1) <= 4e+96) {
                                      		tmp = z0 - ((((z0 * z0) - (1.0 * 1.0)) / (z0 + 1.0)) * 1.0);
                                      	} else if ((-2.0 / z1) <= 1e+150) {
                                      		tmp = 1.0 + (((-1.3333333333333333 / z1) * 1.0) / (z1 * z1));
                                      	} else {
                                      		tmp = 1.0 + (((-2.0 * t_0) + -2.0) / z1);
                                      	}
                                      	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(z0, z1)
                                      use fmin_fmax_functions
                                          real(8), intent (in) :: z0
                                          real(8), intent (in) :: z1
                                          real(8) :: t_0
                                          real(8) :: tmp
                                          t_0 = (z0 - 1.0d0) / z1
                                          if (((-2.0d0) / z1) <= (-20.0d0)) then
                                              tmp = z0 - ((-1.0d0) * 1.0d0)
                                          else if (((-2.0d0) / z1) <= 0.0002d0) then
                                              tmp = 1.0d0 + (2.0d0 * t_0)
                                          else if (((-2.0d0) / z1) <= 4d+96) then
                                              tmp = z0 - ((((z0 * z0) - (1.0d0 * 1.0d0)) / (z0 + 1.0d0)) * 1.0d0)
                                          else if (((-2.0d0) / z1) <= 1d+150) then
                                              tmp = 1.0d0 + ((((-1.3333333333333333d0) / z1) * 1.0d0) / (z1 * z1))
                                          else
                                              tmp = 1.0d0 + ((((-2.0d0) * t_0) + (-2.0d0)) / z1)
                                          end if
                                          code = tmp
                                      end function
                                      
                                      public static double code(double z0, double z1) {
                                      	double t_0 = (z0 - 1.0) / z1;
                                      	double tmp;
                                      	if ((-2.0 / z1) <= -20.0) {
                                      		tmp = z0 - (-1.0 * 1.0);
                                      	} else if ((-2.0 / z1) <= 0.0002) {
                                      		tmp = 1.0 + (2.0 * t_0);
                                      	} else if ((-2.0 / z1) <= 4e+96) {
                                      		tmp = z0 - ((((z0 * z0) - (1.0 * 1.0)) / (z0 + 1.0)) * 1.0);
                                      	} else if ((-2.0 / z1) <= 1e+150) {
                                      		tmp = 1.0 + (((-1.3333333333333333 / z1) * 1.0) / (z1 * z1));
                                      	} else {
                                      		tmp = 1.0 + (((-2.0 * t_0) + -2.0) / z1);
                                      	}
                                      	return tmp;
                                      }
                                      
                                      def code(z0, z1):
                                      	t_0 = (z0 - 1.0) / z1
                                      	tmp = 0
                                      	if (-2.0 / z1) <= -20.0:
                                      		tmp = z0 - (-1.0 * 1.0)
                                      	elif (-2.0 / z1) <= 0.0002:
                                      		tmp = 1.0 + (2.0 * t_0)
                                      	elif (-2.0 / z1) <= 4e+96:
                                      		tmp = z0 - ((((z0 * z0) - (1.0 * 1.0)) / (z0 + 1.0)) * 1.0)
                                      	elif (-2.0 / z1) <= 1e+150:
                                      		tmp = 1.0 + (((-1.3333333333333333 / z1) * 1.0) / (z1 * z1))
                                      	else:
                                      		tmp = 1.0 + (((-2.0 * t_0) + -2.0) / z1)
                                      	return tmp
                                      
                                      function code(z0, z1)
                                      	t_0 = Float64(Float64(z0 - 1.0) / z1)
                                      	tmp = 0.0
                                      	if (Float64(-2.0 / z1) <= -20.0)
                                      		tmp = Float64(z0 - Float64(-1.0 * 1.0));
                                      	elseif (Float64(-2.0 / z1) <= 0.0002)
                                      		tmp = Float64(1.0 + Float64(2.0 * t_0));
                                      	elseif (Float64(-2.0 / z1) <= 4e+96)
                                      		tmp = Float64(z0 - Float64(Float64(Float64(Float64(z0 * z0) - Float64(1.0 * 1.0)) / Float64(z0 + 1.0)) * 1.0));
                                      	elseif (Float64(-2.0 / z1) <= 1e+150)
                                      		tmp = Float64(1.0 + Float64(Float64(Float64(-1.3333333333333333 / z1) * 1.0) / Float64(z1 * z1)));
                                      	else
                                      		tmp = Float64(1.0 + Float64(Float64(Float64(-2.0 * t_0) + -2.0) / z1));
                                      	end
                                      	return tmp
                                      end
                                      
                                      function tmp_2 = code(z0, z1)
                                      	t_0 = (z0 - 1.0) / z1;
                                      	tmp = 0.0;
                                      	if ((-2.0 / z1) <= -20.0)
                                      		tmp = z0 - (-1.0 * 1.0);
                                      	elseif ((-2.0 / z1) <= 0.0002)
                                      		tmp = 1.0 + (2.0 * t_0);
                                      	elseif ((-2.0 / z1) <= 4e+96)
                                      		tmp = z0 - ((((z0 * z0) - (1.0 * 1.0)) / (z0 + 1.0)) * 1.0);
                                      	elseif ((-2.0 / z1) <= 1e+150)
                                      		tmp = 1.0 + (((-1.3333333333333333 / z1) * 1.0) / (z1 * z1));
                                      	else
                                      		tmp = 1.0 + (((-2.0 * t_0) + -2.0) / z1);
                                      	end
                                      	tmp_2 = tmp;
                                      end
                                      
                                      code[z0_, z1_] := Block[{t$95$0 = N[(N[(z0 - 1.0), $MachinePrecision] / z1), $MachinePrecision]}, If[LessEqual[N[(-2.0 / z1), $MachinePrecision], -20.0], N[(z0 - N[(-1.0 * 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(-2.0 / z1), $MachinePrecision], 0.0002], N[(1.0 + N[(2.0 * t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(-2.0 / z1), $MachinePrecision], 4e+96], N[(z0 - N[(N[(N[(N[(z0 * z0), $MachinePrecision] - N[(1.0 * 1.0), $MachinePrecision]), $MachinePrecision] / N[(z0 + 1.0), $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(-2.0 / z1), $MachinePrecision], 1e+150], N[(1.0 + N[(N[(N[(-1.3333333333333333 / z1), $MachinePrecision] * 1.0), $MachinePrecision] / N[(z1 * z1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[(N[(-2.0 * t$95$0), $MachinePrecision] + -2.0), $MachinePrecision] / z1), $MachinePrecision]), $MachinePrecision]]]]]]
                                      
                                      \begin{array}{l}
                                      t_0 := \frac{z0 - 1}{z1}\\
                                      \mathbf{if}\;\frac{-2}{z1} \leq -20:\\
                                      \;\;\;\;z0 - -1 \cdot 1\\
                                      
                                      \mathbf{elif}\;\frac{-2}{z1} \leq 0.0002:\\
                                      \;\;\;\;1 + 2 \cdot t\_0\\
                                      
                                      \mathbf{elif}\;\frac{-2}{z1} \leq 4 \cdot 10^{+96}:\\
                                      \;\;\;\;z0 - \frac{z0 \cdot z0 - 1 \cdot 1}{z0 + 1} \cdot 1\\
                                      
                                      \mathbf{elif}\;\frac{-2}{z1} \leq 10^{+150}:\\
                                      \;\;\;\;1 + \frac{\frac{-1.3333333333333333}{z1} \cdot 1}{z1 \cdot z1}\\
                                      
                                      \mathbf{else}:\\
                                      \;\;\;\;1 + \frac{-2 \cdot t\_0 + -2}{z1}\\
                                      
                                      
                                      \end{array}
                                      
                                      Derivation
                                      1. Split input into 5 regimes
                                      2. if (/.f64 #s(literal -2 binary64) z1) < -20

                                        1. Initial program 76.8%

                                          \[z0 - \left(z0 - 1\right) \cdot e^{\frac{-2}{z1}} \]
                                        2. Taylor expanded in z1 around inf

                                          \[\leadsto z0 - \left(z0 - 1\right) \cdot \color{blue}{1} \]
                                        3. Step-by-step derivation
                                          1. Applied rewrites27.8%

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

                                            \[\leadsto z0 - \color{blue}{-1} \cdot 1 \]
                                          3. Step-by-step derivation
                                            1. Applied rewrites37.4%

                                              \[\leadsto z0 - \color{blue}{-1} \cdot 1 \]

                                            if -20 < (/.f64 #s(literal -2 binary64) z1) < 2.0000000000000001e-4

                                            1. Initial program 76.8%

                                              \[z0 - \left(z0 - 1\right) \cdot e^{\frac{-2}{z1}} \]
                                            2. Taylor expanded in z1 around inf

                                              \[\leadsto \color{blue}{1 + 2 \cdot \frac{z0 - 1}{z1}} \]
                                            3. Step-by-step derivation
                                              1. lower-+.f64N/A

                                                \[\leadsto 1 + \color{blue}{2 \cdot \frac{z0 - 1}{z1}} \]
                                              2. lower-*.f64N/A

                                                \[\leadsto 1 + 2 \cdot \color{blue}{\frac{z0 - 1}{z1}} \]
                                              3. lower-/.f64N/A

                                                \[\leadsto 1 + 2 \cdot \frac{z0 - 1}{\color{blue}{z1}} \]
                                              4. lower--.f6458.5%

                                                \[\leadsto 1 + 2 \cdot \frac{z0 - 1}{z1} \]
                                            4. Applied rewrites58.5%

                                              \[\leadsto \color{blue}{1 + 2 \cdot \frac{z0 - 1}{z1}} \]

                                            if 2.0000000000000001e-4 < (/.f64 #s(literal -2 binary64) z1) < 4.0000000000000002e96

                                            1. Initial program 76.8%

                                              \[z0 - \left(z0 - 1\right) \cdot e^{\frac{-2}{z1}} \]
                                            2. Taylor expanded in z1 around inf

                                              \[\leadsto z0 - \left(z0 - 1\right) \cdot \color{blue}{1} \]
                                            3. Step-by-step derivation
                                              1. Applied rewrites27.8%

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

                                                  \[\leadsto z0 - \color{blue}{\left(z0 - 1\right)} \cdot 1 \]
                                                2. flip--N/A

                                                  \[\leadsto z0 - \color{blue}{\frac{z0 \cdot z0 - 1 \cdot 1}{z0 + 1}} \cdot 1 \]
                                                3. lower-unsound-/.f64N/A

                                                  \[\leadsto z0 - \color{blue}{\frac{z0 \cdot z0 - 1 \cdot 1}{z0 + 1}} \cdot 1 \]
                                                4. lower-unsound--.f64N/A

                                                  \[\leadsto z0 - \frac{\color{blue}{z0 \cdot z0 - 1 \cdot 1}}{z0 + 1} \cdot 1 \]
                                                5. lower-unsound-*.f64N/A

                                                  \[\leadsto z0 - \frac{\color{blue}{z0 \cdot z0} - 1 \cdot 1}{z0 + 1} \cdot 1 \]
                                                6. lower-unsound-*.f64N/A

                                                  \[\leadsto z0 - \frac{z0 \cdot z0 - \color{blue}{1 \cdot 1}}{z0 + 1} \cdot 1 \]
                                                7. lower-unsound-+.f6433.7%

                                                  \[\leadsto z0 - \frac{z0 \cdot z0 - 1 \cdot 1}{\color{blue}{z0 + 1}} \cdot 1 \]
                                              3. Applied rewrites33.7%

                                                \[\leadsto z0 - \color{blue}{\frac{z0 \cdot z0 - 1 \cdot 1}{z0 + 1}} \cdot 1 \]

                                              if 4.0000000000000002e96 < (/.f64 #s(literal -2 binary64) z1) < 9.9999999999999998e149

                                              1. Initial program 76.8%

                                                \[z0 - \left(z0 - 1\right) \cdot e^{\frac{-2}{z1}} \]
                                              2. Taylor expanded in z1 around -inf

                                                \[\leadsto \color{blue}{1 + -1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                              3. Step-by-step derivation
                                                1. lower-+.f64N/A

                                                  \[\leadsto 1 + \color{blue}{-1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                                2. lower-*.f64N/A

                                                  \[\leadsto 1 + -1 \cdot \color{blue}{\frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                                3. lower-/.f64N/A

                                                  \[\leadsto 1 + -1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{\color{blue}{z1}} \]
                                              4. Applied rewrites71.0%

                                                \[\leadsto \color{blue}{1 + -1 \cdot \frac{-1 \cdot \frac{1.3333333333333333 \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                              5. Step-by-step derivation
                                                1. lift-*.f64N/A

                                                  \[\leadsto 1 + -1 \cdot \color{blue}{\frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                                2. lift-/.f64N/A

                                                  \[\leadsto 1 + -1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{\color{blue}{z1}} \]
                                                3. associate-*r/N/A

                                                  \[\leadsto 1 + \frac{-1 \cdot \left(-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)\right)}{\color{blue}{z1}} \]
                                                4. mult-flipN/A

                                                  \[\leadsto 1 + \left(-1 \cdot \left(-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)\right)\right) \cdot \color{blue}{\frac{1}{z1}} \]
                                              6. Applied rewrites57.8%

                                                \[\leadsto 1 + \frac{\left(\left(2 \cdot \left(z0 - 1\right)\right) \cdot z1 - \left(2 \cdot \left(z0 - 1\right) - \frac{z0 - 1}{z1} \cdot 1.3333333333333333\right)\right) \cdot 1}{\color{blue}{z1 \cdot z1}} \]
                                              7. Taylor expanded in z0 around 0

                                                \[\leadsto 1 + \frac{\left(\left(2 + -2 \cdot z1\right) - \frac{4}{3} \cdot \frac{1}{z1}\right) \cdot 1}{z1 \cdot z1} \]
                                              8. Step-by-step derivation
                                                1. lower--.f64N/A

                                                  \[\leadsto 1 + \frac{\left(\left(2 + -2 \cdot z1\right) - \frac{4}{3} \cdot \frac{1}{z1}\right) \cdot 1}{z1 \cdot z1} \]
                                                2. lower-+.f64N/A

                                                  \[\leadsto 1 + \frac{\left(\left(2 + -2 \cdot z1\right) - \frac{4}{3} \cdot \frac{1}{z1}\right) \cdot 1}{z1 \cdot z1} \]
                                                3. lower-*.f64N/A

                                                  \[\leadsto 1 + \frac{\left(\left(2 + -2 \cdot z1\right) - \frac{4}{3} \cdot \frac{1}{z1}\right) \cdot 1}{z1 \cdot z1} \]
                                                4. lower-*.f64N/A

                                                  \[\leadsto 1 + \frac{\left(\left(2 + -2 \cdot z1\right) - \frac{4}{3} \cdot \frac{1}{z1}\right) \cdot 1}{z1 \cdot z1} \]
                                                5. lower-/.f6451.4%

                                                  \[\leadsto 1 + \frac{\left(\left(2 + -2 \cdot z1\right) - 1.3333333333333333 \cdot \frac{1}{z1}\right) \cdot 1}{z1 \cdot z1} \]
                                              9. Applied rewrites51.4%

                                                \[\leadsto 1 + \frac{\left(\left(2 + -2 \cdot z1\right) - 1.3333333333333333 \cdot \frac{1}{z1}\right) \cdot 1}{z1 \cdot z1} \]
                                              10. Taylor expanded in z1 around 0

                                                \[\leadsto 1 + \frac{\frac{\frac{-4}{3}}{z1} \cdot 1}{z1 \cdot z1} \]
                                              11. Step-by-step derivation
                                                1. lower-/.f6451.0%

                                                  \[\leadsto 1 + \frac{\frac{-1.3333333333333333}{z1} \cdot 1}{z1 \cdot z1} \]
                                              12. Applied rewrites51.0%

                                                \[\leadsto 1 + \frac{\frac{-1.3333333333333333}{z1} \cdot 1}{z1 \cdot z1} \]

                                              if 9.9999999999999998e149 < (/.f64 #s(literal -2 binary64) z1)

                                              1. Initial program 76.8%

                                                \[z0 - \left(z0 - 1\right) \cdot e^{\frac{-2}{z1}} \]
                                              2. Taylor expanded in z1 around -inf

                                                \[\leadsto \color{blue}{1 + -1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                              3. Step-by-step derivation
                                                1. lower-+.f64N/A

                                                  \[\leadsto 1 + \color{blue}{-1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                                2. lower-*.f64N/A

                                                  \[\leadsto 1 + -1 \cdot \color{blue}{\frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                                3. lower-/.f64N/A

                                                  \[\leadsto 1 + -1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{\color{blue}{z1}} \]
                                              4. Applied rewrites71.0%

                                                \[\leadsto \color{blue}{1 + -1 \cdot \frac{-1 \cdot \frac{1.3333333333333333 \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                              5. Step-by-step derivation
                                                1. lift-*.f64N/A

                                                  \[\leadsto 1 + -1 \cdot \color{blue}{\frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                                2. lift-/.f64N/A

                                                  \[\leadsto 1 + -1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{\color{blue}{z1}} \]
                                                3. associate-*r/N/A

                                                  \[\leadsto 1 + \frac{-1 \cdot \left(-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)\right)}{\color{blue}{z1}} \]
                                                4. mult-flipN/A

                                                  \[\leadsto 1 + \left(-1 \cdot \left(-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)\right)\right) \cdot \color{blue}{\frac{1}{z1}} \]
                                              6. Applied rewrites57.8%

                                                \[\leadsto 1 + \frac{\left(\left(2 \cdot \left(z0 - 1\right)\right) \cdot z1 - \left(2 \cdot \left(z0 - 1\right) - \frac{z0 - 1}{z1} \cdot 1.3333333333333333\right)\right) \cdot 1}{\color{blue}{z1 \cdot z1}} \]
                                              7. Taylor expanded in z1 around inf

                                                \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{\color{blue}{z1}} \]
                                              8. Step-by-step derivation
                                                1. lower-/.f64N/A

                                                  \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                                2. lower-+.f64N/A

                                                  \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                                3. lower-*.f64N/A

                                                  \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                                4. lower-/.f64N/A

                                                  \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                                5. lower--.f64N/A

                                                  \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                                6. lower-*.f64N/A

                                                  \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                                7. lower--.f6466.8%

                                                  \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                              9. Applied rewrites66.8%

                                                \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{\color{blue}{z1}} \]
                                              10. Taylor expanded in z0 around 0

                                                \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + -2}{z1} \]
                                              11. Step-by-step derivation
                                                1. Applied rewrites54.2%

                                                  \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + -2}{z1} \]
                                              12. Recombined 5 regimes into one program.
                                              13. Add Preprocessing

                                              Alternative 13: 79.6% accurate, 1.2× speedup?

                                              \[\begin{array}{l} \mathbf{if}\;\frac{-2}{z1} \leq -20:\\ \;\;\;\;z0 - -1 \cdot 1\\ \mathbf{elif}\;\frac{-2}{z1} \leq 0.0002:\\ \;\;\;\;1 + 2 \cdot \frac{z0 - 1}{z1}\\ \mathbf{elif}\;\frac{-2}{z1} \leq 4 \cdot 10^{+96}:\\ \;\;\;\;z0 - \frac{z0 \cdot z0 - 1 \cdot 1}{z0 + 1} \cdot 1\\ \mathbf{elif}\;\frac{-2}{z1} \leq 10^{+150}:\\ \;\;\;\;1 + \frac{\frac{-1.3333333333333333}{z1} \cdot 1}{z1 \cdot z1}\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{\left(z1 + z1\right) \cdot \left(z0 - 1\right)}{z1 \cdot z1}\\ \end{array} \]
                                              (FPCore (z0 z1)
                                                :precision binary64
                                                (if (<= (/ -2.0 z1) -20.0)
                                                (- z0 (* -1.0 1.0))
                                                (if (<= (/ -2.0 z1) 0.0002)
                                                  (+ 1.0 (* 2.0 (/ (- z0 1.0) z1)))
                                                  (if (<= (/ -2.0 z1) 4e+96)
                                                    (- z0 (* (/ (- (* z0 z0) (* 1.0 1.0)) (+ z0 1.0)) 1.0))
                                                    (if (<= (/ -2.0 z1) 1e+150)
                                                      (+ 1.0 (/ (* (/ -1.3333333333333333 z1) 1.0) (* z1 z1)))
                                                      (+ 1.0 (/ (* (+ z1 z1) (- z0 1.0)) (* z1 z1))))))))
                                              double code(double z0, double z1) {
                                              	double tmp;
                                              	if ((-2.0 / z1) <= -20.0) {
                                              		tmp = z0 - (-1.0 * 1.0);
                                              	} else if ((-2.0 / z1) <= 0.0002) {
                                              		tmp = 1.0 + (2.0 * ((z0 - 1.0) / z1));
                                              	} else if ((-2.0 / z1) <= 4e+96) {
                                              		tmp = z0 - ((((z0 * z0) - (1.0 * 1.0)) / (z0 + 1.0)) * 1.0);
                                              	} else if ((-2.0 / z1) <= 1e+150) {
                                              		tmp = 1.0 + (((-1.3333333333333333 / z1) * 1.0) / (z1 * z1));
                                              	} else {
                                              		tmp = 1.0 + (((z1 + z1) * (z0 - 1.0)) / (z1 * z1));
                                              	}
                                              	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(z0, z1)
                                              use fmin_fmax_functions
                                                  real(8), intent (in) :: z0
                                                  real(8), intent (in) :: z1
                                                  real(8) :: tmp
                                                  if (((-2.0d0) / z1) <= (-20.0d0)) then
                                                      tmp = z0 - ((-1.0d0) * 1.0d0)
                                                  else if (((-2.0d0) / z1) <= 0.0002d0) then
                                                      tmp = 1.0d0 + (2.0d0 * ((z0 - 1.0d0) / z1))
                                                  else if (((-2.0d0) / z1) <= 4d+96) then
                                                      tmp = z0 - ((((z0 * z0) - (1.0d0 * 1.0d0)) / (z0 + 1.0d0)) * 1.0d0)
                                                  else if (((-2.0d0) / z1) <= 1d+150) then
                                                      tmp = 1.0d0 + ((((-1.3333333333333333d0) / z1) * 1.0d0) / (z1 * z1))
                                                  else
                                                      tmp = 1.0d0 + (((z1 + z1) * (z0 - 1.0d0)) / (z1 * z1))
                                                  end if
                                                  code = tmp
                                              end function
                                              
                                              public static double code(double z0, double z1) {
                                              	double tmp;
                                              	if ((-2.0 / z1) <= -20.0) {
                                              		tmp = z0 - (-1.0 * 1.0);
                                              	} else if ((-2.0 / z1) <= 0.0002) {
                                              		tmp = 1.0 + (2.0 * ((z0 - 1.0) / z1));
                                              	} else if ((-2.0 / z1) <= 4e+96) {
                                              		tmp = z0 - ((((z0 * z0) - (1.0 * 1.0)) / (z0 + 1.0)) * 1.0);
                                              	} else if ((-2.0 / z1) <= 1e+150) {
                                              		tmp = 1.0 + (((-1.3333333333333333 / z1) * 1.0) / (z1 * z1));
                                              	} else {
                                              		tmp = 1.0 + (((z1 + z1) * (z0 - 1.0)) / (z1 * z1));
                                              	}
                                              	return tmp;
                                              }
                                              
                                              def code(z0, z1):
                                              	tmp = 0
                                              	if (-2.0 / z1) <= -20.0:
                                              		tmp = z0 - (-1.0 * 1.0)
                                              	elif (-2.0 / z1) <= 0.0002:
                                              		tmp = 1.0 + (2.0 * ((z0 - 1.0) / z1))
                                              	elif (-2.0 / z1) <= 4e+96:
                                              		tmp = z0 - ((((z0 * z0) - (1.0 * 1.0)) / (z0 + 1.0)) * 1.0)
                                              	elif (-2.0 / z1) <= 1e+150:
                                              		tmp = 1.0 + (((-1.3333333333333333 / z1) * 1.0) / (z1 * z1))
                                              	else:
                                              		tmp = 1.0 + (((z1 + z1) * (z0 - 1.0)) / (z1 * z1))
                                              	return tmp
                                              
                                              function code(z0, z1)
                                              	tmp = 0.0
                                              	if (Float64(-2.0 / z1) <= -20.0)
                                              		tmp = Float64(z0 - Float64(-1.0 * 1.0));
                                              	elseif (Float64(-2.0 / z1) <= 0.0002)
                                              		tmp = Float64(1.0 + Float64(2.0 * Float64(Float64(z0 - 1.0) / z1)));
                                              	elseif (Float64(-2.0 / z1) <= 4e+96)
                                              		tmp = Float64(z0 - Float64(Float64(Float64(Float64(z0 * z0) - Float64(1.0 * 1.0)) / Float64(z0 + 1.0)) * 1.0));
                                              	elseif (Float64(-2.0 / z1) <= 1e+150)
                                              		tmp = Float64(1.0 + Float64(Float64(Float64(-1.3333333333333333 / z1) * 1.0) / Float64(z1 * z1)));
                                              	else
                                              		tmp = Float64(1.0 + Float64(Float64(Float64(z1 + z1) * Float64(z0 - 1.0)) / Float64(z1 * z1)));
                                              	end
                                              	return tmp
                                              end
                                              
                                              function tmp_2 = code(z0, z1)
                                              	tmp = 0.0;
                                              	if ((-2.0 / z1) <= -20.0)
                                              		tmp = z0 - (-1.0 * 1.0);
                                              	elseif ((-2.0 / z1) <= 0.0002)
                                              		tmp = 1.0 + (2.0 * ((z0 - 1.0) / z1));
                                              	elseif ((-2.0 / z1) <= 4e+96)
                                              		tmp = z0 - ((((z0 * z0) - (1.0 * 1.0)) / (z0 + 1.0)) * 1.0);
                                              	elseif ((-2.0 / z1) <= 1e+150)
                                              		tmp = 1.0 + (((-1.3333333333333333 / z1) * 1.0) / (z1 * z1));
                                              	else
                                              		tmp = 1.0 + (((z1 + z1) * (z0 - 1.0)) / (z1 * z1));
                                              	end
                                              	tmp_2 = tmp;
                                              end
                                              
                                              code[z0_, z1_] := If[LessEqual[N[(-2.0 / z1), $MachinePrecision], -20.0], N[(z0 - N[(-1.0 * 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(-2.0 / z1), $MachinePrecision], 0.0002], N[(1.0 + N[(2.0 * N[(N[(z0 - 1.0), $MachinePrecision] / z1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(-2.0 / z1), $MachinePrecision], 4e+96], N[(z0 - N[(N[(N[(N[(z0 * z0), $MachinePrecision] - N[(1.0 * 1.0), $MachinePrecision]), $MachinePrecision] / N[(z0 + 1.0), $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(-2.0 / z1), $MachinePrecision], 1e+150], N[(1.0 + N[(N[(N[(-1.3333333333333333 / z1), $MachinePrecision] * 1.0), $MachinePrecision] / N[(z1 * z1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[(N[(z1 + z1), $MachinePrecision] * N[(z0 - 1.0), $MachinePrecision]), $MachinePrecision] / N[(z1 * z1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
                                              
                                              \begin{array}{l}
                                              \mathbf{if}\;\frac{-2}{z1} \leq -20:\\
                                              \;\;\;\;z0 - -1 \cdot 1\\
                                              
                                              \mathbf{elif}\;\frac{-2}{z1} \leq 0.0002:\\
                                              \;\;\;\;1 + 2 \cdot \frac{z0 - 1}{z1}\\
                                              
                                              \mathbf{elif}\;\frac{-2}{z1} \leq 4 \cdot 10^{+96}:\\
                                              \;\;\;\;z0 - \frac{z0 \cdot z0 - 1 \cdot 1}{z0 + 1} \cdot 1\\
                                              
                                              \mathbf{elif}\;\frac{-2}{z1} \leq 10^{+150}:\\
                                              \;\;\;\;1 + \frac{\frac{-1.3333333333333333}{z1} \cdot 1}{z1 \cdot z1}\\
                                              
                                              \mathbf{else}:\\
                                              \;\;\;\;1 + \frac{\left(z1 + z1\right) \cdot \left(z0 - 1\right)}{z1 \cdot z1}\\
                                              
                                              
                                              \end{array}
                                              
                                              Derivation
                                              1. Split input into 5 regimes
                                              2. if (/.f64 #s(literal -2 binary64) z1) < -20

                                                1. Initial program 76.8%

                                                  \[z0 - \left(z0 - 1\right) \cdot e^{\frac{-2}{z1}} \]
                                                2. Taylor expanded in z1 around inf

                                                  \[\leadsto z0 - \left(z0 - 1\right) \cdot \color{blue}{1} \]
                                                3. Step-by-step derivation
                                                  1. Applied rewrites27.8%

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

                                                    \[\leadsto z0 - \color{blue}{-1} \cdot 1 \]
                                                  3. Step-by-step derivation
                                                    1. Applied rewrites37.4%

                                                      \[\leadsto z0 - \color{blue}{-1} \cdot 1 \]

                                                    if -20 < (/.f64 #s(literal -2 binary64) z1) < 2.0000000000000001e-4

                                                    1. Initial program 76.8%

                                                      \[z0 - \left(z0 - 1\right) \cdot e^{\frac{-2}{z1}} \]
                                                    2. Taylor expanded in z1 around inf

                                                      \[\leadsto \color{blue}{1 + 2 \cdot \frac{z0 - 1}{z1}} \]
                                                    3. Step-by-step derivation
                                                      1. lower-+.f64N/A

                                                        \[\leadsto 1 + \color{blue}{2 \cdot \frac{z0 - 1}{z1}} \]
                                                      2. lower-*.f64N/A

                                                        \[\leadsto 1 + 2 \cdot \color{blue}{\frac{z0 - 1}{z1}} \]
                                                      3. lower-/.f64N/A

                                                        \[\leadsto 1 + 2 \cdot \frac{z0 - 1}{\color{blue}{z1}} \]
                                                      4. lower--.f6458.5%

                                                        \[\leadsto 1 + 2 \cdot \frac{z0 - 1}{z1} \]
                                                    4. Applied rewrites58.5%

                                                      \[\leadsto \color{blue}{1 + 2 \cdot \frac{z0 - 1}{z1}} \]

                                                    if 2.0000000000000001e-4 < (/.f64 #s(literal -2 binary64) z1) < 4.0000000000000002e96

                                                    1. Initial program 76.8%

                                                      \[z0 - \left(z0 - 1\right) \cdot e^{\frac{-2}{z1}} \]
                                                    2. Taylor expanded in z1 around inf

                                                      \[\leadsto z0 - \left(z0 - 1\right) \cdot \color{blue}{1} \]
                                                    3. Step-by-step derivation
                                                      1. Applied rewrites27.8%

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

                                                          \[\leadsto z0 - \color{blue}{\left(z0 - 1\right)} \cdot 1 \]
                                                        2. flip--N/A

                                                          \[\leadsto z0 - \color{blue}{\frac{z0 \cdot z0 - 1 \cdot 1}{z0 + 1}} \cdot 1 \]
                                                        3. lower-unsound-/.f64N/A

                                                          \[\leadsto z0 - \color{blue}{\frac{z0 \cdot z0 - 1 \cdot 1}{z0 + 1}} \cdot 1 \]
                                                        4. lower-unsound--.f64N/A

                                                          \[\leadsto z0 - \frac{\color{blue}{z0 \cdot z0 - 1 \cdot 1}}{z0 + 1} \cdot 1 \]
                                                        5. lower-unsound-*.f64N/A

                                                          \[\leadsto z0 - \frac{\color{blue}{z0 \cdot z0} - 1 \cdot 1}{z0 + 1} \cdot 1 \]
                                                        6. lower-unsound-*.f64N/A

                                                          \[\leadsto z0 - \frac{z0 \cdot z0 - \color{blue}{1 \cdot 1}}{z0 + 1} \cdot 1 \]
                                                        7. lower-unsound-+.f6433.7%

                                                          \[\leadsto z0 - \frac{z0 \cdot z0 - 1 \cdot 1}{\color{blue}{z0 + 1}} \cdot 1 \]
                                                      3. Applied rewrites33.7%

                                                        \[\leadsto z0 - \color{blue}{\frac{z0 \cdot z0 - 1 \cdot 1}{z0 + 1}} \cdot 1 \]

                                                      if 4.0000000000000002e96 < (/.f64 #s(literal -2 binary64) z1) < 9.9999999999999998e149

                                                      1. Initial program 76.8%

                                                        \[z0 - \left(z0 - 1\right) \cdot e^{\frac{-2}{z1}} \]
                                                      2. Taylor expanded in z1 around -inf

                                                        \[\leadsto \color{blue}{1 + -1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                                      3. Step-by-step derivation
                                                        1. lower-+.f64N/A

                                                          \[\leadsto 1 + \color{blue}{-1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                                        2. lower-*.f64N/A

                                                          \[\leadsto 1 + -1 \cdot \color{blue}{\frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                                        3. lower-/.f64N/A

                                                          \[\leadsto 1 + -1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{\color{blue}{z1}} \]
                                                      4. Applied rewrites71.0%

                                                        \[\leadsto \color{blue}{1 + -1 \cdot \frac{-1 \cdot \frac{1.3333333333333333 \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                                      5. Step-by-step derivation
                                                        1. lift-*.f64N/A

                                                          \[\leadsto 1 + -1 \cdot \color{blue}{\frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                                        2. lift-/.f64N/A

                                                          \[\leadsto 1 + -1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{\color{blue}{z1}} \]
                                                        3. associate-*r/N/A

                                                          \[\leadsto 1 + \frac{-1 \cdot \left(-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)\right)}{\color{blue}{z1}} \]
                                                        4. mult-flipN/A

                                                          \[\leadsto 1 + \left(-1 \cdot \left(-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)\right)\right) \cdot \color{blue}{\frac{1}{z1}} \]
                                                      6. Applied rewrites57.8%

                                                        \[\leadsto 1 + \frac{\left(\left(2 \cdot \left(z0 - 1\right)\right) \cdot z1 - \left(2 \cdot \left(z0 - 1\right) - \frac{z0 - 1}{z1} \cdot 1.3333333333333333\right)\right) \cdot 1}{\color{blue}{z1 \cdot z1}} \]
                                                      7. Taylor expanded in z0 around 0

                                                        \[\leadsto 1 + \frac{\left(\left(2 + -2 \cdot z1\right) - \frac{4}{3} \cdot \frac{1}{z1}\right) \cdot 1}{z1 \cdot z1} \]
                                                      8. Step-by-step derivation
                                                        1. lower--.f64N/A

                                                          \[\leadsto 1 + \frac{\left(\left(2 + -2 \cdot z1\right) - \frac{4}{3} \cdot \frac{1}{z1}\right) \cdot 1}{z1 \cdot z1} \]
                                                        2. lower-+.f64N/A

                                                          \[\leadsto 1 + \frac{\left(\left(2 + -2 \cdot z1\right) - \frac{4}{3} \cdot \frac{1}{z1}\right) \cdot 1}{z1 \cdot z1} \]
                                                        3. lower-*.f64N/A

                                                          \[\leadsto 1 + \frac{\left(\left(2 + -2 \cdot z1\right) - \frac{4}{3} \cdot \frac{1}{z1}\right) \cdot 1}{z1 \cdot z1} \]
                                                        4. lower-*.f64N/A

                                                          \[\leadsto 1 + \frac{\left(\left(2 + -2 \cdot z1\right) - \frac{4}{3} \cdot \frac{1}{z1}\right) \cdot 1}{z1 \cdot z1} \]
                                                        5. lower-/.f6451.4%

                                                          \[\leadsto 1 + \frac{\left(\left(2 + -2 \cdot z1\right) - 1.3333333333333333 \cdot \frac{1}{z1}\right) \cdot 1}{z1 \cdot z1} \]
                                                      9. Applied rewrites51.4%

                                                        \[\leadsto 1 + \frac{\left(\left(2 + -2 \cdot z1\right) - 1.3333333333333333 \cdot \frac{1}{z1}\right) \cdot 1}{z1 \cdot z1} \]
                                                      10. Taylor expanded in z1 around 0

                                                        \[\leadsto 1 + \frac{\frac{\frac{-4}{3}}{z1} \cdot 1}{z1 \cdot z1} \]
                                                      11. Step-by-step derivation
                                                        1. lower-/.f6451.0%

                                                          \[\leadsto 1 + \frac{\frac{-1.3333333333333333}{z1} \cdot 1}{z1 \cdot z1} \]
                                                      12. Applied rewrites51.0%

                                                        \[\leadsto 1 + \frac{\frac{-1.3333333333333333}{z1} \cdot 1}{z1 \cdot z1} \]

                                                      if 9.9999999999999998e149 < (/.f64 #s(literal -2 binary64) z1)

                                                      1. Initial program 76.8%

                                                        \[z0 - \left(z0 - 1\right) \cdot e^{\frac{-2}{z1}} \]
                                                      2. Step-by-step derivation
                                                        1. lift-exp.f64N/A

                                                          \[\leadsto z0 - \left(z0 - 1\right) \cdot \color{blue}{e^{\frac{-2}{z1}}} \]
                                                        2. lift-/.f64N/A

                                                          \[\leadsto z0 - \left(z0 - 1\right) \cdot e^{\color{blue}{\frac{-2}{z1}}} \]
                                                        3. frac-2negN/A

                                                          \[\leadsto z0 - \left(z0 - 1\right) \cdot e^{\color{blue}{\frac{\mathsf{neg}\left(-2\right)}{\mathsf{neg}\left(z1\right)}}} \]
                                                        4. mult-flipN/A

                                                          \[\leadsto z0 - \left(z0 - 1\right) \cdot e^{\color{blue}{\left(\mathsf{neg}\left(-2\right)\right) \cdot \frac{1}{\mathsf{neg}\left(z1\right)}}} \]
                                                        5. exp-prodN/A

                                                          \[\leadsto z0 - \left(z0 - 1\right) \cdot \color{blue}{{\left(e^{\mathsf{neg}\left(-2\right)}\right)}^{\left(\frac{1}{\mathsf{neg}\left(z1\right)}\right)}} \]
                                                        6. lower-pow.f64N/A

                                                          \[\leadsto z0 - \left(z0 - 1\right) \cdot \color{blue}{{\left(e^{\mathsf{neg}\left(-2\right)}\right)}^{\left(\frac{1}{\mathsf{neg}\left(z1\right)}\right)}} \]
                                                        7. lower-exp.f64N/A

                                                          \[\leadsto z0 - \left(z0 - 1\right) \cdot {\color{blue}{\left(e^{\mathsf{neg}\left(-2\right)}\right)}}^{\left(\frac{1}{\mathsf{neg}\left(z1\right)}\right)} \]
                                                        8. metadata-evalN/A

                                                          \[\leadsto z0 - \left(z0 - 1\right) \cdot {\left(e^{\color{blue}{2}}\right)}^{\left(\frac{1}{\mathsf{neg}\left(z1\right)}\right)} \]
                                                        9. frac-2negN/A

                                                          \[\leadsto z0 - \left(z0 - 1\right) \cdot {\left(e^{2}\right)}^{\color{blue}{\left(\frac{\mathsf{neg}\left(1\right)}{\mathsf{neg}\left(\left(\mathsf{neg}\left(z1\right)\right)\right)}\right)}} \]
                                                        10. remove-double-negN/A

                                                          \[\leadsto z0 - \left(z0 - 1\right) \cdot {\left(e^{2}\right)}^{\left(\frac{\mathsf{neg}\left(1\right)}{\color{blue}{z1}}\right)} \]
                                                        11. lower-/.f64N/A

                                                          \[\leadsto z0 - \left(z0 - 1\right) \cdot {\left(e^{2}\right)}^{\color{blue}{\left(\frac{\mathsf{neg}\left(1\right)}{z1}\right)}} \]
                                                        12. metadata-eval76.8%

                                                          \[\leadsto z0 - \left(z0 - 1\right) \cdot {\left(e^{2}\right)}^{\left(\frac{\color{blue}{-1}}{z1}\right)} \]
                                                      3. Applied rewrites76.8%

                                                        \[\leadsto z0 - \left(z0 - 1\right) \cdot \color{blue}{{\left(e^{2}\right)}^{\left(\frac{-1}{z1}\right)}} \]
                                                      4. Taylor expanded in z1 around inf

                                                        \[\leadsto \color{blue}{1 + 2 \cdot \frac{z0 - 1}{z1}} \]
                                                      5. Step-by-step derivation
                                                        1. lower-+.f64N/A

                                                          \[\leadsto 1 + \color{blue}{2 \cdot \frac{z0 - 1}{z1}} \]
                                                        2. lower-*.f64N/A

                                                          \[\leadsto 1 + 2 \cdot \color{blue}{\frac{z0 - 1}{z1}} \]
                                                        3. lower-/.f64N/A

                                                          \[\leadsto 1 + 2 \cdot \frac{z0 - 1}{\color{blue}{z1}} \]
                                                        4. lower--.f6458.5%

                                                          \[\leadsto 1 + 2 \cdot \frac{z0 - 1}{z1} \]
                                                      6. Applied rewrites58.5%

                                                        \[\leadsto \color{blue}{1 + 2 \cdot \frac{z0 - 1}{z1}} \]
                                                      7. Step-by-step derivation
                                                        1. lift-*.f64N/A

                                                          \[\leadsto 1 + 2 \cdot \color{blue}{\frac{z0 - 1}{z1}} \]
                                                        2. count-2-revN/A

                                                          \[\leadsto 1 + \left(\frac{z0 - 1}{z1} + \color{blue}{\frac{z0 - 1}{z1}}\right) \]
                                                        3. lift-/.f64N/A

                                                          \[\leadsto 1 + \left(\frac{z0 - 1}{z1} + \frac{\color{blue}{z0 - 1}}{z1}\right) \]
                                                        4. lift-/.f64N/A

                                                          \[\leadsto 1 + \left(\frac{z0 - 1}{z1} + \frac{z0 - 1}{\color{blue}{z1}}\right) \]
                                                        5. common-denominatorN/A

                                                          \[\leadsto 1 + \frac{\left(z0 - 1\right) \cdot z1 + \left(z0 - 1\right) \cdot z1}{\color{blue}{z1 \cdot z1}} \]
                                                        6. count-2-revN/A

                                                          \[\leadsto 1 + \frac{2 \cdot \left(\left(z0 - 1\right) \cdot z1\right)}{\color{blue}{z1} \cdot z1} \]
                                                        7. associate-*l*N/A

                                                          \[\leadsto 1 + \frac{\left(2 \cdot \left(z0 - 1\right)\right) \cdot z1}{\color{blue}{z1} \cdot z1} \]
                                                        8. lift--.f64N/A

                                                          \[\leadsto 1 + \frac{\left(2 \cdot \left(z0 - 1\right)\right) \cdot z1}{z1 \cdot z1} \]
                                                        9. lift-*.f64N/A

                                                          \[\leadsto 1 + \frac{\left(2 \cdot \left(z0 - 1\right)\right) \cdot z1}{z1 \cdot \color{blue}{z1}} \]
                                                        10. lower-/.f64N/A

                                                          \[\leadsto 1 + \frac{\left(2 \cdot \left(z0 - 1\right)\right) \cdot z1}{\color{blue}{z1 \cdot z1}} \]
                                                        11. lift--.f64N/A

                                                          \[\leadsto 1 + \frac{\left(2 \cdot \left(z0 - 1\right)\right) \cdot z1}{z1 \cdot z1} \]
                                                        12. lift-*.f64N/A

                                                          \[\leadsto 1 + \frac{\left(2 \cdot \left(z0 - 1\right)\right) \cdot z1}{z1 \cdot z1} \]
                                                        13. *-commutativeN/A

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

                                                          \[\leadsto 1 + \frac{z1 \cdot \left(2 \cdot \left(z0 - 1\right)\right)}{z1 \cdot z1} \]
                                                        15. associate-*r*N/A

                                                          \[\leadsto 1 + \frac{\left(z1 \cdot 2\right) \cdot \left(z0 - 1\right)}{\color{blue}{z1} \cdot z1} \]
                                                        16. *-commutativeN/A

                                                          \[\leadsto 1 + \frac{\left(2 \cdot z1\right) \cdot \left(z0 - 1\right)}{z1 \cdot z1} \]
                                                        17. count-2N/A

                                                          \[\leadsto 1 + \frac{\left(z1 + z1\right) \cdot \left(z0 - 1\right)}{z1 \cdot z1} \]
                                                        18. lift-+.f64N/A

                                                          \[\leadsto 1 + \frac{\left(z1 + z1\right) \cdot \left(z0 - 1\right)}{z1 \cdot z1} \]
                                                        19. lower-*.f6452.1%

                                                          \[\leadsto 1 + \frac{\left(z1 + z1\right) \cdot \left(z0 - 1\right)}{\color{blue}{z1} \cdot z1} \]
                                                      8. Applied rewrites52.1%

                                                        \[\leadsto 1 + \frac{\left(z1 + z1\right) \cdot \left(z0 - 1\right)}{\color{blue}{z1 \cdot z1}} \]
                                                    4. Recombined 5 regimes into one program.
                                                    5. Add Preprocessing

                                                    Alternative 14: 79.2% accurate, 1.4× speedup?

                                                    \[\begin{array}{l} t_0 := \frac{z0 - 1}{z1}\\ \mathbf{if}\;\frac{-2}{z1} \leq -20:\\ \;\;\;\;z0 - -1 \cdot 1\\ \mathbf{elif}\;\frac{-2}{z1} \leq 4 \cdot 10^{+96}:\\ \;\;\;\;\frac{-2 \cdot \left(t\_0 - \left(z0 - 1\right)\right)}{z1} - -1\\ \mathbf{elif}\;\frac{-2}{z1} \leq 10^{+150}:\\ \;\;\;\;1 + \frac{\frac{-1.3333333333333333}{z1} \cdot 1}{z1 \cdot z1}\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{-2 \cdot t\_0 + -2}{z1}\\ \end{array} \]
                                                    (FPCore (z0 z1)
                                                      :precision binary64
                                                      (let* ((t_0 (/ (- z0 1.0) z1)))
                                                      (if (<= (/ -2.0 z1) -20.0)
                                                        (- z0 (* -1.0 1.0))
                                                        (if (<= (/ -2.0 z1) 4e+96)
                                                          (- (/ (* -2.0 (- t_0 (- z0 1.0))) z1) -1.0)
                                                          (if (<= (/ -2.0 z1) 1e+150)
                                                            (+ 1.0 (/ (* (/ -1.3333333333333333 z1) 1.0) (* z1 z1)))
                                                            (+ 1.0 (/ (+ (* -2.0 t_0) -2.0) z1)))))))
                                                    double code(double z0, double z1) {
                                                    	double t_0 = (z0 - 1.0) / z1;
                                                    	double tmp;
                                                    	if ((-2.0 / z1) <= -20.0) {
                                                    		tmp = z0 - (-1.0 * 1.0);
                                                    	} else if ((-2.0 / z1) <= 4e+96) {
                                                    		tmp = ((-2.0 * (t_0 - (z0 - 1.0))) / z1) - -1.0;
                                                    	} else if ((-2.0 / z1) <= 1e+150) {
                                                    		tmp = 1.0 + (((-1.3333333333333333 / z1) * 1.0) / (z1 * z1));
                                                    	} else {
                                                    		tmp = 1.0 + (((-2.0 * t_0) + -2.0) / z1);
                                                    	}
                                                    	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(z0, z1)
                                                    use fmin_fmax_functions
                                                        real(8), intent (in) :: z0
                                                        real(8), intent (in) :: z1
                                                        real(8) :: t_0
                                                        real(8) :: tmp
                                                        t_0 = (z0 - 1.0d0) / z1
                                                        if (((-2.0d0) / z1) <= (-20.0d0)) then
                                                            tmp = z0 - ((-1.0d0) * 1.0d0)
                                                        else if (((-2.0d0) / z1) <= 4d+96) then
                                                            tmp = (((-2.0d0) * (t_0 - (z0 - 1.0d0))) / z1) - (-1.0d0)
                                                        else if (((-2.0d0) / z1) <= 1d+150) then
                                                            tmp = 1.0d0 + ((((-1.3333333333333333d0) / z1) * 1.0d0) / (z1 * z1))
                                                        else
                                                            tmp = 1.0d0 + ((((-2.0d0) * t_0) + (-2.0d0)) / z1)
                                                        end if
                                                        code = tmp
                                                    end function
                                                    
                                                    public static double code(double z0, double z1) {
                                                    	double t_0 = (z0 - 1.0) / z1;
                                                    	double tmp;
                                                    	if ((-2.0 / z1) <= -20.0) {
                                                    		tmp = z0 - (-1.0 * 1.0);
                                                    	} else if ((-2.0 / z1) <= 4e+96) {
                                                    		tmp = ((-2.0 * (t_0 - (z0 - 1.0))) / z1) - -1.0;
                                                    	} else if ((-2.0 / z1) <= 1e+150) {
                                                    		tmp = 1.0 + (((-1.3333333333333333 / z1) * 1.0) / (z1 * z1));
                                                    	} else {
                                                    		tmp = 1.0 + (((-2.0 * t_0) + -2.0) / z1);
                                                    	}
                                                    	return tmp;
                                                    }
                                                    
                                                    def code(z0, z1):
                                                    	t_0 = (z0 - 1.0) / z1
                                                    	tmp = 0
                                                    	if (-2.0 / z1) <= -20.0:
                                                    		tmp = z0 - (-1.0 * 1.0)
                                                    	elif (-2.0 / z1) <= 4e+96:
                                                    		tmp = ((-2.0 * (t_0 - (z0 - 1.0))) / z1) - -1.0
                                                    	elif (-2.0 / z1) <= 1e+150:
                                                    		tmp = 1.0 + (((-1.3333333333333333 / z1) * 1.0) / (z1 * z1))
                                                    	else:
                                                    		tmp = 1.0 + (((-2.0 * t_0) + -2.0) / z1)
                                                    	return tmp
                                                    
                                                    function code(z0, z1)
                                                    	t_0 = Float64(Float64(z0 - 1.0) / z1)
                                                    	tmp = 0.0
                                                    	if (Float64(-2.0 / z1) <= -20.0)
                                                    		tmp = Float64(z0 - Float64(-1.0 * 1.0));
                                                    	elseif (Float64(-2.0 / z1) <= 4e+96)
                                                    		tmp = Float64(Float64(Float64(-2.0 * Float64(t_0 - Float64(z0 - 1.0))) / z1) - -1.0);
                                                    	elseif (Float64(-2.0 / z1) <= 1e+150)
                                                    		tmp = Float64(1.0 + Float64(Float64(Float64(-1.3333333333333333 / z1) * 1.0) / Float64(z1 * z1)));
                                                    	else
                                                    		tmp = Float64(1.0 + Float64(Float64(Float64(-2.0 * t_0) + -2.0) / z1));
                                                    	end
                                                    	return tmp
                                                    end
                                                    
                                                    function tmp_2 = code(z0, z1)
                                                    	t_0 = (z0 - 1.0) / z1;
                                                    	tmp = 0.0;
                                                    	if ((-2.0 / z1) <= -20.0)
                                                    		tmp = z0 - (-1.0 * 1.0);
                                                    	elseif ((-2.0 / z1) <= 4e+96)
                                                    		tmp = ((-2.0 * (t_0 - (z0 - 1.0))) / z1) - -1.0;
                                                    	elseif ((-2.0 / z1) <= 1e+150)
                                                    		tmp = 1.0 + (((-1.3333333333333333 / z1) * 1.0) / (z1 * z1));
                                                    	else
                                                    		tmp = 1.0 + (((-2.0 * t_0) + -2.0) / z1);
                                                    	end
                                                    	tmp_2 = tmp;
                                                    end
                                                    
                                                    code[z0_, z1_] := Block[{t$95$0 = N[(N[(z0 - 1.0), $MachinePrecision] / z1), $MachinePrecision]}, If[LessEqual[N[(-2.0 / z1), $MachinePrecision], -20.0], N[(z0 - N[(-1.0 * 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(-2.0 / z1), $MachinePrecision], 4e+96], N[(N[(N[(-2.0 * N[(t$95$0 - N[(z0 - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z1), $MachinePrecision] - -1.0), $MachinePrecision], If[LessEqual[N[(-2.0 / z1), $MachinePrecision], 1e+150], N[(1.0 + N[(N[(N[(-1.3333333333333333 / z1), $MachinePrecision] * 1.0), $MachinePrecision] / N[(z1 * z1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[(N[(-2.0 * t$95$0), $MachinePrecision] + -2.0), $MachinePrecision] / z1), $MachinePrecision]), $MachinePrecision]]]]]
                                                    
                                                    \begin{array}{l}
                                                    t_0 := \frac{z0 - 1}{z1}\\
                                                    \mathbf{if}\;\frac{-2}{z1} \leq -20:\\
                                                    \;\;\;\;z0 - -1 \cdot 1\\
                                                    
                                                    \mathbf{elif}\;\frac{-2}{z1} \leq 4 \cdot 10^{+96}:\\
                                                    \;\;\;\;\frac{-2 \cdot \left(t\_0 - \left(z0 - 1\right)\right)}{z1} - -1\\
                                                    
                                                    \mathbf{elif}\;\frac{-2}{z1} \leq 10^{+150}:\\
                                                    \;\;\;\;1 + \frac{\frac{-1.3333333333333333}{z1} \cdot 1}{z1 \cdot z1}\\
                                                    
                                                    \mathbf{else}:\\
                                                    \;\;\;\;1 + \frac{-2 \cdot t\_0 + -2}{z1}\\
                                                    
                                                    
                                                    \end{array}
                                                    
                                                    Derivation
                                                    1. Split input into 4 regimes
                                                    2. if (/.f64 #s(literal -2 binary64) z1) < -20

                                                      1. Initial program 76.8%

                                                        \[z0 - \left(z0 - 1\right) \cdot e^{\frac{-2}{z1}} \]
                                                      2. Taylor expanded in z1 around inf

                                                        \[\leadsto z0 - \left(z0 - 1\right) \cdot \color{blue}{1} \]
                                                      3. Step-by-step derivation
                                                        1. Applied rewrites27.8%

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

                                                          \[\leadsto z0 - \color{blue}{-1} \cdot 1 \]
                                                        3. Step-by-step derivation
                                                          1. Applied rewrites37.4%

                                                            \[\leadsto z0 - \color{blue}{-1} \cdot 1 \]

                                                          if -20 < (/.f64 #s(literal -2 binary64) z1) < 4.0000000000000002e96

                                                          1. Initial program 76.8%

                                                            \[z0 - \left(z0 - 1\right) \cdot e^{\frac{-2}{z1}} \]
                                                          2. Taylor expanded in z1 around -inf

                                                            \[\leadsto \color{blue}{1 + -1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                                          3. Step-by-step derivation
                                                            1. lower-+.f64N/A

                                                              \[\leadsto 1 + \color{blue}{-1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                                            2. lower-*.f64N/A

                                                              \[\leadsto 1 + -1 \cdot \color{blue}{\frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                                            3. lower-/.f64N/A

                                                              \[\leadsto 1 + -1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{\color{blue}{z1}} \]
                                                          4. Applied rewrites71.0%

                                                            \[\leadsto \color{blue}{1 + -1 \cdot \frac{-1 \cdot \frac{1.3333333333333333 \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                                          5. Step-by-step derivation
                                                            1. lift-*.f64N/A

                                                              \[\leadsto 1 + -1 \cdot \color{blue}{\frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                                            2. lift-/.f64N/A

                                                              \[\leadsto 1 + -1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{\color{blue}{z1}} \]
                                                            3. associate-*r/N/A

                                                              \[\leadsto 1 + \frac{-1 \cdot \left(-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)\right)}{\color{blue}{z1}} \]
                                                            4. mult-flipN/A

                                                              \[\leadsto 1 + \left(-1 \cdot \left(-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)\right)\right) \cdot \color{blue}{\frac{1}{z1}} \]
                                                          6. Applied rewrites57.8%

                                                            \[\leadsto 1 + \frac{\left(\left(2 \cdot \left(z0 - 1\right)\right) \cdot z1 - \left(2 \cdot \left(z0 - 1\right) - \frac{z0 - 1}{z1} \cdot 1.3333333333333333\right)\right) \cdot 1}{\color{blue}{z1 \cdot z1}} \]
                                                          7. Taylor expanded in z1 around inf

                                                            \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{\color{blue}{z1}} \]
                                                          8. Step-by-step derivation
                                                            1. lower-/.f64N/A

                                                              \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                                            2. lower-+.f64N/A

                                                              \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                                            3. lower-*.f64N/A

                                                              \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                                            4. lower-/.f64N/A

                                                              \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                                            5. lower--.f64N/A

                                                              \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                                            6. lower-*.f64N/A

                                                              \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                                            7. lower--.f6466.8%

                                                              \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                                          9. Applied rewrites66.8%

                                                            \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{\color{blue}{z1}} \]
                                                          10. Step-by-step derivation
                                                            1. lift--.f64N/A

                                                              \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                                            2. *-commutativeN/A

                                                              \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                                            3. *-commutativeN/A

                                                              \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                                            4. sinh-+-cosh-revN/A

                                                              \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                                            5. sinh-+-cosh-revN/A

                                                              \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                                            6. metadata-evalN/A

                                                              \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                                            7. associate-*r/N/A

                                                              \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                                            8. pow-expN/A

                                                              \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                                            9. lift--.f6466.8%

                                                              \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                                            10. lift-+.f64N/A

                                                              \[\leadsto 1 + \color{blue}{\frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                                          11. Applied rewrites66.8%

                                                            \[\leadsto \color{blue}{\frac{-2 \cdot \left(\frac{z0 - 1}{z1} - \left(z0 - 1\right)\right)}{z1} - -1} \]

                                                          if 4.0000000000000002e96 < (/.f64 #s(literal -2 binary64) z1) < 9.9999999999999998e149

                                                          1. Initial program 76.8%

                                                            \[z0 - \left(z0 - 1\right) \cdot e^{\frac{-2}{z1}} \]
                                                          2. Taylor expanded in z1 around -inf

                                                            \[\leadsto \color{blue}{1 + -1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                                          3. Step-by-step derivation
                                                            1. lower-+.f64N/A

                                                              \[\leadsto 1 + \color{blue}{-1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                                            2. lower-*.f64N/A

                                                              \[\leadsto 1 + -1 \cdot \color{blue}{\frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                                            3. lower-/.f64N/A

                                                              \[\leadsto 1 + -1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{\color{blue}{z1}} \]
                                                          4. Applied rewrites71.0%

                                                            \[\leadsto \color{blue}{1 + -1 \cdot \frac{-1 \cdot \frac{1.3333333333333333 \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                                          5. Step-by-step derivation
                                                            1. lift-*.f64N/A

                                                              \[\leadsto 1 + -1 \cdot \color{blue}{\frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                                            2. lift-/.f64N/A

                                                              \[\leadsto 1 + -1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{\color{blue}{z1}} \]
                                                            3. associate-*r/N/A

                                                              \[\leadsto 1 + \frac{-1 \cdot \left(-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)\right)}{\color{blue}{z1}} \]
                                                            4. mult-flipN/A

                                                              \[\leadsto 1 + \left(-1 \cdot \left(-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)\right)\right) \cdot \color{blue}{\frac{1}{z1}} \]
                                                          6. Applied rewrites57.8%

                                                            \[\leadsto 1 + \frac{\left(\left(2 \cdot \left(z0 - 1\right)\right) \cdot z1 - \left(2 \cdot \left(z0 - 1\right) - \frac{z0 - 1}{z1} \cdot 1.3333333333333333\right)\right) \cdot 1}{\color{blue}{z1 \cdot z1}} \]
                                                          7. Taylor expanded in z0 around 0

                                                            \[\leadsto 1 + \frac{\left(\left(2 + -2 \cdot z1\right) - \frac{4}{3} \cdot \frac{1}{z1}\right) \cdot 1}{z1 \cdot z1} \]
                                                          8. Step-by-step derivation
                                                            1. lower--.f64N/A

                                                              \[\leadsto 1 + \frac{\left(\left(2 + -2 \cdot z1\right) - \frac{4}{3} \cdot \frac{1}{z1}\right) \cdot 1}{z1 \cdot z1} \]
                                                            2. lower-+.f64N/A

                                                              \[\leadsto 1 + \frac{\left(\left(2 + -2 \cdot z1\right) - \frac{4}{3} \cdot \frac{1}{z1}\right) \cdot 1}{z1 \cdot z1} \]
                                                            3. lower-*.f64N/A

                                                              \[\leadsto 1 + \frac{\left(\left(2 + -2 \cdot z1\right) - \frac{4}{3} \cdot \frac{1}{z1}\right) \cdot 1}{z1 \cdot z1} \]
                                                            4. lower-*.f64N/A

                                                              \[\leadsto 1 + \frac{\left(\left(2 + -2 \cdot z1\right) - \frac{4}{3} \cdot \frac{1}{z1}\right) \cdot 1}{z1 \cdot z1} \]
                                                            5. lower-/.f6451.4%

                                                              \[\leadsto 1 + \frac{\left(\left(2 + -2 \cdot z1\right) - 1.3333333333333333 \cdot \frac{1}{z1}\right) \cdot 1}{z1 \cdot z1} \]
                                                          9. Applied rewrites51.4%

                                                            \[\leadsto 1 + \frac{\left(\left(2 + -2 \cdot z1\right) - 1.3333333333333333 \cdot \frac{1}{z1}\right) \cdot 1}{z1 \cdot z1} \]
                                                          10. Taylor expanded in z1 around 0

                                                            \[\leadsto 1 + \frac{\frac{\frac{-4}{3}}{z1} \cdot 1}{z1 \cdot z1} \]
                                                          11. Step-by-step derivation
                                                            1. lower-/.f6451.0%

                                                              \[\leadsto 1 + \frac{\frac{-1.3333333333333333}{z1} \cdot 1}{z1 \cdot z1} \]
                                                          12. Applied rewrites51.0%

                                                            \[\leadsto 1 + \frac{\frac{-1.3333333333333333}{z1} \cdot 1}{z1 \cdot z1} \]

                                                          if 9.9999999999999998e149 < (/.f64 #s(literal -2 binary64) z1)

                                                          1. Initial program 76.8%

                                                            \[z0 - \left(z0 - 1\right) \cdot e^{\frac{-2}{z1}} \]
                                                          2. Taylor expanded in z1 around -inf

                                                            \[\leadsto \color{blue}{1 + -1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                                          3. Step-by-step derivation
                                                            1. lower-+.f64N/A

                                                              \[\leadsto 1 + \color{blue}{-1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                                            2. lower-*.f64N/A

                                                              \[\leadsto 1 + -1 \cdot \color{blue}{\frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                                            3. lower-/.f64N/A

                                                              \[\leadsto 1 + -1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{\color{blue}{z1}} \]
                                                          4. Applied rewrites71.0%

                                                            \[\leadsto \color{blue}{1 + -1 \cdot \frac{-1 \cdot \frac{1.3333333333333333 \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                                          5. Step-by-step derivation
                                                            1. lift-*.f64N/A

                                                              \[\leadsto 1 + -1 \cdot \color{blue}{\frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                                            2. lift-/.f64N/A

                                                              \[\leadsto 1 + -1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{\color{blue}{z1}} \]
                                                            3. associate-*r/N/A

                                                              \[\leadsto 1 + \frac{-1 \cdot \left(-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)\right)}{\color{blue}{z1}} \]
                                                            4. mult-flipN/A

                                                              \[\leadsto 1 + \left(-1 \cdot \left(-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)\right)\right) \cdot \color{blue}{\frac{1}{z1}} \]
                                                          6. Applied rewrites57.8%

                                                            \[\leadsto 1 + \frac{\left(\left(2 \cdot \left(z0 - 1\right)\right) \cdot z1 - \left(2 \cdot \left(z0 - 1\right) - \frac{z0 - 1}{z1} \cdot 1.3333333333333333\right)\right) \cdot 1}{\color{blue}{z1 \cdot z1}} \]
                                                          7. Taylor expanded in z1 around inf

                                                            \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{\color{blue}{z1}} \]
                                                          8. Step-by-step derivation
                                                            1. lower-/.f64N/A

                                                              \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                                            2. lower-+.f64N/A

                                                              \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                                            3. lower-*.f64N/A

                                                              \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                                            4. lower-/.f64N/A

                                                              \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                                            5. lower--.f64N/A

                                                              \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                                            6. lower-*.f64N/A

                                                              \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                                            7. lower--.f6466.8%

                                                              \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                                          9. Applied rewrites66.8%

                                                            \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{\color{blue}{z1}} \]
                                                          10. Taylor expanded in z0 around 0

                                                            \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + -2}{z1} \]
                                                          11. Step-by-step derivation
                                                            1. Applied rewrites54.2%

                                                              \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + -2}{z1} \]
                                                          12. Recombined 4 regimes into one program.
                                                          13. Add Preprocessing

                                                          Alternative 15: 79.1% accurate, 1.4× speedup?

                                                          \[\begin{array}{l} \mathbf{if}\;\frac{-2}{z1} \leq -40000:\\ \;\;\;\;z0 - -1 \cdot 1\\ \mathbf{elif}\;\frac{-2}{z1} \leq 4 \cdot 10^{+96}:\\ \;\;\;\;1 + \frac{z0 \cdot \left(2 - 2 \cdot \frac{1}{z1}\right)}{z1}\\ \mathbf{elif}\;\frac{-2}{z1} \leq 10^{+150}:\\ \;\;\;\;1 + \frac{\frac{-1.3333333333333333}{z1} \cdot 1}{z1 \cdot z1}\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + -2}{z1}\\ \end{array} \]
                                                          (FPCore (z0 z1)
                                                            :precision binary64
                                                            (if (<= (/ -2.0 z1) -40000.0)
                                                            (- z0 (* -1.0 1.0))
                                                            (if (<= (/ -2.0 z1) 4e+96)
                                                              (+ 1.0 (/ (* z0 (- 2.0 (* 2.0 (/ 1.0 z1)))) z1))
                                                              (if (<= (/ -2.0 z1) 1e+150)
                                                                (+ 1.0 (/ (* (/ -1.3333333333333333 z1) 1.0) (* z1 z1)))
                                                                (+ 1.0 (/ (+ (* -2.0 (/ (- z0 1.0) z1)) -2.0) z1))))))
                                                          double code(double z0, double z1) {
                                                          	double tmp;
                                                          	if ((-2.0 / z1) <= -40000.0) {
                                                          		tmp = z0 - (-1.0 * 1.0);
                                                          	} else if ((-2.0 / z1) <= 4e+96) {
                                                          		tmp = 1.0 + ((z0 * (2.0 - (2.0 * (1.0 / z1)))) / z1);
                                                          	} else if ((-2.0 / z1) <= 1e+150) {
                                                          		tmp = 1.0 + (((-1.3333333333333333 / z1) * 1.0) / (z1 * z1));
                                                          	} else {
                                                          		tmp = 1.0 + (((-2.0 * ((z0 - 1.0) / z1)) + -2.0) / z1);
                                                          	}
                                                          	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(z0, z1)
                                                          use fmin_fmax_functions
                                                              real(8), intent (in) :: z0
                                                              real(8), intent (in) :: z1
                                                              real(8) :: tmp
                                                              if (((-2.0d0) / z1) <= (-40000.0d0)) then
                                                                  tmp = z0 - ((-1.0d0) * 1.0d0)
                                                              else if (((-2.0d0) / z1) <= 4d+96) then
                                                                  tmp = 1.0d0 + ((z0 * (2.0d0 - (2.0d0 * (1.0d0 / z1)))) / z1)
                                                              else if (((-2.0d0) / z1) <= 1d+150) then
                                                                  tmp = 1.0d0 + ((((-1.3333333333333333d0) / z1) * 1.0d0) / (z1 * z1))
                                                              else
                                                                  tmp = 1.0d0 + ((((-2.0d0) * ((z0 - 1.0d0) / z1)) + (-2.0d0)) / z1)
                                                              end if
                                                              code = tmp
                                                          end function
                                                          
                                                          public static double code(double z0, double z1) {
                                                          	double tmp;
                                                          	if ((-2.0 / z1) <= -40000.0) {
                                                          		tmp = z0 - (-1.0 * 1.0);
                                                          	} else if ((-2.0 / z1) <= 4e+96) {
                                                          		tmp = 1.0 + ((z0 * (2.0 - (2.0 * (1.0 / z1)))) / z1);
                                                          	} else if ((-2.0 / z1) <= 1e+150) {
                                                          		tmp = 1.0 + (((-1.3333333333333333 / z1) * 1.0) / (z1 * z1));
                                                          	} else {
                                                          		tmp = 1.0 + (((-2.0 * ((z0 - 1.0) / z1)) + -2.0) / z1);
                                                          	}
                                                          	return tmp;
                                                          }
                                                          
                                                          def code(z0, z1):
                                                          	tmp = 0
                                                          	if (-2.0 / z1) <= -40000.0:
                                                          		tmp = z0 - (-1.0 * 1.0)
                                                          	elif (-2.0 / z1) <= 4e+96:
                                                          		tmp = 1.0 + ((z0 * (2.0 - (2.0 * (1.0 / z1)))) / z1)
                                                          	elif (-2.0 / z1) <= 1e+150:
                                                          		tmp = 1.0 + (((-1.3333333333333333 / z1) * 1.0) / (z1 * z1))
                                                          	else:
                                                          		tmp = 1.0 + (((-2.0 * ((z0 - 1.0) / z1)) + -2.0) / z1)
                                                          	return tmp
                                                          
                                                          function code(z0, z1)
                                                          	tmp = 0.0
                                                          	if (Float64(-2.0 / z1) <= -40000.0)
                                                          		tmp = Float64(z0 - Float64(-1.0 * 1.0));
                                                          	elseif (Float64(-2.0 / z1) <= 4e+96)
                                                          		tmp = Float64(1.0 + Float64(Float64(z0 * Float64(2.0 - Float64(2.0 * Float64(1.0 / z1)))) / z1));
                                                          	elseif (Float64(-2.0 / z1) <= 1e+150)
                                                          		tmp = Float64(1.0 + Float64(Float64(Float64(-1.3333333333333333 / z1) * 1.0) / Float64(z1 * z1)));
                                                          	else
                                                          		tmp = Float64(1.0 + Float64(Float64(Float64(-2.0 * Float64(Float64(z0 - 1.0) / z1)) + -2.0) / z1));
                                                          	end
                                                          	return tmp
                                                          end
                                                          
                                                          function tmp_2 = code(z0, z1)
                                                          	tmp = 0.0;
                                                          	if ((-2.0 / z1) <= -40000.0)
                                                          		tmp = z0 - (-1.0 * 1.0);
                                                          	elseif ((-2.0 / z1) <= 4e+96)
                                                          		tmp = 1.0 + ((z0 * (2.0 - (2.0 * (1.0 / z1)))) / z1);
                                                          	elseif ((-2.0 / z1) <= 1e+150)
                                                          		tmp = 1.0 + (((-1.3333333333333333 / z1) * 1.0) / (z1 * z1));
                                                          	else
                                                          		tmp = 1.0 + (((-2.0 * ((z0 - 1.0) / z1)) + -2.0) / z1);
                                                          	end
                                                          	tmp_2 = tmp;
                                                          end
                                                          
                                                          code[z0_, z1_] := If[LessEqual[N[(-2.0 / z1), $MachinePrecision], -40000.0], N[(z0 - N[(-1.0 * 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(-2.0 / z1), $MachinePrecision], 4e+96], N[(1.0 + N[(N[(z0 * N[(2.0 - N[(2.0 * N[(1.0 / z1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z1), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(-2.0 / z1), $MachinePrecision], 1e+150], N[(1.0 + N[(N[(N[(-1.3333333333333333 / z1), $MachinePrecision] * 1.0), $MachinePrecision] / N[(z1 * z1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[(N[(-2.0 * N[(N[(z0 - 1.0), $MachinePrecision] / z1), $MachinePrecision]), $MachinePrecision] + -2.0), $MachinePrecision] / z1), $MachinePrecision]), $MachinePrecision]]]]
                                                          
                                                          \begin{array}{l}
                                                          \mathbf{if}\;\frac{-2}{z1} \leq -40000:\\
                                                          \;\;\;\;z0 - -1 \cdot 1\\
                                                          
                                                          \mathbf{elif}\;\frac{-2}{z1} \leq 4 \cdot 10^{+96}:\\
                                                          \;\;\;\;1 + \frac{z0 \cdot \left(2 - 2 \cdot \frac{1}{z1}\right)}{z1}\\
                                                          
                                                          \mathbf{elif}\;\frac{-2}{z1} \leq 10^{+150}:\\
                                                          \;\;\;\;1 + \frac{\frac{-1.3333333333333333}{z1} \cdot 1}{z1 \cdot z1}\\
                                                          
                                                          \mathbf{else}:\\
                                                          \;\;\;\;1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + -2}{z1}\\
                                                          
                                                          
                                                          \end{array}
                                                          
                                                          Derivation
                                                          1. Split input into 4 regimes
                                                          2. if (/.f64 #s(literal -2 binary64) z1) < -4e4

                                                            1. Initial program 76.8%

                                                              \[z0 - \left(z0 - 1\right) \cdot e^{\frac{-2}{z1}} \]
                                                            2. Taylor expanded in z1 around inf

                                                              \[\leadsto z0 - \left(z0 - 1\right) \cdot \color{blue}{1} \]
                                                            3. Step-by-step derivation
                                                              1. Applied rewrites27.8%

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

                                                                \[\leadsto z0 - \color{blue}{-1} \cdot 1 \]
                                                              3. Step-by-step derivation
                                                                1. Applied rewrites37.4%

                                                                  \[\leadsto z0 - \color{blue}{-1} \cdot 1 \]

                                                                if -4e4 < (/.f64 #s(literal -2 binary64) z1) < 4.0000000000000002e96

                                                                1. Initial program 76.8%

                                                                  \[z0 - \left(z0 - 1\right) \cdot e^{\frac{-2}{z1}} \]
                                                                2. Taylor expanded in z1 around -inf

                                                                  \[\leadsto \color{blue}{1 + -1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                                                3. Step-by-step derivation
                                                                  1. lower-+.f64N/A

                                                                    \[\leadsto 1 + \color{blue}{-1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                                                  2. lower-*.f64N/A

                                                                    \[\leadsto 1 + -1 \cdot \color{blue}{\frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                                                  3. lower-/.f64N/A

                                                                    \[\leadsto 1 + -1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{\color{blue}{z1}} \]
                                                                4. Applied rewrites71.0%

                                                                  \[\leadsto \color{blue}{1 + -1 \cdot \frac{-1 \cdot \frac{1.3333333333333333 \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                                                5. Step-by-step derivation
                                                                  1. lift-*.f64N/A

                                                                    \[\leadsto 1 + -1 \cdot \color{blue}{\frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                                                  2. lift-/.f64N/A

                                                                    \[\leadsto 1 + -1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{\color{blue}{z1}} \]
                                                                  3. associate-*r/N/A

                                                                    \[\leadsto 1 + \frac{-1 \cdot \left(-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)\right)}{\color{blue}{z1}} \]
                                                                  4. mult-flipN/A

                                                                    \[\leadsto 1 + \left(-1 \cdot \left(-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)\right)\right) \cdot \color{blue}{\frac{1}{z1}} \]
                                                                6. Applied rewrites57.8%

                                                                  \[\leadsto 1 + \frac{\left(\left(2 \cdot \left(z0 - 1\right)\right) \cdot z1 - \left(2 \cdot \left(z0 - 1\right) - \frac{z0 - 1}{z1} \cdot 1.3333333333333333\right)\right) \cdot 1}{\color{blue}{z1 \cdot z1}} \]
                                                                7. Taylor expanded in z1 around inf

                                                                  \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{\color{blue}{z1}} \]
                                                                8. Step-by-step derivation
                                                                  1. lower-/.f64N/A

                                                                    \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                                                  2. lower-+.f64N/A

                                                                    \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                                                  3. lower-*.f64N/A

                                                                    \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                                                  4. lower-/.f64N/A

                                                                    \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                                                  5. lower--.f64N/A

                                                                    \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                                                  6. lower-*.f64N/A

                                                                    \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                                                  7. lower--.f6466.8%

                                                                    \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                                                9. Applied rewrites66.8%

                                                                  \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{\color{blue}{z1}} \]
                                                                10. Taylor expanded in z0 around inf

                                                                  \[\leadsto 1 + \frac{z0 \cdot \left(2 - 2 \cdot \frac{1}{z1}\right)}{z1} \]
                                                                11. Step-by-step derivation
                                                                  1. lower-*.f64N/A

                                                                    \[\leadsto 1 + \frac{z0 \cdot \left(2 - 2 \cdot \frac{1}{z1}\right)}{z1} \]
                                                                  2. lower--.f64N/A

                                                                    \[\leadsto 1 + \frac{z0 \cdot \left(2 - 2 \cdot \frac{1}{z1}\right)}{z1} \]
                                                                  3. lower-*.f64N/A

                                                                    \[\leadsto 1 + \frac{z0 \cdot \left(2 - 2 \cdot \frac{1}{z1}\right)}{z1} \]
                                                                  4. lower-/.f6461.5%

                                                                    \[\leadsto 1 + \frac{z0 \cdot \left(2 - 2 \cdot \frac{1}{z1}\right)}{z1} \]
                                                                12. Applied rewrites61.5%

                                                                  \[\leadsto 1 + \frac{z0 \cdot \left(2 - 2 \cdot \frac{1}{z1}\right)}{z1} \]

                                                                if 4.0000000000000002e96 < (/.f64 #s(literal -2 binary64) z1) < 9.9999999999999998e149

                                                                1. Initial program 76.8%

                                                                  \[z0 - \left(z0 - 1\right) \cdot e^{\frac{-2}{z1}} \]
                                                                2. Taylor expanded in z1 around -inf

                                                                  \[\leadsto \color{blue}{1 + -1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                                                3. Step-by-step derivation
                                                                  1. lower-+.f64N/A

                                                                    \[\leadsto 1 + \color{blue}{-1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                                                  2. lower-*.f64N/A

                                                                    \[\leadsto 1 + -1 \cdot \color{blue}{\frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                                                  3. lower-/.f64N/A

                                                                    \[\leadsto 1 + -1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{\color{blue}{z1}} \]
                                                                4. Applied rewrites71.0%

                                                                  \[\leadsto \color{blue}{1 + -1 \cdot \frac{-1 \cdot \frac{1.3333333333333333 \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                                                5. Step-by-step derivation
                                                                  1. lift-*.f64N/A

                                                                    \[\leadsto 1 + -1 \cdot \color{blue}{\frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                                                  2. lift-/.f64N/A

                                                                    \[\leadsto 1 + -1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{\color{blue}{z1}} \]
                                                                  3. associate-*r/N/A

                                                                    \[\leadsto 1 + \frac{-1 \cdot \left(-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)\right)}{\color{blue}{z1}} \]
                                                                  4. mult-flipN/A

                                                                    \[\leadsto 1 + \left(-1 \cdot \left(-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)\right)\right) \cdot \color{blue}{\frac{1}{z1}} \]
                                                                6. Applied rewrites57.8%

                                                                  \[\leadsto 1 + \frac{\left(\left(2 \cdot \left(z0 - 1\right)\right) \cdot z1 - \left(2 \cdot \left(z0 - 1\right) - \frac{z0 - 1}{z1} \cdot 1.3333333333333333\right)\right) \cdot 1}{\color{blue}{z1 \cdot z1}} \]
                                                                7. Taylor expanded in z0 around 0

                                                                  \[\leadsto 1 + \frac{\left(\left(2 + -2 \cdot z1\right) - \frac{4}{3} \cdot \frac{1}{z1}\right) \cdot 1}{z1 \cdot z1} \]
                                                                8. Step-by-step derivation
                                                                  1. lower--.f64N/A

                                                                    \[\leadsto 1 + \frac{\left(\left(2 + -2 \cdot z1\right) - \frac{4}{3} \cdot \frac{1}{z1}\right) \cdot 1}{z1 \cdot z1} \]
                                                                  2. lower-+.f64N/A

                                                                    \[\leadsto 1 + \frac{\left(\left(2 + -2 \cdot z1\right) - \frac{4}{3} \cdot \frac{1}{z1}\right) \cdot 1}{z1 \cdot z1} \]
                                                                  3. lower-*.f64N/A

                                                                    \[\leadsto 1 + \frac{\left(\left(2 + -2 \cdot z1\right) - \frac{4}{3} \cdot \frac{1}{z1}\right) \cdot 1}{z1 \cdot z1} \]
                                                                  4. lower-*.f64N/A

                                                                    \[\leadsto 1 + \frac{\left(\left(2 + -2 \cdot z1\right) - \frac{4}{3} \cdot \frac{1}{z1}\right) \cdot 1}{z1 \cdot z1} \]
                                                                  5. lower-/.f6451.4%

                                                                    \[\leadsto 1 + \frac{\left(\left(2 + -2 \cdot z1\right) - 1.3333333333333333 \cdot \frac{1}{z1}\right) \cdot 1}{z1 \cdot z1} \]
                                                                9. Applied rewrites51.4%

                                                                  \[\leadsto 1 + \frac{\left(\left(2 + -2 \cdot z1\right) - 1.3333333333333333 \cdot \frac{1}{z1}\right) \cdot 1}{z1 \cdot z1} \]
                                                                10. Taylor expanded in z1 around 0

                                                                  \[\leadsto 1 + \frac{\frac{\frac{-4}{3}}{z1} \cdot 1}{z1 \cdot z1} \]
                                                                11. Step-by-step derivation
                                                                  1. lower-/.f6451.0%

                                                                    \[\leadsto 1 + \frac{\frac{-1.3333333333333333}{z1} \cdot 1}{z1 \cdot z1} \]
                                                                12. Applied rewrites51.0%

                                                                  \[\leadsto 1 + \frac{\frac{-1.3333333333333333}{z1} \cdot 1}{z1 \cdot z1} \]

                                                                if 9.9999999999999998e149 < (/.f64 #s(literal -2 binary64) z1)

                                                                1. Initial program 76.8%

                                                                  \[z0 - \left(z0 - 1\right) \cdot e^{\frac{-2}{z1}} \]
                                                                2. Taylor expanded in z1 around -inf

                                                                  \[\leadsto \color{blue}{1 + -1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                                                3. Step-by-step derivation
                                                                  1. lower-+.f64N/A

                                                                    \[\leadsto 1 + \color{blue}{-1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                                                  2. lower-*.f64N/A

                                                                    \[\leadsto 1 + -1 \cdot \color{blue}{\frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                                                  3. lower-/.f64N/A

                                                                    \[\leadsto 1 + -1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{\color{blue}{z1}} \]
                                                                4. Applied rewrites71.0%

                                                                  \[\leadsto \color{blue}{1 + -1 \cdot \frac{-1 \cdot \frac{1.3333333333333333 \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                                                5. Step-by-step derivation
                                                                  1. lift-*.f64N/A

                                                                    \[\leadsto 1 + -1 \cdot \color{blue}{\frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                                                  2. lift-/.f64N/A

                                                                    \[\leadsto 1 + -1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{\color{blue}{z1}} \]
                                                                  3. associate-*r/N/A

                                                                    \[\leadsto 1 + \frac{-1 \cdot \left(-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)\right)}{\color{blue}{z1}} \]
                                                                  4. mult-flipN/A

                                                                    \[\leadsto 1 + \left(-1 \cdot \left(-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)\right)\right) \cdot \color{blue}{\frac{1}{z1}} \]
                                                                6. Applied rewrites57.8%

                                                                  \[\leadsto 1 + \frac{\left(\left(2 \cdot \left(z0 - 1\right)\right) \cdot z1 - \left(2 \cdot \left(z0 - 1\right) - \frac{z0 - 1}{z1} \cdot 1.3333333333333333\right)\right) \cdot 1}{\color{blue}{z1 \cdot z1}} \]
                                                                7. Taylor expanded in z1 around inf

                                                                  \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{\color{blue}{z1}} \]
                                                                8. Step-by-step derivation
                                                                  1. lower-/.f64N/A

                                                                    \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                                                  2. lower-+.f64N/A

                                                                    \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                                                  3. lower-*.f64N/A

                                                                    \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                                                  4. lower-/.f64N/A

                                                                    \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                                                  5. lower--.f64N/A

                                                                    \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                                                  6. lower-*.f64N/A

                                                                    \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                                                  7. lower--.f6466.8%

                                                                    \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                                                9. Applied rewrites66.8%

                                                                  \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{\color{blue}{z1}} \]
                                                                10. Taylor expanded in z0 around 0

                                                                  \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + -2}{z1} \]
                                                                11. Step-by-step derivation
                                                                  1. Applied rewrites54.2%

                                                                    \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + -2}{z1} \]
                                                                12. Recombined 4 regimes into one program.
                                                                13. Add Preprocessing

                                                                Alternative 16: 77.7% accurate, 1.4× speedup?

                                                                \[\begin{array}{l} \mathbf{if}\;\frac{-2}{z1} \leq -20:\\ \;\;\;\;z0 - -1 \cdot 1\\ \mathbf{elif}\;\frac{-2}{z1} \leq 10^{+65}:\\ \;\;\;\;1 + 2 \cdot \frac{z0 - 1}{z1}\\ \mathbf{elif}\;\frac{-2}{z1} \leq 10^{+150}:\\ \;\;\;\;1 + \frac{\frac{-1.3333333333333333}{z1} \cdot 1}{z1 \cdot z1}\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{\left(z1 + z1\right) \cdot \left(z0 - 1\right)}{z1 \cdot z1}\\ \end{array} \]
                                                                (FPCore (z0 z1)
                                                                  :precision binary64
                                                                  (if (<= (/ -2.0 z1) -20.0)
                                                                  (- z0 (* -1.0 1.0))
                                                                  (if (<= (/ -2.0 z1) 1e+65)
                                                                    (+ 1.0 (* 2.0 (/ (- z0 1.0) z1)))
                                                                    (if (<= (/ -2.0 z1) 1e+150)
                                                                      (+ 1.0 (/ (* (/ -1.3333333333333333 z1) 1.0) (* z1 z1)))
                                                                      (+ 1.0 (/ (* (+ z1 z1) (- z0 1.0)) (* z1 z1)))))))
                                                                double code(double z0, double z1) {
                                                                	double tmp;
                                                                	if ((-2.0 / z1) <= -20.0) {
                                                                		tmp = z0 - (-1.0 * 1.0);
                                                                	} else if ((-2.0 / z1) <= 1e+65) {
                                                                		tmp = 1.0 + (2.0 * ((z0 - 1.0) / z1));
                                                                	} else if ((-2.0 / z1) <= 1e+150) {
                                                                		tmp = 1.0 + (((-1.3333333333333333 / z1) * 1.0) / (z1 * z1));
                                                                	} else {
                                                                		tmp = 1.0 + (((z1 + z1) * (z0 - 1.0)) / (z1 * z1));
                                                                	}
                                                                	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(z0, z1)
                                                                use fmin_fmax_functions
                                                                    real(8), intent (in) :: z0
                                                                    real(8), intent (in) :: z1
                                                                    real(8) :: tmp
                                                                    if (((-2.0d0) / z1) <= (-20.0d0)) then
                                                                        tmp = z0 - ((-1.0d0) * 1.0d0)
                                                                    else if (((-2.0d0) / z1) <= 1d+65) then
                                                                        tmp = 1.0d0 + (2.0d0 * ((z0 - 1.0d0) / z1))
                                                                    else if (((-2.0d0) / z1) <= 1d+150) then
                                                                        tmp = 1.0d0 + ((((-1.3333333333333333d0) / z1) * 1.0d0) / (z1 * z1))
                                                                    else
                                                                        tmp = 1.0d0 + (((z1 + z1) * (z0 - 1.0d0)) / (z1 * z1))
                                                                    end if
                                                                    code = tmp
                                                                end function
                                                                
                                                                public static double code(double z0, double z1) {
                                                                	double tmp;
                                                                	if ((-2.0 / z1) <= -20.0) {
                                                                		tmp = z0 - (-1.0 * 1.0);
                                                                	} else if ((-2.0 / z1) <= 1e+65) {
                                                                		tmp = 1.0 + (2.0 * ((z0 - 1.0) / z1));
                                                                	} else if ((-2.0 / z1) <= 1e+150) {
                                                                		tmp = 1.0 + (((-1.3333333333333333 / z1) * 1.0) / (z1 * z1));
                                                                	} else {
                                                                		tmp = 1.0 + (((z1 + z1) * (z0 - 1.0)) / (z1 * z1));
                                                                	}
                                                                	return tmp;
                                                                }
                                                                
                                                                def code(z0, z1):
                                                                	tmp = 0
                                                                	if (-2.0 / z1) <= -20.0:
                                                                		tmp = z0 - (-1.0 * 1.0)
                                                                	elif (-2.0 / z1) <= 1e+65:
                                                                		tmp = 1.0 + (2.0 * ((z0 - 1.0) / z1))
                                                                	elif (-2.0 / z1) <= 1e+150:
                                                                		tmp = 1.0 + (((-1.3333333333333333 / z1) * 1.0) / (z1 * z1))
                                                                	else:
                                                                		tmp = 1.0 + (((z1 + z1) * (z0 - 1.0)) / (z1 * z1))
                                                                	return tmp
                                                                
                                                                function code(z0, z1)
                                                                	tmp = 0.0
                                                                	if (Float64(-2.0 / z1) <= -20.0)
                                                                		tmp = Float64(z0 - Float64(-1.0 * 1.0));
                                                                	elseif (Float64(-2.0 / z1) <= 1e+65)
                                                                		tmp = Float64(1.0 + Float64(2.0 * Float64(Float64(z0 - 1.0) / z1)));
                                                                	elseif (Float64(-2.0 / z1) <= 1e+150)
                                                                		tmp = Float64(1.0 + Float64(Float64(Float64(-1.3333333333333333 / z1) * 1.0) / Float64(z1 * z1)));
                                                                	else
                                                                		tmp = Float64(1.0 + Float64(Float64(Float64(z1 + z1) * Float64(z0 - 1.0)) / Float64(z1 * z1)));
                                                                	end
                                                                	return tmp
                                                                end
                                                                
                                                                function tmp_2 = code(z0, z1)
                                                                	tmp = 0.0;
                                                                	if ((-2.0 / z1) <= -20.0)
                                                                		tmp = z0 - (-1.0 * 1.0);
                                                                	elseif ((-2.0 / z1) <= 1e+65)
                                                                		tmp = 1.0 + (2.0 * ((z0 - 1.0) / z1));
                                                                	elseif ((-2.0 / z1) <= 1e+150)
                                                                		tmp = 1.0 + (((-1.3333333333333333 / z1) * 1.0) / (z1 * z1));
                                                                	else
                                                                		tmp = 1.0 + (((z1 + z1) * (z0 - 1.0)) / (z1 * z1));
                                                                	end
                                                                	tmp_2 = tmp;
                                                                end
                                                                
                                                                code[z0_, z1_] := If[LessEqual[N[(-2.0 / z1), $MachinePrecision], -20.0], N[(z0 - N[(-1.0 * 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(-2.0 / z1), $MachinePrecision], 1e+65], N[(1.0 + N[(2.0 * N[(N[(z0 - 1.0), $MachinePrecision] / z1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(-2.0 / z1), $MachinePrecision], 1e+150], N[(1.0 + N[(N[(N[(-1.3333333333333333 / z1), $MachinePrecision] * 1.0), $MachinePrecision] / N[(z1 * z1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[(N[(z1 + z1), $MachinePrecision] * N[(z0 - 1.0), $MachinePrecision]), $MachinePrecision] / N[(z1 * z1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
                                                                
                                                                \begin{array}{l}
                                                                \mathbf{if}\;\frac{-2}{z1} \leq -20:\\
                                                                \;\;\;\;z0 - -1 \cdot 1\\
                                                                
                                                                \mathbf{elif}\;\frac{-2}{z1} \leq 10^{+65}:\\
                                                                \;\;\;\;1 + 2 \cdot \frac{z0 - 1}{z1}\\
                                                                
                                                                \mathbf{elif}\;\frac{-2}{z1} \leq 10^{+150}:\\
                                                                \;\;\;\;1 + \frac{\frac{-1.3333333333333333}{z1} \cdot 1}{z1 \cdot z1}\\
                                                                
                                                                \mathbf{else}:\\
                                                                \;\;\;\;1 + \frac{\left(z1 + z1\right) \cdot \left(z0 - 1\right)}{z1 \cdot z1}\\
                                                                
                                                                
                                                                \end{array}
                                                                
                                                                Derivation
                                                                1. Split input into 4 regimes
                                                                2. if (/.f64 #s(literal -2 binary64) z1) < -20

                                                                  1. Initial program 76.8%

                                                                    \[z0 - \left(z0 - 1\right) \cdot e^{\frac{-2}{z1}} \]
                                                                  2. Taylor expanded in z1 around inf

                                                                    \[\leadsto z0 - \left(z0 - 1\right) \cdot \color{blue}{1} \]
                                                                  3. Step-by-step derivation
                                                                    1. Applied rewrites27.8%

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

                                                                      \[\leadsto z0 - \color{blue}{-1} \cdot 1 \]
                                                                    3. Step-by-step derivation
                                                                      1. Applied rewrites37.4%

                                                                        \[\leadsto z0 - \color{blue}{-1} \cdot 1 \]

                                                                      if -20 < (/.f64 #s(literal -2 binary64) z1) < 9.9999999999999999e64

                                                                      1. Initial program 76.8%

                                                                        \[z0 - \left(z0 - 1\right) \cdot e^{\frac{-2}{z1}} \]
                                                                      2. Taylor expanded in z1 around inf

                                                                        \[\leadsto \color{blue}{1 + 2 \cdot \frac{z0 - 1}{z1}} \]
                                                                      3. Step-by-step derivation
                                                                        1. lower-+.f64N/A

                                                                          \[\leadsto 1 + \color{blue}{2 \cdot \frac{z0 - 1}{z1}} \]
                                                                        2. lower-*.f64N/A

                                                                          \[\leadsto 1 + 2 \cdot \color{blue}{\frac{z0 - 1}{z1}} \]
                                                                        3. lower-/.f64N/A

                                                                          \[\leadsto 1 + 2 \cdot \frac{z0 - 1}{\color{blue}{z1}} \]
                                                                        4. lower--.f6458.5%

                                                                          \[\leadsto 1 + 2 \cdot \frac{z0 - 1}{z1} \]
                                                                      4. Applied rewrites58.5%

                                                                        \[\leadsto \color{blue}{1 + 2 \cdot \frac{z0 - 1}{z1}} \]

                                                                      if 9.9999999999999999e64 < (/.f64 #s(literal -2 binary64) z1) < 9.9999999999999998e149

                                                                      1. Initial program 76.8%

                                                                        \[z0 - \left(z0 - 1\right) \cdot e^{\frac{-2}{z1}} \]
                                                                      2. Taylor expanded in z1 around -inf

                                                                        \[\leadsto \color{blue}{1 + -1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                                                      3. Step-by-step derivation
                                                                        1. lower-+.f64N/A

                                                                          \[\leadsto 1 + \color{blue}{-1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                                                        2. lower-*.f64N/A

                                                                          \[\leadsto 1 + -1 \cdot \color{blue}{\frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                                                        3. lower-/.f64N/A

                                                                          \[\leadsto 1 + -1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{\color{blue}{z1}} \]
                                                                      4. Applied rewrites71.0%

                                                                        \[\leadsto \color{blue}{1 + -1 \cdot \frac{-1 \cdot \frac{1.3333333333333333 \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                                                      5. Step-by-step derivation
                                                                        1. lift-*.f64N/A

                                                                          \[\leadsto 1 + -1 \cdot \color{blue}{\frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                                                        2. lift-/.f64N/A

                                                                          \[\leadsto 1 + -1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{\color{blue}{z1}} \]
                                                                        3. associate-*r/N/A

                                                                          \[\leadsto 1 + \frac{-1 \cdot \left(-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)\right)}{\color{blue}{z1}} \]
                                                                        4. mult-flipN/A

                                                                          \[\leadsto 1 + \left(-1 \cdot \left(-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)\right)\right) \cdot \color{blue}{\frac{1}{z1}} \]
                                                                      6. Applied rewrites57.8%

                                                                        \[\leadsto 1 + \frac{\left(\left(2 \cdot \left(z0 - 1\right)\right) \cdot z1 - \left(2 \cdot \left(z0 - 1\right) - \frac{z0 - 1}{z1} \cdot 1.3333333333333333\right)\right) \cdot 1}{\color{blue}{z1 \cdot z1}} \]
                                                                      7. Taylor expanded in z0 around 0

                                                                        \[\leadsto 1 + \frac{\left(\left(2 + -2 \cdot z1\right) - \frac{4}{3} \cdot \frac{1}{z1}\right) \cdot 1}{z1 \cdot z1} \]
                                                                      8. Step-by-step derivation
                                                                        1. lower--.f64N/A

                                                                          \[\leadsto 1 + \frac{\left(\left(2 + -2 \cdot z1\right) - \frac{4}{3} \cdot \frac{1}{z1}\right) \cdot 1}{z1 \cdot z1} \]
                                                                        2. lower-+.f64N/A

                                                                          \[\leadsto 1 + \frac{\left(\left(2 + -2 \cdot z1\right) - \frac{4}{3} \cdot \frac{1}{z1}\right) \cdot 1}{z1 \cdot z1} \]
                                                                        3. lower-*.f64N/A

                                                                          \[\leadsto 1 + \frac{\left(\left(2 + -2 \cdot z1\right) - \frac{4}{3} \cdot \frac{1}{z1}\right) \cdot 1}{z1 \cdot z1} \]
                                                                        4. lower-*.f64N/A

                                                                          \[\leadsto 1 + \frac{\left(\left(2 + -2 \cdot z1\right) - \frac{4}{3} \cdot \frac{1}{z1}\right) \cdot 1}{z1 \cdot z1} \]
                                                                        5. lower-/.f6451.4%

                                                                          \[\leadsto 1 + \frac{\left(\left(2 + -2 \cdot z1\right) - 1.3333333333333333 \cdot \frac{1}{z1}\right) \cdot 1}{z1 \cdot z1} \]
                                                                      9. Applied rewrites51.4%

                                                                        \[\leadsto 1 + \frac{\left(\left(2 + -2 \cdot z1\right) - 1.3333333333333333 \cdot \frac{1}{z1}\right) \cdot 1}{z1 \cdot z1} \]
                                                                      10. Taylor expanded in z1 around 0

                                                                        \[\leadsto 1 + \frac{\frac{\frac{-4}{3}}{z1} \cdot 1}{z1 \cdot z1} \]
                                                                      11. Step-by-step derivation
                                                                        1. lower-/.f6451.0%

                                                                          \[\leadsto 1 + \frac{\frac{-1.3333333333333333}{z1} \cdot 1}{z1 \cdot z1} \]
                                                                      12. Applied rewrites51.0%

                                                                        \[\leadsto 1 + \frac{\frac{-1.3333333333333333}{z1} \cdot 1}{z1 \cdot z1} \]

                                                                      if 9.9999999999999998e149 < (/.f64 #s(literal -2 binary64) z1)

                                                                      1. Initial program 76.8%

                                                                        \[z0 - \left(z0 - 1\right) \cdot e^{\frac{-2}{z1}} \]
                                                                      2. Step-by-step derivation
                                                                        1. lift-exp.f64N/A

                                                                          \[\leadsto z0 - \left(z0 - 1\right) \cdot \color{blue}{e^{\frac{-2}{z1}}} \]
                                                                        2. lift-/.f64N/A

                                                                          \[\leadsto z0 - \left(z0 - 1\right) \cdot e^{\color{blue}{\frac{-2}{z1}}} \]
                                                                        3. frac-2negN/A

                                                                          \[\leadsto z0 - \left(z0 - 1\right) \cdot e^{\color{blue}{\frac{\mathsf{neg}\left(-2\right)}{\mathsf{neg}\left(z1\right)}}} \]
                                                                        4. mult-flipN/A

                                                                          \[\leadsto z0 - \left(z0 - 1\right) \cdot e^{\color{blue}{\left(\mathsf{neg}\left(-2\right)\right) \cdot \frac{1}{\mathsf{neg}\left(z1\right)}}} \]
                                                                        5. exp-prodN/A

                                                                          \[\leadsto z0 - \left(z0 - 1\right) \cdot \color{blue}{{\left(e^{\mathsf{neg}\left(-2\right)}\right)}^{\left(\frac{1}{\mathsf{neg}\left(z1\right)}\right)}} \]
                                                                        6. lower-pow.f64N/A

                                                                          \[\leadsto z0 - \left(z0 - 1\right) \cdot \color{blue}{{\left(e^{\mathsf{neg}\left(-2\right)}\right)}^{\left(\frac{1}{\mathsf{neg}\left(z1\right)}\right)}} \]
                                                                        7. lower-exp.f64N/A

                                                                          \[\leadsto z0 - \left(z0 - 1\right) \cdot {\color{blue}{\left(e^{\mathsf{neg}\left(-2\right)}\right)}}^{\left(\frac{1}{\mathsf{neg}\left(z1\right)}\right)} \]
                                                                        8. metadata-evalN/A

                                                                          \[\leadsto z0 - \left(z0 - 1\right) \cdot {\left(e^{\color{blue}{2}}\right)}^{\left(\frac{1}{\mathsf{neg}\left(z1\right)}\right)} \]
                                                                        9. frac-2negN/A

                                                                          \[\leadsto z0 - \left(z0 - 1\right) \cdot {\left(e^{2}\right)}^{\color{blue}{\left(\frac{\mathsf{neg}\left(1\right)}{\mathsf{neg}\left(\left(\mathsf{neg}\left(z1\right)\right)\right)}\right)}} \]
                                                                        10. remove-double-negN/A

                                                                          \[\leadsto z0 - \left(z0 - 1\right) \cdot {\left(e^{2}\right)}^{\left(\frac{\mathsf{neg}\left(1\right)}{\color{blue}{z1}}\right)} \]
                                                                        11. lower-/.f64N/A

                                                                          \[\leadsto z0 - \left(z0 - 1\right) \cdot {\left(e^{2}\right)}^{\color{blue}{\left(\frac{\mathsf{neg}\left(1\right)}{z1}\right)}} \]
                                                                        12. metadata-eval76.8%

                                                                          \[\leadsto z0 - \left(z0 - 1\right) \cdot {\left(e^{2}\right)}^{\left(\frac{\color{blue}{-1}}{z1}\right)} \]
                                                                      3. Applied rewrites76.8%

                                                                        \[\leadsto z0 - \left(z0 - 1\right) \cdot \color{blue}{{\left(e^{2}\right)}^{\left(\frac{-1}{z1}\right)}} \]
                                                                      4. Taylor expanded in z1 around inf

                                                                        \[\leadsto \color{blue}{1 + 2 \cdot \frac{z0 - 1}{z1}} \]
                                                                      5. Step-by-step derivation
                                                                        1. lower-+.f64N/A

                                                                          \[\leadsto 1 + \color{blue}{2 \cdot \frac{z0 - 1}{z1}} \]
                                                                        2. lower-*.f64N/A

                                                                          \[\leadsto 1 + 2 \cdot \color{blue}{\frac{z0 - 1}{z1}} \]
                                                                        3. lower-/.f64N/A

                                                                          \[\leadsto 1 + 2 \cdot \frac{z0 - 1}{\color{blue}{z1}} \]
                                                                        4. lower--.f6458.5%

                                                                          \[\leadsto 1 + 2 \cdot \frac{z0 - 1}{z1} \]
                                                                      6. Applied rewrites58.5%

                                                                        \[\leadsto \color{blue}{1 + 2 \cdot \frac{z0 - 1}{z1}} \]
                                                                      7. Step-by-step derivation
                                                                        1. lift-*.f64N/A

                                                                          \[\leadsto 1 + 2 \cdot \color{blue}{\frac{z0 - 1}{z1}} \]
                                                                        2. count-2-revN/A

                                                                          \[\leadsto 1 + \left(\frac{z0 - 1}{z1} + \color{blue}{\frac{z0 - 1}{z1}}\right) \]
                                                                        3. lift-/.f64N/A

                                                                          \[\leadsto 1 + \left(\frac{z0 - 1}{z1} + \frac{\color{blue}{z0 - 1}}{z1}\right) \]
                                                                        4. lift-/.f64N/A

                                                                          \[\leadsto 1 + \left(\frac{z0 - 1}{z1} + \frac{z0 - 1}{\color{blue}{z1}}\right) \]
                                                                        5. common-denominatorN/A

                                                                          \[\leadsto 1 + \frac{\left(z0 - 1\right) \cdot z1 + \left(z0 - 1\right) \cdot z1}{\color{blue}{z1 \cdot z1}} \]
                                                                        6. count-2-revN/A

                                                                          \[\leadsto 1 + \frac{2 \cdot \left(\left(z0 - 1\right) \cdot z1\right)}{\color{blue}{z1} \cdot z1} \]
                                                                        7. associate-*l*N/A

                                                                          \[\leadsto 1 + \frac{\left(2 \cdot \left(z0 - 1\right)\right) \cdot z1}{\color{blue}{z1} \cdot z1} \]
                                                                        8. lift--.f64N/A

                                                                          \[\leadsto 1 + \frac{\left(2 \cdot \left(z0 - 1\right)\right) \cdot z1}{z1 \cdot z1} \]
                                                                        9. lift-*.f64N/A

                                                                          \[\leadsto 1 + \frac{\left(2 \cdot \left(z0 - 1\right)\right) \cdot z1}{z1 \cdot \color{blue}{z1}} \]
                                                                        10. lower-/.f64N/A

                                                                          \[\leadsto 1 + \frac{\left(2 \cdot \left(z0 - 1\right)\right) \cdot z1}{\color{blue}{z1 \cdot z1}} \]
                                                                        11. lift--.f64N/A

                                                                          \[\leadsto 1 + \frac{\left(2 \cdot \left(z0 - 1\right)\right) \cdot z1}{z1 \cdot z1} \]
                                                                        12. lift-*.f64N/A

                                                                          \[\leadsto 1 + \frac{\left(2 \cdot \left(z0 - 1\right)\right) \cdot z1}{z1 \cdot z1} \]
                                                                        13. *-commutativeN/A

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

                                                                          \[\leadsto 1 + \frac{z1 \cdot \left(2 \cdot \left(z0 - 1\right)\right)}{z1 \cdot z1} \]
                                                                        15. associate-*r*N/A

                                                                          \[\leadsto 1 + \frac{\left(z1 \cdot 2\right) \cdot \left(z0 - 1\right)}{\color{blue}{z1} \cdot z1} \]
                                                                        16. *-commutativeN/A

                                                                          \[\leadsto 1 + \frac{\left(2 \cdot z1\right) \cdot \left(z0 - 1\right)}{z1 \cdot z1} \]
                                                                        17. count-2N/A

                                                                          \[\leadsto 1 + \frac{\left(z1 + z1\right) \cdot \left(z0 - 1\right)}{z1 \cdot z1} \]
                                                                        18. lift-+.f64N/A

                                                                          \[\leadsto 1 + \frac{\left(z1 + z1\right) \cdot \left(z0 - 1\right)}{z1 \cdot z1} \]
                                                                        19. lower-*.f6452.1%

                                                                          \[\leadsto 1 + \frac{\left(z1 + z1\right) \cdot \left(z0 - 1\right)}{\color{blue}{z1} \cdot z1} \]
                                                                      8. Applied rewrites52.1%

                                                                        \[\leadsto 1 + \frac{\left(z1 + z1\right) \cdot \left(z0 - 1\right)}{\color{blue}{z1 \cdot z1}} \]
                                                                    4. Recombined 4 regimes into one program.
                                                                    5. Add Preprocessing

                                                                    Alternative 17: 76.0% accurate, 0.5× speedup?

                                                                    \[\begin{array}{l} t_0 := e^{\frac{-2}{z1}}\\ \mathbf{if}\;t\_0 \leq 0:\\ \;\;\;\;z0 - -1 \cdot 1\\ \mathbf{elif}\;t\_0 \leq 1:\\ \;\;\;\;1 + 2 \cdot \frac{z0}{z1}\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{\left(z1 + z1\right) \cdot \left(z0 - 1\right)}{z1 \cdot z1}\\ \end{array} \]
                                                                    (FPCore (z0 z1)
                                                                      :precision binary64
                                                                      (let* ((t_0 (exp (/ -2.0 z1))))
                                                                      (if (<= t_0 0.0)
                                                                        (- z0 (* -1.0 1.0))
                                                                        (if (<= t_0 1.0)
                                                                          (+ 1.0 (* 2.0 (/ z0 z1)))
                                                                          (+ 1.0 (/ (* (+ z1 z1) (- z0 1.0)) (* z1 z1)))))))
                                                                    double code(double z0, double z1) {
                                                                    	double t_0 = exp((-2.0 / z1));
                                                                    	double tmp;
                                                                    	if (t_0 <= 0.0) {
                                                                    		tmp = z0 - (-1.0 * 1.0);
                                                                    	} else if (t_0 <= 1.0) {
                                                                    		tmp = 1.0 + (2.0 * (z0 / z1));
                                                                    	} else {
                                                                    		tmp = 1.0 + (((z1 + z1) * (z0 - 1.0)) / (z1 * z1));
                                                                    	}
                                                                    	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(z0, z1)
                                                                    use fmin_fmax_functions
                                                                        real(8), intent (in) :: z0
                                                                        real(8), intent (in) :: z1
                                                                        real(8) :: t_0
                                                                        real(8) :: tmp
                                                                        t_0 = exp(((-2.0d0) / z1))
                                                                        if (t_0 <= 0.0d0) then
                                                                            tmp = z0 - ((-1.0d0) * 1.0d0)
                                                                        else if (t_0 <= 1.0d0) then
                                                                            tmp = 1.0d0 + (2.0d0 * (z0 / z1))
                                                                        else
                                                                            tmp = 1.0d0 + (((z1 + z1) * (z0 - 1.0d0)) / (z1 * z1))
                                                                        end if
                                                                        code = tmp
                                                                    end function
                                                                    
                                                                    public static double code(double z0, double z1) {
                                                                    	double t_0 = Math.exp((-2.0 / z1));
                                                                    	double tmp;
                                                                    	if (t_0 <= 0.0) {
                                                                    		tmp = z0 - (-1.0 * 1.0);
                                                                    	} else if (t_0 <= 1.0) {
                                                                    		tmp = 1.0 + (2.0 * (z0 / z1));
                                                                    	} else {
                                                                    		tmp = 1.0 + (((z1 + z1) * (z0 - 1.0)) / (z1 * z1));
                                                                    	}
                                                                    	return tmp;
                                                                    }
                                                                    
                                                                    def code(z0, z1):
                                                                    	t_0 = math.exp((-2.0 / z1))
                                                                    	tmp = 0
                                                                    	if t_0 <= 0.0:
                                                                    		tmp = z0 - (-1.0 * 1.0)
                                                                    	elif t_0 <= 1.0:
                                                                    		tmp = 1.0 + (2.0 * (z0 / z1))
                                                                    	else:
                                                                    		tmp = 1.0 + (((z1 + z1) * (z0 - 1.0)) / (z1 * z1))
                                                                    	return tmp
                                                                    
                                                                    function code(z0, z1)
                                                                    	t_0 = exp(Float64(-2.0 / z1))
                                                                    	tmp = 0.0
                                                                    	if (t_0 <= 0.0)
                                                                    		tmp = Float64(z0 - Float64(-1.0 * 1.0));
                                                                    	elseif (t_0 <= 1.0)
                                                                    		tmp = Float64(1.0 + Float64(2.0 * Float64(z0 / z1)));
                                                                    	else
                                                                    		tmp = Float64(1.0 + Float64(Float64(Float64(z1 + z1) * Float64(z0 - 1.0)) / Float64(z1 * z1)));
                                                                    	end
                                                                    	return tmp
                                                                    end
                                                                    
                                                                    function tmp_2 = code(z0, z1)
                                                                    	t_0 = exp((-2.0 / z1));
                                                                    	tmp = 0.0;
                                                                    	if (t_0 <= 0.0)
                                                                    		tmp = z0 - (-1.0 * 1.0);
                                                                    	elseif (t_0 <= 1.0)
                                                                    		tmp = 1.0 + (2.0 * (z0 / z1));
                                                                    	else
                                                                    		tmp = 1.0 + (((z1 + z1) * (z0 - 1.0)) / (z1 * z1));
                                                                    	end
                                                                    	tmp_2 = tmp;
                                                                    end
                                                                    
                                                                    code[z0_, z1_] := Block[{t$95$0 = N[Exp[N[(-2.0 / z1), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$0, 0.0], N[(z0 - N[(-1.0 * 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1.0], N[(1.0 + N[(2.0 * N[(z0 / z1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[(N[(z1 + z1), $MachinePrecision] * N[(z0 - 1.0), $MachinePrecision]), $MachinePrecision] / N[(z1 * z1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
                                                                    
                                                                    \begin{array}{l}
                                                                    t_0 := e^{\frac{-2}{z1}}\\
                                                                    \mathbf{if}\;t\_0 \leq 0:\\
                                                                    \;\;\;\;z0 - -1 \cdot 1\\
                                                                    
                                                                    \mathbf{elif}\;t\_0 \leq 1:\\
                                                                    \;\;\;\;1 + 2 \cdot \frac{z0}{z1}\\
                                                                    
                                                                    \mathbf{else}:\\
                                                                    \;\;\;\;1 + \frac{\left(z1 + z1\right) \cdot \left(z0 - 1\right)}{z1 \cdot z1}\\
                                                                    
                                                                    
                                                                    \end{array}
                                                                    
                                                                    Derivation
                                                                    1. Split input into 3 regimes
                                                                    2. if (exp.f64 (/.f64 #s(literal -2 binary64) z1)) < 0.0

                                                                      1. Initial program 76.8%

                                                                        \[z0 - \left(z0 - 1\right) \cdot e^{\frac{-2}{z1}} \]
                                                                      2. Taylor expanded in z1 around inf

                                                                        \[\leadsto z0 - \left(z0 - 1\right) \cdot \color{blue}{1} \]
                                                                      3. Step-by-step derivation
                                                                        1. Applied rewrites27.8%

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

                                                                          \[\leadsto z0 - \color{blue}{-1} \cdot 1 \]
                                                                        3. Step-by-step derivation
                                                                          1. Applied rewrites37.4%

                                                                            \[\leadsto z0 - \color{blue}{-1} \cdot 1 \]

                                                                          if 0.0 < (exp.f64 (/.f64 #s(literal -2 binary64) z1)) < 1

                                                                          1. Initial program 76.8%

                                                                            \[z0 - \left(z0 - 1\right) \cdot e^{\frac{-2}{z1}} \]
                                                                          2. Step-by-step derivation
                                                                            1. lift-exp.f64N/A

                                                                              \[\leadsto z0 - \left(z0 - 1\right) \cdot \color{blue}{e^{\frac{-2}{z1}}} \]
                                                                            2. lift-/.f64N/A

                                                                              \[\leadsto z0 - \left(z0 - 1\right) \cdot e^{\color{blue}{\frac{-2}{z1}}} \]
                                                                            3. frac-2negN/A

                                                                              \[\leadsto z0 - \left(z0 - 1\right) \cdot e^{\color{blue}{\frac{\mathsf{neg}\left(-2\right)}{\mathsf{neg}\left(z1\right)}}} \]
                                                                            4. mult-flipN/A

                                                                              \[\leadsto z0 - \left(z0 - 1\right) \cdot e^{\color{blue}{\left(\mathsf{neg}\left(-2\right)\right) \cdot \frac{1}{\mathsf{neg}\left(z1\right)}}} \]
                                                                            5. exp-prodN/A

                                                                              \[\leadsto z0 - \left(z0 - 1\right) \cdot \color{blue}{{\left(e^{\mathsf{neg}\left(-2\right)}\right)}^{\left(\frac{1}{\mathsf{neg}\left(z1\right)}\right)}} \]
                                                                            6. lower-pow.f64N/A

                                                                              \[\leadsto z0 - \left(z0 - 1\right) \cdot \color{blue}{{\left(e^{\mathsf{neg}\left(-2\right)}\right)}^{\left(\frac{1}{\mathsf{neg}\left(z1\right)}\right)}} \]
                                                                            7. lower-exp.f64N/A

                                                                              \[\leadsto z0 - \left(z0 - 1\right) \cdot {\color{blue}{\left(e^{\mathsf{neg}\left(-2\right)}\right)}}^{\left(\frac{1}{\mathsf{neg}\left(z1\right)}\right)} \]
                                                                            8. metadata-evalN/A

                                                                              \[\leadsto z0 - \left(z0 - 1\right) \cdot {\left(e^{\color{blue}{2}}\right)}^{\left(\frac{1}{\mathsf{neg}\left(z1\right)}\right)} \]
                                                                            9. frac-2negN/A

                                                                              \[\leadsto z0 - \left(z0 - 1\right) \cdot {\left(e^{2}\right)}^{\color{blue}{\left(\frac{\mathsf{neg}\left(1\right)}{\mathsf{neg}\left(\left(\mathsf{neg}\left(z1\right)\right)\right)}\right)}} \]
                                                                            10. remove-double-negN/A

                                                                              \[\leadsto z0 - \left(z0 - 1\right) \cdot {\left(e^{2}\right)}^{\left(\frac{\mathsf{neg}\left(1\right)}{\color{blue}{z1}}\right)} \]
                                                                            11. lower-/.f64N/A

                                                                              \[\leadsto z0 - \left(z0 - 1\right) \cdot {\left(e^{2}\right)}^{\color{blue}{\left(\frac{\mathsf{neg}\left(1\right)}{z1}\right)}} \]
                                                                            12. metadata-eval76.8%

                                                                              \[\leadsto z0 - \left(z0 - 1\right) \cdot {\left(e^{2}\right)}^{\left(\frac{\color{blue}{-1}}{z1}\right)} \]
                                                                          3. Applied rewrites76.8%

                                                                            \[\leadsto z0 - \left(z0 - 1\right) \cdot \color{blue}{{\left(e^{2}\right)}^{\left(\frac{-1}{z1}\right)}} \]
                                                                          4. Taylor expanded in z1 around inf

                                                                            \[\leadsto \color{blue}{1 + 2 \cdot \frac{z0 - 1}{z1}} \]
                                                                          5. Step-by-step derivation
                                                                            1. lower-+.f64N/A

                                                                              \[\leadsto 1 + \color{blue}{2 \cdot \frac{z0 - 1}{z1}} \]
                                                                            2. lower-*.f64N/A

                                                                              \[\leadsto 1 + 2 \cdot \color{blue}{\frac{z0 - 1}{z1}} \]
                                                                            3. lower-/.f64N/A

                                                                              \[\leadsto 1 + 2 \cdot \frac{z0 - 1}{\color{blue}{z1}} \]
                                                                            4. lower--.f6458.5%

                                                                              \[\leadsto 1 + 2 \cdot \frac{z0 - 1}{z1} \]
                                                                          6. Applied rewrites58.5%

                                                                            \[\leadsto \color{blue}{1 + 2 \cdot \frac{z0 - 1}{z1}} \]
                                                                          7. Taylor expanded in z0 around inf

                                                                            \[\leadsto 1 + 2 \cdot \frac{z0}{\color{blue}{z1}} \]
                                                                          8. Step-by-step derivation
                                                                            1. lower-/.f6458.0%

                                                                              \[\leadsto 1 + 2 \cdot \frac{z0}{z1} \]
                                                                          9. Applied rewrites58.0%

                                                                            \[\leadsto 1 + 2 \cdot \frac{z0}{\color{blue}{z1}} \]

                                                                          if 1 < (exp.f64 (/.f64 #s(literal -2 binary64) z1))

                                                                          1. Initial program 76.8%

                                                                            \[z0 - \left(z0 - 1\right) \cdot e^{\frac{-2}{z1}} \]
                                                                          2. Step-by-step derivation
                                                                            1. lift-exp.f64N/A

                                                                              \[\leadsto z0 - \left(z0 - 1\right) \cdot \color{blue}{e^{\frac{-2}{z1}}} \]
                                                                            2. lift-/.f64N/A

                                                                              \[\leadsto z0 - \left(z0 - 1\right) \cdot e^{\color{blue}{\frac{-2}{z1}}} \]
                                                                            3. frac-2negN/A

                                                                              \[\leadsto z0 - \left(z0 - 1\right) \cdot e^{\color{blue}{\frac{\mathsf{neg}\left(-2\right)}{\mathsf{neg}\left(z1\right)}}} \]
                                                                            4. mult-flipN/A

                                                                              \[\leadsto z0 - \left(z0 - 1\right) \cdot e^{\color{blue}{\left(\mathsf{neg}\left(-2\right)\right) \cdot \frac{1}{\mathsf{neg}\left(z1\right)}}} \]
                                                                            5. exp-prodN/A

                                                                              \[\leadsto z0 - \left(z0 - 1\right) \cdot \color{blue}{{\left(e^{\mathsf{neg}\left(-2\right)}\right)}^{\left(\frac{1}{\mathsf{neg}\left(z1\right)}\right)}} \]
                                                                            6. lower-pow.f64N/A

                                                                              \[\leadsto z0 - \left(z0 - 1\right) \cdot \color{blue}{{\left(e^{\mathsf{neg}\left(-2\right)}\right)}^{\left(\frac{1}{\mathsf{neg}\left(z1\right)}\right)}} \]
                                                                            7. lower-exp.f64N/A

                                                                              \[\leadsto z0 - \left(z0 - 1\right) \cdot {\color{blue}{\left(e^{\mathsf{neg}\left(-2\right)}\right)}}^{\left(\frac{1}{\mathsf{neg}\left(z1\right)}\right)} \]
                                                                            8. metadata-evalN/A

                                                                              \[\leadsto z0 - \left(z0 - 1\right) \cdot {\left(e^{\color{blue}{2}}\right)}^{\left(\frac{1}{\mathsf{neg}\left(z1\right)}\right)} \]
                                                                            9. frac-2negN/A

                                                                              \[\leadsto z0 - \left(z0 - 1\right) \cdot {\left(e^{2}\right)}^{\color{blue}{\left(\frac{\mathsf{neg}\left(1\right)}{\mathsf{neg}\left(\left(\mathsf{neg}\left(z1\right)\right)\right)}\right)}} \]
                                                                            10. remove-double-negN/A

                                                                              \[\leadsto z0 - \left(z0 - 1\right) \cdot {\left(e^{2}\right)}^{\left(\frac{\mathsf{neg}\left(1\right)}{\color{blue}{z1}}\right)} \]
                                                                            11. lower-/.f64N/A

                                                                              \[\leadsto z0 - \left(z0 - 1\right) \cdot {\left(e^{2}\right)}^{\color{blue}{\left(\frac{\mathsf{neg}\left(1\right)}{z1}\right)}} \]
                                                                            12. metadata-eval76.8%

                                                                              \[\leadsto z0 - \left(z0 - 1\right) \cdot {\left(e^{2}\right)}^{\left(\frac{\color{blue}{-1}}{z1}\right)} \]
                                                                          3. Applied rewrites76.8%

                                                                            \[\leadsto z0 - \left(z0 - 1\right) \cdot \color{blue}{{\left(e^{2}\right)}^{\left(\frac{-1}{z1}\right)}} \]
                                                                          4. Taylor expanded in z1 around inf

                                                                            \[\leadsto \color{blue}{1 + 2 \cdot \frac{z0 - 1}{z1}} \]
                                                                          5. Step-by-step derivation
                                                                            1. lower-+.f64N/A

                                                                              \[\leadsto 1 + \color{blue}{2 \cdot \frac{z0 - 1}{z1}} \]
                                                                            2. lower-*.f64N/A

                                                                              \[\leadsto 1 + 2 \cdot \color{blue}{\frac{z0 - 1}{z1}} \]
                                                                            3. lower-/.f64N/A

                                                                              \[\leadsto 1 + 2 \cdot \frac{z0 - 1}{\color{blue}{z1}} \]
                                                                            4. lower--.f6458.5%

                                                                              \[\leadsto 1 + 2 \cdot \frac{z0 - 1}{z1} \]
                                                                          6. Applied rewrites58.5%

                                                                            \[\leadsto \color{blue}{1 + 2 \cdot \frac{z0 - 1}{z1}} \]
                                                                          7. Step-by-step derivation
                                                                            1. lift-*.f64N/A

                                                                              \[\leadsto 1 + 2 \cdot \color{blue}{\frac{z0 - 1}{z1}} \]
                                                                            2. count-2-revN/A

                                                                              \[\leadsto 1 + \left(\frac{z0 - 1}{z1} + \color{blue}{\frac{z0 - 1}{z1}}\right) \]
                                                                            3. lift-/.f64N/A

                                                                              \[\leadsto 1 + \left(\frac{z0 - 1}{z1} + \frac{\color{blue}{z0 - 1}}{z1}\right) \]
                                                                            4. lift-/.f64N/A

                                                                              \[\leadsto 1 + \left(\frac{z0 - 1}{z1} + \frac{z0 - 1}{\color{blue}{z1}}\right) \]
                                                                            5. common-denominatorN/A

                                                                              \[\leadsto 1 + \frac{\left(z0 - 1\right) \cdot z1 + \left(z0 - 1\right) \cdot z1}{\color{blue}{z1 \cdot z1}} \]
                                                                            6. count-2-revN/A

                                                                              \[\leadsto 1 + \frac{2 \cdot \left(\left(z0 - 1\right) \cdot z1\right)}{\color{blue}{z1} \cdot z1} \]
                                                                            7. associate-*l*N/A

                                                                              \[\leadsto 1 + \frac{\left(2 \cdot \left(z0 - 1\right)\right) \cdot z1}{\color{blue}{z1} \cdot z1} \]
                                                                            8. lift--.f64N/A

                                                                              \[\leadsto 1 + \frac{\left(2 \cdot \left(z0 - 1\right)\right) \cdot z1}{z1 \cdot z1} \]
                                                                            9. lift-*.f64N/A

                                                                              \[\leadsto 1 + \frac{\left(2 \cdot \left(z0 - 1\right)\right) \cdot z1}{z1 \cdot \color{blue}{z1}} \]
                                                                            10. lower-/.f64N/A

                                                                              \[\leadsto 1 + \frac{\left(2 \cdot \left(z0 - 1\right)\right) \cdot z1}{\color{blue}{z1 \cdot z1}} \]
                                                                            11. lift--.f64N/A

                                                                              \[\leadsto 1 + \frac{\left(2 \cdot \left(z0 - 1\right)\right) \cdot z1}{z1 \cdot z1} \]
                                                                            12. lift-*.f64N/A

                                                                              \[\leadsto 1 + \frac{\left(2 \cdot \left(z0 - 1\right)\right) \cdot z1}{z1 \cdot z1} \]
                                                                            13. *-commutativeN/A

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

                                                                              \[\leadsto 1 + \frac{z1 \cdot \left(2 \cdot \left(z0 - 1\right)\right)}{z1 \cdot z1} \]
                                                                            15. associate-*r*N/A

                                                                              \[\leadsto 1 + \frac{\left(z1 \cdot 2\right) \cdot \left(z0 - 1\right)}{\color{blue}{z1} \cdot z1} \]
                                                                            16. *-commutativeN/A

                                                                              \[\leadsto 1 + \frac{\left(2 \cdot z1\right) \cdot \left(z0 - 1\right)}{z1 \cdot z1} \]
                                                                            17. count-2N/A

                                                                              \[\leadsto 1 + \frac{\left(z1 + z1\right) \cdot \left(z0 - 1\right)}{z1 \cdot z1} \]
                                                                            18. lift-+.f64N/A

                                                                              \[\leadsto 1 + \frac{\left(z1 + z1\right) \cdot \left(z0 - 1\right)}{z1 \cdot z1} \]
                                                                            19. lower-*.f6452.1%

                                                                              \[\leadsto 1 + \frac{\left(z1 + z1\right) \cdot \left(z0 - 1\right)}{\color{blue}{z1} \cdot z1} \]
                                                                          8. Applied rewrites52.1%

                                                                            \[\leadsto 1 + \frac{\left(z1 + z1\right) \cdot \left(z0 - 1\right)}{\color{blue}{z1 \cdot z1}} \]
                                                                        4. Recombined 3 regimes into one program.
                                                                        5. Add Preprocessing

                                                                        Alternative 18: 69.4% accurate, 0.9× speedup?

                                                                        \[\begin{array}{l} \mathbf{if}\;e^{\frac{-2}{z1}} \leq 4 \cdot 10^{-15}:\\ \;\;\;\;z0 - -1 \cdot 1\\ \mathbf{else}:\\ \;\;\;\;1 + 2 \cdot \frac{z0 - 1}{z1}\\ \end{array} \]
                                                                        (FPCore (z0 z1)
                                                                          :precision binary64
                                                                          (if (<= (exp (/ -2.0 z1)) 4e-15)
                                                                          (- z0 (* -1.0 1.0))
                                                                          (+ 1.0 (* 2.0 (/ (- z0 1.0) z1)))))
                                                                        double code(double z0, double z1) {
                                                                        	double tmp;
                                                                        	if (exp((-2.0 / z1)) <= 4e-15) {
                                                                        		tmp = z0 - (-1.0 * 1.0);
                                                                        	} else {
                                                                        		tmp = 1.0 + (2.0 * ((z0 - 1.0) / z1));
                                                                        	}
                                                                        	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(z0, z1)
                                                                        use fmin_fmax_functions
                                                                            real(8), intent (in) :: z0
                                                                            real(8), intent (in) :: z1
                                                                            real(8) :: tmp
                                                                            if (exp(((-2.0d0) / z1)) <= 4d-15) then
                                                                                tmp = z0 - ((-1.0d0) * 1.0d0)
                                                                            else
                                                                                tmp = 1.0d0 + (2.0d0 * ((z0 - 1.0d0) / z1))
                                                                            end if
                                                                            code = tmp
                                                                        end function
                                                                        
                                                                        public static double code(double z0, double z1) {
                                                                        	double tmp;
                                                                        	if (Math.exp((-2.0 / z1)) <= 4e-15) {
                                                                        		tmp = z0 - (-1.0 * 1.0);
                                                                        	} else {
                                                                        		tmp = 1.0 + (2.0 * ((z0 - 1.0) / z1));
                                                                        	}
                                                                        	return tmp;
                                                                        }
                                                                        
                                                                        def code(z0, z1):
                                                                        	tmp = 0
                                                                        	if math.exp((-2.0 / z1)) <= 4e-15:
                                                                        		tmp = z0 - (-1.0 * 1.0)
                                                                        	else:
                                                                        		tmp = 1.0 + (2.0 * ((z0 - 1.0) / z1))
                                                                        	return tmp
                                                                        
                                                                        function code(z0, z1)
                                                                        	tmp = 0.0
                                                                        	if (exp(Float64(-2.0 / z1)) <= 4e-15)
                                                                        		tmp = Float64(z0 - Float64(-1.0 * 1.0));
                                                                        	else
                                                                        		tmp = Float64(1.0 + Float64(2.0 * Float64(Float64(z0 - 1.0) / z1)));
                                                                        	end
                                                                        	return tmp
                                                                        end
                                                                        
                                                                        function tmp_2 = code(z0, z1)
                                                                        	tmp = 0.0;
                                                                        	if (exp((-2.0 / z1)) <= 4e-15)
                                                                        		tmp = z0 - (-1.0 * 1.0);
                                                                        	else
                                                                        		tmp = 1.0 + (2.0 * ((z0 - 1.0) / z1));
                                                                        	end
                                                                        	tmp_2 = tmp;
                                                                        end
                                                                        
                                                                        code[z0_, z1_] := If[LessEqual[N[Exp[N[(-2.0 / z1), $MachinePrecision]], $MachinePrecision], 4e-15], N[(z0 - N[(-1.0 * 1.0), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(2.0 * N[(N[(z0 - 1.0), $MachinePrecision] / z1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
                                                                        
                                                                        \begin{array}{l}
                                                                        \mathbf{if}\;e^{\frac{-2}{z1}} \leq 4 \cdot 10^{-15}:\\
                                                                        \;\;\;\;z0 - -1 \cdot 1\\
                                                                        
                                                                        \mathbf{else}:\\
                                                                        \;\;\;\;1 + 2 \cdot \frac{z0 - 1}{z1}\\
                                                                        
                                                                        
                                                                        \end{array}
                                                                        
                                                                        Derivation
                                                                        1. Split input into 2 regimes
                                                                        2. if (exp.f64 (/.f64 #s(literal -2 binary64) z1)) < 4.0000000000000003e-15

                                                                          1. Initial program 76.8%

                                                                            \[z0 - \left(z0 - 1\right) \cdot e^{\frac{-2}{z1}} \]
                                                                          2. Taylor expanded in z1 around inf

                                                                            \[\leadsto z0 - \left(z0 - 1\right) \cdot \color{blue}{1} \]
                                                                          3. Step-by-step derivation
                                                                            1. Applied rewrites27.8%

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

                                                                              \[\leadsto z0 - \color{blue}{-1} \cdot 1 \]
                                                                            3. Step-by-step derivation
                                                                              1. Applied rewrites37.4%

                                                                                \[\leadsto z0 - \color{blue}{-1} \cdot 1 \]

                                                                              if 4.0000000000000003e-15 < (exp.f64 (/.f64 #s(literal -2 binary64) z1))

                                                                              1. Initial program 76.8%

                                                                                \[z0 - \left(z0 - 1\right) \cdot e^{\frac{-2}{z1}} \]
                                                                              2. Taylor expanded in z1 around inf

                                                                                \[\leadsto \color{blue}{1 + 2 \cdot \frac{z0 - 1}{z1}} \]
                                                                              3. Step-by-step derivation
                                                                                1. lower-+.f64N/A

                                                                                  \[\leadsto 1 + \color{blue}{2 \cdot \frac{z0 - 1}{z1}} \]
                                                                                2. lower-*.f64N/A

                                                                                  \[\leadsto 1 + 2 \cdot \color{blue}{\frac{z0 - 1}{z1}} \]
                                                                                3. lower-/.f64N/A

                                                                                  \[\leadsto 1 + 2 \cdot \frac{z0 - 1}{\color{blue}{z1}} \]
                                                                                4. lower--.f6458.5%

                                                                                  \[\leadsto 1 + 2 \cdot \frac{z0 - 1}{z1} \]
                                                                              4. Applied rewrites58.5%

                                                                                \[\leadsto \color{blue}{1 + 2 \cdot \frac{z0 - 1}{z1}} \]
                                                                            4. Recombined 2 regimes into one program.
                                                                            5. Add Preprocessing

                                                                            Alternative 19: 68.8% accurate, 0.9× speedup?

                                                                            \[\begin{array}{l} \mathbf{if}\;e^{\frac{-2}{z1}} \leq 0:\\ \;\;\;\;z0 - -1 \cdot 1\\ \mathbf{else}:\\ \;\;\;\;1 + 2 \cdot \frac{z0}{z1}\\ \end{array} \]
                                                                            (FPCore (z0 z1)
                                                                              :precision binary64
                                                                              (if (<= (exp (/ -2.0 z1)) 0.0)
                                                                              (- z0 (* -1.0 1.0))
                                                                              (+ 1.0 (* 2.0 (/ z0 z1)))))
                                                                            double code(double z0, double z1) {
                                                                            	double tmp;
                                                                            	if (exp((-2.0 / z1)) <= 0.0) {
                                                                            		tmp = z0 - (-1.0 * 1.0);
                                                                            	} else {
                                                                            		tmp = 1.0 + (2.0 * (z0 / z1));
                                                                            	}
                                                                            	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(z0, z1)
                                                                            use fmin_fmax_functions
                                                                                real(8), intent (in) :: z0
                                                                                real(8), intent (in) :: z1
                                                                                real(8) :: tmp
                                                                                if (exp(((-2.0d0) / z1)) <= 0.0d0) then
                                                                                    tmp = z0 - ((-1.0d0) * 1.0d0)
                                                                                else
                                                                                    tmp = 1.0d0 + (2.0d0 * (z0 / z1))
                                                                                end if
                                                                                code = tmp
                                                                            end function
                                                                            
                                                                            public static double code(double z0, double z1) {
                                                                            	double tmp;
                                                                            	if (Math.exp((-2.0 / z1)) <= 0.0) {
                                                                            		tmp = z0 - (-1.0 * 1.0);
                                                                            	} else {
                                                                            		tmp = 1.0 + (2.0 * (z0 / z1));
                                                                            	}
                                                                            	return tmp;
                                                                            }
                                                                            
                                                                            def code(z0, z1):
                                                                            	tmp = 0
                                                                            	if math.exp((-2.0 / z1)) <= 0.0:
                                                                            		tmp = z0 - (-1.0 * 1.0)
                                                                            	else:
                                                                            		tmp = 1.0 + (2.0 * (z0 / z1))
                                                                            	return tmp
                                                                            
                                                                            function code(z0, z1)
                                                                            	tmp = 0.0
                                                                            	if (exp(Float64(-2.0 / z1)) <= 0.0)
                                                                            		tmp = Float64(z0 - Float64(-1.0 * 1.0));
                                                                            	else
                                                                            		tmp = Float64(1.0 + Float64(2.0 * Float64(z0 / z1)));
                                                                            	end
                                                                            	return tmp
                                                                            end
                                                                            
                                                                            function tmp_2 = code(z0, z1)
                                                                            	tmp = 0.0;
                                                                            	if (exp((-2.0 / z1)) <= 0.0)
                                                                            		tmp = z0 - (-1.0 * 1.0);
                                                                            	else
                                                                            		tmp = 1.0 + (2.0 * (z0 / z1));
                                                                            	end
                                                                            	tmp_2 = tmp;
                                                                            end
                                                                            
                                                                            code[z0_, z1_] := If[LessEqual[N[Exp[N[(-2.0 / z1), $MachinePrecision]], $MachinePrecision], 0.0], N[(z0 - N[(-1.0 * 1.0), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(2.0 * N[(z0 / z1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
                                                                            
                                                                            \begin{array}{l}
                                                                            \mathbf{if}\;e^{\frac{-2}{z1}} \leq 0:\\
                                                                            \;\;\;\;z0 - -1 \cdot 1\\
                                                                            
                                                                            \mathbf{else}:\\
                                                                            \;\;\;\;1 + 2 \cdot \frac{z0}{z1}\\
                                                                            
                                                                            
                                                                            \end{array}
                                                                            
                                                                            Derivation
                                                                            1. Split input into 2 regimes
                                                                            2. if (exp.f64 (/.f64 #s(literal -2 binary64) z1)) < 0.0

                                                                              1. Initial program 76.8%

                                                                                \[z0 - \left(z0 - 1\right) \cdot e^{\frac{-2}{z1}} \]
                                                                              2. Taylor expanded in z1 around inf

                                                                                \[\leadsto z0 - \left(z0 - 1\right) \cdot \color{blue}{1} \]
                                                                              3. Step-by-step derivation
                                                                                1. Applied rewrites27.8%

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

                                                                                  \[\leadsto z0 - \color{blue}{-1} \cdot 1 \]
                                                                                3. Step-by-step derivation
                                                                                  1. Applied rewrites37.4%

                                                                                    \[\leadsto z0 - \color{blue}{-1} \cdot 1 \]

                                                                                  if 0.0 < (exp.f64 (/.f64 #s(literal -2 binary64) z1))

                                                                                  1. Initial program 76.8%

                                                                                    \[z0 - \left(z0 - 1\right) \cdot e^{\frac{-2}{z1}} \]
                                                                                  2. Step-by-step derivation
                                                                                    1. lift-exp.f64N/A

                                                                                      \[\leadsto z0 - \left(z0 - 1\right) \cdot \color{blue}{e^{\frac{-2}{z1}}} \]
                                                                                    2. lift-/.f64N/A

                                                                                      \[\leadsto z0 - \left(z0 - 1\right) \cdot e^{\color{blue}{\frac{-2}{z1}}} \]
                                                                                    3. frac-2negN/A

                                                                                      \[\leadsto z0 - \left(z0 - 1\right) \cdot e^{\color{blue}{\frac{\mathsf{neg}\left(-2\right)}{\mathsf{neg}\left(z1\right)}}} \]
                                                                                    4. mult-flipN/A

                                                                                      \[\leadsto z0 - \left(z0 - 1\right) \cdot e^{\color{blue}{\left(\mathsf{neg}\left(-2\right)\right) \cdot \frac{1}{\mathsf{neg}\left(z1\right)}}} \]
                                                                                    5. exp-prodN/A

                                                                                      \[\leadsto z0 - \left(z0 - 1\right) \cdot \color{blue}{{\left(e^{\mathsf{neg}\left(-2\right)}\right)}^{\left(\frac{1}{\mathsf{neg}\left(z1\right)}\right)}} \]
                                                                                    6. lower-pow.f64N/A

                                                                                      \[\leadsto z0 - \left(z0 - 1\right) \cdot \color{blue}{{\left(e^{\mathsf{neg}\left(-2\right)}\right)}^{\left(\frac{1}{\mathsf{neg}\left(z1\right)}\right)}} \]
                                                                                    7. lower-exp.f64N/A

                                                                                      \[\leadsto z0 - \left(z0 - 1\right) \cdot {\color{blue}{\left(e^{\mathsf{neg}\left(-2\right)}\right)}}^{\left(\frac{1}{\mathsf{neg}\left(z1\right)}\right)} \]
                                                                                    8. metadata-evalN/A

                                                                                      \[\leadsto z0 - \left(z0 - 1\right) \cdot {\left(e^{\color{blue}{2}}\right)}^{\left(\frac{1}{\mathsf{neg}\left(z1\right)}\right)} \]
                                                                                    9. frac-2negN/A

                                                                                      \[\leadsto z0 - \left(z0 - 1\right) \cdot {\left(e^{2}\right)}^{\color{blue}{\left(\frac{\mathsf{neg}\left(1\right)}{\mathsf{neg}\left(\left(\mathsf{neg}\left(z1\right)\right)\right)}\right)}} \]
                                                                                    10. remove-double-negN/A

                                                                                      \[\leadsto z0 - \left(z0 - 1\right) \cdot {\left(e^{2}\right)}^{\left(\frac{\mathsf{neg}\left(1\right)}{\color{blue}{z1}}\right)} \]
                                                                                    11. lower-/.f64N/A

                                                                                      \[\leadsto z0 - \left(z0 - 1\right) \cdot {\left(e^{2}\right)}^{\color{blue}{\left(\frac{\mathsf{neg}\left(1\right)}{z1}\right)}} \]
                                                                                    12. metadata-eval76.8%

                                                                                      \[\leadsto z0 - \left(z0 - 1\right) \cdot {\left(e^{2}\right)}^{\left(\frac{\color{blue}{-1}}{z1}\right)} \]
                                                                                  3. Applied rewrites76.8%

                                                                                    \[\leadsto z0 - \left(z0 - 1\right) \cdot \color{blue}{{\left(e^{2}\right)}^{\left(\frac{-1}{z1}\right)}} \]
                                                                                  4. Taylor expanded in z1 around inf

                                                                                    \[\leadsto \color{blue}{1 + 2 \cdot \frac{z0 - 1}{z1}} \]
                                                                                  5. Step-by-step derivation
                                                                                    1. lower-+.f64N/A

                                                                                      \[\leadsto 1 + \color{blue}{2 \cdot \frac{z0 - 1}{z1}} \]
                                                                                    2. lower-*.f64N/A

                                                                                      \[\leadsto 1 + 2 \cdot \color{blue}{\frac{z0 - 1}{z1}} \]
                                                                                    3. lower-/.f64N/A

                                                                                      \[\leadsto 1 + 2 \cdot \frac{z0 - 1}{\color{blue}{z1}} \]
                                                                                    4. lower--.f6458.5%

                                                                                      \[\leadsto 1 + 2 \cdot \frac{z0 - 1}{z1} \]
                                                                                  6. Applied rewrites58.5%

                                                                                    \[\leadsto \color{blue}{1 + 2 \cdot \frac{z0 - 1}{z1}} \]
                                                                                  7. Taylor expanded in z0 around inf

                                                                                    \[\leadsto 1 + 2 \cdot \frac{z0}{\color{blue}{z1}} \]
                                                                                  8. Step-by-step derivation
                                                                                    1. lower-/.f6458.0%

                                                                                      \[\leadsto 1 + 2 \cdot \frac{z0}{z1} \]
                                                                                  9. Applied rewrites58.0%

                                                                                    \[\leadsto 1 + 2 \cdot \frac{z0}{\color{blue}{z1}} \]
                                                                                4. Recombined 2 regimes into one program.
                                                                                5. Add Preprocessing

                                                                                Alternative 20: 50.6% accurate, 3.8× speedup?

                                                                                \[\begin{array}{l} \mathbf{if}\;\frac{-2}{z1} \leq -3.5 \cdot 10^{-75}:\\ \;\;\;\;z0 - -1 \cdot 1\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{-2}{z1}\\ \end{array} \]
                                                                                (FPCore (z0 z1)
                                                                                  :precision binary64
                                                                                  (if (<= (/ -2.0 z1) -3.5e-75) (- z0 (* -1.0 1.0)) (+ 1.0 (/ -2.0 z1))))
                                                                                double code(double z0, double z1) {
                                                                                	double tmp;
                                                                                	if ((-2.0 / z1) <= -3.5e-75) {
                                                                                		tmp = z0 - (-1.0 * 1.0);
                                                                                	} else {
                                                                                		tmp = 1.0 + (-2.0 / z1);
                                                                                	}
                                                                                	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(z0, z1)
                                                                                use fmin_fmax_functions
                                                                                    real(8), intent (in) :: z0
                                                                                    real(8), intent (in) :: z1
                                                                                    real(8) :: tmp
                                                                                    if (((-2.0d0) / z1) <= (-3.5d-75)) then
                                                                                        tmp = z0 - ((-1.0d0) * 1.0d0)
                                                                                    else
                                                                                        tmp = 1.0d0 + ((-2.0d0) / z1)
                                                                                    end if
                                                                                    code = tmp
                                                                                end function
                                                                                
                                                                                public static double code(double z0, double z1) {
                                                                                	double tmp;
                                                                                	if ((-2.0 / z1) <= -3.5e-75) {
                                                                                		tmp = z0 - (-1.0 * 1.0);
                                                                                	} else {
                                                                                		tmp = 1.0 + (-2.0 / z1);
                                                                                	}
                                                                                	return tmp;
                                                                                }
                                                                                
                                                                                def code(z0, z1):
                                                                                	tmp = 0
                                                                                	if (-2.0 / z1) <= -3.5e-75:
                                                                                		tmp = z0 - (-1.0 * 1.0)
                                                                                	else:
                                                                                		tmp = 1.0 + (-2.0 / z1)
                                                                                	return tmp
                                                                                
                                                                                function code(z0, z1)
                                                                                	tmp = 0.0
                                                                                	if (Float64(-2.0 / z1) <= -3.5e-75)
                                                                                		tmp = Float64(z0 - Float64(-1.0 * 1.0));
                                                                                	else
                                                                                		tmp = Float64(1.0 + Float64(-2.0 / z1));
                                                                                	end
                                                                                	return tmp
                                                                                end
                                                                                
                                                                                function tmp_2 = code(z0, z1)
                                                                                	tmp = 0.0;
                                                                                	if ((-2.0 / z1) <= -3.5e-75)
                                                                                		tmp = z0 - (-1.0 * 1.0);
                                                                                	else
                                                                                		tmp = 1.0 + (-2.0 / z1);
                                                                                	end
                                                                                	tmp_2 = tmp;
                                                                                end
                                                                                
                                                                                code[z0_, z1_] := If[LessEqual[N[(-2.0 / z1), $MachinePrecision], -3.5e-75], N[(z0 - N[(-1.0 * 1.0), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(-2.0 / z1), $MachinePrecision]), $MachinePrecision]]
                                                                                
                                                                                \begin{array}{l}
                                                                                \mathbf{if}\;\frac{-2}{z1} \leq -3.5 \cdot 10^{-75}:\\
                                                                                \;\;\;\;z0 - -1 \cdot 1\\
                                                                                
                                                                                \mathbf{else}:\\
                                                                                \;\;\;\;1 + \frac{-2}{z1}\\
                                                                                
                                                                                
                                                                                \end{array}
                                                                                
                                                                                Derivation
                                                                                1. Split input into 2 regimes
                                                                                2. if (/.f64 #s(literal -2 binary64) z1) < -3.4999999999999999e-75

                                                                                  1. Initial program 76.8%

                                                                                    \[z0 - \left(z0 - 1\right) \cdot e^{\frac{-2}{z1}} \]
                                                                                  2. Taylor expanded in z1 around inf

                                                                                    \[\leadsto z0 - \left(z0 - 1\right) \cdot \color{blue}{1} \]
                                                                                  3. Step-by-step derivation
                                                                                    1. Applied rewrites27.8%

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

                                                                                      \[\leadsto z0 - \color{blue}{-1} \cdot 1 \]
                                                                                    3. Step-by-step derivation
                                                                                      1. Applied rewrites37.4%

                                                                                        \[\leadsto z0 - \color{blue}{-1} \cdot 1 \]

                                                                                      if -3.4999999999999999e-75 < (/.f64 #s(literal -2 binary64) z1)

                                                                                      1. Initial program 76.8%

                                                                                        \[z0 - \left(z0 - 1\right) \cdot e^{\frac{-2}{z1}} \]
                                                                                      2. Step-by-step derivation
                                                                                        1. lift-exp.f64N/A

                                                                                          \[\leadsto z0 - \left(z0 - 1\right) \cdot \color{blue}{e^{\frac{-2}{z1}}} \]
                                                                                        2. lift-/.f64N/A

                                                                                          \[\leadsto z0 - \left(z0 - 1\right) \cdot e^{\color{blue}{\frac{-2}{z1}}} \]
                                                                                        3. frac-2negN/A

                                                                                          \[\leadsto z0 - \left(z0 - 1\right) \cdot e^{\color{blue}{\frac{\mathsf{neg}\left(-2\right)}{\mathsf{neg}\left(z1\right)}}} \]
                                                                                        4. mult-flipN/A

                                                                                          \[\leadsto z0 - \left(z0 - 1\right) \cdot e^{\color{blue}{\left(\mathsf{neg}\left(-2\right)\right) \cdot \frac{1}{\mathsf{neg}\left(z1\right)}}} \]
                                                                                        5. exp-prodN/A

                                                                                          \[\leadsto z0 - \left(z0 - 1\right) \cdot \color{blue}{{\left(e^{\mathsf{neg}\left(-2\right)}\right)}^{\left(\frac{1}{\mathsf{neg}\left(z1\right)}\right)}} \]
                                                                                        6. lower-pow.f64N/A

                                                                                          \[\leadsto z0 - \left(z0 - 1\right) \cdot \color{blue}{{\left(e^{\mathsf{neg}\left(-2\right)}\right)}^{\left(\frac{1}{\mathsf{neg}\left(z1\right)}\right)}} \]
                                                                                        7. lower-exp.f64N/A

                                                                                          \[\leadsto z0 - \left(z0 - 1\right) \cdot {\color{blue}{\left(e^{\mathsf{neg}\left(-2\right)}\right)}}^{\left(\frac{1}{\mathsf{neg}\left(z1\right)}\right)} \]
                                                                                        8. metadata-evalN/A

                                                                                          \[\leadsto z0 - \left(z0 - 1\right) \cdot {\left(e^{\color{blue}{2}}\right)}^{\left(\frac{1}{\mathsf{neg}\left(z1\right)}\right)} \]
                                                                                        9. frac-2negN/A

                                                                                          \[\leadsto z0 - \left(z0 - 1\right) \cdot {\left(e^{2}\right)}^{\color{blue}{\left(\frac{\mathsf{neg}\left(1\right)}{\mathsf{neg}\left(\left(\mathsf{neg}\left(z1\right)\right)\right)}\right)}} \]
                                                                                        10. remove-double-negN/A

                                                                                          \[\leadsto z0 - \left(z0 - 1\right) \cdot {\left(e^{2}\right)}^{\left(\frac{\mathsf{neg}\left(1\right)}{\color{blue}{z1}}\right)} \]
                                                                                        11. lower-/.f64N/A

                                                                                          \[\leadsto z0 - \left(z0 - 1\right) \cdot {\left(e^{2}\right)}^{\color{blue}{\left(\frac{\mathsf{neg}\left(1\right)}{z1}\right)}} \]
                                                                                        12. metadata-eval76.8%

                                                                                          \[\leadsto z0 - \left(z0 - 1\right) \cdot {\left(e^{2}\right)}^{\left(\frac{\color{blue}{-1}}{z1}\right)} \]
                                                                                      3. Applied rewrites76.8%

                                                                                        \[\leadsto z0 - \left(z0 - 1\right) \cdot \color{blue}{{\left(e^{2}\right)}^{\left(\frac{-1}{z1}\right)}} \]
                                                                                      4. Taylor expanded in z1 around inf

                                                                                        \[\leadsto \color{blue}{1 + 2 \cdot \frac{z0 - 1}{z1}} \]
                                                                                      5. Step-by-step derivation
                                                                                        1. lower-+.f64N/A

                                                                                          \[\leadsto 1 + \color{blue}{2 \cdot \frac{z0 - 1}{z1}} \]
                                                                                        2. lower-*.f64N/A

                                                                                          \[\leadsto 1 + 2 \cdot \color{blue}{\frac{z0 - 1}{z1}} \]
                                                                                        3. lower-/.f64N/A

                                                                                          \[\leadsto 1 + 2 \cdot \frac{z0 - 1}{\color{blue}{z1}} \]
                                                                                        4. lower--.f6458.5%

                                                                                          \[\leadsto 1 + 2 \cdot \frac{z0 - 1}{z1} \]
                                                                                      6. Applied rewrites58.5%

                                                                                        \[\leadsto \color{blue}{1 + 2 \cdot \frac{z0 - 1}{z1}} \]
                                                                                      7. Taylor expanded in z0 around 0

                                                                                        \[\leadsto 1 + \frac{-2}{\color{blue}{z1}} \]
                                                                                      8. Step-by-step derivation
                                                                                        1. lower-/.f6439.5%

                                                                                          \[\leadsto 1 + \frac{-2}{z1} \]
                                                                                      9. Applied rewrites39.5%

                                                                                        \[\leadsto 1 + \frac{-2}{\color{blue}{z1}} \]
                                                                                    4. Recombined 2 regimes into one program.
                                                                                    5. Add Preprocessing

                                                                                    Alternative 21: 50.0% accurate, 4.7× speedup?

                                                                                    \[\begin{array}{l} \mathbf{if}\;\frac{-2}{z1} \leq -3.5 \cdot 10^{-75}:\\ \;\;\;\;z0 - -1 \cdot 1\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
                                                                                    (FPCore (z0 z1)
                                                                                      :precision binary64
                                                                                      (if (<= (/ -2.0 z1) -3.5e-75) (- z0 (* -1.0 1.0)) 1.0))
                                                                                    double code(double z0, double z1) {
                                                                                    	double tmp;
                                                                                    	if ((-2.0 / z1) <= -3.5e-75) {
                                                                                    		tmp = z0 - (-1.0 * 1.0);
                                                                                    	} else {
                                                                                    		tmp = 1.0;
                                                                                    	}
                                                                                    	return tmp;
                                                                                    }
                                                                                    
                                                                                    module fmin_fmax_functions
                                                                                        implicit none
                                                                                        private
                                                                                        public fmax
                                                                                        public fmin
                                                                                    
                                                                                        interface fmax
                                                                                            module procedure fmax88
                                                                                            module procedure fmax44
                                                                                            module procedure fmax84
                                                                                            module procedure fmax48
                                                                                        end interface
                                                                                        interface fmin
                                                                                            module procedure fmin88
                                                                                            module procedure fmin44
                                                                                            module procedure fmin84
                                                                                            module procedure fmin48
                                                                                        end interface
                                                                                    contains
                                                                                        real(8) function fmax88(x, y) result (res)
                                                                                            real(8), intent (in) :: x
                                                                                            real(8), intent (in) :: y
                                                                                            res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                                                                        end function
                                                                                        real(4) function fmax44(x, y) result (res)
                                                                                            real(4), intent (in) :: x
                                                                                            real(4), intent (in) :: y
                                                                                            res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                                                                        end function
                                                                                        real(8) function fmax84(x, y) result(res)
                                                                                            real(8), intent (in) :: x
                                                                                            real(4), intent (in) :: y
                                                                                            res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                                                                                        end function
                                                                                        real(8) function fmax48(x, y) result(res)
                                                                                            real(4), intent (in) :: x
                                                                                            real(8), intent (in) :: y
                                                                                            res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                                                                                        end function
                                                                                        real(8) function fmin88(x, y) result (res)
                                                                                            real(8), intent (in) :: x
                                                                                            real(8), intent (in) :: y
                                                                                            res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                                                                        end function
                                                                                        real(4) function fmin44(x, y) result (res)
                                                                                            real(4), intent (in) :: x
                                                                                            real(4), intent (in) :: y
                                                                                            res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                                                                        end function
                                                                                        real(8) function fmin84(x, y) result(res)
                                                                                            real(8), intent (in) :: x
                                                                                            real(4), intent (in) :: y
                                                                                            res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                                                                                        end function
                                                                                        real(8) function fmin48(x, y) result(res)
                                                                                            real(4), intent (in) :: x
                                                                                            real(8), intent (in) :: y
                                                                                            res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                                                                                        end function
                                                                                    end module
                                                                                    
                                                                                    real(8) function code(z0, z1)
                                                                                    use fmin_fmax_functions
                                                                                        real(8), intent (in) :: z0
                                                                                        real(8), intent (in) :: z1
                                                                                        real(8) :: tmp
                                                                                        if (((-2.0d0) / z1) <= (-3.5d-75)) then
                                                                                            tmp = z0 - ((-1.0d0) * 1.0d0)
                                                                                        else
                                                                                            tmp = 1.0d0
                                                                                        end if
                                                                                        code = tmp
                                                                                    end function
                                                                                    
                                                                                    public static double code(double z0, double z1) {
                                                                                    	double tmp;
                                                                                    	if ((-2.0 / z1) <= -3.5e-75) {
                                                                                    		tmp = z0 - (-1.0 * 1.0);
                                                                                    	} else {
                                                                                    		tmp = 1.0;
                                                                                    	}
                                                                                    	return tmp;
                                                                                    }
                                                                                    
                                                                                    def code(z0, z1):
                                                                                    	tmp = 0
                                                                                    	if (-2.0 / z1) <= -3.5e-75:
                                                                                    		tmp = z0 - (-1.0 * 1.0)
                                                                                    	else:
                                                                                    		tmp = 1.0
                                                                                    	return tmp
                                                                                    
                                                                                    function code(z0, z1)
                                                                                    	tmp = 0.0
                                                                                    	if (Float64(-2.0 / z1) <= -3.5e-75)
                                                                                    		tmp = Float64(z0 - Float64(-1.0 * 1.0));
                                                                                    	else
                                                                                    		tmp = 1.0;
                                                                                    	end
                                                                                    	return tmp
                                                                                    end
                                                                                    
                                                                                    function tmp_2 = code(z0, z1)
                                                                                    	tmp = 0.0;
                                                                                    	if ((-2.0 / z1) <= -3.5e-75)
                                                                                    		tmp = z0 - (-1.0 * 1.0);
                                                                                    	else
                                                                                    		tmp = 1.0;
                                                                                    	end
                                                                                    	tmp_2 = tmp;
                                                                                    end
                                                                                    
                                                                                    code[z0_, z1_] := If[LessEqual[N[(-2.0 / z1), $MachinePrecision], -3.5e-75], N[(z0 - N[(-1.0 * 1.0), $MachinePrecision]), $MachinePrecision], 1.0]
                                                                                    
                                                                                    \begin{array}{l}
                                                                                    \mathbf{if}\;\frac{-2}{z1} \leq -3.5 \cdot 10^{-75}:\\
                                                                                    \;\;\;\;z0 - -1 \cdot 1\\
                                                                                    
                                                                                    \mathbf{else}:\\
                                                                                    \;\;\;\;1\\
                                                                                    
                                                                                    
                                                                                    \end{array}
                                                                                    
                                                                                    Derivation
                                                                                    1. Split input into 2 regimes
                                                                                    2. if (/.f64 #s(literal -2 binary64) z1) < -3.4999999999999999e-75

                                                                                      1. Initial program 76.8%

                                                                                        \[z0 - \left(z0 - 1\right) \cdot e^{\frac{-2}{z1}} \]
                                                                                      2. Taylor expanded in z1 around inf

                                                                                        \[\leadsto z0 - \left(z0 - 1\right) \cdot \color{blue}{1} \]
                                                                                      3. Step-by-step derivation
                                                                                        1. Applied rewrites27.8%

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

                                                                                          \[\leadsto z0 - \color{blue}{-1} \cdot 1 \]
                                                                                        3. Step-by-step derivation
                                                                                          1. Applied rewrites37.4%

                                                                                            \[\leadsto z0 - \color{blue}{-1} \cdot 1 \]

                                                                                          if -3.4999999999999999e-75 < (/.f64 #s(literal -2 binary64) z1)

                                                                                          1. Initial program 76.8%

                                                                                            \[z0 - \left(z0 - 1\right) \cdot e^{\frac{-2}{z1}} \]
                                                                                          2. Taylor expanded in z1 around -inf

                                                                                            \[\leadsto \color{blue}{1 + -1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                                                                          3. Step-by-step derivation
                                                                                            1. lower-+.f64N/A

                                                                                              \[\leadsto 1 + \color{blue}{-1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                                                                            2. lower-*.f64N/A

                                                                                              \[\leadsto 1 + -1 \cdot \color{blue}{\frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                                                                            3. lower-/.f64N/A

                                                                                              \[\leadsto 1 + -1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{\color{blue}{z1}} \]
                                                                                          4. Applied rewrites71.0%

                                                                                            \[\leadsto \color{blue}{1 + -1 \cdot \frac{-1 \cdot \frac{1.3333333333333333 \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                                                                          5. Step-by-step derivation
                                                                                            1. lift-*.f64N/A

                                                                                              \[\leadsto 1 + -1 \cdot \color{blue}{\frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                                                                            2. lift-/.f64N/A

                                                                                              \[\leadsto 1 + -1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{\color{blue}{z1}} \]
                                                                                            3. associate-*r/N/A

                                                                                              \[\leadsto 1 + \frac{-1 \cdot \left(-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)\right)}{\color{blue}{z1}} \]
                                                                                            4. mult-flipN/A

                                                                                              \[\leadsto 1 + \left(-1 \cdot \left(-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)\right)\right) \cdot \color{blue}{\frac{1}{z1}} \]
                                                                                          6. Applied rewrites57.8%

                                                                                            \[\leadsto 1 + \frac{\left(\left(2 \cdot \left(z0 - 1\right)\right) \cdot z1 - \left(2 \cdot \left(z0 - 1\right) - \frac{z0 - 1}{z1} \cdot 1.3333333333333333\right)\right) \cdot 1}{\color{blue}{z1 \cdot z1}} \]
                                                                                          7. Taylor expanded in z1 around inf

                                                                                            \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{\color{blue}{z1}} \]
                                                                                          8. Step-by-step derivation
                                                                                            1. lower-/.f64N/A

                                                                                              \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                                                                            2. lower-+.f64N/A

                                                                                              \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                                                                            3. lower-*.f64N/A

                                                                                              \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                                                                            4. lower-/.f64N/A

                                                                                              \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                                                                            5. lower--.f64N/A

                                                                                              \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                                                                            6. lower-*.f64N/A

                                                                                              \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                                                                            7. lower--.f6466.8%

                                                                                              \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                                                                          9. Applied rewrites66.8%

                                                                                            \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{\color{blue}{z1}} \]
                                                                                          10. Taylor expanded in z1 around inf

                                                                                            \[\leadsto 1 \]
                                                                                          11. Step-by-step derivation
                                                                                            1. Applied rewrites39.0%

                                                                                              \[\leadsto 1 \]
                                                                                          12. Recombined 2 regimes into one program.
                                                                                          13. Add Preprocessing

                                                                                          Alternative 22: 39.0% accurate, 123.0× speedup?

                                                                                          \[1 \]
                                                                                          (FPCore (z0 z1)
                                                                                            :precision binary64
                                                                                            1.0)
                                                                                          double code(double z0, double z1) {
                                                                                          	return 1.0;
                                                                                          }
                                                                                          
                                                                                          module fmin_fmax_functions
                                                                                              implicit none
                                                                                              private
                                                                                              public fmax
                                                                                              public fmin
                                                                                          
                                                                                              interface fmax
                                                                                                  module procedure fmax88
                                                                                                  module procedure fmax44
                                                                                                  module procedure fmax84
                                                                                                  module procedure fmax48
                                                                                              end interface
                                                                                              interface fmin
                                                                                                  module procedure fmin88
                                                                                                  module procedure fmin44
                                                                                                  module procedure fmin84
                                                                                                  module procedure fmin48
                                                                                              end interface
                                                                                          contains
                                                                                              real(8) function fmax88(x, y) result (res)
                                                                                                  real(8), intent (in) :: x
                                                                                                  real(8), intent (in) :: y
                                                                                                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                                                                              end function
                                                                                              real(4) function fmax44(x, y) result (res)
                                                                                                  real(4), intent (in) :: x
                                                                                                  real(4), intent (in) :: y
                                                                                                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                                                                              end function
                                                                                              real(8) function fmax84(x, y) result(res)
                                                                                                  real(8), intent (in) :: x
                                                                                                  real(4), intent (in) :: y
                                                                                                  res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                                                                                              end function
                                                                                              real(8) function fmax48(x, y) result(res)
                                                                                                  real(4), intent (in) :: x
                                                                                                  real(8), intent (in) :: y
                                                                                                  res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                                                                                              end function
                                                                                              real(8) function fmin88(x, y) result (res)
                                                                                                  real(8), intent (in) :: x
                                                                                                  real(8), intent (in) :: y
                                                                                                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                                                                              end function
                                                                                              real(4) function fmin44(x, y) result (res)
                                                                                                  real(4), intent (in) :: x
                                                                                                  real(4), intent (in) :: y
                                                                                                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                                                                              end function
                                                                                              real(8) function fmin84(x, y) result(res)
                                                                                                  real(8), intent (in) :: x
                                                                                                  real(4), intent (in) :: y
                                                                                                  res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                                                                                              end function
                                                                                              real(8) function fmin48(x, y) result(res)
                                                                                                  real(4), intent (in) :: x
                                                                                                  real(8), intent (in) :: y
                                                                                                  res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                                                                                              end function
                                                                                          end module
                                                                                          
                                                                                          real(8) function code(z0, z1)
                                                                                          use fmin_fmax_functions
                                                                                              real(8), intent (in) :: z0
                                                                                              real(8), intent (in) :: z1
                                                                                              code = 1.0d0
                                                                                          end function
                                                                                          
                                                                                          public static double code(double z0, double z1) {
                                                                                          	return 1.0;
                                                                                          }
                                                                                          
                                                                                          def code(z0, z1):
                                                                                          	return 1.0
                                                                                          
                                                                                          function code(z0, z1)
                                                                                          	return 1.0
                                                                                          end
                                                                                          
                                                                                          function tmp = code(z0, z1)
                                                                                          	tmp = 1.0;
                                                                                          end
                                                                                          
                                                                                          code[z0_, z1_] := 1.0
                                                                                          
                                                                                          1
                                                                                          
                                                                                          Derivation
                                                                                          1. Initial program 76.8%

                                                                                            \[z0 - \left(z0 - 1\right) \cdot e^{\frac{-2}{z1}} \]
                                                                                          2. Taylor expanded in z1 around -inf

                                                                                            \[\leadsto \color{blue}{1 + -1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                                                                          3. Step-by-step derivation
                                                                                            1. lower-+.f64N/A

                                                                                              \[\leadsto 1 + \color{blue}{-1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                                                                            2. lower-*.f64N/A

                                                                                              \[\leadsto 1 + -1 \cdot \color{blue}{\frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                                                                            3. lower-/.f64N/A

                                                                                              \[\leadsto 1 + -1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{\color{blue}{z1}} \]
                                                                                          4. Applied rewrites71.0%

                                                                                            \[\leadsto \color{blue}{1 + -1 \cdot \frac{-1 \cdot \frac{1.3333333333333333 \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                                                                          5. Step-by-step derivation
                                                                                            1. lift-*.f64N/A

                                                                                              \[\leadsto 1 + -1 \cdot \color{blue}{\frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{z1}} \]
                                                                                            2. lift-/.f64N/A

                                                                                              \[\leadsto 1 + -1 \cdot \frac{-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)}{\color{blue}{z1}} \]
                                                                                            3. associate-*r/N/A

                                                                                              \[\leadsto 1 + \frac{-1 \cdot \left(-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)\right)}{\color{blue}{z1}} \]
                                                                                            4. mult-flipN/A

                                                                                              \[\leadsto 1 + \left(-1 \cdot \left(-1 \cdot \frac{\frac{4}{3} \cdot \frac{z0 - 1}{z1} - 2 \cdot \left(z0 - 1\right)}{z1} - 2 \cdot \left(z0 - 1\right)\right)\right) \cdot \color{blue}{\frac{1}{z1}} \]
                                                                                          6. Applied rewrites57.8%

                                                                                            \[\leadsto 1 + \frac{\left(\left(2 \cdot \left(z0 - 1\right)\right) \cdot z1 - \left(2 \cdot \left(z0 - 1\right) - \frac{z0 - 1}{z1} \cdot 1.3333333333333333\right)\right) \cdot 1}{\color{blue}{z1 \cdot z1}} \]
                                                                                          7. Taylor expanded in z1 around inf

                                                                                            \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{\color{blue}{z1}} \]
                                                                                          8. Step-by-step derivation
                                                                                            1. lower-/.f64N/A

                                                                                              \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                                                                            2. lower-+.f64N/A

                                                                                              \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                                                                            3. lower-*.f64N/A

                                                                                              \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                                                                            4. lower-/.f64N/A

                                                                                              \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                                                                            5. lower--.f64N/A

                                                                                              \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                                                                            6. lower-*.f64N/A

                                                                                              \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                                                                            7. lower--.f6466.8%

                                                                                              \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{z1} \]
                                                                                          9. Applied rewrites66.8%

                                                                                            \[\leadsto 1 + \frac{-2 \cdot \frac{z0 - 1}{z1} + 2 \cdot \left(z0 - 1\right)}{\color{blue}{z1}} \]
                                                                                          10. Taylor expanded in z1 around inf

                                                                                            \[\leadsto 1 \]
                                                                                          11. Step-by-step derivation
                                                                                            1. Applied rewrites39.0%

                                                                                              \[\leadsto 1 \]
                                                                                            2. Add Preprocessing

                                                                                            Reproduce

                                                                                            ?
                                                                                            herbie shell --seed 2025250 
                                                                                            (FPCore (z0 z1)
                                                                                              :name "(- z0 (* (- z0 1) (exp (/ -2 z1))))"
                                                                                              :precision binary64
                                                                                              (- z0 (* (- z0 1.0) (exp (/ -2.0 z1)))))