exp neg sub

Percentage Accurate: 100.0% → 100.0%
Time: 9.8s
Alternatives: 13
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 13 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, 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 2: 99.4% accurate, 0.9× speedup?

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

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

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


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

    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. associate-*r*N/A

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

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

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

        \[\leadsto \color{blue}{1 \cdot e^{-1}} + \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. Simplified100.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)} \]

    if 4.99999999999999977e-7 < (*.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 3: 91.7% accurate, 2.2× speedup?

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

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

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


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

    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. associate-*r*N/A

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

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

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

        \[\leadsto \color{blue}{1 \cdot e^{-1}} + \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. Simplified100.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)} \]

    if 4.99999999999999977e-7 < (*.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}} \]
    6. Taylor expanded in x around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{x \cdot \left(x \cdot \left({x}^{2} \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot {x}^{2}\right)\right)\right)} \]
    11. Simplified88.1%

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

Alternative 4: 92.0% accurate, 2.2× speedup?

\[\begin{array}{l} \\ \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) \end{array} \]
(FPCore (x)
 :precision binary64
 (*
  (/ 1.0 E)
  (fma x (fma (fma (* x x) 0.16666666666666666 0.5) (* x (* x x)) x) 1.0)))
double code(double x) {
	return (1.0 / ((double) M_E)) * fma(x, fma(fma((x * x), 0.16666666666666666, 0.5), (x * (x * x)), x), 1.0);
}
function code(x)
	return Float64(Float64(1.0 / exp(1)) * fma(x, fma(fma(Float64(x * x), 0.16666666666666666, 0.5), Float64(x * Float64(x * x)), x), 1.0))
end
code[x_] := N[(N[(1.0 / E), $MachinePrecision] * N[(x * N[(N[(N[(x * x), $MachinePrecision] * 0.16666666666666666 + 0.5), $MachinePrecision] * N[(x * N[(x * x), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\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)
\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. Simplified94.1%

    \[\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. Add Preprocessing

Alternative 5: 91.7% accurate, 2.6× speedup?

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

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

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


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

    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.9

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

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

    if 4.99999999999999977e-7 < (*.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}} \]
    6. Taylor expanded in x around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{x \cdot \left(x \cdot \left({x}^{2} \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot {x}^{2}\right)\right)\right)} \]
    11. Simplified88.1%

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

Alternative 6: 91.7% accurate, 2.6× speedup?

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

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

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


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

    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.9

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

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

    if 4.99999999999999977e-7 < (*.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}} \]
    6. Taylor expanded in x around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(x \cdot x, \left(x \cdot \left(x \cdot \color{blue}{\left(x \cdot x\right)}\right)\right) \cdot 0.16666666666666666, 1\right) \]
    11. Simplified88.1%

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

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

        \[\leadsto \color{blue}{\frac{1}{6} \cdot {x}^{6}} \]
      2. metadata-evalN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{6} \cdot \left(\left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right) \cdot \color{blue}{\left(x \cdot x\right)}\right) \]
      17. lower-*.f6488.1

        \[\leadsto 0.16666666666666666 \cdot \left(\left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right) \cdot \color{blue}{\left(x \cdot x\right)}\right) \]
    14. Simplified88.1%

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

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

