NMSE Section 6.1 mentioned, A

Percentage Accurate: 73.4% → 99.1%
Time: 5.2s
Alternatives: 11
Speedup: 2.1×

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 11 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.4% 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.1% accurate, 1.2× speedup?

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

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

    \[\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. Add Preprocessing
  3. 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)} \]
  4. Step-by-step derivation
    1. *-commutativeN/A

      \[\leadsto \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) \cdot \color{blue}{\frac{1}{2}} \]
    2. lower-*.f64N/A

      \[\leadsto \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) \cdot \color{blue}{\frac{1}{2}} \]
  5. Applied rewrites99.1%

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

Alternative 2: 85.0% accurate, 1.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\varepsilon \leq 1:\\ \;\;\;\;e^{-x}\\ \mathbf{else}:\\ \;\;\;\;\left(e^{x \cdot \varepsilon} - \left(-e^{-x \cdot \varepsilon}\right)\right) \cdot 0.5\\ \end{array} \end{array} \]
(FPCore (x eps)
 :precision binary64
 (if (<= eps 1.0)
   (exp (- x))
   (* (- (exp (* x eps)) (- (exp (- (* x eps))))) 0.5)))
double code(double x, double eps) {
	double tmp;
	if (eps <= 1.0) {
		tmp = exp(-x);
	} else {
		tmp = (exp((x * eps)) - -exp(-(x * eps))) * 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 <= 1.0d0) then
        tmp = exp(-x)
    else
        tmp = (exp((x * eps)) - -exp(-(x * eps))) * 0.5d0
    end if
    code = tmp
end function
public static double code(double x, double eps) {
	double tmp;
	if (eps <= 1.0) {
		tmp = Math.exp(-x);
	} else {
		tmp = (Math.exp((x * eps)) - -Math.exp(-(x * eps))) * 0.5;
	}
	return tmp;
}
def code(x, eps):
	tmp = 0
	if eps <= 1.0:
		tmp = math.exp(-x)
	else:
		tmp = (math.exp((x * eps)) - -math.exp(-(x * eps))) * 0.5
	return tmp
function code(x, eps)
	tmp = 0.0
	if (eps <= 1.0)
		tmp = exp(Float64(-x));
	else
		tmp = Float64(Float64(exp(Float64(x * eps)) - Float64(-exp(Float64(-Float64(x * eps))))) * 0.5);
	end
	return tmp
end
function tmp_2 = code(x, eps)
	tmp = 0.0;
	if (eps <= 1.0)
		tmp = exp(-x);
	else
		tmp = (exp((x * eps)) - -exp(-(x * eps))) * 0.5;
	end
	tmp_2 = tmp;
end
code[x_, eps_] := If[LessEqual[eps, 1.0], N[Exp[(-x)], $MachinePrecision], N[(N[(N[Exp[N[(x * eps), $MachinePrecision]], $MachinePrecision] - (-N[Exp[(-N[(x * eps), $MachinePrecision])], $MachinePrecision])), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq 1:\\
\;\;\;\;e^{-x}\\

\mathbf{else}:\\
\;\;\;\;\left(e^{x \cdot \varepsilon} - \left(-e^{-x \cdot \varepsilon}\right)\right) \cdot 0.5\\


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

    1. Initial program 62.7%

      \[\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. Add Preprocessing
    3. 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)} \]
    4. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \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) \cdot \color{blue}{\frac{1}{2}} \]
      2. lower-*.f64N/A

        \[\leadsto \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) \cdot \color{blue}{\frac{1}{2}} \]
    5. Applied rewrites98.7%

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

      \[\leadsto \left(e^{\varepsilon \cdot x} - \left(-e^{-\mathsf{fma}\left(x, \varepsilon, x\right)}\right)\right) \cdot \frac{1}{2} \]
    7. Step-by-step derivation
      1. *-commutativeN/A

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

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

        \[\leadsto \left(e^{x \cdot \varepsilon} - \left(-e^{-\mathsf{fma}\left(x, \varepsilon, x\right)}\right)\right) \cdot \frac{1}{2} \]
      4. lower-*.f6484.8

        \[\leadsto \left(e^{x \cdot \varepsilon} - \left(-e^{-\mathsf{fma}\left(x, \varepsilon, x\right)}\right)\right) \cdot 0.5 \]
    8. Applied rewrites84.8%

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

      \[\leadsto e^{\mathsf{neg}\left(x\right)} \]
    10. Step-by-step derivation
      1. distribute-rgt-neg-inN/A

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

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

        \[\leadsto e^{\mathsf{neg}\left(x\right)} \]
      4. lift-neg.f6479.0

        \[\leadsto e^{-x} \]
    11. Applied rewrites79.0%

      \[\leadsto e^{-x} \]

    if 1 < eps

    1. Initial program 100.0%

      \[\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2} \]
    2. Add Preprocessing
    3. 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)} \]
    4. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \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) \cdot \color{blue}{\frac{1}{2}} \]
      2. lower-*.f64N/A

        \[\leadsto \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) \cdot \color{blue}{\frac{1}{2}} \]
    5. Applied rewrites99.9%

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

      \[\leadsto \left(e^{\varepsilon \cdot x} - \left(-e^{-\mathsf{fma}\left(x, \varepsilon, x\right)}\right)\right) \cdot \frac{1}{2} \]
    7. Step-by-step derivation
      1. *-commutativeN/A

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

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

        \[\leadsto \left(e^{x \cdot \varepsilon} - \left(-e^{-\mathsf{fma}\left(x, \varepsilon, x\right)}\right)\right) \cdot \frac{1}{2} \]
      4. lower-*.f6499.9

        \[\leadsto \left(e^{x \cdot \varepsilon} - \left(-e^{-\mathsf{fma}\left(x, \varepsilon, x\right)}\right)\right) \cdot 0.5 \]
    8. Applied rewrites99.9%

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

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

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

        \[\leadsto \left(e^{x \cdot \varepsilon} - \left(-e^{-x \cdot \varepsilon}\right)\right) \cdot 0.5 \]
    11. Applied rewrites100.0%

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

