
(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 5 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 7.5%
expm1-define100.0%
Simplified100.0%
(FPCore (x) :precision binary64 (* x (+ 1.0 (* x (+ 0.5 (* x (+ 0.16666666666666666 (* x 0.041666666666666664))))))))
double code(double x) {
return x * (1.0 + (x * (0.5 + (x * (0.16666666666666666 + (x * 0.041666666666666664))))));
}
real(8) function code(x)
real(8), intent (in) :: x
code = x * (1.0d0 + (x * (0.5d0 + (x * (0.16666666666666666d0 + (x * 0.041666666666666664d0))))))
end function
public static double code(double x) {
return x * (1.0 + (x * (0.5 + (x * (0.16666666666666666 + (x * 0.041666666666666664))))));
}
def code(x): return x * (1.0 + (x * (0.5 + (x * (0.16666666666666666 + (x * 0.041666666666666664))))))
function code(x) return Float64(x * Float64(1.0 + Float64(x * Float64(0.5 + Float64(x * Float64(0.16666666666666666 + Float64(x * 0.041666666666666664))))))) end
function tmp = code(x) tmp = x * (1.0 + (x * (0.5 + (x * (0.16666666666666666 + (x * 0.041666666666666664)))))); end
code[x_] := N[(x * N[(1.0 + N[(x * N[(0.5 + N[(x * N[(0.16666666666666666 + N[(x * 0.041666666666666664), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(1 + x \cdot \left(0.5 + x \cdot \left(0.16666666666666666 + x \cdot 0.041666666666666664\right)\right)\right)
\end{array}
Initial program 7.5%
expm1-define100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
*-commutative100.0%
Simplified100.0%
(FPCore (x) :precision binary64 (* x (+ 1.0 (* x (+ 0.5 (* x 0.16666666666666666))))))
double code(double x) {
return x * (1.0 + (x * (0.5 + (x * 0.16666666666666666))));
}
real(8) function code(x)
real(8), intent (in) :: x
code = x * (1.0d0 + (x * (0.5d0 + (x * 0.16666666666666666d0))))
end function
public static double code(double x) {
return x * (1.0 + (x * (0.5 + (x * 0.16666666666666666))));
}
def code(x): return x * (1.0 + (x * (0.5 + (x * 0.16666666666666666))))
function code(x) return Float64(x * Float64(1.0 + Float64(x * Float64(0.5 + Float64(x * 0.16666666666666666))))) end
function tmp = code(x) tmp = x * (1.0 + (x * (0.5 + (x * 0.16666666666666666)))); end
code[x_] := N[(x * N[(1.0 + N[(x * N[(0.5 + N[(x * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(1 + x \cdot \left(0.5 + x \cdot 0.16666666666666666\right)\right)
\end{array}
Initial program 7.5%
expm1-define100.0%
Simplified100.0%
Taylor expanded in x around 0 99.9%
*-commutative99.9%
Simplified99.9%
(FPCore (x) :precision binary64 (* x (+ 1.0 (* x 0.5))))
double code(double x) {
return x * (1.0 + (x * 0.5));
}
real(8) function code(x)
real(8), intent (in) :: x
code = x * (1.0d0 + (x * 0.5d0))
end function
public static double code(double x) {
return x * (1.0 + (x * 0.5));
}
def code(x): return x * (1.0 + (x * 0.5))
function code(x) return Float64(x * Float64(1.0 + Float64(x * 0.5))) end
function tmp = code(x) tmp = x * (1.0 + (x * 0.5)); end
code[x_] := N[(x * N[(1.0 + N[(x * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(1 + x \cdot 0.5\right)
\end{array}
Initial program 7.5%
expm1-define100.0%
Simplified100.0%
Taylor expanded in x around 0 99.7%
*-commutative99.7%
Simplified99.7%
(FPCore (x) :precision binary64 x)
double code(double x) {
return x;
}
real(8) function code(x)
real(8), intent (in) :: x
code = x
end function
public static double code(double x) {
return x;
}
def code(x): return x
function code(x) return x end
function tmp = code(x) tmp = x; end
code[x_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 7.5%
expm1-define100.0%
Simplified100.0%
Taylor expanded in x around 0 98.7%
(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}
herbie shell --seed 2024110
(FPCore (x)
:name "expm1 (example 3.7)"
:precision binary64
:pre (<= (fabs x) 1.0)
:alt
(expm1 x)
(- (exp x) 1.0))