exp neg sub

Percentage Accurate: 100.0% → 100.0%
Time: 2.9s
Alternatives: 12
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}

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 12 alternatives:

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

Initial Program: 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.5× speedup?

\[\begin{array}{l} \\ \frac{1}{\frac{e}{{\left(e^{x}\right)}^{x}}} \end{array} \]
(FPCore (x) :precision binary64 (/ 1.0 (/ E (pow (exp x) x))))
double code(double x) {
	return 1.0 / (((double) M_E) / pow(exp(x), x));
}
public static double code(double x) {
	return 1.0 / (Math.E / Math.pow(Math.exp(x), x));
}
def code(x):
	return 1.0 / (math.e / math.pow(math.exp(x), x))
function code(x)
	return Float64(1.0 / Float64(exp(1) / (exp(x) ^ x)))
end
function tmp = code(x)
	tmp = 1.0 / (2.71828182845904523536 / (exp(x) ^ x));
end
code[x_] := N[(1.0 / N[(E / N[Power[N[Exp[x], $MachinePrecision], x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{1}{\frac{e}{{\left(e^{x}\right)}^{x}}}
\end{array}
Derivation
  1. Initial program 100.0%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{e^{1 - x \cdot x}}} \]
    6. lower-/.f64N/A

      \[\leadsto \color{blue}{\frac{1}{e^{1 - x \cdot x}}} \]
    7. pow2N/A

      \[\leadsto \frac{1}{e^{1 - \color{blue}{{x}^{2}}}} \]
    8. exp-diffN/A

      \[\leadsto \frac{1}{\color{blue}{\frac{e^{1}}{e^{{x}^{2}}}}} \]
    9. lower-/.f64N/A

      \[\leadsto \frac{1}{\color{blue}{\frac{e^{1}}{e^{{x}^{2}}}}} \]
    10. exp-1-eN/A

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

      \[\leadsto \frac{1}{\frac{\color{blue}{e}}{e^{{x}^{2}}}} \]
    12. pow2N/A

      \[\leadsto \frac{1}{\frac{e}{e^{\color{blue}{x \cdot x}}}} \]
    13. exp-prodN/A

      \[\leadsto \frac{1}{\frac{e}{\color{blue}{{\left(e^{x}\right)}^{x}}}} \]
    14. lower-pow.f64N/A

      \[\leadsto \frac{1}{\frac{e}{\color{blue}{{\left(e^{x}\right)}^{x}}}} \]
    15. lower-exp.f64100.0

      \[\leadsto \frac{1}{\frac{e}{{\color{blue}{\left(e^{x}\right)}}^{x}}} \]
  3. Applied rewrites100.0%

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

Alternative 2: 100.0% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \frac{{\left(e^{x}\right)}^{x}}{e} \end{array} \]
(FPCore (x) :precision binary64 (/ (pow (exp x) x) E))
double code(double x) {
	return pow(exp(x), x) / ((double) M_E);
}
public static double code(double x) {
	return Math.pow(Math.exp(x), x) / Math.E;
}
def code(x):
	return math.pow(math.exp(x), x) / math.e
function code(x)
	return Float64((exp(x) ^ x) / exp(1))
end
function tmp = code(x)
	tmp = (exp(x) ^ x) / 2.71828182845904523536;
end
code[x_] := N[(N[Power[N[Exp[x], $MachinePrecision], x], $MachinePrecision] / E), $MachinePrecision]
\begin{array}{l}

\\
\frac{{\left(e^{x}\right)}^{x}}{e}
\end{array}
Derivation
  1. Initial program 100.0%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{e^{1 - x \cdot x}}} \]
    6. lower-/.f64N/A

      \[\leadsto \color{blue}{\frac{1}{e^{1 - x \cdot x}}} \]
    7. pow2N/A

      \[\leadsto \frac{1}{e^{1 - \color{blue}{{x}^{2}}}} \]
    8. exp-diffN/A

      \[\leadsto \frac{1}{\color{blue}{\frac{e^{1}}{e^{{x}^{2}}}}} \]
    9. lower-/.f64N/A

      \[\leadsto \frac{1}{\color{blue}{\frac{e^{1}}{e^{{x}^{2}}}}} \]
    10. exp-1-eN/A

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

      \[\leadsto \frac{1}{\frac{\color{blue}{e}}{e^{{x}^{2}}}} \]
    12. pow2N/A

      \[\leadsto \frac{1}{\frac{e}{e^{\color{blue}{x \cdot x}}}} \]
    13. exp-prodN/A

      \[\leadsto \frac{1}{\frac{e}{\color{blue}{{\left(e^{x}\right)}^{x}}}} \]
    14. lower-pow.f64N/A

      \[\leadsto \frac{1}{\frac{e}{\color{blue}{{\left(e^{x}\right)}^{x}}}} \]
    15. lower-exp.f64100.0

      \[\leadsto \frac{1}{\frac{e}{{\color{blue}{\left(e^{x}\right)}}^{x}}} \]
  3. Applied rewrites100.0%

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

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

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

      \[\leadsto \frac{1}{\color{blue}{\frac{\mathsf{E}\left(\right)}{{\left(e^{x}\right)}^{x}}}} \]
    4. lift-exp.f64N/A

      \[\leadsto \frac{1}{\frac{\mathsf{E}\left(\right)}{{\color{blue}{\left(e^{x}\right)}}^{x}}} \]
    5. lift-pow.f64N/A

      \[\leadsto \frac{1}{\frac{\mathsf{E}\left(\right)}{\color{blue}{{\left(e^{x}\right)}^{x}}}} \]
    6. pow-expN/A

      \[\leadsto \frac{1}{\frac{\mathsf{E}\left(\right)}{\color{blue}{e^{x \cdot x}}}} \]
    7. pow2N/A

      \[\leadsto \frac{1}{\frac{\mathsf{E}\left(\right)}{e^{\color{blue}{{x}^{2}}}}} \]
    8. e-exp-1N/A

      \[\leadsto \frac{1}{\frac{\color{blue}{e^{1}}}{e^{{x}^{2}}}} \]
    9. div-expN/A

      \[\leadsto \frac{1}{\color{blue}{e^{1 - {x}^{2}}}} \]
    10. pow2N/A

      \[\leadsto \frac{1}{e^{1 - \color{blue}{x \cdot x}}} \]
    11. exp-negN/A

      \[\leadsto \color{blue}{e^{\mathsf{neg}\left(\left(1 - x \cdot x\right)\right)}} \]
    12. fp-cancel-sub-sign-invN/A

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

      \[\leadsto e^{\mathsf{neg}\left(\left(1 + \color{blue}{\left(\mathsf{neg}\left(x \cdot x\right)\right)}\right)\right)} \]
    14. pow2N/A

      \[\leadsto e^{\mathsf{neg}\left(\left(1 + \left(\mathsf{neg}\left(\color{blue}{{x}^{2}}\right)\right)\right)\right)} \]
    15. distribute-neg-inN/A

      \[\leadsto e^{\color{blue}{\left(\mathsf{neg}\left(1\right)\right) + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left({x}^{2}\right)\right)\right)\right)}} \]
    16. metadata-evalN/A

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

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

      \[\leadsto e^{-1 + \color{blue}{\left(\mathsf{neg}\left(-1\right)\right) \cdot {x}^{2}}} \]
    19. metadata-evalN/A

      \[\leadsto e^{-1 + \color{blue}{1} \cdot {x}^{2}} \]
    20. *-lft-identityN/A

      \[\leadsto e^{-1 + \color{blue}{{x}^{2}}} \]
    21. +-commutativeN/A

      \[\leadsto e^{\color{blue}{{x}^{2} + -1}} \]
    22. pow2N/A

      \[\leadsto e^{\color{blue}{x \cdot x} + -1} \]
  5. Applied rewrites100.0%

    \[\leadsto \color{blue}{\frac{{\left(e^{x}\right)}^{x}}{e}} \]
  6. Add Preprocessing