Alternative 7: 88.1% accurate, 3.0× speedup?

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

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

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


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

    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}} \]
    6. Taylor expanded in x around 0

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(x, \color{blue}{\mathsf{fma}\left(\frac{1}{2}, {x}^{3}, x\right)}, 1\right) \]
      12. cube-multN/A

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

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

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

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

        \[\leadsto \mathsf{fma}\left(x, \mathsf{fma}\left(0.5, x \cdot \color{blue}{\left(x \cdot x\right)}, x\right), 1\right) \]
    8. Simplified78.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto x \cdot \mathsf{fma}\left(x, \color{blue}{\left(x \cdot x\right)} \cdot 0.5, x\right) \]
    11. Simplified78.6%

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

    if -2e8 < (-.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.f6499.9

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

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

Alternative 8: 87.9% accurate, 3.1× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\frac{1}{e}\\


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

    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}} \]
    6. Taylor expanded in x around 0

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(x, \color{blue}{\mathsf{fma}\left(\frac{1}{2}, {x}^{3}, x\right)}, 1\right) \]
      12. cube-multN/A

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

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

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

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

        \[\leadsto \mathsf{fma}\left(x, \mathsf{fma}\left(0.5, x \cdot \color{blue}{\left(x \cdot x\right)}, x\right), 1\right) \]
    8. Simplified78.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto x \cdot \mathsf{fma}\left(x, \color{blue}{\left(x \cdot x\right)} \cdot 0.5, x\right) \]
    11. Simplified78.6%

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

    if -2e8 < (-.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}} \]
    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.3

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

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

Alternative 9: 87.9% accurate, 3.2× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\frac{1}{e}\\


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

    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}} \]
    6. Taylor expanded in x around 0

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(x, \color{blue}{\mathsf{fma}\left(\frac{1}{2}, {x}^{3}, x\right)}, 1\right) \]
      12. cube-multN/A

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

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

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

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

        \[\leadsto \mathsf{fma}\left(x, \mathsf{fma}\left(0.5, x \cdot \color{blue}{\left(x \cdot x\right)}, x\right), 1\right) \]
    8. Simplified78.6%

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

      \[\leadsto \color{blue}{\frac{1}{2} \cdot {x}^{4}} \]
    10. Step-by-step derivation
      1. metadata-evalN/A

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

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

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

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

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

        \[\leadsto x \cdot \left(\frac{1}{2} \cdot \color{blue}{\left(\left(x \cdot x\right) \cdot x\right)}\right) \]
      7. unpow2N/A

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

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

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

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

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

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

        \[\leadsto x \cdot \left(x \cdot \left(\color{blue}{\left(x \cdot x\right)} \cdot \frac{1}{2}\right)\right) \]
      14. lower-*.f6478.6

        \[\leadsto x \cdot \left(x \cdot \left(\color{blue}{\left(x \cdot x\right)} \cdot 0.5\right)\right) \]
    11. Simplified78.6%

      \[\leadsto \color{blue}{x \cdot \left(x \cdot \left(\left(x \cdot x\right) \cdot 0.5\right)\right)} \]

    if -2e8 < (-.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}} \]
    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.3

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

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

Alternative 10: 76.0% accurate, 4.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 5 \cdot 10^{-7}:\\
\;\;\;\;\frac{1}{e}\\

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


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

    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.3

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

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

    if 4.99999999999999977e-7 < (*.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}} \]
    6. Taylor expanded in x around 0

      \[\leadsto \color{blue}{1 + {x}^{2}} \]
    7. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \color{blue}{{x}^{2} + 1} \]
      2. unpow2N/A

        \[\leadsto \color{blue}{x \cdot x} + 1 \]
      3. lower-fma.f6449.0

        \[\leadsto \color{blue}{\mathsf{fma}\left(x, x, 1\right)} \]
    8. Simplified49.0%

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

