exp neg sub

Percentage Accurate: 100.0% → 100.0%
Time: 6.3s
Alternatives: 7
Speedup: 1.0×

Specification

?
\[\begin{array}{l} \\ e^{-\left(1 - x \cdot x\right)} \end{array} \]
(FPCore (x) :precision binary64 (exp (- (- 1.0 (* x x)))))
double code(double x) {
	return exp(-(1.0 - (x * x)));
}
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)
use fmin_fmax_functions
    real(8), intent (in) :: x
    code = exp(-(1.0d0 - (x * x)))
end function
public static double code(double x) {
	return Math.exp(-(1.0 - (x * x)));
}
def code(x):
	return math.exp(-(1.0 - (x * x)))
function code(x)
	return exp(Float64(-Float64(1.0 - Float64(x * x))))
end
function tmp = code(x)
	tmp = exp(-(1.0 - (x * x)));
end
code[x_] := N[Exp[(-N[(1.0 - N[(x * x), $MachinePrecision]), $MachinePrecision])], $MachinePrecision]
\begin{array}{l}

\\
e^{-\left(1 - x \cdot x\right)}
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 7 alternatives:

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

Initial Program: 100.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ e^{-\left(1 - x \cdot x\right)} \end{array} \]
(FPCore (x) :precision binary64 (exp (- (- 1.0 (* x x)))))
double code(double x) {
	return exp(-(1.0 - (x * x)));
}
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)
use fmin_fmax_functions
    real(8), intent (in) :: x
    code = exp(-(1.0d0 - (x * x)))
end function
public static double code(double x) {
	return Math.exp(-(1.0 - (x * x)));
}
def code(x):
	return math.exp(-(1.0 - (x * x)))
function code(x)
	return exp(Float64(-Float64(1.0 - Float64(x * x))))
end
function tmp = code(x)
	tmp = exp(-(1.0 - (x * x)));
end
code[x_] := N[Exp[(-N[(1.0 - N[(x * x), $MachinePrecision]), $MachinePrecision])], $MachinePrecision]
\begin{array}{l}

\\
e^{-\left(1 - x \cdot x\right)}
\end{array}

Alternative 1: 100.0% accurate, 0.8× speedup?

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

\\
e^{\mathsf{fma}\left(\sqrt{x\_m} \cdot \sqrt{x\_m}, x\_m, -1\right)}
\end{array}
Derivation
  1. Initial program 100.0%

    \[e^{-\left(1 - x \cdot x\right)} \]
  2. Add Preprocessing
  3. Applied rewrites100.0%

    \[\leadsto \color{blue}{e^{\mathsf{fma}\left(x, x, -1\right)}} \]
  4. Step-by-step derivation
    1. rem-square-sqrtN/A

      \[\leadsto e^{\mathsf{fma}\left(\color{blue}{\sqrt{x} \cdot \sqrt{x}}, x, -1\right)} \]
    2. lift-sqrt.f64N/A

      \[\leadsto e^{\mathsf{fma}\left(\color{blue}{\sqrt{x}} \cdot \sqrt{x}, x, -1\right)} \]
    3. lift-sqrt.f64N/A

      \[\leadsto e^{\mathsf{fma}\left(\sqrt{x} \cdot \color{blue}{\sqrt{x}}, x, -1\right)} \]
    4. lift-*.f6447.3

      \[\leadsto e^{\mathsf{fma}\left(\color{blue}{\sqrt{x} \cdot \sqrt{x}}, x, -1\right)} \]
  5. Applied rewrites47.3%

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

Alternative 2: 99.6% accurate, 1.0× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ \begin{array}{l} \mathbf{if}\;x\_m \leq 1.5:\\ \;\;\;\;\mathsf{fma}\left(x\_m, x\_m, 1\right) \cdot \frac{\mathsf{fma}\left(x\_m, x\_m, -1\right)}{\mathsf{fma}\left(x\_m, x\_m, -1\right) \cdot \mathsf{E}\left(\right)}\\ \mathbf{else}:\\ \;\;\;\;e^{x\_m \cdot x\_m}\\ \end{array} \end{array} \]
x_m = (fabs.f64 x)
(FPCore (x_m)
 :precision binary64
 (if (<= x_m 1.5)
   (* (fma x_m x_m 1.0) (/ (fma x_m x_m -1.0) (* (fma x_m x_m -1.0) (E))))
   (exp (* x_m x_m))))
