
(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 11 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 (or (<= y -5e-57) (not (<= y 7e-27))) (* (log1p (* y (expm1 x))) c) (* (* (expm1 x) c) y)))
double code(double c, double x, double y) {
double tmp;
if ((y <= -5e-57) || !(y <= 7e-27)) {
tmp = log1p((y * expm1(x))) * c;
} else {
tmp = (expm1(x) * c) * y;
}
return tmp;
}
public static double code(double c, double x, double y) {
double tmp;
if ((y <= -5e-57) || !(y <= 7e-27)) {
tmp = Math.log1p((y * Math.expm1(x))) * c;
} else {
tmp = (Math.expm1(x) * c) * y;
}
return tmp;
}
def code(c, x, y): tmp = 0 if (y <= -5e-57) or not (y <= 7e-27): tmp = math.log1p((y * math.expm1(x))) * c else: tmp = (math.expm1(x) * c) * y return tmp
function code(c, x, y) tmp = 0.0 if ((y <= -5e-57) || !(y <= 7e-27)) tmp = Float64(log1p(Float64(y * expm1(x))) * c); else tmp = Float64(Float64(expm1(x) * c) * y); end return tmp end
code[c_, x_, y_] := If[Or[LessEqual[y, -5e-57], N[Not[LessEqual[y, 7e-27]], $MachinePrecision]], N[(N[Log[1 + N[(y * N[(Exp[x] - 1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * c), $MachinePrecision], N[(N[(N[(Exp[x] - 1), $MachinePrecision] * c), $MachinePrecision] * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5 \cdot 10^{-57} \lor \neg \left(y \leq 7 \cdot 10^{-27}\right):\\
\;\;\;\;\mathsf{log1p}\left(y \cdot \mathsf{expm1}\left(x\right)\right) \cdot c\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{expm1}\left(x\right) \cdot c\right) \cdot y\\
\end{array}
\end{array}
if y < -5.0000000000000002e-57 or 7.0000000000000003e-27 < y Initial program 34.2%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6434.2
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6437.5
lift-*.f64N/A
*-commutativeN/A
lower-*.f6437.5
lift--.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lift-E.f64N/A
log-EN/A
*-lft-identityN/A
lower-expm1.f6499.7
Applied rewrites99.7%
if -5.0000000000000002e-57 < y < 7.0000000000000003e-27Initial program 46.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6446.9
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6468.5
lift-*.f64N/A
*-commutativeN/A
lower-*.f6468.5
lift--.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lift-E.f64N/A
log-EN/A
*-lft-identityN/A
lower-expm1.f6486.3
Applied rewrites86.3%
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%
Final simplification99.8%
(FPCore (c x y)
:precision binary64
(if (<= y -17000000000.0)
(* (log1p (* y (* (fma (fma 0.16666666666666666 x 0.5) x 1.0) x))) c)
(if (<= y 1.6)
(* (* (expm1 x) c) y)
(*
(log1p
(*
y
(*
(fma
(fma (fma 0.041666666666666664 x 0.16666666666666666) x 0.5)
x
1.0)
x)))
c))))
double code(double c, double x, double y) {
double tmp;
if (y <= -17000000000.0) {
tmp = log1p((y * (fma(fma(0.16666666666666666, x, 0.5), x, 1.0) * x))) * c;
} else if (y <= 1.6) {
tmp = (expm1(x) * c) * y;
} else {
tmp = log1p((y * (fma(fma(fma(0.041666666666666664, x, 0.16666666666666666), x, 0.5), x, 1.0) * x))) * c;
}
return tmp;
}
function code(c, x, y) tmp = 0.0 if (y <= -17000000000.0) tmp = Float64(log1p(Float64(y * Float64(fma(fma(0.16666666666666666, x, 0.5), x, 1.0) * x))) * c); elseif (y <= 1.6) tmp = Float64(Float64(expm1(x) * c) * y); else tmp = Float64(log1p(Float64(y * Float64(fma(fma(fma(0.041666666666666664, x, 0.16666666666666666), x, 0.5), x, 1.0) * x))) * c); end return tmp end
code[c_, x_, y_] := If[LessEqual[y, -17000000000.0], N[(N[Log[1 + N[(y * N[(N[(N[(0.16666666666666666 * x + 0.5), $MachinePrecision] * x + 1.0), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * c), $MachinePrecision], If[LessEqual[y, 1.6], N[(N[(N[(Exp[x] - 1), $MachinePrecision] * c), $MachinePrecision] * y), $MachinePrecision], N[(N[Log[1 + N[(y * N[(N[(N[(N[(0.041666666666666664 * x + 0.16666666666666666), $MachinePrecision] * x + 0.5), $MachinePrecision] * x + 1.0), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * c), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -17000000000:\\
\;\;\;\;\mathsf{log1p}\left(y \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, x, 0.5\right), x, 1\right) \cdot x\right)\right) \cdot c\\
\mathbf{elif}\;y \leq 1.6:\\
\;\;\;\;\left(\mathsf{expm1}\left(x\right) \cdot c\right) \cdot y\\
\mathbf{else}:\\
\;\;\;\;\mathsf{log1p}\left(y \cdot \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)\right) \cdot c\\
\end{array}
\end{array}
if y < -1.7e10Initial program 43.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6443.5
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6443.5
lift-*.f64N/A
*-commutativeN/A
lower-*.f6443.5
lift--.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lift-E.f64N/A
log-EN/A
*-lft-identityN/A
lower-expm1.f6499.7
Applied rewrites99.7%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6466.2
Applied rewrites66.2%
if -1.7e10 < y < 1.6000000000000001Initial program 45.0%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6445.0
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6466.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6466.7
lift--.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lift-E.f64N/A
log-EN/A
*-lft-identityN/A
lower-expm1.f6487.8
Applied rewrites87.8%
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 1.6000000000000001 < y Initial program 23.2%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6423.2
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6423.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6423.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%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6499.6
Applied rewrites99.6%
(FPCore (c x y) :precision binary64 (if (or (<= y -17000000000.0) (not (<= y 1.6))) (* (log1p (* y (* (fma (fma 0.16666666666666666 x 0.5) x 1.0) x))) c) (* (* (expm1 x) c) y)))
double code(double c, double x, double y) {
double tmp;
if ((y <= -17000000000.0) || !(y <= 1.6)) {
tmp = log1p((y * (fma(fma(0.16666666666666666, x, 0.5), x, 1.0) * x))) * c;
} else {
tmp = (expm1(x) * c) * y;
}
return tmp;
}
function code(c, x, y) tmp = 0.0 if ((y <= -17000000000.0) || !(y <= 1.6)) tmp = Float64(log1p(Float64(y * Float64(fma(fma(0.16666666666666666, x, 0.5), x, 1.0) * x))) * c); else tmp = Float64(Float64(expm1(x) * c) * y); end return tmp end
code[c_, x_, y_] := If[Or[LessEqual[y, -17000000000.0], N[Not[LessEqual[y, 1.6]], $MachinePrecision]], N[(N[Log[1 + N[(y * N[(N[(N[(0.16666666666666666 * x + 0.5), $MachinePrecision] * x + 1.0), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * c), $MachinePrecision], N[(N[(N[(Exp[x] - 1), $MachinePrecision] * c), $MachinePrecision] * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -17000000000 \lor \neg \left(y \leq 1.6\right):\\
\;\;\;\;\mathsf{log1p}\left(y \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, x, 0.5\right), x, 1\right) \cdot x\right)\right) \cdot c\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{expm1}\left(x\right) \cdot c\right) \cdot y\\
\end{array}
\end{array}
if y < -1.7e10 or 1.6000000000000001 < y Initial program 35.0%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6435.0
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6435.0
lift-*.f64N/A
*-commutativeN/A
lower-*.f6435.0
lift--.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lift-E.f64N/A
log-EN/A
*-lft-identityN/A
lower-expm1.f6499.7
Applied rewrites99.7%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6480.0
Applied rewrites80.0%
if -1.7e10 < y < 1.6000000000000001Initial program 45.0%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6445.0
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6466.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6466.7
lift--.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lift-E.f64N/A
log-EN/A
*-lft-identityN/A
lower-expm1.f6487.8
Applied rewrites87.8%
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%
Final simplification92.1%
(FPCore (c x y) :precision binary64 (if (or (<= y -1.5e+22) (not (<= y 1.6))) (* (log1p (* y (* (fma 0.5 x 1.0) x))) c) (* (* (expm1 x) c) y)))
double code(double c, double x, double y) {
double tmp;
if ((y <= -1.5e+22) || !(y <= 1.6)) {
tmp = log1p((y * (fma(0.5, x, 1.0) * x))) * c;
} else {
tmp = (expm1(x) * c) * y;
}
return tmp;
}
function code(c, x, y) tmp = 0.0 if ((y <= -1.5e+22) || !(y <= 1.6)) tmp = Float64(log1p(Float64(y * Float64(fma(0.5, x, 1.0) * x))) * c); else tmp = Float64(Float64(expm1(x) * c) * y); end return tmp end
code[c_, x_, y_] := If[Or[LessEqual[y, -1.5e+22], N[Not[LessEqual[y, 1.6]], $MachinePrecision]], N[(N[Log[1 + N[(y * N[(N[(0.5 * x + 1.0), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * c), $MachinePrecision], N[(N[(N[(Exp[x] - 1), $MachinePrecision] * c), $MachinePrecision] * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.5 \cdot 10^{+22} \lor \neg \left(y \leq 1.6\right):\\
\;\;\;\;\mathsf{log1p}\left(y \cdot \left(\mathsf{fma}\left(0.5, x, 1\right) \cdot x\right)\right) \cdot c\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{expm1}\left(x\right) \cdot c\right) \cdot y\\
\end{array}
\end{array}
if y < -1.5e22 or 1.6000000000000001 < y Initial program 35.3%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6435.3
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6435.3
lift-*.f64N/A
*-commutativeN/A
lower-*.f6435.3
lift--.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lift-E.f64N/A
log-EN/A
*-lft-identityN/A
lower-expm1.f6499.7
Applied rewrites99.7%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6478.5
Applied rewrites78.5%
if -1.5e22 < y < 1.6000000000000001Initial program 44.6%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6444.6
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6465.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6465.8
lift--.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lift-E.f64N/A
log-EN/A
*-lft-identityN/A
lower-expm1.f6488.1
Applied rewrites88.1%
Taylor expanded in y around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-expm1.f6499.3
Applied rewrites99.3%
Final simplification91.5%
(FPCore (c x y) :precision binary64 (if (or (<= y -4.5e+111) (not (<= y 1.6e+95))) (* c (log (fma y x 1.0))) (* (* c y) (expm1 x))))
double code(double c, double x, double y) {
double tmp;
if ((y <= -4.5e+111) || !(y <= 1.6e+95)) {
tmp = c * log(fma(y, x, 1.0));
} else {
tmp = (c * y) * expm1(x);
}
return tmp;
}
function code(c, x, y) tmp = 0.0 if ((y <= -4.5e+111) || !(y <= 1.6e+95)) tmp = Float64(c * log(fma(y, x, 1.0))); else tmp = Float64(Float64(c * y) * expm1(x)); end return tmp end
code[c_, x_, y_] := If[Or[LessEqual[y, -4.5e+111], N[Not[LessEqual[y, 1.6e+95]], $MachinePrecision]], N[(c * N[Log[N[(y * x + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(c * y), $MachinePrecision] * N[(Exp[x] - 1), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.5 \cdot 10^{+111} \lor \neg \left(y \leq 1.6 \cdot 10^{+95}\right):\\
\;\;\;\;c \cdot \log \left(\mathsf{fma}\left(y, x, 1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(c \cdot y\right) \cdot \mathsf{expm1}\left(x\right)\\
\end{array}
\end{array}
if y < -4.50000000000000001e111 or 1.6e95 < y Initial program 38.4%
Taylor expanded in x around 0
+-commutativeN/A
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-fma.f6454.1
Applied rewrites54.1%
if -4.50000000000000001e111 < y < 1.6e95Initial program 41.8%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6441.8
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6458.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f6458.6
lift--.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lift-E.f64N/A
log-EN/A
*-lft-identityN/A
lower-expm1.f6490.5
Applied rewrites90.5%
Taylor expanded in y around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-expm1.f6492.1
Applied rewrites92.1%
Applied rewrites94.3%
Final simplification85.8%
(FPCore (c x y) :precision binary64 (if (<= c 1.02e-66) (* (* c y) (expm1 x)) (* (* (expm1 x) c) y)))
double code(double c, double x, double y) {
double tmp;
if (c <= 1.02e-66) {
tmp = (c * y) * expm1(x);
} else {
tmp = (expm1(x) * c) * y;
}
return tmp;
}
public static double code(double c, double x, double y) {
double tmp;
if (c <= 1.02e-66) {
tmp = (c * y) * Math.expm1(x);
} else {
tmp = (Math.expm1(x) * c) * y;
}
return tmp;
}
def code(c, x, y): tmp = 0 if c <= 1.02e-66: tmp = (c * y) * math.expm1(x) else: tmp = (math.expm1(x) * c) * y return tmp
function code(c, x, y) tmp = 0.0 if (c <= 1.02e-66) tmp = Float64(Float64(c * y) * expm1(x)); else tmp = Float64(Float64(expm1(x) * c) * y); end return tmp end
code[c_, x_, y_] := If[LessEqual[c, 1.02e-66], N[(N[(c * y), $MachinePrecision] * N[(Exp[x] - 1), $MachinePrecision]), $MachinePrecision], N[(N[(N[(Exp[x] - 1), $MachinePrecision] * c), $MachinePrecision] * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq 1.02 \cdot 10^{-66}:\\
\;\;\;\;\left(c \cdot y\right) \cdot \mathsf{expm1}\left(x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{expm1}\left(x\right) \cdot c\right) \cdot y\\
\end{array}
\end{array}
if c < 1.01999999999999996e-66Initial program 50.3%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6450.3
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6459.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6459.9
lift--.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lift-E.f64N/A
log-EN/A
*-lft-identityN/A
lower-expm1.f6494.3
Applied rewrites94.3%
Taylor expanded in y around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-expm1.f6476.7
Applied rewrites76.7%
Applied rewrites83.0%
if 1.01999999999999996e-66 < c Initial program 22.3%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6422.3
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6442.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6442.8
lift--.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lift-E.f64N/A
log-EN/A
*-lft-identityN/A
lower-expm1.f6488.7
Applied rewrites88.7%
Taylor expanded in y around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-expm1.f6479.3
Applied rewrites79.3%
(FPCore (c x y) :precision binary64 (* (* c y) (expm1 x)))
double code(double c, double x, double y) {
return (c * y) * expm1(x);
}
public static double code(double c, double x, double y) {
return (c * y) * Math.expm1(x);
}
def code(c, x, y): return (c * y) * math.expm1(x)
function code(c, x, y) return Float64(Float64(c * y) * expm1(x)) end
code[c_, x_, y_] := N[(N[(c * y), $MachinePrecision] * N[(Exp[x] - 1), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(c \cdot y\right) \cdot \mathsf{expm1}\left(x\right)
\end{array}
Initial program 41.1%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6441.1
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6454.3
lift-*.f64N/A
*-commutativeN/A
lower-*.f6454.3
lift--.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lift-E.f64N/A
log-EN/A
*-lft-identityN/A
lower-expm1.f6492.5
Applied rewrites92.5%
Taylor expanded in y around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-expm1.f6477.6
Applied rewrites77.6%
Applied rewrites80.1%
(FPCore (c x y) :precision binary64 (if (<= c 3.5e-54) (* (* 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 <= 3.5e-54) {
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 <= 3.5e-54) tmp = Float64(Float64(c * y) * x); else tmp = Float64(Float64(fma(fma(0.16666666666666666, Float64(c * x), Float64(0.5 * c)), x, c) * x) * y); end return tmp end
code[c_, x_, y_] := If[LessEqual[c, 3.5e-54], N[(N[(c * y), $MachinePrecision] * x), $MachinePrecision], N[(N[(N[(N[(0.16666666666666666 * N[(c * x), $MachinePrecision] + N[(0.5 * c), $MachinePrecision]), $MachinePrecision] * x + c), $MachinePrecision] * x), $MachinePrecision] * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq 3.5 \cdot 10^{-54}:\\
\;\;\;\;\left(c \cdot y\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, c \cdot x, 0.5 \cdot c\right), x, c\right) \cdot x\right) \cdot y\\
\end{array}
\end{array}
if c < 3.49999999999999982e-54Initial program 49.8%
Taylor expanded in x around 0
associate-*r*N/A
log-EN/A
*-rgt-identityN/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
*-rgt-identityN/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-*.f6472.2
Applied rewrites72.2%
if 3.49999999999999982e-54 < c Initial program 22.0%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6422.0
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6441.3
lift-*.f64N/A
*-commutativeN/A
lower-*.f6441.3
lift--.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lift-E.f64N/A
log-EN/A
*-lft-identityN/A
lower-expm1.f6488.1
Applied rewrites88.1%
Taylor expanded in y around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-expm1.f6479.4
Applied rewrites79.4%
Taylor expanded in x around 0
Applied rewrites61.3%
(FPCore (c x y) :precision binary64 (if (<= c 3.5e-54) (* (* c y) x) (* (* (* (fma (fma 0.16666666666666666 x 0.5) x 1.0) x) c) y)))
double code(double c, double x, double y) {
double tmp;
if (c <= 3.5e-54) {
tmp = (c * y) * x;
} else {
tmp = ((fma(fma(0.16666666666666666, x, 0.5), x, 1.0) * x) * c) * y;
}
return tmp;
}
function code(c, x, y) tmp = 0.0 if (c <= 3.5e-54) tmp = Float64(Float64(c * y) * x); else tmp = Float64(Float64(Float64(fma(fma(0.16666666666666666, x, 0.5), x, 1.0) * x) * c) * y); end return tmp end
code[c_, x_, y_] := If[LessEqual[c, 3.5e-54], N[(N[(c * y), $MachinePrecision] * x), $MachinePrecision], N[(N[(N[(N[(N[(0.16666666666666666 * x + 0.5), $MachinePrecision] * x + 1.0), $MachinePrecision] * x), $MachinePrecision] * c), $MachinePrecision] * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq 3.5 \cdot 10^{-54}:\\
\;\;\;\;\left(c \cdot y\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, x, 0.5\right), x, 1\right) \cdot x\right) \cdot c\right) \cdot y\\
\end{array}
\end{array}
if c < 3.49999999999999982e-54Initial program 49.8%
Taylor expanded in x around 0
associate-*r*N/A
log-EN/A
*-rgt-identityN/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
*-rgt-identityN/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-*.f6472.2
Applied rewrites72.2%
if 3.49999999999999982e-54 < c Initial program 22.0%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6422.0
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6441.3
lift-*.f64N/A
*-commutativeN/A
lower-*.f6441.3
lift--.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lift-E.f64N/A
log-EN/A
*-lft-identityN/A
lower-expm1.f6488.1
Applied rewrites88.1%
Taylor expanded in y around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-expm1.f6479.4
Applied rewrites79.4%
Taylor expanded in x around 0
Applied rewrites61.3%
(FPCore (c x y) :precision binary64 (if (<= c 5e+15) (* (* c y) x) (* (* x c) y)))
double code(double c, double x, double y) {
double tmp;
if (c <= 5e+15) {
tmp = (c * y) * x;
} else {
tmp = (x * c) * y;
}
return tmp;
}
real(8) function code(c, x, y)
real(8), intent (in) :: c
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (c <= 5d+15) then
tmp = (c * y) * x
else
tmp = (x * c) * y
end if
code = tmp
end function
public static double code(double c, double x, double y) {
double tmp;
if (c <= 5e+15) {
tmp = (c * y) * x;
} else {
tmp = (x * c) * y;
}
return tmp;
}
def code(c, x, y): tmp = 0 if c <= 5e+15: tmp = (c * y) * x else: tmp = (x * c) * y return tmp
function code(c, x, y) tmp = 0.0 if (c <= 5e+15) tmp = Float64(Float64(c * y) * x); else tmp = Float64(Float64(x * c) * y); end return tmp end
function tmp_2 = code(c, x, y) tmp = 0.0; if (c <= 5e+15) tmp = (c * y) * x; else tmp = (x * c) * y; end tmp_2 = tmp; end
code[c_, x_, y_] := If[LessEqual[c, 5e+15], N[(N[(c * y), $MachinePrecision] * x), $MachinePrecision], N[(N[(x * c), $MachinePrecision] * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq 5 \cdot 10^{+15}:\\
\;\;\;\;\left(c \cdot y\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot c\right) \cdot y\\
\end{array}
\end{array}
if c < 5e15Initial program 48.4%
Taylor expanded in x around 0
associate-*r*N/A
log-EN/A
*-rgt-identityN/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
*-rgt-identityN/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-*.f6471.6
Applied rewrites71.6%
if 5e15 < c Initial program 19.9%
Taylor expanded in x around 0
associate-*r*N/A
log-EN/A
*-rgt-identityN/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
*-rgt-identityN/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-*.f6454.4
Applied rewrites54.4%
Applied rewrites59.2%
(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.1%
Taylor expanded in x around 0
associate-*r*N/A
log-EN/A
*-rgt-identityN/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
*-rgt-identityN/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-*.f6467.2
Applied rewrites67.2%
(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 2024337
(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)))))