
(FPCore (c x y) :precision binary64 (* c (log (+ 1.0 (* (- (pow (E) x) 1.0) y)))))
\begin{array}{l}
\\
c \cdot \log \left(1 + \left({\mathsf{E}\left(\right)}^{x} - 1\right) \cdot y\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 1 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (c x y) :precision binary64 (* c (log (+ 1.0 (* (- (pow (E) x) 1.0) y)))))
\begin{array}{l}
\\
c \cdot \log \left(1 + \left({\mathsf{E}\left(\right)}^{x} - 1\right) \cdot y\right)
\end{array}
(FPCore (c x y) :precision binary64 (* (log (+ (* y (- (pow (E) x) 1.0)) 1.0)) c))
\begin{array}{l}
\\
\log \left(y \cdot \left({\mathsf{E}\left(\right)}^{x} - 1\right) + 1\right) \cdot c
\end{array}
Initial program 39.7%
Final simplification39.7%
(FPCore (c x y) :precision binary64 (* c (log1p (* (expm1 x) y))))
double code(double c, double x, double y) {
return c * log1p((expm1(x) * y));
}
public static double code(double c, double x, double y) {
return c * Math.log1p((Math.expm1(x) * y));
}
def code(c, x, y): return c * math.log1p((math.expm1(x) * y))
function code(c, x, y) return Float64(c * log1p(Float64(expm1(x) * y))) end
code[c_, x_, y_] := N[(c * N[Log[1 + N[(N[(Exp[x] - 1), $MachinePrecision] * y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
c \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(x\right) \cdot y\right)
\end{array}
herbie shell --seed 2024346
(FPCore (c x y)
:name "Logarithmic Transform"
:precision binary64
:alt
(* c (log1p (* (expm1 x) y)))
(* c (log (+ 1.0 (* (- (pow (E) x) 1.0) y)))))