
(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 4 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}
NOTE: x should be positive before calling this function (FPCore (x) :precision binary64 (* (pow (exp x) x) (exp -1.0)))
x = abs(x);
double code(double x) {
return pow(exp(x), x) * exp(-1.0);
}
NOTE: x should be positive before calling this function
real(8) function code(x)
real(8), intent (in) :: x
code = (exp(x) ** x) * exp((-1.0d0))
end function
x = Math.abs(x);
public static double code(double x) {
return Math.pow(Math.exp(x), x) * Math.exp(-1.0);
}
x = abs(x) def code(x): return math.pow(math.exp(x), x) * math.exp(-1.0)
x = abs(x) function code(x) return Float64((exp(x) ^ x) * exp(-1.0)) end
x = abs(x) function tmp = code(x) tmp = (exp(x) ^ x) * exp(-1.0); end
NOTE: x should be positive before calling this function code[x_] := N[(N[Power[N[Exp[x], $MachinePrecision], x], $MachinePrecision] * N[Exp[-1.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x = |x|\\
\\
{\left(e^{x}\right)}^{x} \cdot e^{-1}
\end{array}
Initial program 100.0%
neg-sub0100.0%
sqr-neg100.0%
associate--r-100.0%
metadata-eval100.0%
+-commutative100.0%
sqr-neg100.0%
Simplified100.0%
exp-sum99.9%
exp-prod100.0%
Applied egg-rr100.0%
Final simplification100.0%
NOTE: x should be positive before calling this function (FPCore (x) :precision binary64 (pow (exp (+ x 1.0)) (+ x -1.0)))
x = abs(x);
double code(double x) {
return pow(exp((x + 1.0)), (x + -1.0));
}
NOTE: x should be positive before calling this function
real(8) function code(x)
real(8), intent (in) :: x
code = exp((x + 1.0d0)) ** (x + (-1.0d0))
end function
x = Math.abs(x);
public static double code(double x) {
return Math.pow(Math.exp((x + 1.0)), (x + -1.0));
}
x = abs(x) def code(x): return math.pow(math.exp((x + 1.0)), (x + -1.0))
x = abs(x) function code(x) return exp(Float64(x + 1.0)) ^ Float64(x + -1.0) end
x = abs(x) function tmp = code(x) tmp = exp((x + 1.0)) ^ (x + -1.0); end
NOTE: x should be positive before calling this function code[x_] := N[Power[N[Exp[N[(x + 1.0), $MachinePrecision]], $MachinePrecision], N[(x + -1.0), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
x = |x|\\
\\
{\left(e^{x + 1}\right)}^{\left(x + -1\right)}
\end{array}
Initial program 100.0%
neg-sub0100.0%
sqr-neg100.0%
associate--r-100.0%
metadata-eval100.0%
+-commutative100.0%
sqr-neg100.0%
Simplified100.0%
difference-of-sqr--199.9%
exp-prod100.0%
sub-neg100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Final simplification100.0%
NOTE: x should be positive before calling this function (FPCore (x) :precision binary64 (exp (+ -1.0 (* x x))))
x = abs(x);
double code(double x) {
return exp((-1.0 + (x * x)));
}
NOTE: x should be positive before calling this function
real(8) function code(x)
real(8), intent (in) :: x
code = exp(((-1.0d0) + (x * x)))
end function
x = Math.abs(x);
public static double code(double x) {
return Math.exp((-1.0 + (x * x)));
}
x = abs(x) def code(x): return math.exp((-1.0 + (x * x)))
x = abs(x) function code(x) return exp(Float64(-1.0 + Float64(x * x))) end
x = abs(x) function tmp = code(x) tmp = exp((-1.0 + (x * x))); end
NOTE: x should be positive before calling this function code[x_] := N[Exp[N[(-1.0 + N[(x * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
x = |x|\\
\\
e^{-1 + x \cdot x}
\end{array}
Initial program 100.0%
neg-sub0100.0%
sqr-neg100.0%
associate--r-100.0%
metadata-eval100.0%
+-commutative100.0%
sqr-neg100.0%
Simplified100.0%
Final simplification100.0%
NOTE: x should be positive before calling this function (FPCore (x) :precision binary64 (exp -1.0))
x = abs(x);
double code(double x) {
return exp(-1.0);
}
NOTE: x should be positive before calling this function
real(8) function code(x)
real(8), intent (in) :: x
code = exp((-1.0d0))
end function
x = Math.abs(x);
public static double code(double x) {
return Math.exp(-1.0);
}
x = abs(x) def code(x): return math.exp(-1.0)
x = abs(x) function code(x) return exp(-1.0) end
x = abs(x) function tmp = code(x) tmp = exp(-1.0); end
NOTE: x should be positive before calling this function code[x_] := N[Exp[-1.0], $MachinePrecision]
\begin{array}{l}
x = |x|\\
\\
e^{-1}
\end{array}
Initial program 100.0%
neg-sub0100.0%
sqr-neg100.0%
associate--r-100.0%
metadata-eval100.0%
+-commutative100.0%
sqr-neg100.0%
Simplified100.0%
Taylor expanded in x around 0 50.4%
Final simplification50.4%
herbie shell --seed 2023275
(FPCore (x)
:name "exp neg sub"
:precision binary64
(exp (- (- 1.0 (* x x)))))