
(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 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (c x y) :precision binary64 (* c (log (+ 1.0 (* (- (pow (E) x) 1.0) y)))))
\begin{array}{l}
\\
c \cdot \log \left(1 + \left({\mathsf{E}\left(\right)}^{x} - 1\right) \cdot y\right)
\end{array}
(FPCore (c x y)
:precision binary64
(if (<= y -2e-25)
(* c (log1p (* (expm1 x) y)))
(if (<= y 5.2e-6)
(* (* (/ 1.0 (/ (+ (pow (E) x) 1.0) (expm1 (* 2.0 x)))) c) y)
(*
(log1p
(*
(*
(fma
(fma (fma 0.041666666666666664 x 0.16666666666666666) x 0.5)
x
1.0)
x)
y))
c))))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2 \cdot 10^{-25}:\\
\;\;\;\;c \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(x\right) \cdot y\right)\\
\mathbf{elif}\;y \leq 5.2 \cdot 10^{-6}:\\
\;\;\;\;\left(\frac{1}{\frac{{\mathsf{E}\left(\right)}^{x} + 1}{\mathsf{expm1}\left(2 \cdot x\right)}} \cdot c\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 < -2.00000000000000008e-25Initial program 46.3%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6446.3
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6446.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6446.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 -2.00000000000000008e-25 < y < 5.20000000000000019e-6Initial program 45.6%
Taylor expanded in y around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-pow.f64N/A
lower-E.f6469.6
Applied rewrites69.6%
Applied rewrites99.8%
if 5.20000000000000019e-6 < y Initial program 14.4%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6414.4
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6414.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6414.4
lift--.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lift-E.f64N/A
log-EN/A
*-lft-identityN/A
lower-expm1.f6497.6
Applied rewrites97.6%
Taylor expanded in x around 0
Applied rewrites97.7%
Final simplification99.4%
(FPCore (c x y)
:precision binary64
(if (<= (pow (E) x) 0.0)
(* (* (expm1 x) y) c)
(*
(log1p
(*
(*
(fma (fma (fma 0.041666666666666664 x 0.16666666666666666) x 0.5) x 1.0)
x)
y))
c)))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;{\mathsf{E}\left(\right)}^{x} \leq 0:\\
\;\;\;\;\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 (pow.f64 (E.f64) x) < 0.0Initial program 56.6%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6456.6
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6499.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.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.9
Applied rewrites99.9%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-expm1.f6466.1
Applied rewrites66.1%
if 0.0 < (pow.f64 (E.f64) x) Initial program 32.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6432.9
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6433.1
lift-*.f64N/A
*-commutativeN/A
lower-*.f6433.1
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 x around 0
Applied rewrites90.0%
Final simplification82.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}
Initial program 40.2%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6440.2
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6453.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6453.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%
Final simplification93.1%
(FPCore (c x y) :precision binary64 (if (<= x -0.0128) (* (* (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 <= -0.0128) {
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 <= -0.0128) 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, -0.0128], 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 -0.0128:\\
\;\;\;\;\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 < -0.0128000000000000006Initial program 56.6%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6456.6
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6499.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.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.9
Applied rewrites99.9%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-expm1.f6466.1
Applied rewrites66.1%
if -0.0128000000000000006 < x Initial program 32.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6432.9
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6433.1
lift-*.f64N/A
*-commutativeN/A
lower-*.f6433.1
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 x around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6489.8
Applied rewrites89.8%
Final simplification82.5%
(FPCore (c x y) :precision binary64 (let* ((t_0 (* (log (fma y x 1.0)) c))) (if (<= y -1.2e+234) t_0 (if (<= y 2.5e+184) (* (* (expm1 x) y) 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 <= -1.2e+234) {
tmp = t_0;
} else if (y <= 2.5e+184) {
tmp = (expm1(x) * y) * 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 <= -1.2e+234) tmp = t_0; elseif (y <= 2.5e+184) tmp = Float64(Float64(expm1(x) * y) * 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, -1.2e+234], t$95$0, If[LessEqual[y, 2.5e+184], N[(N[(N[(Exp[x] - 1), $MachinePrecision] * y), $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 -1.2 \cdot 10^{+234}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 2.5 \cdot 10^{+184}:\\
\;\;\;\;\left(\mathsf{expm1}\left(x\right) \cdot y\right) \cdot c\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -1.20000000000000006e234 or 2.4999999999999999e184 < y Initial program 24.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.f6473.8
Applied rewrites73.8%
if -1.20000000000000006e234 < y < 2.4999999999999999e184Initial program 41.8%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6441.8
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6456.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6456.7
lift--.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lift-E.f64N/A
log-EN/A
*-lft-identityN/A
lower-expm1.f6492.5
Applied rewrites92.5%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-expm1.f6478.4
Applied rewrites78.4%
Final simplification78.0%
(FPCore (c x y) :precision binary64 (if (<= x -1e-42) (* (* (expm1 x) y) c) (* (* (fma (* (fma 0.16666666666666666 x 0.5) c) x c) x) y)))
double code(double c, double x, double y) {
double tmp;
if (x <= -1e-42) {
tmp = (expm1(x) * y) * c;
} 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 (x <= -1e-42) tmp = Float64(Float64(expm1(x) * y) * c); 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[x, -1e-42], N[(N[(N[(Exp[x] - 1), $MachinePrecision] * y), $MachinePrecision] * c), $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}\;x \leq -1 \cdot 10^{-42}:\\
\;\;\;\;\left(\mathsf{expm1}\left(x\right) \cdot y\right) \cdot c\\
\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 x < -1.00000000000000004e-42Initial program 57.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6457.9
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6497.5
lift-*.f64N/A
*-commutativeN/A
lower-*.f6497.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.9
Applied rewrites99.9%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-expm1.f6467.0
Applied rewrites67.0%
if -1.00000000000000004e-42 < x Initial program 31.2%
Taylor expanded in y around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-pow.f64N/A
lower-E.f6431.6
Applied rewrites31.6%
Taylor expanded in x around 0
Applied rewrites80.7%
Taylor expanded in x around 0
Applied rewrites80.9%
(FPCore (c x y) :precision binary64 (let* ((t_0 (/ (fma -0.5 x 1.0) x))) (if (<= c 1e-7) (/ (* c y) t_0) (* (* (/ 1.0 t_0) c) y))))
double code(double c, double x, double y) {
double t_0 = fma(-0.5, x, 1.0) / x;
double tmp;
if (c <= 1e-7) {
tmp = (c * y) / t_0;
} else {
tmp = ((1.0 / t_0) * c) * y;
}
return tmp;
}
function code(c, x, y) t_0 = Float64(fma(-0.5, x, 1.0) / x) tmp = 0.0 if (c <= 1e-7) tmp = Float64(Float64(c * y) / t_0); else tmp = Float64(Float64(Float64(1.0 / t_0) * c) * y); end return tmp end
code[c_, x_, y_] := Block[{t$95$0 = N[(N[(-0.5 * x + 1.0), $MachinePrecision] / x), $MachinePrecision]}, If[LessEqual[c, 1e-7], N[(N[(c * y), $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[(N[(1.0 / t$95$0), $MachinePrecision] * c), $MachinePrecision] * y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\mathsf{fma}\left(-0.5, x, 1\right)}{x}\\
\mathbf{if}\;c \leq 10^{-7}:\\
\;\;\;\;\frac{c \cdot y}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{1}{t\_0} \cdot c\right) \cdot y\\
\end{array}
\end{array}
if c < 9.9999999999999995e-8Initial program 47.6%
Taylor expanded in y around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-pow.f64N/A
lower-E.f6448.9
Applied rewrites48.9%
Applied rewrites76.0%
Taylor expanded in x around 0
Applied rewrites65.6%
Applied rewrites66.9%
if 9.9999999999999995e-8 < c Initial program 19.6%
Taylor expanded in y around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-pow.f64N/A
lower-E.f6427.1
Applied rewrites27.1%
Applied rewrites76.6%
Taylor expanded in x around 0
Applied rewrites62.3%
Final simplification65.6%
(FPCore (c x y) :precision binary64 (let* ((t_0 (/ (fma -0.5 x 1.0) x))) (if (<= c 5e+25) (/ (* c y) t_0) (* (/ c t_0) y))))
double code(double c, double x, double y) {
double t_0 = fma(-0.5, x, 1.0) / x;
double tmp;
if (c <= 5e+25) {
tmp = (c * y) / t_0;
} else {
tmp = (c / t_0) * y;
}
return tmp;
}
function code(c, x, y) t_0 = Float64(fma(-0.5, x, 1.0) / x) tmp = 0.0 if (c <= 5e+25) tmp = Float64(Float64(c * y) / t_0); else tmp = Float64(Float64(c / t_0) * y); end return tmp end
code[c_, x_, y_] := Block[{t$95$0 = N[(N[(-0.5 * x + 1.0), $MachinePrecision] / x), $MachinePrecision]}, If[LessEqual[c, 5e+25], N[(N[(c * y), $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[(c / t$95$0), $MachinePrecision] * y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\mathsf{fma}\left(-0.5, x, 1\right)}{x}\\
\mathbf{if}\;c \leq 5 \cdot 10^{+25}:\\
\;\;\;\;\frac{c \cdot y}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{t\_0} \cdot y\\
\end{array}
\end{array}
if c < 5.00000000000000024e25Initial program 46.7%
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.f6448.4
Applied rewrites48.4%
Applied rewrites76.0%
Taylor expanded in x around 0
Applied rewrites65.4%
Applied rewrites66.6%
if 5.00000000000000024e25 < c Initial program 20.6%
Taylor expanded in y around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-pow.f64N/A
lower-E.f6427.1
Applied rewrites27.1%
Applied rewrites76.7%
Taylor expanded in x around 0
Applied rewrites62.7%
Applied rewrites62.6%
Final simplification65.6%
(FPCore (c x y) :precision binary64 (if (<= y -7e+115) (* (* x y) c) (* (/ c (/ (fma -0.5 x 1.0) x)) y)))
double code(double c, double x, double y) {
double tmp;
if (y <= -7e+115) {
tmp = (x * y) * c;
} else {
tmp = (c / (fma(-0.5, x, 1.0) / x)) * y;
}
return tmp;
}
function code(c, x, y) tmp = 0.0 if (y <= -7e+115) tmp = Float64(Float64(x * y) * c); else tmp = Float64(Float64(c / Float64(fma(-0.5, x, 1.0) / x)) * y); end return tmp end
code[c_, x_, y_] := If[LessEqual[y, -7e+115], N[(N[(x * y), $MachinePrecision] * c), $MachinePrecision], N[(N[(c / N[(N[(-0.5 * x + 1.0), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7 \cdot 10^{+115}:\\
\;\;\;\;\left(x \cdot y\right) \cdot c\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{\frac{\mathsf{fma}\left(-0.5, x, 1\right)}{x}} \cdot y\\
\end{array}
\end{array}
if y < -7.00000000000000011e115Initial program 47.5%
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-*.f6436.3
Applied rewrites36.3%
if -7.00000000000000011e115 < y Initial program 38.7%
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.f6450.6
Applied rewrites50.6%
Applied rewrites86.5%
Taylor expanded in x around 0
Applied rewrites72.8%
Applied rewrites72.8%
Final simplification66.8%
(FPCore (c x y) :precision binary64 (if (<= c 3.3e+25) (* (* c y) x) (* (* x c) y)))
double code(double c, double x, double y) {
double tmp;
if (c <= 3.3e+25) {
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 <= 3.3d+25) 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 <= 3.3e+25) {
tmp = (c * y) * x;
} else {
tmp = (x * c) * y;
}
return tmp;
}
def code(c, x, y): tmp = 0 if c <= 3.3e+25: tmp = (c * y) * x else: tmp = (x * c) * y return tmp
function code(c, x, y) tmp = 0.0 if (c <= 3.3e+25) 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 <= 3.3e+25) tmp = (c * y) * x; else tmp = (x * c) * y; end tmp_2 = tmp; end
code[c_, x_, y_] := If[LessEqual[c, 3.3e+25], N[(N[(c * y), $MachinePrecision] * x), $MachinePrecision], N[(N[(x * c), $MachinePrecision] * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq 3.3 \cdot 10^{+25}:\\
\;\;\;\;\left(c \cdot y\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot c\right) \cdot y\\
\end{array}
\end{array}
if c < 3.3000000000000001e25Initial program 46.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%
if 3.3000000000000001e25 < c Initial program 20.6%
Taylor expanded in y around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-pow.f64N/A
lower-E.f6427.1
Applied rewrites27.1%
Taylor expanded in x around 0
Applied rewrites60.2%
(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.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-*.f6461.3
Applied rewrites61.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 2024285
(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)))))