NMSE Section 6.1 mentioned, A

Percentage Accurate: 73.1% → 99.0%
Time: 5.3s
Alternatives: 7
Speedup: 2.2×

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}

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 7 alternatives:

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

Initial Program: 73.1% 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: 99.0% accurate, 1.5× speedup?

\[\begin{array}{l} eps_m = \left|\varepsilon\right| \\ \begin{array}{l} \mathbf{if}\;eps\_m \leq 2 \cdot 10^{-113}:\\ \;\;\;\;\frac{2}{e^{x}} \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;\left(e^{-eps\_m \cdot x} + e^{\left(eps\_m - 1\right) \cdot x}\right) \cdot 0.5\\ \end{array} \end{array} \]
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
 :precision binary64
 (if (<= eps_m 2e-113)
   (* (/ 2.0 (exp x)) 0.5)
   (* (+ (exp (- (* eps_m x))) (exp (* (- eps_m 1.0) x))) 0.5)))
eps_m = fabs(eps);
double code(double x, double eps_m) {
	double tmp;
	if (eps_m <= 2e-113) {
		tmp = (2.0 / exp(x)) * 0.5;
	} else {
		tmp = (exp(-(eps_m * x)) + exp(((eps_m - 1.0) * x))) * 0.5;
	}
	return tmp;
}
eps_m =     private
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_m)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: eps_m
    real(8) :: tmp
    if (eps_m <= 2d-113) then
        tmp = (2.0d0 / exp(x)) * 0.5d0
    else
        tmp = (exp(-(eps_m * x)) + exp(((eps_m - 1.0d0) * x))) * 0.5d0
    end if
    code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
	double tmp;
	if (eps_m <= 2e-113) {
		tmp = (2.0 / Math.exp(x)) * 0.5;
	} else {
		tmp = (Math.exp(-(eps_m * x)) + Math.exp(((eps_m - 1.0) * x))) * 0.5;
	}
	return tmp;
}
eps_m = math.fabs(eps)
def code(x, eps_m):
	tmp = 0
	if eps_m <= 2e-113:
		tmp = (2.0 / math.exp(x)) * 0.5
	else:
		tmp = (math.exp(-(eps_m * x)) + math.exp(((eps_m - 1.0) * x))) * 0.5
	return tmp
eps_m = abs(eps)
function code(x, eps_m)
	tmp = 0.0
	if (eps_m <= 2e-113)
		tmp = Float64(Float64(2.0 / exp(x)) * 0.5);
	else
		tmp = Float64(Float64(exp(Float64(-Float64(eps_m * x))) + exp(Float64(Float64(eps_m - 1.0) * x))) * 0.5);
	end
	return tmp
end
eps_m = abs(eps);
function tmp_2 = code(x, eps_m)
	tmp = 0.0;
	if (eps_m <= 2e-113)
		tmp = (2.0 / exp(x)) * 0.5;
	else
		tmp = (exp(-(eps_m * x)) + exp(((eps_m - 1.0) * x))) * 0.5;
	end
	tmp_2 = tmp;