Alternative 3: 76.3% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;e^{-\left(1 - x \cdot x\right)} \leq 0.5:\\ \;\;\;\;\frac{1}{e}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{x}{e}\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= (exp (- (- 1.0 (* x x)))) 0.5) (/ 1.0 E) (* x (/ x E))))
double code(double x) {
	double tmp;
	if (exp(-(1.0 - (x * x))) <= 0.5) {
		tmp = 1.0 / ((double) M_E);
	} else {
		tmp = x * (x / ((double) M_E));
	}
	return tmp;
}
public static double code(double x) {
	double tmp;
	if (Math.exp(-(1.0 - (x * x))) <= 0.5) {
		tmp = 1.0 / Math.E;
	} else {
		tmp = x * (x / Math.E);
	}
	return tmp;
}
def code(x):
	tmp = 0
	if math.exp(-(1.0 - (x * x))) <= 0.5:
		tmp = 1.0 / math.e
	else:
		tmp = x * (x / math.e)
	return tmp
function code(x)
	tmp = 0.0
	if (exp(Float64(-Float64(1.0 - Float64(x * x)))) <= 0.5)
		tmp = Float64(1.0 / exp(1));
	else
		tmp = Float64(x * Float64(x / exp(1)));
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = 0.0;
	if (exp(-(1.0 - (x * x))) <= 0.5)
		tmp = 1.0 / 2.71828182845904523536;
	else
		tmp = x * (x / 2.71828182845904523536);
	end
	tmp_2 = tmp;
end
code[x_] := If[LessEqual[N[Exp[(-N[(1.0 - N[(x * x), $MachinePrecision]), $MachinePrecision])], $MachinePrecision], 0.5], N[(1.0 / E), $MachinePrecision], N[(x * N[(x / E), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;e^{-\left(1 - x \cdot x\right)} \leq 0.5:\\
\;\;\;\;\frac{1}{e}\\

\mathbf{else}:\\
\;\;\;\;x \cdot \frac{x}{e}\\


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

    1. Initial program 100.0%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{1}{e^{1 - x \cdot x}}} \]
      6. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{1}{e^{1 - x \cdot x}}} \]
      7. pow2N/A

        \[\leadsto \frac{1}{e^{1 - \color{blue}{{x}^{2}}}} \]
      8. exp-diffN/A

        \[\leadsto \frac{1}{\color{blue}{\frac{e^{1}}{e^{{x}^{2}}}}} \]
      9. lower-/.f64N/A

        \[\leadsto \frac{1}{\color{blue}{\frac{e^{1}}{e^{{x}^{2}}}}} \]
      10. exp-1-eN/A

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

        \[\leadsto \frac{1}{\frac{\color{blue}{e}}{e^{{x}^{2}}}} \]
      12. pow2N/A

        \[\leadsto \frac{1}{\frac{e}{e^{\color{blue}{x \cdot x}}}} \]
      13. exp-prodN/A

        \[\leadsto \frac{1}{\frac{e}{\color{blue}{{\left(e^{x}\right)}^{x}}}} \]
      14. lower-pow.f64N/A

        \[\leadsto \frac{1}{\frac{e}{\color{blue}{{\left(e^{x}\right)}^{x}}}} \]
      15. lower-exp.f64100.0

        \[\leadsto \frac{1}{\frac{e}{{\color{blue}{\left(e^{x}\right)}}^{x}}} \]
    3. Applied rewrites100.0%

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

      \[\leadsto \frac{1}{\color{blue}{\mathsf{E}\left(\right)}} \]
    5. Step-by-step derivation
      1. lift-E.f6499.1

        \[\leadsto \frac{1}{e} \]
    6. Applied rewrites99.1%

      \[\leadsto \frac{1}{\color{blue}{e}} \]

    if 0.5 < (exp.f64 (neg.f64 (-.f64 #s(literal 1 binary64) (*.f64 x x))))

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(x, x, 1\right) \cdot e^{\mathsf{neg}\left(1\right)} \]
      3. rec-expN/A

        \[\leadsto \mathsf{fma}\left(x, x, 1\right) \cdot \frac{1}{\color{blue}{e^{1}}} \]
      4. e-exp-1N/A

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

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

        \[\leadsto \mathsf{fma}\left(x, x, 1\right) \cdot \frac{1}{e} \]
    6. Applied rewrites52.8%

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

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

        \[\leadsto \frac{{x}^{2}}{\mathsf{E}\left(\right)} \]
      2. pow2N/A

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

        \[\leadsto \frac{x \cdot x}{\mathsf{E}\left(\right)} \]
      4. lift-E.f6452.8

        \[\leadsto \frac{x \cdot x}{e} \]
    9. Applied rewrites52.8%

      \[\leadsto \frac{x \cdot x}{\color{blue}{e}} \]
    10. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{x \cdot x}{e} \]
      2. lift-E.f64N/A

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

        \[\leadsto \frac{x \cdot x}{\mathsf{E}\left(\right)} \]
      4. associate-/l*N/A

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

        \[\leadsto x \cdot \frac{x}{\color{blue}{\mathsf{E}\left(\right)}} \]
      6. lower-/.f64N/A

        \[\leadsto x \cdot \frac{x}{\mathsf{E}\left(\right)} \]
      7. lift-E.f6452.8

        \[\leadsto x \cdot \frac{x}{e} \]
    11. Applied rewrites52.8%

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

Alternative 4: 100.0% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \frac{1}{e \cdot e^{\left(-x\right) \cdot x}} \end{array} \]
(FPCore (x) :precision binary64 (/ 1.0 (* E (exp (* (- x) x)))))
double code(double x) {
	return 1.0 / (((double) M_E) * exp((-x * x)));
}
public static double code(double x) {
	return 1.0 / (Math.E * Math.exp((-x * x)));
}
def code(x):
	return 1.0 / (math.e * math.exp((-x * x)))
