
(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 14 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}
x_m = (fabs.f64 x) (FPCore (x_m) :precision binary64 (pow (exp (+ x_m 1.0)) (+ x_m -1.0)))
x_m = fabs(x);
double code(double x_m) {
return pow(exp((x_m + 1.0)), (x_m + -1.0));
}
x_m = abs(x)
real(8) function code(x_m)
real(8), intent (in) :: x_m
code = exp((x_m + 1.0d0)) ** (x_m + (-1.0d0))
end function
x_m = Math.abs(x);
public static double code(double x_m) {
return Math.pow(Math.exp((x_m + 1.0)), (x_m + -1.0));
}
x_m = math.fabs(x) def code(x_m): return math.pow(math.exp((x_m + 1.0)), (x_m + -1.0))
x_m = abs(x) function code(x_m) return exp(Float64(x_m + 1.0)) ^ Float64(x_m + -1.0) end
x_m = abs(x); function tmp = code(x_m) tmp = exp((x_m + 1.0)) ^ (x_m + -1.0); end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_] := N[Power[N[Exp[N[(x$95$m + 1.0), $MachinePrecision]], $MachinePrecision], N[(x$95$m + -1.0), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
{\left(e^{x\_m + 1}\right)}^{\left(x\_m + -1\right)}
\end{array}
Initial program 99.9%
lift-neg.f64N/A
neg-sub0N/A
lift--.f64N/A
associate--r-N/A
metadata-evalN/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6499.9
Applied rewrites99.9%
lift-exp.f64N/A
lift-fma.f64N/A
difference-of-sqr--1N/A
exp-prodN/A
lower-pow.f64N/A
lower-exp.f64N/A
lower-+.f64N/A
sub-negN/A
metadata-evalN/A
lower-+.f64100.0
Applied rewrites100.0%
x_m = (fabs.f64 x) (FPCore (x_m) :precision binary64 (if (<= (exp (+ -1.0 (* x_m x_m))) 0.5) (/ 1.0 (/ E (fma x_m (fma x_m (* (* x_m x_m) 0.5) x_m) 1.0))) (* 0.16666666666666666 (* x_m (/ (* x_m (* x_m (* x_m (* x_m x_m)))) E)))))
x_m = fabs(x);
double code(double x_m) {
double tmp;
if (exp((-1.0 + (x_m * x_m))) <= 0.5) {
tmp = 1.0 / (((double) M_E) / fma(x_m, fma(x_m, ((x_m * x_m) * 0.5), x_m), 1.0));
} else {
tmp = 0.16666666666666666 * (x_m * ((x_m * (x_m * (x_m * (x_m * x_m)))) / ((double) M_E)));
}
return tmp;
}
x_m = abs(x) function code(x_m) tmp = 0.0 if (exp(Float64(-1.0 + Float64(x_m * x_m))) <= 0.5) tmp = Float64(1.0 / Float64(exp(1) / fma(x_m, fma(x_m, Float64(Float64(x_m * x_m) * 0.5), x_m), 1.0))); else tmp = Float64(0.16666666666666666 * Float64(x_m * Float64(Float64(x_m * Float64(x_m * Float64(x_m * Float64(x_m * x_m)))) / exp(1)))); end return tmp end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_] := If[LessEqual[N[Exp[N[(-1.0 + N[(x$95$m * x$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 0.5], N[(1.0 / N[(E / N[(x$95$m * N[(x$95$m * N[(N[(x$95$m * x$95$m), $MachinePrecision] * 0.5), $MachinePrecision] + x$95$m), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.16666666666666666 * N[(x$95$m * N[(N[(x$95$m * N[(x$95$m * N[(x$95$m * N[(x$95$m * x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / E), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;e^{-1 + x\_m \cdot x\_m} \leq 0.5:\\
\;\;\;\;\frac{1}{\frac{e}{\mathsf{fma}\left(x\_m, \mathsf{fma}\left(x\_m, \left(x\_m \cdot x\_m\right) \cdot 0.5, x\_m\right), 1\right)}}\\
\mathbf{else}:\\
\;\;\;\;0.16666666666666666 \cdot \left(x\_m \cdot \frac{x\_m \cdot \left(x\_m \cdot \left(x\_m \cdot \left(x\_m \cdot x\_m\right)\right)\right)}{e}\right)\\
\end{array}
\end{array}
if (exp.f64 (neg.f64 (-.f64 #s(literal 1 binary64) (*.f64 x x)))) < 0.5Initial 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
Applied rewrites99.4%
Applied rewrites99.4%
if 0.5 < (exp.f64 (neg.f64 (-.f64 #s(literal 1 binary64) (*.f64 x x)))) Initial program 99.9%
Applied rewrites59.4%
Taylor expanded in x around 0
Applied rewrites81.7%
Applied rewrites41.1%
Taylor expanded in x around inf
Applied rewrites81.7%
Final simplification89.5%
x_m = (fabs.f64 x) (FPCore (x_m) :precision binary64 (if (<= (exp (+ -1.0 (* x_m x_m))) 0.5) (/ (fma x_m (fma x_m (* (* x_m x_m) 0.5) x_m) 1.0) E) (* 0.16666666666666666 (* x_m (/ (* x_m (* x_m (* x_m (* x_m x_m)))) E)))))
x_m = fabs(x);
double code(double x_m) {
double tmp;
if (exp((-1.0 + (x_m * x_m))) <= 0.5) {
tmp = fma(x_m, fma(x_m, ((x_m * x_m) * 0.5), x_m), 1.0) / ((double) M_E);
} else {
tmp = 0.16666666666666666 * (x_m * ((x_m * (x_m * (x_m * (x_m * x_m)))) / ((double) M_E)));
}
return tmp;
}
x_m = abs(x) function code(x_m) tmp = 0.0 if (exp(Float64(-1.0 + Float64(x_m * x_m))) <= 0.5) tmp = Float64(fma(x_m, fma(x_m, Float64(Float64(x_m * x_m) * 0.5), x_m), 1.0) / exp(1)); else tmp = Float64(0.16666666666666666 * Float64(x_m * Float64(Float64(x_m * Float64(x_m * Float64(x_m * Float64(x_m * x_m)))) / exp(1)))); end return tmp end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_] := If[LessEqual[N[Exp[N[(-1.0 + N[(x$95$m * x$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 0.5], N[(N[(x$95$m * N[(x$95$m * N[(N[(x$95$m * x$95$m), $MachinePrecision] * 0.5), $MachinePrecision] + x$95$m), $MachinePrecision] + 1.0), $MachinePrecision] / E), $MachinePrecision], N[(0.16666666666666666 * N[(x$95$m * N[(N[(x$95$m * N[(x$95$m * N[(x$95$m * N[(x$95$m * x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / E), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;e^{-1 + x\_m \cdot x\_m} \leq 0.5:\\
\;\;\;\;\frac{\mathsf{fma}\left(x\_m, \mathsf{fma}\left(x\_m, \left(x\_m \cdot x\_m\right) \cdot 0.5, x\_m\right), 1\right)}{e}\\
\mathbf{else}:\\
\;\;\;\;0.16666666666666666 \cdot \left(x\_m \cdot \frac{x\_m \cdot \left(x\_m \cdot \left(x\_m \cdot \left(x\_m \cdot x\_m\right)\right)\right)}{e}\right)\\
\end{array}
\end{array}
if (exp.f64 (neg.f64 (-.f64 #s(literal 1 binary64) (*.f64 x x)))) < 0.5Initial 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
Applied rewrites99.4%
Applied rewrites99.4%
if 0.5 < (exp.f64 (neg.f64 (-.f64 #s(literal 1 binary64) (*.f64 x x)))) Initial program 99.9%
Applied rewrites59.4%
Taylor expanded in x around 0
Applied rewrites81.7%
Applied rewrites41.1%
Taylor expanded in x around inf
Applied rewrites81.7%
Final simplification89.5%
x_m = (fabs.f64 x) (FPCore (x_m) :precision binary64 (exp (fma x_m x_m -1.0)))
x_m = fabs(x);
double code(double x_m) {
return exp(fma(x_m, x_m, -1.0));
}
x_m = abs(x) function code(x_m) return exp(fma(x_m, x_m, -1.0)) end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_] := N[Exp[N[(x$95$m * x$95$m + -1.0), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
e^{\mathsf{fma}\left(x\_m, x\_m, -1\right)}
\end{array}
Initial program 99.9%
lift-neg.f64N/A
neg-sub0N/A
lift--.f64N/A
associate--r-N/A
metadata-evalN/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6499.9
Applied rewrites99.9%
x_m = (fabs.f64 x) (FPCore (x_m) :precision binary64 (pow E (+ x_m -1.0)))
x_m = fabs(x);
double code(double x_m) {
return pow(((double) M_E), (x_m + -1.0));
}
x_m = Math.abs(x);
public static double code(double x_m) {
return Math.pow(Math.E, (x_m + -1.0));
}
x_m = math.fabs(x) def code(x_m): return math.pow(math.e, (x_m + -1.0))
x_m = abs(x) function code(x_m) return exp(1) ^ Float64(x_m + -1.0) end
x_m = abs(x); function tmp = code(x_m) tmp = 2.71828182845904523536 ^ (x_m + -1.0); end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_] := N[Power[E, N[(x$95$m + -1.0), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
{e}^{\left(x\_m + -1\right)}
\end{array}
Initial program 99.9%
lift-neg.f64N/A
neg-sub0N/A
lift--.f64N/A
associate--r-N/A
metadata-evalN/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6499.9
Applied rewrites99.9%
lift-exp.f64N/A
lift-fma.f64N/A
difference-of-sqr--1N/A
exp-prodN/A
lower-pow.f64N/A
lower-exp.f64N/A
lower-+.f64N/A
sub-negN/A
metadata-evalN/A
lower-+.f64100.0
Applied rewrites100.0%
Taylor expanded in x around 0
exp-1-eN/A
lower-E.f6467.8
Applied rewrites67.8%
x_m = (fabs.f64 x)
(FPCore (x_m)
:precision binary64
(let* ((t_0 (fma x_m (* (* x_m x_m) 0.5) x_m)))
(if (<= (* x_m x_m) 2e+151)
(/ (fma (* x_m x_m) (* t_0 t_0) -1.0) (* E (fma x_m t_0 -1.0)))
(* x_m (* 0.5 (* x_m (/ (* x_m x_m) E)))))))x_m = fabs(x);
double code(double x_m) {
double t_0 = fma(x_m, ((x_m * x_m) * 0.5), x_m);
double tmp;
if ((x_m * x_m) <= 2e+151) {
tmp = fma((x_m * x_m), (t_0 * t_0), -1.0) / (((double) M_E) * fma(x_m, t_0, -1.0));
} else {
tmp = x_m * (0.5 * (x_m * ((x_m * x_m) / ((double) M_E))));
}
return tmp;
}
x_m = abs(x) function code(x_m) t_0 = fma(x_m, Float64(Float64(x_m * x_m) * 0.5), x_m) tmp = 0.0 if (Float64(x_m * x_m) <= 2e+151) tmp = Float64(fma(Float64(x_m * x_m), Float64(t_0 * t_0), -1.0) / Float64(exp(1) * fma(x_m, t_0, -1.0))); else tmp = Float64(x_m * Float64(0.5 * Float64(x_m * Float64(Float64(x_m * x_m) / exp(1))))); end return tmp end
x_m = N[Abs[x], $MachinePrecision]
code[x$95$m_] := Block[{t$95$0 = N[(x$95$m * N[(N[(x$95$m * x$95$m), $MachinePrecision] * 0.5), $MachinePrecision] + x$95$m), $MachinePrecision]}, If[LessEqual[N[(x$95$m * x$95$m), $MachinePrecision], 2e+151], N[(N[(N[(x$95$m * x$95$m), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision] + -1.0), $MachinePrecision] / N[(E * N[(x$95$m * t$95$0 + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$95$m * N[(0.5 * N[(x$95$m * N[(N[(x$95$m * x$95$m), $MachinePrecision] / E), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(x\_m, \left(x\_m \cdot x\_m\right) \cdot 0.5, x\_m\right)\\
\mathbf{if}\;x\_m \cdot x\_m \leq 2 \cdot 10^{+151}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x\_m \cdot x\_m, t\_0 \cdot t\_0, -1\right)}{e \cdot \mathsf{fma}\left(x\_m, t\_0, -1\right)}\\
\mathbf{else}:\\
\;\;\;\;x\_m \cdot \left(0.5 \cdot \left(x\_m \cdot \frac{x\_m \cdot x\_m}{e}\right)\right)\\
\end{array}
\end{array}
if (*.f64 x x) < 2.00000000000000003e151Initial program 99.9%
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
Applied rewrites76.7%
Applied rewrites88.7%
if 2.00000000000000003e151 < (*.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
Applied rewrites100.0%
Taylor expanded in x around inf
Applied rewrites100.0%
Final simplification93.4%
x_m = (fabs.f64 x) (FPCore (x_m) :precision binary64 (* (/ 1.0 E) (fma x_m (fma (fma x_m (* x_m 0.16666666666666666) 0.5) (* x_m (* x_m x_m)) x_m) 1.0)))
x_m = fabs(x);
double code(double x_m) {
return (1.0 / ((double) M_E)) * fma(x_m, fma(fma(x_m, (x_m * 0.16666666666666666), 0.5), (x_m * (x_m * x_m)), x_m), 1.0);
}
x_m = abs(x) function code(x_m) return Float64(Float64(1.0 / exp(1)) * fma(x_m, fma(fma(x_m, Float64(x_m * 0.16666666666666666), 0.5), Float64(x_m * Float64(x_m * x_m)), x_m), 1.0)) end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_] := N[(N[(1.0 / E), $MachinePrecision] * N[(x$95$m * N[(N[(x$95$m * N[(x$95$m * 0.16666666666666666), $MachinePrecision] + 0.5), $MachinePrecision] * N[(x$95$m * N[(x$95$m * x$95$m), $MachinePrecision]), $MachinePrecision] + x$95$m), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
\frac{1}{e} \cdot \mathsf{fma}\left(x\_m, \mathsf{fma}\left(\mathsf{fma}\left(x\_m, x\_m \cdot 0.16666666666666666, 0.5\right), x\_m \cdot \left(x\_m \cdot x\_m\right), x\_m\right), 1\right)
\end{array}
Initial program 99.9%
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
Applied rewrites89.5%
x_m = (fabs.f64 x) (FPCore (x_m) :precision binary64 (if (<= (- 1.0 (* x_m x_m)) -10.0) (* x_m (* 0.5 (* x_m (/ (* x_m x_m) E)))) (/ 1.0 (/ E (fma x_m x_m 1.0)))))
x_m = fabs(x);
double code(double x_m) {
double tmp;
if ((1.0 - (x_m * x_m)) <= -10.0) {
tmp = x_m * (0.5 * (x_m * ((x_m * x_m) / ((double) M_E))));
} else {
tmp = 1.0 / (((double) M_E) / fma(x_m, x_m, 1.0));
}
return tmp;
}
x_m = abs(x) function code(x_m) tmp = 0.0 if (Float64(1.0 - Float64(x_m * x_m)) <= -10.0) tmp = Float64(x_m * Float64(0.5 * Float64(x_m * Float64(Float64(x_m * x_m) / exp(1))))); else tmp = Float64(1.0 / Float64(exp(1) / fma(x_m, x_m, 1.0))); end return tmp end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_] := If[LessEqual[N[(1.0 - N[(x$95$m * x$95$m), $MachinePrecision]), $MachinePrecision], -10.0], N[(x$95$m * N[(0.5 * N[(x$95$m * N[(N[(x$95$m * x$95$m), $MachinePrecision] / E), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(E / N[(x$95$m * x$95$m + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;1 - x\_m \cdot x\_m \leq -10:\\
\;\;\;\;x\_m \cdot \left(0.5 \cdot \left(x\_m \cdot \frac{x\_m \cdot x\_m}{e}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{e}{\mathsf{fma}\left(x\_m, x\_m, 1\right)}}\\
\end{array}
\end{array}
if (-.f64 #s(literal 1 binary64) (*.f64 x x)) < -10Initial program 99.9%
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
Applied rewrites76.2%
Taylor expanded in x around inf
Applied rewrites76.2%
if -10 < (-.f64 #s(literal 1 binary64) (*.f64 x x)) Initial program 100.0%
Applied rewrites100.0%
Taylor expanded in x around 0
distribute-rgt1-inN/A
+-commutativeN/A
*-commutativeN/A
metadata-evalN/A
rec-expN/A
e-exp-1N/A
associate-*l/N/A
*-lft-identityN/A
lower-/.f64N/A
+-commutativeN/A
unpow2N/A
lower-fma.f64N/A
lower-E.f6499.3
Applied rewrites99.3%
Applied rewrites99.3%
Final simplification86.4%
x_m = (fabs.f64 x) (FPCore (x_m) :precision binary64 (if (<= (* x_m x_m) 0.4) (/ 1.0 (/ E (fma x_m x_m 1.0))) (* (/ (* x_m x_m) E) (fma x_m (* x_m 0.5) 1.0))))
x_m = fabs(x);
double code(double x_m) {
double tmp;
if ((x_m * x_m) <= 0.4) {
tmp = 1.0 / (((double) M_E) / fma(x_m, x_m, 1.0));
} else {
tmp = ((x_m * x_m) / ((double) M_E)) * fma(x_m, (x_m * 0.5), 1.0);
}
return tmp;
}
x_m = abs(x) function code(x_m) tmp = 0.0 if (Float64(x_m * x_m) <= 0.4) tmp = Float64(1.0 / Float64(exp(1) / fma(x_m, x_m, 1.0))); else tmp = Float64(Float64(Float64(x_m * x_m) / exp(1)) * fma(x_m, Float64(x_m * 0.5), 1.0)); end return tmp end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_] := If[LessEqual[N[(x$95$m * x$95$m), $MachinePrecision], 0.4], N[(1.0 / N[(E / N[(x$95$m * x$95$m + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x$95$m * x$95$m), $MachinePrecision] / E), $MachinePrecision] * N[(x$95$m * N[(x$95$m * 0.5), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;x\_m \cdot x\_m \leq 0.4:\\
\;\;\;\;\frac{1}{\frac{e}{\mathsf{fma}\left(x\_m, x\_m, 1\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{x\_m \cdot x\_m}{e} \cdot \mathsf{fma}\left(x\_m, x\_m \cdot 0.5, 1\right)\\
\end{array}
\end{array}
if (*.f64 x x) < 0.40000000000000002Initial program 100.0%
Applied rewrites100.0%
Taylor expanded in x around 0
distribute-rgt1-inN/A
+-commutativeN/A
*-commutativeN/A
metadata-evalN/A
rec-expN/A
e-exp-1N/A
associate-*l/N/A
*-lft-identityN/A
lower-/.f64N/A
+-commutativeN/A
unpow2N/A
lower-fma.f64N/A
lower-E.f6499.3
Applied rewrites99.3%
Applied rewrites99.3%
if 0.40000000000000002 < (*.f64 x x) Initial program 99.9%
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
Applied rewrites76.2%
Applied rewrites76.2%
Taylor expanded in x around inf
Applied rewrites76.2%
Final simplification86.4%
x_m = (fabs.f64 x) (FPCore (x_m) :precision binary64 (/ (fma x_m (fma x_m (* (* x_m x_m) 0.5) x_m) 1.0) E))
x_m = fabs(x);
double code(double x_m) {
return fma(x_m, fma(x_m, ((x_m * x_m) * 0.5), x_m), 1.0) / ((double) M_E);
}
x_m = abs(x) function code(x_m) return Float64(fma(x_m, fma(x_m, Float64(Float64(x_m * x_m) * 0.5), x_m), 1.0) / exp(1)) end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_] := N[(N[(x$95$m * N[(x$95$m * N[(N[(x$95$m * x$95$m), $MachinePrecision] * 0.5), $MachinePrecision] + x$95$m), $MachinePrecision] + 1.0), $MachinePrecision] / E), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
\frac{\mathsf{fma}\left(x\_m, \mathsf{fma}\left(x\_m, \left(x\_m \cdot x\_m\right) \cdot 0.5, x\_m\right), 1\right)}{e}
\end{array}
Initial program 99.9%
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
Applied rewrites86.4%
Applied rewrites86.4%
Final simplification86.4%
x_m = (fabs.f64 x) (FPCore (x_m) :precision binary64 (/ 1.0 (/ E (fma x_m x_m 1.0))))
x_m = fabs(x);
double code(double x_m) {
return 1.0 / (((double) M_E) / fma(x_m, x_m, 1.0));
}
x_m = abs(x) function code(x_m) return Float64(1.0 / Float64(exp(1) / fma(x_m, x_m, 1.0))) end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_] := N[(1.0 / N[(E / N[(x$95$m * x$95$m + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
\frac{1}{\frac{e}{\mathsf{fma}\left(x\_m, x\_m, 1\right)}}
\end{array}
Initial program 99.9%
Applied rewrites77.3%
Taylor expanded in x around 0
distribute-rgt1-inN/A
+-commutativeN/A
*-commutativeN/A
metadata-evalN/A
rec-expN/A
e-exp-1N/A
associate-*l/N/A
*-lft-identityN/A
lower-/.f64N/A
+-commutativeN/A
unpow2N/A
lower-fma.f64N/A
lower-E.f6468.5
Applied rewrites68.5%
Applied rewrites68.5%
x_m = (fabs.f64 x) (FPCore (x_m) :precision binary64 (if (<= (* x_m x_m) 1.0) (/ 1.0 E) (/ (* x_m x_m) E)))
x_m = fabs(x);
double code(double x_m) {
double tmp;
if ((x_m * x_m) <= 1.0) {
tmp = 1.0 / ((double) M_E);
} else {
tmp = (x_m * x_m) / ((double) M_E);
}
return tmp;
}
x_m = Math.abs(x);
public static double code(double x_m) {
double tmp;
if ((x_m * x_m) <= 1.0) {
tmp = 1.0 / Math.E;
} else {
tmp = (x_m * x_m) / Math.E;
}
return tmp;
}
x_m = math.fabs(x) def code(x_m): tmp = 0 if (x_m * x_m) <= 1.0: tmp = 1.0 / math.e else: tmp = (x_m * x_m) / math.e return tmp
x_m = abs(x) function code(x_m) tmp = 0.0 if (Float64(x_m * x_m) <= 1.0) tmp = Float64(1.0 / exp(1)); else tmp = Float64(Float64(x_m * x_m) / exp(1)); end return tmp end
x_m = abs(x); function tmp_2 = code(x_m) tmp = 0.0; if ((x_m * x_m) <= 1.0) tmp = 1.0 / 2.71828182845904523536; else tmp = (x_m * x_m) / 2.71828182845904523536; end tmp_2 = tmp; end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_] := If[LessEqual[N[(x$95$m * x$95$m), $MachinePrecision], 1.0], N[(1.0 / E), $MachinePrecision], N[(N[(x$95$m * x$95$m), $MachinePrecision] / E), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;x\_m \cdot x\_m \leq 1:\\
\;\;\;\;\frac{1}{e}\\
\mathbf{else}:\\
\;\;\;\;\frac{x\_m \cdot x\_m}{e}\\
\end{array}
\end{array}
if (*.f64 x x) < 1Initial 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.6
Applied rewrites98.6%
if 1 < (*.f64 x x) Initial program 99.9%
Applied rewrites59.4%
Taylor expanded in x around 0
distribute-rgt1-inN/A
+-commutativeN/A
*-commutativeN/A
metadata-evalN/A
rec-expN/A
e-exp-1N/A
associate-*l/N/A
*-lft-identityN/A
lower-/.f64N/A
+-commutativeN/A
unpow2N/A
lower-fma.f64N/A
lower-E.f6444.1
Applied rewrites44.1%
Taylor expanded in x around inf
Applied rewrites44.1%
x_m = (fabs.f64 x) (FPCore (x_m) :precision binary64 (/ (fma x_m x_m 1.0) E))
x_m = fabs(x);
double code(double x_m) {
return fma(x_m, x_m, 1.0) / ((double) M_E);
}
x_m = abs(x) function code(x_m) return Float64(fma(x_m, x_m, 1.0) / exp(1)) end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_] := N[(N[(x$95$m * x$95$m + 1.0), $MachinePrecision] / E), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
\frac{\mathsf{fma}\left(x\_m, x\_m, 1\right)}{e}
\end{array}
Initial program 99.9%
Applied rewrites77.3%
Taylor expanded in x around 0
distribute-rgt1-inN/A
+-commutativeN/A
*-commutativeN/A
metadata-evalN/A
rec-expN/A
e-exp-1N/A
associate-*l/N/A
*-lft-identityN/A
lower-/.f64N/A
+-commutativeN/A
unpow2N/A
lower-fma.f64N/A
lower-E.f6468.5
Applied rewrites68.5%
x_m = (fabs.f64 x) (FPCore (x_m) :precision binary64 (/ 1.0 E))
x_m = fabs(x);
double code(double x_m) {
return 1.0 / ((double) M_E);
}
x_m = Math.abs(x);
public static double code(double x_m) {
return 1.0 / Math.E;
}
x_m = math.fabs(x) def code(x_m): return 1.0 / math.e
x_m = abs(x) function code(x_m) return Float64(1.0 / exp(1)) end
x_m = abs(x); function tmp = code(x_m) tmp = 1.0 / 2.71828182845904523536; end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_] := N[(1.0 / E), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
\frac{1}{e}
\end{array}
Initial program 99.9%
Taylor expanded in x around 0
metadata-evalN/A
rec-expN/A
lower-/.f64N/A
exp-1-eN/A
lower-E.f6445.3
Applied rewrites45.3%
herbie shell --seed 2024223
(FPCore (x)
:name "exp neg sub"
:precision binary64
(exp (- (- 1.0 (* x x)))))