
(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 (let* ((t_0 (* c (log1p (* (expm1 x) y))))) (if (<= y -3.15e-15) t_0 (if (<= y 6.3e-84) (* (* 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 <= -3.15e-15) {
tmp = t_0;
} else if (y <= 6.3e-84) {
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 <= -3.15e-15) {
tmp = t_0;
} else if (y <= 6.3e-84) {
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 <= -3.15e-15: tmp = t_0 elif y <= 6.3e-84: 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 <= -3.15e-15) tmp = t_0; elseif (y <= 6.3e-84) 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, -3.15e-15], t$95$0, If[LessEqual[y, 6.3e-84], 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 -3.15 \cdot 10^{-15}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 6.3 \cdot 10^{-84}:\\
\;\;\;\;\left(c \cdot \mathsf{expm1}\left(x\right)\right) \cdot y\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -3.14999999999999991e-15 or 6.3000000000000004e-84 < y Initial program 31.4%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6431.4
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6436.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f6436.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%
if -3.14999999999999991e-15 < y < 6.3000000000000004e-84Initial program 44.2%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6444.2
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6472.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f6472.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.2
Applied rewrites90.2%
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 -9e-7)
(* (log1p (* (* (fma (fma 0.16666666666666666 x 0.5) x 1.0) x) y)) c)
(if (<= y 6.2e-11)
(* (* 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 <= -9e-7) {
tmp = log1p(((fma(fma(0.16666666666666666, x, 0.5), x, 1.0) * x) * y)) * c;
} else if (y <= 6.2e-11) {
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 <= -9e-7) tmp = Float64(log1p(Float64(Float64(fma(fma(0.16666666666666666, x, 0.5), x, 1.0) * x) * y)) * c); elseif (y <= 6.2e-11) 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, -9e-7], 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], If[LessEqual[y, 6.2e-11], 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 -9 \cdot 10^{-7}:\\
\;\;\;\;\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\\
\mathbf{elif}\;y \leq 6.2 \cdot 10^{-11}:\\
\;\;\;\;\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 < -8.99999999999999959e-7Initial program 39.8%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6439.8
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.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.f6472.6
Applied rewrites72.6%
if -8.99999999999999959e-7 < y < 6.20000000000000056e-11Initial program 41.3%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6441.3
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6470.0
lift-*.f64N/A
*-commutativeN/A
lower-*.f6470.0
lift--.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lift-E.f64N/A
log-EN/A
*-lft-identityN/A
lower-expm1.f6491.4
Applied rewrites91.4%
Taylor expanded in y around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-expm1.f6499.6
Applied rewrites99.6%
if 6.20000000000000056e-11 < y Initial program 22.1%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6422.1
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6422.1
lift-*.f64N/A
*-commutativeN/A
lower-*.f6422.1
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
Applied rewrites97.3%
Final simplification92.5%
(FPCore (c x y)
:precision binary64
(let* ((t_0
(*
(log1p (* (* (fma (fma 0.16666666666666666 x 0.5) x 1.0) x) y))
c)))
(if (<= y -9e-7) t_0 (if (<= y 6.2e-11) (* (* c (expm1 x)) y) t_0))))
double code(double c, double x, double y) {
double t_0 = log1p(((fma(fma(0.16666666666666666, x, 0.5), x, 1.0) * x) * y)) * c;
double tmp;
if (y <= -9e-7) {
tmp = t_0;
} else if (y <= 6.2e-11) {
tmp = (c * expm1(x)) * y;
} else {
tmp = t_0;
}
return tmp;
}
function code(c, x, y) t_0 = Float64(log1p(Float64(Float64(fma(fma(0.16666666666666666, x, 0.5), x, 1.0) * x) * y)) * c) tmp = 0.0 if (y <= -9e-7) tmp = t_0; elseif (y <= 6.2e-11) 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[(N[(0.16666666666666666 * x + 0.5), $MachinePrecision] * x + 1.0), $MachinePrecision] * x), $MachinePrecision] * y), $MachinePrecision]], $MachinePrecision] * c), $MachinePrecision]}, If[LessEqual[y, -9e-7], t$95$0, If[LessEqual[y, 6.2e-11], 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(\mathsf{fma}\left(0.16666666666666666, x, 0.5\right), x, 1\right) \cdot x\right) \cdot y\right) \cdot c\\
\mathbf{if}\;y \leq -9 \cdot 10^{-7}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 6.2 \cdot 10^{-11}:\\
\;\;\;\;\left(c \cdot \mathsf{expm1}\left(x\right)\right) \cdot y\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -8.99999999999999959e-7 or 6.20000000000000056e-11 < 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.f6481.3
Applied rewrites81.3%
if -8.99999999999999959e-7 < y < 6.20000000000000056e-11Initial program 41.3%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6441.3
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6470.0
lift-*.f64N/A
*-commutativeN/A
lower-*.f6470.0
lift--.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lift-E.f64N/A
log-EN/A
*-lft-identityN/A
lower-expm1.f6491.4
Applied rewrites91.4%
Taylor expanded in y around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-expm1.f6499.6
Applied rewrites99.6%
Final simplification92.5%
(FPCore (c x y) :precision binary64 (let* ((t_0 (* (log1p (* (* (fma 0.5 x 1.0) x) y)) c))) (if (<= y -9e-7) t_0 (if (<= y 6.2e-11) (* (* 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 <= -9e-7) {
tmp = t_0;
} else if (y <= 6.2e-11) {
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 <= -9e-7) tmp = t_0; elseif (y <= 6.2e-11) 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, -9e-7], t$95$0, If[LessEqual[y, 6.2e-11], 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 -9 \cdot 10^{-7}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 6.2 \cdot 10^{-11}:\\
\;\;\;\;\left(c \cdot \mathsf{expm1}\left(x\right)\right) \cdot y\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -8.99999999999999959e-7 or 6.20000000000000056e-11 < 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
lower-fma.f6479.6
Applied rewrites79.6%
if -8.99999999999999959e-7 < y < 6.20000000000000056e-11Initial program 41.3%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6441.3
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6470.0
lift-*.f64N/A
*-commutativeN/A
lower-*.f6470.0
lift--.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lift-E.f64N/A
log-EN/A
*-lft-identityN/A
lower-expm1.f6491.4
Applied rewrites91.4%
Taylor expanded in y around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-expm1.f6499.6
Applied rewrites99.6%
Final simplification91.9%
(FPCore (c x y) :precision binary64 (let* ((t_0 (* (log (fma y x 1.0)) c))) (if (<= y -4.3e+147) t_0 (if (<= y 1.05e+112) (* (* c (expm1 x)) y) t_0))))
double code(double c, double x, double y) {
double t_0 = log(fma(y, x, 1.0)) * c;
double tmp;
if (y <= -4.3e+147) {
tmp = t_0;
} else if (y <= 1.05e+112) {
tmp = (c * expm1(x)) * y;
} 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 <= -4.3e+147) tmp = t_0; elseif (y <= 1.05e+112) 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[N[(y * x + 1.0), $MachinePrecision]], $MachinePrecision] * c), $MachinePrecision]}, If[LessEqual[y, -4.3e+147], t$95$0, If[LessEqual[y, 1.05e+112], N[(N[(c * N[(Exp[x] - 1), $MachinePrecision]), $MachinePrecision] * y), $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 -4.3 \cdot 10^{+147}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 1.05 \cdot 10^{+112}:\\
\;\;\;\;\left(c \cdot \mathsf{expm1}\left(x\right)\right) \cdot y\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -4.2999999999999999e147 or 1.0499999999999999e112 < y Initial program 35.7%
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.8
Applied rewrites54.8%
if -4.2999999999999999e147 < y < 1.0499999999999999e112Initial program 38.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6438.9
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6461.0
lift-*.f64N/A
*-commutativeN/A
lower-*.f6461.0
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.f6495.0
Applied rewrites95.0%
Final simplification86.9%
(FPCore (c x y) :precision binary64 (if (<= y -9e-7) (* (* x y) c) (* (* c (expm1 x)) y)))
double code(double c, double x, double y) {
double tmp;
if (y <= -9e-7) {
tmp = (x * y) * c;
} else {
tmp = (c * expm1(x)) * y;
}
return tmp;
}
public static double code(double c, double x, double y) {
double tmp;
if (y <= -9e-7) {
tmp = (x * y) * c;
} else {
tmp = (c * Math.expm1(x)) * y;
}
return tmp;
}
def code(c, x, y): tmp = 0 if y <= -9e-7: tmp = (x * y) * c else: tmp = (c * math.expm1(x)) * y return tmp
function code(c, x, y) tmp = 0.0 if (y <= -9e-7) tmp = Float64(Float64(x * y) * c); else tmp = Float64(Float64(c * expm1(x)) * y); end return tmp end
code[c_, x_, y_] := If[LessEqual[y, -9e-7], N[(N[(x * y), $MachinePrecision] * c), $MachinePrecision], N[(N[(c * N[(Exp[x] - 1), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -9 \cdot 10^{-7}:\\
\;\;\;\;\left(x \cdot y\right) \cdot c\\
\mathbf{else}:\\
\;\;\;\;\left(c \cdot \mathsf{expm1}\left(x\right)\right) \cdot y\\
\end{array}
\end{array}
if y < -8.99999999999999959e-7Initial program 39.8%
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-*.f6453.6
Applied rewrites53.6%
if -8.99999999999999959e-7 < y Initial program 37.8%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6437.8
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6461.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6461.2
lift--.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lift-E.f64N/A
log-EN/A
*-lft-identityN/A
lower-expm1.f6492.9
Applied rewrites92.9%
Taylor expanded in y around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-expm1.f6490.5
Applied rewrites90.5%
Final simplification81.3%
(FPCore (c x y) :precision binary64 (if (<= c 0.025) (* (* c y) x) (* (* (fma (fma (* c x) 0.16666666666666666 (* 0.5 c)) x c) x) y)))
double code(double c, double x, double y) {
double tmp;
if (c <= 0.025) {
tmp = (c * y) * x;
} else {
tmp = (fma(fma((c * x), 0.16666666666666666, (0.5 * c)), x, c) * x) * y;
}
return tmp;
}
function code(c, x, y) tmp = 0.0 if (c <= 0.025) tmp = Float64(Float64(c * y) * x); else tmp = Float64(Float64(fma(fma(Float64(c * x), 0.16666666666666666, Float64(0.5 * c)), x, c) * x) * y); end return tmp end
code[c_, x_, y_] := If[LessEqual[c, 0.025], N[(N[(c * y), $MachinePrecision] * x), $MachinePrecision], N[(N[(N[(N[(N[(c * x), $MachinePrecision] * 0.16666666666666666 + N[(0.5 * c), $MachinePrecision]), $MachinePrecision] * x + c), $MachinePrecision] * x), $MachinePrecision] * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq 0.025:\\
\;\;\;\;\left(c \cdot y\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(\mathsf{fma}\left(c \cdot x, 0.16666666666666666, 0.5 \cdot c\right), x, c\right) \cdot x\right) \cdot y\\
\end{array}
\end{array}
if c < 0.025000000000000001Initial 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
*-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.3
Applied rewrites66.3%
if 0.025000000000000001 < c Initial program 19.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6419.9
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6446.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6446.7
lift--.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lift-E.f64N/A
log-EN/A
*-lft-identityN/A
lower-expm1.f6495.0
Applied rewrites95.0%
Taylor expanded in y around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-expm1.f6478.7
Applied rewrites78.7%
Taylor expanded in x around 0
Applied rewrites52.9%
(FPCore (c x y) :precision binary64 (if (<= c 0.025) (* (* 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 <= 0.025) {
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 <= 0.025) 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, 0.025], 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 0.025:\\
\;\;\;\;\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 < 0.025000000000000001Initial 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
*-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.3
Applied rewrites66.3%
if 0.025000000000000001 < c Initial program 19.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6419.9
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6446.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6446.7
lift--.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lift-E.f64N/A
log-EN/A
*-lft-identityN/A
lower-expm1.f6495.0
Applied rewrites95.0%
Taylor expanded in y around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-expm1.f6478.7
Applied rewrites78.7%
Taylor expanded in x around 0
Applied rewrites52.9%
(FPCore (c x y) :precision binary64 (if (<= c 1e+39) (* (* c y) x) (* (* c x) y)))
double code(double c, double x, double y) {
double tmp;
if (c <= 1e+39) {
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+39) 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+39) {
tmp = (c * y) * x;
} else {
tmp = (c * x) * y;
}
return tmp;
}
def code(c, x, y): tmp = 0 if c <= 1e+39: tmp = (c * y) * x else: tmp = (c * x) * y return tmp
function code(c, x, y) tmp = 0.0 if (c <= 1e+39) 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+39) tmp = (c * y) * x; else tmp = (c * x) * y; end tmp_2 = tmp; end
code[c_, x_, y_] := If[LessEqual[c, 1e+39], 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^{+39}:\\
\;\;\;\;\left(c \cdot y\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;\left(c \cdot x\right) \cdot y\\
\end{array}
\end{array}
if c < 9.9999999999999994e38Initial program 42.7%
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-*.f6464.9
Applied rewrites64.9%
if 9.9999999999999994e38 < c Initial program 19.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-*.f6450.8
Applied rewrites50.8%
Applied rewrites55.3%
Final simplification63.0%
(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 38.3%
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-*.f6462.2
Applied rewrites62.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 2024304
(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)))))