function code(x)
	return Float64(1.0 / Float64(exp(1) * exp(Float64(Float64(-x) * x))))
end
function tmp = code(x)
	tmp = 1.0 / (2.71828182845904523536 * exp((-x * x)));
end
code[x_] := N[(1.0 / N[(E * N[Exp[N[((-x) * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{1}{e \cdot e^{\left(-x\right) \cdot x}}
\end{array}
Derivation
  1. Initial program 100.0%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{e^{1 - x \cdot x}}} \]
    6. lower-/.f64N/A

      \[\leadsto \color{blue}{\frac{1}{e^{1 - x \cdot x}}} \]
    7. pow2N/A

      \[\leadsto \frac{1}{e^{1 - \color{blue}{{x}^{2}}}} \]
    8. exp-diffN/A

      \[\leadsto \frac{1}{\color{blue}{\frac{e^{1}}{e^{{x}^{2}}}}} \]
    9. lower-/.f64N/A

      \[\leadsto \frac{1}{\color{blue}{\frac{e^{1}}{e^{{x}^{2}}}}} \]
    10. exp-1-eN/A

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

      \[\leadsto \frac{1}{\frac{\color{blue}{e}}{e^{{x}^{2}}}} \]
    12. pow2N/A

      \[\leadsto \frac{1}{\frac{e}{e^{\color{blue}{x \cdot x}}}} \]
    13. exp-prodN/A

      \[\leadsto \frac{1}{\frac{e}{\color{blue}{{\left(e^{x}\right)}^{x}}}} \]
    14. lower-pow.f64N/A

      \[\leadsto \frac{1}{\frac{e}{\color{blue}{{\left(e^{x}\right)}^{x}}}} \]
    15. lower-exp.f64100.0

      \[\leadsto \frac{1}{\frac{e}{{\color{blue}{\left(e^{x}\right)}}^{x}}} \]
  3. Applied rewrites100.0%

    \[\leadsto \color{blue}{\frac{1}{\frac{e}{{\left(e^{x}\right)}^{x}}}} \]
  4. Step-by-step derivation
    1. lift-E.f64N/A

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

      \[\leadsto \frac{1}{\color{blue}{\frac{\mathsf{E}\left(\right)}{{\left(e^{x}\right)}^{x}}}} \]
    3. lift-exp.f64N/A

      \[\leadsto \frac{1}{\frac{\mathsf{E}\left(\right)}{{\color{blue}{\left(e^{x}\right)}}^{x}}} \]
    4. lift-pow.f64N/A

      \[\leadsto \frac{1}{\frac{\mathsf{E}\left(\right)}{\color{blue}{{\left(e^{x}\right)}^{x}}}} \]
    5. pow-expN/A

      \[\leadsto \frac{1}{\frac{\mathsf{E}\left(\right)}{\color{blue}{e^{x \cdot x}}}} \]
    6. pow2N/A

      \[\leadsto \frac{1}{\frac{\mathsf{E}\left(\right)}{e^{\color{blue}{{x}^{2}}}}} \]
    7. e-exp-1N/A

      \[\leadsto \frac{1}{\frac{\color{blue}{e^{1}}}{e^{{x}^{2}}}} \]
    8. div-expN/A

      \[\leadsto \frac{1}{\color{blue}{e^{1 - {x}^{2}}}} \]
    9. pow2N/A

      \[\leadsto \frac{1}{e^{1 - \color{blue}{x \cdot x}}} \]
    10. fp-cancel-sub-sign-invN/A

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

      \[\leadsto \frac{1}{\color{blue}{e^{1} \cdot e^{\left(\mathsf{neg}\left(x\right)\right) \cdot x}}} \]
    12. e-exp-1N/A

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

      \[\leadsto \frac{1}{\mathsf{E}\left(\right) \cdot e^{\color{blue}{\mathsf{neg}\left(x \cdot x\right)}}} \]
    14. pow2N/A

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

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

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

      \[\leadsto \frac{1}{e \cdot \color{blue}{e^{\mathsf{neg}\left({x}^{2}\right)}}} \]
    18. pow2N/A

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

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

      \[\leadsto \frac{1}{e \cdot e^{\color{blue}{\left(\mathsf{neg}\left(x\right)\right) \cdot x}}} \]
    21. lower-neg.f64100.0

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

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

Alternative 5: 75.6% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 1.22:\\ \;\;\;\;\frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\left(-x\right) \cdot x, \mathsf{fma}\left(0.5, e, e \cdot -0.3333333333333333\right), 0.5 \cdot e\right), x \cdot x, -e\right), x \cdot x, e\right)}\\ \mathbf{else}:\\ \;\;\;\;e^{x \cdot x}\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= x 1.22)
   (/
    1.0
    (fma
     (fma
      (fma (* (- x) x) (fma 0.5 E (* E -0.3333333333333333)) (* 0.5 E))
      (* x x)
      (- E))
     (* x x)
     E))
   (exp (* x x))))
