exp neg sub

Percentage Accurate: 100.0% → 100.0%
Time: 12.2s
Alternatives: 14
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)));
}
real(8) function code(x)
    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 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: 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)));
}
real(8) function code(x)
    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.9× speedup?

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

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

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

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

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

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

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

      \[\leadsto e^{-1 + \color{blue}{x \cdot x}} \]
    6. exp-sumN/A

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

      \[\leadsto e^{\color{blue}{\mathsf{neg}\left(1\right)}} \cdot e^{x \cdot x} \]
    8. rec-expN/A

      \[\leadsto \color{blue}{\frac{1}{e^{1}}} \cdot e^{x \cdot x} \]
    9. associate-/r/N/A

      \[\leadsto \color{blue}{\frac{1}{\frac{e^{1}}{e^{x \cdot x}}}} \]
    10. clear-numN/A

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

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

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

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

      \[\leadsto \frac{e^{x \cdot x}}{\color{blue}{e}} \]
  4. Applied egg-rr100.0%

    \[\leadsto \color{blue}{\frac{e^{x \cdot x}}{e}} \]
  5. Add Preprocessing

Alternative 2: 92.4% accurate, 0.7× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(\mathsf{fma}\left(x, x \cdot 0.16666666666666666, 0.5\right) \cdot \frac{x \cdot x}{e}\right)\\


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{-1}{\mathsf{neg}\left(\mathsf{E}\left(\right)\right)} \cdot \left(x \cdot \color{blue}{\mathsf{fma}\left(x, x \cdot \left(x \cdot \frac{1}{2}\right), x\right)} + 1\right) \]
      7. *-rgt-identityN/A

        \[\leadsto \frac{-1}{\mathsf{neg}\left(\mathsf{E}\left(\right)\right)} \cdot \left(\color{blue}{\left(x \cdot \mathsf{fma}\left(x, x \cdot \left(x \cdot \frac{1}{2}\right), x\right)\right) \cdot 1} + 1\right) \]
      8. *-rgt-identityN/A

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

        \[\leadsto \frac{-1}{\mathsf{neg}\left(\mathsf{E}\left(\right)\right)} \cdot \color{blue}{\mathsf{fma}\left(x, \mathsf{fma}\left(x, x \cdot \left(x \cdot \frac{1}{2}\right), x\right), 1\right)} \]
      10. associate-*l/N/A

        \[\leadsto \color{blue}{\frac{-1 \cdot \mathsf{fma}\left(x, \mathsf{fma}\left(x, x \cdot \left(x \cdot \frac{1}{2}\right), x\right), 1\right)}{\mathsf{neg}\left(\mathsf{E}\left(\right)\right)}} \]
      11. neg-mul-1N/A

        \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(\mathsf{fma}\left(x, \mathsf{fma}\left(x, x \cdot \left(x \cdot \frac{1}{2}\right), x\right), 1\right)\right)}}{\mathsf{neg}\left(\mathsf{E}\left(\right)\right)} \]
      12. frac-2negN/A

        \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(x, \mathsf{fma}\left(x, x \cdot \left(x \cdot \frac{1}{2}\right), x\right), 1\right)}{\mathsf{E}\left(\right)}} \]
      13. lower-/.f6499.9

        \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(x, \mathsf{fma}\left(x, x \cdot \left(x \cdot 0.5\right), x\right), 1\right)}{e}} \]
    7. Applied egg-rr99.9%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \left(x \cdot x\right) \cdot 0.5, x\right), 1\right)}{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. Add Preprocessing
    3. Taylor expanded in x around 0

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(x \cdot x\right) \cdot \left(\frac{x \cdot x}{e} \cdot \mathsf{fma}\left(x, x \cdot 0.16666666666666666, 0.5\right)\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification92.2%

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

Alternative 3: 92.4% accurate, 0.7× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot \left(0.16666666666666666 \cdot \frac{x \cdot x}{e}\right)\right)\\


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{-1}{\mathsf{neg}\left(\mathsf{E}\left(\right)\right)} \cdot \left(x \cdot \color{blue}{\mathsf{fma}\left(x, x \cdot \left(x \cdot \frac{1}{2}\right), x\right)} + 1\right) \]
      7. *-rgt-identityN/A

        \[\leadsto \frac{-1}{\mathsf{neg}\left(\mathsf{E}\left(\right)\right)} \cdot \left(\color{blue}{\left(x \cdot \mathsf{fma}\left(x, x \cdot \left(x \cdot \frac{1}{2}\right), x\right)\right) \cdot 1} + 1\right) \]
      8. *-rgt-identityN/A

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

        \[\leadsto \frac{-1}{\mathsf{neg}\left(\mathsf{E}\left(\right)\right)} \cdot \color{blue}{\mathsf{fma}\left(x, \mathsf{fma}\left(x, x \cdot \left(x \cdot \frac{1}{2}\right), x\right), 1\right)} \]
      10. associate-*l/N/A

        \[\leadsto \color{blue}{\frac{-1 \cdot \mathsf{fma}\left(x, \mathsf{fma}\left(x, x \cdot \left(x \cdot \frac{1}{2}\right), x\right), 1\right)}{\mathsf{neg}\left(\mathsf{E}\left(\right)\right)}} \]
      11. neg-mul-1N/A

        \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(\mathsf{fma}\left(x, \mathsf{fma}\left(x, x \cdot \left(x \cdot \frac{1}{2}\right), x\right), 1\right)\right)}}{\mathsf{neg}\left(\mathsf{E}\left(\right)\right)} \]
      12. frac-2negN/A

        \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(x, \mathsf{fma}\left(x, x \cdot \left(x \cdot \frac{1}{2}\right), x\right), 1\right)}{\mathsf{E}\left(\right)}} \]
      13. lower-/.f6499.9

        \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(x, \mathsf{fma}\left(x, x \cdot \left(x \cdot 0.5\right), x\right), 1\right)}{e}} \]
    7. Applied egg-rr99.9%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \left(x \cdot x\right) \cdot 0.5, x\right), 1\right)}{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. Add Preprocessing
    3. Taylor expanded in x around 0

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{{x}^{6}}{\mathsf{E}\left(\right)} \cdot \frac{1}{6}} \]
      2. associate-*l/N/A

        \[\leadsto \color{blue}{\frac{{x}^{6} \cdot \frac{1}{6}}{\mathsf{E}\left(\right)}} \]
      3. metadata-evalN/A

        \[\leadsto \frac{{x}^{\color{blue}{\left(2 \cdot 3\right)}} \cdot \frac{1}{6}}{\mathsf{E}\left(\right)} \]
      4. pow-sqrN/A

        \[\leadsto \frac{\color{blue}{\left({x}^{3} \cdot {x}^{3}\right)} \cdot \frac{1}{6}}{\mathsf{E}\left(\right)} \]
      5. cube-prodN/A

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

        \[\leadsto \frac{{\color{blue}{\left({x}^{2}\right)}}^{3} \cdot \frac{1}{6}}{\mathsf{E}\left(\right)} \]
      7. cube-unmultN/A

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

        \[\leadsto \frac{\left({x}^{2} \cdot \color{blue}{{x}^{\left(2 \cdot 2\right)}}\right) \cdot \frac{1}{6}}{\mathsf{E}\left(\right)} \]
      9. metadata-evalN/A

        \[\leadsto \frac{\left({x}^{2} \cdot {x}^{\color{blue}{4}}\right) \cdot \frac{1}{6}}{\mathsf{E}\left(\right)} \]
      10. associate-*r*N/A

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

        \[\leadsto \frac{{x}^{2} \cdot \color{blue}{\left(\frac{1}{6} \cdot {x}^{4}\right)}}{\mathsf{E}\left(\right)} \]
      12. metadata-evalN/A

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

        \[\leadsto \frac{{x}^{2} \cdot \left(\frac{1}{6} \cdot \color{blue}{\left({x}^{2} \cdot {x}^{2}\right)}\right)}{\mathsf{E}\left(\right)} \]
      14. associate-*l*N/A

        \[\leadsto \frac{{x}^{2} \cdot \color{blue}{\left(\left(\frac{1}{6} \cdot {x}^{2}\right) \cdot {x}^{2}\right)}}{\mathsf{E}\left(\right)} \]
      15. associate-*r*N/A

        \[\leadsto \frac{\color{blue}{\left({x}^{2} \cdot \left(\frac{1}{6} \cdot {x}^{2}\right)\right) \cdot {x}^{2}}}{\mathsf{E}\left(\right)} \]
      16. associate-*l/N/A

        \[\leadsto \color{blue}{\frac{{x}^{2} \cdot \left(\frac{1}{6} \cdot {x}^{2}\right)}{\mathsf{E}\left(\right)} \cdot {x}^{2}} \]
      17. associate-*r/N/A

        \[\leadsto \color{blue}{\left({x}^{2} \cdot \frac{\frac{1}{6} \cdot {x}^{2}}{\mathsf{E}\left(\right)}\right)} \cdot {x}^{2} \]
      18. associate-*r/N/A

        \[\leadsto \left({x}^{2} \cdot \color{blue}{\left(\frac{1}{6} \cdot \frac{{x}^{2}}{\mathsf{E}\left(\right)}\right)}\right) \cdot {x}^{2} \]
      19. associate-*r*N/A

        \[\leadsto \color{blue}{{x}^{2} \cdot \left(\left(\frac{1}{6} \cdot \frac{{x}^{2}}{\mathsf{E}\left(\right)}\right) \cdot {x}^{2}\right)} \]
    8. Simplified83.7%

      \[\leadsto \color{blue}{\left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot \left(\frac{x \cdot x}{e} \cdot 0.16666666666666666\right)\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification92.2%

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

Alternative 4: 88.8% accurate, 0.8× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;x \cdot \left(x \cdot \frac{\mathsf{fma}\left(x \cdot x, 0.5, 1\right)}{e}\right)\\


\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. 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. *-commutativeN/A

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\mathsf{E}\left(\right)} \cdot \left(\color{blue}{x \cdot x} + 1\right) \]
      10. lower-fma.f6499.7

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

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

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

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

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

        \[\leadsto \frac{-1}{\mathsf{neg}\left(\mathsf{E}\left(\right)\right)} \cdot \color{blue}{\mathsf{fma}\left(x, x, 1\right)} \]
      5. associate-*l/N/A

        \[\leadsto \color{blue}{\frac{-1 \cdot \mathsf{fma}\left(x, x, 1\right)}{\mathsf{neg}\left(\mathsf{E}\left(\right)\right)}} \]
      6. neg-mul-1N/A

        \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(\mathsf{fma}\left(x, x, 1\right)\right)}}{\mathsf{neg}\left(\mathsf{E}\left(\right)\right)} \]
      7. frac-2negN/A

        \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(x, x, 1\right)}{\mathsf{E}\left(\right)}} \]
      8. lower-/.f6499.7

        \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(x, x, 1\right)}{e}} \]
    7. Applied egg-rr99.7%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(x, x, 1\right)}{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. Add Preprocessing
    3. Taylor expanded in x around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{{x}^{4} \cdot \left(\frac{1}{2} \cdot \frac{1}{\mathsf{E}\left(\right)} + \frac{1}{{x}^{2} \cdot \mathsf{E}\left(\right)}\right)} \]
    7. Step-by-step derivation
      1. distribute-lft-inN/A

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto {x}^{2} \cdot \color{blue}{\left(\frac{1}{\mathsf{E}\left(\right)} + {x}^{2} \cdot \left(\frac{1}{2} \cdot \frac{1}{\mathsf{E}\left(\right)}\right)\right)} \]
    8. Simplified79.0%

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

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

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

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

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

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

        \[\leadsto x \cdot \left(x \cdot \left(\frac{1}{2} \cdot \frac{\color{blue}{1 \cdot {x}^{2}}}{\mathsf{E}\left(\right)} + \frac{1}{\mathsf{E}\left(\right)}\right)\right) \]
      6. associate-*l/N/A

        \[\leadsto x \cdot \left(x \cdot \left(\frac{1}{2} \cdot \color{blue}{\left(\frac{1}{\mathsf{E}\left(\right)} \cdot {x}^{2}\right)} + \frac{1}{\mathsf{E}\left(\right)}\right)\right) \]
      7. associate-*l*N/A

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

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

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

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

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

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

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

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

        \[\leadsto x \cdot \left(x \cdot \color{blue}{\frac{1 + \frac{1}{2} \cdot {x}^{2}}{\mathsf{E}\left(\right)}}\right) \]
    11. Simplified79.0%

      \[\leadsto \color{blue}{x \cdot \left(x \cdot \frac{\mathsf{fma}\left(x \cdot x, 0.5, 1\right)}{e}\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification89.8%

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

Alternative 5: 88.8% accurate, 0.8× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\left(x \cdot \left(\left(x \cdot x\right) \cdot 0.5\right)\right) \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. 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. *-commutativeN/A

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\mathsf{E}\left(\right)} \cdot \left(\color{blue}{x \cdot x} + 1\right) \]
      10. lower-fma.f6499.7

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

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

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

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

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

        \[\leadsto \frac{-1}{\mathsf{neg}\left(\mathsf{E}\left(\right)\right)} \cdot \color{blue}{\mathsf{fma}\left(x, x, 1\right)} \]
      5. associate-*l/N/A

        \[\leadsto \color{blue}{\frac{-1 \cdot \mathsf{fma}\left(x, x, 1\right)}{\mathsf{neg}\left(\mathsf{E}\left(\right)\right)}} \]
      6. neg-mul-1N/A

        \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(\mathsf{fma}\left(x, x, 1\right)\right)}}{\mathsf{neg}\left(\mathsf{E}\left(\right)\right)} \]
      7. frac-2negN/A

        \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(x, x, 1\right)}{\mathsf{E}\left(\right)}} \]
      8. lower-/.f6499.7

        \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(x, x, 1\right)}{e}} \]
    7. Applied egg-rr99.7%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(x, x, 1\right)}{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. Add Preprocessing
    3. Taylor expanded in x around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{2} \cdot \frac{{x}^{4}}{\mathsf{E}\left(\right)}} \]
    7. Step-by-step derivation
      1. associate-*r/N/A

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

        \[\leadsto \frac{\color{blue}{{x}^{4} \cdot \frac{1}{2}}}{\mathsf{E}\left(\right)} \]
      3. associate-*r/N/A

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

        \[\leadsto {x}^{4} \cdot \frac{\color{blue}{\frac{1}{2} \cdot 1}}{\mathsf{E}\left(\right)} \]
      5. associate-*r/N/A

        \[\leadsto {x}^{4} \cdot \color{blue}{\left(\frac{1}{2} \cdot \frac{1}{\mathsf{E}\left(\right)}\right)} \]
      6. metadata-evalN/A

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

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

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

        \[\leadsto {x}^{2} \cdot \left({x}^{2} \cdot \color{blue}{\frac{\frac{1}{2} \cdot 1}{\mathsf{E}\left(\right)}}\right) \]
      10. metadata-evalN/A

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

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

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

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

        \[\leadsto \color{blue}{\frac{{x}^{2} \cdot \left(\frac{1}{2} \cdot {x}^{2}\right)}{\mathsf{E}\left(\right)}} \]
    8. Simplified79.0%

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

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

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

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

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

        \[\leadsto \frac{\left(\frac{1}{2} \cdot \left(x \cdot \left(x \cdot x\right)\right)\right) \cdot x}{\color{blue}{\mathsf{E}\left(\right)}} \]
      6. associate-/l*N/A

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

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

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

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

        \[\leadsto \left(\color{blue}{\left(x \cdot \left(x \cdot x\right)\right)} \cdot \frac{1}{2}\right) \cdot \frac{x}{\mathsf{E}\left(\right)} \]
      11. associate-*l*N/A

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

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

        \[\leadsto \left(x \cdot \color{blue}{\left(\left(x \cdot x\right) \cdot \frac{1}{2}\right)}\right) \cdot \frac{x}{\mathsf{E}\left(\right)} \]
      14. lower-/.f6479.0

        \[\leadsto \left(x \cdot \left(\left(x \cdot x\right) \cdot 0.5\right)\right) \cdot \color{blue}{\frac{x}{e}} \]
    10. Applied egg-rr79.0%

      \[\leadsto \color{blue}{\left(x \cdot \left(\left(x \cdot x\right) \cdot 0.5\right)\right) \cdot \frac{x}{e}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification89.8%

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

Alternative 6: 76.7% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;e^{x \cdot x + -1} \leq 0.5:\\ \;\;\;\;\frac{1}{e}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{x}{e}\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= (exp (+ (* x x) -1.0)) 0.5) (/ 1.0 E) (* x (/ x E))))
double code(double x) {
	double tmp;
	if (exp(((x * x) + -1.0)) <= 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(((x * x) + -1.0)) <= 0.5) {
		tmp = 1.0 / Math.E;
	} else {
		tmp = x * (x / Math.E);
	}
	return tmp;
}
def code(x):
	tmp = 0
	if math.exp(((x * x) + -1.0)) <= 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(x * x) + -1.0)) <= 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(((x * x) + -1.0)) <= 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[(N[(x * x), $MachinePrecision] + -1.0), $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^{x \cdot x + -1} \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. Add Preprocessing
    3. Taylor expanded in x around 0

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

        \[\leadsto e^{\color{blue}{\mathsf{neg}\left(1\right)}} \]
      2. rec-expN/A

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

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

        \[\leadsto \frac{1}{\color{blue}{\mathsf{E}\left(\right)}} \]
      5. lower-E.f6499.2

        \[\leadsto \frac{1}{\color{blue}{e}} \]
    5. Simplified99.2%

      \[\leadsto \color{blue}{\frac{1}{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. 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. *-commutativeN/A

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\mathsf{E}\left(\right)} \cdot \left(\color{blue}{x \cdot x} + 1\right) \]
      10. lower-fma.f6454.9

        \[\leadsto \frac{1}{e} \cdot \color{blue}{\mathsf{fma}\left(x, x, 1\right)} \]
    5. Simplified54.9%

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

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

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

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

        \[\leadsto \frac{\color{blue}{x \cdot x}}{\mathsf{E}\left(\right)} \]
      4. lower-E.f6454.9

        \[\leadsto \frac{x \cdot x}{\color{blue}{e}} \]
    8. Simplified54.9%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{x}{e}} \cdot x \]
    10. Applied egg-rr54.9%

      \[\leadsto \color{blue}{\frac{x}{e} \cdot x} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification78.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;e^{x \cdot x + -1} \leq 0.5:\\ \;\;\;\;\frac{1}{e}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{x}{e}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 99.6% accurate, 0.9× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 x x) < 5.00000000000000024e-5

    1. Initial program 100.0%

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

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

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

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

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

        \[\leadsto e^{-1 + \color{blue}{x \cdot x}} \]
      6. exp-sumN/A

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

        \[\leadsto e^{\color{blue}{\mathsf{neg}\left(1\right)}} \cdot e^{x \cdot x} \]
      8. rec-expN/A

        \[\leadsto \color{blue}{\frac{1}{e^{1}}} \cdot e^{x \cdot x} \]
      9. associate-/r/N/A

        \[\leadsto \color{blue}{\frac{1}{\frac{e^{1}}{e^{x \cdot x}}}} \]
      10. clear-numN/A

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

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

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

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

        \[\leadsto \frac{e^{x \cdot x}}{\color{blue}{e}} \]
    4. Applied egg-rr100.0%

      \[\leadsto \color{blue}{\frac{e^{x \cdot x}}{e}} \]
    5. 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)}}{\mathsf{E}\left(\right)} \]
    6. Step-by-step derivation
      1. +-commutativeN/A

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

        \[\leadsto \frac{\color{blue}{\left(x \cdot x\right)} \cdot \left(1 + {x}^{2} \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot {x}^{2}\right)\right) + 1}{\mathsf{E}\left(\right)} \]
      3. associate-*l*N/A

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

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(x, x \cdot \left(1 + {x}^{2} \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot {x}^{2}\right)\right), 1\right)}}{\mathsf{E}\left(\right)} \]
    7. Simplified100.0%

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

    if 5.00000000000000024e-5 < (*.f64 x x)

    1. Initial program 100.0%

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

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

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

        \[\leadsto e^{\color{blue}{x \cdot x}} \]
    5. Simplified100.0%

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