Alternative 11: 36.0% accurate, 5.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;1 - x \cdot x \leq -200000000:\\ \;\;\;\;x \cdot x\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= (- 1.0 (* x x)) -200000000.0) (* x x) 1.0))
double code(double x) {
	double tmp;
	if ((1.0 - (x * x)) <= -200000000.0) {
		tmp = x * x;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
real(8) function code(x)
    real(8), intent (in) :: x
    real(8) :: tmp
    if ((1.0d0 - (x * x)) <= (-200000000.0d0)) then
        tmp = x * x
    else
        tmp = 1.0d0
    end if
    code = tmp
end function
public static double code(double x) {
	double tmp;
	if ((1.0 - (x * x)) <= -200000000.0) {
		tmp = x * x;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
def code(x):
	tmp = 0
	if (1.0 - (x * x)) <= -200000000.0:
		tmp = x * x
	else:
		tmp = 1.0
	return tmp
function code(x)
	tmp = 0.0
	if (Float64(1.0 - Float64(x * x)) <= -200000000.0)
		tmp = Float64(x * x);
	else
		tmp = 1.0;
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = 0.0;
	if ((1.0 - (x * x)) <= -200000000.0)
		tmp = x * x;
	else
		tmp = 1.0;
	end
	tmp_2 = tmp;
end
code[x_] := If[LessEqual[N[(1.0 - N[(x * x), $MachinePrecision]), $MachinePrecision], -200000000.0], N[(x * x), $MachinePrecision], 1.0]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;1 - x \cdot x \leq -200000000:\\
\;\;\;\;x \cdot x\\

\mathbf{else}:\\
\;\;\;\;1\\


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

    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}} \]
    6. Taylor expanded in x around 0

      \[\leadsto \color{blue}{1 + {x}^{2}} \]
    7. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \color{blue}{{x}^{2} + 1} \]
      2. unpow2N/A

        \[\leadsto \color{blue}{x \cdot x} + 1 \]
      3. lower-fma.f6449.0

        \[\leadsto \color{blue}{\mathsf{fma}\left(x, x, 1\right)} \]
    8. Simplified49.0%

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

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

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

        \[\leadsto \color{blue}{x \cdot x} \]
    11. Simplified49.0%

      \[\leadsto \color{blue}{x \cdot x} \]

    if -2e8 < (-.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 inf

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

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

        \[\leadsto e^{\color{blue}{x \cdot x}} \]
    5. Simplified17.8%

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

      \[\leadsto \color{blue}{1} \]
    7. Step-by-step derivation
      1. Simplified17.8%

        \[\leadsto \color{blue}{1} \]
    8. Recombined 2 regimes into one program.
    9. Add Preprocessing

    Alternative 12: 36.0% accurate, 15.9× speedup?

    \[\begin{array}{l} \\ \mathsf{fma}\left(x, x, 1\right) \end{array} \]
    (FPCore (x) :precision binary64 (fma x x 1.0))
    double code(double x) {
    	return fma(x, x, 1.0);
    }
    
    function code(x)
    	return fma(x, x, 1.0)
    end
    
    code[x_] := N[(x * x + 1.0), $MachinePrecision]
    
    \begin{array}{l}
    
    \\
    \mathsf{fma}\left(x, x, 1\right)
    \end{array}
    
    Derivation
    1. Initial program 100.0%

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

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

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

        \[\leadsto e^{\color{blue}{x \cdot x}} \]
    5. Simplified58.9%

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

      \[\leadsto \color{blue}{1 + {x}^{2}} \]
    7. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \color{blue}{{x}^{2} + 1} \]
      2. unpow2N/A

        \[\leadsto \color{blue}{x \cdot x} + 1 \]
      3. lower-fma.f6433.4

        \[\leadsto \color{blue}{\mathsf{fma}\left(x, x, 1\right)} \]
    8. Simplified33.4%

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

    Alternative 13: 10.4% accurate, 111.0× speedup?

    \[\begin{array}{l} \\ 1 \end{array} \]
    (FPCore (x) :precision binary64 1.0)
    double code(double x) {
    	return 1.0;
    }
    
    real(8) function code(x)
        real(8), intent (in) :: x
        code = 1.0d0
    end function
    
    public static double code(double x) {
    	return 1.0;
    }
    
    def code(x):
    	return 1.0
    
    function code(x)
    	return 1.0
    end
    
    function tmp = code(x)
    	tmp = 1.0;
    end
    
    code[x_] := 1.0
    
    \begin{array}{l}
    
    \\
    1
    \end{array}
    
    Derivation
    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-*.f6458.9

        \[\leadsto e^{\color{blue}{x \cdot x}} \]
    5. Simplified58.9%

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

      \[\leadsto \color{blue}{1} \]
    7. Step-by-step derivation
      1. Simplified10.5%

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

      Reproduce

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