NMSE Section 6.1 mentioned, A

Percentage Accurate: 73.8% → 98.8%
Time: 7.0s
Alternatives: 10
Speedup: 2.0×

Specification

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

\\
\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2}
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 10 alternatives:

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

Initial Program: 73.8% accurate, 1.0× speedup?

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

\\
\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2}
\end{array}

Alternative 1: 98.8% accurate, 1.1× speedup?

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

\\
\frac{e^{-x \cdot \left(1 - \varepsilon\right)} - -1 \cdot e^{-x \cdot \left(1 + \varepsilon\right)}}{2}
\end{array}
Derivation
  1. Initial program 68.9%

    \[\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2} \]
  2. Taylor expanded in eps around inf

    \[\leadsto \frac{\color{blue}{e^{\mathsf{neg}\left(x \cdot \left(1 - \varepsilon\right)\right)} - -1 \cdot e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}}}{2} \]
  3. Step-by-step derivation
    1. lower--.f64N/A

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

      \[\leadsto \frac{\color{blue}{e^{\mathsf{neg}\left(x \cdot \left(1 - \varepsilon\right)\right)}} - -1 \cdot e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}}{2} \]
    3. lower-neg.f64N/A

      \[\leadsto \frac{e^{\color{blue}{-x \cdot \left(1 - \varepsilon\right)}} - -1 \cdot e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}}{2} \]
    4. lower-*.f64N/A

      \[\leadsto \frac{e^{-\color{blue}{x \cdot \left(1 - \varepsilon\right)}} - -1 \cdot e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}}{2} \]
    5. lower--.f64N/A

      \[\leadsto \frac{e^{-x \cdot \color{blue}{\left(1 - \varepsilon\right)}} - -1 \cdot e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}}{2} \]
    6. lower-*.f64N/A

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

      \[\leadsto \frac{e^{-x \cdot \left(1 - \varepsilon\right)} - -1 \cdot \color{blue}{e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}}}{2} \]
    8. lower-neg.f64N/A

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

      \[\leadsto \frac{e^{-x \cdot \left(1 - \varepsilon\right)} - -1 \cdot e^{-\color{blue}{x \cdot \left(1 + \varepsilon\right)}}}{2} \]
    10. lower-+.f6498.5

      \[\leadsto \frac{e^{-x \cdot \left(1 - \varepsilon\right)} - -1 \cdot e^{-x \cdot \color{blue}{\left(1 + \varepsilon\right)}}}{2} \]
  4. Applied rewrites98.5%

    \[\leadsto \frac{\color{blue}{e^{-x \cdot \left(1 - \varepsilon\right)} - -1 \cdot e^{-x \cdot \left(1 + \varepsilon\right)}}}{2} \]
  5. Add Preprocessing

Alternative 2: 78.4% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\varepsilon \leq -29:\\ \;\;\;\;\frac{\left(1 + x \cdot \left(\varepsilon - 1\right)\right) - -1 \cdot e^{-x \cdot \left(1 + \varepsilon\right)}}{2}\\ \mathbf{elif}\;\varepsilon \leq 1.9 \cdot 10^{-14}:\\ \;\;\;\;\frac{\mathsf{fma}\left(e^{-x}, \left(x + 1\right) - -1, \frac{x}{e^{x}}\right)}{2}\\ \mathbf{elif}\;\varepsilon \leq 2.3 \cdot 10^{+203}:\\ \;\;\;\;\frac{e^{-\mathsf{fma}\left(\varepsilon, x, x\right)} + 1}{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right)}{2}\\ \end{array} \end{array} \]
(FPCore (x eps)
 :precision binary64
 (if (<= eps -29.0)
   (/ (- (+ 1.0 (* x (- eps 1.0))) (* -1.0 (exp (- (* x (+ 1.0 eps)))))) 2.0)
   (if (<= eps 1.9e-14)
     (/ (fma (exp (- x)) (- (+ x 1.0) -1.0) (/ x (exp x))) 2.0)
     (if (<= eps 2.3e+203)
       (/ (+ (exp (- (fma eps x x))) 1.0) 2.0)
       (/
        (-
         (* (+ 1.0 (/ 1.0 eps)) (exp (- (* (- 1.0 eps) x))))
         (- (/ 1.0 eps) 1.0))
        2.0)))))
double code(double x, double eps) {
	double tmp;
	if (eps <= -29.0) {
		tmp = ((1.0 + (x * (eps - 1.0))) - (-1.0 * exp(-(x * (1.0 + eps))))) / 2.0;
	} else if (eps <= 1.9e-14) {
		tmp = fma(exp(-x), ((x + 1.0) - -1.0), (x / exp(x))) / 2.0;
	} else if (eps <= 2.3e+203) {
		tmp = (exp(-fma(eps, x, x)) + 1.0) / 2.0;
	} else {
		tmp = (((1.0 + (1.0 / eps)) * exp(-((1.0 - eps) * x))) - ((1.0 / eps) - 1.0)) / 2.0;
	}
	return tmp;
}
function code(x, eps)
	tmp = 0.0
	if (eps <= -29.0)
		tmp = Float64(Float64(Float64(1.0 + Float64(x * Float64(eps - 1.0))) - Float64(-1.0 * exp(Float64(-Float64(x * Float64(1.0 + eps)))))) / 2.0);
	elseif (eps <= 1.9e-14)
		tmp = Float64(fma(exp(Float64(-x)), Float64(Float64(x + 1.0) - -1.0), Float64(x / exp(x))) / 2.0);
	elseif (eps <= 2.3e+203)
		tmp = Float64(Float64(exp(Float64(-fma(eps, x, x))) + 1.0) / 2.0);
	else
		tmp = Float64(Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) * exp(Float64(-Float64(Float64(1.0 - eps) * x)))) - Float64(Float64(1.0 / eps) - 1.0)) / 2.0);
	end
	return tmp