Alternative 3: 73.9% accurate, 2.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{-x}\\ \mathbf{if}\;x \leq -700:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq -1.612 \cdot 10^{-273}:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-1, \frac{\varepsilon \cdot \varepsilon - 1}{\varepsilon - 1}, -1\right), x, 2\right) \cdot 0.5\\ \mathbf{elif}\;x \leq 3.1 \cdot 10^{+85}:\\ \;\;\;\;\left(e^{x \cdot \varepsilon} - -1\right) \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x eps)
 :precision binary64
 (let* ((t_0 (exp (- x))))
   (if (<= x -700.0)
     t_0
     (if (<= x -1.612e-273)
       (* (fma (fma -1.0 (/ (- (* eps eps) 1.0) (- eps 1.0)) -1.0) x 2.0) 0.5)
       (if (<= x 3.1e+85) (* (- (exp (* x eps)) -1.0) 0.5) t_0)))))
double code(double x, double eps) {
	double t_0 = exp(-x);
	double tmp;
	if (x <= -700.0) {
		tmp = t_0;
	} else if (x <= -1.612e-273) {
		tmp = fma(fma(-1.0, (((eps * eps) - 1.0) / (eps - 1.0)), -1.0), x, 2.0) * 0.5;
	} else if (x <= 3.1e+85) {
		tmp = (exp((x * eps)) - -1.0) * 0.5;
	} else {
		tmp = t_0;
	}
	return tmp;
}
function code(x, eps)
	t_0 = exp(Float64(-x))
	tmp = 0.0
	if (x <= -700.0)
		tmp = t_0;
	elseif (x <= -1.612e-273)
		tmp = Float64(fma(fma(-1.0, Float64(Float64(Float64(eps * eps) - 1.0) / Float64(eps - 1.0)), -1.0), x, 2.0) * 0.5);
	elseif (x <= 3.1e+85)
		tmp = Float64(Float64(exp(Float64(x * eps)) - -1.0) * 0.5);
	else
		tmp = t_0;
	end
	return tmp
