NMSE Section 6.1 mentioned, A

Percentage Accurate: 72.7% → 99.9%
Time: 4.8s
Alternatives: 14
Speedup: 2.1×

Specification

?
\[\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} \]
(FPCore (x eps)
 :precision binary64
 (/
  (-
   (* (+ 1.0 (/ 1.0 eps)) (exp (- (* (- 1.0 eps) x))))
   (* (- (/ 1.0 eps) 1.0) (exp (- (* (+ 1.0 eps) x)))))
  2.0))
double code(double x, double eps) {
	return (((1.0 + (1.0 / eps)) * exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * exp(-((1.0 + eps) * x)))) / 2.0;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

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

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 14 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: 72.7% accurate, 1.0× speedup?

\[\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} \]
(FPCore (x eps)
 :precision binary64
 (/
  (-
   (* (+ 1.0 (/ 1.0 eps)) (exp (- (* (- 1.0 eps) x))))
   (* (- (/ 1.0 eps) 1.0) (exp (- (* (+ 1.0 eps) x)))))
  2.0))
double code(double x, double eps) {
	return (((1.0 + (1.0 / eps)) * exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * exp(-((1.0 + eps) * x)))) / 2.0;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

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

Alternative 1: 99.9% accurate, 1.3× speedup?

\[\begin{array}{l} \mathbf{if}\;\left|\varepsilon\right| \leq 9.5 \cdot 10^{-20}:\\ \;\;\;\;\frac{\left(x - -1\right) + \left(x - -1\right)}{e^{x}} \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;\left(e^{-\left|\varepsilon\right| \cdot x} + e^{\left(\left|\varepsilon\right| - 1\right) \cdot x}\right) \cdot 0.5\\ \end{array} \]
(FPCore (x eps)
 :precision binary64
 (if (<= (fabs eps) 9.5e-20)
   (* (/ (+ (- x -1.0) (- x -1.0)) (exp x)) 0.5)
   (* (+ (exp (- (* (fabs eps) x))) (exp (* (- (fabs eps) 1.0) x))) 0.5)))
double code(double x, double eps) {
	double tmp;
	if (fabs(eps) <= 9.5e-20) {
		tmp = (((x - -1.0) + (x - -1.0)) / exp(x)) * 0.5;
	} else {
		tmp = (exp(-(fabs(eps) * x)) + exp(((fabs(eps) - 1.0) * x))) * 0.5;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(x, eps)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: eps
    real(8) :: tmp
    if (abs(eps) <= 9.5d-20) then
        tmp = (((x - (-1.0d0)) + (x - (-1.0d0))) / exp(x)) * 0.5d0
    else
        tmp = (exp(-(abs(eps) * x)) + exp(((abs(eps) - 1.0d0) * x))) * 0.5d0
    end if
    code = tmp
end function
public static double code(double x, double eps) {
	double tmp;
	if (Math.abs(eps) <= 9.5e-20) {
		tmp = (((x - -1.0) + (x - -1.0)) / Math.exp(x)) * 0.5;
	} else {
		tmp = (Math.exp(-(Math.abs(eps) * x)) + Math.exp(((Math.abs(eps) - 1.0) * x))) * 0.5;
	}
	return tmp;
}
def code(x, eps):
	tmp = 0
	if math.fabs(eps) <= 9.5e-20:
		tmp = (((x - -1.0) + (x - -1.0)) / math.exp(x)) * 0.5
	else:
		tmp = (math.exp(-(math.fabs(eps) * x)) + math.exp(((math.fabs(eps) - 1.0) * x))) * 0.5
	return tmp
function code(x, eps)
	tmp = 0.0
	if (abs(eps) <= 9.5e-20)
		tmp = Float64(Float64(Float64(Float64(x - -1.0) + Float64(x - -1.0)) / exp(x)) * 0.5);
	else
		tmp = Float64(Float64(exp(Float64(-Float64(abs(eps) * x))) + exp(Float64(Float64(abs(eps) - 1.0) * x))) * 0.5);
	end
	return tmp
end
function tmp_2 = code(x, eps)
	tmp = 0.0;
	if (abs(eps) <= 9.5e-20)
		tmp = (((x - -1.0) + (x - -1.0)) / exp(x)) * 0.5;
	else
		tmp = (exp(-(abs(eps) * x)) + exp(((abs(eps) - 1.0) * x))) * 0.5;
	end
	tmp_2 = tmp;
end
code[x_, eps_] := If[LessEqual[N[Abs[eps], $MachinePrecision], 9.5e-20], N[(N[(N[(N[(x - -1.0), $MachinePrecision] + N[(x - -1.0), $MachinePrecision]), $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(N[Exp[(-N[(N[Abs[eps], $MachinePrecision] * x), $MachinePrecision])], $MachinePrecision] + N[Exp[N[(N[(N[Abs[eps], $MachinePrecision] - 1.0), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\left|\varepsilon\right| \leq 9.5 \cdot 10^{-20}:\\
\;\;\;\;\frac{\left(x - -1\right) + \left(x - -1\right)}{e^{x}} \cdot 0.5\\

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


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

    1. Initial program 72.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 9.5e-20 < eps

    1. Initial program 72.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 99.0% accurate, 1.5× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 84.1% accurate, 1.5× speedup?

\[\begin{array}{l} t_0 := \left|\varepsilon\right| - 1\\ \mathbf{if}\;x \leq -1.75 \cdot 10^{+89}:\\ \;\;\;\;\frac{1 \cdot 1 - \sqrt{\left(x \cdot x\right) \cdot \left(x \cdot x\right)}}{x - -1}\\ \mathbf{elif}\;x \leq 5 \cdot 10^{-297}:\\ \;\;\;\;\left(e^{-\left|\varepsilon\right| \cdot x} + \left(1 + x \cdot t\_0\right)\right) \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;\left(e^{t\_0 \cdot x} - -1\right) \cdot 0.5\\ \end{array} \]
(FPCore (x eps)
 :precision binary64
 (let* ((t_0 (- (fabs eps) 1.0)))
   (if (<= x -1.75e+89)
     (/ (- (* 1.0 1.0) (sqrt (* (* x x) (* x x)))) (- x -1.0))
     (if (<= x 5e-297)
       (* (+ (exp (- (* (fabs eps) x))) (+ 1.0 (* x t_0))) 0.5)
       (* (- (exp (* t_0 x)) -1.0) 0.5)))))
double code(double x, double eps) {
	double t_0 = fabs(eps) - 1.0;
	double tmp;
	if (x <= -1.75e+89) {
		tmp = ((1.0 * 1.0) - sqrt(((x * x) * (x * x)))) / (x - -1.0);
	} else if (x <= 5e-297) {
		tmp = (exp(-(fabs(eps) * x)) + (1.0 + (x * t_0))) * 0.5;
	} else {
		tmp = (exp((t_0 * x)) - -1.0) * 0.5;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(x, eps)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: eps
    real(8) :: t_0
    real(8) :: tmp
    t_0 = abs(eps) - 1.0d0
    if (x <= (-1.75d+89)) then
        tmp = ((1.0d0 * 1.0d0) - sqrt(((x * x) * (x * x)))) / (x - (-1.0d0))
    else if (x <= 5d-297) then
        tmp = (exp(-(abs(eps) * x)) + (1.0d0 + (x * t_0))) * 0.5d0
    else
        tmp = (exp((t_0 * x)) - (-1.0d0)) * 0.5d0
    end if
    code = tmp
end function
public static double code(double x, double eps) {
	double t_0 = Math.abs(eps) - 1.0;
	double tmp;
	if (x <= -1.75e+89) {
		tmp = ((1.0 * 1.0) - Math.sqrt(((x * x) * (x * x)))) / (x - -1.0);
	} else if (x <= 5e-297) {
		tmp = (Math.exp(-(Math.abs(eps) * x)) + (1.0 + (x * t_0))) * 0.5;
	} else {
		tmp = (Math.exp((t_0 * x)) - -1.0) * 0.5;
	}
	return tmp;
}
def code(x, eps):
	t_0 = math.fabs(eps) - 1.0
	tmp = 0
	if x <= -1.75e+89:
		tmp = ((1.0 * 1.0) - math.sqrt(((x * x) * (x * x)))) / (x - -1.0)
	elif x <= 5e-297:
		tmp = (math.exp(-(math.fabs(eps) * x)) + (1.0 + (x * t_0))) * 0.5
	else:
		tmp = (math.exp((t_0 * x)) - -1.0) * 0.5
	return tmp
function code(x, eps)
	t_0 = Float64(abs(eps) - 1.0)
	tmp = 0.0
	if (x <= -1.75e+89)
		tmp = Float64(Float64(Float64(1.0 * 1.0) - sqrt(Float64(Float64(x * x) * Float64(x * x)))) / Float64(x - -1.0));
	elseif (x <= 5e-297)
		tmp = Float64(Float64(exp(Float64(-Float64(abs(eps) * x))) + Float64(1.0 + Float64(x * t_0))) * 0.5);
	else
		tmp = Float64(Float64(exp(Float64(t_0 * x)) - -1.0) * 0.5);
	end
	return tmp
end
function tmp_2 = code(x, eps)
	t_0 = abs(eps) - 1.0;
	tmp = 0.0;
	if (x <= -1.75e+89)
		tmp = ((1.0 * 1.0) - sqrt(((x * x) * (x * x)))) / (x - -1.0);
	elseif (x <= 5e-297)
		tmp = (exp(-(abs(eps) * x)) + (1.0 + (x * t_0))) * 0.5;
	else
		tmp = (exp((t_0 * x)) - -1.0) * 0.5;
	end
	tmp_2 = tmp;
end
code[x_, eps_] := Block[{t$95$0 = N[(N[Abs[eps], $MachinePrecision] - 1.0), $MachinePrecision]}, If[LessEqual[x, -1.75e+89], N[(N[(N[(1.0 * 1.0), $MachinePrecision] - N[Sqrt[N[(N[(x * x), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(x - -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 5e-297], N[(N[(N[Exp[(-N[(N[Abs[eps], $MachinePrecision] * x), $MachinePrecision])], $MachinePrecision] + N[(1.0 + N[(x * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(N[Exp[N[(t$95$0 * x), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision] * 0.5), $MachinePrecision]]]]
\begin{array}{l}
t_0 := \left|\varepsilon\right| - 1\\
\mathbf{if}\;x \leq -1.75 \cdot 10^{+89}:\\
\;\;\;\;\frac{1 \cdot 1 - \sqrt{\left(x \cdot x\right) \cdot \left(x \cdot x\right)}}{x - -1}\\

\mathbf{elif}\;x \leq 5 \cdot 10^{-297}:\\
\;\;\;\;\left(e^{-\left|\varepsilon\right| \cdot x} + \left(1 + x \cdot t\_0\right)\right) \cdot 0.5\\

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


\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -1.75e89

    1. Initial program 72.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 1 + \color{blue}{-1 \cdot x} \]
    6. Step-by-step derivation
      1. lower-+.f64N/A

        \[\leadsto 1 + -1 \cdot \color{blue}{x} \]
      2. lower-*.f6443.1

        \[\leadsto 1 + -1 \cdot x \]
    7. Applied rewrites43.1%

      \[\leadsto 1 + \color{blue}{-1 \cdot x} \]
    8. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto 1 + -1 \cdot \color{blue}{x} \]
      2. lift-*.f64N/A

        \[\leadsto 1 + -1 \cdot x \]
      3. fp-cancel-sign-sub-invN/A

        \[\leadsto 1 - \left(\mathsf{neg}\left(-1\right)\right) \cdot \color{blue}{x} \]
      4. flip--N/A

        \[\leadsto \frac{1 \cdot 1 - \left(\left(\mathsf{neg}\left(-1\right)\right) \cdot x\right) \cdot \left(\left(\mathsf{neg}\left(-1\right)\right) \cdot x\right)}{1 + \color{blue}{\left(\mathsf{neg}\left(-1\right)\right) \cdot x}} \]
      5. distribute-lft-neg-outN/A

        \[\leadsto \frac{1 \cdot 1 - \left(\left(\mathsf{neg}\left(-1\right)\right) \cdot x\right) \cdot \left(\left(\mathsf{neg}\left(-1\right)\right) \cdot x\right)}{1 + \left(\mathsf{neg}\left(-1 \cdot x\right)\right)} \]
      6. lift-*.f64N/A

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

        \[\leadsto \frac{1 \cdot 1 - \left(\left(\mathsf{neg}\left(-1\right)\right) \cdot x\right) \cdot \left(\left(\mathsf{neg}\left(-1\right)\right) \cdot x\right)}{1 + \left(\mathsf{neg}\left(-1 \cdot x\right)\right)} \]
      8. mul-1-negN/A

        \[\leadsto \frac{1 \cdot 1 - \left(\left(\mathsf{neg}\left(-1\right)\right) \cdot x\right) \cdot \left(\left(\mathsf{neg}\left(-1\right)\right) \cdot x\right)}{1 + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right)} \]
      9. remove-double-negN/A

        \[\leadsto \frac{1 \cdot 1 - \left(\left(\mathsf{neg}\left(-1\right)\right) \cdot x\right) \cdot \left(\left(\mathsf{neg}\left(-1\right)\right) \cdot x\right)}{1 + x} \]
      10. lower-unsound-+.f32N/A

        \[\leadsto \frac{1 \cdot 1 - \left(\left(\mathsf{neg}\left(-1\right)\right) \cdot x\right) \cdot \left(\left(\mathsf{neg}\left(-1\right)\right) \cdot x\right)}{1 + x} \]
      11. lower-+.f32N/A

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

        \[\leadsto \frac{1 \cdot 1 - \left(\left(\mathsf{neg}\left(-1\right)\right) \cdot x\right) \cdot \left(\left(\mathsf{neg}\left(-1\right)\right) \cdot x\right)}{x + 1} \]
      13. metadata-evalN/A

        \[\leadsto \frac{1 \cdot 1 - \left(\left(\mathsf{neg}\left(-1\right)\right) \cdot x\right) \cdot \left(\left(\mathsf{neg}\left(-1\right)\right) \cdot x\right)}{x + \left(\mathsf{neg}\left(-1\right)\right)} \]
      14. sub-flipN/A

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

        \[\leadsto \frac{1 \cdot 1 - \left(\left(\mathsf{neg}\left(-1\right)\right) \cdot x\right) \cdot \left(\left(\mathsf{neg}\left(-1\right)\right) \cdot x\right)}{x - -1} \]
      16. lower-unsound-/.f64N/A

        \[\leadsto \frac{1 \cdot 1 - \left(\left(\mathsf{neg}\left(-1\right)\right) \cdot x\right) \cdot \left(\left(\mathsf{neg}\left(-1\right)\right) \cdot x\right)}{x - \color{blue}{-1}} \]
    9. Applied rewrites49.7%

      \[\leadsto \frac{1 \cdot 1 - x \cdot x}{x - \color{blue}{-1}} \]
    10. Step-by-step derivation
      1. rem-square-sqrtN/A

        \[\leadsto \frac{1 \cdot 1 - \sqrt{x \cdot x} \cdot \sqrt{x \cdot x}}{x - -1} \]
      2. sqrt-unprodN/A

        \[\leadsto \frac{1 \cdot 1 - \sqrt{\left(x \cdot x\right) \cdot \left(x \cdot x\right)}}{x - -1} \]
      3. lower-*.f32N/A

        \[\leadsto \frac{1 \cdot 1 - \sqrt{\left(x \cdot x\right) \cdot \left(x \cdot x\right)}}{x - -1} \]
      4. lower-unsound-*.f32N/A

        \[\leadsto \frac{1 \cdot 1 - \sqrt{\left(x \cdot x\right) \cdot \left(x \cdot x\right)}}{x - -1} \]
      5. lower-sqrt.f64N/A

        \[\leadsto \frac{1 \cdot 1 - \sqrt{\left(x \cdot x\right) \cdot \left(x \cdot x\right)}}{x - -1} \]
      6. lower-unsound-*.f6453.1

        \[\leadsto \frac{1 \cdot 1 - \sqrt{\left(x \cdot x\right) \cdot \left(x \cdot x\right)}}{x - -1} \]
    11. Applied rewrites53.1%

      \[\leadsto \frac{1 \cdot 1 - \sqrt{\left(x \cdot x\right) \cdot \left(x \cdot x\right)}}{x - -1} \]

    if -1.75e89 < x < 5e-297

    1. Initial program 72.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5e-297 < x

    1. Initial program 72.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 4: 78.8% accurate, 1.7× speedup?

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

      1. Initial program 72.7%

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

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

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

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

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

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

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

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

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

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

      if -700 < x

      1. Initial program 72.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      Alternative 5: 78.0% accurate, 0.7× speedup?

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

        1. Initial program 72.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        if 2 < (/.f64 (-.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))))) #s(literal 2 binary64))

        1. Initial program 72.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        Alternative 6: 74.6% accurate, 2.1× speedup?

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

          1. Initial program 72.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto 1 + \color{blue}{-1 \cdot x} \]
          6. Step-by-step derivation
            1. lower-+.f64N/A

              \[\leadsto 1 + -1 \cdot \color{blue}{x} \]
            2. lower-*.f6443.1

              \[\leadsto 1 + -1 \cdot x \]
          7. Applied rewrites43.1%

            \[\leadsto 1 + \color{blue}{-1 \cdot x} \]
          8. Step-by-step derivation
            1. lift-+.f64N/A

              \[\leadsto 1 + -1 \cdot \color{blue}{x} \]
            2. lift-*.f64N/A

              \[\leadsto 1 + -1 \cdot x \]
            3. fp-cancel-sign-sub-invN/A

              \[\leadsto 1 - \left(\mathsf{neg}\left(-1\right)\right) \cdot \color{blue}{x} \]
            4. flip--N/A

              \[\leadsto \frac{1 \cdot 1 - \left(\left(\mathsf{neg}\left(-1\right)\right) \cdot x\right) \cdot \left(\left(\mathsf{neg}\left(-1\right)\right) \cdot x\right)}{1 + \color{blue}{\left(\mathsf{neg}\left(-1\right)\right) \cdot x}} \]
            5. distribute-lft-neg-outN/A

              \[\leadsto \frac{1 \cdot 1 - \left(\left(\mathsf{neg}\left(-1\right)\right) \cdot x\right) \cdot \left(\left(\mathsf{neg}\left(-1\right)\right) \cdot x\right)}{1 + \left(\mathsf{neg}\left(-1 \cdot x\right)\right)} \]
            6. lift-*.f64N/A

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

              \[\leadsto \frac{1 \cdot 1 - \left(\left(\mathsf{neg}\left(-1\right)\right) \cdot x\right) \cdot \left(\left(\mathsf{neg}\left(-1\right)\right) \cdot x\right)}{1 + \left(\mathsf{neg}\left(-1 \cdot x\right)\right)} \]
            8. mul-1-negN/A

              \[\leadsto \frac{1 \cdot 1 - \left(\left(\mathsf{neg}\left(-1\right)\right) \cdot x\right) \cdot \left(\left(\mathsf{neg}\left(-1\right)\right) \cdot x\right)}{1 + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right)} \]
            9. remove-double-negN/A

              \[\leadsto \frac{1 \cdot 1 - \left(\left(\mathsf{neg}\left(-1\right)\right) \cdot x\right) \cdot \left(\left(\mathsf{neg}\left(-1\right)\right) \cdot x\right)}{1 + x} \]
            10. lower-unsound-+.f32N/A

              \[\leadsto \frac{1 \cdot 1 - \left(\left(\mathsf{neg}\left(-1\right)\right) \cdot x\right) \cdot \left(\left(\mathsf{neg}\left(-1\right)\right) \cdot x\right)}{1 + x} \]
            11. lower-+.f32N/A

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

              \[\leadsto \frac{1 \cdot 1 - \left(\left(\mathsf{neg}\left(-1\right)\right) \cdot x\right) \cdot \left(\left(\mathsf{neg}\left(-1\right)\right) \cdot x\right)}{x + 1} \]
            13. metadata-evalN/A

              \[\leadsto \frac{1 \cdot 1 - \left(\left(\mathsf{neg}\left(-1\right)\right) \cdot x\right) \cdot \left(\left(\mathsf{neg}\left(-1\right)\right) \cdot x\right)}{x + \left(\mathsf{neg}\left(-1\right)\right)} \]
            14. sub-flipN/A

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

              \[\leadsto \frac{1 \cdot 1 - \left(\left(\mathsf{neg}\left(-1\right)\right) \cdot x\right) \cdot \left(\left(\mathsf{neg}\left(-1\right)\right) \cdot x\right)}{x - -1} \]
            16. lower-unsound-/.f64N/A

              \[\leadsto \frac{1 \cdot 1 - \left(\left(\mathsf{neg}\left(-1\right)\right) \cdot x\right) \cdot \left(\left(\mathsf{neg}\left(-1\right)\right) \cdot x\right)}{x - \color{blue}{-1}} \]
          9. Applied rewrites49.7%

            \[\leadsto \frac{1 \cdot 1 - x \cdot x}{x - \color{blue}{-1}} \]
          10. Step-by-step derivation
            1. rem-square-sqrtN/A

              \[\leadsto \frac{1 \cdot 1 - \sqrt{x \cdot x} \cdot \sqrt{x \cdot x}}{x - -1} \]
            2. sqrt-unprodN/A

              \[\leadsto \frac{1 \cdot 1 - \sqrt{\left(x \cdot x\right) \cdot \left(x \cdot x\right)}}{x - -1} \]
            3. lower-*.f32N/A

              \[\leadsto \frac{1 \cdot 1 - \sqrt{\left(x \cdot x\right) \cdot \left(x \cdot x\right)}}{x - -1} \]
            4. lower-unsound-*.f32N/A

              \[\leadsto \frac{1 \cdot 1 - \sqrt{\left(x \cdot x\right) \cdot \left(x \cdot x\right)}}{x - -1} \]
            5. lower-sqrt.f64N/A

              \[\leadsto \frac{1 \cdot 1 - \sqrt{\left(x \cdot x\right) \cdot \left(x \cdot x\right)}}{x - -1} \]
            6. lower-unsound-*.f6453.1

              \[\leadsto \frac{1 \cdot 1 - \sqrt{\left(x \cdot x\right) \cdot \left(x \cdot x\right)}}{x - -1} \]
          11. Applied rewrites53.1%

            \[\leadsto \frac{1 \cdot 1 - \sqrt{\left(x \cdot x\right) \cdot \left(x \cdot x\right)}}{x - -1} \]

          if 5e-297 < x

          1. Initial program 72.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          Alternative 7: 71.2% accurate, 2.1× speedup?

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

            1. Initial program 72.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto 1 + \color{blue}{-1 \cdot x} \]
            6. Step-by-step derivation
              1. lower-+.f64N/A

                \[\leadsto 1 + -1 \cdot \color{blue}{x} \]
              2. lower-*.f6443.1

                \[\leadsto 1 + -1 \cdot x \]
            7. Applied rewrites43.1%

              \[\leadsto 1 + \color{blue}{-1 \cdot x} \]
            8. Step-by-step derivation
              1. lift-+.f64N/A

                \[\leadsto 1 + -1 \cdot \color{blue}{x} \]
              2. lift-*.f64N/A

                \[\leadsto 1 + -1 \cdot x \]
              3. mul-1-negN/A

                \[\leadsto 1 + \left(\mathsf{neg}\left(x\right)\right) \]
              4. sub-flip-reverseN/A

                \[\leadsto 1 - x \]
              5. lower--.f6443.1

                \[\leadsto 1 - x \]
            9. Applied rewrites43.1%

              \[\leadsto 1 - x \]
            10. Step-by-step derivation
              1. lift--.f64N/A

                \[\leadsto 1 - x \]
              2. sub-negate-revN/A

                \[\leadsto \mathsf{neg}\left(\left(x - 1\right)\right) \]
              3. flip--N/A

                \[\leadsto \mathsf{neg}\left(\frac{x \cdot x - 1 \cdot 1}{x + 1}\right) \]
              4. lower-unsound-+.f32N/A

                \[\leadsto \mathsf{neg}\left(\frac{x \cdot x - 1 \cdot 1}{x + 1}\right) \]
              5. lower-+.f32N/A

                \[\leadsto \mathsf{neg}\left(\frac{x \cdot x - 1 \cdot 1}{x + 1}\right) \]
              6. metadata-evalN/A

                \[\leadsto \mathsf{neg}\left(\frac{x \cdot x - 1 \cdot 1}{x + \left(\mathsf{neg}\left(-1\right)\right)}\right) \]
              7. sub-flipN/A

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

                \[\leadsto \mathsf{neg}\left(\frac{x \cdot x - 1 \cdot 1}{x - -1}\right) \]
              9. lower-unsound-/.f64N/A

                \[\leadsto \mathsf{neg}\left(\frac{x \cdot x - 1 \cdot 1}{x - -1}\right) \]
              10. lower-unsound-*.f64N/A

                \[\leadsto \mathsf{neg}\left(\frac{x \cdot x - 1 \cdot 1}{x - -1}\right) \]
              11. lower-unsound--.f32N/A

                \[\leadsto \mathsf{neg}\left(\frac{x \cdot x - 1 \cdot 1}{x - -1}\right) \]
              12. lower-unsound-*.f64N/A

                \[\leadsto \mathsf{neg}\left(\frac{x \cdot x - 1 \cdot 1}{x - -1}\right) \]
              13. lift-*.f64N/A

                \[\leadsto \mathsf{neg}\left(\frac{x \cdot x - 1 \cdot 1}{x - -1}\right) \]
              14. metadata-evalN/A

                \[\leadsto \mathsf{neg}\left(\frac{x \cdot x - 1}{x - -1}\right) \]
              15. lower--.f32N/A

                \[\leadsto \mathsf{neg}\left(\frac{x \cdot x - 1}{x - -1}\right) \]
              16. sub-negate-revN/A

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

                \[\leadsto \mathsf{neg}\left(\frac{\mathsf{neg}\left(\left(1 - x \cdot x\right)\right)}{x - -1}\right) \]
              18. metadata-evalN/A

                \[\leadsto \mathsf{neg}\left(\frac{\mathsf{neg}\left(\left(1 \cdot 1 - x \cdot x\right)\right)}{x - -1}\right) \]
              19. lift-*.f64N/A

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

                \[\leadsto \mathsf{neg}\left(\frac{\mathsf{neg}\left(\left(1 \cdot 1 - x \cdot x\right)\right)}{x - -1}\right) \]
              21. distribute-frac-neg2N/A

                \[\leadsto \frac{\mathsf{neg}\left(\left(1 \cdot 1 - x \cdot x\right)\right)}{\mathsf{neg}\left(\left(x - -1\right)\right)} \]
              22. mult-flipN/A

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

                \[\leadsto \left(\mathsf{neg}\left(\left(1 \cdot 1 - x \cdot x\right)\right)\right) \cdot \frac{1}{\color{blue}{\mathsf{neg}\left(\left(x - -1\right)\right)}} \]
            11. Applied rewrites49.7%

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

            if 5e-297 < x

            1. Initial program 72.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            Alternative 8: 63.6% accurate, 2.2× speedup?

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

              1. Initial program 72.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                \[\leadsto 1 + \color{blue}{-1 \cdot x} \]
              6. Step-by-step derivation
                1. lower-+.f64N/A

                  \[\leadsto 1 + -1 \cdot \color{blue}{x} \]
                2. lower-*.f6443.1

                  \[\leadsto 1 + -1 \cdot x \]
              7. Applied rewrites43.1%

                \[\leadsto 1 + \color{blue}{-1 \cdot x} \]
              8. Step-by-step derivation
                1. lift-+.f64N/A

                  \[\leadsto 1 + -1 \cdot \color{blue}{x} \]
                2. lift-*.f64N/A

                  \[\leadsto 1 + -1 \cdot x \]
                3. mul-1-negN/A

                  \[\leadsto 1 + \left(\mathsf{neg}\left(x\right)\right) \]
                4. sub-flip-reverseN/A

                  \[\leadsto 1 - x \]
                5. lower--.f6443.1

                  \[\leadsto 1 - x \]
              9. Applied rewrites43.1%

                \[\leadsto 1 - x \]
              10. Step-by-step derivation
                1. lift--.f64N/A

                  \[\leadsto 1 - x \]
                2. sub-negate-revN/A

                  \[\leadsto \mathsf{neg}\left(\left(x - 1\right)\right) \]
                3. flip--N/A

                  \[\leadsto \mathsf{neg}\left(\frac{x \cdot x - 1 \cdot 1}{x + 1}\right) \]
                4. lower-unsound-+.f32N/A

                  \[\leadsto \mathsf{neg}\left(\frac{x \cdot x - 1 \cdot 1}{x + 1}\right) \]
                5. lower-+.f32N/A

                  \[\leadsto \mathsf{neg}\left(\frac{x \cdot x - 1 \cdot 1}{x + 1}\right) \]
                6. metadata-evalN/A

                  \[\leadsto \mathsf{neg}\left(\frac{x \cdot x - 1 \cdot 1}{x + \left(\mathsf{neg}\left(-1\right)\right)}\right) \]
                7. sub-flipN/A

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

                  \[\leadsto \mathsf{neg}\left(\frac{x \cdot x - 1 \cdot 1}{x - -1}\right) \]
                9. lower-unsound-/.f64N/A

                  \[\leadsto \mathsf{neg}\left(\frac{x \cdot x - 1 \cdot 1}{x - -1}\right) \]
                10. lower-unsound-*.f64N/A

                  \[\leadsto \mathsf{neg}\left(\frac{x \cdot x - 1 \cdot 1}{x - -1}\right) \]
                11. lower-unsound--.f32N/A

                  \[\leadsto \mathsf{neg}\left(\frac{x \cdot x - 1 \cdot 1}{x - -1}\right) \]
                12. lower-unsound-*.f64N/A

                  \[\leadsto \mathsf{neg}\left(\frac{x \cdot x - 1 \cdot 1}{x - -1}\right) \]
                13. lift-*.f64N/A

                  \[\leadsto \mathsf{neg}\left(\frac{x \cdot x - 1 \cdot 1}{x - -1}\right) \]
                14. metadata-evalN/A

                  \[\leadsto \mathsf{neg}\left(\frac{x \cdot x - 1}{x - -1}\right) \]
                15. lower--.f32N/A

                  \[\leadsto \mathsf{neg}\left(\frac{x \cdot x - 1}{x - -1}\right) \]
                16. sub-negate-revN/A

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

                  \[\leadsto \mathsf{neg}\left(\frac{\mathsf{neg}\left(\left(1 - x \cdot x\right)\right)}{x - -1}\right) \]
                18. metadata-evalN/A

                  \[\leadsto \mathsf{neg}\left(\frac{\mathsf{neg}\left(\left(1 \cdot 1 - x \cdot x\right)\right)}{x - -1}\right) \]
                19. lift-*.f64N/A

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

                  \[\leadsto \mathsf{neg}\left(\frac{\mathsf{neg}\left(\left(1 \cdot 1 - x \cdot x\right)\right)}{x - -1}\right) \]
                21. distribute-frac-neg2N/A

                  \[\leadsto \frac{\mathsf{neg}\left(\left(1 \cdot 1 - x \cdot x\right)\right)}{\mathsf{neg}\left(\left(x - -1\right)\right)} \]
                22. mult-flipN/A

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

                  \[\leadsto \left(\mathsf{neg}\left(\left(1 \cdot 1 - x \cdot x\right)\right)\right) \cdot \frac{1}{\color{blue}{\mathsf{neg}\left(\left(x - -1\right)\right)}} \]
              11. Applied rewrites49.7%

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

              if 6.99999999999999968e-7 < x < 2.5500000000000001e212

              1. Initial program 72.7%

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

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

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

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

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

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

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

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

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

              if 2.5500000000000001e212 < x

              1. Initial program 72.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto 1 + {x}^{2} \cdot \left(0.3333333333333333 \cdot x - 0.5\right) \]
              7. Applied rewrites52.4%

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

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

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

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

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

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

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

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

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

                  \[\leadsto \mathsf{fma}\left(\left(0.3333333333333333 \cdot x - 0.5\right) \cdot x, x, 1\right) \]
                10. lift--.f64N/A

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

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

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

                  \[\leadsto \mathsf{fma}\left(\left(\frac{1}{3} \cdot x + \frac{-1}{2}\right) \cdot x, x, 1\right) \]
                14. lower-fma.f6452.4

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

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

                \[\leadsto \mathsf{fma}\left(\left(\frac{1}{3} \cdot x\right) \cdot x, x, 1\right) \]
              11. Step-by-step derivation
                1. lower-*.f6452.3

                  \[\leadsto \mathsf{fma}\left(\left(0.3333333333333333 \cdot x\right) \cdot x, x, 1\right) \]
              12. Applied rewrites52.3%

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

            Alternative 9: 63.6% accurate, 2.6× speedup?

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

              1. Initial program 72.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                \[\leadsto 1 + \color{blue}{-1 \cdot x} \]
              6. Step-by-step derivation
                1. lower-+.f64N/A

                  \[\leadsto 1 + -1 \cdot \color{blue}{x} \]
                2. lower-*.f6443.1

                  \[\leadsto 1 + -1 \cdot x \]
              7. Applied rewrites43.1%

                \[\leadsto 1 + \color{blue}{-1 \cdot x} \]
              8. Step-by-step derivation
                1. lift-+.f64N/A

                  \[\leadsto 1 + -1 \cdot \color{blue}{x} \]
                2. lift-*.f64N/A

                  \[\leadsto 1 + -1 \cdot x \]
                3. mul-1-negN/A

                  \[\leadsto 1 + \left(\mathsf{neg}\left(x\right)\right) \]
                4. sub-flip-reverseN/A

                  \[\leadsto 1 - x \]
                5. lower--.f6443.1

                  \[\leadsto 1 - x \]
              9. Applied rewrites43.1%

                \[\leadsto 1 - x \]
              10. Step-by-step derivation
                1. lift--.f64N/A

                  \[\leadsto 1 - x \]
                2. sub-negate-revN/A

                  \[\leadsto \mathsf{neg}\left(\left(x - 1\right)\right) \]
                3. flip--N/A

                  \[\leadsto \mathsf{neg}\left(\frac{x \cdot x - 1 \cdot 1}{x + 1}\right) \]
                4. lower-unsound-+.f32N/A

                  \[\leadsto \mathsf{neg}\left(\frac{x \cdot x - 1 \cdot 1}{x + 1}\right) \]
                5. lower-+.f32N/A

                  \[\leadsto \mathsf{neg}\left(\frac{x \cdot x - 1 \cdot 1}{x + 1}\right) \]
                6. metadata-evalN/A

                  \[\leadsto \mathsf{neg}\left(\frac{x \cdot x - 1 \cdot 1}{x + \left(\mathsf{neg}\left(-1\right)\right)}\right) \]
                7. sub-flipN/A

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

                  \[\leadsto \mathsf{neg}\left(\frac{x \cdot x - 1 \cdot 1}{x - -1}\right) \]
                9. lower-unsound-/.f64N/A

                  \[\leadsto \mathsf{neg}\left(\frac{x \cdot x - 1 \cdot 1}{x - -1}\right) \]
                10. lower-unsound-*.f64N/A

                  \[\leadsto \mathsf{neg}\left(\frac{x \cdot x - 1 \cdot 1}{x - -1}\right) \]
                11. lower-unsound--.f32N/A

                  \[\leadsto \mathsf{neg}\left(\frac{x \cdot x - 1 \cdot 1}{x - -1}\right) \]
                12. lower-unsound-*.f64N/A

                  \[\leadsto \mathsf{neg}\left(\frac{x \cdot x - 1 \cdot 1}{x - -1}\right) \]
                13. lift-*.f64N/A

                  \[\leadsto \mathsf{neg}\left(\frac{x \cdot x - 1 \cdot 1}{x - -1}\right) \]
                14. metadata-evalN/A

                  \[\leadsto \mathsf{neg}\left(\frac{x \cdot x - 1}{x - -1}\right) \]
                15. lower--.f32N/A

                  \[\leadsto \mathsf{neg}\left(\frac{x \cdot x - 1}{x - -1}\right) \]
                16. sub-negate-revN/A

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

                  \[\leadsto \mathsf{neg}\left(\frac{\mathsf{neg}\left(\left(1 - x \cdot x\right)\right)}{x - -1}\right) \]
                18. metadata-evalN/A

                  \[\leadsto \mathsf{neg}\left(\frac{\mathsf{neg}\left(\left(1 \cdot 1 - x \cdot x\right)\right)}{x - -1}\right) \]
                19. lift-*.f64N/A

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

                  \[\leadsto \mathsf{neg}\left(\frac{\mathsf{neg}\left(\left(1 \cdot 1 - x \cdot x\right)\right)}{x - -1}\right) \]
                21. distribute-frac-neg2N/A

                  \[\leadsto \frac{\mathsf{neg}\left(\left(1 \cdot 1 - x \cdot x\right)\right)}{\mathsf{neg}\left(\left(x - -1\right)\right)} \]
                22. mult-flipN/A

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

                  \[\leadsto \left(\mathsf{neg}\left(\left(1 \cdot 1 - x \cdot x\right)\right)\right) \cdot \frac{1}{\color{blue}{\mathsf{neg}\left(\left(x - -1\right)\right)}} \]
              11. Applied rewrites49.7%

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

              if 0.650000000000000022 < x < 1.10000000000000002e203

              1. Initial program 72.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                \[\leadsto \frac{x}{\color{blue}{e^{x}}} \]
              8. Step-by-step derivation
                1. lower-/.f64N/A

                  \[\leadsto \frac{x}{e^{x}} \]
                2. lower-exp.f6416.5

                  \[\leadsto \frac{x}{e^{x}} \]
              9. Applied rewrites16.5%

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

              if 1.10000000000000002e203 < x

              1. Initial program 72.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto 1 + {x}^{2} \cdot \left(0.3333333333333333 \cdot x - 0.5\right) \]
              7. Applied rewrites52.4%

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

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

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

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

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

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

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

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

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

                  \[\leadsto \mathsf{fma}\left(\left(0.3333333333333333 \cdot x - 0.5\right) \cdot x, x, 1\right) \]
                10. lift--.f64N/A

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

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

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

                  \[\leadsto \mathsf{fma}\left(\left(\frac{1}{3} \cdot x + \frac{-1}{2}\right) \cdot x, x, 1\right) \]
                14. lower-fma.f6452.4

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

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

                \[\leadsto \mathsf{fma}\left(\left(\frac{1}{3} \cdot x\right) \cdot x, x, 1\right) \]
              11. Step-by-step derivation
                1. lower-*.f6452.3

                  \[\leadsto \mathsf{fma}\left(\left(0.3333333333333333 \cdot x\right) \cdot x, x, 1\right) \]
              12. Applied rewrites52.3%

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

            Alternative 10: 63.2% accurate, 2.6× speedup?

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

              1. Initial program 72.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                \[\leadsto 1 + \color{blue}{-1 \cdot x} \]
              6. Step-by-step derivation
                1. lower-+.f64N/A

                  \[\leadsto 1 + -1 \cdot \color{blue}{x} \]
                2. lower-*.f6443.1

                  \[\leadsto 1 + -1 \cdot x \]
              7. Applied rewrites43.1%

                \[\leadsto 1 + \color{blue}{-1 \cdot x} \]
              8. Step-by-step derivation
                1. lift-+.f64N/A

                  \[\leadsto 1 + -1 \cdot \color{blue}{x} \]
                2. lift-*.f64N/A

                  \[\leadsto 1 + -1 \cdot x \]
                3. mul-1-negN/A

                  \[\leadsto 1 + \left(\mathsf{neg}\left(x\right)\right) \]
                4. sub-flip-reverseN/A

                  \[\leadsto 1 - x \]
                5. lower--.f6443.1

                  \[\leadsto 1 - x \]
              9. Applied rewrites43.1%

                \[\leadsto 1 - x \]
              10. Step-by-step derivation
                1. lift--.f64N/A

                  \[\leadsto 1 - x \]
                2. sub-negate-revN/A

                  \[\leadsto \mathsf{neg}\left(\left(x - 1\right)\right) \]
                3. flip--N/A

                  \[\leadsto \mathsf{neg}\left(\frac{x \cdot x - 1 \cdot 1}{x + 1}\right) \]
                4. lower-unsound-+.f32N/A

                  \[\leadsto \mathsf{neg}\left(\frac{x \cdot x - 1 \cdot 1}{x + 1}\right) \]
                5. lower-+.f32N/A

                  \[\leadsto \mathsf{neg}\left(\frac{x \cdot x - 1 \cdot 1}{x + 1}\right) \]
                6. metadata-evalN/A

                  \[\leadsto \mathsf{neg}\left(\frac{x \cdot x - 1 \cdot 1}{x + \left(\mathsf{neg}\left(-1\right)\right)}\right) \]
                7. sub-flipN/A

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

                  \[\leadsto \mathsf{neg}\left(\frac{x \cdot x - 1 \cdot 1}{x - -1}\right) \]
                9. lower-unsound-/.f64N/A

                  \[\leadsto \mathsf{neg}\left(\frac{x \cdot x - 1 \cdot 1}{x - -1}\right) \]
                10. lower-unsound-*.f64N/A

                  \[\leadsto \mathsf{neg}\left(\frac{x \cdot x - 1 \cdot 1}{x - -1}\right) \]
                11. lower-unsound--.f32N/A

                  \[\leadsto \mathsf{neg}\left(\frac{x \cdot x - 1 \cdot 1}{x - -1}\right) \]
                12. lower-unsound-*.f64N/A

                  \[\leadsto \mathsf{neg}\left(\frac{x \cdot x - 1 \cdot 1}{x - -1}\right) \]
                13. lift-*.f64N/A

                  \[\leadsto \mathsf{neg}\left(\frac{x \cdot x - 1 \cdot 1}{x - -1}\right) \]
                14. metadata-evalN/A

                  \[\leadsto \mathsf{neg}\left(\frac{x \cdot x - 1}{x - -1}\right) \]
                15. lower--.f32N/A

                  \[\leadsto \mathsf{neg}\left(\frac{x \cdot x - 1}{x - -1}\right) \]
                16. sub-negate-revN/A

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

                  \[\leadsto \mathsf{neg}\left(\frac{\mathsf{neg}\left(\left(1 - x \cdot x\right)\right)}{x - -1}\right) \]
                18. metadata-evalN/A

                  \[\leadsto \mathsf{neg}\left(\frac{\mathsf{neg}\left(\left(1 \cdot 1 - x \cdot x\right)\right)}{x - -1}\right) \]
                19. lift-*.f64N/A

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

                  \[\leadsto \mathsf{neg}\left(\frac{\mathsf{neg}\left(\left(1 \cdot 1 - x \cdot x\right)\right)}{x - -1}\right) \]
                21. distribute-frac-neg2N/A

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

                  \[\leadsto \frac{\mathsf{neg}\left(\left(1 \cdot 1 - x \cdot x\right)\right)}{\mathsf{neg}\left(\left(x - -1\right)\right)} \]
              11. Applied rewrites49.7%

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

              if 0.650000000000000022 < x < 1.10000000000000002e203

              1. Initial program 72.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                \[\leadsto \frac{x}{\color{blue}{e^{x}}} \]
              8. Step-by-step derivation
                1. lower-/.f64N/A

                  \[\leadsto \frac{x}{e^{x}} \]
                2. lower-exp.f6416.5

                  \[\leadsto \frac{x}{e^{x}} \]
              9. Applied rewrites16.5%

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

              if 1.10000000000000002e203 < x

              1. Initial program 72.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto 1 + {x}^{2} \cdot \left(0.3333333333333333 \cdot x - 0.5\right) \]
              7. Applied rewrites52.4%

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

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

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

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

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

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

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

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

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

                  \[\leadsto \mathsf{fma}\left(\left(0.3333333333333333 \cdot x - 0.5\right) \cdot x, x, 1\right) \]
                10. lift--.f64N/A

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

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

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

                  \[\leadsto \mathsf{fma}\left(\left(\frac{1}{3} \cdot x + \frac{-1}{2}\right) \cdot x, x, 1\right) \]
                14. lower-fma.f6452.4

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

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

                \[\leadsto \mathsf{fma}\left(\left(\frac{1}{3} \cdot x\right) \cdot x, x, 1\right) \]
              11. Step-by-step derivation
                1. lower-*.f6452.3

                  \[\leadsto \mathsf{fma}\left(\left(0.3333333333333333 \cdot x\right) \cdot x, x, 1\right) \]
              12. Applied rewrites52.3%

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

            Alternative 11: 59.7% accurate, 3.3× speedup?

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

              1. Initial program 72.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                \[\leadsto 1 + \color{blue}{-1 \cdot x} \]
              6. Step-by-step derivation
                1. lower-+.f64N/A

                  \[\leadsto 1 + -1 \cdot \color{blue}{x} \]
                2. lower-*.f6443.1

                  \[\leadsto 1 + -1 \cdot x \]
              7. Applied rewrites43.1%

                \[\leadsto 1 + \color{blue}{-1 \cdot x} \]
              8. Step-by-step derivation
                1. lift-+.f64N/A

                  \[\leadsto 1 + -1 \cdot \color{blue}{x} \]
                2. lift-*.f64N/A

                  \[\leadsto 1 + -1 \cdot x \]
                3. mul-1-negN/A

                  \[\leadsto 1 + \left(\mathsf{neg}\left(x\right)\right) \]
                4. sub-flip-reverseN/A

                  \[\leadsto 1 - x \]
                5. lower--.f6443.1

                  \[\leadsto 1 - x \]
              9. Applied rewrites43.1%

                \[\leadsto 1 - x \]
              10. Step-by-step derivation
                1. lift--.f64N/A

                  \[\leadsto 1 - x \]
                2. sub-negate-revN/A

                  \[\leadsto \mathsf{neg}\left(\left(x - 1\right)\right) \]
                3. flip--N/A

                  \[\leadsto \mathsf{neg}\left(\frac{x \cdot x - 1 \cdot 1}{x + 1}\right) \]
                4. lower-unsound-+.f32N/A

                  \[\leadsto \mathsf{neg}\left(\frac{x \cdot x - 1 \cdot 1}{x + 1}\right) \]
                5. lower-+.f32N/A

                  \[\leadsto \mathsf{neg}\left(\frac{x \cdot x - 1 \cdot 1}{x + 1}\right) \]
                6. metadata-evalN/A

                  \[\leadsto \mathsf{neg}\left(\frac{x \cdot x - 1 \cdot 1}{x + \left(\mathsf{neg}\left(-1\right)\right)}\right) \]
                7. sub-flipN/A

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

                  \[\leadsto \mathsf{neg}\left(\frac{x \cdot x - 1 \cdot 1}{x - -1}\right) \]
                9. lower-unsound-/.f64N/A

                  \[\leadsto \mathsf{neg}\left(\frac{x \cdot x - 1 \cdot 1}{x - -1}\right) \]
                10. lower-unsound-*.f64N/A

                  \[\leadsto \mathsf{neg}\left(\frac{x \cdot x - 1 \cdot 1}{x - -1}\right) \]
                11. lower-unsound--.f32N/A

                  \[\leadsto \mathsf{neg}\left(\frac{x \cdot x - 1 \cdot 1}{x - -1}\right) \]
                12. lower-unsound-*.f64N/A

                  \[\leadsto \mathsf{neg}\left(\frac{x \cdot x - 1 \cdot 1}{x - -1}\right) \]
                13. lift-*.f64N/A

                  \[\leadsto \mathsf{neg}\left(\frac{x \cdot x - 1 \cdot 1}{x - -1}\right) \]
                14. metadata-evalN/A

                  \[\leadsto \mathsf{neg}\left(\frac{x \cdot x - 1}{x - -1}\right) \]
                15. lower--.f32N/A

                  \[\leadsto \mathsf{neg}\left(\frac{x \cdot x - 1}{x - -1}\right) \]
                16. sub-negate-revN/A

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

                  \[\leadsto \mathsf{neg}\left(\frac{\mathsf{neg}\left(\left(1 - x \cdot x\right)\right)}{x - -1}\right) \]
                18. metadata-evalN/A

                  \[\leadsto \mathsf{neg}\left(\frac{\mathsf{neg}\left(\left(1 \cdot 1 - x \cdot x\right)\right)}{x - -1}\right) \]
                19. lift-*.f64N/A

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

                  \[\leadsto \mathsf{neg}\left(\frac{\mathsf{neg}\left(\left(1 \cdot 1 - x \cdot x\right)\right)}{x - -1}\right) \]
                21. distribute-frac-neg2N/A

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

                  \[\leadsto \frac{\mathsf{neg}\left(\left(1 \cdot 1 - x \cdot x\right)\right)}{\mathsf{neg}\left(\left(x - -1\right)\right)} \]
              11. Applied rewrites49.7%

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

              if -1.9e-6 < x

              1. Initial program 72.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto 1 + {x}^{2} \cdot \left(0.3333333333333333 \cdot x - 0.5\right) \]
              7. Applied rewrites52.4%

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

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

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

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

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

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

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

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

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

                  \[\leadsto \mathsf{fma}\left(\left(0.3333333333333333 \cdot x - 0.5\right) \cdot x, x, 1\right) \]
                10. lift--.f64N/A

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

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

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

                  \[\leadsto \mathsf{fma}\left(\left(\frac{1}{3} \cdot x + \frac{-1}{2}\right) \cdot x, x, 1\right) \]
                14. lower-fma.f6452.4

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

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

            Alternative 12: 59.6% accurate, 3.7× speedup?

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

              1. Initial program 72.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                \[\leadsto 1 + \color{blue}{-1 \cdot x} \]
              6. Step-by-step derivation
                1. lower-+.f64N/A

                  \[\leadsto 1 + -1 \cdot \color{blue}{x} \]
                2. lower-*.f6443.1

                  \[\leadsto 1 + -1 \cdot x \]
              7. Applied rewrites43.1%

                \[\leadsto 1 + \color{blue}{-1 \cdot x} \]
              8. Step-by-step derivation
                1. lift-+.f64N/A

                  \[\leadsto 1 + -1 \cdot \color{blue}{x} \]
                2. lift-*.f64N/A

                  \[\leadsto 1 + -1 \cdot x \]
                3. mul-1-negN/A

                  \[\leadsto 1 + \left(\mathsf{neg}\left(x\right)\right) \]
                4. sub-flip-reverseN/A

                  \[\leadsto 1 - x \]
                5. lower--.f6443.1

                  \[\leadsto 1 - x \]
              9. Applied rewrites43.1%

                \[\leadsto 1 - x \]
              10. Step-by-step derivation
                1. lift--.f64N/A

                  \[\leadsto 1 - x \]
                2. sub-negate-revN/A

                  \[\leadsto \mathsf{neg}\left(\left(x - 1\right)\right) \]
                3. flip--N/A

                  \[\leadsto \mathsf{neg}\left(\frac{x \cdot x - 1 \cdot 1}{x + 1}\right) \]
                4. lower-unsound-+.f32N/A

                  \[\leadsto \mathsf{neg}\left(\frac{x \cdot x - 1 \cdot 1}{x + 1}\right) \]
                5. lower-+.f32N/A

                  \[\leadsto \mathsf{neg}\left(\frac{x \cdot x - 1 \cdot 1}{x + 1}\right) \]
                6. metadata-evalN/A

                  \[\leadsto \mathsf{neg}\left(\frac{x \cdot x - 1 \cdot 1}{x + \left(\mathsf{neg}\left(-1\right)\right)}\right) \]
                7. sub-flipN/A

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

                  \[\leadsto \mathsf{neg}\left(\frac{x \cdot x - 1 \cdot 1}{x - -1}\right) \]
                9. lower-unsound-/.f64N/A

                  \[\leadsto \mathsf{neg}\left(\frac{x \cdot x - 1 \cdot 1}{x - -1}\right) \]
                10. lower-unsound-*.f64N/A

                  \[\leadsto \mathsf{neg}\left(\frac{x \cdot x - 1 \cdot 1}{x - -1}\right) \]
                11. lower-unsound--.f32N/A

                  \[\leadsto \mathsf{neg}\left(\frac{x \cdot x - 1 \cdot 1}{x - -1}\right) \]
                12. lower-unsound-*.f64N/A

                  \[\leadsto \mathsf{neg}\left(\frac{x \cdot x - 1 \cdot 1}{x - -1}\right) \]
                13. lift-*.f64N/A

                  \[\leadsto \mathsf{neg}\left(\frac{x \cdot x - 1 \cdot 1}{x - -1}\right) \]
                14. metadata-evalN/A

                  \[\leadsto \mathsf{neg}\left(\frac{x \cdot x - 1}{x - -1}\right) \]
                15. lower--.f32N/A

                  \[\leadsto \mathsf{neg}\left(\frac{x \cdot x - 1}{x - -1}\right) \]
                16. sub-negate-revN/A

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

                  \[\leadsto \mathsf{neg}\left(\frac{\mathsf{neg}\left(\left(1 - x \cdot x\right)\right)}{x - -1}\right) \]
                18. metadata-evalN/A

                  \[\leadsto \mathsf{neg}\left(\frac{\mathsf{neg}\left(\left(1 \cdot 1 - x \cdot x\right)\right)}{x - -1}\right) \]
                19. lift-*.f64N/A

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

                  \[\leadsto \mathsf{neg}\left(\frac{\mathsf{neg}\left(\left(1 \cdot 1 - x \cdot x\right)\right)}{x - -1}\right) \]
                21. distribute-frac-neg2N/A

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

                  \[\leadsto \frac{\mathsf{neg}\left(\left(1 \cdot 1 - x \cdot x\right)\right)}{\mathsf{neg}\left(\left(x - -1\right)\right)} \]
              11. Applied rewrites49.7%

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

              if -1.9e-6 < x

              1. Initial program 72.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto 1 + {x}^{2} \cdot \left(0.3333333333333333 \cdot x - 0.5\right) \]
              7. Applied rewrites52.4%

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

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

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

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

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

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

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

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

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

                  \[\leadsto \mathsf{fma}\left(\left(0.3333333333333333 \cdot x - 0.5\right) \cdot x, x, 1\right) \]
                10. lift--.f64N/A

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

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

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

                  \[\leadsto \mathsf{fma}\left(\left(\frac{1}{3} \cdot x + \frac{-1}{2}\right) \cdot x, x, 1\right) \]
                14. lower-fma.f6452.4

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

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

                \[\leadsto \mathsf{fma}\left(\left(\frac{1}{3} \cdot x\right) \cdot x, x, 1\right) \]
              11. Step-by-step derivation
                1. lower-*.f6452.3

                  \[\leadsto \mathsf{fma}\left(\left(0.3333333333333333 \cdot x\right) \cdot x, x, 1\right) \]
              12. Applied rewrites52.3%

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

            Alternative 13: 52.3% accurate, 4.9× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                \[\leadsto 1 + {x}^{2} \cdot \left(0.3333333333333333 \cdot x - 0.5\right) \]
            7. Applied rewrites52.4%

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

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

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

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

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

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

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

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

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

                \[\leadsto \mathsf{fma}\left(\left(0.3333333333333333 \cdot x - 0.5\right) \cdot x, x, 1\right) \]
              10. lift--.f64N/A

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

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

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

                \[\leadsto \mathsf{fma}\left(\left(\frac{1}{3} \cdot x + \frac{-1}{2}\right) \cdot x, x, 1\right) \]
              14. lower-fma.f6452.4

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

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

              \[\leadsto \mathsf{fma}\left(\left(\frac{1}{3} \cdot x\right) \cdot x, x, 1\right) \]
            11. Step-by-step derivation
              1. lower-*.f6452.3

                \[\leadsto \mathsf{fma}\left(\left(0.3333333333333333 \cdot x\right) \cdot x, x, 1\right) \]
            12. Applied rewrites52.3%

              \[\leadsto \mathsf{fma}\left(\left(0.3333333333333333 \cdot x\right) \cdot x, x, 1\right) \]
            13. Add Preprocessing

            Alternative 14: 43.7% accurate, 58.4× speedup?

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

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

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

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

              Reproduce

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