Alternative 8: 100.0% accurate, 1.0× speedup?

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

\\
e^{x \cdot x + -1}
\end{array}
Derivation
  1. Initial program 100.0%

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

    \[\leadsto e^{x \cdot x + -1} \]
  4. Add Preprocessing

Alternative 9: 92.4% accurate, 2.5× speedup?

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

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

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

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

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

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

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

      \[\leadsto e^{-1 + \color{blue}{x \cdot x}} \]
    6. exp-sumN/A

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

      \[\leadsto e^{\color{blue}{\mathsf{neg}\left(1\right)}} \cdot e^{x \cdot x} \]
    8. rec-expN/A

      \[\leadsto \color{blue}{\frac{1}{e^{1}}} \cdot e^{x \cdot x} \]
    9. associate-/r/N/A

      \[\leadsto \color{blue}{\frac{1}{\frac{e^{1}}{e^{x \cdot x}}}} \]
    10. clear-numN/A

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

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

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

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

      \[\leadsto \frac{e^{x \cdot x}}{\color{blue}{e}} \]
  4. Applied egg-rr100.0%

    \[\leadsto \color{blue}{\frac{e^{x \cdot x}}{e}} \]
  5. 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)}}{\mathsf{E}\left(\right)} \]
  6. Step-by-step derivation
    1. +-commutativeN/A

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

      \[\leadsto \frac{\color{blue}{\left(x \cdot x\right)} \cdot \left(1 + {x}^{2} \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot {x}^{2}\right)\right) + 1}{\mathsf{E}\left(\right)} \]
    3. associate-*l*N/A

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

      \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(x, x \cdot \left(1 + {x}^{2} \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot {x}^{2}\right)\right), 1\right)}}{\mathsf{E}\left(\right)} \]
  7. Simplified92.2%

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

