
(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 7 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 (<= x 5.9e-305)
t_0
(if (<= x 1.7e-76)
(*
(*
(fma
(fma
(* 0.3333333333333333 c)
(* (* x x) y)
(* (* (fma x c c) -0.5) x))
y
(fma (fma 0.16666666666666666 (* c x) (* 0.5 c)) x c))
x)
y)
t_0))))
double code(double c, double x, double y) {
double t_0 = c * log1p((expm1(x) * y));
double tmp;
if (x <= 5.9e-305) {
tmp = t_0;
} else if (x <= 1.7e-76) {
tmp = (fma(fma((0.3333333333333333 * c), ((x * x) * y), ((fma(x, c, c) * -0.5) * x)), y, fma(fma(0.16666666666666666, (c * x), (0.5 * c)), x, c)) * 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 (x <= 5.9e-305) tmp = t_0; elseif (x <= 1.7e-76) tmp = Float64(Float64(fma(fma(Float64(0.3333333333333333 * c), Float64(Float64(x * x) * y), Float64(Float64(fma(x, c, c) * -0.5) * x)), y, fma(fma(0.16666666666666666, Float64(c * x), Float64(0.5 * c)), x, c)) * 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[x, 5.9e-305], t$95$0, If[LessEqual[x, 1.7e-76], N[(N[(N[(N[(N[(0.3333333333333333 * c), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * y), $MachinePrecision] + N[(N[(N[(x * c + c), $MachinePrecision] * -0.5), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] * y + N[(N[(0.16666666666666666 * N[(c * x), $MachinePrecision] + N[(0.5 * c), $MachinePrecision]), $MachinePrecision] * x + c), $MachinePrecision]), $MachinePrecision] * x), $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}\;x \leq 5.9 \cdot 10^{-305}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.7 \cdot 10^{-76}:\\
\;\;\;\;\left(\mathsf{fma}\left(\mathsf{fma}\left(0.3333333333333333 \cdot c, \left(x \cdot x\right) \cdot y, \left(\mathsf{fma}\left(x, c, c\right) \cdot -0.5\right) \cdot x\right), y, \mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, c \cdot x, 0.5 \cdot c\right), x, c\right)\right) \cdot x\right) \cdot y\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < 5.9000000000000005e-305 or 1.7e-76 < x Initial program 34.4%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6434.4
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6454.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6454.9
lift--.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lift-E.f64N/A
log-EN/A
*-lft-identityN/A
lower-expm1.f6494.3
Applied rewrites94.3%
if 5.9000000000000005e-305 < x < 1.7e-76Initial program 30.0%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites30.0%
Taylor expanded in x around 0
Applied rewrites79.5%
Taylor expanded in y around 0
Applied rewrites94.5%
Final simplification94.3%
(FPCore (c x y)
:precision binary64
(let* ((t_0 (* (log1p (* (* (fma 0.5 x 1.0) x) y)) c)))
(if (<= x -8e-5)
(* (* (expm1 x) y) c)
(if (<= x 5.9e-305)
t_0
(if (<= x 1.7e-76)
(*
(*
(fma
(fma
(* 0.3333333333333333 c)
(* (* x x) y)
(* (* (fma x c c) -0.5) x))
y
(fma (fma 0.16666666666666666 (* c x) (* 0.5 c)) x c))
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 (x <= -8e-5) {
tmp = (expm1(x) * y) * c;
} else if (x <= 5.9e-305) {
tmp = t_0;
} else if (x <= 1.7e-76) {
tmp = (fma(fma((0.3333333333333333 * c), ((x * x) * y), ((fma(x, c, c) * -0.5) * x)), y, fma(fma(0.16666666666666666, (c * x), (0.5 * c)), x, c)) * 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 (x <= -8e-5) tmp = Float64(Float64(expm1(x) * y) * c); elseif (x <= 5.9e-305) tmp = t_0; elseif (x <= 1.7e-76) tmp = Float64(Float64(fma(fma(Float64(0.3333333333333333 * c), Float64(Float64(x * x) * y), Float64(Float64(fma(x, c, c) * -0.5) * x)), y, fma(fma(0.16666666666666666, Float64(c * x), Float64(0.5 * c)), x, c)) * 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[x, -8e-5], N[(N[(N[(Exp[x] - 1), $MachinePrecision] * y), $MachinePrecision] * c), $MachinePrecision], If[LessEqual[x, 5.9e-305], t$95$0, If[LessEqual[x, 1.7e-76], N[(N[(N[(N[(N[(0.3333333333333333 * c), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * y), $MachinePrecision] + N[(N[(N[(x * c + c), $MachinePrecision] * -0.5), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] * y + N[(N[(0.16666666666666666 * N[(c * x), $MachinePrecision] + N[(0.5 * c), $MachinePrecision]), $MachinePrecision] * x + c), $MachinePrecision]), $MachinePrecision] * x), $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}\;x \leq -8 \cdot 10^{-5}:\\
\;\;\;\;\left(\mathsf{expm1}\left(x\right) \cdot y\right) \cdot c\\
\mathbf{elif}\;x \leq 5.9 \cdot 10^{-305}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.7 \cdot 10^{-76}:\\
\;\;\;\;\left(\mathsf{fma}\left(\mathsf{fma}\left(0.3333333333333333 \cdot c, \left(x \cdot x\right) \cdot y, \left(\mathsf{fma}\left(x, c, c\right) \cdot -0.5\right) \cdot x\right), y, \mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, c \cdot x, 0.5 \cdot c\right), x, c\right)\right) \cdot x\right) \cdot y\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -8.00000000000000065e-5Initial program 48.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6448.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
lower-expm1.f6467.9
Applied rewrites67.9%
if -8.00000000000000065e-5 < x < 5.9000000000000005e-305 or 1.7e-76 < x Initial program 25.2%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6425.2
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.f6490.7
Applied rewrites90.7%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6490.2
Applied rewrites90.2%
if 5.9000000000000005e-305 < x < 1.7e-76Initial program 30.0%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites30.0%
Taylor expanded in x around 0
Applied rewrites79.5%
Taylor expanded in y around 0
Applied rewrites94.5%
Final simplification84.3%
(FPCore (c x y)
:precision binary64
(let* ((t_0 (* (log1p (* y x)) c)))
(if (<= x -3.6e-15)
(* (* (expm1 x) y) c)
(if (<= x 5.9e-305)
t_0
(if (<= x 1.7e-76)
(*
(*
(fma
(fma
(* 0.3333333333333333 c)
(* (* x x) y)
(* (* (fma x c c) -0.5) x))
y
(fma (fma 0.16666666666666666 (* c x) (* 0.5 c)) x c))
x)
y)
t_0)))))
double code(double c, double x, double y) {
double t_0 = log1p((y * x)) * c;
double tmp;
if (x <= -3.6e-15) {
tmp = (expm1(x) * y) * c;
} else if (x <= 5.9e-305) {
tmp = t_0;
} else if (x <= 1.7e-76) {
tmp = (fma(fma((0.3333333333333333 * c), ((x * x) * y), ((fma(x, c, c) * -0.5) * x)), y, fma(fma(0.16666666666666666, (c * x), (0.5 * c)), x, c)) * x) * y;
} else {
tmp = t_0;
}
return tmp;
}
function code(c, x, y) t_0 = Float64(log1p(Float64(y * x)) * c) tmp = 0.0 if (x <= -3.6e-15) tmp = Float64(Float64(expm1(x) * y) * c); elseif (x <= 5.9e-305) tmp = t_0; elseif (x <= 1.7e-76) tmp = Float64(Float64(fma(fma(Float64(0.3333333333333333 * c), Float64(Float64(x * x) * y), Float64(Float64(fma(x, c, c) * -0.5) * x)), y, fma(fma(0.16666666666666666, Float64(c * x), Float64(0.5 * c)), x, c)) * x) * y); else tmp = t_0; end return tmp end
code[c_, x_, y_] := Block[{t$95$0 = N[(N[Log[1 + N[(y * x), $MachinePrecision]], $MachinePrecision] * c), $MachinePrecision]}, If[LessEqual[x, -3.6e-15], N[(N[(N[(Exp[x] - 1), $MachinePrecision] * y), $MachinePrecision] * c), $MachinePrecision], If[LessEqual[x, 5.9e-305], t$95$0, If[LessEqual[x, 1.7e-76], N[(N[(N[(N[(N[(0.3333333333333333 * c), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * y), $MachinePrecision] + N[(N[(N[(x * c + c), $MachinePrecision] * -0.5), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] * y + N[(N[(0.16666666666666666 * N[(c * x), $MachinePrecision] + N[(0.5 * c), $MachinePrecision]), $MachinePrecision] * x + c), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision] * y), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{log1p}\left(y \cdot x\right) \cdot c\\
\mathbf{if}\;x \leq -3.6 \cdot 10^{-15}:\\
\;\;\;\;\left(\mathsf{expm1}\left(x\right) \cdot y\right) \cdot c\\
\mathbf{elif}\;x \leq 5.9 \cdot 10^{-305}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.7 \cdot 10^{-76}:\\
\;\;\;\;\left(\mathsf{fma}\left(\mathsf{fma}\left(0.3333333333333333 \cdot c, \left(x \cdot x\right) \cdot y, \left(\mathsf{fma}\left(x, c, c\right) \cdot -0.5\right) \cdot x\right), y, \mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, c \cdot x, 0.5 \cdot c\right), x, c\right)\right) \cdot x\right) \cdot y\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -3.6000000000000001e-15Initial program 48.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6448.5
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6498.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6498.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.8
Applied rewrites99.8%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
lower-expm1.f6468.6
Applied rewrites68.6%
if -3.6000000000000001e-15 < x < 5.9000000000000005e-305 or 1.7e-76 < x Initial program 24.7%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6424.7
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6424.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6424.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.5
Applied rewrites90.5%
Taylor expanded in x around 0
lower-*.f6490.1
Applied rewrites90.1%
if 5.9000000000000005e-305 < x < 1.7e-76Initial program 30.0%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites30.0%
Taylor expanded in x around 0
Applied rewrites79.5%
Taylor expanded in y around 0
Applied rewrites94.5%
Final simplification84.3%
(FPCore (c x y)
:precision binary64
(if (<= x -6.8e-29)
(* (* (expm1 x) y) c)
(*
(*
(fma
(fma (* 0.3333333333333333 c) (* (* x x) y) (* (* (fma x c c) -0.5) x))
y
(fma (fma 0.16666666666666666 (* c x) (* 0.5 c)) x c))
x)
y)))
double code(double c, double x, double y) {
double tmp;
if (x <= -6.8e-29) {
tmp = (expm1(x) * y) * c;
} else {
tmp = (fma(fma((0.3333333333333333 * c), ((x * x) * y), ((fma(x, c, c) * -0.5) * x)), y, fma(fma(0.16666666666666666, (c * x), (0.5 * c)), x, c)) * x) * y;
}
return tmp;
}
function code(c, x, y) tmp = 0.0 if (x <= -6.8e-29) tmp = Float64(Float64(expm1(x) * y) * c); else tmp = Float64(Float64(fma(fma(Float64(0.3333333333333333 * c), Float64(Float64(x * x) * y), Float64(Float64(fma(x, c, c) * -0.5) * x)), y, fma(fma(0.16666666666666666, Float64(c * x), Float64(0.5 * c)), x, c)) * x) * y); end return tmp end
code[c_, x_, y_] := If[LessEqual[x, -6.8e-29], N[(N[(N[(Exp[x] - 1), $MachinePrecision] * y), $MachinePrecision] * c), $MachinePrecision], N[(N[(N[(N[(N[(0.3333333333333333 * c), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * y), $MachinePrecision] + N[(N[(N[(x * c + c), $MachinePrecision] * -0.5), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] * y + N[(N[(0.16666666666666666 * N[(c * x), $MachinePrecision] + N[(0.5 * c), $MachinePrecision]), $MachinePrecision] * x + c), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision] * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6.8 \cdot 10^{-29}:\\
\;\;\;\;\left(\mathsf{expm1}\left(x\right) \cdot y\right) \cdot c\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(\mathsf{fma}\left(0.3333333333333333 \cdot c, \left(x \cdot x\right) \cdot y, \left(\mathsf{fma}\left(x, c, c\right) \cdot -0.5\right) \cdot x\right), y, \mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, c \cdot x, 0.5 \cdot c\right), x, c\right)\right) \cdot x\right) \cdot y\\
\end{array}
\end{array}
if x < -6.79999999999999945e-29Initial program 45.8%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6445.8
lift-log.f64N/A
lift-+.f64N/A
lower-log1p.f6492.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6492.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.7
Applied rewrites99.7%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
lower-expm1.f6466.9
Applied rewrites66.9%
if -6.79999999999999945e-29 < x Initial program 27.0%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites26.4%
Taylor expanded in x around 0
Applied rewrites67.2%
Taylor expanded in y around 0
Applied rewrites81.8%
Final simplification76.6%
(FPCore (c x y)
:precision binary64
(if (<= c 8.5e+63)
(* (* c y) x)
(*
(*
(fma
(fma (* 0.3333333333333333 c) (* (* x x) y) (* (* (fma x c c) -0.5) x))
y
(fma (fma 0.16666666666666666 (* c x) (* 0.5 c)) x c))
x)
y)))
double code(double c, double x, double y) {
double tmp;
if (c <= 8.5e+63) {
tmp = (c * y) * x;
} else {
tmp = (fma(fma((0.3333333333333333 * c), ((x * x) * y), ((fma(x, c, c) * -0.5) * x)), y, fma(fma(0.16666666666666666, (c * x), (0.5 * c)), x, c)) * x) * y;
}
return tmp;
}
function code(c, x, y) tmp = 0.0 if (c <= 8.5e+63) tmp = Float64(Float64(c * y) * x); else tmp = Float64(Float64(fma(fma(Float64(0.3333333333333333 * c), Float64(Float64(x * x) * y), Float64(Float64(fma(x, c, c) * -0.5) * x)), y, fma(fma(0.16666666666666666, Float64(c * x), Float64(0.5 * c)), x, c)) * x) * y); end return tmp end
code[c_, x_, y_] := If[LessEqual[c, 8.5e+63], N[(N[(c * y), $MachinePrecision] * x), $MachinePrecision], N[(N[(N[(N[(N[(0.3333333333333333 * c), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * y), $MachinePrecision] + N[(N[(N[(x * c + c), $MachinePrecision] * -0.5), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] * y + N[(N[(0.16666666666666666 * N[(c * x), $MachinePrecision] + N[(0.5 * c), $MachinePrecision]), $MachinePrecision] * x + c), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision] * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq 8.5 \cdot 10^{+63}:\\
\;\;\;\;\left(c \cdot y\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(\mathsf{fma}\left(0.3333333333333333 \cdot c, \left(x \cdot x\right) \cdot y, \left(\mathsf{fma}\left(x, c, c\right) \cdot -0.5\right) \cdot x\right), y, \mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, c \cdot x, 0.5 \cdot c\right), x, c\right)\right) \cdot x\right) \cdot y\\
\end{array}
\end{array}
if c < 8.5000000000000004e63Initial program 40.5%
Taylor expanded in x around 0
associate-*r*N/A
log-EN/A
*-rgt-identityN/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
*-lft-identityN/A
*-commutativeN/A
log-EN/A
lower-*.f64N/A
*-commutativeN/A
log-EN/A
*-rgt-identityN/A
lower-*.f6460.4
Applied rewrites60.4%
if 8.5000000000000004e63 < c Initial program 14.4%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites24.3%
Taylor expanded in x around 0
Applied rewrites37.6%
Taylor expanded in y around 0
Applied rewrites58.2%
Final simplification59.8%
(FPCore (c x y) :precision binary64 (if (<= c 1.16e-66) (* (* c y) x) (* (* c x) y)))
double code(double c, double x, double y) {
double tmp;
if (c <= 1.16e-66) {
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 <= 1.16d-66) 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 <= 1.16e-66) {
tmp = (c * y) * x;
} else {
tmp = (c * x) * y;
}
return tmp;
}
def code(c, x, y): tmp = 0 if c <= 1.16e-66: tmp = (c * y) * x else: tmp = (c * x) * y return tmp
function code(c, x, y) tmp = 0.0 if (c <= 1.16e-66) 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 <= 1.16e-66) tmp = (c * y) * x; else tmp = (c * x) * y; end tmp_2 = tmp; end
code[c_, x_, y_] := If[LessEqual[c, 1.16e-66], N[(N[(c * y), $MachinePrecision] * x), $MachinePrecision], N[(N[(c * x), $MachinePrecision] * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq 1.16 \cdot 10^{-66}:\\
\;\;\;\;\left(c \cdot y\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;\left(c \cdot x\right) \cdot y\\
\end{array}
\end{array}
if c < 1.16000000000000002e-66Initial program 41.2%
Taylor expanded in x around 0
associate-*r*N/A
log-EN/A
*-rgt-identityN/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
*-lft-identityN/A
*-commutativeN/A
log-EN/A
lower-*.f64N/A
*-commutativeN/A
log-EN/A
*-rgt-identityN/A
lower-*.f6461.0
Applied rewrites61.0%
if 1.16000000000000002e-66 < c Initial program 18.6%
Taylor expanded in x around 0
associate-*r*N/A
log-EN/A
*-rgt-identityN/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
*-lft-identityN/A
*-commutativeN/A
log-EN/A
lower-*.f64N/A
*-commutativeN/A
log-EN/A
*-rgt-identityN/A
lower-*.f6446.2
Applied rewrites46.2%
Applied rewrites57.1%
Final simplification59.7%
(FPCore (c x y) :precision binary64 (* (* c x) y))
double code(double c, double x, double y) {
return (c * x) * y;
}
real(8) function code(c, x, y)
real(8), intent (in) :: c
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (c * x) * y
end function
public static double code(double c, double x, double y) {
return (c * x) * y;
}
def code(c, x, y): return (c * x) * y
function code(c, x, y) return Float64(Float64(c * x) * y) end
function tmp = code(c, x, y) tmp = (c * x) * y; end
code[c_, x_, y_] := N[(N[(c * x), $MachinePrecision] * y), $MachinePrecision]
\begin{array}{l}
\\
\left(c \cdot x\right) \cdot y
\end{array}
Initial program 33.4%
Taylor expanded in x around 0
associate-*r*N/A
log-EN/A
*-rgt-identityN/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
*-lft-identityN/A
*-commutativeN/A
log-EN/A
lower-*.f64N/A
*-commutativeN/A
log-EN/A
*-rgt-identityN/A
lower-*.f6455.9
Applied rewrites55.9%
Applied rewrites57.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 2024264
(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)))))