
(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 -1e-21) t_0 (if (<= y 2e-74) (* (* 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 <= -1e-21) {
tmp = t_0;
} else if (y <= 2e-74) {
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 <= -1e-21) {
tmp = t_0;
} else if (y <= 2e-74) {
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 <= -1e-21: tmp = t_0 elif y <= 2e-74: 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 <= -1e-21) tmp = t_0; elseif (y <= 2e-74) 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, -1e-21], t$95$0, If[LessEqual[y, 2e-74], 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 -1 \cdot 10^{-21}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 2 \cdot 10^{-74}:\\
\;\;\;\;\left(c \cdot \mathsf{expm1}\left(x\right)\right) \cdot y\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -9.99999999999999908e-22 or 1.99999999999999992e-74 < y Initial program 26.4%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6426.4
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6432.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6432.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%
if -9.99999999999999908e-22 < y < 1.99999999999999992e-74Initial program 49.1%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6449.1
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6473.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6473.9
lift--.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lift-E.f64N/A
log-EN/A
*-lft-identityN/A
lower-expm1.f6484.7
Applied rewrites84.7%
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.7%
(FPCore (c x y)
:precision binary64
(if (<= y -0.95)
(* (log1p (* (/ 1.0 (/ (fma -0.5 x 1.0) x)) y)) c)
(if (<= y 1.1)
(* (* 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 <= -0.95) {
tmp = log1p(((1.0 / (fma(-0.5, x, 1.0) / x)) * y)) * c;
} else if (y <= 1.1) {
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 <= -0.95) tmp = Float64(log1p(Float64(Float64(1.0 / Float64(fma(-0.5, x, 1.0) / x)) * y)) * c); elseif (y <= 1.1) 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, -0.95], N[(N[Log[1 + N[(N[(1.0 / N[(N[(-0.5 * x + 1.0), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]], $MachinePrecision] * c), $MachinePrecision], If[LessEqual[y, 1.1], 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 -0.95:\\
\;\;\;\;\mathsf{log1p}\left(\frac{1}{\frac{\mathsf{fma}\left(-0.5, x, 1\right)}{x}} \cdot y\right) \cdot c\\
\mathbf{elif}\;y \leq 1.1:\\
\;\;\;\;\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 < -0.94999999999999996Initial program 34.7%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6434.7
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6434.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6434.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%
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.6
Applied rewrites99.6%
Taylor expanded in x around 0
lower-/.f64N/A
+-commutativeN/A
lower-fma.f6480.5
Applied rewrites80.5%
if -0.94999999999999996 < y < 1.1000000000000001Initial program 45.4%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6445.4
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6470.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6470.7
lift--.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lift-E.f64N/A
log-EN/A
*-lft-identityN/A
lower-expm1.f6487.6
Applied rewrites87.6%
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 1.1000000000000001 < y Initial program 12.8%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6412.8
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6412.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6412.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.5
Applied rewrites99.5%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6499.5
Applied rewrites99.5%
Final simplification94.6%
(FPCore (c x y)
:precision binary64
(if (<= y -7.6)
(* (log1p (* (/ 1.0 (/ 1.0 x)) y)) c)
(if (<= y 1.1)
(* (* 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 <= -7.6) {
tmp = log1p(((1.0 / (1.0 / x)) * y)) * c;
} else if (y <= 1.1) {
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 <= -7.6) tmp = Float64(log1p(Float64(Float64(1.0 / Float64(1.0 / x)) * y)) * c); elseif (y <= 1.1) 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, -7.6], N[(N[Log[1 + N[(N[(1.0 / N[(1.0 / x), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]], $MachinePrecision] * c), $MachinePrecision], If[LessEqual[y, 1.1], 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 -7.6:\\
\;\;\;\;\mathsf{log1p}\left(\frac{1}{\frac{1}{x}} \cdot y\right) \cdot c\\
\mathbf{elif}\;y \leq 1.1:\\
\;\;\;\;\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 < -7.5999999999999996Initial program 34.7%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6434.7
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6434.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6434.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%
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.6
Applied rewrites99.6%
Taylor expanded in x around 0
lower-/.f6475.0
Applied rewrites75.0%
if -7.5999999999999996 < y < 1.1000000000000001Initial program 45.4%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6445.4
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6470.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6470.7
lift--.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lift-E.f64N/A
log-EN/A
*-lft-identityN/A
lower-expm1.f6487.6
Applied rewrites87.6%
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 1.1000000000000001 < y Initial program 12.8%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6412.8
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6412.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6412.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.5
Applied rewrites99.5%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6499.5
Applied rewrites99.5%
Final simplification93.4%
(FPCore (c x y) :precision binary64 (let* ((t_0 (* (log1p (* (* (fma 0.5 x 1.0) x) y)) c))) (if (<= y -7.6) t_0 (if (<= y 1.1) (* (* 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 <= -7.6) {
tmp = t_0;
} else if (y <= 1.1) {
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 <= -7.6) tmp = t_0; elseif (y <= 1.1) 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, -7.6], t$95$0, If[LessEqual[y, 1.1], 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 -7.6:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 1.1:\\
\;\;\;\;\left(c \cdot \mathsf{expm1}\left(x\right)\right) \cdot y\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -7.5999999999999996 or 1.1000000000000001 < y Initial program 25.4%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6425.4
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6425.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6425.4
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.f6481.5
Applied rewrites81.5%
if -7.5999999999999996 < y < 1.1000000000000001Initial program 45.4%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6445.4
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6470.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6470.7
lift--.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lift-E.f64N/A
log-EN/A
*-lft-identityN/A
lower-expm1.f6487.6
Applied rewrites87.6%
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%
Final simplification91.8%
(FPCore (c x y) :precision binary64 (let* ((t_0 (* (log (fma y x 1.0)) c))) (if (<= y -1.45e+98) t_0 (if (<= y 6.5e+164) (* (* 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 <= -1.45e+98) {
tmp = t_0;
} else if (y <= 6.5e+164) {
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 <= -1.45e+98) tmp = t_0; elseif (y <= 6.5e+164) 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, -1.45e+98], t$95$0, If[LessEqual[y, 6.5e+164], 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 -1.45 \cdot 10^{+98}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 6.5 \cdot 10^{+164}:\\
\;\;\;\;\left(c \cdot \mathsf{expm1}\left(x\right)\right) \cdot y\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -1.45000000000000005e98 or 6.5000000000000003e164 < y Initial program 28.1%
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.6
Applied rewrites54.6%
if -1.45000000000000005e98 < y < 6.5000000000000003e164Initial program 40.6%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6440.6
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6460.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6460.7
lift--.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lift-E.f64N/A
log-EN/A
*-lft-identityN/A
lower-expm1.f6490.1
Applied rewrites90.1%
Taylor expanded in y around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-expm1.f6493.8
Applied rewrites93.8%
Final simplification84.8%
(FPCore (c x y) :precision binary64 (let* ((t_0 (* (* x y) c))) (if (<= y -4.9e+98) t_0 (if (<= y 1e+44) (* (* c (expm1 x)) y) t_0))))
double code(double c, double x, double y) {
double t_0 = (x * y) * c;
double tmp;
if (y <= -4.9e+98) {
tmp = t_0;
} else if (y <= 1e+44) {
tmp = (c * expm1(x)) * y;
} else {
tmp = t_0;
}
return tmp;
}
public static double code(double c, double x, double y) {
double t_0 = (x * y) * c;
double tmp;
if (y <= -4.9e+98) {
tmp = t_0;
} else if (y <= 1e+44) {
tmp = (c * Math.expm1(x)) * y;
} else {
tmp = t_0;
}
return tmp;
}
def code(c, x, y): t_0 = (x * y) * c tmp = 0 if y <= -4.9e+98: tmp = t_0 elif y <= 1e+44: tmp = (c * math.expm1(x)) * y else: tmp = t_0 return tmp
function code(c, x, y) t_0 = Float64(Float64(x * y) * c) tmp = 0.0 if (y <= -4.9e+98) tmp = t_0; elseif (y <= 1e+44) 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[(x * y), $MachinePrecision] * c), $MachinePrecision]}, If[LessEqual[y, -4.9e+98], t$95$0, If[LessEqual[y, 1e+44], N[(N[(c * N[(Exp[x] - 1), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x \cdot y\right) \cdot c\\
\mathbf{if}\;y \leq -4.9 \cdot 10^{+98}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 10^{+44}:\\
\;\;\;\;\left(c \cdot \mathsf{expm1}\left(x\right)\right) \cdot y\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -4.89999999999999979e98 or 1.0000000000000001e44 < y Initial program 26.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-*.f6446.6
Applied rewrites46.6%
if -4.89999999999999979e98 < y < 1.0000000000000001e44Initial program 41.8%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6441.8
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6462.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6462.9
lift--.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lift-E.f64N/A
log-EN/A
*-lft-identityN/A
lower-expm1.f6489.6
Applied rewrites89.6%
Taylor expanded in y around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-expm1.f6494.9
Applied rewrites94.9%
Final simplification82.1%
(FPCore (c x y)
:precision binary64
(if (<= c 1.82e+146)
(* (* c y) x)
(*
(fma
(* (* (* (fma -0.5 x -0.5) y) x) x)
c
(* (* (fma (fma 0.16666666666666666 x 0.5) x 1.0) c) x))
y)))
double code(double c, double x, double y) {
double tmp;
if (c <= 1.82e+146) {
tmp = (c * y) * x;
} else {
tmp = fma((((fma(-0.5, x, -0.5) * y) * x) * x), c, ((fma(fma(0.16666666666666666, x, 0.5), x, 1.0) * c) * x)) * y;
}
return tmp;
}
function code(c, x, y) tmp = 0.0 if (c <= 1.82e+146) tmp = Float64(Float64(c * y) * x); else tmp = Float64(fma(Float64(Float64(Float64(fma(-0.5, x, -0.5) * y) * x) * x), c, Float64(Float64(fma(fma(0.16666666666666666, x, 0.5), x, 1.0) * c) * x)) * y); end return tmp end
code[c_, x_, y_] := If[LessEqual[c, 1.82e+146], N[(N[(c * y), $MachinePrecision] * x), $MachinePrecision], N[(N[(N[(N[(N[(N[(-0.5 * x + -0.5), $MachinePrecision] * y), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision] * c + N[(N[(N[(N[(0.16666666666666666 * x + 0.5), $MachinePrecision] * x + 1.0), $MachinePrecision] * c), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq 1.82 \cdot 10^{+146}:\\
\;\;\;\;\left(c \cdot y\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(\left(\mathsf{fma}\left(-0.5, x, -0.5\right) \cdot y\right) \cdot x\right) \cdot x, c, \left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, x, 0.5\right), x, 1\right) \cdot c\right) \cdot x\right) \cdot y\\
\end{array}
\end{array}
if c < 1.82e146Initial program 40.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
*-lft-identityN/A
*-commutativeN/A
metadata-evalN/A
log-EN/A
log-EN/A
metadata-evalN/A
log-EN/A
lower-*.f64N/A
log-EN/A
*-rgt-identityN/A
lower-*.f6462.8
Applied rewrites62.8%
if 1.82e146 < c Initial program 18.9%
Taylor expanded in x around 0
Applied rewrites65.5%
Taylor expanded in y around 0
Applied rewrites81.1%
(FPCore (c x y) :precision binary64 (if (<= c 5.5e+58) (* (* c y) x) (* (* c x) y)))
double code(double c, double x, double y) {
double tmp;
if (c <= 5.5e+58) {
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 <= 5.5d+58) 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 <= 5.5e+58) {
tmp = (c * y) * x;
} else {
tmp = (c * x) * y;
}
return tmp;
}
def code(c, x, y): tmp = 0 if c <= 5.5e+58: tmp = (c * y) * x else: tmp = (c * x) * y return tmp
function code(c, x, y) tmp = 0.0 if (c <= 5.5e+58) 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 <= 5.5e+58) tmp = (c * y) * x; else tmp = (c * x) * y; end tmp_2 = tmp; end
code[c_, x_, y_] := If[LessEqual[c, 5.5e+58], N[(N[(c * y), $MachinePrecision] * x), $MachinePrecision], N[(N[(c * x), $MachinePrecision] * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq 5.5 \cdot 10^{+58}:\\
\;\;\;\;\left(c \cdot y\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;\left(c \cdot x\right) \cdot y\\
\end{array}
\end{array}
if c < 5.4999999999999999e58Initial program 43.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
*-lft-identityN/A
*-commutativeN/A
metadata-evalN/A
log-EN/A
log-EN/A
metadata-evalN/A
log-EN/A
lower-*.f64N/A
log-EN/A
*-rgt-identityN/A
lower-*.f6464.7
Applied rewrites64.7%
if 5.4999999999999999e58 < c Initial program 14.8%
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
*-lft-identityN/A
*-commutativeN/A
metadata-evalN/A
log-EN/A
log-EN/A
metadata-evalN/A
log-EN/A
lower-*.f64N/A
log-EN/A
*-rgt-identityN/A
lower-*.f6462.8
Applied rewrites62.8%
Applied rewrites68.5%
Final simplification65.4%
(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 37.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
*-lft-identityN/A
*-commutativeN/A
metadata-evalN/A
log-EN/A
log-EN/A
metadata-evalN/A
log-EN/A
lower-*.f64N/A
log-EN/A
*-rgt-identityN/A
lower-*.f6464.3
Applied rewrites64.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}
herbie shell --seed 2024331
(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)))))