Alternative 10: 92.3% accurate, 2.5× speedup?

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

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

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

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

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

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

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

      \[\leadsto e^{-1 + \color{blue}{x \cdot x}} \]
    6. exp-sumN/A

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

      \[\leadsto e^{\color{blue}{\mathsf{neg}\left(1\right)}} \cdot e^{x \cdot x} \]
    8. rec-expN/A

      \[\leadsto \color{blue}{\frac{1}{e^{1}}} \cdot e^{x \cdot x} \]
    9. associate-/r/N/A

      \[\leadsto \color{blue}{\frac{1}{\frac{e^{1}}{e^{x \cdot x}}}} \]
    10. clear-numN/A

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

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

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

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

      \[\leadsto \frac{e^{x \cdot x}}{\color{blue}{e}} \]
  4. Applied egg-rr100.0%

    \[\leadsto \color{blue}{\frac{e^{x \cdot x}}{e}} \]
  5. 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)}}{\mathsf{E}\left(\right)} \]
  6. Step-by-step derivation
    1. +-commutativeN/A

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

      \[\leadsto \frac{\color{blue}{\left(x \cdot x\right)} \cdot \left(1 + {x}^{2} \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot {x}^{2}\right)\right) + 1}{\mathsf{E}\left(\right)} \]
    3. associate-*l*N/A

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

      \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(x, x \cdot \left(1 + {x}^{2} \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot {x}^{2}\right)\right), 1\right)}}{\mathsf{E}\left(\right)} \]
  7. Simplified92.2%

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

    \[\leadsto \frac{\mathsf{fma}\left(x, \mathsf{fma}\left(x, x \cdot \color{blue}{\left(\frac{1}{6} \cdot {x}^{3}\right)}, x\right), 1\right)}{\mathsf{E}\left(\right)} \]
  9. Step-by-step derivation
    1. unpow3N/A

      \[\leadsto \frac{\mathsf{fma}\left(x, \mathsf{fma}\left(x, x \cdot \left(\frac{1}{6} \cdot \color{blue}{\left(\left(x \cdot x\right) \cdot x\right)}\right), x\right), 1\right)}{\mathsf{E}\left(\right)} \]
    2. unpow2N/A

      \[\leadsto \frac{\mathsf{fma}\left(x, \mathsf{fma}\left(x, x \cdot \left(\frac{1}{6} \cdot \left(\color{blue}{{x}^{2}} \cdot x\right)\right), x\right), 1\right)}{\mathsf{E}\left(\right)} \]
    3. associate-*r*N/A

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

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

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

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

      \[\leadsto \frac{\mathsf{fma}\left(x, \mathsf{fma}\left(x, x \cdot \left(x \cdot \color{blue}{\left({x}^{2} \cdot \frac{1}{6}\right)}\right), x\right), 1\right)}{\mathsf{E}\left(\right)} \]
    8. unpow2N/A

      \[\leadsto \frac{\mathsf{fma}\left(x, \mathsf{fma}\left(x, x \cdot \left(x \cdot \left(\color{blue}{\left(x \cdot x\right)} \cdot \frac{1}{6}\right)\right), x\right), 1\right)}{\mathsf{E}\left(\right)} \]
    9. lower-*.f6492.1

      \[\leadsto \frac{\mathsf{fma}\left(x, \mathsf{fma}\left(x, x \cdot \left(x \cdot \left(\color{blue}{\left(x \cdot x\right)} \cdot 0.16666666666666666\right)\right), x\right), 1\right)}{e} \]
  10. Simplified92.1%

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

