
(FPCore (x) :precision binary64 (- (exp x) 1.0))
double code(double x) {
return exp(x) - 1.0;
}
real(8) function code(x)
real(8), intent (in) :: x
code = exp(x) - 1.0d0
end function
public static double code(double x) {
return Math.exp(x) - 1.0;
}
def code(x): return math.exp(x) - 1.0
function code(x) return Float64(exp(x) - 1.0) end
function tmp = code(x) tmp = exp(x) - 1.0; end
code[x_] := N[(N[Exp[x], $MachinePrecision] - 1.0), $MachinePrecision]
\begin{array}{l}
\\
e^{x} - 1
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 1 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 (- (exp x) 1.0))
double code(double x) {
return exp(x) - 1.0;
}
real(8) function code(x)
real(8), intent (in) :: x
code = exp(x) - 1.0d0
end function
public static double code(double x) {
return Math.exp(x) - 1.0;
}
def code(x): return math.exp(x) - 1.0
function code(x) return Float64(exp(x) - 1.0) end
function tmp = code(x) tmp = exp(x) - 1.0; end
code[x_] := N[(N[Exp[x], $MachinePrecision] - 1.0), $MachinePrecision]
\begin{array}{l}
\\
e^{x} - 1
\end{array}
(FPCore (x) :precision binary64 (expm1 x))
double code(double x) {
return expm1(x);
}
public static double code(double x) {
return Math.expm1(x);
}
def code(x): return math.expm1(x)
function code(x) return expm1(x) end
code[x_] := N[(Exp[x] - 1), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{expm1}\left(x\right)
\end{array}
Initial program 39.9%
expm1-def100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x) :precision binary64 (* x (+ (+ 1.0 (/ x 2.0)) (/ (* x x) 6.0))))
double code(double x) {
return x * ((1.0 + (x / 2.0)) + ((x * x) / 6.0));
}
real(8) function code(x)
real(8), intent (in) :: x
code = x * ((1.0d0 + (x / 2.0d0)) + ((x * x) / 6.0d0))
end function
public static double code(double x) {
return x * ((1.0 + (x / 2.0)) + ((x * x) / 6.0));
}
def code(x): return x * ((1.0 + (x / 2.0)) + ((x * x) / 6.0))
function code(x) return Float64(x * Float64(Float64(1.0 + Float64(x / 2.0)) + Float64(Float64(x * x) / 6.0))) end
function tmp = code(x) tmp = x * ((1.0 + (x / 2.0)) + ((x * x) / 6.0)); end
code[x_] := N[(x * N[(N[(1.0 + N[(x / 2.0), $MachinePrecision]), $MachinePrecision] + N[(N[(x * x), $MachinePrecision] / 6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(\left(1 + \frac{x}{2}\right) + \frac{x \cdot x}{6}\right)
\end{array}
herbie shell --seed 2023192
(FPCore (x)
:name "expm1 (example 3.7)"
:precision binary64
:pre (< -0.00017 x)
:herbie-target
(* x (+ (+ 1.0 (/ x 2.0)) (/ (* x x) 6.0)))
(- (exp x) 1.0))