NMSE Section 6.1 mentioned, A

Percentage Accurate: 73.2% → 98.9%
Time: 6.2s
Alternatives: 10
Speedup: 1.5×

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 10 alternatives:

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

Initial Program: 73.2% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2} \end{array} \]
(FPCore (x eps)
 :precision binary64
 (/
  (-
   (* (+ 1.0 (/ 1.0 eps)) (exp (- (* (- 1.0 eps) x))))
   (* (- (/ 1.0 eps) 1.0) (exp (- (* (+ 1.0 eps) x)))))
  2.0))
double code(double x, double eps) {
	return (((1.0 + (1.0 / eps)) * exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * exp(-((1.0 + eps) * x)))) / 2.0;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(x, eps)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: eps
    code = (((1.0d0 + (1.0d0 / eps)) * exp(-((1.0d0 - eps) * x))) - (((1.0d0 / eps) - 1.0d0) * exp(-((1.0d0 + eps) * x)))) / 2.0d0
end function
public static double code(double x, double eps) {
	return (((1.0 + (1.0 / eps)) * Math.exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * Math.exp(-((1.0 + eps) * x)))) / 2.0;
}
def code(x, eps):
	return (((1.0 + (1.0 / eps)) * math.exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * math.exp(-((1.0 + eps) * x)))) / 2.0
function code(x, eps)
	return Float64(Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) * exp(Float64(-Float64(Float64(1.0 - eps) * x)))) - Float64(Float64(Float64(1.0 / eps) - 1.0) * exp(Float64(-Float64(Float64(1.0 + eps) * x))))) / 2.0)
end
function tmp = code(x, eps)
	tmp = (((1.0 + (1.0 / eps)) * exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * exp(-((1.0 + eps) * x)))) / 2.0;
end
code[x_, eps_] := N[(N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] * N[Exp[(-N[(N[(1.0 - eps), $MachinePrecision] * x), $MachinePrecision])], $MachinePrecision]), $MachinePrecision] - N[(N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision] * N[Exp[(-N[(N[(1.0 + eps), $MachinePrecision] * x), $MachinePrecision])], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}

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

Alternative 1: 98.9% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \left(e^{\left(\varepsilon - 1\right) \cdot x} - \left(-e^{-\mathsf{fma}\left(x, \varepsilon, x\right)}\right)\right) \cdot 0.5 \end{array} \]
(FPCore (x eps)
 :precision binary64
 (* (- (exp (* (- eps 1.0) x)) (- (exp (- (fma x eps x))))) 0.5))
double code(double x, double eps) {
	return (exp(((eps - 1.0) * x)) - -exp(-fma(x, eps, x))) * 0.5;
}
function code(x, eps)
	return Float64(Float64(exp(Float64(Float64(eps - 1.0) * x)) - Float64(-exp(Float64(-fma(x, eps, x))))) * 0.5)