Alternative 11: 92.1% accurate, 2.6× speedup?

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

\\
\frac{\mathsf{fma}\left(x \cdot x, \left(x \cdot x\right) \cdot \left(x \cdot \left(x \cdot 0.16666666666666666\right)\right), 1\right)}{e}
\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 \left(e^{-1} + {x}^{2} \cdot \left(\frac{1}{6} \cdot \left({x}^{2} \cdot e^{-1}\right) + \frac{1}{2} \cdot e^{-1}\right)\right)} \]
  4. Step-by-step derivation
    1. distribute-rgt-inN/A

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \frac{1}{\mathsf{E}\left(\right)} \cdot \mathsf{fma}\left(x, \color{blue}{\frac{1}{6} \cdot {x}^{5}}, 1\right) \]
  7. Step-by-step derivation
    1. metadata-evalN/A

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

      \[\leadsto \frac{1}{\mathsf{E}\left(\right)} \cdot \mathsf{fma}\left(x, \frac{1}{6} \cdot \color{blue}{\left({x}^{4} \cdot x\right)}, 1\right) \]
    3. associate-*l*N/A

      \[\leadsto \frac{1}{\mathsf{E}\left(\right)} \cdot \mathsf{fma}\left(x, \color{blue}{\left(\frac{1}{6} \cdot {x}^{4}\right) \cdot x}, 1\right) \]
    4. metadata-evalN/A

      \[\leadsto \frac{1}{\mathsf{E}\left(\right)} \cdot \mathsf{fma}\left(x, \left(\frac{1}{6} \cdot {x}^{\color{blue}{\left(2 \cdot 2\right)}}\right) \cdot x, 1\right) \]
    5. pow-sqrN/A

      \[\leadsto \frac{1}{\mathsf{E}\left(\right)} \cdot \mathsf{fma}\left(x, \left(\frac{1}{6} \cdot \color{blue}{\left({x}^{2} \cdot {x}^{2}\right)}\right) \cdot x, 1\right) \]
    6. associate-*l*N/A

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

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

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

      \[\leadsto \frac{1}{\mathsf{E}\left(\right)} \cdot \mathsf{fma}\left(x, \color{blue}{x \cdot \left({x}^{2} \cdot \left(\frac{1}{6} \cdot {x}^{2}\right)\right)}, 1\right) \]
    10. unpow2N/A

      \[\leadsto \frac{1}{\mathsf{E}\left(\right)} \cdot \mathsf{fma}\left(x, x \cdot \left(\color{blue}{\left(x \cdot x\right)} \cdot \left(\frac{1}{6} \cdot {x}^{2}\right)\right), 1\right) \]
    11. associate-*l*N/A

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

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

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

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

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

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

      \[\leadsto \frac{1}{\mathsf{E}\left(\right)} \cdot \mathsf{fma}\left(x, x \cdot \left(x \cdot \left(x \cdot \color{blue}{\left({x}^{2} \cdot \frac{1}{6}\right)}\right)\right), 1\right) \]
    18. unpow2N/A

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\mathsf{E}\left(\right)} \cdot \color{blue}{\mathsf{fma}\left(x, x \cdot \left(x \cdot \left(x \cdot \left(\left(x \cdot x\right) \cdot \frac{1}{6}\right)\right)\right), 1\right)} \]
    8. associate-*l/N/A

      \[\leadsto \color{blue}{\frac{1 \cdot \mathsf{fma}\left(x, x \cdot \left(x \cdot \left(x \cdot \left(\left(x \cdot x\right) \cdot \frac{1}{6}\right)\right)\right), 1\right)}{\mathsf{E}\left(\right)}} \]
    9. *-lft-identityN/A

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(x, x \cdot \left(x \cdot \left(x \cdot \left(\left(x \cdot x\right) \cdot 0.16666666666666666\right)\right)\right), 1\right)}{e}} \]
  10. Applied egg-rr91.8%

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

