NMSE Section 6.1 mentioned, A

Percentage Accurate: 73.4% → 99.6%
Time: 11.6s
Alternatives: 12
Speedup: 0.7×

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 12 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;
}
real(8) function code(x, eps)
    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.6% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(\frac{1}{\varepsilon} + 1\right) \cdot e^{\left(\varepsilon - 1\right) \cdot x} - e^{\left(-1 - \varepsilon\right) \cdot x} \cdot \left(\frac{1}{\varepsilon} - 1\right)\\ \mathbf{if}\;t\_0 \leq 5:\\ \;\;\;\;e^{-x} \cdot \left(x + 1\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{t\_0}{2}\\ \end{array} \end{array} \]
(FPCore (x eps)
 :precision binary64
 (let* ((t_0
         (-
          (* (+ (/ 1.0 eps) 1.0) (exp (* (- eps 1.0) x)))
          (* (exp (* (- -1.0 eps) x)) (- (/ 1.0 eps) 1.0)))))
   (if (<= t_0 5.0) (* (exp (- x)) (+ x 1.0)) (/ t_0 2.0))))
double code(double x, double eps) {
	double t_0 = (((1.0 / eps) + 1.0) * exp(((eps - 1.0) * x))) - (exp(((-1.0 - eps) * x)) * ((1.0 / eps) - 1.0));
	double tmp;
	if (t_0 <= 5.0) {
		tmp = exp(-x) * (x + 1.0);
	} else {
		tmp = t_0 / 2.0;
	}
	return tmp;
}
real(8) function code(x, eps)
    real(8), intent (in) :: x
    real(8), intent (in) :: eps
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (((1.0d0 / eps) + 1.0d0) * exp(((eps - 1.0d0) * x))) - (exp((((-1.0d0) - eps) * x)) * ((1.0d0 / eps) - 1.0d0))
    if (t_0 <= 5.0d0) then
        tmp = exp(-x) * (x + 1.0d0)
    else
        tmp = t_0 / 2.0d0
    end if
    code = tmp
end function
public static double code(double x, double eps) {
	double t_0 = (((1.0 / eps) + 1.0) * Math.exp(((eps - 1.0) * x))) - (Math.exp(((-1.0 - eps) * x)) * ((1.0 / eps) - 1.0));
	double tmp;
	if (t_0 <= 5.0) {
		tmp = Math.exp(-x) * (x + 1.0);
	} else {
		tmp = t_0 / 2.0;
	}
	return tmp;
}
def code(x, eps):
	t_0 = (((1.0 / eps) + 1.0) * math.exp(((eps - 1.0) * x))) - (math.exp(((-1.0 - eps) * x)) * ((1.0 / eps) - 1.0))
	tmp = 0
	if t_0 <= 5.0:
		tmp = math.exp(-x) * (x + 1.0)
	else:
		tmp = t_0 / 2.0
	return tmp
function code(x, eps)
	t_0 = Float64(Float64(Float64(Float64(1.0 / eps) + 1.0) * exp(Float64(Float64(eps - 1.0) * x))) - Float64(exp(Float64(Float64(-1.0 - eps) * x)) * Float64(Float64(1.0 / eps) - 1.0)))
	tmp = 0.0
	if (t_0 <= 5.0)
		tmp = Float64(exp(Float64(-x)) * Float64(x + 1.0));
	else
		tmp = Float64(t_0 / 2.0);
	end
	return tmp
end
function tmp_2 = code(x, eps)
	t_0 = (((1.0 / eps) + 1.0) * exp(((eps - 1.0) * x))) - (exp(((-1.0 - eps) * x)) * ((1.0 / eps) - 1.0));
	tmp = 0.0;
	if (t_0 <= 5.0)
		tmp = exp(-x) * (x + 1.0);
	else
		tmp = t_0 / 2.0;
	end
	tmp_2 = tmp;
