
(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 3 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 (pow (exp (+ 2.0 (* 2.0 x))) (* 2.0 (* 0.25 (+ x -1.0)))))
double code(double x) {
return pow(exp((2.0 + (2.0 * x))), (2.0 * (0.25 * (x + -1.0))));
}
real(8) function code(x)
real(8), intent (in) :: x
code = exp((2.0d0 + (2.0d0 * x))) ** (2.0d0 * (0.25d0 * (x + (-1.0d0))))
end function
public static double code(double x) {
return Math.pow(Math.exp((2.0 + (2.0 * x))), (2.0 * (0.25 * (x + -1.0))));
}
def code(x): return math.pow(math.exp((2.0 + (2.0 * x))), (2.0 * (0.25 * (x + -1.0))))
function code(x) return exp(Float64(2.0 + Float64(2.0 * x))) ^ Float64(2.0 * Float64(0.25 * Float64(x + -1.0))) end
function tmp = code(x) tmp = exp((2.0 + (2.0 * x))) ^ (2.0 * (0.25 * (x + -1.0))); end
code[x_] := N[Power[N[Exp[N[(2.0 + N[(2.0 * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(2.0 * N[(0.25 * N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
{\left(e^{2 + 2 \cdot x}\right)}^{\left(2 \cdot \left(0.25 \cdot \left(x + -1\right)\right)\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--1100.0%
exp-prod100.0%
sub-neg100.0%
metadata-eval100.0%
Applied egg-rr100.0%
sqr-pow100.0%
pow-prod-down100.0%
sqr-pow100.0%
pow2100.0%
associate-/l/100.0%
metadata-eval100.0%
pow2100.0%
associate-/l/100.0%
metadata-eval100.0%
Applied egg-rr100.0%
pow-sqr100.0%
unpow2100.0%
prod-exp100.0%
count-2100.0%
+-commutative100.0%
distribute-lft-in100.0%
metadata-eval100.0%
metadata-eval100.0%
associate-/l*100.0%
*-commutative100.0%
associate-/l*100.0%
associate-/r/100.0%
metadata-eval100.0%
+-commutative100.0%
Simplified100.0%
Final simplification100.0%
(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(-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^{-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%
(FPCore (x) :precision binary64 (exp -1.0))
double code(double x) {
return exp(-1.0);
}
real(8) function code(x)
real(8), intent (in) :: x
code = exp((-1.0d0))
end function
public static double code(double x) {
return Math.exp(-1.0);
}
def code(x): return math.exp(-1.0)
function code(x) return exp(-1.0) end
function tmp = code(x) tmp = exp(-1.0); end
code[x_] := N[Exp[-1.0], $MachinePrecision]
\begin{array}{l}
\\
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 52.4%
Final simplification52.4%
herbie shell --seed 2023301
(FPCore (x)
:name "exp neg sub"
:precision binary64
(exp (- (- 1.0 (* x x)))))