double code(double x) {
	double tmp;
	if (x <= 1.22) {
		tmp = 1.0 / fma(fma(fma((-x * x), fma(0.5, ((double) M_E), (((double) M_E) * -0.3333333333333333)), (0.5 * ((double) M_E))), (x * x), -((double) M_E)), (x * x), ((double) M_E));
	} else {
		tmp = exp((x * x));
	}
	return tmp;
}
function code(x)
	tmp = 0.0
	if (x <= 1.22)
		tmp = Float64(1.0 / fma(fma(fma(Float64(Float64(-x) * x), fma(0.5, exp(1), Float64(exp(1) * -0.3333333333333333)), Float64(0.5 * exp(1))), Float64(x * x), Float64(-exp(1))), Float64(x * x), exp(1)));
	else
		tmp = exp(Float64(x * x));
	end
	return tmp
end
code[x_] := If[LessEqual[x, 1.22], N[(1.0 / N[(N[(N[(N[((-x) * x), $MachinePrecision] * N[(0.5 * E + N[(E * -0.3333333333333333), $MachinePrecision]), $MachinePrecision] + N[(0.5 * E), $MachinePrecision]), $MachinePrecision] * N[(x * x), $MachinePrecision] + (-E)), $MachinePrecision] * N[(x * x), $MachinePrecision] + E), $MachinePrecision]), $MachinePrecision], N[Exp[N[(x * x), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.22:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\left(-x\right) \cdot x, \mathsf{fma}\left(0.5, e, e \cdot -0.3333333333333333\right), 0.5 \cdot e\right), x \cdot x, -e\right), x \cdot x, e\right)}\\

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


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

    1. Initial program 100.0%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{1}{e^{1 - x \cdot x}}} \]
      6. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{1}{e^{1 - x \cdot x}}} \]
      7. pow2N/A

        \[\leadsto \frac{1}{e^{1 - \color{blue}{{x}^{2}}}} \]
      8. exp-diffN/A

        \[\leadsto \frac{1}{\color{blue}{\frac{e^{1}}{e^{{x}^{2}}}}} \]
      9. lower-/.f64N/A

        \[\leadsto \frac{1}{\color{blue}{\frac{e^{1}}{e^{{x}^{2}}}}} \]
      10. exp-1-eN/A

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

        \[\leadsto \frac{1}{\frac{\color{blue}{e}}{e^{{x}^{2}}}} \]
      12. pow2N/A

        \[\leadsto \frac{1}{\frac{e}{e^{\color{blue}{x \cdot x}}}} \]
      13. exp-prodN/A

        \[\leadsto \frac{1}{\frac{e}{\color{blue}{{\left(e^{x}\right)}^{x}}}} \]
      14. lower-pow.f64N/A

        \[\leadsto \frac{1}{\frac{e}{\color{blue}{{\left(e^{x}\right)}^{x}}}} \]
      15. lower-exp.f64100.0

        \[\leadsto \frac{1}{\frac{e}{{\color{blue}{\left(e^{x}\right)}}^{x}}} \]
    3. Applied rewrites100.0%

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

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

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

    if 1.21999999999999997 < x

    1. Initial program 100.0%

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

      \[\leadsto e^{\color{blue}{{x}^{2}}} \]
    3. Step-by-step derivation
      1. pow2N/A

        \[\leadsto e^{x \cdot \color{blue}{x}} \]
      2. lift-*.f6499.6

        \[\leadsto e^{x \cdot \color{blue}{x}} \]
    4. Applied rewrites99.6%

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

Alternative 6: 100.0% accurate, 1.0× speedup?

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

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

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

    \[\leadsto e^{\color{blue}{{x}^{2} - 1}} \]
  3. Step-by-step derivation
    1. metadata-evalN/A

      \[\leadsto e^{{x}^{2} - 1 \cdot \color{blue}{1}} \]
    2. fp-cancel-sub-sign-invN/A

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

      \[\leadsto e^{x \cdot x + \color{blue}{\left(\mathsf{neg}\left(1\right)\right)} \cdot 1} \]
    4. metadata-evalN/A

      \[\leadsto e^{x \cdot x + -1 \cdot 1} \]
    5. metadata-evalN/A

      \[\leadsto e^{x \cdot x + -1} \]
    6. lower-fma.f64100.0

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

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

Alternative 7: 92.3% accurate, 2.5× speedup?

\[\begin{array}{l} \\ \frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, x \cdot x, 0.5\right), x \cdot x, 1\right), x \cdot x, 1\right)}{e} \end{array} \]
(FPCore (x)
 :precision binary64
 (/
  (fma (fma (fma 0.16666666666666666 (* x x) 0.5) (* x x) 1.0) (* x x) 1.0)
  E))
double code(double x) {
	return fma(fma(fma(0.16666666666666666, (x * x), 0.5), (x * x), 1.0), (x * x), 1.0) / ((double) M_E);
}
function code(x)
	return Float64(fma(fma(fma(0.16666666666666666, Float64(x * x), 0.5), Float64(x * x), 1.0), Float64(x * x), 1.0) / exp(1))
