
(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 9 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 (let* ((t_0 (* c (log1p (* (expm1 x) y))))) (if (<= y -5e-23) t_0 (if (<= y 2e-177) (* (* c (expm1 x)) y) t_0))))
double code(double c, double x, double y) {
double t_0 = c * log1p((expm1(x) * y));
double tmp;
if (y <= -5e-23) {
tmp = t_0;
} else if (y <= 2e-177) {
tmp = (c * expm1(x)) * y;
} else {
tmp = t_0;
}
return tmp;
}
public static double code(double c, double x, double y) {
double t_0 = c * Math.log1p((Math.expm1(x) * y));
double tmp;
if (y <= -5e-23) {
tmp = t_0;
} else if (y <= 2e-177) {
tmp = (c * Math.expm1(x)) * y;
} else {
tmp = t_0;
}
return tmp;
}
def code(c, x, y): t_0 = c * math.log1p((math.expm1(x) * y)) tmp = 0 if y <= -5e-23: tmp = t_0 elif y <= 2e-177: tmp = (c * math.expm1(x)) * y else: tmp = t_0 return tmp
function code(c, x, y) t_0 = Float64(c * log1p(Float64(expm1(x) * y))) tmp = 0.0 if (y <= -5e-23) tmp = t_0; elseif (y <= 2e-177) tmp = Float64(Float64(c * expm1(x)) * y); else tmp = t_0; end return tmp end
code[c_, x_, y_] := Block[{t$95$0 = N[(c * N[Log[1 + N[(N[(Exp[x] - 1), $MachinePrecision] * y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -5e-23], t$95$0, If[LessEqual[y, 2e-177], N[(N[(c * N[(Exp[x] - 1), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := c \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(x\right) \cdot y\right)\\
\mathbf{if}\;y \leq -5 \cdot 10^{-23}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 2 \cdot 10^{-177}:\\
\;\;\;\;\left(c \cdot \mathsf{expm1}\left(x\right)\right) \cdot y\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -5.0000000000000002e-23 or 1.9999999999999999e-177 < y Initial program 33.7%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6433.7
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6440.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6440.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.7
Applied rewrites99.7%
if -5.0000000000000002e-23 < y < 1.9999999999999999e-177Initial program 52.7%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6452.7
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6475.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6475.4
lift--.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lift-E.f64N/A
log-EN/A
*-lft-identityN/A
lower-expm1.f6488.8
Applied rewrites88.8%
Taylor expanded in y around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-expm1.f6499.9
Applied rewrites99.9%
Final simplification99.8%
(FPCore (c x y)
:precision binary64
(if (<= y -13.6)
(* (log1p (/ (* (* 3.0 y) x) 3.0)) c)
(if (<= y 5.4e+17)
(* (* 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 <= -13.6) {
tmp = log1p((((3.0 * y) * x) / 3.0)) * c;
} else if (y <= 5.4e+17) {
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 <= -13.6) tmp = Float64(log1p(Float64(Float64(Float64(3.0 * y) * x) / 3.0)) * c); elseif (y <= 5.4e+17) 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, -13.6], N[(N[Log[1 + N[(N[(N[(3.0 * y), $MachinePrecision] * x), $MachinePrecision] / 3.0), $MachinePrecision]], $MachinePrecision] * c), $MachinePrecision], If[LessEqual[y, 5.4e+17], 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 -13.6:\\
\;\;\;\;\mathsf{log1p}\left(\frac{\left(3 \cdot y\right) \cdot x}{3}\right) \cdot c\\
\mathbf{elif}\;y \leq 5.4 \cdot 10^{+17}:\\
\;\;\;\;\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 < -13.5999999999999996Initial program 43.3%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6443.3
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6443.3
lift-*.f64N/A
*-commutativeN/A
lower-*.f6443.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.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 rewrites74.8%
Taylor expanded in x around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6467.6
Applied rewrites67.6%
if -13.5999999999999996 < y < 5.4e17Initial program 47.1%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6447.1
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6469.3
lift-*.f64N/A
*-commutativeN/A
lower-*.f6469.3
lift--.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lift-E.f64N/A
log-EN/A
*-lft-identityN/A
lower-expm1.f6493.1
Applied rewrites93.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%
if 5.4e17 < y Initial program 13.3%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6413.3
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6413.3
lift-*.f64N/A
*-commutativeN/A
lower-*.f6413.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.6
Applied rewrites99.6%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6499.6
Applied rewrites99.6%
Final simplification91.1%
(FPCore (c x y) :precision binary64 (let* ((t_0 (* (log1p (* (* (fma 0.5 x 1.0) x) y)) c))) (if (<= y -560000000.0) t_0 (if (<= y 5.4e+17) (* (* c (expm1 x)) y) t_0))))
double code(double c, double x, double y) {
double t_0 = log1p(((fma(0.5, x, 1.0) * x) * y)) * c;
double tmp;
if (y <= -560000000.0) {
tmp = t_0;
} else if (y <= 5.4e+17) {
tmp = (c * expm1(x)) * y;
} else {
tmp = t_0;
}
return tmp;
}
function code(c, x, y) t_0 = Float64(log1p(Float64(Float64(fma(0.5, x, 1.0) * x) * y)) * c) tmp = 0.0 if (y <= -560000000.0) tmp = t_0; elseif (y <= 5.4e+17) 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[(N[(N[(0.5 * x + 1.0), $MachinePrecision] * x), $MachinePrecision] * y), $MachinePrecision]], $MachinePrecision] * c), $MachinePrecision]}, If[LessEqual[y, -560000000.0], t$95$0, If[LessEqual[y, 5.4e+17], 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(\left(\mathsf{fma}\left(0.5, x, 1\right) \cdot x\right) \cdot y\right) \cdot c\\
\mathbf{if}\;y \leq -560000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 5.4 \cdot 10^{+17}:\\
\;\;\;\;\left(c \cdot \mathsf{expm1}\left(x\right)\right) \cdot y\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -5.6e8 or 5.4e17 < y Initial program 30.3%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6430.3
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6430.3
lift-*.f64N/A
*-commutativeN/A
lower-*.f6430.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.6
Applied rewrites99.6%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6478.4
Applied rewrites78.4%
if -5.6e8 < y < 5.4e17Initial program 47.8%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6447.8
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6469.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6469.7
lift--.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lift-E.f64N/A
log-EN/A
*-lft-identityN/A
lower-expm1.f6493.1
Applied rewrites93.1%
Taylor expanded in y around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-expm1.f6498.7
Applied rewrites98.7%
Final simplification90.1%
(FPCore (c x y)
:precision binary64
(let* ((t_0 (* (log (fma y x 1.0)) c)))
(if (<= y -3.9e+124)
t_0
(if (<= y 5.4e+17)
(* (* c (expm1 x)) y)
(if (<= y 8.8e+254) (* (* (* (fma 0.5 x 1.0) y) x) c) t_0)))))
double code(double c, double x, double y) {
double t_0 = log(fma(y, x, 1.0)) * c;
double tmp;
if (y <= -3.9e+124) {
tmp = t_0;
} else if (y <= 5.4e+17) {
tmp = (c * expm1(x)) * y;
} else if (y <= 8.8e+254) {
tmp = ((fma(0.5, x, 1.0) * y) * x) * c;
} else {
tmp = t_0;
}
return tmp;
}
function code(c, x, y) t_0 = Float64(log(fma(y, x, 1.0)) * c) tmp = 0.0 if (y <= -3.9e+124) tmp = t_0; elseif (y <= 5.4e+17) tmp = Float64(Float64(c * expm1(x)) * y); elseif (y <= 8.8e+254) tmp = Float64(Float64(Float64(fma(0.5, x, 1.0) * y) * x) * c); else tmp = t_0; end return tmp end
code[c_, x_, y_] := Block[{t$95$0 = N[(N[Log[N[(y * x + 1.0), $MachinePrecision]], $MachinePrecision] * c), $MachinePrecision]}, If[LessEqual[y, -3.9e+124], t$95$0, If[LessEqual[y, 5.4e+17], N[(N[(c * N[(Exp[x] - 1), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[y, 8.8e+254], N[(N[(N[(N[(0.5 * x + 1.0), $MachinePrecision] * y), $MachinePrecision] * x), $MachinePrecision] * c), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \log \left(\mathsf{fma}\left(y, x, 1\right)\right) \cdot c\\
\mathbf{if}\;y \leq -3.9 \cdot 10^{+124}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 5.4 \cdot 10^{+17}:\\
\;\;\;\;\left(c \cdot \mathsf{expm1}\left(x\right)\right) \cdot y\\
\mathbf{elif}\;y \leq 8.8 \cdot 10^{+254}:\\
\;\;\;\;\left(\left(\mathsf{fma}\left(0.5, x, 1\right) \cdot y\right) \cdot x\right) \cdot c\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -3.9e124 or 8.8000000000000005e254 < y Initial program 39.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.f6449.3
Applied rewrites49.3%
if -3.9e124 < y < 5.4e17Initial program 46.7%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6446.7
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6466.3
lift-*.f64N/A
*-commutativeN/A
lower-*.f6466.3
lift--.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lift-E.f64N/A
log-EN/A
*-lft-identityN/A
lower-expm1.f6493.8
Applied rewrites93.8%
Taylor expanded in y around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-expm1.f6495.5
Applied rewrites95.5%
if 5.4e17 < y < 8.8000000000000005e254Initial program 14.4%
Taylor expanded in x around 0
*-commutativeN/A
+-commutativeN/A
log-EN/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
*-lft-identityN/A
lower-*.f64N/A
Applied rewrites55.0%
Taylor expanded in y around 0
Applied rewrites81.0%
Final simplification84.0%
(FPCore (c x y)
:precision binary64
(if (<= y -3.3e+31)
(* (* x y) c)
(if (<= y 5.4e+17)
(* (* c (expm1 x)) y)
(* (* (* (fma 0.5 x 1.0) y) x) c))))
double code(double c, double x, double y) {
double tmp;
if (y <= -3.3e+31) {
tmp = (x * y) * c;
} else if (y <= 5.4e+17) {
tmp = (c * expm1(x)) * y;
} else {
tmp = ((fma(0.5, x, 1.0) * y) * x) * c;
}
return tmp;
}
function code(c, x, y) tmp = 0.0 if (y <= -3.3e+31) tmp = Float64(Float64(x * y) * c); elseif (y <= 5.4e+17) tmp = Float64(Float64(c * expm1(x)) * y); else tmp = Float64(Float64(Float64(fma(0.5, x, 1.0) * y) * x) * c); end return tmp end
code[c_, x_, y_] := If[LessEqual[y, -3.3e+31], N[(N[(x * y), $MachinePrecision] * c), $MachinePrecision], If[LessEqual[y, 5.4e+17], N[(N[(c * N[(Exp[x] - 1), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision], N[(N[(N[(N[(0.5 * x + 1.0), $MachinePrecision] * y), $MachinePrecision] * x), $MachinePrecision] * c), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.3 \cdot 10^{+31}:\\
\;\;\;\;\left(x \cdot y\right) \cdot c\\
\mathbf{elif}\;y \leq 5.4 \cdot 10^{+17}:\\
\;\;\;\;\left(c \cdot \mathsf{expm1}\left(x\right)\right) \cdot y\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\mathsf{fma}\left(0.5, x, 1\right) \cdot y\right) \cdot x\right) \cdot c\\
\end{array}
\end{array}
if y < -3.29999999999999992e31Initial program 43.4%
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-*.f6437.8
Applied rewrites37.8%
if -3.29999999999999992e31 < y < 5.4e17Initial program 46.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6446.9
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.f6493.3
Applied rewrites93.3%
Taylor expanded in y around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-expm1.f6498.4
Applied rewrites98.4%
if 5.4e17 < y Initial program 13.3%
Taylor expanded in x around 0
*-commutativeN/A
+-commutativeN/A
log-EN/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
*-lft-identityN/A
lower-*.f64N/A
Applied rewrites48.7%
Taylor expanded in y around 0
Applied rewrites72.3%
Final simplification79.5%
(FPCore (c x y) :precision binary64 (if (<= c 3.9e-13) (* (* 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.9e-13) {
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.9e-13) 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.9e-13], 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.9 \cdot 10^{-13}:\\
\;\;\;\;\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.90000000000000004e-13Initial program 48.2%
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
*-rgt-identityN/A
metadata-evalN/A
log-EN/A
log-EN/A
metadata-evalN/A
log-EN/A
lower-*.f64N/A
log-EN/A
metadata-evalN/A
log-EN/A
log-EN/A
metadata-evalN/A
*-rgt-identityN/A
lower-*.f6466.6
Applied rewrites66.6%
if 3.90000000000000004e-13 < c Initial program 19.0%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6419.0
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6439.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6439.8
lift--.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lift-E.f64N/A
log-EN/A
*-lft-identityN/A
lower-expm1.f6493.4
Applied rewrites93.4%
Taylor expanded in y around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-expm1.f6478.3
Applied rewrites78.3%
Taylor expanded in x around 0
Applied rewrites61.7%
(FPCore (c x y) :precision binary64 (if (<= c 3e-11) (* (* c y) x) (* (* (fma 0.5 (* c x) c) x) y)))
double code(double c, double x, double y) {
double tmp;
if (c <= 3e-11) {
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 <= 3e-11) tmp = Float64(Float64(c * y) * x); else tmp = Float64(Float64(fma(0.5, Float64(c * x), c) * x) * y); end return tmp end
code[c_, x_, y_] := If[LessEqual[c, 3e-11], N[(N[(c * y), $MachinePrecision] * x), $MachinePrecision], N[(N[(N[(0.5 * N[(c * x), $MachinePrecision] + c), $MachinePrecision] * x), $MachinePrecision] * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq 3 \cdot 10^{-11}:\\
\;\;\;\;\left(c \cdot y\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(0.5, c \cdot x, c\right) \cdot x\right) \cdot y\\
\end{array}
\end{array}
if c < 3e-11Initial program 48.2%
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
*-rgt-identityN/A
metadata-evalN/A
log-EN/A
log-EN/A
metadata-evalN/A
log-EN/A
lower-*.f64N/A
log-EN/A
metadata-evalN/A
log-EN/A
log-EN/A
metadata-evalN/A
*-rgt-identityN/A
lower-*.f6466.6
Applied rewrites66.6%
if 3e-11 < c Initial program 19.0%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6419.0
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6439.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6439.8
lift--.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lift-E.f64N/A
log-EN/A
*-lft-identityN/A
lower-expm1.f6493.4
Applied rewrites93.4%
Taylor expanded in y around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-expm1.f6478.3
Applied rewrites78.3%
Taylor expanded in x around 0
Applied rewrites59.7%
(FPCore (c x y) :precision binary64 (if (<= c 1e-23) (* (* c y) x) (* (* c x) y)))
double code(double c, double x, double y) {
double tmp;
if (c <= 1e-23) {
tmp = (c * y) * 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-23) then
tmp = (c * y) * 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-23) {
tmp = (c * y) * x;
} else {
tmp = (c * x) * y;
}
return tmp;
}
def code(c, x, y): tmp = 0 if c <= 1e-23: tmp = (c * y) * x else: tmp = (c * x) * y return tmp
function code(c, x, y) tmp = 0.0 if (c <= 1e-23) tmp = Float64(Float64(c * y) * 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-23) tmp = (c * y) * x; else tmp = (c * x) * y; end tmp_2 = tmp; end
code[c_, x_, y_] := If[LessEqual[c, 1e-23], N[(N[(c * y), $MachinePrecision] * x), $MachinePrecision], N[(N[(c * x), $MachinePrecision] * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq 10^{-23}:\\
\;\;\;\;\left(c \cdot y\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;\left(c \cdot x\right) \cdot y\\
\end{array}
\end{array}
if c < 9.9999999999999996e-24Initial program 47.6%
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
*-rgt-identityN/A
metadata-evalN/A
log-EN/A
log-EN/A
metadata-evalN/A
log-EN/A
lower-*.f64N/A
log-EN/A
metadata-evalN/A
log-EN/A
log-EN/A
metadata-evalN/A
*-rgt-identityN/A
lower-*.f6466.7
Applied rewrites66.7%
if 9.9999999999999996e-24 < c Initial program 21.2%
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
*-rgt-identityN/A
metadata-evalN/A
log-EN/A
log-EN/A
metadata-evalN/A
log-EN/A
lower-*.f64N/A
log-EN/A
metadata-evalN/A
log-EN/A
log-EN/A
metadata-evalN/A
*-rgt-identityN/A
lower-*.f6447.9
Applied rewrites47.9%
Applied rewrites58.5%
Final simplification64.5%
(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 40.4%
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
*-rgt-identityN/A
metadata-evalN/A
log-EN/A
log-EN/A
metadata-evalN/A
log-EN/A
lower-*.f64N/A
log-EN/A
metadata-evalN/A
log-EN/A
log-EN/A
metadata-evalN/A
*-rgt-identityN/A
lower-*.f6461.6
Applied rewrites61.6%
(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 2024284
(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)))))