Alternative 12: 88.9% accurate, 3.3× speedup?

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

\\
\frac{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \left(x \cdot x\right) \cdot 0.5, x\right), 1\right)}{e}
\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 \left(e^{-1} + \frac{1}{2} \cdot \left({x}^{2} \cdot e^{-1}\right)\right)} \]
  4. Step-by-step derivation
    1. *-lft-identityN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{-1}{\mathsf{neg}\left(\mathsf{E}\left(\right)\right)} \cdot \left(x \cdot \color{blue}{\mathsf{fma}\left(x, x \cdot \left(x \cdot \frac{1}{2}\right), x\right)} + 1\right) \]
    7. *-rgt-identityN/A

      \[\leadsto \frac{-1}{\mathsf{neg}\left(\mathsf{E}\left(\right)\right)} \cdot \left(\color{blue}{\left(x \cdot \mathsf{fma}\left(x, x \cdot \left(x \cdot \frac{1}{2}\right), x\right)\right) \cdot 1} + 1\right) \]
    8. *-rgt-identityN/A

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

      \[\leadsto \frac{-1}{\mathsf{neg}\left(\mathsf{E}\left(\right)\right)} \cdot \color{blue}{\mathsf{fma}\left(x, \mathsf{fma}\left(x, x \cdot \left(x \cdot \frac{1}{2}\right), x\right), 1\right)} \]
    10. associate-*l/N/A

      \[\leadsto \color{blue}{\frac{-1 \cdot \mathsf{fma}\left(x, \mathsf{fma}\left(x, x \cdot \left(x \cdot \frac{1}{2}\right), x\right), 1\right)}{\mathsf{neg}\left(\mathsf{E}\left(\right)\right)}} \]
    11. neg-mul-1N/A

      \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(\mathsf{fma}\left(x, \mathsf{fma}\left(x, x \cdot \left(x \cdot \frac{1}{2}\right), x\right), 1\right)\right)}}{\mathsf{neg}\left(\mathsf{E}\left(\right)\right)} \]
    12. frac-2negN/A

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(x, \mathsf{fma}\left(x, x \cdot \left(x \cdot \frac{1}{2}\right), x\right), 1\right)}{\mathsf{E}\left(\right)}} \]
    13. lower-/.f6489.9

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(x, \mathsf{fma}\left(x, x \cdot \left(x \cdot 0.5\right), x\right), 1\right)}{e}} \]
  7. Applied egg-rr89.9%

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