end
code[x_] := N[(N[(N[(N[(0.16666666666666666 * N[(x * x), $MachinePrecision] + 0.5), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision] / E), $MachinePrecision]
\begin{array}{l}

\\
\frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, x \cdot x, 0.5\right), x \cdot x, 1\right), x \cdot x, 1\right)}{e}
\end{array}
Derivation
  1. Initial program 100.0%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{e^{1 - x \cdot x}}} \]
    6. lower-/.f64N/A

      \[\leadsto \color{blue}{\frac{1}{e^{1 - x \cdot x}}} \]
    7. pow2N/A

      \[\leadsto \frac{1}{e^{1 - \color{blue}{{x}^{2}}}} \]
    8. exp-diffN/A

      \[\leadsto \frac{1}{\color{blue}{\frac{e^{1}}{e^{{x}^{2}}}}} \]
    9. lower-/.f64N/A

      \[\leadsto \frac{1}{\color{blue}{\frac{e^{1}}{e^{{x}^{2}}}}} \]
    10. exp-1-eN/A

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

      \[\leadsto \frac{1}{\frac{\color{blue}{e}}{e^{{x}^{2}}}} \]
    12. pow2N/A

      \[\leadsto \frac{1}{\frac{e}{e^{\color{blue}{x \cdot x}}}} \]
    13. exp-prodN/A

      \[\leadsto \frac{1}{\frac{e}{\color{blue}{{\left(e^{x}\right)}^{x}}}} \]
    14. lower-pow.f64N/A

      \[\leadsto \frac{1}{\frac{e}{\color{blue}{{\left(e^{x}\right)}^{x}}}} \]
    15. lower-exp.f64100.0

      \[\leadsto \frac{1}{\frac{e}{{\color{blue}{\left(e^{x}\right)}}^{x}}} \]
  3. Applied rewrites100.0%

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

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

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

      \[\leadsto \frac{1}{\color{blue}{\frac{\mathsf{E}\left(\right)}{{\left(e^{x}\right)}^{x}}}} \]
    4. lift-exp.f64N/A

      \[\leadsto \frac{1}{\frac{\mathsf{E}\left(\right)}{{\color{blue}{\left(e^{x}\right)}}^{x}}} \]
    5. lift-pow.f64N/A

      \[\leadsto \frac{1}{\frac{\mathsf{E}\left(\right)}{\color{blue}{{\left(e^{x}\right)}^{x}}}} \]
    6. pow-expN/A

      \[\leadsto \frac{1}{\frac{\mathsf{E}\left(\right)}{\color{blue}{e^{x \cdot x}}}} \]
    7. pow2N/A

      \[\leadsto \frac{1}{\frac{\mathsf{E}\left(\right)}{e^{\color{blue}{{x}^{2}}}}} \]
    8. e-exp-1N/A

      \[\leadsto \frac{1}{\frac{\color{blue}{e^{1}}}{e^{{x}^{2}}}} \]
    9. div-expN/A

      \[\leadsto \frac{1}{\color{blue}{e^{1 - {x}^{2}}}} \]
    10. pow2N/A

      \[\leadsto \frac{1}{e^{1 - \color{blue}{x \cdot x}}} \]
    11. exp-negN/A

      \[\leadsto \color{blue}{e^{\mathsf{neg}\left(\left(1 - x \cdot x\right)\right)}} \]
    12. fp-cancel-sub-sign-invN/A

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

      \[\leadsto e^{\mathsf{neg}\left(\left(1 + \color{blue}{\left(\mathsf{neg}\left(x \cdot x\right)\right)}\right)\right)} \]
    14. pow2N/A

      \[\leadsto e^{\mathsf{neg}\left(\left(1 + \left(\mathsf{neg}\left(\color{blue}{{x}^{2}}\right)\right)\right)\right)} \]
    15. distribute-neg-inN/A

      \[\leadsto e^{\color{blue}{\left(\mathsf{neg}\left(1\right)\right) + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left({x}^{2}\right)\right)\right)\right)}} \]
    16. metadata-evalN/A

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

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

      \[\leadsto e^{-1 + \color{blue}{\left(\mathsf{neg}\left(-1\right)\right) \cdot {x}^{2}}} \]
    19. metadata-evalN/A

      \[\leadsto e^{-1 + \color{blue}{1} \cdot {x}^{2}} \]
    20. *-lft-identityN/A

      \[\leadsto e^{-1 + \color{blue}{{x}^{2}}} \]
    21. +-commutativeN/A

      \[\leadsto e^{\color{blue}{{x}^{2} + -1}} \]
    22. pow2N/A

      \[\leadsto e^{\color{blue}{x \cdot x} + -1} \]
  5. Applied rewrites100.0%

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{6}, {x}^{2}, \frac{1}{2}\right), {x}^{2}, 1\right), {x}^{2}, 1\right)}{e} \]
    9. pow2N/A

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

      \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{6}, x \cdot x, \frac{1}{2}\right), {x}^{2}, 1\right), {x}^{2}, 1\right)}{e} \]
    11. pow2N/A

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

      \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{6}, x \cdot x, \frac{1}{2}\right), x \cdot x, 1\right), {x}^{2}, 1\right)}{e} \]
    13. pow2N/A

      \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{6}, x \cdot x, \frac{1}{2}\right), x \cdot x, 1\right), x \cdot \color{blue}{x}, 1\right)}{e} \]
    14. lift-*.f6492.3

      \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, x \cdot x, 0.5\right), x \cdot x, 1\right), x \cdot \color{blue}{x}, 1\right)}{e} \]
  8. Applied rewrites92.3%

    \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, x \cdot x, 0.5\right), x \cdot x, 1\right), x \cdot x, 1\right)}}{e} \]
  9. Add Preprocessing

Alternative 8: 88.2% accurate, 3.3× speedup?

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