\begin{array}{l}
x_m = \left|x\right|

\\
\begin{array}{l}
\mathbf{if}\;x\_m \leq 1.5:\\
\;\;\;\;\mathsf{fma}\left(x\_m, x\_m, 1\right) \cdot \frac{\mathsf{fma}\left(x\_m, x\_m, -1\right)}{\mathsf{fma}\left(x\_m, x\_m, -1\right) \cdot \mathsf{E}\left(\right)}\\

\mathbf{else}:\\
\;\;\;\;e^{x\_m \cdot x\_m}\\


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

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{e^{-1} + {x}^{2} \cdot e^{-1}} \]
    4. Step-by-step derivation
      1. distribute-rgt1-inN/A

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(x, x, 1\right)} \cdot e^{-1} \]
      5. lower-exp.f6488.9

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(x, x, 1\right)}{\mathsf{E}\left(\right)}} \]
    7. Applied rewrites73.5%

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

    if 1.5 < x

    1. Initial program 100.0%

      \[e^{-\left(1 - x \cdot x\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. rem-square-sqrtN/A

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

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

        \[\leadsto e^{-\left(1 - \left(\color{blue}{\sqrt{x}} \cdot \sqrt{x}\right) \cdot x\right)} \]
      4. lower-sqrt.f64100.0

        \[\leadsto e^{-\left(1 - \left(\sqrt{x} \cdot \color{blue}{\sqrt{x}}\right) \cdot x\right)} \]
    4. Applied rewrites100.0%

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

      \[\leadsto e^{\color{blue}{-1 \cdot \left({x}^{2} \cdot {\left(\sqrt{-1}\right)}^{2}\right)}} \]
    6. Step-by-step derivation
      1. mul-1-negN/A

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

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

        \[\leadsto e^{\mathsf{neg}\left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot {x}^{2}\right)} \]
      4. rem-square-sqrtN/A

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

        \[\leadsto e^{\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left({x}^{2}\right)\right)}\right)} \]
      6. unpow2N/A

        \[\leadsto e^{\mathsf{neg}\left(\left(\mathsf{neg}\left(\color{blue}{x \cdot x}\right)\right)\right)} \]
      7. distribute-rgt-neg-inN/A

        \[\leadsto e^{\mathsf{neg}\left(\color{blue}{x \cdot \left(\mathsf{neg}\left(x\right)\right)}\right)} \]
      8. distribute-lft-neg-inN/A

        \[\leadsto e^{\color{blue}{\left(\mathsf{neg}\left(x\right)\right) \cdot \left(\mathsf{neg}\left(x\right)\right)}} \]
      9. sqr-neg-revN/A

        \[\leadsto e^{\color{blue}{x \cdot x}} \]
      10. lower-*.f64100.0

        \[\leadsto e^{\color{blue}{x \cdot x}} \]
    7. Applied rewrites100.0%

      \[\leadsto e^{\color{blue}{x \cdot x}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 3: 100.0% accurate, 1.0× speedup?

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

\\
e^{\mathsf{fma}\left(x\_m, x\_m, -1\right)}
\end{array}
Derivation
  1. Initial program 100.0%

    \[e^{-\left(1 - x \cdot x\right)} \]
  2. Add Preprocessing
  3. Applied rewrites100.0%

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

Alternative 4: 88.0% accurate, 1.9× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ \begin{array}{l} t_0 := \mathsf{fma}\left(-x\_m, x\_m, 1\right)\\ \mathbf{if}\;1 - x\_m \cdot x\_m \leq -\infty:\\ \;\;\;\;\frac{x\_m \cdot x\_m}{\mathsf{E}\left(\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{t\_0 \cdot \mathsf{fma}\left(x\_m, x\_m, 1\right)}{t\_0 \cdot \mathsf{E}\left(\right)}\\ \end{array} \end{array} \]
x_m = (fabs.f64 x)
(FPCore (x_m)
 :precision binary64
 (let* ((t_0 (fma (- x_m) x_m 1.0)))
   (if (<= (- 1.0 (* x_m x_m)) (- INFINITY))
     (/ (* x_m x_m) (E))
     (/ (* t_0 (fma x_m x_m 1.0)) (* t_0 (E))))))
\begin{array}{l}
x_m = \left|x\right|

\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(-x\_m, x\_m, 1\right)\\
\mathbf{if}\;1 - x\_m \cdot x\_m \leq -\infty:\\
\;\;\;\;\frac{x\_m \cdot x\_m}{\mathsf{E}\left(\right)}\\

\mathbf{else}:\\
\;\;\;\;\frac{t\_0 \cdot \mathsf{fma}\left(x\_m, x\_m, 1\right)}{t\_0 \cdot \mathsf{E}\left(\right)}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 #s(literal 1 binary64) (*.f64 x x)) < -inf.0

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{e^{-1} + {x}^{2} \cdot e^{-1}} \]
    4. Step-by-step derivation
      1. distribute-rgt1-inN/A

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(x, x, 1\right)} \cdot e^{-1} \]
      5. lower-exp.f64100.0

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(x, x, 1\right)}{\mathsf{E}\left(\right)}} \]
    7. Taylor expanded in x around inf

      \[\leadsto \frac{{x}^{2}}{\color{blue}{\mathsf{E}\left(\right)}} \]
    8. Step-by-step derivation
      1. Applied rewrites100.0%

        \[\leadsto \frac{x \cdot x}{\color{blue}{\mathsf{E}\left(\right)}} \]

      if -inf.0 < (-.f64 #s(literal 1 binary64) (*.f64 x x))

      1. Initial program 100.0%

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

        \[\leadsto \color{blue}{e^{-1} + {x}^{2} \cdot e^{-1}} \]
      4. Step-by-step derivation
        1. distribute-rgt1-inN/A

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

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

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

          \[\leadsto \color{blue}{\mathsf{fma}\left(x, x, 1\right)} \cdot e^{-1} \]
        5. lower-exp.f6476.4

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

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

        \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(x, x, 1\right)}{\mathsf{E}\left(\right)}} \]
      7. Step-by-step derivation
        1. Applied rewrites76.4%

          \[\leadsto \frac{x}{\mathsf{E}\left(\right)} \cdot x - \color{blue}{\frac{-1}{\mathsf{E}\left(\right)}} \]
        2. Step-by-step derivation
          1. Applied rewrites89.4%

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

        Alternative 5: 76.1% accurate, 4.8× speedup?

        \[\begin{array}{l} x_m = \left|x\right| \\ \begin{array}{l} \mathbf{if}\;x\_m \leq 1:\\ \;\;\;\;\frac{1}{\mathsf{E}\left(\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{x\_m \cdot x\_m}{\mathsf{E}\left(\right)}\\ \end{array} \end{array} \]
        x_m = (fabs.f64 x)
        (FPCore (x_m)
         :precision binary64
         (if (<= x_m 1.0) (/ 1.0 (E)) (/ (* x_m x_m) (E))))
        \begin{array}{l}
        x_m = \left|x\right|
        
        \\
        \begin{array}{l}
        \mathbf{if}\;x\_m \leq 1:\\
        \;\;\;\;\frac{1}{\mathsf{E}\left(\right)}\\
        
        \mathbf{else}:\\
        \;\;\;\;\frac{x\_m \cdot x\_m}{\mathsf{E}\left(\right)}\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if x < 1

          1. Initial program 100.0%

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

            \[\leadsto \color{blue}{e^{-1} + {x}^{2} \cdot e^{-1}} \]
          4. Step-by-step derivation
            1. distribute-rgt1-inN/A

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

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

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

              \[\leadsto \color{blue}{\mathsf{fma}\left(x, x, 1\right)} \cdot e^{-1} \]
            5. lower-exp.f6488.9

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

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

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

            \[\leadsto \frac{1}{\mathsf{E}\left(\right)} \]
          8. Step-by-step derivation
            1. Applied rewrites73.3%

              \[\leadsto \frac{1}{\mathsf{E}\left(\right)} \]

            if 1 < x

            1. Initial program 100.0%

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

              \[\leadsto \color{blue}{e^{-1} + {x}^{2} \cdot e^{-1}} \]
            4. Step-by-step derivation
              1. distribute-rgt1-inN/A

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

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

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

                \[\leadsto \color{blue}{\mathsf{fma}\left(x, x, 1\right)} \cdot e^{-1} \]
              5. lower-exp.f6457.0

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

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

              \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(x, x, 1\right)}{\mathsf{E}\left(\right)}} \]
            7. Taylor expanded in x around inf

              \[\leadsto \frac{{x}^{2}}{\color{blue}{\mathsf{E}\left(\right)}} \]
            8. Step-by-step derivation
              1. Applied rewrites57.0%

                \[\leadsto \frac{x \cdot x}{\color{blue}{\mathsf{E}\left(\right)}} \]
            9. Recombined 2 regimes into one program.
            10. Add Preprocessing

            Alternative 6: 76.4% accurate, 6.2× speedup?

            \[\begin{array}{l} x_m = \left|x\right| \\ \frac{\mathsf{fma}\left(x\_m, x\_m, 1\right)}{\mathsf{E}\left(\right)} \end{array} \]
            x_m = (fabs.f64 x)
            (FPCore (x_m) :precision binary64 (/ (fma x_m x_m 1.0) (E)))
            \begin{array}{l}
            x_m = \left|x\right|
            
            \\
            \frac{\mathsf{fma}\left(x\_m, x\_m, 1\right)}{\mathsf{E}\left(\right)}
            \end{array}
            
            Derivation
            1. Initial program 100.0%

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

              \[\leadsto \color{blue}{e^{-1} + {x}^{2} \cdot e^{-1}} \]
            4. Step-by-step derivation
              1. distribute-rgt1-inN/A

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

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

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

                \[\leadsto \color{blue}{\mathsf{fma}\left(x, x, 1\right)} \cdot e^{-1} \]
              5. lower-exp.f6482.0

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

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

              \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(x, x, 1\right)}{\mathsf{E}\left(\right)}} \]
            7. Add Preprocessing

            Alternative 7: 51.7% accurate, 9.3× speedup?

            \[\begin{array}{l} x_m = \left|x\right| \\ \frac{1}{\mathsf{E}\left(\right)} \end{array} \]
            x_m = (fabs.f64 x)
            (FPCore (x_m) :precision binary64 (/ 1.0 (E)))
            \begin{array}{l}
            x_m = \left|x\right|
            
            \\
            \frac{1}{\mathsf{E}\left(\right)}
            \end{array}
            
            Derivation
            1. Initial program 100.0%

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

              \[\leadsto \color{blue}{e^{-1} + {x}^{2} \cdot e^{-1}} \]
            4. Step-by-step derivation
              1. distribute-rgt1-inN/A

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

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

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

                \[\leadsto \color{blue}{\mathsf{fma}\left(x, x, 1\right)} \cdot e^{-1} \]
              5. lower-exp.f6482.0

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

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

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

              \[\leadsto \frac{1}{\mathsf{E}\left(\right)} \]
            8. Step-by-step derivation
              1. Applied rewrites58.2%

                \[\leadsto \frac{1}{\mathsf{E}\left(\right)} \]
              2. Add Preprocessing

              Reproduce

              ?
              herbie shell --seed 2024351 
              (FPCore (x)
                :name "exp neg sub"
                :precision binary64
                (exp (- (- 1.0 (* x x)))))