Alternative 13: 76.9% 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. 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. *-commutativeN/A

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\mathsf{E}\left(\right)} \cdot \left(\color{blue}{x \cdot x} + 1\right) \]
    10. lower-fma.f6478.4

      \[\leadsto \frac{1}{e} \cdot \color{blue}{\mathsf{fma}\left(x, x, 1\right)} \]
  5. Simplified78.4%

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

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

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

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

      \[\leadsto \frac{-1}{\mathsf{neg}\left(\mathsf{E}\left(\right)\right)} \cdot \color{blue}{\mathsf{fma}\left(x, x, 1\right)} \]
    5. associate-*l/N/A

      \[\leadsto \color{blue}{\frac{-1 \cdot \mathsf{fma}\left(x, x, 1\right)}{\mathsf{neg}\left(\mathsf{E}\left(\right)\right)}} \]
    6. neg-mul-1N/A

      \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(\mathsf{fma}\left(x, x, 1\right)\right)}}{\mathsf{neg}\left(\mathsf{E}\left(\right)\right)} \]
    7. frac-2negN/A

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(x, x, 1\right)}{\mathsf{E}\left(\right)}} \]
    8. lower-/.f6478.4

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(x, x, 1\right)}{e}} \]
  7. Applied egg-rr78.4%

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

Alternative 14: 51.5% 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. Add Preprocessing
  3. Taylor expanded in x around 0

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

      \[\leadsto e^{\color{blue}{\mathsf{neg}\left(1\right)}} \]
    2. rec-expN/A

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

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

      \[\leadsto \frac{1}{\color{blue}{\mathsf{E}\left(\right)}} \]
    5. lower-E.f6453.4

      \[\leadsto \frac{1}{\color{blue}{e}} \]
  5. Simplified53.4%

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

Reproduce

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