\\
\frac{\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, 0.5, 1\right) \cdot x, x, 1\right)}{e}
\end{array}
Derivation
  1. Initial program 100.0%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{e^{1 - x \cdot x}}} \]
    6. lower-/.f64N/A

      \[\leadsto \color{blue}{\frac{1}{e^{1 - x \cdot x}}} \]
    7. pow2N/A

      \[\leadsto \frac{1}{e^{1 - \color{blue}{{x}^{2}}}} \]
    8. exp-diffN/A

      \[\leadsto \frac{1}{\color{blue}{\frac{e^{1}}{e^{{x}^{2}}}}} \]
    9. lower-/.f64N/A

      \[\leadsto \frac{1}{\color{blue}{\frac{e^{1}}{e^{{x}^{2}}}}} \]
    10. exp-1-eN/A

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

      \[\leadsto \frac{1}{\frac{\color{blue}{e}}{e^{{x}^{2}}}} \]
    12. pow2N/A

      \[\leadsto \frac{1}{\frac{e}{e^{\color{blue}{x \cdot x}}}} \]
    13. exp-prodN/A

      \[\leadsto \frac{1}{\frac{e}{\color{blue}{{\left(e^{x}\right)}^{x}}}} \]
    14. lower-pow.f64N/A

      \[\leadsto \frac{1}{\frac{e}{\color{blue}{{\left(e^{x}\right)}^{x}}}} \]
    15. lower-exp.f64100.0

      \[\leadsto \frac{1}{\frac{e}{{\color{blue}{\left(e^{x}\right)}}^{x}}} \]
  3. Applied rewrites100.0%

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

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

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

      \[\leadsto \frac{1}{\color{blue}{\frac{\mathsf{E}\left(\right)}{{\left(e^{x}\right)}^{x}}}} \]
    4. lift-exp.f64N/A

      \[\leadsto \frac{1}{\frac{\mathsf{E}\left(\right)}{{\color{blue}{\left(e^{x}\right)}}^{x}}} \]
    5. lift-pow.f64N/A

      \[\leadsto \frac{1}{\frac{\mathsf{E}\left(\right)}{\color{blue}{{\left(e^{x}\right)}^{x}}}} \]
    6. pow-expN/A

      \[\leadsto \frac{1}{\frac{\mathsf{E}\left(\right)}{\color{blue}{e^{x \cdot x}}}} \]
    7. pow2N/A

      \[\leadsto \frac{1}{\frac{\mathsf{E}\left(\right)}{e^{\color{blue}{{x}^{2}}}}} \]
    8. e-exp-1N/A

      \[\leadsto \frac{1}{\frac{\color{blue}{e^{1}}}{e^{{x}^{2}}}} \]
    9. div-expN/A

      \[\leadsto \frac{1}{\color{blue}{e^{1 - {x}^{2}}}} \]
    10. pow2N/A

      \[\leadsto \frac{1}{e^{1 - \color{blue}{x \cdot x}}} \]
    11. exp-negN/A

      \[\leadsto \color{blue}{e^{\mathsf{neg}\left(\left(1 - x \cdot x\right)\right)}} \]
    12. fp-cancel-sub-sign-invN/A

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

      \[\leadsto e^{\mathsf{neg}\left(\left(1 + \color{blue}{\left(\mathsf{neg}\left(x \cdot x\right)\right)}\right)\right)} \]
    14. pow2N/A

      \[\leadsto e^{\mathsf{neg}\left(\left(1 + \left(\mathsf{neg}\left(\color{blue}{{x}^{2}}\right)\right)\right)\right)} \]
    15. distribute-neg-inN/A

      \[\leadsto e^{\color{blue}{\left(\mathsf{neg}\left(1\right)\right) + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left({x}^{2}\right)\right)\right)\right)}} \]
    16. metadata-evalN/A

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

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

      \[\leadsto e^{-1 + \color{blue}{\left(\mathsf{neg}\left(-1\right)\right) \cdot {x}^{2}}} \]
    19. metadata-evalN/A

      \[\leadsto e^{-1 + \color{blue}{1} \cdot {x}^{2}} \]
    20. *-lft-identityN/A

      \[\leadsto e^{-1 + \color{blue}{{x}^{2}}} \]
    21. +-commutativeN/A

      \[\leadsto e^{\color{blue}{{x}^{2} + -1}} \]
    22. pow2N/A

      \[\leadsto e^{\color{blue}{x \cdot x} + -1} \]
  5. Applied rewrites100.0%

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

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

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

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

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

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

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

      \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left({x}^{2}, \frac{1}{2}, 1\right), {\color{blue}{x}}^{2}, 1\right)}{e} \]
    7. pow2N/A

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

      \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, \frac{1}{2}, 1\right), {x}^{2}, 1\right)}{e} \]
    9. pow2N/A

      \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, \frac{1}{2}, 1\right), x \cdot \color{blue}{x}, 1\right)}{e} \]
    10. lift-*.f6488.2

      \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, 0.5, 1\right), x \cdot \color{blue}{x}, 1\right)}{e} \]
  8. Applied rewrites88.2%

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

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

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

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

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

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

      \[\leadsto \frac{\left(1 + \left(x \cdot x\right) \cdot \frac{1}{2}\right) \cdot {x}^{2} + 1}{e} \]
    7. pow2N/A

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

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

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

      \[\leadsto \frac{\left({x}^{2} \cdot 1 + {x}^{2} \cdot \left(\frac{1}{2} \cdot {x}^{2}\right)\right) + 1}{e} \]
    11. *-rgt-identityN/A

      \[\leadsto \frac{\left({x}^{2} + {x}^{2} \cdot \left(\frac{1}{2} \cdot {x}^{2}\right)\right) + 1}{e} \]
    12. *-rgt-identityN/A

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

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

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

      \[\leadsto \frac{\left(1 + {x}^{2} \cdot \frac{1}{2}\right) \cdot {x}^{2} + 1}{e} \]
    16. pow2N/A

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

      \[\leadsto \frac{\left(\left(x \cdot x\right) \cdot \frac{1}{2} + 1\right) \cdot {x}^{2} + 1}{e} \]
    18. pow2N/A

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

      \[\leadsto \frac{\left(\left(\left(x \cdot x\right) \cdot \frac{1}{2} + 1\right) \cdot x\right) \cdot x + 1}{e} \]
  10. Applied rewrites88.2%

    \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, 0.5, 1\right) \cdot x, \color{blue}{x}, 1\right)}{e} \]
  11. Add Preprocessing

