
(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 10 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
(if (<= y -5e-17)
(* c (log1p (* (expm1 x) y)))
(if (<= y 2.25e-18)
(* (* c (expm1 x)) y)
(*
(log1p
(*
(*
(fma
(fma (fma 0.041666666666666664 x 0.16666666666666666) x 0.5)
x
1.0)
x)
y))
c))))
double code(double c, double x, double y) {
double tmp;
if (y <= -5e-17) {
tmp = c * log1p((expm1(x) * y));
} else if (y <= 2.25e-18) {
tmp = (c * expm1(x)) * y;
} else {
tmp = log1p(((fma(fma(fma(0.041666666666666664, x, 0.16666666666666666), x, 0.5), x, 1.0) * x) * y)) * c;
}
return tmp;
}
function code(c, x, y) tmp = 0.0 if (y <= -5e-17) tmp = Float64(c * log1p(Float64(expm1(x) * y))); elseif (y <= 2.25e-18) tmp = Float64(Float64(c * expm1(x)) * y); else tmp = Float64(log1p(Float64(Float64(fma(fma(fma(0.041666666666666664, x, 0.16666666666666666), x, 0.5), x, 1.0) * x) * y)) * c); end return tmp end
code[c_, x_, y_] := If[LessEqual[y, -5e-17], N[(c * N[Log[1 + N[(N[(Exp[x] - 1), $MachinePrecision] * y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.25e-18], N[(N[(c * N[(Exp[x] - 1), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision], N[(N[Log[1 + N[(N[(N[(N[(N[(0.041666666666666664 * x + 0.16666666666666666), $MachinePrecision] * x + 0.5), $MachinePrecision] * x + 1.0), $MachinePrecision] * x), $MachinePrecision] * y), $MachinePrecision]], $MachinePrecision] * c), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5 \cdot 10^{-17}:\\
\;\;\;\;c \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(x\right) \cdot y\right)\\
\mathbf{elif}\;y \leq 2.25 \cdot 10^{-18}:\\
\;\;\;\;\left(c \cdot \mathsf{expm1}\left(x\right)\right) \cdot y\\
\mathbf{else}:\\
\;\;\;\;\mathsf{log1p}\left(\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.041666666666666664, x, 0.16666666666666666\right), x, 0.5\right), x, 1\right) \cdot x\right) \cdot y\right) \cdot c\\
\end{array}
\end{array}
if y < -4.9999999999999999e-17Initial program 55.6%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6455.6
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6458.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6458.2
lift--.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lift-E.f64N/A
log-EN/A
*-lft-identityN/A
lower-expm1.f6499.6
Applied rewrites99.6%
if -4.9999999999999999e-17 < y < 2.24999999999999997e-18Initial program 43.6%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6443.6
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6470.5
lift-*.f64N/A
*-commutativeN/A
lower-*.f6470.5
lift--.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lift-E.f64N/A
log-EN/A
*-lft-identityN/A
lower-expm1.f6487.6
Applied rewrites87.6%
Taylor expanded in y around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-expm1.f6499.8
Applied rewrites99.8%
if 2.24999999999999997e-18 < y Initial program 11.7%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites47.1%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6447.1
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6497.8
Applied rewrites97.8%
Final simplification99.4%
(FPCore (c x y)
:precision binary64
(if (<= y -110000000000.0)
(* (log1p (* x y)) c)
(if (<= y 2.25e-18)
(* (* c (expm1 x)) y)
(*
(log1p
(*
(*
(fma
(fma (fma 0.041666666666666664 x 0.16666666666666666) x 0.5)
x
1.0)
x)
y))
c))))
double code(double c, double x, double y) {
double tmp;
if (y <= -110000000000.0) {
tmp = log1p((x * y)) * c;
} else if (y <= 2.25e-18) {
tmp = (c * expm1(x)) * y;
} else {
tmp = log1p(((fma(fma(fma(0.041666666666666664, x, 0.16666666666666666), x, 0.5), x, 1.0) * x) * y)) * c;
}
return tmp;
}
function code(c, x, y) tmp = 0.0 if (y <= -110000000000.0) tmp = Float64(log1p(Float64(x * y)) * c); elseif (y <= 2.25e-18) tmp = Float64(Float64(c * expm1(x)) * y); else tmp = Float64(log1p(Float64(Float64(fma(fma(fma(0.041666666666666664, x, 0.16666666666666666), x, 0.5), x, 1.0) * x) * y)) * c); end return tmp end
code[c_, x_, y_] := If[LessEqual[y, -110000000000.0], N[(N[Log[1 + N[(x * y), $MachinePrecision]], $MachinePrecision] * c), $MachinePrecision], If[LessEqual[y, 2.25e-18], N[(N[(c * N[(Exp[x] - 1), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision], N[(N[Log[1 + N[(N[(N[(N[(N[(0.041666666666666664 * x + 0.16666666666666666), $MachinePrecision] * x + 0.5), $MachinePrecision] * x + 1.0), $MachinePrecision] * x), $MachinePrecision] * y), $MachinePrecision]], $MachinePrecision] * c), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -110000000000:\\
\;\;\;\;\mathsf{log1p}\left(x \cdot y\right) \cdot c\\
\mathbf{elif}\;y \leq 2.25 \cdot 10^{-18}:\\
\;\;\;\;\left(c \cdot \mathsf{expm1}\left(x\right)\right) \cdot y\\
\mathbf{else}:\\
\;\;\;\;\mathsf{log1p}\left(\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.041666666666666664, x, 0.16666666666666666\right), x, 0.5\right), x, 1\right) \cdot x\right) \cdot y\right) \cdot c\\
\end{array}
\end{array}
if y < -1.1e11Initial program 61.4%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites25.7%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6425.7
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6446.1
Applied rewrites46.1%
Taylor expanded in x around 0
Applied rewrites48.5%
Taylor expanded in x around 0
log-EN/A
*-rgt-identity50.5
Applied rewrites50.5%
if -1.1e11 < y < 2.24999999999999997e-18Initial program 41.8%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6441.8
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6468.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6468.2
lift--.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lift-E.f64N/A
log-EN/A
*-lft-identityN/A
lower-expm1.f6488.5
Applied rewrites88.5%
Taylor expanded in y around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-expm1.f6499.7
Applied rewrites99.7%
if 2.24999999999999997e-18 < y Initial program 11.7%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites47.1%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6447.1
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6497.8
Applied rewrites97.8%
Final simplification86.5%
(FPCore (c x y)
:precision binary64
(if (<= y -110000000000.0)
(* (log1p (* x y)) c)
(if (<= y 2.25e-18)
(* (* c (expm1 x)) y)
(*
(log1p (* (* (fma (fma (* 0.041666666666666664 x) x 0.5) x 1.0) x) y))
c))))
double code(double c, double x, double y) {
double tmp;
if (y <= -110000000000.0) {
tmp = log1p((x * y)) * c;
} else if (y <= 2.25e-18) {
tmp = (c * expm1(x)) * y;
} else {
tmp = log1p(((fma(fma((0.041666666666666664 * x), x, 0.5), x, 1.0) * x) * y)) * c;
}
return tmp;
}
function code(c, x, y) tmp = 0.0 if (y <= -110000000000.0) tmp = Float64(log1p(Float64(x * y)) * c); elseif (y <= 2.25e-18) tmp = Float64(Float64(c * expm1(x)) * y); else tmp = Float64(log1p(Float64(Float64(fma(fma(Float64(0.041666666666666664 * x), x, 0.5), x, 1.0) * x) * y)) * c); end return tmp end
code[c_, x_, y_] := If[LessEqual[y, -110000000000.0], N[(N[Log[1 + N[(x * y), $MachinePrecision]], $MachinePrecision] * c), $MachinePrecision], If[LessEqual[y, 2.25e-18], N[(N[(c * N[(Exp[x] - 1), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision], N[(N[Log[1 + N[(N[(N[(N[(N[(0.041666666666666664 * x), $MachinePrecision] * x + 0.5), $MachinePrecision] * x + 1.0), $MachinePrecision] * x), $MachinePrecision] * y), $MachinePrecision]], $MachinePrecision] * c), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -110000000000:\\
\;\;\;\;\mathsf{log1p}\left(x \cdot y\right) \cdot c\\
\mathbf{elif}\;y \leq 2.25 \cdot 10^{-18}:\\
\;\;\;\;\left(c \cdot \mathsf{expm1}\left(x\right)\right) \cdot y\\
\mathbf{else}:\\
\;\;\;\;\mathsf{log1p}\left(\left(\mathsf{fma}\left(\mathsf{fma}\left(0.041666666666666664 \cdot x, x, 0.5\right), x, 1\right) \cdot x\right) \cdot y\right) \cdot c\\
\end{array}
\end{array}
if y < -1.1e11Initial program 61.4%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites25.7%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6425.7
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6446.1
Applied rewrites46.1%
Taylor expanded in x around 0
Applied rewrites48.5%
Taylor expanded in x around 0
log-EN/A
*-rgt-identity50.5
Applied rewrites50.5%
if -1.1e11 < y < 2.24999999999999997e-18Initial program 41.8%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6441.8
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6468.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6468.2
lift--.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lift-E.f64N/A
log-EN/A
*-lft-identityN/A
lower-expm1.f6488.5
Applied rewrites88.5%
Taylor expanded in y around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-expm1.f6499.7
Applied rewrites99.7%
if 2.24999999999999997e-18 < y Initial program 11.7%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites47.1%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6447.1
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6497.8
Applied rewrites97.8%
Taylor expanded in x around inf
Applied rewrites97.8%
Final simplification86.5%
(FPCore (c x y)
:precision binary64
(if (<= y -110000000000.0)
(* (log1p (* x y)) c)
(if (<= y 2.25e-18)
(* (* c (expm1 x)) y)
(* (log1p (* (* (fma (fma 0.16666666666666666 x 0.5) x 1.0) x) y)) c))))
double code(double c, double x, double y) {
double tmp;
if (y <= -110000000000.0) {
tmp = log1p((x * y)) * c;
} else if (y <= 2.25e-18) {
tmp = (c * expm1(x)) * y;
} else {
tmp = log1p(((fma(fma(0.16666666666666666, x, 0.5), x, 1.0) * x) * y)) * c;
}
return tmp;
}
function code(c, x, y) tmp = 0.0 if (y <= -110000000000.0) tmp = Float64(log1p(Float64(x * y)) * c); elseif (y <= 2.25e-18) tmp = Float64(Float64(c * expm1(x)) * y); else tmp = Float64(log1p(Float64(Float64(fma(fma(0.16666666666666666, x, 0.5), x, 1.0) * x) * y)) * c); end return tmp end
code[c_, x_, y_] := If[LessEqual[y, -110000000000.0], N[(N[Log[1 + N[(x * y), $MachinePrecision]], $MachinePrecision] * c), $MachinePrecision], If[LessEqual[y, 2.25e-18], N[(N[(c * N[(Exp[x] - 1), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision], N[(N[Log[1 + N[(N[(N[(N[(0.16666666666666666 * x + 0.5), $MachinePrecision] * x + 1.0), $MachinePrecision] * x), $MachinePrecision] * y), $MachinePrecision]], $MachinePrecision] * c), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -110000000000:\\
\;\;\;\;\mathsf{log1p}\left(x \cdot y\right) \cdot c\\
\mathbf{elif}\;y \leq 2.25 \cdot 10^{-18}:\\
\;\;\;\;\left(c \cdot \mathsf{expm1}\left(x\right)\right) \cdot y\\
\mathbf{else}:\\
\;\;\;\;\mathsf{log1p}\left(\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, x, 0.5\right), x, 1\right) \cdot x\right) \cdot y\right) \cdot c\\
\end{array}
\end{array}
if y < -1.1e11Initial program 61.4%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites25.7%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6425.7
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6446.1
Applied rewrites46.1%
Taylor expanded in x around 0
Applied rewrites48.5%
Taylor expanded in x around 0
log-EN/A
*-rgt-identity50.5
Applied rewrites50.5%
if -1.1e11 < y < 2.24999999999999997e-18Initial program 41.8%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6441.8
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6468.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6468.2
lift--.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lift-E.f64N/A
log-EN/A
*-lft-identityN/A
lower-expm1.f6488.5
Applied rewrites88.5%
Taylor expanded in y around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-expm1.f6499.7
Applied rewrites99.7%
if 2.24999999999999997e-18 < y Initial program 11.7%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6411.7
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6411.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6411.7
lift--.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lift-E.f64N/A
log-EN/A
*-lft-identityN/A
lower-expm1.f6497.5
Applied rewrites97.5%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6497.8
Applied rewrites97.8%
Final simplification86.5%
(FPCore (c x y)
:precision binary64
(if (<= y -110000000000.0)
(* (log1p (* x y)) c)
(if (<= y 2.25e-18)
(* (* c (expm1 x)) y)
(* (log1p (* (* (fma 0.5 x 1.0) x) y)) c))))
double code(double c, double x, double y) {
double tmp;
if (y <= -110000000000.0) {
tmp = log1p((x * y)) * c;
} else if (y <= 2.25e-18) {
tmp = (c * expm1(x)) * y;
} else {
tmp = log1p(((fma(0.5, x, 1.0) * x) * y)) * c;
}
return tmp;
}
function code(c, x, y) tmp = 0.0 if (y <= -110000000000.0) tmp = Float64(log1p(Float64(x * y)) * c); elseif (y <= 2.25e-18) tmp = Float64(Float64(c * expm1(x)) * y); else tmp = Float64(log1p(Float64(Float64(fma(0.5, x, 1.0) * x) * y)) * c); end return tmp end
code[c_, x_, y_] := If[LessEqual[y, -110000000000.0], N[(N[Log[1 + N[(x * y), $MachinePrecision]], $MachinePrecision] * c), $MachinePrecision], If[LessEqual[y, 2.25e-18], N[(N[(c * N[(Exp[x] - 1), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision], N[(N[Log[1 + N[(N[(N[(0.5 * x + 1.0), $MachinePrecision] * x), $MachinePrecision] * y), $MachinePrecision]], $MachinePrecision] * c), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -110000000000:\\
\;\;\;\;\mathsf{log1p}\left(x \cdot y\right) \cdot c\\
\mathbf{elif}\;y \leq 2.25 \cdot 10^{-18}:\\
\;\;\;\;\left(c \cdot \mathsf{expm1}\left(x\right)\right) \cdot y\\
\mathbf{else}:\\
\;\;\;\;\mathsf{log1p}\left(\left(\mathsf{fma}\left(0.5, x, 1\right) \cdot x\right) \cdot y\right) \cdot c\\
\end{array}
\end{array}
if y < -1.1e11Initial program 61.4%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites25.7%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6425.7
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6446.1
Applied rewrites46.1%
Taylor expanded in x around 0
Applied rewrites48.5%
Taylor expanded in x around 0
log-EN/A
*-rgt-identity50.5
Applied rewrites50.5%
if -1.1e11 < y < 2.24999999999999997e-18Initial program 41.8%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6441.8
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6468.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6468.2
lift--.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lift-E.f64N/A
log-EN/A
*-lft-identityN/A
lower-expm1.f6488.5
Applied rewrites88.5%
Taylor expanded in y around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-expm1.f6499.7
Applied rewrites99.7%
if 2.24999999999999997e-18 < y Initial program 11.7%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6411.7
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6411.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6411.7
lift--.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lift-E.f64N/A
log-EN/A
*-lft-identityN/A
lower-expm1.f6497.5
Applied rewrites97.5%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6497.8
Applied rewrites97.8%
Final simplification86.5%
(FPCore (c x y)
:precision binary64
(let* ((t_0 (* (log1p (* x y)) c)))
(if (<= y -110000000000.0)
t_0
(if (<= y 2.25e-18) (* (* c (expm1 x)) y) t_0))))
double code(double c, double x, double y) {
double t_0 = log1p((x * y)) * c;
double tmp;
if (y <= -110000000000.0) {
tmp = t_0;
} else if (y <= 2.25e-18) {
tmp = (c * expm1(x)) * y;
} else {
tmp = t_0;
}
return tmp;
}
public static double code(double c, double x, double y) {
double t_0 = Math.log1p((x * y)) * c;
double tmp;
if (y <= -110000000000.0) {
tmp = t_0;
} else if (y <= 2.25e-18) {
tmp = (c * Math.expm1(x)) * y;
} else {
tmp = t_0;
}
return tmp;
}
def code(c, x, y): t_0 = math.log1p((x * y)) * c tmp = 0 if y <= -110000000000.0: tmp = t_0 elif y <= 2.25e-18: tmp = (c * math.expm1(x)) * y else: tmp = t_0 return tmp
function code(c, x, y) t_0 = Float64(log1p(Float64(x * y)) * c) tmp = 0.0 if (y <= -110000000000.0) tmp = t_0; elseif (y <= 2.25e-18) tmp = Float64(Float64(c * expm1(x)) * y); else tmp = t_0; end return tmp end
code[c_, x_, y_] := Block[{t$95$0 = N[(N[Log[1 + N[(x * y), $MachinePrecision]], $MachinePrecision] * c), $MachinePrecision]}, If[LessEqual[y, -110000000000.0], t$95$0, If[LessEqual[y, 2.25e-18], N[(N[(c * N[(Exp[x] - 1), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{log1p}\left(x \cdot y\right) \cdot c\\
\mathbf{if}\;y \leq -110000000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 2.25 \cdot 10^{-18}:\\
\;\;\;\;\left(c \cdot \mathsf{expm1}\left(x\right)\right) \cdot y\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -1.1e11 or 2.24999999999999997e-18 < y Initial program 41.2%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites34.4%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6434.4
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6467.2
Applied rewrites67.2%
Taylor expanded in x around 0
Applied rewrites68.6%
Taylor expanded in x around 0
log-EN/A
*-rgt-identity69.7
Applied rewrites69.7%
if -1.1e11 < y < 2.24999999999999997e-18Initial program 41.8%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6441.8
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6468.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6468.2
lift--.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lift-E.f64N/A
log-EN/A
*-lft-identityN/A
lower-expm1.f6488.5
Applied rewrites88.5%
Taylor expanded in y around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-expm1.f6499.7
Applied rewrites99.7%
Final simplification86.5%
(FPCore (c x y) :precision binary64 (if (<= y 2.25e-18) (* (* c (expm1 x)) y) (* (* x y) c)))
double code(double c, double x, double y) {
double tmp;
if (y <= 2.25e-18) {
tmp = (c * expm1(x)) * y;
} else {
tmp = (x * y) * c;
}
return tmp;
}
public static double code(double c, double x, double y) {
double tmp;
if (y <= 2.25e-18) {
tmp = (c * Math.expm1(x)) * y;
} else {
tmp = (x * y) * c;
}
return tmp;
}
def code(c, x, y): tmp = 0 if y <= 2.25e-18: tmp = (c * math.expm1(x)) * y else: tmp = (x * y) * c return tmp
function code(c, x, y) tmp = 0.0 if (y <= 2.25e-18) tmp = Float64(Float64(c * expm1(x)) * y); else tmp = Float64(Float64(x * y) * c); end return tmp end
code[c_, x_, y_] := If[LessEqual[y, 2.25e-18], N[(N[(c * N[(Exp[x] - 1), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision], N[(N[(x * y), $MachinePrecision] * c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.25 \cdot 10^{-18}:\\
\;\;\;\;\left(c \cdot \mathsf{expm1}\left(x\right)\right) \cdot y\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot y\right) \cdot c\\
\end{array}
\end{array}
if y < 2.24999999999999997e-18Initial program 48.0%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6448.0
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6466.0
lift-*.f64N/A
*-commutativeN/A
lower-*.f6466.0
lift--.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lift-E.f64N/A
log-EN/A
*-lft-identityN/A
lower-expm1.f6492.0
Applied rewrites92.0%
Taylor expanded in y around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-expm1.f6476.6
Applied rewrites76.6%
if 2.24999999999999997e-18 < y Initial program 11.7%
Taylor expanded in x around 0
log-EN/A
metadata-evalN/A
log-EN/A
associate-*r*N/A
log-EN/A
metadata-evalN/A
*-rgt-identityN/A
*-commutativeN/A
lower-*.f6463.8
Applied rewrites63.8%
Final simplification74.3%
(FPCore (c x y) :precision binary64 (if (<= c 1.02e+135) (* (* c y) x) (* (* (fma (fma (* 0.16666666666666666 c) x (* 0.5 c)) x c) x) y)))
double code(double c, double x, double y) {
double tmp;
if (c <= 1.02e+135) {
tmp = (c * y) * x;
} else {
tmp = (fma(fma((0.16666666666666666 * c), x, (0.5 * c)), x, c) * x) * y;
}
return tmp;
}
function code(c, x, y) tmp = 0.0 if (c <= 1.02e+135) tmp = Float64(Float64(c * y) * x); else tmp = Float64(Float64(fma(fma(Float64(0.16666666666666666 * c), x, Float64(0.5 * c)), x, c) * x) * y); end return tmp end
code[c_, x_, y_] := If[LessEqual[c, 1.02e+135], N[(N[(c * y), $MachinePrecision] * x), $MachinePrecision], N[(N[(N[(N[(N[(0.16666666666666666 * c), $MachinePrecision] * x + N[(0.5 * c), $MachinePrecision]), $MachinePrecision] * x + c), $MachinePrecision] * x), $MachinePrecision] * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq 1.02 \cdot 10^{+135}:\\
\;\;\;\;\left(c \cdot y\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666 \cdot c, x, 0.5 \cdot c\right), x, c\right) \cdot x\right) \cdot y\\
\end{array}
\end{array}
if c < 1.01999999999999993e135Initial program 43.9%
Taylor expanded in x around 0
associate-*r*N/A
log-EN/A
*-commutativeN/A
*-lft-identityN/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
*-lft-identityN/A
*-commutativeN/A
metadata-evalN/A
log-EN/A
log-EN/A
metadata-evalN/A
log-EN/A
lower-*.f64N/A
log-EN/A
*-rgt-identityN/A
lower-*.f6460.8
Applied rewrites60.8%
if 1.01999999999999993e135 < c Initial program 22.9%
Taylor expanded in y around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-pow.f64N/A
lower-E.f6416.4
Applied rewrites16.4%
Taylor expanded in x around 0
Applied rewrites68.0%
(FPCore (c x y) :precision binary64 (if (<= c 6.7e+162) (* (* c y) x) (* (* (fma (* 0.5 c) x c) x) y)))
double code(double c, double x, double y) {
double tmp;
if (c <= 6.7e+162) {
tmp = (c * y) * x;
} else {
tmp = (fma((0.5 * c), x, c) * x) * y;
}
return tmp;
}
function code(c, x, y) tmp = 0.0 if (c <= 6.7e+162) tmp = Float64(Float64(c * y) * x); else tmp = Float64(Float64(fma(Float64(0.5 * c), x, c) * x) * y); end return tmp end
code[c_, x_, y_] := If[LessEqual[c, 6.7e+162], N[(N[(c * y), $MachinePrecision] * x), $MachinePrecision], N[(N[(N[(N[(0.5 * c), $MachinePrecision] * x + c), $MachinePrecision] * x), $MachinePrecision] * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq 6.7 \cdot 10^{+162}:\\
\;\;\;\;\left(c \cdot y\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(0.5 \cdot c, x, c\right) \cdot x\right) \cdot y\\
\end{array}
\end{array}
if c < 6.6999999999999999e162Initial program 44.1%
Taylor expanded in x around 0
associate-*r*N/A
log-EN/A
*-commutativeN/A
*-lft-identityN/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
*-lft-identityN/A
*-commutativeN/A
metadata-evalN/A
log-EN/A
log-EN/A
metadata-evalN/A
log-EN/A
lower-*.f64N/A
log-EN/A
*-rgt-identityN/A
lower-*.f6460.6
Applied rewrites60.6%
if 6.6999999999999999e162 < c Initial program 20.2%
Taylor expanded in y around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-pow.f64N/A
lower-E.f6416.8
Applied rewrites16.8%
Taylor expanded in x around 0
Applied rewrites67.8%
(FPCore (c x y) :precision binary64 (* (* c y) x))
double code(double c, double x, double y) {
return (c * y) * x;
}
real(8) function code(c, x, y)
real(8), intent (in) :: c
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (c * y) * x
end function
public static double code(double c, double x, double y) {
return (c * y) * x;
}
def code(c, x, y): return (c * y) * x
function code(c, x, y) return Float64(Float64(c * y) * x) end
function tmp = code(c, x, y) tmp = (c * y) * x; end
code[c_, x_, y_] := N[(N[(c * y), $MachinePrecision] * x), $MachinePrecision]
\begin{array}{l}
\\
\left(c \cdot y\right) \cdot x
\end{array}
Initial program 41.5%
Taylor expanded in x around 0
associate-*r*N/A
log-EN/A
*-commutativeN/A
*-lft-identityN/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
*-lft-identityN/A
*-commutativeN/A
metadata-evalN/A
log-EN/A
log-EN/A
metadata-evalN/A
log-EN/A
lower-*.f64N/A
log-EN/A
*-rgt-identityN/A
lower-*.f6459.9
Applied rewrites59.9%
(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 2024327
(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)))))