end
code[x_, eps_] := N[(N[(N[Exp[N[(N[(eps - 1.0), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] - (-N[Exp[(-N[(x * eps + x), $MachinePrecision])], $MachinePrecision])), $MachinePrecision] * 0.5), $MachinePrecision]
\begin{array}{l}

\\
\left(e^{\left(\varepsilon - 1\right) \cdot x} - \left(-e^{-\mathsf{fma}\left(x, \varepsilon, x\right)}\right)\right) \cdot 0.5
\end{array}
Derivation
  1. Initial program 73.2%

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

    \[\leadsto \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. Applied rewrites98.9%

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

Alternative 2: 74.1% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(e^{-x} \cdot 2\right) \cdot 0.5\\ t_1 := \left(e^{\left(\varepsilon - 1\right) \cdot x} - -1\right) \cdot 0.5\\ \mathbf{if}\;x \leq -3 \cdot 10^{+84}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq -2 \cdot 10^{-268}:\\ \;\;\;\;\left(\mathsf{fma}\left(\varepsilon - 1, x, 1\right) - \left(-e^{-\mathsf{fma}\left(x, \varepsilon, x\right)}\right)\right) \cdot 0.5\\ \mathbf{elif}\;x \leq 3700000:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x \leq 2.2 \cdot 10^{+162}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x eps)
 :precision binary64
 (let* ((t_0 (* (* (exp (- x)) 2.0) 0.5))
        (t_1 (* (- (exp (* (- eps 1.0) x)) -1.0) 0.5)))
   (if (<= x -3e+84)
     t_0
     (if (<= x -2e-268)
       (* (- (fma (- eps 1.0) x 1.0) (- (exp (- (fma x eps x))))) 0.5)
       (if (<= x 3700000.0) t_1 (if (<= x 2.2e+162) t_0 t_1))))))
double code(double x, double eps) {
	double t_0 = (exp(-x) * 2.0) * 0.5;
	double t_1 = (exp(((eps - 1.0) * x)) - -1.0) * 0.5;
	double tmp;
	if (x <= -3e+84) {
		tmp = t_0;
	} else if (x <= -2e-268) {
		tmp = (fma((eps - 1.0), x, 1.0) - -exp(-fma(x, eps, x))) * 0.5;
	} else if (x <= 3700000.0) {
		tmp = t_1;
	} else if (x <= 2.2e+162) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(x, eps)
	t_0 = Float64(Float64(exp(Float64(-x)) * 2.0) * 0.5)
	t_1 = Float64(Float64(exp(Float64(Float64(eps - 1.0) * x)) - -1.0) * 0.5)
	tmp = 0.0
	if (x <= -3e+84)
		tmp = t_0;
	elseif (x <= -2e-268)
		tmp = Float64(Float64(fma(Float64(eps - 1.0), x, 1.0) - Float64(-exp(Float64(-fma(x, eps, x))))) * 0.5);
	elseif (x <= 3700000.0)
		tmp = t_1;
	elseif (x <= 2.2e+162)
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
code[x_, eps_] := Block[{t$95$0 = N[(N[(N[Exp[(-x)], $MachinePrecision] * 2.0), $MachinePrecision] * 0.5), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Exp[N[(N[(eps - 1.0), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision] * 0.5), $MachinePrecision]}, If[LessEqual[x, -3e+84], t$95$0, If[LessEqual[x, -2e-268], N[(N[(N[(N[(eps - 1.0), $MachinePrecision] * x + 1.0), $MachinePrecision] - (-N[Exp[(-N[(x * eps + x), $MachinePrecision])], $MachinePrecision])), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 3700000.0], t$95$1, If[LessEqual[x, 2.2e+162], t$95$0, t$95$1]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(e^{-x} \cdot 2\right) \cdot 0.5\\
t_1 := \left(e^{\left(\varepsilon - 1\right) \cdot x} - -1\right) \cdot 0.5\\
\mathbf{if}\;x \leq -3 \cdot 10^{+84}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;x \leq 3700000:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;x \leq 2.2 \cdot 10^{+162}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -2.99999999999999996e84 or 3.7e6 < x < 2.2000000000000002e162

    1. Initial program 73.2%

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

      \[\leadsto \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. Applied rewrites98.9%

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

      \[\leadsto \left(e^{\mathsf{neg}\left(x\right)} + e^{-1 \cdot x}\right) \cdot \frac{1}{2} \]
    5. Step-by-step derivation
      1. mul-1-negN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(e^{-x} \cdot 2\right) \cdot \frac{1}{2} \]
      10. lift-exp.f6471.2

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

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

    if -2.99999999999999996e84 < x < -1.99999999999999992e-268

    1. Initial program 73.2%

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

      \[\leadsto \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. Applied rewrites98.9%

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

      \[\leadsto \left(\left(1 + x \cdot \left(\varepsilon - 1\right)\right) - \left(-e^{-\mathsf{fma}\left(x, \varepsilon, x\right)}\right)\right) \cdot \frac{1}{2} \]
    5. Step-by-step derivation
      1. sub-negate-revN/A

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

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

        \[\leadsto \left(\left(1 + \left(\varepsilon - 1\right) \cdot x\right) - \left(-e^{-\mathsf{fma}\left(x, \varepsilon, x\right)}\right)\right) \cdot \frac{1}{2} \]
      4. +-commutativeN/A

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

        \[\leadsto \left(\mathsf{fma}\left(\varepsilon - 1, x, 1\right) - \left(-e^{-\mathsf{fma}\left(x, \varepsilon, x\right)}\right)\right) \cdot \frac{1}{2} \]
      6. lift--.f6463.5

        \[\leadsto \left(\mathsf{fma}\left(\varepsilon - 1, x, 1\right) - \left(-e^{-\mathsf{fma}\left(x, \varepsilon, x\right)}\right)\right) \cdot 0.5 \]
    6. Applied rewrites63.5%

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

    if -1.99999999999999992e-268 < x < 3.7e6 or 2.2000000000000002e162 < x

    1. Initial program 73.2%

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

      \[\leadsto \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. Applied rewrites98.9%

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

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

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

    Alternative 3: 72.0% accurate, 2.2× speedup?

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

      1. Initial program 73.2%

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

        \[\leadsto \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. Applied rewrites98.9%

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

        \[\leadsto \left(e^{\mathsf{neg}\left(x\right)} + e^{-1 \cdot x}\right) \cdot \frac{1}{2} \]
      5. Step-by-step derivation
        1. mul-1-negN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \left(e^{-x} \cdot 2\right) \cdot \frac{1}{2} \]
        10. lift-exp.f6471.2

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

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

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

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

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

          \[\leadsto \left(\frac{1}{e^{x}} \cdot 2\right) \cdot \frac{1}{2} \]
        5. metadata-evalN/A

          \[\leadsto \left(\frac{1}{e^{x}} \cdot \frac{4}{2}\right) \cdot \frac{1}{2} \]
        6. frac-timesN/A

          \[\leadsto \frac{1 \cdot 4}{e^{x} \cdot 2} \cdot \frac{1}{2} \]
        7. metadata-evalN/A

          \[\leadsto \frac{4}{e^{x} \cdot 2} \cdot \frac{1}{2} \]
        8. lower-/.f64N/A

          \[\leadsto \frac{4}{e^{x} \cdot 2} \cdot \frac{1}{2} \]
        9. lower-*.f64N/A

          \[\leadsto \frac{4}{e^{x} \cdot 2} \cdot \frac{1}{2} \]
        10. lower-exp.f6471.2

          \[\leadsto \frac{4}{e^{x} \cdot 2} \cdot 0.5 \]
      10. Applied rewrites71.2%

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

      if 3.29999999999999991e120 < eps

      1. Initial program 73.2%

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

        \[\leadsto \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. Applied rewrites98.9%

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

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

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

      Alternative 4: 70.7% accurate, 2.4× speedup?

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

        1. Initial program 73.2%

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

          \[\leadsto \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. Applied rewrites98.9%

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

          \[\leadsto \left(e^{\mathsf{neg}\left(x\right)} + e^{-1 \cdot x}\right) \cdot \frac{1}{2} \]
        5. Step-by-step derivation
          1. mul-1-negN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \left(e^{-x} \cdot 2\right) \cdot \frac{1}{2} \]
          10. lift-exp.f6471.2

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

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

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

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

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

            \[\leadsto \left(\frac{1}{e^{x}} \cdot 2\right) \cdot \frac{1}{2} \]
          5. metadata-evalN/A

            \[\leadsto \left(\frac{1}{e^{x}} \cdot \frac{4}{2}\right) \cdot \frac{1}{2} \]
          6. frac-timesN/A

            \[\leadsto \frac{1 \cdot 4}{e^{x} \cdot 2} \cdot \frac{1}{2} \]
          7. metadata-evalN/A

            \[\leadsto \frac{4}{e^{x} \cdot 2} \cdot \frac{1}{2} \]
          8. lower-/.f64N/A

            \[\leadsto \frac{4}{e^{x} \cdot 2} \cdot \frac{1}{2} \]
          9. lower-*.f64N/A

            \[\leadsto \frac{4}{e^{x} \cdot 2} \cdot \frac{1}{2} \]
          10. lower-exp.f6471.2

            \[\leadsto \frac{4}{e^{x} \cdot 2} \cdot 0.5 \]
        10. Applied rewrites71.2%

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

        if 4.9999999999999997e161 < x

        1. Initial program 73.2%

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

          \[\leadsto \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. Applied rewrites98.9%

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

          \[\leadsto \left(e^{\mathsf{neg}\left(x\right)} + e^{-1 \cdot x}\right) \cdot \frac{1}{2} \]
        5. Step-by-step derivation
          1. mul-1-negN/A

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \mathsf{fma}\left(x - 2, x, 2\right) \cdot \frac{1}{2} \]
          4. lower--.f6457.5

            \[\leadsto \mathsf{fma}\left(x - 2, x, 2\right) \cdot 0.5 \]
        9. Applied rewrites57.5%

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

      Alternative 5: 70.7% accurate, 2.7× speedup?

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

        1. Initial program 73.2%

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

          \[\leadsto \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. Applied rewrites98.9%

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

          \[\leadsto \left(e^{\mathsf{neg}\left(x\right)} + e^{-1 \cdot x}\right) \cdot \frac{1}{2} \]
        5. Step-by-step derivation
          1. mul-1-negN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \left(e^{-x} \cdot 2\right) \cdot \frac{1}{2} \]
          10. lift-exp.f6471.2

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

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

        if 4.9999999999999997e161 < x

        1. Initial program 73.2%

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

          \[\leadsto \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. Applied rewrites98.9%

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

          \[\leadsto \left(e^{\mathsf{neg}\left(x\right)} + e^{-1 \cdot x}\right) \cdot \frac{1}{2} \]
        5. Step-by-step derivation
          1. mul-1-negN/A

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \mathsf{fma}\left(x - 2, x, 2\right) \cdot \frac{1}{2} \]
          4. lower--.f6457.5

            \[\leadsto \mathsf{fma}\left(x - 2, x, 2\right) \cdot 0.5 \]
        9. Applied rewrites57.5%

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

      Alternative 6: 63.5% accurate, 2.4× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(x - 2, x, 2\right) \cdot 0.5\\ \mathbf{if}\;x \leq 360:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq 3.6 \cdot 10^{+165}:\\ \;\;\;\;\frac{\frac{1}{\varepsilon} - \left(\frac{1}{\varepsilon} - 1\right)}{2}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
      (FPCore (x eps)
       :precision binary64
       (let* ((t_0 (* (fma (- x 2.0) x 2.0) 0.5)))
         (if (<= x 360.0)
           t_0
           (if (<= x 3.6e+165) (/ (- (/ 1.0 eps) (- (/ 1.0 eps) 1.0)) 2.0) t_0))))
      double code(double x, double eps) {
      	double t_0 = fma((x - 2.0), x, 2.0) * 0.5;
      	double tmp;
      	if (x <= 360.0) {
      		tmp = t_0;
      	} else if (x <= 3.6e+165) {
      		tmp = ((1.0 / eps) - ((1.0 / eps) - 1.0)) / 2.0;
      	} else {
      		tmp = t_0;
      	}
      	return tmp;
      }
      
      function code(x, eps)
      	t_0 = Float64(fma(Float64(x - 2.0), x, 2.0) * 0.5)
      	tmp = 0.0
      	if (x <= 360.0)
      		tmp = t_0;
      	elseif (x <= 3.6e+165)
      		tmp = Float64(Float64(Float64(1.0 / eps) - Float64(Float64(1.0 / eps) - 1.0)) / 2.0);
      	else
      		tmp = t_0;
      	end
      	return tmp
      end
      
      code[x_, eps_] := Block[{t$95$0 = N[(N[(N[(x - 2.0), $MachinePrecision] * x + 2.0), $MachinePrecision] * 0.5), $MachinePrecision]}, If[LessEqual[x, 360.0], t$95$0, If[LessEqual[x, 3.6e+165], N[(N[(N[(1.0 / eps), $MachinePrecision] - N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], t$95$0]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      t_0 := \mathsf{fma}\left(x - 2, x, 2\right) \cdot 0.5\\
      \mathbf{if}\;x \leq 360:\\
      \;\;\;\;t\_0\\
      
      \mathbf{elif}\;x \leq 3.6 \cdot 10^{+165}:\\
      \;\;\;\;\frac{\frac{1}{\varepsilon} - \left(\frac{1}{\varepsilon} - 1\right)}{2}\\
      
      \mathbf{else}:\\
      \;\;\;\;t\_0\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if x < 360 or 3.5999999999999998e165 < x

        1. Initial program 73.2%

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

          \[\leadsto \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. Applied rewrites98.9%

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

          \[\leadsto \left(e^{\mathsf{neg}\left(x\right)} + e^{-1 \cdot x}\right) \cdot \frac{1}{2} \]
        5. Step-by-step derivation
          1. mul-1-negN/A

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \mathsf{fma}\left(x - 2, x, 2\right) \cdot \frac{1}{2} \]
          4. lower--.f6457.5

            \[\leadsto \mathsf{fma}\left(x - 2, x, 2\right) \cdot 0.5 \]
        9. Applied rewrites57.5%

          \[\leadsto \mathsf{fma}\left(x - 2, x, 2\right) \cdot 0.5 \]

        if 360 < x < 3.5999999999999998e165

        1. Initial program 73.2%

          \[\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2} \]
        2. Taylor expanded in 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. lift-/.f64N/A

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

            \[\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} \]
        4. Applied rewrites38.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} \]
        5. Taylor expanded in eps around 0

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

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

            \[\leadsto \frac{\frac{e^{\mathsf{neg}\left(x\right)}}{\varepsilon} - \left(\frac{1}{\varepsilon} - 1\right)}{2} \]
          3. lower-neg.f6412.4

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

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

          \[\leadsto \frac{\frac{1}{\color{blue}{\varepsilon}} - \left(\frac{1}{\varepsilon} - 1\right)}{2} \]
        9. Step-by-step derivation
          1. lift-/.f6418.4

            \[\leadsto \frac{\frac{1}{\varepsilon} - \left(\frac{1}{\varepsilon} - 1\right)}{2} \]
        10. Applied rewrites18.4%

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

      Alternative 7: 60.4% accurate, 3.3× speedup?

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

        1. Initial program 73.2%

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

          \[\leadsto \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. Applied rewrites98.9%

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

          \[\leadsto \left(e^{\mathsf{neg}\left(x\right)} + e^{-1 \cdot x}\right) \cdot \frac{1}{2} \]
        5. Step-by-step derivation
          1. mul-1-negN/A

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \mathsf{fma}\left(x - 2, x, 2\right) \cdot \frac{1}{2} \]
          4. lower--.f6457.5

            \[\leadsto \mathsf{fma}\left(x - 2, x, 2\right) \cdot 0.5 \]
        9. Applied rewrites57.5%

          \[\leadsto \mathsf{fma}\left(x - 2, x, 2\right) \cdot 0.5 \]

        if -7.2e-9 < x

        1. Initial program 73.2%

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

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

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

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

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

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

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

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

            \[\leadsto \mathsf{fma}\left(\frac{1}{3} \cdot x - \frac{1}{2}, {x}^{\color{blue}{2}}, 1\right) \]
          4. sub-flipN/A

            \[\leadsto \mathsf{fma}\left(\frac{1}{3} \cdot x + \left(\mathsf{neg}\left(\frac{1}{2}\right)\right), {x}^{2}, 1\right) \]
          5. metadata-evalN/A

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

            \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{3}, x, \frac{-1}{2}\right), {x}^{2}, 1\right) \]
          7. unpow2N/A

            \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{3}, x, \frac{-1}{2}\right), x \cdot x, 1\right) \]
          8. lower-*.f6452.6

            \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(0.3333333333333333, x, -0.5\right), x \cdot x, 1\right) \]
        7. Applied rewrites52.6%

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

      Alternative 8: 57.5% accurate, 5.1× speedup?

      \[\begin{array}{l} \\ \mathsf{fma}\left(x - 2, x, 2\right) \cdot 0.5 \end{array} \]
      (FPCore (x eps) :precision binary64 (* (fma (- x 2.0) x 2.0) 0.5))
      double code(double x, double eps) {
      	return fma((x - 2.0), x, 2.0) * 0.5;
      }
      
      function code(x, eps)
      	return Float64(fma(Float64(x - 2.0), x, 2.0) * 0.5)
      end
      
      code[x_, eps_] := N[(N[(N[(x - 2.0), $MachinePrecision] * x + 2.0), $MachinePrecision] * 0.5), $MachinePrecision]
      
      \begin{array}{l}
      
      \\
      \mathsf{fma}\left(x - 2, x, 2\right) \cdot 0.5
      \end{array}
      
      Derivation
      1. Initial program 73.2%

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

        \[\leadsto \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. Applied rewrites98.9%

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

        \[\leadsto \left(e^{\mathsf{neg}\left(x\right)} + e^{-1 \cdot x}\right) \cdot \frac{1}{2} \]
      5. Step-by-step derivation
        1. mul-1-negN/A

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \mathsf{fma}\left(x - 2, x, 2\right) \cdot \frac{1}{2} \]
        4. lower--.f6457.5

          \[\leadsto \mathsf{fma}\left(x - 2, x, 2\right) \cdot 0.5 \]
      9. Applied rewrites57.5%

        \[\leadsto \mathsf{fma}\left(x - 2, x, 2\right) \cdot 0.5 \]
      10. Add Preprocessing

      Alternative 9: 46.8% accurate, 4.4× speedup?

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

        1. Initial program 73.2%

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

          \[\leadsto \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. Applied rewrites98.9%

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

          \[\leadsto \left(2 + x \cdot \left(\left(\varepsilon + -1 \cdot \left(1 + \varepsilon\right)\right) - 1\right)\right) \cdot \frac{1}{2} \]
        5. Step-by-step derivation
          1. +-commutativeN/A

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

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

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

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

            \[\leadsto \mathsf{fma}\left(\left(\varepsilon - \left(\mathsf{neg}\left(-1 \cdot \left(1 + \varepsilon\right)\right)\right)\right) - 1, x, 2\right) \cdot \frac{1}{2} \]
          6. mul-1-negN/A

            \[\leadsto \mathsf{fma}\left(\left(\varepsilon - \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(1 + \varepsilon\right)\right)\right)\right)\right)\right) - 1, x, 2\right) \cdot \frac{1}{2} \]
          7. +-commutativeN/A

            \[\leadsto \mathsf{fma}\left(\left(\varepsilon - \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(\varepsilon + 1\right)\right)\right)\right)\right)\right) - 1, x, 2\right) \cdot \frac{1}{2} \]
          8. add-negateN/A

            \[\leadsto \mathsf{fma}\left(\left(\varepsilon - \left(\mathsf{neg}\left(\left(\left(\mathsf{neg}\left(\varepsilon\right)\right) - 1\right)\right)\right)\right) - 1, x, 2\right) \cdot \frac{1}{2} \]
          9. mul-1-negN/A

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

            \[\leadsto \mathsf{fma}\left(\left(\varepsilon - \left(1 - -1 \cdot \varepsilon\right)\right) - 1, x, 2\right) \cdot \frac{1}{2} \]
          11. mul-1-negN/A

            \[\leadsto \mathsf{fma}\left(\left(\varepsilon - \left(1 - \left(\mathsf{neg}\left(\varepsilon\right)\right)\right)\right) - 1, x, 2\right) \cdot \frac{1}{2} \]
          12. add-flipN/A

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

            \[\leadsto \mathsf{fma}\left(\left(\varepsilon - \left(1 + \varepsilon\right)\right) - 1, x, 2\right) \cdot \frac{1}{2} \]
          14. +-commutativeN/A

            \[\leadsto \mathsf{fma}\left(\left(\varepsilon - \left(\varepsilon + 1\right)\right) - 1, x, 2\right) \cdot \frac{1}{2} \]
          15. add-flipN/A

            \[\leadsto \mathsf{fma}\left(\left(\varepsilon - \left(\varepsilon - \left(\mathsf{neg}\left(1\right)\right)\right)\right) - 1, x, 2\right) \cdot \frac{1}{2} \]
          16. metadata-evalN/A

            \[\leadsto \mathsf{fma}\left(\left(\varepsilon - \left(\varepsilon - -1\right)\right) - 1, x, 2\right) \cdot \frac{1}{2} \]
          17. lower--.f6443.3

            \[\leadsto \mathsf{fma}\left(\left(\varepsilon - \left(\varepsilon - -1\right)\right) - 1, x, 2\right) \cdot 0.5 \]
        6. Applied rewrites43.3%

          \[\leadsto \mathsf{fma}\left(\left(\varepsilon - \left(\varepsilon - -1\right)\right) - 1, x, 2\right) \cdot 0.5 \]
        7. Taylor expanded in eps around 0

          \[\leadsto \mathsf{fma}\left(-2, x, 2\right) \cdot \frac{1}{2} \]
        8. Step-by-step derivation
          1. Applied rewrites43.3%

            \[\leadsto \mathsf{fma}\left(-2, x, 2\right) \cdot 0.5 \]

          if 0.0850000000000000061 < x

          1. Initial program 73.2%

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

            \[\leadsto \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. Applied rewrites98.9%

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

            \[\leadsto \left(\left(1 + x \cdot \left(\varepsilon - 1\right)\right) - \left(-e^{-\mathsf{fma}\left(x, \varepsilon, x\right)}\right)\right) \cdot \frac{1}{2} \]
          5. Step-by-step derivation
            1. sub-negate-revN/A

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

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

              \[\leadsto \left(\left(1 + \left(\varepsilon - 1\right) \cdot x\right) - \left(-e^{-\mathsf{fma}\left(x, \varepsilon, x\right)}\right)\right) \cdot \frac{1}{2} \]
            4. +-commutativeN/A

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

              \[\leadsto \left(\mathsf{fma}\left(\varepsilon - 1, x, 1\right) - \left(-e^{-\mathsf{fma}\left(x, \varepsilon, x\right)}\right)\right) \cdot \frac{1}{2} \]
            6. lift--.f6463.5

              \[\leadsto \left(\mathsf{fma}\left(\varepsilon - 1, x, 1\right) - \left(-e^{-\mathsf{fma}\left(x, \varepsilon, x\right)}\right)\right) \cdot 0.5 \]
          6. Applied rewrites63.5%

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

            \[\leadsto \left(\mathsf{fma}\left(\varepsilon - 1, x, 1\right) - -1\right) \cdot \frac{1}{2} \]
          8. Step-by-step derivation
            1. Applied rewrites49.4%

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

              \[\leadsto \left(\varepsilon \cdot x - -1\right) \cdot \frac{1}{2} \]
            3. Step-by-step derivation
              1. *-commutativeN/A

                \[\leadsto \left(x \cdot \varepsilon - -1\right) \cdot \frac{1}{2} \]
              2. lower-*.f6416.1

                \[\leadsto \left(x \cdot \varepsilon - -1\right) \cdot 0.5 \]
            4. Applied rewrites16.1%

              \[\leadsto \left(x \cdot \varepsilon - -1\right) \cdot 0.5 \]
          9. Recombined 2 regimes into one program.
          10. Add Preprocessing

          Alternative 10: 43.8% accurate, 58.4× speedup?

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

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

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

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

            Reproduce

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