Alternative 9: 87.9% accurate, 3.4× speedup?

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

\\
\frac{\mathsf{fma}\left(\left(x \cdot x\right) \cdot 0.5, x \cdot x, 1\right)}{e}
\end{array}
Derivation
  1. Initial program 100.0%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{e^{1 - x \cdot x}}} \]
    6. lower-/.f64N/A

      \[\leadsto \color{blue}{\frac{1}{e^{1 - x \cdot x}}} \]
    7. pow2N/A

      \[\leadsto \frac{1}{e^{1 - \color{blue}{{x}^{2}}}} \]
    8. exp-diffN/A

      \[\leadsto \frac{1}{\color{blue}{\frac{e^{1}}{e^{{x}^{2}}}}} \]
    9. lower-/.f64N/A

      \[\leadsto \frac{1}{\color{blue}{\frac{e^{1}}{e^{{x}^{2}}}}} \]
    10. exp-1-eN/A

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

      \[\leadsto \frac{1}{\frac{\color{blue}{e}}{e^{{x}^{2}}}} \]
    12. pow2N/A

      \[\leadsto \frac{1}{\frac{e}{e^{\color{blue}{x \cdot x}}}} \]
    13. exp-prodN/A

      \[\leadsto \frac{1}{\frac{e}{\color{blue}{{\left(e^{x}\right)}^{x}}}} \]
    14. lower-pow.f64N/A

      \[\leadsto \frac{1}{\frac{e}{\color{blue}{{\left(e^{x}\right)}^{x}}}} \]
    15. lower-exp.f64100.0

      \[\leadsto \frac{1}{\frac{e}{{\color{blue}{\left(e^{x}\right)}}^{x}}} \]
  3. Applied rewrites100.0%

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

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

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

      \[\leadsto \frac{1}{\color{blue}{\frac{\mathsf{E}\left(\right)}{{\left(e^{x}\right)}^{x}}}} \]
    4. lift-exp.f64N/A

      \[\leadsto \frac{1}{\frac{\mathsf{E}\left(\right)}{{\color{blue}{\left(e^{x}\right)}}^{x}}} \]
    5. lift-pow.f64N/A

      \[\leadsto \frac{1}{\frac{\mathsf{E}\left(\right)}{\color{blue}{{\left(e^{x}\right)}^{x}}}} \]
    6. pow-expN/A

      \[\leadsto \frac{1}{\frac{\mathsf{E}\left(\right)}{\color{blue}{e^{x \cdot x}}}} \]
    7. pow2N/A

      \[\leadsto \frac{1}{\frac{\mathsf{E}\left(\right)}{e^{\color{blue}{{x}^{2}}}}} \]
    8. e-exp-1N/A

      \[\leadsto \frac{1}{\frac{\color{blue}{e^{1}}}{e^{{x}^{2}}}} \]
    9. div-expN/A

      \[\leadsto \frac{1}{\color{blue}{e^{1 - {x}^{2}}}} \]
    10. pow2N/A

      \[\leadsto \frac{1}{e^{1 - \color{blue}{x \cdot x}}} \]
    11. exp-negN/A

      \[\leadsto \color{blue}{e^{\mathsf{neg}\left(\left(1 - x \cdot x\right)\right)}} \]
    12. fp-cancel-sub-sign-invN/A

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

      \[\leadsto e^{\mathsf{neg}\left(\left(1 + \color{blue}{\left(\mathsf{neg}\left(x \cdot x\right)\right)}\right)\right)} \]
    14. pow2N/A

      \[\leadsto e^{\mathsf{neg}\left(\left(1 + \left(\mathsf{neg}\left(\color{blue}{{x}^{2}}\right)\right)\right)\right)} \]
    15. distribute-neg-inN/A

      \[\leadsto e^{\color{blue}{\left(\mathsf{neg}\left(1\right)\right) + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left({x}^{2}\right)\right)\right)\right)}} \]
    16. metadata-evalN/A

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

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

      \[\leadsto e^{-1 + \color{blue}{\left(\mathsf{neg}\left(-1\right)\right) \cdot {x}^{2}}} \]
    19. metadata-evalN/A

      \[\leadsto e^{-1 + \color{blue}{1} \cdot {x}^{2}} \]
    20. *-lft-identityN/A

      \[\leadsto e^{-1 + \color{blue}{{x}^{2}}} \]
    21. +-commutativeN/A

      \[\leadsto e^{\color{blue}{{x}^{2} + -1}} \]
    22. pow2N/A

      \[\leadsto e^{\color{blue}{x \cdot x} + -1} \]
  5. Applied rewrites100.0%

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

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

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

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

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

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

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

      \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left({x}^{2}, \frac{1}{2}, 1\right), {\color{blue}{x}}^{2}, 1\right)}{e} \]
    7. pow2N/A

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

      \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, \frac{1}{2}, 1\right), {x}^{2}, 1\right)}{e} \]
    9. pow2N/A

      \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, \frac{1}{2}, 1\right), x \cdot \color{blue}{x}, 1\right)}{e} \]
    10. lift-*.f6488.2

      \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, 0.5, 1\right), x \cdot \color{blue}{x}, 1\right)}{e} \]
  8. Applied rewrites88.2%

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

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

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

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

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

      \[\leadsto \frac{\mathsf{fma}\left(\left(x \cdot x\right) \cdot 0.5, x \cdot x, 1\right)}{e} \]
  11. Applied rewrites87.9%

    \[\leadsto \frac{\mathsf{fma}\left(\left(x \cdot x\right) \cdot 0.5, \color{blue}{x} \cdot x, 1\right)}{e} \]
  12. Add Preprocessing

Alternative 10: 76.6% accurate, 4.8× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(x, x, 1\right) \cdot \frac{1}{e} \end{array} \]
(FPCore (x) :precision binary64 (* (fma x x 1.0) (/ 1.0 E)))
double code(double x) {
	return fma(x, x, 1.0) * (1.0 / ((double) M_E));
}
function code(x)
	return Float64(fma(x, x, 1.0) * Float64(1.0 / exp(1)))
