
(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 13 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 -7e-59)
t_0
(if (<= y 9e-34)
(* (/ (* (expm1 (* 3.0 x)) c) (fma (exp x) (exp x) (+ (exp x) 1.0))) y)
t_0))))
double code(double c, double x, double y) {
double t_0 = c * log1p((expm1(x) * y));
double tmp;
if (y <= -7e-59) {
tmp = t_0;
} else if (y <= 9e-34) {
tmp = ((expm1((3.0 * x)) * c) / fma(exp(x), exp(x), (exp(x) + 1.0))) * 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 <= -7e-59) tmp = t_0; elseif (y <= 9e-34) tmp = Float64(Float64(Float64(expm1(Float64(3.0 * x)) * c) / fma(exp(x), exp(x), Float64(exp(x) + 1.0))) * 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, -7e-59], t$95$0, If[LessEqual[y, 9e-34], N[(N[(N[(N[(Exp[N[(3.0 * x), $MachinePrecision]] - 1), $MachinePrecision] * c), $MachinePrecision] / N[(N[Exp[x], $MachinePrecision] * N[Exp[x], $MachinePrecision] + N[(N[Exp[x], $MachinePrecision] + 1.0), $MachinePrecision]), $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 -7 \cdot 10^{-59}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 9 \cdot 10^{-34}:\\
\;\;\;\;\frac{\mathsf{expm1}\left(3 \cdot x\right) \cdot c}{\mathsf{fma}\left(e^{x}, e^{x}, e^{x} + 1\right)} \cdot y\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -7.0000000000000002e-59 or 9.00000000000000085e-34 < y Initial program 35.1%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6435.1
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6437.3
lift-*.f64N/A
*-commutativeN/A
lower-*.f6437.3
lift--.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lift-E.f64N/A
log-EN/A
*-lft-identityN/A
lower-expm1.f6498.9
Applied rewrites98.9%
if -7.0000000000000002e-59 < y < 9.00000000000000085e-34Initial program 44.0%
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.1
Applied rewrites67.1%
Applied rewrites67.2%
Applied rewrites99.7%
Final simplification99.3%
(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}
Initial program 39.3%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6439.3
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6451.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6451.4
lift--.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lift-E.f64N/A
log-EN/A
*-lft-identityN/A
lower-expm1.f6493.6
Applied rewrites93.6%
Final simplification93.6%
(FPCore (c x y)
:precision binary64
(if (<= y -0.39)
(* (log1p (/ y (/ (fma -0.5 x 1.0) x))) c)
(if (<= y 1.28e+41)
(* (* (expm1 x) y) c)
(*
(log1p
(/
y
(/
(fma
(fma (fma -0.001388888888888889 (* x x) 0.08333333333333333) x -0.5)
x
1.0)
x)))
c))))
double code(double c, double x, double y) {
double tmp;
if (y <= -0.39) {
tmp = log1p((y / (fma(-0.5, x, 1.0) / x))) * c;
} else if (y <= 1.28e+41) {
tmp = (expm1(x) * y) * c;
} else {
tmp = log1p((y / (fma(fma(fma(-0.001388888888888889, (x * x), 0.08333333333333333), x, -0.5), x, 1.0) / x))) * c;
}
return tmp;
}
function code(c, x, y) tmp = 0.0 if (y <= -0.39) tmp = Float64(log1p(Float64(y / Float64(fma(-0.5, x, 1.0) / x))) * c); elseif (y <= 1.28e+41) tmp = Float64(Float64(expm1(x) * y) * c); else tmp = Float64(log1p(Float64(y / Float64(fma(fma(fma(-0.001388888888888889, Float64(x * x), 0.08333333333333333), x, -0.5), x, 1.0) / x))) * c); end return tmp end
code[c_, x_, y_] := If[LessEqual[y, -0.39], N[(N[Log[1 + N[(y / N[(N[(-0.5 * x + 1.0), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * c), $MachinePrecision], If[LessEqual[y, 1.28e+41], N[(N[(N[(Exp[x] - 1), $MachinePrecision] * y), $MachinePrecision] * c), $MachinePrecision], N[(N[Log[1 + N[(y / N[(N[(N[(N[(-0.001388888888888889 * N[(x * x), $MachinePrecision] + 0.08333333333333333), $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 -0.39:\\
\;\;\;\;\mathsf{log1p}\left(\frac{y}{\frac{\mathsf{fma}\left(-0.5, x, 1\right)}{x}}\right) \cdot c\\
\mathbf{elif}\;y \leq 1.28 \cdot 10^{+41}:\\
\;\;\;\;\left(\mathsf{expm1}\left(x\right) \cdot y\right) \cdot c\\
\mathbf{else}:\\
\;\;\;\;\mathsf{log1p}\left(\frac{y}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.001388888888888889, x \cdot x, 0.08333333333333333\right), x, -0.5\right), x, 1\right)}{x}}\right) \cdot c\\
\end{array}
\end{array}
if y < -0.39000000000000001Initial program 55.0%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6455.0
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6455.0
lift-*.f64N/A
*-commutativeN/A
lower-*.f6455.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-expm1.f64N/A
flip--N/A
clear-numN/A
lower-/.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
pow2N/A
pow-expN/A
metadata-evalN/A
lower-expm1.f64N/A
lower-*.f6499.5
Applied rewrites99.5%
Taylor expanded in x around 0
lower-/.f64N/A
+-commutativeN/A
lower-fma.f6470.4
Applied rewrites70.4%
lift-*.f64N/A
lift-/.f64N/A
un-div-invN/A
lower-/.f6470.4
Applied rewrites70.4%
if -0.39000000000000001 < y < 1.27999999999999992e41Initial program 41.2%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6441.2
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6462.0
lift-*.f64N/A
*-commutativeN/A
lower-*.f6462.0
lift--.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lift-E.f64N/A
log-EN/A
*-lft-identityN/A
lower-expm1.f6489.3
Applied rewrites89.3%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-expm1.f6488.8
Applied rewrites88.8%
if 1.27999999999999992e41 < y Initial program 12.2%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6412.2
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6412.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6412.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%
lift-expm1.f64N/A
flip--N/A
clear-numN/A
lower-/.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
pow2N/A
pow-expN/A
metadata-evalN/A
lower-expm1.f64N/A
lower-*.f6499.5
Applied rewrites99.5%
Taylor expanded in x around 0
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sub-negN/A
*-commutativeN/A
metadata-evalN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6499.5
Applied rewrites99.5%
lift-*.f64N/A
lift-/.f64N/A
un-div-invN/A
lower-/.f6499.6
Applied rewrites99.6%
(FPCore (c x y)
:precision binary64
(if (<= y -0.39)
(* (log1p (/ y (/ (fma -0.5 x 1.0) x))) c)
(if (<= y 5.0)
(* (* (expm1 x) y) c)
(*
(log1p (* (/ 1.0 (/ (fma (fma 0.08333333333333333 x -0.5) x 1.0) x)) y))
c))))
double code(double c, double x, double y) {
double tmp;
if (y <= -0.39) {
tmp = log1p((y / (fma(-0.5, x, 1.0) / x))) * c;
} else if (y <= 5.0) {
tmp = (expm1(x) * y) * c;
} else {
tmp = log1p(((1.0 / (fma(fma(0.08333333333333333, x, -0.5), x, 1.0) / x)) * y)) * c;
}
return tmp;
}
function code(c, x, y) tmp = 0.0 if (y <= -0.39) tmp = Float64(log1p(Float64(y / Float64(fma(-0.5, x, 1.0) / x))) * c); elseif (y <= 5.0) tmp = Float64(Float64(expm1(x) * y) * c); else tmp = Float64(log1p(Float64(Float64(1.0 / Float64(fma(fma(0.08333333333333333, x, -0.5), x, 1.0) / x)) * y)) * c); end return tmp end
code[c_, x_, y_] := If[LessEqual[y, -0.39], N[(N[Log[1 + N[(y / N[(N[(-0.5 * x + 1.0), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * c), $MachinePrecision], If[LessEqual[y, 5.0], N[(N[(N[(Exp[x] - 1), $MachinePrecision] * y), $MachinePrecision] * c), $MachinePrecision], N[(N[Log[1 + N[(N[(1.0 / N[(N[(N[(0.08333333333333333 * x + -0.5), $MachinePrecision] * x + 1.0), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]], $MachinePrecision] * c), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -0.39:\\
\;\;\;\;\mathsf{log1p}\left(\frac{y}{\frac{\mathsf{fma}\left(-0.5, x, 1\right)}{x}}\right) \cdot c\\
\mathbf{elif}\;y \leq 5:\\
\;\;\;\;\left(\mathsf{expm1}\left(x\right) \cdot y\right) \cdot c\\
\mathbf{else}:\\
\;\;\;\;\mathsf{log1p}\left(\frac{1}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(0.08333333333333333, x, -0.5\right), x, 1\right)}{x}} \cdot y\right) \cdot c\\
\end{array}
\end{array}
if y < -0.39000000000000001Initial program 55.0%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6455.0
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6455.0
lift-*.f64N/A
*-commutativeN/A
lower-*.f6455.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-expm1.f64N/A
flip--N/A
clear-numN/A
lower-/.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
pow2N/A
pow-expN/A
metadata-evalN/A
lower-expm1.f64N/A
lower-*.f6499.5
Applied rewrites99.5%
Taylor expanded in x around 0
lower-/.f64N/A
+-commutativeN/A
lower-fma.f6470.4
Applied rewrites70.4%
lift-*.f64N/A
lift-/.f64N/A
un-div-invN/A
lower-/.f6470.4
Applied rewrites70.4%
if -0.39000000000000001 < y < 5Initial program 42.3%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6442.3
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6464.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6464.4
lift--.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lift-E.f64N/A
log-EN/A
*-lft-identityN/A
lower-expm1.f6489.3
Applied rewrites89.3%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-expm1.f6488.8
Applied rewrites88.8%
if 5 < y Initial program 14.3%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6414.3
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6414.3
lift-*.f64N/A
*-commutativeN/A
lower-*.f6414.3
lift--.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lift-E.f64N/A
log-EN/A
*-lft-identityN/A
lower-expm1.f6497.8
Applied rewrites97.8%
lift-expm1.f64N/A
flip--N/A
clear-numN/A
lower-/.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
pow2N/A
pow-expN/A
metadata-evalN/A
lower-expm1.f64N/A
lower-*.f6497.7
Applied rewrites97.7%
Taylor expanded in x around 0
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sub-negN/A
metadata-evalN/A
lower-fma.f6497.6
Applied rewrites97.6%
Final simplification86.3%
(FPCore (c x y)
:precision binary64
(if (<= y -0.39)
(* (log1p (/ y (/ (fma -0.5 x 1.0) x))) c)
(if (<= y 0.2)
(* (* (expm1 x) y) c)
(*
(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 <= -0.39) {
tmp = log1p((y / (fma(-0.5, x, 1.0) / x))) * c;
} else if (y <= 0.2) {
tmp = (expm1(x) * y) * c;
} 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 <= -0.39) tmp = Float64(log1p(Float64(y / Float64(fma(-0.5, x, 1.0) / x))) * c); elseif (y <= 0.2) tmp = Float64(Float64(expm1(x) * y) * c); 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, -0.39], N[(N[Log[1 + N[(y / N[(N[(-0.5 * x + 1.0), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * c), $MachinePrecision], If[LessEqual[y, 0.2], N[(N[(N[(Exp[x] - 1), $MachinePrecision] * y), $MachinePrecision] * c), $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 -0.39:\\
\;\;\;\;\mathsf{log1p}\left(\frac{y}{\frac{\mathsf{fma}\left(-0.5, x, 1\right)}{x}}\right) \cdot c\\
\mathbf{elif}\;y \leq 0.2:\\
\;\;\;\;\left(\mathsf{expm1}\left(x\right) \cdot y\right) \cdot c\\
\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 < -0.39000000000000001Initial program 55.0%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6455.0
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6455.0
lift-*.f64N/A
*-commutativeN/A
lower-*.f6455.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-expm1.f64N/A
flip--N/A
clear-numN/A
lower-/.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
pow2N/A
pow-expN/A
metadata-evalN/A
lower-expm1.f64N/A
lower-*.f6499.5
Applied rewrites99.5%
Taylor expanded in x around 0
lower-/.f64N/A
+-commutativeN/A
lower-fma.f6470.4
Applied rewrites70.4%
lift-*.f64N/A
lift-/.f64N/A
un-div-invN/A
lower-/.f6470.4
Applied rewrites70.4%
if -0.39000000000000001 < y < 0.20000000000000001Initial program 42.3%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6442.3
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6464.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6464.4
lift--.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lift-E.f64N/A
log-EN/A
*-lft-identityN/A
lower-expm1.f6489.3
Applied rewrites89.3%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-expm1.f6488.8
Applied rewrites88.8%
if 0.20000000000000001 < y Initial program 14.3%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6414.3
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6414.3
lift-*.f64N/A
*-commutativeN/A
lower-*.f6414.3
lift--.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lift-E.f64N/A
log-EN/A
*-lft-identityN/A
lower-expm1.f6497.8
Applied rewrites97.8%
Taylor expanded in x around 0
*-commutativeN/A
Applied rewrites97.5%
Final simplification86.3%
(FPCore (c x y)
:precision binary64
(if (<= x -3300.0)
(* (* (expm1 x) y) c)
(*
(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 (x <= -3300.0) {
tmp = (expm1(x) * y) * c;
} 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 (x <= -3300.0) tmp = Float64(Float64(expm1(x) * y) * c); 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[x, -3300.0], N[(N[(N[(Exp[x] - 1), $MachinePrecision] * y), $MachinePrecision] * c), $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}\;x \leq -3300:\\
\;\;\;\;\left(\mathsf{expm1}\left(x\right) \cdot y\right) \cdot c\\
\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 x < -3300Initial program 55.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6455.5
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6499.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.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.8
Applied rewrites99.8%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-expm1.f6461.3
Applied rewrites61.3%
if -3300 < x Initial program 33.8%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6433.8
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6434.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6434.9
lift--.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lift-E.f64N/A
log-EN/A
*-lft-identityN/A
lower-expm1.f6491.5
Applied rewrites91.5%
Taylor expanded in x around 0
*-commutativeN/A
Applied rewrites90.9%
Final simplification83.4%
(FPCore (c x y) :precision binary64 (if (<= x -250000.0) (* (* (expm1 x) y) c) (* (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 (x <= -250000.0) {
tmp = (expm1(x) * y) * c;
} 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 (x <= -250000.0) tmp = Float64(Float64(expm1(x) * y) * c); 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[x, -250000.0], N[(N[(N[(Exp[x] - 1), $MachinePrecision] * y), $MachinePrecision] * c), $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}\;x \leq -250000:\\
\;\;\;\;\left(\mathsf{expm1}\left(x\right) \cdot y\right) \cdot c\\
\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 x < -2.5e5Initial program 54.8%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6454.8
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6499.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.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.8
Applied rewrites99.8%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-expm1.f6462.1
Applied rewrites62.1%
if -2.5e5 < x Initial program 34.1%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6434.1
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6435.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6435.2
lift--.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lift-E.f64N/A
log-EN/A
*-lft-identityN/A
lower-expm1.f6491.5
Applied rewrites91.5%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6490.5
Applied rewrites90.5%
Final simplification83.4%
(FPCore (c x y) :precision binary64 (if (<= x -3300.0) (* (* (expm1 x) y) c) (* (log1p (* (* (fma 0.5 x 1.0) x) y)) c)))
double code(double c, double x, double y) {
double tmp;
if (x <= -3300.0) {
tmp = (expm1(x) * y) * c;
} else {
tmp = log1p(((fma(0.5, x, 1.0) * x) * y)) * c;
}
return tmp;
}
function code(c, x, y) tmp = 0.0 if (x <= -3300.0) tmp = Float64(Float64(expm1(x) * y) * c); 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[x, -3300.0], N[(N[(N[(Exp[x] - 1), $MachinePrecision] * y), $MachinePrecision] * c), $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}\;x \leq -3300:\\
\;\;\;\;\left(\mathsf{expm1}\left(x\right) \cdot y\right) \cdot c\\
\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 x < -3300Initial program 55.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6455.5
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6499.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.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.8
Applied rewrites99.8%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-expm1.f6461.3
Applied rewrites61.3%
if -3300 < x Initial program 33.8%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6433.8
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6434.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6434.9
lift--.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lift-E.f64N/A
log-EN/A
*-lft-identityN/A
lower-expm1.f6491.5
Applied rewrites91.5%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6490.7
Applied rewrites90.7%
Final simplification83.2%
(FPCore (c x y) :precision binary64 (if (<= x -250000.0) (* (* (expm1 x) y) c) (* (log1p (* x y)) c)))
double code(double c, double x, double y) {
double tmp;
if (x <= -250000.0) {
tmp = (expm1(x) * y) * c;
} else {
tmp = log1p((x * y)) * c;
}
return tmp;
}
public static double code(double c, double x, double y) {
double tmp;
if (x <= -250000.0) {
tmp = (Math.expm1(x) * y) * c;
} else {
tmp = Math.log1p((x * y)) * c;
}
return tmp;
}
def code(c, x, y): tmp = 0 if x <= -250000.0: tmp = (math.expm1(x) * y) * c else: tmp = math.log1p((x * y)) * c return tmp
function code(c, x, y) tmp = 0.0 if (x <= -250000.0) tmp = Float64(Float64(expm1(x) * y) * c); else tmp = Float64(log1p(Float64(x * y)) * c); end return tmp end
code[c_, x_, y_] := If[LessEqual[x, -250000.0], N[(N[(N[(Exp[x] - 1), $MachinePrecision] * y), $MachinePrecision] * c), $MachinePrecision], N[(N[Log[1 + N[(x * y), $MachinePrecision]], $MachinePrecision] * c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -250000:\\
\;\;\;\;\left(\mathsf{expm1}\left(x\right) \cdot y\right) \cdot c\\
\mathbf{else}:\\
\;\;\;\;\mathsf{log1p}\left(x \cdot y\right) \cdot c\\
\end{array}
\end{array}
if x < -2.5e5Initial program 54.8%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6454.8
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6499.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.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.8
Applied rewrites99.8%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-expm1.f6462.1
Applied rewrites62.1%
if -2.5e5 < x Initial program 34.1%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6434.1
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6435.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6435.2
lift--.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lift-E.f64N/A
log-EN/A
*-lft-identityN/A
lower-expm1.f6491.5
Applied rewrites91.5%
lift-expm1.f64N/A
flip--N/A
clear-numN/A
lower-/.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
pow2N/A
pow-expN/A
metadata-evalN/A
lower-expm1.f64N/A
lower-*.f6491.5
Applied rewrites91.5%
Taylor expanded in x around 0
lower-/.f64N/A
+-commutativeN/A
lower-fma.f6490.2
Applied rewrites90.2%
Taylor expanded in x around 0
lower-*.f6489.7
Applied rewrites89.7%
(FPCore (c x y)
:precision binary64
(if (<= x 4.4e-275)
(* (* (expm1 x) y) c)
(*
(*
(fma
(fma
(fma (* 0.041666666666666664 c) x (* 0.16666666666666666 c))
x
(* 0.5 c))
x
c)
x)
y)))
double code(double c, double x, double y) {
double tmp;
if (x <= 4.4e-275) {
tmp = (expm1(x) * y) * c;
} else {
tmp = (fma(fma(fma((0.041666666666666664 * c), x, (0.16666666666666666 * c)), x, (0.5 * c)), x, c) * x) * y;
}
return tmp;
}
function code(c, x, y) tmp = 0.0 if (x <= 4.4e-275) tmp = Float64(Float64(expm1(x) * y) * c); else tmp = Float64(Float64(fma(fma(fma(Float64(0.041666666666666664 * c), x, Float64(0.16666666666666666 * c)), x, Float64(0.5 * c)), x, c) * x) * y); end return tmp end
code[c_, x_, y_] := If[LessEqual[x, 4.4e-275], N[(N[(N[(Exp[x] - 1), $MachinePrecision] * y), $MachinePrecision] * c), $MachinePrecision], N[(N[(N[(N[(N[(N[(0.041666666666666664 * c), $MachinePrecision] * x + N[(0.16666666666666666 * c), $MachinePrecision]), $MachinePrecision] * x + N[(0.5 * c), $MachinePrecision]), $MachinePrecision] * x + c), $MachinePrecision] * x), $MachinePrecision] * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 4.4 \cdot 10^{-275}:\\
\;\;\;\;\left(\mathsf{expm1}\left(x\right) \cdot y\right) \cdot c\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.041666666666666664 \cdot c, x, 0.16666666666666666 \cdot c\right), x, 0.5 \cdot c\right), x, c\right) \cdot x\right) \cdot y\\
\end{array}
\end{array}
if x < 4.39999999999999977e-275Initial program 45.3%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6445.3
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6464.1
lift-*.f64N/A
*-commutativeN/A
lower-*.f6464.1
lift--.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lift-E.f64N/A
log-EN/A
*-lft-identityN/A
lower-expm1.f6496.6
Applied rewrites96.6%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-expm1.f6471.3
Applied rewrites71.3%
if 4.39999999999999977e-275 < x Initial program 30.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.f6430.2
Applied rewrites30.2%
Taylor expanded in x around 0
Applied rewrites73.3%
(FPCore (c x y) :precision binary64 (if (<= c 8.2e+27) (* (* c y) x) (* (* (fma (* (fma 0.16666666666666666 x 0.5) c) x c) x) y)))
double code(double c, double x, double y) {
double tmp;
if (c <= 8.2e+27) {
tmp = (c * y) * x;
} else {
tmp = (fma((fma(0.16666666666666666, x, 0.5) * c), x, c) * x) * y;
}
return tmp;
}
function code(c, x, y) tmp = 0.0 if (c <= 8.2e+27) tmp = Float64(Float64(c * y) * x); else tmp = Float64(Float64(fma(Float64(fma(0.16666666666666666, x, 0.5) * c), x, c) * x) * y); end return tmp end
code[c_, x_, y_] := If[LessEqual[c, 8.2e+27], N[(N[(c * y), $MachinePrecision] * x), $MachinePrecision], N[(N[(N[(N[(N[(0.16666666666666666 * x + 0.5), $MachinePrecision] * c), $MachinePrecision] * x + c), $MachinePrecision] * x), $MachinePrecision] * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq 8.2 \cdot 10^{+27}:\\
\;\;\;\;\left(c \cdot y\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, x, 0.5\right) \cdot c, x, c\right) \cdot x\right) \cdot y\\
\end{array}
\end{array}
if c < 8.2000000000000005e27Initial program 45.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-*.f6460.7
Applied rewrites60.7%
if 8.2000000000000005e27 < c Initial program 21.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.f6419.5
Applied rewrites19.5%
Taylor expanded in x around 0
Applied rewrites60.2%
Taylor expanded in c around 0
Applied rewrites60.2%
(FPCore (c x y) :precision binary64 (if (<= c 1e+17) (* (* c y) x) (* (* x c) y)))
double code(double c, double x, double y) {
double tmp;
if (c <= 1e+17) {
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 <= 1d+17) 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 <= 1e+17) {
tmp = (c * y) * x;
} else {
tmp = (x * c) * y;
}
return tmp;
}
def code(c, x, y): tmp = 0 if c <= 1e+17: tmp = (c * y) * x else: tmp = (x * c) * y return tmp
function code(c, x, y) tmp = 0.0 if (c <= 1e+17) 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 <= 1e+17) tmp = (c * y) * x; else tmp = (x * c) * y; end tmp_2 = tmp; end
code[c_, x_, y_] := If[LessEqual[c, 1e+17], N[(N[(c * y), $MachinePrecision] * x), $MachinePrecision], N[(N[(x * c), $MachinePrecision] * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq 10^{+17}:\\
\;\;\;\;\left(c \cdot y\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot c\right) \cdot y\\
\end{array}
\end{array}
if c < 1e17Initial program 46.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-*.f6460.7
Applied rewrites60.7%
if 1e17 < c Initial program 19.8%
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.f6419.7
Applied rewrites19.7%
Taylor expanded in x around 0
Applied rewrites60.1%
(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 39.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-*.f6457.9
Applied rewrites57.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 2024295
(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)))))