
(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 5 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 (* x 2.0))) (* (+ x -1.0) 0.5)))
double code(double x) {
return pow(exp((2.0 + (x * 2.0))), ((x + -1.0) * 0.5));
}
real(8) function code(x)
real(8), intent (in) :: x
code = exp((2.0d0 + (x * 2.0d0))) ** ((x + (-1.0d0)) * 0.5d0)
end function
public static double code(double x) {
return Math.pow(Math.exp((2.0 + (x * 2.0))), ((x + -1.0) * 0.5));
}
def code(x): return math.pow(math.exp((2.0 + (x * 2.0))), ((x + -1.0) * 0.5))
function code(x) return exp(Float64(2.0 + Float64(x * 2.0))) ^ Float64(Float64(x + -1.0) * 0.5) end
function tmp = code(x) tmp = exp((2.0 + (x * 2.0))) ^ ((x + -1.0) * 0.5); end
code[x_] := N[Power[N[Exp[N[(2.0 + N[(x * 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[(x + -1.0), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
{\left(e^{2 + x \cdot 2}\right)}^{\left(\left(x + -1\right) \cdot 0.5\right)}
\end{array}
Initial program 99.9%
neg-sub099.9%
sqr-neg99.9%
associate--r-99.9%
metadata-eval99.9%
+-commutative99.9%
sqr-neg99.9%
Simplified99.9%
exp-sum99.9%
exp-prod100.0%
Applied egg-rr100.0%
add-exp-log99.9%
log-prod99.9%
pow-exp99.9%
add-log-exp99.9%
add-log-exp99.9%
metadata-eval99.9%
sub-neg99.9%
difference-of-sqr-199.9%
sub-neg99.9%
metadata-eval99.9%
pow-exp99.9%
sqr-pow99.9%
pow-sqr99.9%
pow-pow99.9%
div-inv99.9%
metadata-eval99.9%
Applied egg-rr99.9%
add-exp-log100.0%
exp-sum100.0%
unpow-prod-down100.0%
log-prod100.0%
pow-exp100.0%
add-log-exp100.0%
pow-exp100.0%
metadata-eval100.0%
add-log-exp100.0%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (x) :precision binary64 (pow (exp (+ x 1.0)) (+ x -1.0)))
double code(double x) {
return pow(exp((x + 1.0)), (x + -1.0));
}
real(8) function code(x)
real(8), intent (in) :: x
code = exp((x + 1.0d0)) ** (x + (-1.0d0))
end function
public static double code(double x) {
return Math.pow(Math.exp((x + 1.0)), (x + -1.0));
}
def code(x): return math.pow(math.exp((x + 1.0)), (x + -1.0))
function code(x) return exp(Float64(x + 1.0)) ^ Float64(x + -1.0) end
function tmp = code(x) tmp = exp((x + 1.0)) ^ (x + -1.0); end
code[x_] := N[Power[N[Exp[N[(x + 1.0), $MachinePrecision]], $MachinePrecision], N[(x + -1.0), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
{\left(e^{x + 1}\right)}^{\left(x + -1\right)}
\end{array}
Initial program 99.9%
neg-sub099.9%
sqr-neg99.9%
associate--r-99.9%
metadata-eval99.9%
+-commutative99.9%
sqr-neg99.9%
Simplified99.9%
difference-of-sqr--199.9%
exp-prod99.9%
sub-neg99.9%
metadata-eval99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x) :precision binary64 (pow (exp (- -1.0 x)) (- 1.0 x)))
double code(double x) {
return pow(exp((-1.0 - x)), (1.0 - x));
}
real(8) function code(x)
real(8), intent (in) :: x
code = exp(((-1.0d0) - x)) ** (1.0d0 - x)
end function
public static double code(double x) {
return Math.pow(Math.exp((-1.0 - x)), (1.0 - x));
}
def code(x): return math.pow(math.exp((-1.0 - x)), (1.0 - x))
function code(x) return exp(Float64(-1.0 - x)) ^ Float64(1.0 - x) end
function tmp = code(x) tmp = exp((-1.0 - x)) ^ (1.0 - x); end
code[x_] := N[Power[N[Exp[N[(-1.0 - x), $MachinePrecision]], $MachinePrecision], N[(1.0 - x), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
{\left(e^{-1 - x}\right)}^{\left(1 - x\right)}
\end{array}
Initial program 99.9%
neg-sub099.9%
sqr-neg99.9%
associate--r-99.9%
metadata-eval99.9%
+-commutative99.9%
sqr-neg99.9%
Simplified99.9%
exp-sum99.9%
exp-prod100.0%
Applied egg-rr100.0%
add-exp-log99.9%
log-prod99.9%
pow-exp99.9%
add-log-exp99.9%
add-log-exp99.9%
metadata-eval99.9%
sub-neg99.9%
difference-of-sqr-199.9%
sub-neg99.9%
metadata-eval99.9%
pow-exp99.9%
add-sqr-sqrt99.2%
pow299.2%
pow-pow99.2%
Applied egg-rr99.2%
Taylor expanded in x around -inf 99.9%
Simplified99.9%
Final simplification99.9%
(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 99.9%
neg-sub099.9%
sqr-neg99.9%
associate--r-99.9%
metadata-eval99.9%
+-commutative99.9%
sqr-neg99.9%
Simplified99.9%
Final simplification99.9%
(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 99.9%
neg-sub099.9%
sqr-neg99.9%
associate--r-99.9%
metadata-eval99.9%
+-commutative99.9%
sqr-neg99.9%
Simplified99.9%
Taylor expanded in x around 0 49.7%
Final simplification49.7%
herbie shell --seed 2023274
(FPCore (x)
:name "exp neg sub"
:precision binary64
(exp (- (- 1.0 (* x x)))))