
(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 17 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) (+ x_m -1.0)) (pow E (+ x_m -1.0))))
x_m = fabs(x);
double code(double x_m) {
return pow(exp(x_m), (x_m + -1.0)) * pow(((double) M_E), (x_m + -1.0));
}
x_m = Math.abs(x);
public static double code(double x_m) {
return Math.pow(Math.exp(x_m), (x_m + -1.0)) * Math.pow(Math.E, (x_m + -1.0));
}
x_m = math.fabs(x) def code(x_m): return math.pow(math.exp(x_m), (x_m + -1.0)) * math.pow(math.e, (x_m + -1.0))
x_m = abs(x) function code(x_m) return Float64((exp(x_m) ^ Float64(x_m + -1.0)) * (exp(1) ^ Float64(x_m + -1.0))) end
x_m = abs(x); function tmp = code(x_m) tmp = (exp(x_m) ^ (x_m + -1.0)) * (2.71828182845904523536 ^ (x_m + -1.0)); end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_] := N[(N[Power[N[Exp[x$95$m], $MachinePrecision], N[(x$95$m + -1.0), $MachinePrecision]], $MachinePrecision] * N[Power[E, N[(x$95$m + -1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
{\left(e^{x\_m}\right)}^{\left(x\_m + -1\right)} \cdot {e}^{\left(x\_m + -1\right)}
\end{array}
Initial program 100.0%
lift-neg.f64N/A
neg-sub0N/A
lift--.f64N/A
associate--r-N/A
metadata-evalN/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64100.0
Applied rewrites100.0%
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%
lift-pow.f64N/A
lift-exp.f64N/A
lift-+.f64N/A
exp-sumN/A
e-exp-1N/A
*-un-lft-identityN/A
lift-E.f64N/A
associate-*r*N/A
unpow-prod-downN/A
lower-*.f64N/A
lower-pow.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-pow.f64100.0
Applied rewrites100.0%
lift-*.f64N/A
*-rgt-identity100.0
Applied rewrites100.0%
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 100.0%
lift-neg.f64N/A
neg-sub0N/A
lift--.f64N/A
associate--r-N/A
metadata-evalN/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64100.0
Applied rewrites100.0%
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%
herbie shell --seed 2024229
(FPCore (x)
:name "exp neg sub"
:precision binary64
(exp (- (- 1.0 (* x x)))))