end
eps_m = N[Abs[eps], $MachinePrecision]
code[x_, eps$95$m_] := If[LessEqual[eps$95$m, 2e-113], N[(N[(2.0 / N[Exp[x], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(N[Exp[(-N[(eps$95$m * x), $MachinePrecision])], $MachinePrecision] + N[Exp[N[(N[(eps$95$m - 1.0), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|

\\
\begin{array}{l}
\mathbf{if}\;eps\_m \leq 2 \cdot 10^{-113}:\\
\;\;\;\;\frac{2}{e^{x}} \cdot 0.5\\

\mathbf{else}:\\
\;\;\;\;\left(e^{-eps\_m \cdot x} + e^{\left(eps\_m - 1\right) \cdot x}\right) \cdot 0.5\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if eps < 1.99999999999999996e-113

    1. Initial program 73.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 \color{blue}{\frac{1}{2} \cdot \left(e^{\mathsf{neg}\left(x \cdot \left(1 - \varepsilon\right)\right)} - -1 \cdot e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}\right)} \]
    3. Step-by-step derivation
      1. lower-*.f64N/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{2} \cdot \left(e^{-x \cdot \left(1 - \varepsilon\right)} - -1 \cdot e^{-x \cdot \left(1 + \varepsilon\right)}\right) \]
      11. lower-+.f6499.0

        \[\leadsto 0.5 \cdot \left(e^{-x \cdot \left(1 - \varepsilon\right)} - -1 \cdot e^{-x \cdot \left(1 + \varepsilon\right)}\right) \]
    4. Applied rewrites99.0%

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

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

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

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

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

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

        \[\leadsto \frac{1}{2} \cdot \left(e^{-x} - -1 \cdot e^{\mathsf{neg}\left(x\right)}\right) \]
      6. lower-neg.f6471.2

        \[\leadsto 0.5 \cdot \left(e^{-x} - -1 \cdot e^{-x}\right) \]
    7. Applied rewrites71.2%

      \[\leadsto 0.5 \cdot \left(e^{-x} - \color{blue}{-1 \cdot e^{-x}}\right) \]
    8. Step-by-step derivation
      1. lift-*.f64N/A

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

        \[\leadsto \left(e^{-x} - -1 \cdot e^{-x}\right) \cdot \color{blue}{\frac{1}{2}} \]
      3. lower-*.f6471.2

        \[\leadsto \left(e^{-x} - -1 \cdot e^{-x}\right) \cdot \color{blue}{0.5} \]
    9. Applied rewrites71.2%

      \[\leadsto \frac{2}{e^{x}} \cdot \color{blue}{0.5} \]

    if 1.99999999999999996e-113 < eps

    1. Initial program 73.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 \color{blue}{\frac{1}{2} \cdot \left(e^{\mathsf{neg}\left(x \cdot \left(1 - \varepsilon\right)\right)} - -1 \cdot e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}\right)} \]
    3. Step-by-step derivation
      1. lower-*.f64N/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{2} \cdot \left(e^{-x \cdot \left(1 - \varepsilon\right)} - -1 \cdot e^{-x \cdot \left(1 + \varepsilon\right)}\right) \]
      11. lower-+.f6499.0

        \[\leadsto 0.5 \cdot \left(e^{-x \cdot \left(1 - \varepsilon\right)} - -1 \cdot e^{-x \cdot \left(1 + \varepsilon\right)}\right) \]
    4. Applied rewrites99.0%

      \[\leadsto \color{blue}{0.5 \cdot \left(e^{-x \cdot \left(1 - \varepsilon\right)} - -1 \cdot e^{-x \cdot \left(1 + \varepsilon\right)}\right)} \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

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

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

        \[\leadsto \left(e^{-x \cdot \left(1 - \varepsilon\right)} - -1 \cdot e^{-x \cdot \left(1 + \varepsilon\right)}\right) \cdot \color{blue}{0.5} \]
    6. Applied rewrites99.0%

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

      \[\leadsto \left(e^{-\varepsilon \cdot x} + e^{\left(\varepsilon - 1\right) \cdot x}\right) \cdot \frac{1}{2} \]
    8. Step-by-step derivation
      1. lower-*.f6492.3

        \[\leadsto \left(e^{-\varepsilon \cdot x} + e^{\left(\varepsilon - 1\right) \cdot x}\right) \cdot 0.5 \]
    9. Applied rewrites92.3%

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

Alternative 2: 98.1% accurate, 1.5× speedup?

\[\begin{array}{l} eps_m = \left|\varepsilon\right| \\ \left(e^{-\mathsf{fma}\left(x, eps\_m, x\right)} + e^{\left(eps\_m - 1\right) \cdot x}\right) \cdot 0.5 \end{array} \]
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
 :precision binary64
 (* (+ (exp (- (fma x eps_m x))) (exp (* (- eps_m 1.0) x))) 0.5))
eps_m = fabs(eps);
double code(double x, double eps_m) {
	return (exp(-fma(x, eps_m, x)) + exp(((eps_m - 1.0) * x))) * 0.5;
}
eps_m = abs(eps)
function code(x, eps_m)
	return Float64(Float64(exp(Float64(-fma(x, eps_m, x))) + exp(Float64(Float64(eps_m - 1.0) * x))) * 0.5)
end
eps_m = N[Abs[eps], $MachinePrecision]
code[x_, eps$95$m_] := N[(N[(N[Exp[(-N[(x * eps$95$m + x), $MachinePrecision])], $MachinePrecision] + N[Exp[N[(N[(eps$95$m - 1.0), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]
\begin{array}{l}
eps_m = \left|\varepsilon\right|

\\
\left(e^{-\mathsf{fma}\left(x, eps\_m, x\right)} + e^{\left(eps\_m - 1\right) \cdot x}\right) \cdot 0.5
\end{array}
Derivation
  1. Initial program 73.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 \color{blue}{\frac{1}{2} \cdot \left(e^{\mathsf{neg}\left(x \cdot \left(1 - \varepsilon\right)\right)} - -1 \cdot e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}\right)} \]
  3. Step-by-step derivation
    1. lower-*.f64N/A

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{2} \cdot \left(e^{-x \cdot \left(1 - \varepsilon\right)} - -1 \cdot e^{-x \cdot \left(1 + \varepsilon\right)}\right) \]
    11. lower-+.f6499.0

      \[\leadsto 0.5 \cdot \left(e^{-x \cdot \left(1 - \varepsilon\right)} - -1 \cdot e^{-x \cdot \left(1 + \varepsilon\right)}\right) \]
  4. Applied rewrites99.0%

    \[\leadsto \color{blue}{0.5 \cdot \left(e^{-x \cdot \left(1 - \varepsilon\right)} - -1 \cdot e^{-x \cdot \left(1 + \varepsilon\right)}\right)} \]
  5. Step-by-step derivation
    1. lift-*.f64N/A

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

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

      \[\leadsto \left(e^{-x \cdot \left(1 - \varepsilon\right)} - -1 \cdot e^{-x \cdot \left(1 + \varepsilon\right)}\right) \cdot \color{blue}{0.5} \]
  6. Applied rewrites99.0%

    \[\leadsto \color{blue}{\left(e^{-\mathsf{fma}\left(x, \varepsilon, x\right)} + e^{\left(\varepsilon - 1\right) \cdot x}\right) \cdot 0.5} \]
  7. Add Preprocessing

Alternative 3: 85.1% accurate, 1.6× speedup?

\[\begin{array}{l} eps_m = \left|\varepsilon\right| \\ \begin{array}{l} \mathbf{if}\;x \leq -50000000:\\ \;\;\;\;\frac{2}{e^{x}} \cdot 0.5\\ \mathbf{elif}\;x \leq -2.9 \cdot 10^{-259}:\\ \;\;\;\;\left(e^{-eps\_m \cdot x} + \left(1 + x \cdot \left(eps\_m - 1\right)\right)\right) \cdot 0.5\\ \mathbf{elif}\;x \leq 8.2 \cdot 10^{+261}:\\ \;\;\;\;\left(e^{\left(eps\_m - 1\right) \cdot x} - -1\right) \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(1 + \frac{1}{eps\_m}\right) - \left(\frac{1}{eps\_m} - 1\right)}{2}\\ \end{array} \end{array} \]
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
 :precision binary64
 (if (<= x -50000000.0)
   (* (/ 2.0 (exp x)) 0.5)
   (if (<= x -2.9e-259)
     (* (+ (exp (- (* eps_m x))) (+ 1.0 (* x (- eps_m 1.0)))) 0.5)
     (if (<= x 8.2e+261)
       (* (- (exp (* (- eps_m 1.0) x)) -1.0) 0.5)
       (/ (- (+ 1.0 (/ 1.0 eps_m)) (- (/ 1.0 eps_m) 1.0)) 2.0)))))
eps_m = fabs(eps);
double code(double x, double eps_m) {
	double tmp;
	if (x <= -50000000.0) {
		tmp = (2.0 / exp(x)) * 0.5;
	} else if (x <= -2.9e-259) {
		tmp = (exp(-(eps_m * x)) + (1.0 + (x * (eps_m - 1.0)))) * 0.5;
	} else if (x <= 8.2e+261) {
		tmp = (exp(((eps_m - 1.0) * x)) - -1.0) * 0.5;
	} else {
		tmp = ((1.0 + (1.0 / eps_m)) - ((1.0 / eps_m) - 1.0)) / 2.0;
	}
	return tmp;
}
eps_m =     private
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_m)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: eps_m
    real(8) :: tmp
    if (x <= (-50000000.0d0)) then
        tmp = (2.0d0 / exp(x)) * 0.5d0
    else if (x <= (-2.9d-259)) then
        tmp = (exp(-(eps_m * x)) + (1.0d0 + (x * (eps_m - 1.0d0)))) * 0.5d0
    else if (x <= 8.2d+261) then
        tmp = (exp(((eps_m - 1.0d0) * x)) - (-1.0d0)) * 0.5d0
    else
        tmp = ((1.0d0 + (1.0d0 / eps_m)) - ((1.0d0 / eps_m) - 1.0d0)) / 2.0d0
    end if
    code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
	double tmp;
	if (x <= -50000000.0) {
		tmp = (2.0 / Math.exp(x)) * 0.5;
	} else if (x <= -2.9e-259) {
		tmp = (Math.exp(-(eps_m * x)) + (1.0 + (x * (eps_m - 1.0)))) * 0.5;
	} else if (x <= 8.2e+261) {
		tmp = (Math.exp(((eps_m - 1.0) * x)) - -1.0) * 0.5;
	} else {
		tmp = ((1.0 + (1.0 / eps_m)) - ((1.0 / eps_m) - 1.0)) / 2.0;
	}
	return tmp;
}
eps_m = math.fabs(eps)
def code(x, eps_m):
	tmp = 0
	if x <= -50000000.0:
		tmp = (2.0 / math.exp(x)) * 0.5
	elif x <= -2.9e-259:
		tmp = (math.exp(-(eps_m * x)) + (1.0 + (x * (eps_m - 1.0)))) * 0.5
	elif x <= 8.2e+261:
		tmp = (math.exp(((eps_m - 1.0) * x)) - -1.0) * 0.5
	else:
		tmp = ((1.0 + (1.0 / eps_m)) - ((1.0 / eps_m) - 1.0)) / 2.0
	return tmp
eps_m = abs(eps)
function code(x, eps_m)
	tmp = 0.0
	if (x <= -50000000.0)
		tmp = Float64(Float64(2.0 / exp(x)) * 0.5);
	elseif (x <= -2.9e-259)
		tmp = Float64(Float64(exp(Float64(-Float64(eps_m * x))) + Float64(1.0 + Float64(x * Float64(eps_m - 1.0)))) * 0.5);
	elseif (x <= 8.2e+261)
		tmp = Float64(Float64(exp(Float64(Float64(eps_m - 1.0) * x)) - -1.0) * 0.5);
	else
		tmp = Float64(Float64(Float64(1.0 + Float64(1.0 / eps_m)) - Float64(Float64(1.0 / eps_m) - 1.0)) / 2.0);
	end
	return tmp
end
eps_m = abs(eps);
function tmp_2 = code(x, eps_m)
	tmp = 0.0;
	if (x <= -50000000.0)
		tmp = (2.0 / exp(x)) * 0.5;
	elseif (x <= -2.9e-259)
		tmp = (exp(-(eps_m * x)) + (1.0 + (x * (eps_m - 1.0)))) * 0.5;
	elseif (x <= 8.2e+261)
		tmp = (exp(((eps_m - 1.0) * x)) - -1.0) * 0.5;
	else
		tmp = ((1.0 + (1.0 / eps_m)) - ((1.0 / eps_m) - 1.0)) / 2.0;
	end
	tmp_2 = tmp;
end
eps_m = N[Abs[eps], $MachinePrecision]
code[x_, eps$95$m_] := If[LessEqual[x, -50000000.0], N[(N[(2.0 / N[Exp[x], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, -2.9e-259], N[(N[(N[Exp[(-N[(eps$95$m * x), $MachinePrecision])], $MachinePrecision] + N[(1.0 + N[(x * N[(eps$95$m - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 8.2e+261], N[(N[(N[Exp[N[(N[(eps$95$m - 1.0), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(N[(1.0 + N[(1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision] - N[(N[(1.0 / eps$95$m), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|

\\
\begin{array}{l}
\mathbf{if}\;x \leq -50000000:\\
\;\;\;\;\frac{2}{e^{x}} \cdot 0.5\\

\mathbf{elif}\;x \leq -2.9 \cdot 10^{-259}:\\
\;\;\;\;\left(e^{-eps\_m \cdot x} + \left(1 + x \cdot \left(eps\_m - 1\right)\right)\right) \cdot 0.5\\

\mathbf{elif}\;x \leq 8.2 \cdot 10^{+261}:\\
\;\;\;\;\left(e^{\left(eps\_m - 1\right) \cdot x} - -1\right) \cdot 0.5\\

\mathbf{else}:\\
\;\;\;\;\frac{\left(1 + \frac{1}{eps\_m}\right) - \left(\frac{1}{eps\_m} - 1\right)}{2}\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < -5e7

    1. Initial program 73.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 \color{blue}{\frac{1}{2} \cdot \left(e^{\mathsf{neg}\left(x \cdot \left(1 - \varepsilon\right)\right)} - -1 \cdot e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}\right)} \]
    3. Step-by-step derivation
      1. lower-*.f64N/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{2} \cdot \left(e^{-x \cdot \left(1 - \varepsilon\right)} - -1 \cdot e^{-x \cdot \left(1 + \varepsilon\right)}\right) \]
      11. lower-+.f6499.0

        \[\leadsto 0.5 \cdot \left(e^{-x \cdot \left(1 - \varepsilon\right)} - -1 \cdot e^{-x \cdot \left(1 + \varepsilon\right)}\right) \]
    4. Applied rewrites99.0%

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

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

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

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

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

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

        \[\leadsto \frac{1}{2} \cdot \left(e^{-x} - -1 \cdot e^{\mathsf{neg}\left(x\right)}\right) \]
      6. lower-neg.f6471.2

        \[\leadsto 0.5 \cdot \left(e^{-x} - -1 \cdot e^{-x}\right) \]
    7. Applied rewrites71.2%

      \[\leadsto 0.5 \cdot \left(e^{-x} - \color{blue}{-1 \cdot e^{-x}}\right) \]
    8. Step-by-step derivation
      1. lift-*.f64N/A

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

        \[\leadsto \left(e^{-x} - -1 \cdot e^{-x}\right) \cdot \color{blue}{\frac{1}{2}} \]
      3. lower-*.f6471.2

        \[\leadsto \left(e^{-x} - -1 \cdot e^{-x}\right) \cdot \color{blue}{0.5} \]
    9. Applied rewrites71.2%

      \[\leadsto \frac{2}{e^{x}} \cdot \color{blue}{0.5} \]

    if -5e7 < x < -2.90000000000000009e-259

    1. Initial program 73.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 \color{blue}{\frac{1}{2} \cdot \left(e^{\mathsf{neg}\left(x \cdot \left(1 - \varepsilon\right)\right)} - -1 \cdot e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}\right)} \]
    3. Step-by-step derivation
      1. lower-*.f64N/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{2} \cdot \left(e^{-x \cdot \left(1 - \varepsilon\right)} - -1 \cdot e^{-x \cdot \left(1 + \varepsilon\right)}\right) \]
      11. lower-+.f6499.0

        \[\leadsto 0.5 \cdot \left(e^{-x \cdot \left(1 - \varepsilon\right)} - -1 \cdot e^{-x \cdot \left(1 + \varepsilon\right)}\right) \]
    4. Applied rewrites99.0%

      \[\leadsto \color{blue}{0.5 \cdot \left(e^{-x \cdot \left(1 - \varepsilon\right)} - -1 \cdot e^{-x \cdot \left(1 + \varepsilon\right)}\right)} \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

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

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

        \[\leadsto \left(e^{-x \cdot \left(1 - \varepsilon\right)} - -1 \cdot e^{-x \cdot \left(1 + \varepsilon\right)}\right) \cdot \color{blue}{0.5} \]
    6. Applied rewrites99.0%

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

      \[\leadsto \left(e^{-\varepsilon \cdot x} + e^{\left(\varepsilon - 1\right) \cdot x}\right) \cdot \frac{1}{2} \]
    8. Step-by-step derivation
      1. lower-*.f6492.3

        \[\leadsto \left(e^{-\varepsilon \cdot x} + e^{\left(\varepsilon - 1\right) \cdot x}\right) \cdot 0.5 \]
    9. Applied rewrites92.3%

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

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

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

        \[\leadsto \left(e^{-\varepsilon \cdot x} + \left(1 + x \cdot \left(\varepsilon - 1\right)\right)\right) \cdot \frac{1}{2} \]
      3. lower--.f6464.0

        \[\leadsto \left(e^{-\varepsilon \cdot x} + \left(1 + x \cdot \left(\varepsilon - 1\right)\right)\right) \cdot 0.5 \]
    12. Applied rewrites64.0%

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

    if -2.90000000000000009e-259 < x < 8.1999999999999999e261

    1. Initial program 73.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 \color{blue}{\frac{1}{2} \cdot \left(e^{\mathsf{neg}\left(x \cdot \left(1 - \varepsilon\right)\right)} - -1 \cdot e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}\right)} \]
    3. Step-by-step derivation
      1. lower-*.f64N/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{2} \cdot \left(e^{-x \cdot \left(1 - \varepsilon\right)} - -1 \cdot e^{-x \cdot \left(1 + \varepsilon\right)}\right) \]
      11. lower-+.f6499.0

        \[\leadsto 0.5 \cdot \left(e^{-x \cdot \left(1 - \varepsilon\right)} - -1 \cdot e^{-x \cdot \left(1 + \varepsilon\right)}\right) \]
    4. Applied rewrites99.0%

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

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

        \[\leadsto 0.5 \cdot \left(e^{-x \cdot \left(1 - \varepsilon\right)} - -1\right) \]
      2. Step-by-step derivation
        1. lift-*.f64N/A

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

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

          \[\leadsto \left(e^{-x \cdot \left(1 - \varepsilon\right)} - -1\right) \cdot \color{blue}{0.5} \]
        4. lift-neg.f64N/A

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

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

          \[\leadsto \left(e^{\mathsf{neg}\left(\left(1 - \varepsilon\right) \cdot x\right)} - -1\right) \cdot \frac{1}{2} \]
        7. distribute-lft-neg-inN/A

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

          \[\leadsto \left(e^{\left(\mathsf{neg}\left(\left(1 - \varepsilon\right)\right)\right) \cdot x} - -1\right) \cdot \frac{1}{2} \]
        9. sub-negate-revN/A

          \[\leadsto \left(e^{\left(\varepsilon - 1\right) \cdot x} - -1\right) \cdot \frac{1}{2} \]
        10. lift--.f64N/A

          \[\leadsto \left(e^{\left(\varepsilon - 1\right) \cdot x} - -1\right) \cdot \frac{1}{2} \]
        11. lift-*.f6464.2

          \[\leadsto \left(e^{\left(\varepsilon - 1\right) \cdot x} - -1\right) \cdot 0.5 \]
      3. Applied rewrites64.2%

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

      if 8.1999999999999999e261 < x

      1. Initial program 73.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 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} - \left(\frac{1}{\varepsilon} - \color{blue}{1}\right)}{2} \]
        2. lower-/.f6438.1

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

        \[\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} \]
      5. Taylor expanded in x around 0

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

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

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

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

    Alternative 4: 78.0% accurate, 2.2× speedup?

    \[\begin{array}{l} eps_m = \left|\varepsilon\right| \\ \begin{array}{l} \mathbf{if}\;eps\_m \leq 1.65 \cdot 10^{+37}:\\ \;\;\;\;\frac{2}{e^{x}} \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;\left(e^{\left(eps\_m - 1\right) \cdot x} - -1\right) \cdot 0.5\\ \end{array} \end{array} \]
    eps_m = (fabs.f64 eps)
    (FPCore (x eps_m)
     :precision binary64
     (if (<= eps_m 1.65e+37)
       (* (/ 2.0 (exp x)) 0.5)
       (* (- (exp (* (- eps_m 1.0) x)) -1.0) 0.5)))
    eps_m = fabs(eps);
    double code(double x, double eps_m) {
    	double tmp;
    	if (eps_m <= 1.65e+37) {
    		tmp = (2.0 / exp(x)) * 0.5;
    	} else {
    		tmp = (exp(((eps_m - 1.0) * x)) - -1.0) * 0.5;
    	}
    	return tmp;
    }
    
    eps_m =     private
    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_m)
    use fmin_fmax_functions
        real(8), intent (in) :: x
        real(8), intent (in) :: eps_m
        real(8) :: tmp
        if (eps_m <= 1.65d+37) then
            tmp = (2.0d0 / exp(x)) * 0.5d0
        else
            tmp = (exp(((eps_m - 1.0d0) * x)) - (-1.0d0)) * 0.5d0
        end if
        code = tmp
    end function
    
    eps_m = Math.abs(eps);
    public static double code(double x, double eps_m) {
    	double tmp;
    	if (eps_m <= 1.65e+37) {
    		tmp = (2.0 / Math.exp(x)) * 0.5;
    	} else {
    		tmp = (Math.exp(((eps_m - 1.0) * x)) - -1.0) * 0.5;
    	}
    	return tmp;
    }
    
    eps_m = math.fabs(eps)
    def code(x, eps_m):
    	tmp = 0
    	if eps_m <= 1.65e+37:
    		tmp = (2.0 / math.exp(x)) * 0.5
    	else:
    		tmp = (math.exp(((eps_m - 1.0) * x)) - -1.0) * 0.5
    	return tmp
    
    eps_m = abs(eps)
    function code(x, eps_m)
    	tmp = 0.0
    	if (eps_m <= 1.65e+37)
    		tmp = Float64(Float64(2.0 / exp(x)) * 0.5);
    	else
    		tmp = Float64(Float64(exp(Float64(Float64(eps_m - 1.0) * x)) - -1.0) * 0.5);
    	end
    	return tmp
    end
    
    eps_m = abs(eps);
    function tmp_2 = code(x, eps_m)
    	tmp = 0.0;
    	if (eps_m <= 1.65e+37)
    		tmp = (2.0 / exp(x)) * 0.5;
    	else
    		tmp = (exp(((eps_m - 1.0) * x)) - -1.0) * 0.5;
    	end
    	tmp_2 = tmp;
    end
    
    eps_m = N[Abs[eps], $MachinePrecision]
    code[x_, eps$95$m_] := If[LessEqual[eps$95$m, 1.65e+37], N[(N[(2.0 / N[Exp[x], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(N[Exp[N[(N[(eps$95$m - 1.0), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision] * 0.5), $MachinePrecision]]
    
    \begin{array}{l}
    eps_m = \left|\varepsilon\right|
    
    \\
    \begin{array}{l}
    \mathbf{if}\;eps\_m \leq 1.65 \cdot 10^{+37}:\\
    \;\;\;\;\frac{2}{e^{x}} \cdot 0.5\\
    
    \mathbf{else}:\\
    \;\;\;\;\left(e^{\left(eps\_m - 1\right) \cdot x} - -1\right) \cdot 0.5\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if eps < 1.65e37

      1. Initial program 73.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 \color{blue}{\frac{1}{2} \cdot \left(e^{\mathsf{neg}\left(x \cdot \left(1 - \varepsilon\right)\right)} - -1 \cdot e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}\right)} \]
      3. Step-by-step derivation
        1. lower-*.f64N/A

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

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

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

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

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

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

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

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

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

          \[\leadsto \frac{1}{2} \cdot \left(e^{-x \cdot \left(1 - \varepsilon\right)} - -1 \cdot e^{-x \cdot \left(1 + \varepsilon\right)}\right) \]
        11. lower-+.f6499.0

          \[\leadsto 0.5 \cdot \left(e^{-x \cdot \left(1 - \varepsilon\right)} - -1 \cdot e^{-x \cdot \left(1 + \varepsilon\right)}\right) \]
      4. Applied rewrites99.0%

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

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

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

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

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

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

          \[\leadsto \frac{1}{2} \cdot \left(e^{-x} - -1 \cdot e^{\mathsf{neg}\left(x\right)}\right) \]
        6. lower-neg.f6471.2

          \[\leadsto 0.5 \cdot \left(e^{-x} - -1 \cdot e^{-x}\right) \]
      7. Applied rewrites71.2%

        \[\leadsto 0.5 \cdot \left(e^{-x} - \color{blue}{-1 \cdot e^{-x}}\right) \]
      8. Step-by-step derivation
        1. lift-*.f64N/A

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

          \[\leadsto \left(e^{-x} - -1 \cdot e^{-x}\right) \cdot \color{blue}{\frac{1}{2}} \]
        3. lower-*.f6471.2

          \[\leadsto \left(e^{-x} - -1 \cdot e^{-x}\right) \cdot \color{blue}{0.5} \]
      9. Applied rewrites71.2%

        \[\leadsto \frac{2}{e^{x}} \cdot \color{blue}{0.5} \]

      if 1.65e37 < eps

      1. Initial program 73.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 \color{blue}{\frac{1}{2} \cdot \left(e^{\mathsf{neg}\left(x \cdot \left(1 - \varepsilon\right)\right)} - -1 \cdot e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}\right)} \]
      3. Step-by-step derivation
        1. lower-*.f64N/A

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

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

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

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

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

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

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

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

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

          \[\leadsto \frac{1}{2} \cdot \left(e^{-x \cdot \left(1 - \varepsilon\right)} - -1 \cdot e^{-x \cdot \left(1 + \varepsilon\right)}\right) \]
        11. lower-+.f6499.0

          \[\leadsto 0.5 \cdot \left(e^{-x \cdot \left(1 - \varepsilon\right)} - -1 \cdot e^{-x \cdot \left(1 + \varepsilon\right)}\right) \]
      4. Applied rewrites99.0%

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

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

          \[\leadsto 0.5 \cdot \left(e^{-x \cdot \left(1 - \varepsilon\right)} - -1\right) \]
        2. Step-by-step derivation
          1. lift-*.f64N/A

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

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

            \[\leadsto \left(e^{-x \cdot \left(1 - \varepsilon\right)} - -1\right) \cdot \color{blue}{0.5} \]
          4. lift-neg.f64N/A

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

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

            \[\leadsto \left(e^{\mathsf{neg}\left(\left(1 - \varepsilon\right) \cdot x\right)} - -1\right) \cdot \frac{1}{2} \]
          7. distribute-lft-neg-inN/A

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

            \[\leadsto \left(e^{\left(\mathsf{neg}\left(\left(1 - \varepsilon\right)\right)\right) \cdot x} - -1\right) \cdot \frac{1}{2} \]
          9. sub-negate-revN/A

            \[\leadsto \left(e^{\left(\varepsilon - 1\right) \cdot x} - -1\right) \cdot \frac{1}{2} \]
          10. lift--.f64N/A

            \[\leadsto \left(e^{\left(\varepsilon - 1\right) \cdot x} - -1\right) \cdot \frac{1}{2} \]
          11. lift-*.f6464.2

            \[\leadsto \left(e^{\left(\varepsilon - 1\right) \cdot x} - -1\right) \cdot 0.5 \]
        3. Applied rewrites64.2%

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

      Alternative 5: 71.4% accurate, 2.7× speedup?

      \[\begin{array}{l} eps_m = \left|\varepsilon\right| \\ \begin{array}{l} \mathbf{if}\;eps\_m \leq 1.75 \cdot 10^{+34}:\\ \;\;\;\;\frac{2}{e^{x}} \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(2 + x \cdot \left(x - 2\right)\right)\\ \end{array} \end{array} \]
      eps_m = (fabs.f64 eps)
      (FPCore (x eps_m)
       :precision binary64
       (if (<= eps_m 1.75e+34)
         (* (/ 2.0 (exp x)) 0.5)
         (* 0.5 (+ 2.0 (* x (- x 2.0))))))
      eps_m = fabs(eps);
      double code(double x, double eps_m) {
      	double tmp;
      	if (eps_m <= 1.75e+34) {
      		tmp = (2.0 / exp(x)) * 0.5;
      	} else {
      		tmp = 0.5 * (2.0 + (x * (x - 2.0)));
      	}
      	return tmp;
      }
      
      eps_m =     private
      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_m)
      use fmin_fmax_functions
          real(8), intent (in) :: x
          real(8), intent (in) :: eps_m
          real(8) :: tmp
          if (eps_m <= 1.75d+34) then
              tmp = (2.0d0 / exp(x)) * 0.5d0
          else
              tmp = 0.5d0 * (2.0d0 + (x * (x - 2.0d0)))
          end if
          code = tmp
      end function
      
      eps_m = Math.abs(eps);
      public static double code(double x, double eps_m) {
      	double tmp;
      	if (eps_m <= 1.75e+34) {
      		tmp = (2.0 / Math.exp(x)) * 0.5;
      	} else {
      		tmp = 0.5 * (2.0 + (x * (x - 2.0)));
      	}
      	return tmp;
      }
      
      eps_m = math.fabs(eps)
      def code(x, eps_m):
      	tmp = 0
      	if eps_m <= 1.75e+34:
      		tmp = (2.0 / math.exp(x)) * 0.5
      	else:
      		tmp = 0.5 * (2.0 + (x * (x - 2.0)))
      	return tmp
      
      eps_m = abs(eps)
      function code(x, eps_m)
      	tmp = 0.0
      	if (eps_m <= 1.75e+34)
      		tmp = Float64(Float64(2.0 / exp(x)) * 0.5);
      	else
      		tmp = Float64(0.5 * Float64(2.0 + Float64(x * Float64(x - 2.0))));
      	end
      	return tmp
      end
      
      eps_m = abs(eps);
      function tmp_2 = code(x, eps_m)
      	tmp = 0.0;
      	if (eps_m <= 1.75e+34)
      		tmp = (2.0 / exp(x)) * 0.5;
      	else
      		tmp = 0.5 * (2.0 + (x * (x - 2.0)));
      	end
      	tmp_2 = tmp;
      end
      
      eps_m = N[Abs[eps], $MachinePrecision]
      code[x_, eps$95$m_] := If[LessEqual[eps$95$m, 1.75e+34], N[(N[(2.0 / N[Exp[x], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], N[(0.5 * N[(2.0 + N[(x * N[(x - 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
      
      \begin{array}{l}
      eps_m = \left|\varepsilon\right|
      
      \\
      \begin{array}{l}
      \mathbf{if}\;eps\_m \leq 1.75 \cdot 10^{+34}:\\
      \;\;\;\;\frac{2}{e^{x}} \cdot 0.5\\
      
      \mathbf{else}:\\
      \;\;\;\;0.5 \cdot \left(2 + x \cdot \left(x - 2\right)\right)\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if eps < 1.74999999999999999e34

        1. Initial program 73.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 \color{blue}{\frac{1}{2} \cdot \left(e^{\mathsf{neg}\left(x \cdot \left(1 - \varepsilon\right)\right)} - -1 \cdot e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}\right)} \]
        3. Step-by-step derivation
          1. lower-*.f64N/A

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

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

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

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

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

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

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

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

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

            \[\leadsto \frac{1}{2} \cdot \left(e^{-x \cdot \left(1 - \varepsilon\right)} - -1 \cdot e^{-x \cdot \left(1 + \varepsilon\right)}\right) \]
          11. lower-+.f6499.0

            \[\leadsto 0.5 \cdot \left(e^{-x \cdot \left(1 - \varepsilon\right)} - -1 \cdot e^{-x \cdot \left(1 + \varepsilon\right)}\right) \]
        4. Applied rewrites99.0%

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

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

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

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

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

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

            \[\leadsto \frac{1}{2} \cdot \left(e^{-x} - -1 \cdot e^{\mathsf{neg}\left(x\right)}\right) \]
          6. lower-neg.f6471.2

            \[\leadsto 0.5 \cdot \left(e^{-x} - -1 \cdot e^{-x}\right) \]
        7. Applied rewrites71.2%

          \[\leadsto 0.5 \cdot \left(e^{-x} - \color{blue}{-1 \cdot e^{-x}}\right) \]
        8. Step-by-step derivation
          1. lift-*.f64N/A

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

            \[\leadsto \left(e^{-x} - -1 \cdot e^{-x}\right) \cdot \color{blue}{\frac{1}{2}} \]
          3. lower-*.f6471.2

            \[\leadsto \left(e^{-x} - -1 \cdot e^{-x}\right) \cdot \color{blue}{0.5} \]
        9. Applied rewrites71.2%

          \[\leadsto \frac{2}{e^{x}} \cdot \color{blue}{0.5} \]

        if 1.74999999999999999e34 < eps

        1. Initial program 73.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 \color{blue}{\frac{1}{2} \cdot \left(e^{\mathsf{neg}\left(x \cdot \left(1 - \varepsilon\right)\right)} - -1 \cdot e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}\right)} \]
        3. Step-by-step derivation
          1. lower-*.f64N/A

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

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

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

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

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

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

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

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

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

            \[\leadsto \frac{1}{2} \cdot \left(e^{-x \cdot \left(1 - \varepsilon\right)} - -1 \cdot e^{-x \cdot \left(1 + \varepsilon\right)}\right) \]
          11. lower-+.f6499.0

            \[\leadsto 0.5 \cdot \left(e^{-x \cdot \left(1 - \varepsilon\right)} - -1 \cdot e^{-x \cdot \left(1 + \varepsilon\right)}\right) \]
        4. Applied rewrites99.0%

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

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

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

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

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

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

            \[\leadsto \frac{1}{2} \cdot \left(e^{-x} - -1 \cdot e^{\mathsf{neg}\left(x\right)}\right) \]
          6. lower-neg.f6471.2

            \[\leadsto 0.5 \cdot \left(e^{-x} - -1 \cdot e^{-x}\right) \]
        7. Applied rewrites71.2%

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

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

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

            \[\leadsto \frac{1}{2} \cdot \left(2 + x \cdot \left(x - 2\right)\right) \]
          3. lower--.f6457.5

            \[\leadsto 0.5 \cdot \left(2 + x \cdot \left(x - 2\right)\right) \]
        10. Applied rewrites57.5%

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

      Alternative 6: 57.5% accurate, 4.8× speedup?

      \[\begin{array}{l} eps_m = \left|\varepsilon\right| \\ 0.5 \cdot \left(2 + x \cdot \left(x - 2\right)\right) \end{array} \]
      eps_m = (fabs.f64 eps)
      (FPCore (x eps_m) :precision binary64 (* 0.5 (+ 2.0 (* x (- x 2.0)))))
      eps_m = fabs(eps);
      double code(double x, double eps_m) {
      	return 0.5 * (2.0 + (x * (x - 2.0)));
      }
      
      eps_m =     private
      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_m)
      use fmin_fmax_functions
          real(8), intent (in) :: x
          real(8), intent (in) :: eps_m
          code = 0.5d0 * (2.0d0 + (x * (x - 2.0d0)))
      end function
      
      eps_m = Math.abs(eps);
      public static double code(double x, double eps_m) {
      	return 0.5 * (2.0 + (x * (x - 2.0)));
      }
      
      eps_m = math.fabs(eps)
      def code(x, eps_m):
      	return 0.5 * (2.0 + (x * (x - 2.0)))
      
      eps_m = abs(eps)
      function code(x, eps_m)
      	return Float64(0.5 * Float64(2.0 + Float64(x * Float64(x - 2.0))))
      end
      
      eps_m = abs(eps);
      function tmp = code(x, eps_m)
      	tmp = 0.5 * (2.0 + (x * (x - 2.0)));
      end
      
      eps_m = N[Abs[eps], $MachinePrecision]
      code[x_, eps$95$m_] := N[(0.5 * N[(2.0 + N[(x * N[(x - 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
      
      \begin{array}{l}
      eps_m = \left|\varepsilon\right|
      
      \\
      0.5 \cdot \left(2 + x \cdot \left(x - 2\right)\right)
      \end{array}
      
      Derivation
      1. Initial program 73.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 \color{blue}{\frac{1}{2} \cdot \left(e^{\mathsf{neg}\left(x \cdot \left(1 - \varepsilon\right)\right)} - -1 \cdot e^{\mathsf{neg}\left(x \cdot \left(1 + \varepsilon\right)\right)}\right)} \]
      3. Step-by-step derivation
        1. lower-*.f64N/A

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

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

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

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

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

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

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

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

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

          \[\leadsto \frac{1}{2} \cdot \left(e^{-x \cdot \left(1 - \varepsilon\right)} - -1 \cdot e^{-x \cdot \left(1 + \varepsilon\right)}\right) \]
        11. lower-+.f6499.0

          \[\leadsto 0.5 \cdot \left(e^{-x \cdot \left(1 - \varepsilon\right)} - -1 \cdot e^{-x \cdot \left(1 + \varepsilon\right)}\right) \]
      4. Applied rewrites99.0%

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

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

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

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

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

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

          \[\leadsto \frac{1}{2} \cdot \left(e^{-x} - -1 \cdot e^{\mathsf{neg}\left(x\right)}\right) \]
        6. lower-neg.f6471.2

          \[\leadsto 0.5 \cdot \left(e^{-x} - -1 \cdot e^{-x}\right) \]
      7. Applied rewrites71.2%

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

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

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

          \[\leadsto \frac{1}{2} \cdot \left(2 + x \cdot \left(x - 2\right)\right) \]
        3. lower--.f6457.5

          \[\leadsto 0.5 \cdot \left(2 + x \cdot \left(x - 2\right)\right) \]
      10. Applied rewrites57.5%

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

      Alternative 7: 44.1% accurate, 58.4× speedup?

      \[\begin{array}{l} eps_m = \left|\varepsilon\right| \\ 1 \end{array} \]
      eps_m = (fabs.f64 eps)
      (FPCore (x eps_m) :precision binary64 1.0)
      eps_m = fabs(eps);
      double code(double x, double eps_m) {
      	return 1.0;
      }
      
      eps_m =     private
      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_m)
      use fmin_fmax_functions
          real(8), intent (in) :: x
          real(8), intent (in) :: eps_m
          code = 1.0d0
      end function
      
      eps_m = Math.abs(eps);
      public static double code(double x, double eps_m) {
      	return 1.0;
      }
      
      eps_m = math.fabs(eps)
      def code(x, eps_m):
      	return 1.0
      
      eps_m = abs(eps)
      function code(x, eps_m)
      	return 1.0
      end
      
      eps_m = abs(eps);
      function tmp = code(x, eps_m)
      	tmp = 1.0;
      end
      
      eps_m = N[Abs[eps], $MachinePrecision]
      code[x_, eps$95$m_] := 1.0
      
      \begin{array}{l}
      eps_m = \left|\varepsilon\right|
      
      \\
      1
      \end{array}
      
      Derivation
      1. Initial program 73.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 x around 0

        \[\leadsto \color{blue}{1} \]
      3. Step-by-step derivation
        1. Applied rewrites44.1%

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

        Reproduce

        ?
        herbie shell --seed 2025162 
        (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))