
(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 (or (<= y -1.6e-7) (not (<= y 2e-43))) (* (log1p (* y (expm1 x))) c) (* (* (expm1 x) c) y)))
double code(double c, double x, double y) {
double tmp;
if ((y <= -1.6e-7) || !(y <= 2e-43)) {
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 <= -1.6e-7) || !(y <= 2e-43)) {
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 <= -1.6e-7) or not (y <= 2e-43): 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 <= -1.6e-7) || !(y <= 2e-43)) 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, -1.6e-7], N[Not[LessEqual[y, 2e-43]], $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 -1.6 \cdot 10^{-7} \lor \neg \left(y \leq 2 \cdot 10^{-43}\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 < -1.6e-7 or 2.00000000000000015e-43 < y Initial program 33.2%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6433.2
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6436.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6436.7
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 -1.6e-7 < y < 2.00000000000000015e-43Initial program 42.3%
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.f6467.2
Applied rewrites67.2%
Applied rewrites99.9%
Final simplification99.8%
(FPCore (c x y)
:precision binary64
(if (<= y -105000.0)
(* (log1p (* y (* (fma (fma 0.16666666666666666 x 0.5) x 1.0) x))) c)
(if (<= y 7.5e-20)
(* (* (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 <= -105000.0) {
tmp = log1p((y * (fma(fma(0.16666666666666666, x, 0.5), x, 1.0) * x))) * c;
} else if (y <= 7.5e-20) {
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 <= -105000.0) tmp = Float64(log1p(Float64(y * Float64(fma(fma(0.16666666666666666, x, 0.5), x, 1.0) * x))) * c); elseif (y <= 7.5e-20) 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, -105000.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, 7.5e-20], 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 -105000:\\
\;\;\;\;\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 7.5 \cdot 10^{-20}:\\
\;\;\;\;\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 < -105000Initial program 44.0%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6444.0
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6444.0
lift-*.f64N/A
*-commutativeN/A
lower-*.f6444.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.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
lower-fma.f6468.9
Applied rewrites68.9%
if -105000 < y < 7.49999999999999981e-20Initial program 41.6%
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.f6466.5
Applied rewrites66.5%
Applied rewrites99.0%
if 7.49999999999999981e-20 < y Initial program 17.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6417.9
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6417.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6417.9
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.f6497.9
Applied rewrites97.9%
Final simplification91.5%
(FPCore (c x y) :precision binary64 (if (or (<= y -105000.0) (not (<= y 7.5e-20))) (* (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 <= -105000.0) || !(y <= 7.5e-20)) {
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 <= -105000.0) || !(y <= 7.5e-20)) 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, -105000.0], N[Not[LessEqual[y, 7.5e-20]], $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 -105000 \lor \neg \left(y \leq 7.5 \cdot 10^{-20}\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 < -105000 or 7.49999999999999981e-20 < y Initial program 33.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6433.5
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6433.5
lift-*.f64N/A
*-commutativeN/A
lower-*.f6433.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.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
lower-fma.f6480.6
Applied rewrites80.6%
if -105000 < y < 7.49999999999999981e-20Initial program 41.6%
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.f6466.5
Applied rewrites66.5%
Applied rewrites99.0%
Final simplification91.5%
(FPCore (c x y) :precision binary64 (if (or (<= y -1.1e+33) (not (<= y 7.5e-20))) (* (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.1e+33) || !(y <= 7.5e-20)) {
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.1e+33) || !(y <= 7.5e-20)) 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.1e+33], N[Not[LessEqual[y, 7.5e-20]], $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.1 \cdot 10^{+33} \lor \neg \left(y \leq 7.5 \cdot 10^{-20}\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.09999999999999997e33 or 7.49999999999999981e-20 < y Initial program 31.6%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6431.6
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6431.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f6431.6
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
lower-fma.f6480.8
Applied rewrites80.8%
if -1.09999999999999997e33 < y < 7.49999999999999981e-20Initial program 42.3%
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.f6464.5
Applied rewrites64.5%
Applied rewrites97.2%
Final simplification91.0%
(FPCore (c x y)
:precision binary64
(if (<= y -17000.0)
(* (log1p (/ (* (* 3.0 x) y) 3.0)) c)
(if (<= y 7.5e-20)
(* (* (expm1 x) c) y)
(* (log1p (* y (* (fma 0.5 x 1.0) x))) c))))
double code(double c, double x, double y) {
double tmp;
if (y <= -17000.0) {
tmp = log1p((((3.0 * x) * y) / 3.0)) * c;
} else if (y <= 7.5e-20) {
tmp = (expm1(x) * c) * y;
} else {
tmp = log1p((y * (fma(0.5, x, 1.0) * x))) * c;
}
return tmp;
}
function code(c, x, y) tmp = 0.0 if (y <= -17000.0) tmp = Float64(log1p(Float64(Float64(Float64(3.0 * x) * y) / 3.0)) * c); elseif (y <= 7.5e-20) tmp = Float64(Float64(expm1(x) * c) * y); else tmp = Float64(log1p(Float64(y * Float64(fma(0.5, x, 1.0) * x))) * c); end return tmp end
code[c_, x_, y_] := If[LessEqual[y, -17000.0], N[(N[Log[1 + N[(N[(N[(3.0 * x), $MachinePrecision] * y), $MachinePrecision] / 3.0), $MachinePrecision]], $MachinePrecision] * c), $MachinePrecision], If[LessEqual[y, 7.5e-20], N[(N[(N[(Exp[x] - 1), $MachinePrecision] * c), $MachinePrecision] * y), $MachinePrecision], N[(N[Log[1 + N[(y * N[(N[(0.5 * x + 1.0), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * c), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -17000:\\
\;\;\;\;\mathsf{log1p}\left(\frac{\left(3 \cdot x\right) \cdot y}{3}\right) \cdot c\\
\mathbf{elif}\;y \leq 7.5 \cdot 10^{-20}:\\
\;\;\;\;\left(\mathsf{expm1}\left(x\right) \cdot c\right) \cdot y\\
\mathbf{else}:\\
\;\;\;\;\mathsf{log1p}\left(y \cdot \left(\mathsf{fma}\left(0.5, x, 1\right) \cdot x\right)\right) \cdot c\\
\end{array}
\end{array}
if y < -17000Initial program 44.0%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6444.0
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6444.0
lift-*.f64N/A
*-commutativeN/A
lower-*.f6444.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.6
Applied rewrites99.6%
lift-*.f64N/A
*-commutativeN/A
lift-expm1.f64N/A
flip3--N/A
associate-*l/N/A
lower-/.f64N/A
lower-*.f64N/A
pow-expN/A
metadata-evalN/A
lower-expm1.f64N/A
lower-*.f64N/A
metadata-evalN/A
*-rgt-identityN/A
+-commutativeN/A
lower-fma.f64N/A
lower-exp.f64N/A
lower-exp.f64N/A
lower-+.f64N/A
lower-exp.f6499.5
Applied rewrites99.5%
Taylor expanded in x around 0
Applied rewrites75.2%
Taylor expanded in x around 0
lower-*.f6468.3
Applied rewrites68.3%
if -17000 < y < 7.49999999999999981e-20Initial program 41.6%
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.f6466.5
Applied rewrites66.5%
Applied rewrites99.0%
if 7.49999999999999981e-20 < y Initial program 17.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6417.9
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6417.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6417.9
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
lower-fma.f6497.9
Applied rewrites97.9%
Final simplification91.4%
(FPCore (c x y) :precision binary64 (if (or (<= y -1.7e+157) (not (<= y 2.45e+198))) (* c (log (fma y x 1.0))) (* (* (expm1 x) c) y)))
double code(double c, double x, double y) {
double tmp;
if ((y <= -1.7e+157) || !(y <= 2.45e+198)) {
tmp = c * log(fma(y, x, 1.0));
} else {
tmp = (expm1(x) * c) * y;
}
return tmp;
}
function code(c, x, y) tmp = 0.0 if ((y <= -1.7e+157) || !(y <= 2.45e+198)) tmp = Float64(c * log(fma(y, x, 1.0))); else tmp = Float64(Float64(expm1(x) * c) * y); end return tmp end
code[c_, x_, y_] := If[Or[LessEqual[y, -1.7e+157], N[Not[LessEqual[y, 2.45e+198]], $MachinePrecision]], N[(c * N[Log[N[(y * x + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[(Exp[x] - 1), $MachinePrecision] * c), $MachinePrecision] * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.7 \cdot 10^{+157} \lor \neg \left(y \leq 2.45 \cdot 10^{+198}\right):\\
\;\;\;\;c \cdot \log \left(\mathsf{fma}\left(y, x, 1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{expm1}\left(x\right) \cdot c\right) \cdot y\\
\end{array}
\end{array}
if y < -1.6999999999999999e157 or 2.44999999999999993e198 < y Initial program 34.2%
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.f6467.9
Applied rewrites67.9%
if -1.6999999999999999e157 < y < 2.44999999999999993e198Initial program 39.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.f6452.9
Applied rewrites52.9%
Applied rewrites89.1%
Final simplification85.1%
(FPCore (c x y) :precision binary64 (if (<= c 500000.0) (* (* (expm1 x) y) c) (* (* (expm1 x) c) y)))
double code(double c, double x, double y) {
double tmp;
if (c <= 500000.0) {
tmp = (expm1(x) * y) * c;
} else {
tmp = (expm1(x) * c) * y;
}
return tmp;
}
public static double code(double c, double x, double y) {
double tmp;
if (c <= 500000.0) {
tmp = (Math.expm1(x) * y) * c;
} else {
tmp = (Math.expm1(x) * c) * y;
}
return tmp;
}
def code(c, x, y): tmp = 0 if c <= 500000.0: tmp = (math.expm1(x) * y) * c else: tmp = (math.expm1(x) * c) * y return tmp
function code(c, x, y) tmp = 0.0 if (c <= 500000.0) tmp = Float64(Float64(expm1(x) * y) * c); else tmp = Float64(Float64(expm1(x) * c) * y); end return tmp end
code[c_, x_, y_] := If[LessEqual[c, 500000.0], N[(N[(N[(Exp[x] - 1), $MachinePrecision] * y), $MachinePrecision] * c), $MachinePrecision], N[(N[(N[(Exp[x] - 1), $MachinePrecision] * c), $MachinePrecision] * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq 500000:\\
\;\;\;\;\left(\mathsf{expm1}\left(x\right) \cdot y\right) \cdot c\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{expm1}\left(x\right) \cdot c\right) \cdot y\\
\end{array}
\end{array}
if c < 5e5Initial program 44.0%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6444.0
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6457.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6457.8
lift--.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lift-E.f64N/A
log-EN/A
*-lft-identityN/A
lower-expm1.f6494.5
Applied rewrites94.5%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-expm1.f6472.9
Applied rewrites72.9%
if 5e5 < c Initial program 14.1%
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.f6429.5
Applied rewrites29.5%
Applied rewrites74.1%
Final simplification73.1%
(FPCore (c x y) :precision binary64 (* (* (expm1 x) c) y))
double code(double c, double x, double y) {
return (expm1(x) * c) * y;
}
public static double code(double c, double x, double y) {
return (Math.expm1(x) * c) * y;
}
def code(c, x, y): return (math.expm1(x) * c) * y
function code(c, x, y) return Float64(Float64(expm1(x) * c) * y) end
code[c_, x_, y_] := N[(N[(N[(Exp[x] - 1), $MachinePrecision] * c), $MachinePrecision] * y), $MachinePrecision]
\begin{array}{l}
\\
\left(\mathsf{expm1}\left(x\right) \cdot c\right) \cdot y
\end{array}
Initial program 38.3%
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.f6444.2
Applied rewrites44.2%
Applied rewrites75.1%
Final simplification75.1%
(FPCore (c x y) :precision binary64 (if (<= c 1e-62) (* (* y c) x) (* (* c x) y)))
double code(double c, double x, double y) {
double tmp;
if (c <= 1e-62) {
tmp = (y * c) * x;
} else {
tmp = (c * x) * 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 <= 1d-62) then
tmp = (y * c) * x
else
tmp = (c * x) * y
end if
code = tmp
end function
public static double code(double c, double x, double y) {
double tmp;
if (c <= 1e-62) {
tmp = (y * c) * x;
} else {
tmp = (c * x) * y;
}
return tmp;
}
def code(c, x, y): tmp = 0 if c <= 1e-62: tmp = (y * c) * x else: tmp = (c * x) * y return tmp
function code(c, x, y) tmp = 0.0 if (c <= 1e-62) tmp = Float64(Float64(y * c) * x); else tmp = Float64(Float64(c * x) * y); end return tmp end
function tmp_2 = code(c, x, y) tmp = 0.0; if (c <= 1e-62) tmp = (y * c) * x; else tmp = (c * x) * y; end tmp_2 = tmp; end
code[c_, x_, y_] := If[LessEqual[c, 1e-62], N[(N[(y * c), $MachinePrecision] * x), $MachinePrecision], N[(N[(c * x), $MachinePrecision] * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq 10^{-62}:\\
\;\;\;\;\left(y \cdot c\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;\left(c \cdot x\right) \cdot y\\
\end{array}
\end{array}
if c < 1e-62Initial program 44.2%
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
*-commutativeN/A
log-EN/A
metadata-evalN/A
log-EN/A
log-EN/A
metadata-evalN/A
*-rgt-identityN/A
lower-*.f6463.2
Applied rewrites63.2%
if 1e-62 < c Initial program 21.5%
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
*-commutativeN/A
log-EN/A
metadata-evalN/A
log-EN/A
log-EN/A
metadata-evalN/A
*-rgt-identityN/A
lower-*.f6450.2
Applied rewrites50.2%
Applied rewrites52.6%
Final simplification60.4%
(FPCore (c x y) :precision binary64 (* (* c x) y))
double code(double c, double x, double y) {
return (c * x) * y;
}
real(8) function code(c, x, y)
real(8), intent (in) :: c
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (c * x) * y
end function
public static double code(double c, double x, double y) {
return (c * x) * y;
}
def code(c, x, y): return (c * x) * y
function code(c, x, y) return Float64(Float64(c * x) * y) end
function tmp = code(c, x, y) tmp = (c * x) * y; end
code[c_, x_, y_] := N[(N[(c * x), $MachinePrecision] * y), $MachinePrecision]
\begin{array}{l}
\\
\left(c \cdot x\right) \cdot y
\end{array}
Initial program 38.3%
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
*-commutativeN/A
log-EN/A
metadata-evalN/A
log-EN/A
log-EN/A
metadata-evalN/A
*-rgt-identityN/A
lower-*.f6459.8
Applied rewrites59.8%
Applied rewrites56.7%
Final simplification56.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 2024339
(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)))))