end
code[x_] := N[(N[(x * x + 1.0), $MachinePrecision] * N[(1.0 / E), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(x, x, 1\right) \cdot e^{\mathsf{neg}\left(1\right)} \]
    3. rec-expN/A

      \[\leadsto \mathsf{fma}\left(x, x, 1\right) \cdot \frac{1}{\color{blue}{e^{1}}} \]
    4. e-exp-1N/A

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

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

      \[\leadsto \mathsf{fma}\left(x, x, 1\right) \cdot \frac{1}{e} \]
  6. Applied rewrites76.6%

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

Alternative 11: 76.6% accurate, 6.2× speedup?

\[\begin{array}{l} \\ \frac{\mathsf{fma}\left(x, x, 1\right)}{e} \end{array} \]
(FPCore (x) :precision binary64 (/ (fma x x 1.0) E))
double code(double x) {
	return fma(x, x, 1.0) / ((double) M_E);
}
function code(x)
	return Float64(fma(x, x, 1.0) / exp(1))
end
code[x_] := N[(N[(x * x + 1.0), $MachinePrecision] / E), $MachinePrecision]
\begin{array}{l}

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{e^{1 - x \cdot x}}} \]
    6. lower-/.f64N/A

      \[\leadsto \color{blue}{\frac{1}{e^{1 - x \cdot x}}} \]
    7. pow2N/A

      \[\leadsto \frac{1}{e^{1 - \color{blue}{{x}^{2}}}} \]
    8. exp-diffN/A

      \[\leadsto \frac{1}{\color{blue}{\frac{e^{1}}{e^{{x}^{2}}}}} \]
    9. lower-/.f64N/A

      \[\leadsto \frac{1}{\color{blue}{\frac{e^{1}}{e^{{x}^{2}}}}} \]
    10. exp-1-eN/A

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

      \[\leadsto \frac{1}{\frac{\color{blue}{e}}{e^{{x}^{2}}}} \]
    12. pow2N/A

      \[\leadsto \frac{1}{\frac{e}{e^{\color{blue}{x \cdot x}}}} \]
    13. exp-prodN/A

      \[\leadsto \frac{1}{\frac{e}{\color{blue}{{\left(e^{x}\right)}^{x}}}} \]
    14. lower-pow.f64N/A

      \[\leadsto \frac{1}{\frac{e}{\color{blue}{{\left(e^{x}\right)}^{x}}}} \]
    15. lower-exp.f64100.0

      \[\leadsto \frac{1}{\frac{e}{{\color{blue}{\left(e^{x}\right)}}^{x}}} \]
  3. Applied rewrites100.0%

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

    \[\leadsto \color{blue}{\frac{1}{\mathsf{E}\left(\right)} + \frac{{x}^{2}}{\mathsf{E}\left(\right)}} \]
  5. Step-by-step derivation
    1. div-add-revN/A

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

      \[\leadsto \frac{{x}^{2} + 1}{\mathsf{E}\left(\right)} \]
    3. pow2N/A

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

      \[\leadsto \frac{x \cdot x + 1}{\color{blue}{\mathsf{E}\left(\right)}} \]
    5. lift-fma.f64N/A

      \[\leadsto \frac{\mathsf{fma}\left(x, x, 1\right)}{\mathsf{E}\left(\right)} \]
    6. lift-E.f6476.6

      \[\leadsto \frac{\mathsf{fma}\left(x, x, 1\right)}{e} \]
  6. Applied rewrites76.6%

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

Alternative 12: 51.8% accurate, 9.3× speedup?

\[\begin{array}{l} \\ \frac{1}{e} \end{array} \]
(FPCore (x) :precision binary64 (/ 1.0 E))
double code(double x) {
	return 1.0 / ((double) M_E);
}
public static double code(double x) {
	return 1.0 / Math.E;
}
def code(x):
	return 1.0 / math.e
function code(x)
	return Float64(1.0 / exp(1))
end
function tmp = code(x)
	tmp = 1.0 / 2.71828182845904523536;
end
code[x_] := N[(1.0 / E), $MachinePrecision]
\begin{array}{l}

\\
\frac{1}{e}
\end{array}
Derivation
  1. Initial program 100.0%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{e^{1 - x \cdot x}}} \]
    6. lower-/.f64N/A

      \[\leadsto \color{blue}{\frac{1}{e^{1 - x \cdot x}}} \]
    7. pow2N/A

      \[\leadsto \frac{1}{e^{1 - \color{blue}{{x}^{2}}}} \]
    8. exp-diffN/A

      \[\leadsto \frac{1}{\color{blue}{\frac{e^{1}}{e^{{x}^{2}}}}} \]
    9. lower-/.f64N/A

      \[\leadsto \frac{1}{\color{blue}{\frac{e^{1}}{e^{{x}^{2}}}}} \]
    10. exp-1-eN/A

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

      \[\leadsto \frac{1}{\frac{\color{blue}{e}}{e^{{x}^{2}}}} \]
    12. pow2N/A

      \[\leadsto \frac{1}{\frac{e}{e^{\color{blue}{x \cdot x}}}} \]
    13. exp-prodN/A

      \[\leadsto \frac{1}{\frac{e}{\color{blue}{{\left(e^{x}\right)}^{x}}}} \]
    14. lower-pow.f64N/A

      \[\leadsto \frac{1}{\frac{e}{\color{blue}{{\left(e^{x}\right)}^{x}}}} \]
    15. lower-exp.f64100.0

      \[\leadsto \frac{1}{\frac{e}{{\color{blue}{\left(e^{x}\right)}}^{x}}} \]
  3. Applied rewrites100.0%

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

    \[\leadsto \frac{1}{\color{blue}{\mathsf{E}\left(\right)}} \]
  5. Step-by-step derivation
    1. lift-E.f6451.8

      \[\leadsto \frac{1}{e} \]
  6. Applied rewrites51.8%

    \[\leadsto \frac{1}{\color{blue}{e}} \]
  7. Add Preprocessing

Reproduce

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