end
code[x_, eps_] := Block[{t$95$0 = N[(N[(N[(N[(1.0 / eps), $MachinePrecision] + 1.0), $MachinePrecision] * N[Exp[N[(N[(eps - 1.0), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Exp[N[(N[(-1.0 - eps), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] * N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 5.0], N[(N[Exp[(-x)], $MachinePrecision] * N[(x + 1.0), $MachinePrecision]), $MachinePrecision], N[(t$95$0 / 2.0), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(\frac{1}{\varepsilon} + 1\right) \cdot e^{\left(\varepsilon - 1\right) \cdot x} - e^{\left(-1 - \varepsilon\right) \cdot x} \cdot \left(\frac{1}{\varepsilon} - 1\right)\\
\mathbf{if}\;t\_0 \leq 5:\\
\;\;\;\;e^{-x} \cdot \left(x + 1\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (*.f64 (+.f64 #s(literal 1 binary64) (/.f64 #s(literal 1 binary64) eps)) (exp.f64 (neg.f64 (*.f64 (-.f64 #s(literal 1 binary64) eps) x)))) (*.f64 (-.f64 (/.f64 #s(literal 1 binary64) eps) #s(literal 1 binary64)) (exp.f64 (neg.f64 (*.f64 (+.f64 #s(literal 1 binary64) eps) x))))) < 5

    1. Initial program 53.5%

      \[\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 0

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

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

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

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

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

      if 5 < (-.f64 (*.f64 (+.f64 #s(literal 1 binary64) (/.f64 #s(literal 1 binary64) eps)) (exp.f64 (neg.f64 (*.f64 (-.f64 #s(literal 1 binary64) eps) x)))) (*.f64 (-.f64 (/.f64 #s(literal 1 binary64) eps) #s(literal 1 binary64)) (exp.f64 (neg.f64 (*.f64 (+.f64 #s(literal 1 binary64) eps) x)))))

      1. Initial program 100.0%

        \[\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2} \]
      2. Add Preprocessing
    7. Recombined 2 regimes into one program.
    8. Final simplification100.0%

      \[\leadsto \begin{array}{l} \mathbf{if}\;\left(\frac{1}{\varepsilon} + 1\right) \cdot e^{\left(\varepsilon - 1\right) \cdot x} - e^{\left(-1 - \varepsilon\right) \cdot x} \cdot \left(\frac{1}{\varepsilon} - 1\right) \leq 5:\\ \;\;\;\;e^{-x} \cdot \left(x + 1\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(\frac{1}{\varepsilon} + 1\right) \cdot e^{\left(\varepsilon - 1\right) \cdot x} - e^{\left(-1 - \varepsilon\right) \cdot x} \cdot \left(\frac{1}{\varepsilon} - 1\right)}{2}\\ \end{array} \]
    9. Add Preprocessing

    Alternative 2: 78.5% accurate, 0.7× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{1}{\varepsilon} - 1\\ t_1 := e^{\left(\varepsilon - 1\right) \cdot x}\\ \mathbf{if}\;\left(\frac{1}{\varepsilon} + 1\right) \cdot t\_1 - e^{\left(-1 - \varepsilon\right) \cdot x} \cdot t\_0 \leq 5:\\ \;\;\;\;e^{-x} \cdot \left(x + 1\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1 \cdot t\_1 - t\_0}{2}\\ \end{array} \end{array} \]
    (FPCore (x eps)
     :precision binary64
     (let* ((t_0 (- (/ 1.0 eps) 1.0)) (t_1 (exp (* (- eps 1.0) x))))
       (if (<=
            (- (* (+ (/ 1.0 eps) 1.0) t_1) (* (exp (* (- -1.0 eps) x)) t_0))
            5.0)
         (* (exp (- x)) (+ x 1.0))
         (/ (- (* 1.0 t_1) t_0) 2.0))))
    double code(double x, double eps) {
    	double t_0 = (1.0 / eps) - 1.0;
    	double t_1 = exp(((eps - 1.0) * x));
    	double tmp;
    	if (((((1.0 / eps) + 1.0) * t_1) - (exp(((-1.0 - eps) * x)) * t_0)) <= 5.0) {
    		tmp = exp(-x) * (x + 1.0);
    	} else {
    		tmp = ((1.0 * t_1) - t_0) / 2.0;
    	}
    	return tmp;
    }
    
    real(8) function code(x, eps)
        real(8), intent (in) :: x
        real(8), intent (in) :: eps
        real(8) :: t_0
        real(8) :: t_1
        real(8) :: tmp
        t_0 = (1.0d0 / eps) - 1.0d0
        t_1 = exp(((eps - 1.0d0) * x))
        if (((((1.0d0 / eps) + 1.0d0) * t_1) - (exp((((-1.0d0) - eps) * x)) * t_0)) <= 5.0d0) then
            tmp = exp(-x) * (x + 1.0d0)
        else
            tmp = ((1.0d0 * t_1) - t_0) / 2.0d0
        end if
        code = tmp
    end function
    
    public static double code(double x, double eps) {
    	double t_0 = (1.0 / eps) - 1.0;
    	double t_1 = Math.exp(((eps - 1.0) * x));
    	double tmp;
    	if (((((1.0 / eps) + 1.0) * t_1) - (Math.exp(((-1.0 - eps) * x)) * t_0)) <= 5.0) {
    		tmp = Math.exp(-x) * (x + 1.0);
    	} else {
    		tmp = ((1.0 * t_1) - t_0) / 2.0;
    	}
    	return tmp;
    }
    
    def code(x, eps):
    	t_0 = (1.0 / eps) - 1.0
    	t_1 = math.exp(((eps - 1.0) * x))
    	tmp = 0
    	if ((((1.0 / eps) + 1.0) * t_1) - (math.exp(((-1.0 - eps) * x)) * t_0)) <= 5.0:
    		tmp = math.exp(-x) * (x + 1.0)
    	else:
    		tmp = ((1.0 * t_1) - t_0) / 2.0
    	return tmp
    
    function code(x, eps)
    	t_0 = Float64(Float64(1.0 / eps) - 1.0)
    	t_1 = exp(Float64(Float64(eps - 1.0) * x))
    	tmp = 0.0
    	if (Float64(Float64(Float64(Float64(1.0 / eps) + 1.0) * t_1) - Float64(exp(Float64(Float64(-1.0 - eps) * x)) * t_0)) <= 5.0)
    		tmp = Float64(exp(Float64(-x)) * Float64(x + 1.0));
    	else
    		tmp = Float64(Float64(Float64(1.0 * t_1) - t_0) / 2.0);
    	end
    	return tmp
    end
    
    function tmp_2 = code(x, eps)
    	t_0 = (1.0 / eps) - 1.0;
    	t_1 = exp(((eps - 1.0) * x));
    	tmp = 0.0;
    	if (((((1.0 / eps) + 1.0) * t_1) - (exp(((-1.0 - eps) * x)) * t_0)) <= 5.0)
    		tmp = exp(-x) * (x + 1.0);
    	else
    		tmp = ((1.0 * t_1) - t_0) / 2.0;
    	end
    	tmp_2 = tmp;
    end
    
    code[x_, eps_] := Block[{t$95$0 = N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision]}, Block[{t$95$1 = N[Exp[N[(N[(eps - 1.0), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[(N[(N[(1.0 / eps), $MachinePrecision] + 1.0), $MachinePrecision] * t$95$1), $MachinePrecision] - N[(N[Exp[N[(N[(-1.0 - eps), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], 5.0], N[(N[Exp[(-x)], $MachinePrecision] * N[(x + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 * t$95$1), $MachinePrecision] - t$95$0), $MachinePrecision] / 2.0), $MachinePrecision]]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := \frac{1}{\varepsilon} - 1\\
    t_1 := e^{\left(\varepsilon - 1\right) \cdot x}\\
    \mathbf{if}\;\left(\frac{1}{\varepsilon} + 1\right) \cdot t\_1 - e^{\left(-1 - \varepsilon\right) \cdot x} \cdot t\_0 \leq 5:\\
    \;\;\;\;e^{-x} \cdot \left(x + 1\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;\frac{1 \cdot t\_1 - t\_0}{2}\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if (-.f64 (*.f64 (+.f64 #s(literal 1 binary64) (/.f64 #s(literal 1 binary64) eps)) (exp.f64 (neg.f64 (*.f64 (-.f64 #s(literal 1 binary64) eps) x)))) (*.f64 (-.f64 (/.f64 #s(literal 1 binary64) eps) #s(literal 1 binary64)) (exp.f64 (neg.f64 (*.f64 (+.f64 #s(literal 1 binary64) eps) x))))) < 5

      1. Initial program 53.5%

        \[\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 0

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

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

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

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

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

        if 5 < (-.f64 (*.f64 (+.f64 #s(literal 1 binary64) (/.f64 #s(literal 1 binary64) eps)) (exp.f64 (neg.f64 (*.f64 (-.f64 #s(literal 1 binary64) eps) x)))) (*.f64 (-.f64 (/.f64 #s(literal 1 binary64) eps) #s(literal 1 binary64)) (exp.f64 (neg.f64 (*.f64 (+.f64 #s(literal 1 binary64) eps) x)))))

        1. Initial program 100.0%

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

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

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

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

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

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

            \[\leadsto \frac{\color{blue}{1} \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right)}{2} \]
        8. Recombined 2 regimes into one program.
        9. Final simplification80.7%

          \[\leadsto \begin{array}{l} \mathbf{if}\;\left(\frac{1}{\varepsilon} + 1\right) \cdot e^{\left(\varepsilon - 1\right) \cdot x} - e^{\left(-1 - \varepsilon\right) \cdot x} \cdot \left(\frac{1}{\varepsilon} - 1\right) \leq 5:\\ \;\;\;\;e^{-x} \cdot \left(x + 1\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1 \cdot e^{\left(\varepsilon - 1\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right)}{2}\\ \end{array} \]
        10. Add Preprocessing

        Alternative 3: 66.8% accurate, 0.9× speedup?

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

          1. Initial program 38.1%

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

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

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

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

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

            \[\leadsto \left(2 \cdot \frac{1 + x}{1 + x \cdot \left(1 + \frac{1}{2} \cdot x\right)}\right) \cdot \frac{1}{2} \]
          7. Step-by-step derivation
            1. Applied rewrites83.4%

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

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

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

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

                if 0.0 < (-.f64 (*.f64 (+.f64 #s(literal 1 binary64) (/.f64 #s(literal 1 binary64) eps)) (exp.f64 (neg.f64 (*.f64 (-.f64 #s(literal 1 binary64) eps) x)))) (*.f64 (-.f64 (/.f64 #s(literal 1 binary64) eps) #s(literal 1 binary64)) (exp.f64 (neg.f64 (*.f64 (+.f64 #s(literal 1 binary64) eps) x)))))

                1. Initial program 99.5%

                  \[\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 0

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

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

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

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

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

                    \[\leadsto 1 \cdot e^{\color{blue}{-x}} \]
                  3. Step-by-step derivation
                    1. Applied rewrites45.3%

                      \[\leadsto 1 \cdot e^{\color{blue}{-x}} \]
                    2. Taylor expanded in x around 0

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

                        \[\leadsto 1 \cdot \mathsf{fma}\left(\mathsf{fma}\left(x, 0.5, -1\right), \color{blue}{x}, 1\right) \]
                    4. Recombined 2 regimes into one program.
                    5. Final simplification62.6%

                      \[\leadsto \begin{array}{l} \mathbf{if}\;\left(\frac{1}{\varepsilon} + 1\right) \cdot e^{\left(\varepsilon - 1\right) \cdot x} - e^{\left(-1 - \varepsilon\right) \cdot x} \cdot \left(\frac{1}{\varepsilon} - 1\right) \leq 0:\\ \;\;\;\;\frac{-1}{\left(x - 1\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(0.5, x, 1\right), x, 1\right)}\\ \mathbf{else}:\\ \;\;\;\;1 \cdot \mathsf{fma}\left(\mathsf{fma}\left(x, 0.5, -1\right), x, 1\right)\\ \end{array} \]
                    6. Add Preprocessing

                    Alternative 4: 64.4% accurate, 0.9× speedup?

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

                      1. Initial program 38.1%

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

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

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

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

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

                        \[\leadsto \left(2 \cdot \frac{1 + x}{1 + x \cdot \left(1 + \frac{1}{2} \cdot x\right)}\right) \cdot \frac{1}{2} \]
                      7. Step-by-step derivation
                        1. Applied rewrites83.4%

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

                            \[\leadsto \frac{1 + x}{\color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, x, 1\right), x, 1\right)}} \]

                          if 0.0 < (-.f64 (*.f64 (+.f64 #s(literal 1 binary64) (/.f64 #s(literal 1 binary64) eps)) (exp.f64 (neg.f64 (*.f64 (-.f64 #s(literal 1 binary64) eps) x)))) (*.f64 (-.f64 (/.f64 #s(literal 1 binary64) eps) #s(literal 1 binary64)) (exp.f64 (neg.f64 (*.f64 (+.f64 #s(literal 1 binary64) eps) x)))))

                          1. Initial program 99.5%

                            \[\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 0

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

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

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

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

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

                              \[\leadsto 1 \cdot e^{\color{blue}{-x}} \]
                            3. Step-by-step derivation
                              1. Applied rewrites45.3%

                                \[\leadsto 1 \cdot e^{\color{blue}{-x}} \]
                              2. Taylor expanded in x around 0

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

                                  \[\leadsto 1 \cdot \mathsf{fma}\left(\mathsf{fma}\left(x, 0.5, -1\right), \color{blue}{x}, 1\right) \]
                              4. Recombined 2 regimes into one program.
                              5. Final simplification61.2%

                                \[\leadsto \begin{array}{l} \mathbf{if}\;\left(\frac{1}{\varepsilon} + 1\right) \cdot e^{\left(\varepsilon - 1\right) \cdot x} - e^{\left(-1 - \varepsilon\right) \cdot x} \cdot \left(\frac{1}{\varepsilon} - 1\right) \leq 0:\\ \;\;\;\;\frac{x + 1}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, x, 1\right), x, 1\right)}\\ \mathbf{else}:\\ \;\;\;\;1 \cdot \mathsf{fma}\left(\mathsf{fma}\left(x, 0.5, -1\right), x, 1\right)\\ \end{array} \]
                              6. Add Preprocessing

                              Alternative 5: 67.6% accurate, 1.8× speedup?

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

                                1. Initial program 66.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 0

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

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

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

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

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

                                  if 1 < eps < 6.00000000000000011e25

                                  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 0

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

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

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

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

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

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

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

                                      if 6.00000000000000011e25 < 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 x around 0

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

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

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

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

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

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

                                          \[\leadsto \frac{1 - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2} \]
                                      8. Recombined 3 regimes into one program.
                                      9. Final simplification60.6%

                                        \[\leadsto \begin{array}{l} \mathbf{if}\;\varepsilon \leq 1:\\ \;\;\;\;e^{-x} \cdot \left(x + 1\right)\\ \mathbf{elif}\;\varepsilon \leq 6 \cdot 10^{+25}:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(x, 0.5, -1\right), x, 1\right) \cdot \left(x + 1\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1 - e^{\left(-1 - \varepsilon\right) \cdot x} \cdot \left(\frac{1}{\varepsilon} - 1\right)}{2}\\ \end{array} \]
                                      10. Add Preprocessing

                                      Alternative 6: 73.0% accurate, 2.1× speedup?

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

                                        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 0

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

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

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

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

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

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

                                              \[\leadsto 1 \cdot e^{\color{blue}{-x}} \]

                                            if -720 < x < -9.19999999999999983e-229

                                            1. Initial program 48.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 x around 0

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

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

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

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

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

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

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

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

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

                                                if -9.19999999999999983e-229 < x < 9.5000000000000001e113

                                                1. Initial program 69.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 0

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

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

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

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

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

                                                  if 9.5000000000000001e113 < x

                                                  1. Initial program 100.0%

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

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

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

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

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

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

                                                      \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(0.3333333333333333, x, -0.5\right), \color{blue}{x \cdot x}, 1\right) \]
                                                  8. Recombined 4 regimes into one program.
                                                  9. Final simplification69.5%

                                                    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -720:\\ \;\;\;\;1 \cdot e^{-x}\\ \mathbf{elif}\;x \leq -9.2 \cdot 10^{-229}:\\ \;\;\;\;\mathsf{fma}\left(0.5 \cdot x, \mathsf{fma}\left(\varepsilon - 1, \frac{1}{\varepsilon}, \frac{1 - \varepsilon \cdot \varepsilon}{\varepsilon}\right), 1\right)\\ \mathbf{elif}\;x \leq 9.5 \cdot 10^{+113}:\\ \;\;\;\;e^{-x} \cdot \left(x + 1\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.3333333333333333, x, -0.5\right), x \cdot x, 1\right)\\ \end{array} \]
                                                  10. Add Preprocessing

                                                  Alternative 7: 72.6% accurate, 2.2× speedup?

                                                  \[\begin{array}{l} \\ \begin{array}{l} t_0 := 1 \cdot e^{-x}\\ \mathbf{if}\;x \leq -720:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq -9.2 \cdot 10^{-229}:\\ \;\;\;\;\mathsf{fma}\left(0.5 \cdot x, \mathsf{fma}\left(\varepsilon - 1, \frac{1}{\varepsilon}, \frac{1 - \varepsilon \cdot \varepsilon}{\varepsilon}\right), 1\right)\\ \mathbf{elif}\;x \leq 9.5 \cdot 10^{+113}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.3333333333333333, x, -0.5\right), x \cdot x, 1\right)\\ \end{array} \end{array} \]
                                                  (FPCore (x eps)
                                                   :precision binary64
                                                   (let* ((t_0 (* 1.0 (exp (- x)))))
                                                     (if (<= x -720.0)
                                                       t_0
                                                       (if (<= x -9.2e-229)
                                                         (fma
                                                          (* 0.5 x)
                                                          (fma (- eps 1.0) (/ 1.0 eps) (/ (- 1.0 (* eps eps)) eps))
                                                          1.0)
                                                         (if (<= x 9.5e+113)
                                                           t_0
                                                           (fma (fma 0.3333333333333333 x -0.5) (* x x) 1.0))))))
                                                  double code(double x, double eps) {
                                                  	double t_0 = 1.0 * exp(-x);
                                                  	double tmp;
                                                  	if (x <= -720.0) {
                                                  		tmp = t_0;
                                                  	} else if (x <= -9.2e-229) {
                                                  		tmp = fma((0.5 * x), fma((eps - 1.0), (1.0 / eps), ((1.0 - (eps * eps)) / eps)), 1.0);
                                                  	} else if (x <= 9.5e+113) {
                                                  		tmp = t_0;
                                                  	} else {
                                                  		tmp = fma(fma(0.3333333333333333, x, -0.5), (x * x), 1.0);
                                                  	}
                                                  	return tmp;
                                                  }
                                                  
                                                  function code(x, eps)
                                                  	t_0 = Float64(1.0 * exp(Float64(-x)))
                                                  	tmp = 0.0
                                                  	if (x <= -720.0)
                                                  		tmp = t_0;
                                                  	elseif (x <= -9.2e-229)
                                                  		tmp = fma(Float64(0.5 * x), fma(Float64(eps - 1.0), Float64(1.0 / eps), Float64(Float64(1.0 - Float64(eps * eps)) / eps)), 1.0);
                                                  	elseif (x <= 9.5e+113)
                                                  		tmp = t_0;
                                                  	else
                                                  		tmp = fma(fma(0.3333333333333333, x, -0.5), Float64(x * x), 1.0);
                                                  	end
                                                  	return tmp
                                                  end
                                                  
                                                  code[x_, eps_] := Block[{t$95$0 = N[(1.0 * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -720.0], t$95$0, If[LessEqual[x, -9.2e-229], N[(N[(0.5 * x), $MachinePrecision] * N[(N[(eps - 1.0), $MachinePrecision] * N[(1.0 / eps), $MachinePrecision] + N[(N[(1.0 - N[(eps * eps), $MachinePrecision]), $MachinePrecision] / eps), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision], If[LessEqual[x, 9.5e+113], t$95$0, N[(N[(0.3333333333333333 * x + -0.5), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision]]]]]
                                                  
                                                  \begin{array}{l}
                                                  
                                                  \\
                                                  \begin{array}{l}
                                                  t_0 := 1 \cdot e^{-x}\\
                                                  \mathbf{if}\;x \leq -720:\\
                                                  \;\;\;\;t\_0\\
                                                  
                                                  \mathbf{elif}\;x \leq -9.2 \cdot 10^{-229}:\\
                                                  \;\;\;\;\mathsf{fma}\left(0.5 \cdot x, \mathsf{fma}\left(\varepsilon - 1, \frac{1}{\varepsilon}, \frac{1 - \varepsilon \cdot \varepsilon}{\varepsilon}\right), 1\right)\\
                                                  
                                                  \mathbf{elif}\;x \leq 9.5 \cdot 10^{+113}:\\
                                                  \;\;\;\;t\_0\\
                                                  
                                                  \mathbf{else}:\\
                                                  \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.3333333333333333, x, -0.5\right), x \cdot x, 1\right)\\
                                                  
                                                  
                                                  \end{array}
                                                  \end{array}
                                                  
                                                  Derivation
                                                  1. Split input into 3 regimes
                                                  2. if x < -720 or -9.19999999999999983e-229 < x < 9.5000000000000001e113

                                                    1. Initial program 77.1%

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

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

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

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

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

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

                                                        \[\leadsto 1 \cdot e^{\color{blue}{-x}} \]
                                                      3. Step-by-step derivation
                                                        1. Applied rewrites73.5%

                                                          \[\leadsto 1 \cdot e^{\color{blue}{-x}} \]

                                                        if -720 < x < -9.19999999999999983e-229

                                                        1. Initial program 48.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 x around 0

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

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

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

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

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

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

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

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

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

                                                            if 9.5000000000000001e113 < x

                                                            1. Initial program 100.0%

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

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

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

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

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

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

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

                                                            Alternative 8: 68.8% accurate, 4.1× speedup?

                                                            \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -2.5 \cdot 10^{+100}:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.16666666666666666, x, 0.5\right), x, -1\right), x, 1\right) \cdot 1\\ \mathbf{elif}\;x \leq -9.2 \cdot 10^{-229}:\\ \;\;\;\;\mathsf{fma}\left(0.5 \cdot x, \mathsf{fma}\left(\varepsilon - 1, \frac{1}{\varepsilon}, \frac{1 - \varepsilon \cdot \varepsilon}{\varepsilon}\right), 1\right)\\ \mathbf{elif}\;x \leq 1.8:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.125, x, 0.3333333333333333\right), x, -0.5\right), x \cdot x, 1\right)\\ \mathbf{elif}\;x \leq 9.5 \cdot 10^{+113}:\\ \;\;\;\;\frac{\left(\frac{1}{\varepsilon} + 1\right) - \left(\frac{1}{\varepsilon} - 1\right)}{2}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.3333333333333333, x, -0.5\right), x \cdot x, 1\right)\\ \end{array} \end{array} \]
                                                            (FPCore (x eps)
                                                             :precision binary64
                                                             (if (<= x -2.5e+100)
                                                               (* (fma (fma (fma -0.16666666666666666 x 0.5) x -1.0) x 1.0) 1.0)
                                                               (if (<= x -9.2e-229)
                                                                 (fma
                                                                  (* 0.5 x)
                                                                  (fma (- eps 1.0) (/ 1.0 eps) (/ (- 1.0 (* eps eps)) eps))
                                                                  1.0)
                                                                 (if (<= x 1.8)
                                                                   (fma (fma (fma -0.125 x 0.3333333333333333) x -0.5) (* x x) 1.0)
                                                                   (if (<= x 9.5e+113)
                                                                     (/ (- (+ (/ 1.0 eps) 1.0) (- (/ 1.0 eps) 1.0)) 2.0)
                                                                     (fma (fma 0.3333333333333333 x -0.5) (* x x) 1.0))))))
                                                            double code(double x, double eps) {
                                                            	double tmp;
                                                            	if (x <= -2.5e+100) {
                                                            		tmp = fma(fma(fma(-0.16666666666666666, x, 0.5), x, -1.0), x, 1.0) * 1.0;
                                                            	} else if (x <= -9.2e-229) {
                                                            		tmp = fma((0.5 * x), fma((eps - 1.0), (1.0 / eps), ((1.0 - (eps * eps)) / eps)), 1.0);
                                                            	} else if (x <= 1.8) {
                                                            		tmp = fma(fma(fma(-0.125, x, 0.3333333333333333), x, -0.5), (x * x), 1.0);
                                                            	} else if (x <= 9.5e+113) {
                                                            		tmp = (((1.0 / eps) + 1.0) - ((1.0 / eps) - 1.0)) / 2.0;
                                                            	} else {
                                                            		tmp = fma(fma(0.3333333333333333, x, -0.5), (x * x), 1.0);
                                                            	}
                                                            	return tmp;
                                                            }
                                                            
                                                            function code(x, eps)
                                                            	tmp = 0.0
                                                            	if (x <= -2.5e+100)
                                                            		tmp = Float64(fma(fma(fma(-0.16666666666666666, x, 0.5), x, -1.0), x, 1.0) * 1.0);
                                                            	elseif (x <= -9.2e-229)
                                                            		tmp = fma(Float64(0.5 * x), fma(Float64(eps - 1.0), Float64(1.0 / eps), Float64(Float64(1.0 - Float64(eps * eps)) / eps)), 1.0);
                                                            	elseif (x <= 1.8)
                                                            		tmp = fma(fma(fma(-0.125, x, 0.3333333333333333), x, -0.5), Float64(x * x), 1.0);
                                                            	elseif (x <= 9.5e+113)
                                                            		tmp = Float64(Float64(Float64(Float64(1.0 / eps) + 1.0) - Float64(Float64(1.0 / eps) - 1.0)) / 2.0);
                                                            	else
                                                            		tmp = fma(fma(0.3333333333333333, x, -0.5), Float64(x * x), 1.0);
                                                            	end
                                                            	return tmp
                                                            end
                                                            
                                                            code[x_, eps_] := If[LessEqual[x, -2.5e+100], N[(N[(N[(N[(-0.16666666666666666 * x + 0.5), $MachinePrecision] * x + -1.0), $MachinePrecision] * x + 1.0), $MachinePrecision] * 1.0), $MachinePrecision], If[LessEqual[x, -9.2e-229], N[(N[(0.5 * x), $MachinePrecision] * N[(N[(eps - 1.0), $MachinePrecision] * N[(1.0 / eps), $MachinePrecision] + N[(N[(1.0 - N[(eps * eps), $MachinePrecision]), $MachinePrecision] / eps), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision], If[LessEqual[x, 1.8], N[(N[(N[(-0.125 * x + 0.3333333333333333), $MachinePrecision] * x + -0.5), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision], If[LessEqual[x, 9.5e+113], N[(N[(N[(N[(1.0 / eps), $MachinePrecision] + 1.0), $MachinePrecision] - N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(0.3333333333333333 * x + -0.5), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision]]]]]
                                                            
                                                            \begin{array}{l}
                                                            
                                                            \\
                                                            \begin{array}{l}
                                                            \mathbf{if}\;x \leq -2.5 \cdot 10^{+100}:\\
                                                            \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.16666666666666666, x, 0.5\right), x, -1\right), x, 1\right) \cdot 1\\
                                                            
                                                            \mathbf{elif}\;x \leq -9.2 \cdot 10^{-229}:\\
                                                            \;\;\;\;\mathsf{fma}\left(0.5 \cdot x, \mathsf{fma}\left(\varepsilon - 1, \frac{1}{\varepsilon}, \frac{1 - \varepsilon \cdot \varepsilon}{\varepsilon}\right), 1\right)\\
                                                            
                                                            \mathbf{elif}\;x \leq 1.8:\\
                                                            \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.125, x, 0.3333333333333333\right), x, -0.5\right), x \cdot x, 1\right)\\
                                                            
                                                            \mathbf{elif}\;x \leq 9.5 \cdot 10^{+113}:\\
                                                            \;\;\;\;\frac{\left(\frac{1}{\varepsilon} + 1\right) - \left(\frac{1}{\varepsilon} - 1\right)}{2}\\
                                                            
                                                            \mathbf{else}:\\
                                                            \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.3333333333333333, x, -0.5\right), x \cdot x, 1\right)\\
                                                            
                                                            
                                                            \end{array}
                                                            \end{array}
                                                            
                                                            Derivation
                                                            1. Split input into 5 regimes
                                                            2. if x < -2.4999999999999999e100

                                                              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 0

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

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

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

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

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

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

                                                                    \[\leadsto 1 \cdot e^{\color{blue}{-x}} \]
                                                                  2. Taylor expanded in x around 0

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

                                                                      \[\leadsto 1 \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.16666666666666666, x, 0.5\right), x, -1\right), \color{blue}{x}, 1\right) \]

                                                                    if -2.4999999999999999e100 < x < -9.19999999999999983e-229

                                                                    1. Initial program 59.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 + \frac{1}{2} \cdot \left(x \cdot \left(\left(1 + \frac{1}{\varepsilon}\right) \cdot \left(\varepsilon - 1\right) - -1 \cdot \left(\left(1 + \varepsilon\right) \cdot \left(\frac{1}{\varepsilon} - 1\right)\right)\right)\right)} \]
                                                                    4. Step-by-step derivation
                                                                      1. +-commutativeN/A

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

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

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

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

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

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

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

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

                                                                        if -9.19999999999999983e-229 < x < 1.80000000000000004

                                                                        1. Initial program 58.5%

                                                                          \[\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 0

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

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

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

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

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

                                                                            \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.125, x, 0.3333333333333333\right), x, -0.5\right), \color{blue}{x \cdot x}, 1\right) \]

                                                                          if 1.80000000000000004 < x < 9.5000000000000001e113

                                                                          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 x around 0

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

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

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

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

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

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

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

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

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

                                                                          if 9.5000000000000001e113 < x

                                                                          1. Initial program 100.0%

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

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

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

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

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

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

                                                                              \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(0.3333333333333333, x, -0.5\right), \color{blue}{x \cdot x}, 1\right) \]
                                                                          8. Recombined 5 regimes into one program.
                                                                          9. Final simplification65.2%

                                                                            \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.5 \cdot 10^{+100}:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.16666666666666666, x, 0.5\right), x, -1\right), x, 1\right) \cdot 1\\ \mathbf{elif}\;x \leq -9.2 \cdot 10^{-229}:\\ \;\;\;\;\mathsf{fma}\left(0.5 \cdot x, \mathsf{fma}\left(\varepsilon - 1, \frac{1}{\varepsilon}, \frac{1 - \varepsilon \cdot \varepsilon}{\varepsilon}\right), 1\right)\\ \mathbf{elif}\;x \leq 1.8:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.125, x, 0.3333333333333333\right), x, -0.5\right), x \cdot x, 1\right)\\ \mathbf{elif}\;x \leq 9.5 \cdot 10^{+113}:\\ \;\;\;\;\frac{\left(\frac{1}{\varepsilon} + 1\right) - \left(\frac{1}{\varepsilon} - 1\right)}{2}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.3333333333333333, x, -0.5\right), x \cdot x, 1\right)\\ \end{array} \]
                                                                          10. Add Preprocessing

                                                                          Alternative 9: 62.0% accurate, 9.1× speedup?

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

                                                                            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 0

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

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

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

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

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

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

                                                                                  \[\leadsto 1 \cdot e^{\color{blue}{-x}} \]
                                                                                2. Taylor expanded in x around 0

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

                                                                                    \[\leadsto 1 \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.16666666666666666, x, 0.5\right), x, -1\right), \color{blue}{x}, 1\right) \]

                                                                                  if -5800 < x

                                                                                  1. Initial program 72.3%

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

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

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

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

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

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

                                                                                      \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(0.3333333333333333, x, -0.5\right), \color{blue}{x \cdot x}, 1\right) \]
                                                                                  8. Recombined 2 regimes into one program.
                                                                                  9. Final simplification58.1%

                                                                                    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -5800:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.16666666666666666, x, 0.5\right), x, -1\right), x, 1\right) \cdot 1\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.3333333333333333, x, -0.5\right), x \cdot x, 1\right)\\ \end{array} \]
                                                                                  10. Add Preprocessing

                                                                                  Alternative 10: 59.8% accurate, 11.4× speedup?

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

                                                                                    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 0

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

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

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

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

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

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

                                                                                          \[\leadsto 1 \cdot e^{\color{blue}{-x}} \]
                                                                                        2. Taylor expanded in x around 0

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

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

                                                                                          if -5800 < x

                                                                                          1. Initial program 72.3%

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

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

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

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

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

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

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

                                                                                          Alternative 11: 52.9% accurate, 15.2× speedup?

                                                                                          \[\begin{array}{l} \\ \mathsf{fma}\left(\mathsf{fma}\left(0.3333333333333333, x, -0.5\right), x \cdot x, 1\right) \end{array} \]
                                                                                          (FPCore (x eps)
                                                                                           :precision binary64
                                                                                           (fma (fma 0.3333333333333333 x -0.5) (* x x) 1.0))
                                                                                          double code(double x, double eps) {
                                                                                          	return fma(fma(0.3333333333333333, x, -0.5), (x * x), 1.0);
                                                                                          }
                                                                                          
                                                                                          function code(x, eps)
                                                                                          	return fma(fma(0.3333333333333333, x, -0.5), Float64(x * x), 1.0)
                                                                                          end
                                                                                          
                                                                                          code[x_, eps_] := N[(N[(0.3333333333333333 * x + -0.5), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision]
                                                                                          
                                                                                          \begin{array}{l}
                                                                                          
                                                                                          \\
                                                                                          \mathsf{fma}\left(\mathsf{fma}\left(0.3333333333333333, x, -0.5\right), x \cdot x, 1\right)
                                                                                          \end{array}
                                                                                          
                                                                                          Derivation
                                                                                          1. Initial program 76.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 0

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

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

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

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

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

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

                                                                                            Alternative 12: 43.9% 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;
                                                                                            }
                                                                                            
                                                                                            real(8) function code(x, eps)
                                                                                                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 76.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 x around 0

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

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

                                                                                              Reproduce

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