
(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:
Herbie found 19 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(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}
(FPCore (x) :precision binary64 (exp (fma x x -1.0)))
double code(double x) {
return exp(fma(x, x, -1.0));
}
function code(x) return exp(fma(x, x, -1.0)) end
code[x_] := N[Exp[N[(x * x + -1.0), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
e^{\mathsf{fma}\left(x, x, -1\right)}
\end{array}
Initial program 100.0%
lift-*.f64N/A
sub-negN/A
+-commutativeN/A
distribute-neg-inN/A
remove-double-negN/A
lift-*.f64N/A
metadata-evalN/A
lower-fma.f64100.0
Applied egg-rr100.0%
(FPCore (x)
:precision binary64
(if (<= (* x x) 0.05)
(/
1.0
(/
(* E E)
(fma
(fma (fma (* x x) 0.16666666666666666 0.5) (* x (* x x)) x)
(* x E)
E)))
(exp (* x x))))
double code(double x) {
double tmp;
if ((x * x) <= 0.05) {
tmp = 1.0 / ((((double) M_E) * ((double) M_E)) / fma(fma(fma((x * x), 0.16666666666666666, 0.5), (x * (x * x)), x), (x * ((double) M_E)), ((double) M_E)));
} else {
tmp = exp((x * x));
}
return tmp;
}
function code(x) tmp = 0.0 if (Float64(x * x) <= 0.05) tmp = Float64(1.0 / Float64(Float64(exp(1) * exp(1)) / fma(fma(fma(Float64(x * x), 0.16666666666666666, 0.5), Float64(x * Float64(x * x)), x), Float64(x * exp(1)), exp(1)))); else tmp = exp(Float64(x * x)); end return tmp end
code[x_] := If[LessEqual[N[(x * x), $MachinePrecision], 0.05], N[(1.0 / N[(N[(E * E), $MachinePrecision] / N[(N[(N[(N[(x * x), $MachinePrecision] * 0.16666666666666666 + 0.5), $MachinePrecision] * N[(x * N[(x * x), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision] * N[(x * E), $MachinePrecision] + E), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Exp[N[(x * x), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 0.05:\\
\;\;\;\;\frac{1}{\frac{e \cdot e}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, 0.16666666666666666, 0.5\right), x \cdot \left(x \cdot x\right), x\right), x \cdot e, e\right)}}\\
\mathbf{else}:\\
\;\;\;\;e^{x \cdot x}\\
\end{array}
\end{array}
if (*.f64 x x) < 0.050000000000000003Initial program 100.0%
Taylor expanded in x around 0
distribute-rgt-inN/A
*-commutativeN/A
associate-+r+N/A
distribute-rgt1-inN/A
*-commutativeN/A
associate-*l*N/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
Simplified99.6%
lift-E.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
lift-fma.f64N/A
associate-*l/N/A
clear-numN/A
lower-/.f64N/A
Applied egg-rr99.7%
Applied egg-rr99.7%
if 0.050000000000000003 < (*.f64 x x) Initial program 100.0%
Taylor expanded in x around inf
unpow2N/A
lower-*.f64100.0
Simplified100.0%
(FPCore (x)
:precision binary64
(/
1.0
(/
(* E E)
(fma
(fma (fma (* x x) 0.16666666666666666 0.5) (* x (* x x)) x)
(* x E)
E))))
double code(double x) {
return 1.0 / ((((double) M_E) * ((double) M_E)) / fma(fma(fma((x * x), 0.16666666666666666, 0.5), (x * (x * x)), x), (x * ((double) M_E)), ((double) M_E)));
}
function code(x) return Float64(1.0 / Float64(Float64(exp(1) * exp(1)) / fma(fma(fma(Float64(x * x), 0.16666666666666666, 0.5), Float64(x * Float64(x * x)), x), Float64(x * exp(1)), exp(1)))) end
code[x_] := N[(1.0 / N[(N[(E * E), $MachinePrecision] / N[(N[(N[(N[(x * x), $MachinePrecision] * 0.16666666666666666 + 0.5), $MachinePrecision] * N[(x * N[(x * x), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision] * N[(x * E), $MachinePrecision] + E), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\frac{e \cdot e}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, 0.16666666666666666, 0.5\right), x \cdot \left(x \cdot x\right), x\right), x \cdot e, e\right)}}
\end{array}
Initial program 100.0%
Taylor expanded in x around 0
distribute-rgt-inN/A
*-commutativeN/A
associate-+r+N/A
distribute-rgt1-inN/A
*-commutativeN/A
associate-*l*N/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
Simplified92.0%
lift-E.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
lift-fma.f64N/A
associate-*l/N/A
clear-numN/A
lower-/.f64N/A
Applied egg-rr92.0%
Applied egg-rr92.0%
(FPCore (x) :precision binary64 (if (<= (- 1.0 (* x x)) -1000.0) (* x (* (* x x) (* x (/ (fma (* x x) 0.16666666666666666 0.5) E)))) (/ (fma (* x (fma x (* (* x x) 0.5) x)) E E) (* E E))))
double code(double x) {
double tmp;
if ((1.0 - (x * x)) <= -1000.0) {
tmp = x * ((x * x) * (x * (fma((x * x), 0.16666666666666666, 0.5) / ((double) M_E))));
} else {
tmp = fma((x * fma(x, ((x * x) * 0.5), x)), ((double) M_E), ((double) M_E)) / (((double) M_E) * ((double) M_E));
}
return tmp;
}
function code(x) tmp = 0.0 if (Float64(1.0 - Float64(x * x)) <= -1000.0) tmp = Float64(x * Float64(Float64(x * x) * Float64(x * Float64(fma(Float64(x * x), 0.16666666666666666, 0.5) / exp(1))))); else tmp = Float64(fma(Float64(x * fma(x, Float64(Float64(x * x) * 0.5), x)), exp(1), exp(1)) / Float64(exp(1) * exp(1))); end return tmp end
code[x_] := If[LessEqual[N[(1.0 - N[(x * x), $MachinePrecision]), $MachinePrecision], -1000.0], N[(x * N[(N[(x * x), $MachinePrecision] * N[(x * N[(N[(N[(x * x), $MachinePrecision] * 0.16666666666666666 + 0.5), $MachinePrecision] / E), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x * N[(x * N[(N[(x * x), $MachinePrecision] * 0.5), $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision] * E + E), $MachinePrecision] / N[(E * E), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;1 - x \cdot x \leq -1000:\\
\;\;\;\;x \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot \frac{\mathsf{fma}\left(x \cdot x, 0.16666666666666666, 0.5\right)}{e}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x \cdot \mathsf{fma}\left(x, \left(x \cdot x\right) \cdot 0.5, x\right), e, e\right)}{e \cdot e}\\
\end{array}
\end{array}
if (-.f64 #s(literal 1 binary64) (*.f64 x x)) < -1e3Initial program 100.0%
Taylor expanded in x around 0
distribute-rgt-inN/A
*-commutativeN/A
associate-+r+N/A
distribute-rgt1-inN/A
*-commutativeN/A
associate-*l*N/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
Simplified82.6%
Taylor expanded in x around inf
Simplified82.6%
lift-*.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
lift-E.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6482.6
Applied egg-rr82.6%
if -1e3 < (-.f64 #s(literal 1 binary64) (*.f64 x x)) Initial program 100.0%
Taylor expanded in x around 0
*-lft-identityN/A
associate-*r*N/A
distribute-rgt1-inN/A
associate-*r*N/A
distribute-rgt-inN/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
associate-+l+N/A
+-commutativeN/A
lower-*.f64N/A
Simplified99.5%
lift-E.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
distribute-rgt-inN/A
lift-/.f64N/A
un-div-invN/A
lift-/.f64N/A
div-invN/A
frac-addN/A
lift-E.f64N/A
lift-E.f64N/A
Applied egg-rr99.5%
Final simplification91.9%
(FPCore (x) :precision binary64 (if (<= (- 1.0 (* x x)) -1000.0) (* x (* (* x x) (* x (/ (fma (* x x) 0.16666666666666666 0.5) E)))) (/ 1.0 (fma (* (* x x) E) (fma (* x x) 0.5 -1.0) E))))
double code(double x) {
double tmp;
if ((1.0 - (x * x)) <= -1000.0) {
tmp = x * ((x * x) * (x * (fma((x * x), 0.16666666666666666, 0.5) / ((double) M_E))));
} else {
tmp = 1.0 / fma(((x * x) * ((double) M_E)), fma((x * x), 0.5, -1.0), ((double) M_E));
}
return tmp;
}
function code(x) tmp = 0.0 if (Float64(1.0 - Float64(x * x)) <= -1000.0) tmp = Float64(x * Float64(Float64(x * x) * Float64(x * Float64(fma(Float64(x * x), 0.16666666666666666, 0.5) / exp(1))))); else tmp = Float64(1.0 / fma(Float64(Float64(x * x) * exp(1)), fma(Float64(x * x), 0.5, -1.0), exp(1))); end return tmp end
code[x_] := If[LessEqual[N[(1.0 - N[(x * x), $MachinePrecision]), $MachinePrecision], -1000.0], N[(x * N[(N[(x * x), $MachinePrecision] * N[(x * N[(N[(N[(x * x), $MachinePrecision] * 0.16666666666666666 + 0.5), $MachinePrecision] / E), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(N[(x * x), $MachinePrecision] * E), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * 0.5 + -1.0), $MachinePrecision] + E), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;1 - x \cdot x \leq -1000:\\
\;\;\;\;x \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot \frac{\mathsf{fma}\left(x \cdot x, 0.16666666666666666, 0.5\right)}{e}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\left(x \cdot x\right) \cdot e, \mathsf{fma}\left(x \cdot x, 0.5, -1\right), e\right)}\\
\end{array}
\end{array}
if (-.f64 #s(literal 1 binary64) (*.f64 x x)) < -1e3Initial program 100.0%
Taylor expanded in x around 0
distribute-rgt-inN/A
*-commutativeN/A
associate-+r+N/A
distribute-rgt1-inN/A
*-commutativeN/A
associate-*l*N/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
Simplified82.6%
Taylor expanded in x around inf
Simplified82.6%
lift-*.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
lift-E.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6482.6
Applied egg-rr82.6%
if -1e3 < (-.f64 #s(literal 1 binary64) (*.f64 x x)) Initial program 100.0%
Taylor expanded in x around 0
distribute-rgt-inN/A
*-commutativeN/A
associate-+r+N/A
distribute-rgt1-inN/A
*-commutativeN/A
associate-*l*N/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
Simplified99.6%
lift-E.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
lift-fma.f64N/A
associate-*l/N/A
clear-numN/A
lower-/.f64N/A
Applied egg-rr99.7%
Taylor expanded in x around 0
+-commutativeN/A
Simplified99.5%
Final simplification91.9%
(FPCore (x) :precision binary64 (if (<= (- 1.0 (* x x)) -1000.0) (* x (* x (/ (* (* x x) (* x (* x 0.16666666666666666))) E))) (/ 1.0 (fma (* (* x x) E) (fma (* x x) 0.5 -1.0) E))))
double code(double x) {
double tmp;
if ((1.0 - (x * x)) <= -1000.0) {
tmp = x * (x * (((x * x) * (x * (x * 0.16666666666666666))) / ((double) M_E)));
} else {
tmp = 1.0 / fma(((x * x) * ((double) M_E)), fma((x * x), 0.5, -1.0), ((double) M_E));
}
return tmp;
}
function code(x) tmp = 0.0 if (Float64(1.0 - Float64(x * x)) <= -1000.0) tmp = Float64(x * Float64(x * Float64(Float64(Float64(x * x) * Float64(x * Float64(x * 0.16666666666666666))) / exp(1)))); else tmp = Float64(1.0 / fma(Float64(Float64(x * x) * exp(1)), fma(Float64(x * x), 0.5, -1.0), exp(1))); end return tmp end
code[x_] := If[LessEqual[N[(1.0 - N[(x * x), $MachinePrecision]), $MachinePrecision], -1000.0], N[(x * N[(x * N[(N[(N[(x * x), $MachinePrecision] * N[(x * N[(x * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / E), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(N[(x * x), $MachinePrecision] * E), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * 0.5 + -1.0), $MachinePrecision] + E), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;1 - x \cdot x \leq -1000:\\
\;\;\;\;x \cdot \left(x \cdot \frac{\left(x \cdot x\right) \cdot \left(x \cdot \left(x \cdot 0.16666666666666666\right)\right)}{e}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\left(x \cdot x\right) \cdot e, \mathsf{fma}\left(x \cdot x, 0.5, -1\right), e\right)}\\
\end{array}
\end{array}
if (-.f64 #s(literal 1 binary64) (*.f64 x x)) < -1e3Initial program 100.0%
Taylor expanded in x around 0
distribute-rgt-inN/A
*-commutativeN/A
associate-+r+N/A
distribute-rgt1-inN/A
*-commutativeN/A
associate-*l*N/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
Simplified82.6%
Taylor expanded in x around inf
associate-*r/N/A
metadata-evalN/A
pow-sqrN/A
cube-prodN/A
unpow2N/A
unpow3N/A
pow-sqrN/A
metadata-evalN/A
associate-*l*N/A
*-commutativeN/A
associate-*l*N/A
metadata-evalN/A
pow-sqrN/A
associate-*r*N/A
associate-*r/N/A
associate-*r/N/A
associate-*r/N/A
associate-*r*N/A
Simplified82.6%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-E.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
*-commutativeN/A
associate-*r/N/A
Applied egg-rr82.6%
if -1e3 < (-.f64 #s(literal 1 binary64) (*.f64 x x)) Initial program 100.0%
Taylor expanded in x around 0
distribute-rgt-inN/A
*-commutativeN/A
associate-+r+N/A
distribute-rgt1-inN/A
*-commutativeN/A
associate-*l*N/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
Simplified99.6%
lift-E.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
lift-fma.f64N/A
associate-*l/N/A
clear-numN/A
lower-/.f64N/A
Applied egg-rr99.7%
Taylor expanded in x around 0
+-commutativeN/A
Simplified99.5%
Final simplification91.9%
(FPCore (x) :precision binary64 (/ (fma (* x x) (fma (* (* x x) E) (fma (* x x) 0.16666666666666666 0.5) E) E) (* E E)))
double code(double x) {
return fma((x * x), fma(((x * x) * ((double) M_E)), fma((x * x), 0.16666666666666666, 0.5), ((double) M_E)), ((double) M_E)) / (((double) M_E) * ((double) M_E));
}
function code(x) return Float64(fma(Float64(x * x), fma(Float64(Float64(x * x) * exp(1)), fma(Float64(x * x), 0.16666666666666666, 0.5), exp(1)), exp(1)) / Float64(exp(1) * exp(1))) end
code[x_] := N[(N[(N[(x * x), $MachinePrecision] * N[(N[(N[(x * x), $MachinePrecision] * E), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * 0.16666666666666666 + 0.5), $MachinePrecision] + E), $MachinePrecision] + E), $MachinePrecision] / N[(E * E), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(\left(x \cdot x\right) \cdot e, \mathsf{fma}\left(x \cdot x, 0.16666666666666666, 0.5\right), e\right), e\right)}{e \cdot e}
\end{array}
Initial program 100.0%
Taylor expanded in x around 0
distribute-rgt-inN/A
*-commutativeN/A
associate-+r+N/A
distribute-rgt1-inN/A
*-commutativeN/A
associate-*l*N/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
Simplified92.0%
lift-E.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
lift-fma.f64N/A
lift-/.f64N/A
lift-fma.f64N/A
distribute-rgt-inN/A
Applied egg-rr92.0%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
Simplified92.0%
Final simplification92.0%
(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}
Initial program 100.0%
Taylor expanded in x around 0
distribute-rgt-inN/A
*-commutativeN/A
associate-+r+N/A
distribute-rgt1-inN/A
*-commutativeN/A
associate-*l*N/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
Simplified92.0%
(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(Float64(x * x), Float64(x * fma(Float64(x * x), 0.16666666666666666, 0.5)), x), 1.0) / exp(1)) end
code[x_] := N[(N[(x * N[(N[(x * x), $MachinePrecision] * N[(x * N[(N[(x * x), $MachinePrecision] * 0.16666666666666666 + 0.5), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision] + 1.0), $MachinePrecision] / E), $MachinePrecision]
\begin{array}{l}
\\
\frac{\mathsf{fma}\left(x, \mathsf{fma}\left(x \cdot x, x \cdot \mathsf{fma}\left(x \cdot x, 0.16666666666666666, 0.5\right), x\right), 1\right)}{e}
\end{array}
Initial program 100.0%
Taylor expanded in x around 0
distribute-rgt-inN/A
*-commutativeN/A
associate-+r+N/A
distribute-rgt1-inN/A
*-commutativeN/A
associate-*l*N/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
Simplified92.0%
lift-E.f64N/A
frac-2negN/A
metadata-evalN/A
lift-*.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
lift-fma.f64N/A
associate-*l/N/A
neg-mul-1N/A
frac-2negN/A
Applied egg-rr92.0%
(FPCore (x) :precision binary64 (if (<= (* x x) 0.05) (fma x (/ x E) (/ 1.0 E)) (* x (* (/ x E) (fma x (* x 0.5) 1.0)))))
double code(double x) {
double tmp;
if ((x * x) <= 0.05) {
tmp = fma(x, (x / ((double) M_E)), (1.0 / ((double) M_E)));
} else {
tmp = x * ((x / ((double) M_E)) * fma(x, (x * 0.5), 1.0));
}
return tmp;
}
function code(x) tmp = 0.0 if (Float64(x * x) <= 0.05) tmp = fma(x, Float64(x / exp(1)), Float64(1.0 / exp(1))); else tmp = Float64(x * Float64(Float64(x / exp(1)) * fma(x, Float64(x * 0.5), 1.0))); end return tmp end
code[x_] := If[LessEqual[N[(x * x), $MachinePrecision], 0.05], N[(x * N[(x / E), $MachinePrecision] + N[(1.0 / E), $MachinePrecision]), $MachinePrecision], N[(x * N[(N[(x / E), $MachinePrecision] * N[(x * N[(x * 0.5), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 0.05:\\
\;\;\;\;\mathsf{fma}\left(x, \frac{x}{e}, \frac{1}{e}\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\frac{x}{e} \cdot \mathsf{fma}\left(x, x \cdot 0.5, 1\right)\right)\\
\end{array}
\end{array}
if (*.f64 x x) < 0.050000000000000003Initial program 100.0%
Taylor expanded in x around 0
distribute-rgt1-inN/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
rec-expN/A
lower-/.f64N/A
exp-1-eN/A
lower-E.f64N/A
unpow2N/A
lower-fma.f6499.2
Simplified99.2%
lift-E.f64N/A
lift-/.f64N/A
lift-*.f64N/A
distribute-lft-inN/A
*-commutativeN/A
lift-*.f64N/A
associate-*l*N/A
lift-/.f64N/A
un-div-invN/A
*-rgt-identityN/A
lower-fma.f64N/A
lower-/.f6499.2
Applied egg-rr99.2%
if 0.050000000000000003 < (*.f64 x x) Initial program 100.0%
Taylor expanded in x around 0
*-lft-identityN/A
associate-*r*N/A
distribute-rgt1-inN/A
associate-*r*N/A
distribute-rgt-inN/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
associate-+l+N/A
+-commutativeN/A
lower-*.f64N/A
Simplified75.2%
Taylor expanded in x around inf
Simplified75.2%
Final simplification88.4%
(FPCore (x) :precision binary64 (if (<= (* x x) 0.05) (fma x (/ x E) (/ 1.0 E)) (* x (* x (* 0.5 (/ (* x x) E))))))
double code(double x) {
double tmp;
if ((x * x) <= 0.05) {
tmp = fma(x, (x / ((double) M_E)), (1.0 / ((double) M_E)));
} else {
tmp = x * (x * (0.5 * ((x * x) / ((double) M_E))));
}
return tmp;
}
function code(x) tmp = 0.0 if (Float64(x * x) <= 0.05) tmp = fma(x, Float64(x / exp(1)), Float64(1.0 / exp(1))); else tmp = Float64(x * Float64(x * Float64(0.5 * Float64(Float64(x * x) / exp(1))))); end return tmp end
code[x_] := If[LessEqual[N[(x * x), $MachinePrecision], 0.05], N[(x * N[(x / E), $MachinePrecision] + N[(1.0 / E), $MachinePrecision]), $MachinePrecision], N[(x * N[(x * N[(0.5 * N[(N[(x * x), $MachinePrecision] / E), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 0.05:\\
\;\;\;\;\mathsf{fma}\left(x, \frac{x}{e}, \frac{1}{e}\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(x \cdot \left(0.5 \cdot \frac{x \cdot x}{e}\right)\right)\\
\end{array}
\end{array}
if (*.f64 x x) < 0.050000000000000003Initial program 100.0%
Taylor expanded in x around 0
distribute-rgt1-inN/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
rec-expN/A
lower-/.f64N/A
exp-1-eN/A
lower-E.f64N/A
unpow2N/A
lower-fma.f6499.2
Simplified99.2%
lift-E.f64N/A
lift-/.f64N/A
lift-*.f64N/A
distribute-lft-inN/A
*-commutativeN/A
lift-*.f64N/A
associate-*l*N/A
lift-/.f64N/A
un-div-invN/A
*-rgt-identityN/A
lower-fma.f64N/A
lower-/.f6499.2
Applied egg-rr99.2%
if 0.050000000000000003 < (*.f64 x x) Initial program 100.0%
Taylor expanded in x around 0
*-lft-identityN/A
associate-*r*N/A
distribute-rgt1-inN/A
associate-*r*N/A
distribute-rgt-inN/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
associate-+l+N/A
+-commutativeN/A
lower-*.f64N/A
Simplified75.2%
Taylor expanded in x around inf
metadata-evalN/A
pow-sqrN/A
associate-*r/N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
associate-*r/N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-E.f6475.2
Simplified75.2%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-E.f64N/A
associate-/l*N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lift-/.f64N/A
lower-*.f6475.2
Applied egg-rr75.2%
(FPCore (x) :precision binary64 (* (/ 1.0 E) (fma x (fma x (* x (* x 0.5)) x) 1.0)))
double code(double x) {
return (1.0 / ((double) M_E)) * fma(x, fma(x, (x * (x * 0.5)), x), 1.0);
}
function code(x) return Float64(Float64(1.0 / exp(1)) * fma(x, fma(x, Float64(x * Float64(x * 0.5)), x), 1.0)) end
code[x_] := N[(N[(1.0 / E), $MachinePrecision] * N[(x * N[(x * N[(x * N[(x * 0.5), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{e} \cdot \mathsf{fma}\left(x, \mathsf{fma}\left(x, x \cdot \left(x \cdot 0.5\right), x\right), 1\right)
\end{array}
Initial program 100.0%
Taylor expanded in x around 0
*-lft-identityN/A
associate-*r*N/A
distribute-rgt1-inN/A
associate-*r*N/A
distribute-rgt-inN/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
associate-+l+N/A
+-commutativeN/A
lower-*.f64N/A
Simplified88.6%
(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}
Initial program 100.0%
Taylor expanded in x around 0
*-lft-identityN/A
associate-*r*N/A
distribute-rgt1-inN/A
associate-*r*N/A
distribute-rgt-inN/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
associate-+l+N/A
+-commutativeN/A
lower-*.f64N/A
Simplified88.6%
lift-E.f64N/A
frac-2negN/A
metadata-evalN/A
lift-*.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
lift-fma.f64N/A
associate-*l/N/A
neg-mul-1N/A
frac-2negN/A
lower-/.f6488.6
Applied egg-rr88.6%
Final simplification88.6%
(FPCore (x) :precision binary64 (if (<= (* x x) 0.05) (/ 1.0 E) (/ (* x x) E)))
double code(double x) {
double tmp;
if ((x * x) <= 0.05) {
tmp = 1.0 / ((double) M_E);
} else {
tmp = (x * x) / ((double) M_E);
}
return tmp;
}
public static double code(double x) {
double tmp;
if ((x * x) <= 0.05) {
tmp = 1.0 / Math.E;
} else {
tmp = (x * x) / Math.E;
}
return tmp;
}
def code(x): tmp = 0 if (x * x) <= 0.05: tmp = 1.0 / math.e else: tmp = (x * x) / math.e return tmp
function code(x) tmp = 0.0 if (Float64(x * x) <= 0.05) tmp = Float64(1.0 / exp(1)); else tmp = Float64(Float64(x * x) / exp(1)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if ((x * x) <= 0.05) tmp = 1.0 / 2.71828182845904523536; else tmp = (x * x) / 2.71828182845904523536; end tmp_2 = tmp; end
code[x_] := If[LessEqual[N[(x * x), $MachinePrecision], 0.05], N[(1.0 / E), $MachinePrecision], N[(N[(x * x), $MachinePrecision] / E), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 0.05:\\
\;\;\;\;\frac{1}{e}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot x}{e}\\
\end{array}
\end{array}
if (*.f64 x x) < 0.050000000000000003Initial program 100.0%
Taylor expanded in x around 0
metadata-evalN/A
rec-expN/A
lower-/.f64N/A
exp-1-eN/A
lower-E.f6498.5
Simplified98.5%
if 0.050000000000000003 < (*.f64 x x) Initial program 100.0%
Taylor expanded in x around 0
distribute-rgt1-inN/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
rec-expN/A
lower-/.f64N/A
exp-1-eN/A
lower-E.f64N/A
unpow2N/A
lower-fma.f6448.3
Simplified48.3%
Taylor expanded in x around inf
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-E.f6448.3
Simplified48.3%
(FPCore (x) :precision binary64 (if (<= (* x x) 0.05) (/ 1.0 E) (* x (/ x E))))
double code(double x) {
double tmp;
if ((x * x) <= 0.05) {
tmp = 1.0 / ((double) M_E);
} else {
tmp = x * (x / ((double) M_E));
}
return tmp;
}
public static double code(double x) {
double tmp;
if ((x * x) <= 0.05) {
tmp = 1.0 / Math.E;
} else {
tmp = x * (x / Math.E);
}
return tmp;
}
def code(x): tmp = 0 if (x * x) <= 0.05: tmp = 1.0 / math.e else: tmp = x * (x / math.e) return tmp
function code(x) tmp = 0.0 if (Float64(x * x) <= 0.05) 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 ((x * x) <= 0.05) tmp = 1.0 / 2.71828182845904523536; else tmp = x * (x / 2.71828182845904523536); end tmp_2 = tmp; end
code[x_] := If[LessEqual[N[(x * x), $MachinePrecision], 0.05], N[(1.0 / E), $MachinePrecision], N[(x * N[(x / E), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 0.05:\\
\;\;\;\;\frac{1}{e}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{x}{e}\\
\end{array}
\end{array}
if (*.f64 x x) < 0.050000000000000003Initial program 100.0%
Taylor expanded in x around 0
metadata-evalN/A
rec-expN/A
lower-/.f64N/A
exp-1-eN/A
lower-E.f6498.5
Simplified98.5%
if 0.050000000000000003 < (*.f64 x x) Initial program 100.0%
Taylor expanded in x around 0
distribute-rgt1-inN/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
rec-expN/A
lower-/.f64N/A
exp-1-eN/A
lower-E.f64N/A
unpow2N/A
lower-fma.f6448.3
Simplified48.3%
Taylor expanded in x around inf
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-E.f6448.3
Simplified48.3%
lift-E.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6447.6
Applied egg-rr47.6%
Final simplification75.6%
(FPCore (x) :precision binary64 (/ (fma (* x x) E E) (* E E)))
double code(double x) {
return fma((x * x), ((double) M_E), ((double) M_E)) / (((double) M_E) * ((double) M_E));
}
function code(x) return Float64(fma(Float64(x * x), exp(1), exp(1)) / Float64(exp(1) * exp(1))) end
code[x_] := N[(N[(N[(x * x), $MachinePrecision] * E + E), $MachinePrecision] / N[(E * E), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\mathsf{fma}\left(x \cdot x, e, e\right)}{e \cdot e}
\end{array}
Initial program 100.0%
Taylor expanded in x around 0
distribute-rgt1-inN/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
rec-expN/A
lower-/.f64N/A
exp-1-eN/A
lower-E.f64N/A
unpow2N/A
lower-fma.f6476.3
Simplified76.3%
lift-E.f64N/A
lift-/.f64N/A
lift-*.f64N/A
distribute-rgt-inN/A
lift-/.f64N/A
un-div-invN/A
lift-/.f64N/A
div-invN/A
frac-addN/A
lift-E.f64N/A
lift-E.f64N/A
lower-/.f64N/A
*-rgt-identityN/A
lower-fma.f64N/A
lift-E.f64N/A
lift-E.f64N/A
lower-*.f6476.3
Applied egg-rr76.3%
(FPCore (x) :precision binary64 (* (/ 1.0 E) (fma x x 1.0)))
double code(double x) {
return (1.0 / ((double) M_E)) * fma(x, x, 1.0);
}
function code(x) return Float64(Float64(1.0 / exp(1)) * fma(x, x, 1.0)) end
code[x_] := N[(N[(1.0 / E), $MachinePrecision] * N[(x * x + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{e} \cdot \mathsf{fma}\left(x, x, 1\right)
\end{array}
Initial program 100.0%
Taylor expanded in x around 0
distribute-rgt1-inN/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
rec-expN/A
lower-/.f64N/A
exp-1-eN/A
lower-E.f64N/A
unpow2N/A
lower-fma.f6476.3
Simplified76.3%
(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}
Initial program 100.0%
Taylor expanded in x around 0
distribute-rgt1-inN/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
rec-expN/A
lower-/.f64N/A
exp-1-eN/A
lower-E.f64N/A
unpow2N/A
lower-fma.f6476.3
Simplified76.3%
lift-E.f64N/A
frac-2negN/A
metadata-evalN/A
lift-fma.f64N/A
associate-*l/N/A
neg-mul-1N/A
frac-2negN/A
lower-/.f6476.3
Applied egg-rr76.3%
(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}
Initial program 100.0%
Taylor expanded in x around 0
metadata-evalN/A
rec-expN/A
lower-/.f64N/A
exp-1-eN/A
lower-E.f6455.6
Simplified55.6%
herbie shell --seed 2024212
(FPCore (x)
:name "exp neg sub"
:precision binary64
(exp (- (- 1.0 (* x x)))))