end
code[x_, eps_] := If[LessEqual[eps, -29.0], N[(N[(N[(1.0 + N[(x * N[(eps - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(-1.0 * N[Exp[(-N[(x * N[(1.0 + eps), $MachinePrecision]), $MachinePrecision])], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[eps, 1.9e-14], N[(N[(N[Exp[(-x)], $MachinePrecision] * N[(N[(x + 1.0), $MachinePrecision] - -1.0), $MachinePrecision] + N[(x / N[Exp[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[eps, 2.3e+203], N[(N[(N[Exp[(-N[(eps * x + x), $MachinePrecision])], $MachinePrecision] + 1.0), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] * N[Exp[(-N[(N[(1.0 - eps), $MachinePrecision] * x), $MachinePrecision])], $MachinePrecision]), $MachinePrecision] - N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -29:\\
\;\;\;\;\frac{\left(1 + x \cdot \left(\varepsilon - 1\right)\right) - -1 \cdot e^{-x \cdot \left(1 + \varepsilon\right)}}{2}\\

\mathbf{elif}\;\varepsilon \leq 1.9 \cdot 10^{-14}:\\
\;\;\;\;\frac{\mathsf{fma}\left(e^{-x}, \left(x + 1\right) - -1, \frac{x}{e^{x}}\right)}{2}\\

\mathbf{elif}\;\varepsilon \leq 2.3 \cdot 10^{+203}:\\
\;\;\;\;\frac{e^{-\mathsf{fma}\left(\varepsilon, x, x\right)} + 1}{2}\\

\mathbf{else}:\\
\;\;\;\;\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right)}{2}\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if eps < -29

    1. Initial program 100.0%

      \[\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2} \]
    2. Taylor expanded in eps around inf

      \[\leadsto \frac{\color{blue}{e^{\mathsf{neg}\left(x \cdot \left(1 - \varepsilon\right)\right)} - -1 \cdot e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}}}{2} \]
    3. Step-by-step derivation
      1. lower--.f64N/A

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

        \[\leadsto \frac{\color{blue}{e^{\mathsf{neg}\left(x \cdot \left(1 - \varepsilon\right)\right)}} - -1 \cdot e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}}{2} \]
      3. lower-neg.f64N/A

        \[\leadsto \frac{e^{\color{blue}{-x \cdot \left(1 - \varepsilon\right)}} - -1 \cdot e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}}{2} \]
      4. lower-*.f64N/A

        \[\leadsto \frac{e^{-\color{blue}{x \cdot \left(1 - \varepsilon\right)}} - -1 \cdot e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}}{2} \]
      5. lower--.f64N/A

        \[\leadsto \frac{e^{-x \cdot \color{blue}{\left(1 - \varepsilon\right)}} - -1 \cdot e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}}{2} \]
      6. lower-*.f64N/A

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

        \[\leadsto \frac{e^{-x \cdot \left(1 - \varepsilon\right)} - -1 \cdot \color{blue}{e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}}}{2} \]
      8. lower-neg.f64N/A

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

        \[\leadsto \frac{e^{-x \cdot \left(1 - \varepsilon\right)} - -1 \cdot e^{-\color{blue}{x \cdot \left(1 + \varepsilon\right)}}}{2} \]
      10. lower-+.f64100.0

        \[\leadsto \frac{e^{-x \cdot \left(1 - \varepsilon\right)} - -1 \cdot e^{-x \cdot \color{blue}{\left(1 + \varepsilon\right)}}}{2} \]
    4. Applied rewrites100.0%

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

      \[\leadsto \frac{\left(1 + x \cdot \left(\varepsilon - 1\right)\right) - \color{blue}{-1} \cdot e^{-x \cdot \left(1 + \varepsilon\right)}}{2} \]
    6. Step-by-step derivation
      1. Applied rewrites72.0%

        \[\leadsto \frac{\left(1 + x \cdot \left(\varepsilon - 1\right)\right) - \color{blue}{-1} \cdot e^{-x \cdot \left(1 + \varepsilon\right)}}{2} \]

      if -29 < eps < 1.9000000000000001e-14

      1. Initial program 32.6%

        \[\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2} \]
      2. Taylor expanded in eps around 0

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

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

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

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

          \[\leadsto \frac{\left(e^{\color{blue}{-x}} + x \cdot e^{\mathsf{neg}\left(x\right)}\right) - \left(-1 \cdot e^{\mathsf{neg}\left(x\right)} + -1 \cdot \left(x \cdot e^{\mathsf{neg}\left(x\right)}\right)\right)}{2} \]
        5. lower-*.f64N/A

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

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

          \[\leadsto \frac{\left(e^{-x} + x \cdot e^{\color{blue}{-x}}\right) - \left(-1 \cdot e^{\mathsf{neg}\left(x\right)} + -1 \cdot \left(x \cdot e^{\mathsf{neg}\left(x\right)}\right)\right)}{2} \]
        8. lower-fma.f64N/A

          \[\leadsto \frac{\left(e^{-x} + x \cdot e^{-x}\right) - \color{blue}{\mathsf{fma}\left(-1, e^{\mathsf{neg}\left(x\right)}, -1 \cdot \left(x \cdot e^{\mathsf{neg}\left(x\right)}\right)\right)}}{2} \]
        9. lower-exp.f64N/A

          \[\leadsto \frac{\left(e^{-x} + x \cdot e^{-x}\right) - \mathsf{fma}\left(-1, \color{blue}{e^{\mathsf{neg}\left(x\right)}}, -1 \cdot \left(x \cdot e^{\mathsf{neg}\left(x\right)}\right)\right)}{2} \]
        10. lower-neg.f64N/A

          \[\leadsto \frac{\left(e^{-x} + x \cdot e^{-x}\right) - \mathsf{fma}\left(-1, e^{\color{blue}{-x}}, -1 \cdot \left(x \cdot e^{\mathsf{neg}\left(x\right)}\right)\right)}{2} \]
        11. lower-*.f64N/A

          \[\leadsto \frac{\left(e^{-x} + x \cdot e^{-x}\right) - \mathsf{fma}\left(-1, e^{-x}, \color{blue}{-1 \cdot \left(x \cdot e^{\mathsf{neg}\left(x\right)}\right)}\right)}{2} \]
        12. lower-*.f64N/A

          \[\leadsto \frac{\left(e^{-x} + x \cdot e^{-x}\right) - \mathsf{fma}\left(-1, e^{-x}, -1 \cdot \color{blue}{\left(x \cdot e^{\mathsf{neg}\left(x\right)}\right)}\right)}{2} \]
        13. lower-exp.f64N/A

          \[\leadsto \frac{\left(e^{-x} + x \cdot e^{-x}\right) - \mathsf{fma}\left(-1, e^{-x}, -1 \cdot \left(x \cdot \color{blue}{e^{\mathsf{neg}\left(x\right)}}\right)\right)}{2} \]
        14. lower-neg.f6498.3

          \[\leadsto \frac{\left(e^{-x} + x \cdot e^{-x}\right) - \mathsf{fma}\left(-1, e^{-x}, -1 \cdot \left(x \cdot e^{\color{blue}{-x}}\right)\right)}{2} \]
      4. Applied rewrites98.3%

        \[\leadsto \frac{\color{blue}{\left(e^{-x} + x \cdot e^{-x}\right) - \mathsf{fma}\left(-1, e^{-x}, -1 \cdot \left(x \cdot e^{-x}\right)\right)}}{2} \]
      5. Step-by-step derivation
        1. Applied rewrites100.0%

          \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(e^{-x}, \left(x + 1\right) - -1, \frac{x}{e^{x}}\right)}}{2} \]

        if 1.9000000000000001e-14 < eps < 2.2999999999999999e203

        1. Initial program 100.0%

          \[\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2} \]
        2. Taylor expanded in eps around inf

          \[\leadsto \frac{\color{blue}{e^{\mathsf{neg}\left(x \cdot \left(1 - \varepsilon\right)\right)} - -1 \cdot e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}}}{2} \]
        3. Step-by-step derivation
          1. lower--.f64N/A

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

            \[\leadsto \frac{\color{blue}{e^{\mathsf{neg}\left(x \cdot \left(1 - \varepsilon\right)\right)}} - -1 \cdot e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}}{2} \]
          3. lower-neg.f64N/A

            \[\leadsto \frac{e^{\color{blue}{-x \cdot \left(1 - \varepsilon\right)}} - -1 \cdot e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}}{2} \]
          4. lower-*.f64N/A

            \[\leadsto \frac{e^{-\color{blue}{x \cdot \left(1 - \varepsilon\right)}} - -1 \cdot e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}}{2} \]
          5. lower--.f64N/A

            \[\leadsto \frac{e^{-x \cdot \color{blue}{\left(1 - \varepsilon\right)}} - -1 \cdot e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}}{2} \]
          6. lower-*.f64N/A

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

            \[\leadsto \frac{e^{-x \cdot \left(1 - \varepsilon\right)} - -1 \cdot \color{blue}{e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}}}{2} \]
          8. lower-neg.f64N/A

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

            \[\leadsto \frac{e^{-x \cdot \left(1 - \varepsilon\right)} - -1 \cdot e^{-\color{blue}{x \cdot \left(1 + \varepsilon\right)}}}{2} \]
          10. lower-+.f64100.0

            \[\leadsto \frac{e^{-x \cdot \left(1 - \varepsilon\right)} - -1 \cdot e^{-x \cdot \color{blue}{\left(1 + \varepsilon\right)}}}{2} \]
        4. Applied rewrites100.0%

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

          \[\leadsto \frac{\left(1 + x \cdot \left(\varepsilon - 1\right)\right) - \color{blue}{-1} \cdot e^{-x \cdot \left(1 + \varepsilon\right)}}{2} \]
        6. Step-by-step derivation
          1. Applied rewrites72.7%

            \[\leadsto \frac{\left(1 + x \cdot \left(\varepsilon - 1\right)\right) - \color{blue}{-1} \cdot e^{-x \cdot \left(1 + \varepsilon\right)}}{2} \]
          2. Taylor expanded in x around 0

            \[\leadsto \frac{1 - \color{blue}{-1} \cdot e^{-x \cdot \left(1 + \varepsilon\right)}}{2} \]
          3. Step-by-step derivation
            1. Applied rewrites78.1%

              \[\leadsto \frac{1 - \color{blue}{-1} \cdot e^{-x \cdot \left(1 + \varepsilon\right)}}{2} \]
            2. Step-by-step derivation
              1. Applied rewrites78.1%

                \[\leadsto \frac{\color{blue}{e^{-\mathsf{fma}\left(\varepsilon, x, x\right)} + 1}}{2} \]

              if 2.2999999999999999e203 < eps

              1. Initial program 100.0%

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

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

                  \[\leadsto \frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \color{blue}{\left(\frac{1}{\varepsilon} - 1\right)}}{2} \]
                2. lower-/.f6471.7

                  \[\leadsto \frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\color{blue}{\frac{1}{\varepsilon}} - 1\right)}{2} \]
              4. Applied rewrites71.7%

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

            Alternative 3: 76.5% accurate, 1.9× speedup?

            \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -11000000000000:\\ \;\;\;\;\frac{1 - -1 \cdot e^{-1 \cdot x}}{2}\\ \mathbf{elif}\;x \leq 0.32:\\ \;\;\;\;\frac{e^{-x \cdot \left(1 - \varepsilon\right)} - -1 \cdot 1}{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(1 + \frac{1}{\varepsilon}\right) - \left(\frac{1}{\varepsilon} - 1\right)}{2}\\ \end{array} \end{array} \]
            (FPCore (x eps)
             :precision binary64
             (if (<= x -11000000000000.0)
               (/ (- 1.0 (* -1.0 (exp (* -1.0 x)))) 2.0)
               (if (<= x 0.32)
                 (/ (- (exp (- (* x (- 1.0 eps)))) (* -1.0 1.0)) 2.0)
                 (/ (- (+ 1.0 (/ 1.0 eps)) (- (/ 1.0 eps) 1.0)) 2.0))))
            double code(double x, double eps) {
            	double tmp;
            	if (x <= -11000000000000.0) {
            		tmp = (1.0 - (-1.0 * exp((-1.0 * x)))) / 2.0;
            	} else if (x <= 0.32) {
            		tmp = (exp(-(x * (1.0 - eps))) - (-1.0 * 1.0)) / 2.0;
            	} else {
            		tmp = ((1.0 + (1.0 / eps)) - ((1.0 / eps) - 1.0)) / 2.0;
            	}
            	return tmp;
            }
            
            module fmin_fmax_functions
                implicit none
                private
                public fmax
                public fmin
            
                interface fmax
                    module procedure fmax88
                    module procedure fmax44
                    module procedure fmax84
                    module procedure fmax48
                end interface
                interface fmin
                    module procedure fmin88
                    module procedure fmin44
                    module procedure fmin84
                    module procedure fmin48
                end interface
            contains
                real(8) function fmax88(x, y) result (res)
                    real(8), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                end function
                real(4) function fmax44(x, y) result (res)
                    real(4), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                end function
                real(8) function fmax84(x, y) result(res)
                    real(8), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                end function
                real(8) function fmax48(x, y) result(res)
                    real(4), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                end function
                real(8) function fmin88(x, y) result (res)
                    real(8), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                end function
                real(4) function fmin44(x, y) result (res)
                    real(4), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                end function
                real(8) function fmin84(x, y) result(res)
                    real(8), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                end function
                real(8) function fmin48(x, y) result(res)
                    real(4), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                end function
            end module
            
            real(8) function code(x, eps)
            use fmin_fmax_functions
                real(8), intent (in) :: x
                real(8), intent (in) :: eps
                real(8) :: tmp
                if (x <= (-11000000000000.0d0)) then
                    tmp = (1.0d0 - ((-1.0d0) * exp(((-1.0d0) * x)))) / 2.0d0
                else if (x <= 0.32d0) then
                    tmp = (exp(-(x * (1.0d0 - eps))) - ((-1.0d0) * 1.0d0)) / 2.0d0
                else
                    tmp = ((1.0d0 + (1.0d0 / eps)) - ((1.0d0 / eps) - 1.0d0)) / 2.0d0
                end if
                code = tmp
            end function
            
            public static double code(double x, double eps) {
            	double tmp;
            	if (x <= -11000000000000.0) {
            		tmp = (1.0 - (-1.0 * Math.exp((-1.0 * x)))) / 2.0;
            	} else if (x <= 0.32) {
            		tmp = (Math.exp(-(x * (1.0 - eps))) - (-1.0 * 1.0)) / 2.0;
            	} else {
            		tmp = ((1.0 + (1.0 / eps)) - ((1.0 / eps) - 1.0)) / 2.0;
            	}
            	return tmp;
            }
            
            def code(x, eps):
            	tmp = 0
            	if x <= -11000000000000.0:
            		tmp = (1.0 - (-1.0 * math.exp((-1.0 * x)))) / 2.0
            	elif x <= 0.32:
            		tmp = (math.exp(-(x * (1.0 - eps))) - (-1.0 * 1.0)) / 2.0
            	else:
            		tmp = ((1.0 + (1.0 / eps)) - ((1.0 / eps) - 1.0)) / 2.0
            	return tmp
            
            function code(x, eps)
            	tmp = 0.0
            	if (x <= -11000000000000.0)
            		tmp = Float64(Float64(1.0 - Float64(-1.0 * exp(Float64(-1.0 * x)))) / 2.0);
            	elseif (x <= 0.32)
            		tmp = Float64(Float64(exp(Float64(-Float64(x * Float64(1.0 - eps)))) - Float64(-1.0 * 1.0)) / 2.0);
            	else
            		tmp = Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) - Float64(Float64(1.0 / eps) - 1.0)) / 2.0);
            	end
            	return tmp
            end
            
            function tmp_2 = code(x, eps)
            	tmp = 0.0;
            	if (x <= -11000000000000.0)
            		tmp = (1.0 - (-1.0 * exp((-1.0 * x)))) / 2.0;
            	elseif (x <= 0.32)
            		tmp = (exp(-(x * (1.0 - eps))) - (-1.0 * 1.0)) / 2.0;
            	else
            		tmp = ((1.0 + (1.0 / eps)) - ((1.0 / eps) - 1.0)) / 2.0;
            	end
            	tmp_2 = tmp;
            end
            
            code[x_, eps_] := If[LessEqual[x, -11000000000000.0], N[(N[(1.0 - N[(-1.0 * N[Exp[N[(-1.0 * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 0.32], N[(N[(N[Exp[(-N[(x * N[(1.0 - eps), $MachinePrecision]), $MachinePrecision])], $MachinePrecision] - N[(-1.0 * 1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] - N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
            
            \begin{array}{l}
            
            \\
            \begin{array}{l}
            \mathbf{if}\;x \leq -11000000000000:\\
            \;\;\;\;\frac{1 - -1 \cdot e^{-1 \cdot x}}{2}\\
            
            \mathbf{elif}\;x \leq 0.32:\\
            \;\;\;\;\frac{e^{-x \cdot \left(1 - \varepsilon\right)} - -1 \cdot 1}{2}\\
            
            \mathbf{else}:\\
            \;\;\;\;\frac{\left(1 + \frac{1}{\varepsilon}\right) - \left(\frac{1}{\varepsilon} - 1\right)}{2}\\
            
            
            \end{array}
            \end{array}
            
            Derivation
            1. Split input into 3 regimes
            2. if x < -1.1e13

              1. Initial program 100.0%

                \[\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2} \]
              2. Taylor expanded in eps around inf

                \[\leadsto \frac{\color{blue}{e^{\mathsf{neg}\left(x \cdot \left(1 - \varepsilon\right)\right)} - -1 \cdot e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}}}{2} \]
              3. Step-by-step derivation
                1. lower--.f64N/A

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

                  \[\leadsto \frac{\color{blue}{e^{\mathsf{neg}\left(x \cdot \left(1 - \varepsilon\right)\right)}} - -1 \cdot e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}}{2} \]
                3. lower-neg.f64N/A

                  \[\leadsto \frac{e^{\color{blue}{-x \cdot \left(1 - \varepsilon\right)}} - -1 \cdot e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}}{2} \]
                4. lower-*.f64N/A

                  \[\leadsto \frac{e^{-\color{blue}{x \cdot \left(1 - \varepsilon\right)}} - -1 \cdot e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}}{2} \]
                5. lower--.f64N/A

                  \[\leadsto \frac{e^{-x \cdot \color{blue}{\left(1 - \varepsilon\right)}} - -1 \cdot e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}}{2} \]
                6. lower-*.f64N/A

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

                  \[\leadsto \frac{e^{-x \cdot \left(1 - \varepsilon\right)} - -1 \cdot \color{blue}{e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}}}{2} \]
                8. lower-neg.f64N/A

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

                  \[\leadsto \frac{e^{-x \cdot \left(1 - \varepsilon\right)} - -1 \cdot e^{-\color{blue}{x \cdot \left(1 + \varepsilon\right)}}}{2} \]
                10. lower-+.f64100.0

                  \[\leadsto \frac{e^{-x \cdot \left(1 - \varepsilon\right)} - -1 \cdot e^{-x \cdot \color{blue}{\left(1 + \varepsilon\right)}}}{2} \]
              4. Applied rewrites100.0%

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

                \[\leadsto \frac{\left(1 + x \cdot \left(\varepsilon - 1\right)\right) - \color{blue}{-1} \cdot e^{-x \cdot \left(1 + \varepsilon\right)}}{2} \]
              6. Step-by-step derivation
                1. Applied rewrites59.3%

                  \[\leadsto \frac{\left(1 + x \cdot \left(\varepsilon - 1\right)\right) - \color{blue}{-1} \cdot e^{-x \cdot \left(1 + \varepsilon\right)}}{2} \]
                2. Taylor expanded in x around 0

                  \[\leadsto \frac{1 - \color{blue}{-1} \cdot e^{-x \cdot \left(1 + \varepsilon\right)}}{2} \]
                3. Step-by-step derivation
                  1. Applied rewrites61.8%

                    \[\leadsto \frac{1 - \color{blue}{-1} \cdot e^{-x \cdot \left(1 + \varepsilon\right)}}{2} \]
                  2. Taylor expanded in eps around 0

                    \[\leadsto \frac{1 - -1 \cdot e^{-1 \cdot x}}{2} \]
                  3. Step-by-step derivation
                    1. Applied rewrites100.0%

                      \[\leadsto \frac{1 - -1 \cdot e^{-1 \cdot x}}{2} \]

                    if -1.1e13 < x < 0.320000000000000007

                    1. Initial program 50.0%

                      \[\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2} \]
                    2. Taylor expanded in eps around inf

                      \[\leadsto \frac{\color{blue}{e^{\mathsf{neg}\left(x \cdot \left(1 - \varepsilon\right)\right)} - -1 \cdot e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}}}{2} \]
                    3. Step-by-step derivation
                      1. lower--.f64N/A

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

                        \[\leadsto \frac{\color{blue}{e^{\mathsf{neg}\left(x \cdot \left(1 - \varepsilon\right)\right)}} - -1 \cdot e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}}{2} \]
                      3. lower-neg.f64N/A

                        \[\leadsto \frac{e^{\color{blue}{-x \cdot \left(1 - \varepsilon\right)}} - -1 \cdot e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}}{2} \]
                      4. lower-*.f64N/A

                        \[\leadsto \frac{e^{-\color{blue}{x \cdot \left(1 - \varepsilon\right)}} - -1 \cdot e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}}{2} \]
                      5. lower--.f64N/A

                        \[\leadsto \frac{e^{-x \cdot \color{blue}{\left(1 - \varepsilon\right)}} - -1 \cdot e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}}{2} \]
                      6. lower-*.f64N/A

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

                        \[\leadsto \frac{e^{-x \cdot \left(1 - \varepsilon\right)} - -1 \cdot \color{blue}{e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}}}{2} \]
                      8. lower-neg.f64N/A

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

                        \[\leadsto \frac{e^{-x \cdot \left(1 - \varepsilon\right)} - -1 \cdot e^{-\color{blue}{x \cdot \left(1 + \varepsilon\right)}}}{2} \]
                      10. lower-+.f6497.6

                        \[\leadsto \frac{e^{-x \cdot \left(1 - \varepsilon\right)} - -1 \cdot e^{-x \cdot \color{blue}{\left(1 + \varepsilon\right)}}}{2} \]
                    4. Applied rewrites97.6%

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

                      \[\leadsto \frac{e^{-x \cdot \left(1 - \varepsilon\right)} - -1 \cdot 1}{2} \]
                    6. Step-by-step derivation
                      1. Applied rewrites89.6%

                        \[\leadsto \frac{e^{-x \cdot \left(1 - \varepsilon\right)} - -1 \cdot 1}{2} \]

                      if 0.320000000000000007 < x

                      1. Initial program 100.0%

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

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

                          \[\leadsto \frac{\color{blue}{\left(1 + \frac{1}{\varepsilon}\right)} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2} \]
                        2. lower-/.f6422.3

                          \[\leadsto \frac{\left(1 + \color{blue}{\frac{1}{\varepsilon}}\right) - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2} \]
                      4. Applied rewrites22.3%

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

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

                          \[\leadsto \frac{\left(1 + \frac{1}{\varepsilon}\right) - \color{blue}{\left(\frac{1}{\varepsilon} - 1\right)}}{2} \]
                        2. lower-/.f6457.3

                          \[\leadsto \frac{\left(1 + \frac{1}{\varepsilon}\right) - \left(\color{blue}{\frac{1}{\varepsilon}} - 1\right)}{2} \]
                      7. Applied rewrites57.3%

                        \[\leadsto \frac{\left(1 + \frac{1}{\varepsilon}\right) - \color{blue}{\left(\frac{1}{\varepsilon} - 1\right)}}{2} \]
                    7. Recombined 3 regimes into one program.
                    8. Add Preprocessing

                    Alternative 4: 76.2% accurate, 2.0× speedup?

                    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1.95 \cdot 10^{-7}:\\ \;\;\;\;\frac{1 - -1 \cdot e^{-1 \cdot x}}{2}\\ \mathbf{elif}\;x \leq 1.22 \cdot 10^{+16}:\\ \;\;\;\;\frac{e^{-\mathsf{fma}\left(\varepsilon, x, x\right)} + 1}{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(1 + \frac{1}{\varepsilon}\right) - \left(\frac{1}{\varepsilon} - 1\right)}{2}\\ \end{array} \end{array} \]
                    (FPCore (x eps)
                     :precision binary64
                     (if (<= x -1.95e-7)
                       (/ (- 1.0 (* -1.0 (exp (* -1.0 x)))) 2.0)
                       (if (<= x 1.22e+16)
                         (/ (+ (exp (- (fma eps x x))) 1.0) 2.0)
                         (/ (- (+ 1.0 (/ 1.0 eps)) (- (/ 1.0 eps) 1.0)) 2.0))))
                    double code(double x, double eps) {
                    	double tmp;
                    	if (x <= -1.95e-7) {
                    		tmp = (1.0 - (-1.0 * exp((-1.0 * x)))) / 2.0;
                    	} else if (x <= 1.22e+16) {
                    		tmp = (exp(-fma(eps, x, x)) + 1.0) / 2.0;
                    	} else {
                    		tmp = ((1.0 + (1.0 / eps)) - ((1.0 / eps) - 1.0)) / 2.0;
                    	}
                    	return tmp;
                    }
                    
                    function code(x, eps)
                    	tmp = 0.0
                    	if (x <= -1.95e-7)
                    		tmp = Float64(Float64(1.0 - Float64(-1.0 * exp(Float64(-1.0 * x)))) / 2.0);
                    	elseif (x <= 1.22e+16)
                    		tmp = Float64(Float64(exp(Float64(-fma(eps, x, x))) + 1.0) / 2.0);
                    	else
                    		tmp = Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) - Float64(Float64(1.0 / eps) - 1.0)) / 2.0);
                    	end
                    	return tmp
                    end
                    
                    code[x_, eps_] := If[LessEqual[x, -1.95e-7], N[(N[(1.0 - N[(-1.0 * N[Exp[N[(-1.0 * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 1.22e+16], N[(N[(N[Exp[(-N[(eps * x + x), $MachinePrecision])], $MachinePrecision] + 1.0), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] - N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
                    
                    \begin{array}{l}
                    
                    \\
                    \begin{array}{l}
                    \mathbf{if}\;x \leq -1.95 \cdot 10^{-7}:\\
                    \;\;\;\;\frac{1 - -1 \cdot e^{-1 \cdot x}}{2}\\
                    
                    \mathbf{elif}\;x \leq 1.22 \cdot 10^{+16}:\\
                    \;\;\;\;\frac{e^{-\mathsf{fma}\left(\varepsilon, x, x\right)} + 1}{2}\\
                    
                    \mathbf{else}:\\
                    \;\;\;\;\frac{\left(1 + \frac{1}{\varepsilon}\right) - \left(\frac{1}{\varepsilon} - 1\right)}{2}\\
                    
                    
                    \end{array}
                    \end{array}
                    
                    Derivation
                    1. Split input into 3 regimes
                    2. if x < -1.95000000000000012e-7

                      1. Initial program 93.1%

                        \[\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2} \]
                      2. Taylor expanded in eps around inf

                        \[\leadsto \frac{\color{blue}{e^{\mathsf{neg}\left(x \cdot \left(1 - \varepsilon\right)\right)} - -1 \cdot e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}}}{2} \]
                      3. Step-by-step derivation
                        1. lower--.f64N/A

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

                          \[\leadsto \frac{\color{blue}{e^{\mathsf{neg}\left(x \cdot \left(1 - \varepsilon\right)\right)}} - -1 \cdot e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}}{2} \]
                        3. lower-neg.f64N/A

                          \[\leadsto \frac{e^{\color{blue}{-x \cdot \left(1 - \varepsilon\right)}} - -1 \cdot e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}}{2} \]
                        4. lower-*.f64N/A

                          \[\leadsto \frac{e^{-\color{blue}{x \cdot \left(1 - \varepsilon\right)}} - -1 \cdot e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}}{2} \]
                        5. lower--.f64N/A

                          \[\leadsto \frac{e^{-x \cdot \color{blue}{\left(1 - \varepsilon\right)}} - -1 \cdot e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}}{2} \]
                        6. lower-*.f64N/A

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

                          \[\leadsto \frac{e^{-x \cdot \left(1 - \varepsilon\right)} - -1 \cdot \color{blue}{e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}}}{2} \]
                        8. lower-neg.f64N/A

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

                          \[\leadsto \frac{e^{-x \cdot \left(1 - \varepsilon\right)} - -1 \cdot e^{-\color{blue}{x \cdot \left(1 + \varepsilon\right)}}}{2} \]
                        10. lower-+.f6493.8

                          \[\leadsto \frac{e^{-x \cdot \left(1 - \varepsilon\right)} - -1 \cdot e^{-x \cdot \color{blue}{\left(1 + \varepsilon\right)}}}{2} \]
                      4. Applied rewrites93.8%

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

                        \[\leadsto \frac{\left(1 + x \cdot \left(\varepsilon - 1\right)\right) - \color{blue}{-1} \cdot e^{-x \cdot \left(1 + \varepsilon\right)}}{2} \]
                      6. Step-by-step derivation
                        1. Applied rewrites53.5%

                          \[\leadsto \frac{\left(1 + x \cdot \left(\varepsilon - 1\right)\right) - \color{blue}{-1} \cdot e^{-x \cdot \left(1 + \varepsilon\right)}}{2} \]
                        2. Taylor expanded in x around 0

                          \[\leadsto \frac{1 - \color{blue}{-1} \cdot e^{-x \cdot \left(1 + \varepsilon\right)}}{2} \]
                        3. Step-by-step derivation
                          1. Applied rewrites55.6%

                            \[\leadsto \frac{1 - \color{blue}{-1} \cdot e^{-x \cdot \left(1 + \varepsilon\right)}}{2} \]
                          2. Taylor expanded in eps around 0

                            \[\leadsto \frac{1 - -1 \cdot e^{-1 \cdot x}}{2} \]
                          3. Step-by-step derivation
                            1. Applied rewrites91.6%

                              \[\leadsto \frac{1 - -1 \cdot e^{-1 \cdot x}}{2} \]

                            if -1.95000000000000012e-7 < x < 1.22e16

                            1. Initial program 51.3%

                              \[\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2} \]
                            2. Taylor expanded in eps around inf

                              \[\leadsto \frac{\color{blue}{e^{\mathsf{neg}\left(x \cdot \left(1 - \varepsilon\right)\right)} - -1 \cdot e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}}}{2} \]
                            3. Step-by-step derivation
                              1. lower--.f64N/A

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

                                \[\leadsto \frac{\color{blue}{e^{\mathsf{neg}\left(x \cdot \left(1 - \varepsilon\right)\right)}} - -1 \cdot e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}}{2} \]
                              3. lower-neg.f64N/A

                                \[\leadsto \frac{e^{\color{blue}{-x \cdot \left(1 - \varepsilon\right)}} - -1 \cdot e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}}{2} \]
                              4. lower-*.f64N/A

                                \[\leadsto \frac{e^{-\color{blue}{x \cdot \left(1 - \varepsilon\right)}} - -1 \cdot e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}}{2} \]
                              5. lower--.f64N/A

                                \[\leadsto \frac{e^{-x \cdot \color{blue}{\left(1 - \varepsilon\right)}} - -1 \cdot e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}}{2} \]
                              6. lower-*.f64N/A

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

                                \[\leadsto \frac{e^{-x \cdot \left(1 - \varepsilon\right)} - -1 \cdot \color{blue}{e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}}}{2} \]
                              8. lower-neg.f64N/A

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

                                \[\leadsto \frac{e^{-x \cdot \left(1 - \varepsilon\right)} - -1 \cdot e^{-\color{blue}{x \cdot \left(1 + \varepsilon\right)}}}{2} \]
                              10. lower-+.f6499.3

                                \[\leadsto \frac{e^{-x \cdot \left(1 - \varepsilon\right)} - -1 \cdot e^{-x \cdot \color{blue}{\left(1 + \varepsilon\right)}}}{2} \]
                            4. Applied rewrites99.3%

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

                              \[\leadsto \frac{\left(1 + x \cdot \left(\varepsilon - 1\right)\right) - \color{blue}{-1} \cdot e^{-x \cdot \left(1 + \varepsilon\right)}}{2} \]
                            6. Step-by-step derivation
                              1. Applied rewrites86.4%

                                \[\leadsto \frac{\left(1 + x \cdot \left(\varepsilon - 1\right)\right) - \color{blue}{-1} \cdot e^{-x \cdot \left(1 + \varepsilon\right)}}{2} \]
                              2. Taylor expanded in x around 0

                                \[\leadsto \frac{1 - \color{blue}{-1} \cdot e^{-x \cdot \left(1 + \varepsilon\right)}}{2} \]
                              3. Step-by-step derivation
                                1. Applied rewrites86.2%

                                  \[\leadsto \frac{1 - \color{blue}{-1} \cdot e^{-x \cdot \left(1 + \varepsilon\right)}}{2} \]
                                2. Step-by-step derivation
                                  1. Applied rewrites86.2%

                                    \[\leadsto \frac{\color{blue}{e^{-\mathsf{fma}\left(\varepsilon, x, x\right)} + 1}}{2} \]

                                  if 1.22e16 < x

                                  1. Initial program 100.0%

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

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

                                      \[\leadsto \frac{\color{blue}{\left(1 + \frac{1}{\varepsilon}\right)} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2} \]
                                    2. lower-/.f6419.9

                                      \[\leadsto \frac{\left(1 + \color{blue}{\frac{1}{\varepsilon}}\right) - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2} \]
                                  4. Applied rewrites19.9%

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

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

                                      \[\leadsto \frac{\left(1 + \frac{1}{\varepsilon}\right) - \color{blue}{\left(\frac{1}{\varepsilon} - 1\right)}}{2} \]
                                    2. lower-/.f6458.5

                                      \[\leadsto \frac{\left(1 + \frac{1}{\varepsilon}\right) - \left(\color{blue}{\frac{1}{\varepsilon}} - 1\right)}{2} \]
                                  7. Applied rewrites58.5%

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

                                Alternative 5: 69.4% accurate, 2.1× speedup?

                                \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 1.22 \cdot 10^{+16}:\\ \;\;\;\;\frac{e^{-\mathsf{fma}\left(\varepsilon, x, x\right)} + 1}{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(1 + \frac{1}{\varepsilon}\right) - \left(\frac{1}{\varepsilon} - 1\right)}{2}\\ \end{array} \end{array} \]
                                (FPCore (x eps)
                                 :precision binary64
                                 (if (<= x 1.22e+16)
                                   (/ (+ (exp (- (fma eps x x))) 1.0) 2.0)
                                   (/ (- (+ 1.0 (/ 1.0 eps)) (- (/ 1.0 eps) 1.0)) 2.0)))
                                double code(double x, double eps) {
                                	double tmp;
                                	if (x <= 1.22e+16) {
                                		tmp = (exp(-fma(eps, x, x)) + 1.0) / 2.0;
                                	} else {
                                		tmp = ((1.0 + (1.0 / eps)) - ((1.0 / eps) - 1.0)) / 2.0;
                                	}
                                	return tmp;
                                }
                                
                                function code(x, eps)
                                	tmp = 0.0
                                	if (x <= 1.22e+16)
                                		tmp = Float64(Float64(exp(Float64(-fma(eps, x, x))) + 1.0) / 2.0);
                                	else
                                		tmp = Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) - Float64(Float64(1.0 / eps) - 1.0)) / 2.0);
                                	end
                                	return tmp
                                end
                                
                                code[x_, eps_] := If[LessEqual[x, 1.22e+16], N[(N[(N[Exp[(-N[(eps * x + x), $MachinePrecision])], $MachinePrecision] + 1.0), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] - N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]
                                
                                \begin{array}{l}
                                
                                \\
                                \begin{array}{l}
                                \mathbf{if}\;x \leq 1.22 \cdot 10^{+16}:\\
                                \;\;\;\;\frac{e^{-\mathsf{fma}\left(\varepsilon, x, x\right)} + 1}{2}\\
                                
                                \mathbf{else}:\\
                                \;\;\;\;\frac{\left(1 + \frac{1}{\varepsilon}\right) - \left(\frac{1}{\varepsilon} - 1\right)}{2}\\
                                
                                
                                \end{array}
                                \end{array}
                                
                                Derivation
                                1. Split input into 2 regimes
                                2. if x < 1.22e16

                                  1. Initial program 60.3%

                                    \[\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2} \]
                                  2. Taylor expanded in eps around inf

                                    \[\leadsto \frac{\color{blue}{e^{\mathsf{neg}\left(x \cdot \left(1 - \varepsilon\right)\right)} - -1 \cdot e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}}}{2} \]
                                  3. Step-by-step derivation
                                    1. lower--.f64N/A

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

                                      \[\leadsto \frac{\color{blue}{e^{\mathsf{neg}\left(x \cdot \left(1 - \varepsilon\right)\right)}} - -1 \cdot e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}}{2} \]
                                    3. lower-neg.f64N/A

                                      \[\leadsto \frac{e^{\color{blue}{-x \cdot \left(1 - \varepsilon\right)}} - -1 \cdot e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}}{2} \]
                                    4. lower-*.f64N/A

                                      \[\leadsto \frac{e^{-\color{blue}{x \cdot \left(1 - \varepsilon\right)}} - -1 \cdot e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}}{2} \]
                                    5. lower--.f64N/A

                                      \[\leadsto \frac{e^{-x \cdot \color{blue}{\left(1 - \varepsilon\right)}} - -1 \cdot e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}}{2} \]
                                    6. lower-*.f64N/A

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

                                      \[\leadsto \frac{e^{-x \cdot \left(1 - \varepsilon\right)} - -1 \cdot \color{blue}{e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}}}{2} \]
                                    8. lower-neg.f64N/A

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

                                      \[\leadsto \frac{e^{-x \cdot \left(1 - \varepsilon\right)} - -1 \cdot e^{-\color{blue}{x \cdot \left(1 + \varepsilon\right)}}}{2} \]
                                    10. lower-+.f6498.1

                                      \[\leadsto \frac{e^{-x \cdot \left(1 - \varepsilon\right)} - -1 \cdot e^{-x \cdot \color{blue}{\left(1 + \varepsilon\right)}}}{2} \]
                                  4. Applied rewrites98.1%

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

                                    \[\leadsto \frac{\left(1 + x \cdot \left(\varepsilon - 1\right)\right) - \color{blue}{-1} \cdot e^{-x \cdot \left(1 + \varepsilon\right)}}{2} \]
                                  6. Step-by-step derivation
                                    1. Applied rewrites79.3%

                                      \[\leadsto \frac{\left(1 + x \cdot \left(\varepsilon - 1\right)\right) - \color{blue}{-1} \cdot e^{-x \cdot \left(1 + \varepsilon\right)}}{2} \]
                                    2. Taylor expanded in x around 0

                                      \[\leadsto \frac{1 - \color{blue}{-1} \cdot e^{-x \cdot \left(1 + \varepsilon\right)}}{2} \]
                                    3. Step-by-step derivation
                                      1. Applied rewrites79.6%

                                        \[\leadsto \frac{1 - \color{blue}{-1} \cdot e^{-x \cdot \left(1 + \varepsilon\right)}}{2} \]
                                      2. Step-by-step derivation
                                        1. Applied rewrites79.6%

                                          \[\leadsto \frac{\color{blue}{e^{-\mathsf{fma}\left(\varepsilon, x, x\right)} + 1}}{2} \]

                                        if 1.22e16 < x

                                        1. Initial program 100.0%

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

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

                                            \[\leadsto \frac{\color{blue}{\left(1 + \frac{1}{\varepsilon}\right)} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2} \]
                                          2. lower-/.f6419.9

                                            \[\leadsto \frac{\left(1 + \color{blue}{\frac{1}{\varepsilon}}\right) - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2} \]
                                        4. Applied rewrites19.9%

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

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

                                            \[\leadsto \frac{\left(1 + \frac{1}{\varepsilon}\right) - \color{blue}{\left(\frac{1}{\varepsilon} - 1\right)}}{2} \]
                                          2. lower-/.f6458.5

                                            \[\leadsto \frac{\left(1 + \frac{1}{\varepsilon}\right) - \left(\color{blue}{\frac{1}{\varepsilon}} - 1\right)}{2} \]
                                        7. Applied rewrites58.5%

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

                                      Alternative 6: 58.7% accurate, 5.6× speedup?

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

                                        1. Initial program 59.8%

                                          \[\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2} \]
                                        2. Taylor expanded in eps around inf

                                          \[\leadsto \frac{\color{blue}{e^{\mathsf{neg}\left(x \cdot \left(1 - \varepsilon\right)\right)} - -1 \cdot e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}}}{2} \]
                                        3. Step-by-step derivation
                                          1. lower--.f64N/A

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

                                            \[\leadsto \frac{\color{blue}{e^{\mathsf{neg}\left(x \cdot \left(1 - \varepsilon\right)\right)}} - -1 \cdot e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}}{2} \]
                                          3. lower-neg.f64N/A

                                            \[\leadsto \frac{e^{\color{blue}{-x \cdot \left(1 - \varepsilon\right)}} - -1 \cdot e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}}{2} \]
                                          4. lower-*.f64N/A

                                            \[\leadsto \frac{e^{-\color{blue}{x \cdot \left(1 - \varepsilon\right)}} - -1 \cdot e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}}{2} \]
                                          5. lower--.f64N/A

                                            \[\leadsto \frac{e^{-x \cdot \color{blue}{\left(1 - \varepsilon\right)}} - -1 \cdot e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}}{2} \]
                                          6. lower-*.f64N/A

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

                                            \[\leadsto \frac{e^{-x \cdot \left(1 - \varepsilon\right)} - -1 \cdot \color{blue}{e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}}}{2} \]
                                          8. lower-neg.f64N/A

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

                                            \[\leadsto \frac{e^{-x \cdot \left(1 - \varepsilon\right)} - -1 \cdot e^{-\color{blue}{x \cdot \left(1 + \varepsilon\right)}}}{2} \]
                                          10. lower-+.f6498.1

                                            \[\leadsto \frac{e^{-x \cdot \left(1 - \varepsilon\right)} - -1 \cdot e^{-x \cdot \color{blue}{\left(1 + \varepsilon\right)}}}{2} \]
                                        4. Applied rewrites98.1%

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

                                          \[\leadsto \frac{\left(1 + x \cdot \left(\varepsilon - 1\right)\right) - \color{blue}{-1} \cdot e^{-x \cdot \left(1 + \varepsilon\right)}}{2} \]
                                        6. Step-by-step derivation
                                          1. Applied rewrites79.6%

                                            \[\leadsto \frac{\left(1 + x \cdot \left(\varepsilon - 1\right)\right) - \color{blue}{-1} \cdot e^{-x \cdot \left(1 + \varepsilon\right)}}{2} \]
                                          2. Taylor expanded in x around 0

                                            \[\leadsto \frac{1 - \color{blue}{-1} \cdot e^{-x \cdot \left(1 + \varepsilon\right)}}{2} \]
                                          3. Step-by-step derivation
                                            1. Applied rewrites79.9%

                                              \[\leadsto \frac{1 - \color{blue}{-1} \cdot e^{-x \cdot \left(1 + \varepsilon\right)}}{2} \]
                                            2. Taylor expanded in x around 0

                                              \[\leadsto \frac{1 - -1 \cdot \left(1 + \color{blue}{-1 \cdot \left(x \cdot \left(1 + \varepsilon\right)\right)}\right)}{2} \]
                                            3. Step-by-step derivation
                                              1. Applied rewrites66.0%

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

                                              if 2 < x

                                              1. Initial program 100.0%

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

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

                                                  \[\leadsto \frac{\color{blue}{\left(1 + \frac{1}{\varepsilon}\right)} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2} \]
                                                2. lower-/.f6421.0

                                                  \[\leadsto \frac{\left(1 + \color{blue}{\frac{1}{\varepsilon}}\right) - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2} \]
                                              4. Applied rewrites21.0%

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

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

                                                  \[\leadsto \frac{\left(1 + \frac{1}{\varepsilon}\right) - \color{blue}{\left(\frac{1}{\varepsilon} - 1\right)}}{2} \]
                                                2. lower-/.f6458.2

                                                  \[\leadsto \frac{\left(1 + \frac{1}{\varepsilon}\right) - \left(\color{blue}{\frac{1}{\varepsilon}} - 1\right)}{2} \]
                                              7. Applied rewrites58.2%

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

                                            Alternative 7: 58.7% accurate, 5.9× speedup?

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

                                              1. Initial program 59.8%

                                                \[\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2} \]
                                              2. Taylor expanded in eps around inf

                                                \[\leadsto \frac{\color{blue}{e^{\mathsf{neg}\left(x \cdot \left(1 - \varepsilon\right)\right)} - -1 \cdot e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}}}{2} \]
                                              3. Step-by-step derivation
                                                1. lower--.f64N/A

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

                                                  \[\leadsto \frac{\color{blue}{e^{\mathsf{neg}\left(x \cdot \left(1 - \varepsilon\right)\right)}} - -1 \cdot e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}}{2} \]
                                                3. lower-neg.f64N/A

                                                  \[\leadsto \frac{e^{\color{blue}{-x \cdot \left(1 - \varepsilon\right)}} - -1 \cdot e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}}{2} \]
                                                4. lower-*.f64N/A

                                                  \[\leadsto \frac{e^{-\color{blue}{x \cdot \left(1 - \varepsilon\right)}} - -1 \cdot e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}}{2} \]
                                                5. lower--.f64N/A

                                                  \[\leadsto \frac{e^{-x \cdot \color{blue}{\left(1 - \varepsilon\right)}} - -1 \cdot e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}}{2} \]
                                                6. lower-*.f64N/A

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

                                                  \[\leadsto \frac{e^{-x \cdot \left(1 - \varepsilon\right)} - -1 \cdot \color{blue}{e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}}}{2} \]
                                                8. lower-neg.f64N/A

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

                                                  \[\leadsto \frac{e^{-x \cdot \left(1 - \varepsilon\right)} - -1 \cdot e^{-\color{blue}{x \cdot \left(1 + \varepsilon\right)}}}{2} \]
                                                10. lower-+.f6498.1

                                                  \[\leadsto \frac{e^{-x \cdot \left(1 - \varepsilon\right)} - -1 \cdot e^{-x \cdot \color{blue}{\left(1 + \varepsilon\right)}}}{2} \]
                                              4. Applied rewrites98.1%

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

                                                \[\leadsto \frac{\left(1 + x \cdot \left(\varepsilon - 1\right)\right) - \color{blue}{-1} \cdot e^{-x \cdot \left(1 + \varepsilon\right)}}{2} \]
                                              6. Step-by-step derivation
                                                1. Applied rewrites79.6%

                                                  \[\leadsto \frac{\left(1 + x \cdot \left(\varepsilon - 1\right)\right) - \color{blue}{-1} \cdot e^{-x \cdot \left(1 + \varepsilon\right)}}{2} \]
                                                2. Taylor expanded in x around 0

                                                  \[\leadsto \frac{1 - \color{blue}{-1} \cdot e^{-x \cdot \left(1 + \varepsilon\right)}}{2} \]
                                                3. Step-by-step derivation
                                                  1. Applied rewrites79.9%

                                                    \[\leadsto \frac{1 - \color{blue}{-1} \cdot e^{-x \cdot \left(1 + \varepsilon\right)}}{2} \]
                                                  2. Taylor expanded in x around 0

                                                    \[\leadsto \frac{1 - -1 \cdot \left(1 + \color{blue}{-1 \cdot \left(x \cdot \left(1 + \varepsilon\right)\right)}\right)}{2} \]
                                                  3. Step-by-step derivation
                                                    1. Applied rewrites66.0%

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

                                                    if 2 < x

                                                    1. Initial program 100.0%

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

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

                                                        \[\leadsto \frac{\color{blue}{\left(1 + \frac{1}{\varepsilon}\right)} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2} \]
                                                      2. lower-/.f6421.0

                                                        \[\leadsto \frac{\left(1 + \color{blue}{\frac{1}{\varepsilon}}\right) - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2} \]
                                                    4. Applied rewrites21.0%

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

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

                                                        \[\leadsto \frac{\left(1 + \frac{1}{\varepsilon}\right) - \color{blue}{\left(\frac{1}{\varepsilon} - 1\right)}}{2} \]
                                                      2. lower-/.f6458.2

                                                        \[\leadsto \frac{\left(1 + \frac{1}{\varepsilon}\right) - \left(\color{blue}{\frac{1}{\varepsilon}} - 1\right)}{2} \]
                                                    7. Applied rewrites58.2%

                                                      \[\leadsto \frac{\left(1 + \frac{1}{\varepsilon}\right) - \color{blue}{\left(\frac{1}{\varepsilon} - 1\right)}}{2} \]
                                                    8. Taylor expanded in eps around 0

                                                      \[\leadsto \frac{\frac{1}{\color{blue}{\varepsilon}} - \left(\frac{1}{\varepsilon} - 1\right)}{2} \]
                                                    9. Step-by-step derivation
                                                      1. Applied rewrites58.2%

                                                        \[\leadsto \frac{\frac{1}{\color{blue}{\varepsilon}} - \left(\frac{1}{\varepsilon} - 1\right)}{2} \]
                                                    10. Recombined 2 regimes into one program.
                                                    11. Add Preprocessing

                                                    Alternative 8: 49.5% accurate, 6.3× speedup?

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

                                                      1. Initial program 100.0%

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

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

                                                          \[\leadsto \frac{\color{blue}{\left(1 + \frac{1}{\varepsilon}\right)} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2} \]
                                                        2. lower-/.f6451.0

                                                          \[\leadsto \frac{\left(1 + \color{blue}{\frac{1}{\varepsilon}}\right) - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2} \]
                                                      4. Applied rewrites51.0%

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

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

                                                          \[\leadsto \frac{\left(1 + \frac{1}{\varepsilon}\right) - \color{blue}{\left(\frac{1}{\varepsilon} - 1\right)}}{2} \]
                                                        2. lower-/.f6424.9

                                                          \[\leadsto \frac{\left(1 + \frac{1}{\varepsilon}\right) - \left(\color{blue}{\frac{1}{\varepsilon}} - 1\right)}{2} \]
                                                      7. Applied rewrites24.9%

                                                        \[\leadsto \frac{\left(1 + \frac{1}{\varepsilon}\right) - \color{blue}{\left(\frac{1}{\varepsilon} - 1\right)}}{2} \]
                                                      8. Taylor expanded in x around 0

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

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

                                                          \[\leadsto \frac{\left(1 + \color{blue}{\mathsf{fma}\left(x, \left(1 + \frac{1}{\varepsilon}\right) \cdot \left(\varepsilon - 1\right), \frac{1}{\varepsilon}\right)}\right) - \left(\frac{1}{\varepsilon} - 1\right)}{2} \]
                                                        3. lower-*.f64N/A

                                                          \[\leadsto \frac{\left(1 + \mathsf{fma}\left(x, \color{blue}{\left(1 + \frac{1}{\varepsilon}\right) \cdot \left(\varepsilon - 1\right)}, \frac{1}{\varepsilon}\right)\right) - \left(\frac{1}{\varepsilon} - 1\right)}{2} \]
                                                        4. lower-+.f64N/A

                                                          \[\leadsto \frac{\left(1 + \mathsf{fma}\left(x, \color{blue}{\left(1 + \frac{1}{\varepsilon}\right)} \cdot \left(\varepsilon - 1\right), \frac{1}{\varepsilon}\right)\right) - \left(\frac{1}{\varepsilon} - 1\right)}{2} \]
                                                        5. lower-/.f64N/A

                                                          \[\leadsto \frac{\left(1 + \mathsf{fma}\left(x, \left(1 + \color{blue}{\frac{1}{\varepsilon}}\right) \cdot \left(\varepsilon - 1\right), \frac{1}{\varepsilon}\right)\right) - \left(\frac{1}{\varepsilon} - 1\right)}{2} \]
                                                        6. lower--.f64N/A

                                                          \[\leadsto \frac{\left(1 + \mathsf{fma}\left(x, \left(1 + \frac{1}{\varepsilon}\right) \cdot \color{blue}{\left(\varepsilon - 1\right)}, \frac{1}{\varepsilon}\right)\right) - \left(\frac{1}{\varepsilon} - 1\right)}{2} \]
                                                        7. lower-/.f6443.8

                                                          \[\leadsto \frac{\left(1 + \mathsf{fma}\left(x, \left(1 + \frac{1}{\varepsilon}\right) \cdot \left(\varepsilon - 1\right), \color{blue}{\frac{1}{\varepsilon}}\right)\right) - \left(\frac{1}{\varepsilon} - 1\right)}{2} \]
                                                      10. Applied rewrites43.8%

                                                        \[\leadsto \frac{\color{blue}{\left(1 + \mathsf{fma}\left(x, \left(1 + \frac{1}{\varepsilon}\right) \cdot \left(\varepsilon - 1\right), \frac{1}{\varepsilon}\right)\right)} - \left(\frac{1}{\varepsilon} - 1\right)}{2} \]
                                                      11. Taylor expanded in eps around inf

                                                        \[\leadsto \frac{\left(1 + \varepsilon \cdot \color{blue}{x}\right) - \left(\frac{1}{\varepsilon} - 1\right)}{2} \]
                                                      12. Step-by-step derivation
                                                        1. Applied rewrites43.8%

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

                                                        if -1.60000000000000006e122 < eps

                                                        1. Initial program 63.2%

                                                          \[\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2} \]
                                                        2. Taylor expanded in eps around inf

                                                          \[\leadsto \frac{\color{blue}{e^{\mathsf{neg}\left(x \cdot \left(1 - \varepsilon\right)\right)} - -1 \cdot e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}}}{2} \]
                                                        3. Step-by-step derivation
                                                          1. lower--.f64N/A

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

                                                            \[\leadsto \frac{\color{blue}{e^{\mathsf{neg}\left(x \cdot \left(1 - \varepsilon\right)\right)}} - -1 \cdot e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}}{2} \]
                                                          3. lower-neg.f64N/A

                                                            \[\leadsto \frac{e^{\color{blue}{-x \cdot \left(1 - \varepsilon\right)}} - -1 \cdot e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}}{2} \]
                                                          4. lower-*.f64N/A

                                                            \[\leadsto \frac{e^{-\color{blue}{x \cdot \left(1 - \varepsilon\right)}} - -1 \cdot e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}}{2} \]
                                                          5. lower--.f64N/A

                                                            \[\leadsto \frac{e^{-x \cdot \color{blue}{\left(1 - \varepsilon\right)}} - -1 \cdot e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}}{2} \]
                                                          6. lower-*.f64N/A

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

                                                            \[\leadsto \frac{e^{-x \cdot \left(1 - \varepsilon\right)} - -1 \cdot \color{blue}{e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}}}{2} \]
                                                          8. lower-neg.f64N/A

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

                                                            \[\leadsto \frac{e^{-x \cdot \left(1 - \varepsilon\right)} - -1 \cdot e^{-\color{blue}{x \cdot \left(1 + \varepsilon\right)}}}{2} \]
                                                          10. lower-+.f6498.2

                                                            \[\leadsto \frac{e^{-x \cdot \left(1 - \varepsilon\right)} - -1 \cdot e^{-x \cdot \color{blue}{\left(1 + \varepsilon\right)}}}{2} \]
                                                        4. Applied rewrites98.2%

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

                                                          \[\leadsto \frac{\left(1 + x \cdot \left(\varepsilon - 1\right)\right) - \color{blue}{-1} \cdot e^{-x \cdot \left(1 + \varepsilon\right)}}{2} \]
                                                        6. Step-by-step derivation
                                                          1. Applied rewrites69.0%

                                                            \[\leadsto \frac{\left(1 + x \cdot \left(\varepsilon - 1\right)\right) - \color{blue}{-1} \cdot e^{-x \cdot \left(1 + \varepsilon\right)}}{2} \]
                                                          2. Taylor expanded in x around 0

                                                            \[\leadsto \frac{1 - \color{blue}{-1} \cdot e^{-x \cdot \left(1 + \varepsilon\right)}}{2} \]
                                                          3. Step-by-step derivation
                                                            1. Applied rewrites69.6%

                                                              \[\leadsto \frac{1 - \color{blue}{-1} \cdot e^{-x \cdot \left(1 + \varepsilon\right)}}{2} \]
                                                            2. Taylor expanded in x around 0

                                                              \[\leadsto \frac{1 - -1 \cdot \left(1 + \color{blue}{-1 \cdot \left(x \cdot \left(1 + \varepsilon\right)\right)}\right)}{2} \]
                                                            3. Step-by-step derivation
                                                              1. Applied rewrites57.2%

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

                                                            Alternative 9: 49.3% accurate, 7.6× speedup?

                                                            \[\begin{array}{l} \\ \frac{1 - -1 \cdot \left(1 + -1 \cdot \left(x \cdot \left(1 + \varepsilon\right)\right)\right)}{2} \end{array} \]
                                                            (FPCore (x eps)
                                                             :precision binary64
                                                             (/ (- 1.0 (* -1.0 (+ 1.0 (* -1.0 (* x (+ 1.0 eps)))))) 2.0))
                                                            double code(double x, double eps) {
                                                            	return (1.0 - (-1.0 * (1.0 + (-1.0 * (x * (1.0 + eps)))))) / 2.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(x, eps)
                                                            use fmin_fmax_functions
                                                                real(8), intent (in) :: x
                                                                real(8), intent (in) :: eps
                                                                code = (1.0d0 - ((-1.0d0) * (1.0d0 + ((-1.0d0) * (x * (1.0d0 + eps)))))) / 2.0d0
                                                            end function
                                                            
                                                            public static double code(double x, double eps) {
                                                            	return (1.0 - (-1.0 * (1.0 + (-1.0 * (x * (1.0 + eps)))))) / 2.0;
                                                            }
                                                            
                                                            def code(x, eps):
                                                            	return (1.0 - (-1.0 * (1.0 + (-1.0 * (x * (1.0 + eps)))))) / 2.0
                                                            
                                                            function code(x, eps)
                                                            	return Float64(Float64(1.0 - Float64(-1.0 * Float64(1.0 + Float64(-1.0 * Float64(x * Float64(1.0 + eps)))))) / 2.0)
                                                            end
                                                            
                                                            function tmp = code(x, eps)
                                                            	tmp = (1.0 - (-1.0 * (1.0 + (-1.0 * (x * (1.0 + eps)))))) / 2.0;
                                                            end
                                                            
                                                            code[x_, eps_] := N[(N[(1.0 - N[(-1.0 * N[(1.0 + N[(-1.0 * N[(x * N[(1.0 + eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
                                                            
                                                            \begin{array}{l}
                                                            
                                                            \\
                                                            \frac{1 - -1 \cdot \left(1 + -1 \cdot \left(x \cdot \left(1 + \varepsilon\right)\right)\right)}{2}
                                                            \end{array}
                                                            
                                                            Derivation
                                                            1. Initial program 68.9%

                                                              \[\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2} \]
                                                            2. Taylor expanded in eps around inf

                                                              \[\leadsto \frac{\color{blue}{e^{\mathsf{neg}\left(x \cdot \left(1 - \varepsilon\right)\right)} - -1 \cdot e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}}}{2} \]
                                                            3. Step-by-step derivation
                                                              1. lower--.f64N/A

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

                                                                \[\leadsto \frac{\color{blue}{e^{\mathsf{neg}\left(x \cdot \left(1 - \varepsilon\right)\right)}} - -1 \cdot e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}}{2} \]
                                                              3. lower-neg.f64N/A

                                                                \[\leadsto \frac{e^{\color{blue}{-x \cdot \left(1 - \varepsilon\right)}} - -1 \cdot e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}}{2} \]
                                                              4. lower-*.f64N/A

                                                                \[\leadsto \frac{e^{-\color{blue}{x \cdot \left(1 - \varepsilon\right)}} - -1 \cdot e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}}{2} \]
                                                              5. lower--.f64N/A

                                                                \[\leadsto \frac{e^{-x \cdot \color{blue}{\left(1 - \varepsilon\right)}} - -1 \cdot e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}}{2} \]
                                                              6. lower-*.f64N/A

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

                                                                \[\leadsto \frac{e^{-x \cdot \left(1 - \varepsilon\right)} - -1 \cdot \color{blue}{e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}}}{2} \]
                                                              8. lower-neg.f64N/A

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

                                                                \[\leadsto \frac{e^{-x \cdot \left(1 - \varepsilon\right)} - -1 \cdot e^{-\color{blue}{x \cdot \left(1 + \varepsilon\right)}}}{2} \]
                                                              10. lower-+.f6498.5

                                                                \[\leadsto \frac{e^{-x \cdot \left(1 - \varepsilon\right)} - -1 \cdot e^{-x \cdot \color{blue}{\left(1 + \varepsilon\right)}}}{2} \]
                                                            4. Applied rewrites98.5%

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

                                                              \[\leadsto \frac{\left(1 + x \cdot \left(\varepsilon - 1\right)\right) - \color{blue}{-1} \cdot e^{-x \cdot \left(1 + \varepsilon\right)}}{2} \]
                                                            6. Step-by-step derivation
                                                              1. Applied rewrites68.7%

                                                                \[\leadsto \frac{\left(1 + x \cdot \left(\varepsilon - 1\right)\right) - \color{blue}{-1} \cdot e^{-x \cdot \left(1 + \varepsilon\right)}}{2} \]
                                                              2. Taylor expanded in x around 0

                                                                \[\leadsto \frac{1 - \color{blue}{-1} \cdot e^{-x \cdot \left(1 + \varepsilon\right)}}{2} \]
                                                              3. Step-by-step derivation
                                                                1. Applied rewrites66.7%

                                                                  \[\leadsto \frac{1 - \color{blue}{-1} \cdot e^{-x \cdot \left(1 + \varepsilon\right)}}{2} \]
                                                                2. Taylor expanded in x around 0

                                                                  \[\leadsto \frac{1 - -1 \cdot \left(1 + \color{blue}{-1 \cdot \left(x \cdot \left(1 + \varepsilon\right)\right)}\right)}{2} \]
                                                                3. Step-by-step derivation
                                                                  1. Applied rewrites52.7%

                                                                    \[\leadsto \frac{1 - -1 \cdot \left(1 + \color{blue}{-1 \cdot \left(x \cdot \left(1 + \varepsilon\right)\right)}\right)}{2} \]
                                                                  2. Add Preprocessing

                                                                  Alternative 10: 43.6% accurate, 22.8× speedup?

                                                                  \[\begin{array}{l} \\ \frac{2}{2} \end{array} \]
                                                                  (FPCore (x eps) :precision binary64 (/ 2.0 2.0))
                                                                  double code(double x, double eps) {
                                                                  	return 2.0 / 2.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(x, eps)
                                                                  use fmin_fmax_functions
                                                                      real(8), intent (in) :: x
                                                                      real(8), intent (in) :: eps
                                                                      code = 2.0d0 / 2.0d0
                                                                  end function
                                                                  
                                                                  public static double code(double x, double eps) {
                                                                  	return 2.0 / 2.0;
                                                                  }
                                                                  
                                                                  def code(x, eps):
                                                                  	return 2.0 / 2.0
                                                                  
                                                                  function code(x, eps)
                                                                  	return Float64(2.0 / 2.0)
                                                                  end
                                                                  
                                                                  function tmp = code(x, eps)
                                                                  	tmp = 2.0 / 2.0;
                                                                  end
                                                                  
                                                                  code[x_, eps_] := N[(2.0 / 2.0), $MachinePrecision]
                                                                  
                                                                  \begin{array}{l}
                                                                  
                                                                  \\
                                                                  \frac{2}{2}
                                                                  \end{array}
                                                                  
                                                                  Derivation
                                                                  1. Initial program 68.9%

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

                                                                    \[\leadsto \frac{\color{blue}{2}}{2} \]
                                                                  3. Step-by-step derivation
                                                                    1. Applied rewrites48.8%

                                                                      \[\leadsto \frac{\color{blue}{2}}{2} \]
                                                                    2. Add Preprocessing

                                                                    Reproduce

                                                                    ?
                                                                    herbie shell --seed 2024363 -o localize:costs -o setup:simplify -o generate:simplify
                                                                    (FPCore (x eps)
                                                                      :name "NMSE Section 6.1 mentioned, A"
                                                                      :precision binary64
                                                                      (/ (- (* (+ 1.0 (/ 1.0 eps)) (exp (- (* (- 1.0 eps) x)))) (* (- (/ 1.0 eps) 1.0) (exp (- (* (+ 1.0 eps) x))))) 2.0))