end
code[x_, eps_] := Block[{t$95$0 = N[Exp[(-x)], $MachinePrecision]}, If[LessEqual[x, -700.0], t$95$0, If[LessEqual[x, -1.612e-273], N[(N[(N[(-1.0 * N[(N[(N[(eps * eps), $MachinePrecision] - 1.0), $MachinePrecision] / N[(eps - 1.0), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision] * x + 2.0), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 3.1e+85], N[(N[(N[Exp[N[(x * eps), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision] * 0.5), $MachinePrecision], t$95$0]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := e^{-x}\\
\mathbf{if}\;x \leq -700:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;x \leq 3.1 \cdot 10^{+85}:\\
\;\;\;\;\left(e^{x \cdot \varepsilon} - -1\right) \cdot 0.5\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -700 or 3.10000000000000011e85 < x

    1. Initial program 99.8%

      \[\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2} \]
    2. Add Preprocessing
    3. 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)} \]
    4. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \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) \cdot \color{blue}{\frac{1}{2}} \]
      2. lower-*.f64N/A

        \[\leadsto \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) \cdot \color{blue}{\frac{1}{2}} \]
    5. Applied rewrites99.9%

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

      \[\leadsto \left(e^{\varepsilon \cdot x} - \left(-e^{-\mathsf{fma}\left(x, \varepsilon, x\right)}\right)\right) \cdot \frac{1}{2} \]
    7. Step-by-step derivation
      1. *-commutativeN/A

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

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

        \[\leadsto \left(e^{x \cdot \varepsilon} - \left(-e^{-\mathsf{fma}\left(x, \varepsilon, x\right)}\right)\right) \cdot \frac{1}{2} \]
      4. lower-*.f6480.4

        \[\leadsto \left(e^{x \cdot \varepsilon} - \left(-e^{-\mathsf{fma}\left(x, \varepsilon, x\right)}\right)\right) \cdot 0.5 \]
    8. Applied rewrites80.4%

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

      \[\leadsto e^{\mathsf{neg}\left(x\right)} \]
    10. Step-by-step derivation
      1. distribute-rgt-neg-inN/A

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

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

        \[\leadsto e^{\mathsf{neg}\left(x\right)} \]
      4. lift-neg.f6469.8

        \[\leadsto e^{-x} \]
    11. Applied rewrites69.8%

      \[\leadsto e^{-x} \]

    if -700 < x < -1.61199999999999995e-273

    1. Initial program 55.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. Add Preprocessing
    3. 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)} \]
    4. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \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) \cdot \color{blue}{\frac{1}{2}} \]
      2. lower-*.f64N/A

        \[\leadsto \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) \cdot \color{blue}{\frac{1}{2}} \]
    5. Applied rewrites98.5%

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(-1, \varepsilon + 1, -\left(1 - \varepsilon\right)\right), x, 2\right) \cdot \frac{1}{2} \]
      9. lift--.f6469.9

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(-1, \varepsilon + 1, -\left(1 - \varepsilon\right)\right), x, 2\right) \cdot 0.5 \]
    8. Applied rewrites69.9%

      \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(-1, \varepsilon + 1, -\left(1 - \varepsilon\right)\right), x, 2\right) \cdot 0.5 \]
    9. Step-by-step derivation
      1. lift-+.f64N/A

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(-1, \frac{\varepsilon \cdot \varepsilon - 1}{\varepsilon - 1}, -\left(1 - \varepsilon\right)\right), x, 2\right) \cdot \frac{1}{2} \]
      9. lower--.f6476.8

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

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

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

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

      if -1.61199999999999995e-273 < x < 3.10000000000000011e85

      1. Initial program 62.8%

        \[\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2} \]
      2. Add Preprocessing
      3. 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)} \]
      4. Step-by-step derivation
        1. *-commutativeN/A

          \[\leadsto \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) \cdot \color{blue}{\frac{1}{2}} \]
        2. lower-*.f64N/A

          \[\leadsto \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) \cdot \color{blue}{\frac{1}{2}} \]
      5. Applied rewrites98.8%

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

        \[\leadsto \left(e^{\varepsilon \cdot x} - \left(-e^{-\mathsf{fma}\left(x, \varepsilon, x\right)}\right)\right) \cdot \frac{1}{2} \]
      7. Step-by-step derivation
        1. *-commutativeN/A

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

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

          \[\leadsto \left(e^{x \cdot \varepsilon} - \left(-e^{-\mathsf{fma}\left(x, \varepsilon, x\right)}\right)\right) \cdot \frac{1}{2} \]
        4. lower-*.f6490.3

          \[\leadsto \left(e^{x \cdot \varepsilon} - \left(-e^{-\mathsf{fma}\left(x, \varepsilon, x\right)}\right)\right) \cdot 0.5 \]
      8. Applied rewrites90.3%

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

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

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

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

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

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

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

      Alternative 4: 69.4% accurate, 2.2× speedup?

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

        1. Initial program 70.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. Add Preprocessing
        3. 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)} \]
        4. Step-by-step derivation
          1. *-commutativeN/A

            \[\leadsto \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) \cdot \color{blue}{\frac{1}{2}} \]
          2. lower-*.f64N/A

            \[\leadsto \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) \cdot \color{blue}{\frac{1}{2}} \]
        5. Applied rewrites98.9%

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

          \[\leadsto \left(e^{\varepsilon \cdot x} - \left(-e^{-\mathsf{fma}\left(x, \varepsilon, x\right)}\right)\right) \cdot \frac{1}{2} \]
        7. Step-by-step derivation
          1. *-commutativeN/A

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

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

            \[\leadsto \left(e^{x \cdot \varepsilon} - \left(-e^{-\mathsf{fma}\left(x, \varepsilon, x\right)}\right)\right) \cdot \frac{1}{2} \]
          4. lower-*.f6498.9

            \[\leadsto \left(e^{x \cdot \varepsilon} - \left(-e^{-\mathsf{fma}\left(x, \varepsilon, x\right)}\right)\right) \cdot 0.5 \]
        8. Applied rewrites98.9%

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

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

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

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

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

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

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

          if -1.61199999999999995e-273 < x < 3.10000000000000011e85

          1. Initial program 62.8%

            \[\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2} \]
          2. Add Preprocessing
          3. 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)} \]
          4. Step-by-step derivation
            1. *-commutativeN/A

              \[\leadsto \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) \cdot \color{blue}{\frac{1}{2}} \]
            2. lower-*.f64N/A

              \[\leadsto \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) \cdot \color{blue}{\frac{1}{2}} \]
          5. Applied rewrites98.8%

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

            \[\leadsto \left(e^{\varepsilon \cdot x} - \left(-e^{-\mathsf{fma}\left(x, \varepsilon, x\right)}\right)\right) \cdot \frac{1}{2} \]
          7. Step-by-step derivation
            1. *-commutativeN/A

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

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

              \[\leadsto \left(e^{x \cdot \varepsilon} - \left(-e^{-\mathsf{fma}\left(x, \varepsilon, x\right)}\right)\right) \cdot \frac{1}{2} \]
            4. lower-*.f6490.3

              \[\leadsto \left(e^{x \cdot \varepsilon} - \left(-e^{-\mathsf{fma}\left(x, \varepsilon, x\right)}\right)\right) \cdot 0.5 \]
          8. Applied rewrites90.3%

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

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

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

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

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

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

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

            if 3.10000000000000011e85 < x

            1. Initial program 99.9%

              \[\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2} \]
            2. Add Preprocessing
            3. 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)} \]
            4. Step-by-step derivation
              1. *-commutativeN/A

                \[\leadsto \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) \cdot \color{blue}{\frac{1}{2}} \]
              2. lower-*.f64N/A

                \[\leadsto \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) \cdot \color{blue}{\frac{1}{2}} \]
            5. Applied rewrites100.0%

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

              \[\leadsto \left(e^{\varepsilon \cdot x} - \left(-e^{-\mathsf{fma}\left(x, \varepsilon, x\right)}\right)\right) \cdot \frac{1}{2} \]
            7. Step-by-step derivation
              1. *-commutativeN/A

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

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

                \[\leadsto \left(e^{x \cdot \varepsilon} - \left(-e^{-\mathsf{fma}\left(x, \varepsilon, x\right)}\right)\right) \cdot \frac{1}{2} \]
              4. lower-*.f6467.8

                \[\leadsto \left(e^{x \cdot \varepsilon} - \left(-e^{-\mathsf{fma}\left(x, \varepsilon, x\right)}\right)\right) \cdot 0.5 \]
            8. Applied rewrites67.8%

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

              \[\leadsto e^{\mathsf{neg}\left(x\right)} \]
            10. Step-by-step derivation
              1. distribute-rgt-neg-inN/A

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

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

                \[\leadsto e^{\mathsf{neg}\left(x\right)} \]
              4. lift-neg.f6450.3

                \[\leadsto e^{-x} \]
            11. Applied rewrites50.3%

              \[\leadsto e^{-x} \]
          14. Recombined 3 regimes into one program.
          15. Add Preprocessing

          Alternative 5: 71.5% accurate, 2.5× speedup?

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

            1. Initial program 70.8%

              \[\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2} \]
            2. Add Preprocessing
            3. 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)} \]
            4. Step-by-step derivation
              1. *-commutativeN/A

                \[\leadsto \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) \cdot \color{blue}{\frac{1}{2}} \]
              2. lower-*.f64N/A

                \[\leadsto \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) \cdot \color{blue}{\frac{1}{2}} \]
            5. Applied rewrites99.0%

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

              \[\leadsto \left(e^{\varepsilon \cdot x} - \left(-e^{-\mathsf{fma}\left(x, \varepsilon, x\right)}\right)\right) \cdot \frac{1}{2} \]
            7. Step-by-step derivation
              1. *-commutativeN/A

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

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

                \[\leadsto \left(e^{x \cdot \varepsilon} - \left(-e^{-\mathsf{fma}\left(x, \varepsilon, x\right)}\right)\right) \cdot \frac{1}{2} \]
              4. lower-*.f6488.1

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

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

              \[\leadsto e^{\mathsf{neg}\left(x\right)} \]
            10. Step-by-step derivation
              1. distribute-rgt-neg-inN/A

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

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

                \[\leadsto e^{\mathsf{neg}\left(x\right)} \]
              4. lift-neg.f6474.0

                \[\leadsto e^{-x} \]
            11. Applied rewrites74.0%

              \[\leadsto e^{-x} \]

            if 4.4e217 < eps < 7.20000000000000003e248

            1. Initial program 100.0%

              \[\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2} \]
            2. Add Preprocessing
            3. 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)} \]
            4. Step-by-step derivation
              1. *-commutativeN/A

                \[\leadsto \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) \cdot \color{blue}{\frac{1}{2}} \]
              2. lower-*.f64N/A

                \[\leadsto \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) \cdot \color{blue}{\frac{1}{2}} \]
            5. Applied rewrites100.0%

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

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

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

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

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

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

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

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

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

                \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(-1, \varepsilon + 1, -\left(1 - \varepsilon\right)\right), x, 2\right) \cdot \frac{1}{2} \]
              9. lift--.f6413.2

                \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(-1, \varepsilon + 1, -\left(1 - \varepsilon\right)\right), x, 2\right) \cdot 0.5 \]
            8. Applied rewrites13.2%

              \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(-1, \varepsilon + 1, -\left(1 - \varepsilon\right)\right), x, 2\right) \cdot 0.5 \]
            9. Step-by-step derivation
              1. lift-+.f64N/A

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

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

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

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

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

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

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

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

                \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(-1, \frac{\varepsilon \cdot \varepsilon - 1}{\varepsilon - 1}, -\left(1 - \varepsilon\right)\right), x, 2\right) \cdot 0.5 \]
            10. Applied rewrites49.2%

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

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

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

              if 7.20000000000000003e248 < eps

              1. Initial program 99.9%

                \[\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2} \]
              2. Add Preprocessing
              3. 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)} \]
              4. Step-by-step derivation
                1. *-commutativeN/A

                  \[\leadsto \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) \cdot \color{blue}{\frac{1}{2}} \]
                2. lower-*.f64N/A

                  \[\leadsto \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) \cdot \color{blue}{\frac{1}{2}} \]
              5. Applied rewrites99.9%

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

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

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

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

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

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

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

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

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

                  \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(-1, \varepsilon + 1, -\left(1 - \varepsilon\right)\right), x, 2\right) \cdot \frac{1}{2} \]
                9. lift--.f646.4

                  \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(-1, \varepsilon + 1, -\left(1 - \varepsilon\right)\right), x, 2\right) \cdot 0.5 \]
              8. Applied rewrites6.4%

                \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(-1, \varepsilon + 1, -\left(1 - \varepsilon\right)\right), x, 2\right) \cdot 0.5 \]
              9. Step-by-step derivation
                1. lift-+.f64N/A

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

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

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

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

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

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

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

                  \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(-1, \frac{\varepsilon \cdot \varepsilon - 1}{\varepsilon - 1}, -\left(1 - \varepsilon\right)\right), x, 2\right) \cdot \frac{1}{2} \]
                9. lower--.f6447.7

                  \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(-1, \frac{\varepsilon \cdot \varepsilon - 1}{\varepsilon - 1}, -\left(1 - \varepsilon\right)\right), x, 2\right) \cdot 0.5 \]
              10. Applied rewrites47.7%

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

            Alternative 6: 55.4% accurate, 5.1× speedup?

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

              1. Initial program 71.6%

                \[\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2} \]
              2. Add Preprocessing
              3. 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)} \]
              4. Step-by-step derivation
                1. *-commutativeN/A

                  \[\leadsto \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) \cdot \color{blue}{\frac{1}{2}} \]
                2. lower-*.f64N/A

                  \[\leadsto \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) \cdot \color{blue}{\frac{1}{2}} \]
              5. Applied rewrites98.8%

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

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

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

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

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

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

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

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

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

                  \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(-1, \varepsilon + 1, -\left(1 - \varepsilon\right)\right), x, 2\right) \cdot \frac{1}{2} \]
                9. lift--.f6443.7

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

                \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(-1, \varepsilon + 1, -\left(1 - \varepsilon\right)\right), x, 2\right) \cdot 0.5 \]
              9. Step-by-step derivation
                1. lift-+.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

                if -2.2500000000000001e-240 < x < 4.3000000000000003e-213

                1. Initial program 53.0%

                  \[\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2} \]
                2. Add Preprocessing
                3. 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)} \]
                4. Step-by-step derivation
                  1. *-commutativeN/A

                    \[\leadsto \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) \cdot \color{blue}{\frac{1}{2}} \]
                  2. lower-*.f64N/A

                    \[\leadsto \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) \cdot \color{blue}{\frac{1}{2}} \]
                5. Applied rewrites100.0%

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

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

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

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

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

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

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

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

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

                    \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(-1, \varepsilon + 1, -\left(1 - \varepsilon\right)\right), x, 2\right) \cdot \frac{1}{2} \]
                  9. lift--.f6492.7

                    \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(-1, \varepsilon + 1, -\left(1 - \varepsilon\right)\right), x, 2\right) \cdot 0.5 \]
                8. Applied rewrites92.7%

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

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

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

                  if 4.3000000000000003e-213 < x

                  1. Initial program 81.0%

                    \[\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2} \]
                  2. Add Preprocessing
                  3. 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)} \]
                  4. Step-by-step derivation
                    1. *-commutativeN/A

                      \[\leadsto \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) \cdot \color{blue}{\frac{1}{2}} \]
                    2. lower-*.f64N/A

                      \[\leadsto \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) \cdot \color{blue}{\frac{1}{2}} \]
                  5. Applied rewrites99.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                        \[\leadsto \left(\mathsf{fma}\left(-x, \frac{1 - \varepsilon \cdot \varepsilon}{\varepsilon + 1}, 1\right) - \left(-1\right)\right) \cdot \frac{1}{2} \]
                      10. lower-+.f6440.9

                        \[\leadsto \left(\mathsf{fma}\left(-x, \frac{1 - \varepsilon \cdot \varepsilon}{\varepsilon + 1}, 1\right) - \left(-1\right)\right) \cdot 0.5 \]
                    3. Applied rewrites40.9%

                      \[\leadsto \left(\mathsf{fma}\left(-x, \frac{1 - \varepsilon \cdot \varepsilon}{\varepsilon + 1}, 1\right) - \left(-1\right)\right) \cdot 0.5 \]
                  11. Recombined 3 regimes into one program.
                  12. Add Preprocessing

                  Alternative 7: 52.3% accurate, 5.9× speedup?

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

                    1. Initial program 70.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. Add Preprocessing
                    3. 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)} \]
                    4. Step-by-step derivation
                      1. *-commutativeN/A

                        \[\leadsto \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) \cdot \color{blue}{\frac{1}{2}} \]
                      2. lower-*.f64N/A

                        \[\leadsto \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) \cdot \color{blue}{\frac{1}{2}} \]
                    5. Applied rewrites98.9%

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

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

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

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

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

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

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

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

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

                        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(-1, \varepsilon + 1, -\left(1 - \varepsilon\right)\right), x, 2\right) \cdot \frac{1}{2} \]
                      9. lift--.f6447.4

                        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(-1, \varepsilon + 1, -\left(1 - \varepsilon\right)\right), x, 2\right) \cdot 0.5 \]
                    8. Applied rewrites47.4%

                      \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(-1, \varepsilon + 1, -\left(1 - \varepsilon\right)\right), x, 2\right) \cdot 0.5 \]
                    9. Step-by-step derivation
                      1. lift-+.f64N/A

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

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

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

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

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

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

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

                        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(-1, \frac{\varepsilon \cdot \varepsilon - 1}{\varepsilon - 1}, -\left(1 - \varepsilon\right)\right), x, 2\right) \cdot \frac{1}{2} \]
                      9. lower--.f6459.6

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

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

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

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

                      if -1.61199999999999995e-273 < x

                      1. Initial program 75.4%

                        \[\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. Add Preprocessing
                      3. 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)} \]
                      4. Step-by-step derivation
                        1. *-commutativeN/A

                          \[\leadsto \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) \cdot \color{blue}{\frac{1}{2}} \]
                        2. lower-*.f64N/A

                          \[\leadsto \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) \cdot \color{blue}{\frac{1}{2}} \]
                      5. Applied rewrites99.2%

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

                        \[\leadsto \left(e^{\varepsilon \cdot x} - \left(-e^{-\mathsf{fma}\left(x, \varepsilon, x\right)}\right)\right) \cdot \frac{1}{2} \]
                      7. Step-by-step derivation
                        1. *-commutativeN/A

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

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

                          \[\leadsto \left(e^{x \cdot \varepsilon} - \left(-e^{-\mathsf{fma}\left(x, \varepsilon, x\right)}\right)\right) \cdot \frac{1}{2} \]
                        4. lower-*.f6482.7

                          \[\leadsto \left(e^{x \cdot \varepsilon} - \left(-e^{-\mathsf{fma}\left(x, \varepsilon, x\right)}\right)\right) \cdot 0.5 \]
                      8. Applied rewrites82.7%

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

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

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

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

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

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

                            \[\leadsto \left(\mathsf{fma}\left(\varepsilon - 1, x, 1\right) - \left(-1\right)\right) \cdot \frac{1}{2} \]
                          4. lift--.f6446.3

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

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

                      Alternative 8: 49.8% accurate, 10.1× speedup?

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

                        1. Initial program 70.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. Add Preprocessing
                        3. 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)} \]
                        4. Step-by-step derivation
                          1. *-commutativeN/A

                            \[\leadsto \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) \cdot \color{blue}{\frac{1}{2}} \]
                          2. lower-*.f64N/A

                            \[\leadsto \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) \cdot \color{blue}{\frac{1}{2}} \]
                        5. Applied rewrites98.9%

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

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

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

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

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

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

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

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

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

                            \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(-1, \varepsilon + 1, -\left(1 - \varepsilon\right)\right), x, 2\right) \cdot \frac{1}{2} \]
                          9. lift--.f6447.4

                            \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(-1, \varepsilon + 1, -\left(1 - \varepsilon\right)\right), x, 2\right) \cdot 0.5 \]
                        8. Applied rewrites47.4%

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

                          \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(-1, \varepsilon + 1, -1\right), x, 2\right) \cdot \frac{1}{2} \]
                        10. Step-by-step derivation
                          1. Applied rewrites55.0%

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

                          if -1.61199999999999995e-273 < x

                          1. Initial program 75.4%

                            \[\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. Add Preprocessing
                          3. 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)} \]
                          4. Step-by-step derivation
                            1. *-commutativeN/A

                              \[\leadsto \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) \cdot \color{blue}{\frac{1}{2}} \]
                            2. lower-*.f64N/A

                              \[\leadsto \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) \cdot \color{blue}{\frac{1}{2}} \]
                          5. Applied rewrites99.2%

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

                            \[\leadsto \left(e^{\varepsilon \cdot x} - \left(-e^{-\mathsf{fma}\left(x, \varepsilon, x\right)}\right)\right) \cdot \frac{1}{2} \]
                          7. Step-by-step derivation
                            1. *-commutativeN/A

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

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

                              \[\leadsto \left(e^{x \cdot \varepsilon} - \left(-e^{-\mathsf{fma}\left(x, \varepsilon, x\right)}\right)\right) \cdot \frac{1}{2} \]
                            4. lower-*.f6482.7

                              \[\leadsto \left(e^{x \cdot \varepsilon} - \left(-e^{-\mathsf{fma}\left(x, \varepsilon, x\right)}\right)\right) \cdot 0.5 \]
                          8. Applied rewrites82.7%

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

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

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

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

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

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

                                \[\leadsto \left(\mathsf{fma}\left(\varepsilon - 1, x, 1\right) - \left(-1\right)\right) \cdot \frac{1}{2} \]
                              4. lift--.f6446.3

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

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

                          Alternative 9: 47.3% accurate, 12.4× speedup?

                          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 2 \cdot 10^{-8}:\\ \;\;\;\;\mathsf{fma}\left(-2, x, 2\right) \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot \varepsilon - \left(-1\right)\right) \cdot 0.5\\ \end{array} \end{array} \]
                          (FPCore (x eps)
                           :precision binary64
                           (if (<= x 2e-8) (* (fma -2.0 x 2.0) 0.5) (* (- (* x eps) (- 1.0)) 0.5)))
                          double code(double x, double eps) {
                          	double tmp;
                          	if (x <= 2e-8) {
                          		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 <= 2e-8)
                          		tmp = Float64(fma(-2.0, x, 2.0) * 0.5);
                          	else
                          		tmp = Float64(Float64(Float64(x * eps) - Float64(-1.0)) * 0.5);
                          	end
                          	return tmp
                          end
                          
                          code[x_, eps_] := If[LessEqual[x, 2e-8], 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 2 \cdot 10^{-8}:\\
                          \;\;\;\;\mathsf{fma}\left(-2, x, 2\right) \cdot 0.5\\
                          
                          \mathbf{else}:\\
                          \;\;\;\;\left(x \cdot \varepsilon - \left(-1\right)\right) \cdot 0.5\\
                          
                          
                          \end{array}
                          \end{array}
                          
                          Derivation
                          1. Split input into 2 regimes
                          2. if x < 2e-8

                            1. Initial program 63.2%

                              \[\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2} \]
                            2. Add Preprocessing
                            3. 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)} \]
                            4. Step-by-step derivation
                              1. *-commutativeN/A

                                \[\leadsto \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) \cdot \color{blue}{\frac{1}{2}} \]
                              2. lower-*.f64N/A

                                \[\leadsto \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) \cdot \color{blue}{\frac{1}{2}} \]
                            5. Applied rewrites99.2%

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

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

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

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

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

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

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

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

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

                                \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(-1, \varepsilon + 1, -\left(1 - \varepsilon\right)\right), x, 2\right) \cdot \frac{1}{2} \]
                              9. lift--.f6460.6

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

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

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

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

                              if 2e-8 < x

                              1. Initial program 98.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. Add Preprocessing
                              3. 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)} \]
                              4. Step-by-step derivation
                                1. *-commutativeN/A

                                  \[\leadsto \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) \cdot \color{blue}{\frac{1}{2}} \]
                                2. lower-*.f64N/A

                                  \[\leadsto \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) \cdot \color{blue}{\frac{1}{2}} \]
                              5. Applied rewrites98.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                    \[\leadsto \left(x \cdot \varepsilon - \left(-1\right)\right) \cdot \frac{1}{2} \]
                                  2. lift-*.f6413.8

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

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

                              Alternative 10: 49.9% accurate, 13.7× speedup?

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

                                \[\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. Add Preprocessing
                              3. 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)} \]
                              4. Step-by-step derivation
                                1. *-commutativeN/A

                                  \[\leadsto \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) \cdot \color{blue}{\frac{1}{2}} \]
                                2. lower-*.f64N/A

                                  \[\leadsto \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) \cdot \color{blue}{\frac{1}{2}} \]
                              5. Applied rewrites99.1%

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

                                \[\leadsto \left(e^{\varepsilon \cdot x} - \left(-e^{-\mathsf{fma}\left(x, \varepsilon, x\right)}\right)\right) \cdot \frac{1}{2} \]
                              7. Step-by-step derivation
                                1. *-commutativeN/A

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

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

                                  \[\leadsto \left(e^{x \cdot \varepsilon} - \left(-e^{-\mathsf{fma}\left(x, \varepsilon, x\right)}\right)\right) \cdot \frac{1}{2} \]
                                4. lower-*.f6489.1

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

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

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

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

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

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

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

                                    \[\leadsto \left(\mathsf{fma}\left(\varepsilon - 1, x, 1\right) - \left(-1\right)\right) \cdot \frac{1}{2} \]
                                  4. lift--.f6449.9

                                    \[\leadsto \left(\mathsf{fma}\left(\varepsilon - 1, x, 1\right) - \left(-1\right)\right) \cdot 0.5 \]
                                4. Applied rewrites49.9%

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

                                Alternative 11: 44.3% accurate, 273.0× 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.4%

                                  \[\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. Add Preprocessing
                                3. Taylor expanded in x around 0

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

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

                                  Reproduce

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