
(FPCore (c x y) :precision binary64 (* c (log (+ 1.0 (* (- (pow E x) 1.0) y)))))
double code(double c, double x, double y) {
return c * log((1.0 + ((pow(((double) M_E), x) - 1.0) * y)));
}
public static double code(double c, double x, double y) {
return c * Math.log((1.0 + ((Math.pow(Math.E, x) - 1.0) * y)));
}
def code(c, x, y): return c * math.log((1.0 + ((math.pow(math.e, x) - 1.0) * y)))
function code(c, x, y) return Float64(c * log(Float64(1.0 + Float64(Float64((exp(1) ^ x) - 1.0) * y)))) end
function tmp = code(c, x, y) tmp = c * log((1.0 + (((2.71828182845904523536 ^ x) - 1.0) * y))); end
code[c_, x_, y_] := N[(c * N[Log[N[(1.0 + N[(N[(N[Power[E, x], $MachinePrecision] - 1.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
c \cdot \log \left(1 + \left({e}^{x} - 1\right) \cdot y\right)
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (c x y) :precision binary64 (* c (log (+ 1.0 (* (- (pow E x) 1.0) y)))))
double code(double c, double x, double y) {
return c * log((1.0 + ((pow(((double) M_E), x) - 1.0) * y)));
}
public static double code(double c, double x, double y) {
return c * Math.log((1.0 + ((Math.pow(Math.E, x) - 1.0) * y)));
}
def code(c, x, y): return c * math.log((1.0 + ((math.pow(math.e, x) - 1.0) * y)))
function code(c, x, y) return Float64(c * log(Float64(1.0 + Float64(Float64((exp(1) ^ x) - 1.0) * y)))) end
function tmp = code(c, x, y) tmp = c * log((1.0 + (((2.71828182845904523536 ^ x) - 1.0) * y))); end
code[c_, x_, y_] := N[(c * N[Log[N[(1.0 + N[(N[(N[Power[E, x], $MachinePrecision] - 1.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
c \cdot \log \left(1 + \left({e}^{x} - 1\right) \cdot y\right)
(FPCore (c x y)
:precision binary64
(if (<= y -8.2e+46)
(* (log (fma y (expm1 x) 1.0)) c)
(if (<= y 0.03)
(* (* (expm1 x) c) y)
(if (<= y 2.7e+228)
(* c (* x y))
(*
(log
(fma
y
(*
x
(+
1.0
(*
x
(+
0.5
(*
x
(+ 0.16666666666666666 (* 0.041666666666666664 x)))))))
1.0))
c)))))double code(double c, double x, double y) {
double tmp;
if (y <= -8.2e+46) {
tmp = log(fma(y, expm1(x), 1.0)) * c;
} else if (y <= 0.03) {
tmp = (expm1(x) * c) * y;
} else if (y <= 2.7e+228) {
tmp = c * (x * y);
} else {
tmp = log(fma(y, (x * (1.0 + (x * (0.5 + (x * (0.16666666666666666 + (0.041666666666666664 * x))))))), 1.0)) * c;
}
return tmp;
}
function code(c, x, y) tmp = 0.0 if (y <= -8.2e+46) tmp = Float64(log(fma(y, expm1(x), 1.0)) * c); elseif (y <= 0.03) tmp = Float64(Float64(expm1(x) * c) * y); elseif (y <= 2.7e+228) tmp = Float64(c * Float64(x * y)); else tmp = Float64(log(fma(y, Float64(x * Float64(1.0 + Float64(x * Float64(0.5 + Float64(x * Float64(0.16666666666666666 + Float64(0.041666666666666664 * x))))))), 1.0)) * c); end return tmp end
code[c_, x_, y_] := If[LessEqual[y, -8.2e+46], N[(N[Log[N[(y * N[(Exp[x] - 1), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision] * c), $MachinePrecision], If[LessEqual[y, 0.03], N[(N[(N[(Exp[x] - 1), $MachinePrecision] * c), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[y, 2.7e+228], N[(c * N[(x * y), $MachinePrecision]), $MachinePrecision], N[(N[Log[N[(y * N[(x * N[(1.0 + N[(x * N[(0.5 + N[(x * N[(0.16666666666666666 + N[(0.041666666666666664 * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision] * c), $MachinePrecision]]]]
\begin{array}{l}
\mathbf{if}\;y \leq -8.2 \cdot 10^{+46}:\\
\;\;\;\;\log \left(\mathsf{fma}\left(y, \mathsf{expm1}\left(x\right), 1\right)\right) \cdot c\\
\mathbf{elif}\;y \leq 0.03:\\
\;\;\;\;\left(\mathsf{expm1}\left(x\right) \cdot c\right) \cdot y\\
\mathbf{elif}\;y \leq 2.7 \cdot 10^{+228}:\\
\;\;\;\;c \cdot \left(x \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;\log \left(\mathsf{fma}\left(y, x \cdot \left(1 + x \cdot \left(0.5 + x \cdot \left(0.16666666666666666 + 0.041666666666666664 \cdot x\right)\right)\right), 1\right)\right) \cdot c\\
\end{array}
if y < -8.2e46Initial program 41.7%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6441.7%
Applied rewrites51.7%
if -8.2e46 < y < 0.029999999999999999Initial program 41.7%
Taylor expanded in y around 0
lower-*.f64N/A
lower-*.f64N/A
lower-expm1.f6473.7%
Applied rewrites73.7%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6476.7%
Applied rewrites76.7%
if 0.029999999999999999 < y < 2.7000000000000002e228Initial program 41.7%
Taylor expanded in x around 0
lower-*.f64N/A
lower-*.f6456.0%
Applied rewrites56.0%
if 2.7000000000000002e228 < y Initial program 41.7%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6441.7%
Applied rewrites51.7%
Taylor expanded in x around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6436.7%
Applied rewrites36.7%
(FPCore (c x y)
:precision binary64
(let* ((t_0 (* (log (fma y (expm1 x) 1.0)) c)))
(if (<= y -8.2e+46)
t_0
(if (<= y 0.03)
(* (* (expm1 x) c) y)
(if (<= y 3e+228) (* c (* x y)) t_0)))))double code(double c, double x, double y) {
double t_0 = log(fma(y, expm1(x), 1.0)) * c;
double tmp;
if (y <= -8.2e+46) {
tmp = t_0;
} else if (y <= 0.03) {
tmp = (expm1(x) * c) * y;
} else if (y <= 3e+228) {
tmp = c * (x * y);
} else {
tmp = t_0;
}
return tmp;
}
function code(c, x, y) t_0 = Float64(log(fma(y, expm1(x), 1.0)) * c) tmp = 0.0 if (y <= -8.2e+46) tmp = t_0; elseif (y <= 0.03) tmp = Float64(Float64(expm1(x) * c) * y); elseif (y <= 3e+228) tmp = Float64(c * Float64(x * y)); else tmp = t_0; end return tmp end
code[c_, x_, y_] := Block[{t$95$0 = N[(N[Log[N[(y * N[(Exp[x] - 1), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision] * c), $MachinePrecision]}, If[LessEqual[y, -8.2e+46], t$95$0, If[LessEqual[y, 0.03], N[(N[(N[(Exp[x] - 1), $MachinePrecision] * c), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[y, 3e+228], N[(c * N[(x * y), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
t_0 := \log \left(\mathsf{fma}\left(y, \mathsf{expm1}\left(x\right), 1\right)\right) \cdot c\\
\mathbf{if}\;y \leq -8.2 \cdot 10^{+46}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 0.03:\\
\;\;\;\;\left(\mathsf{expm1}\left(x\right) \cdot c\right) \cdot y\\
\mathbf{elif}\;y \leq 3 \cdot 10^{+228}:\\
\;\;\;\;c \cdot \left(x \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if y < -8.2e46 or 3.0000000000000001e228 < y Initial program 41.7%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6441.7%
Applied rewrites51.7%
if -8.2e46 < y < 0.029999999999999999Initial program 41.7%
Taylor expanded in y around 0
lower-*.f64N/A
lower-*.f64N/A
lower-expm1.f6473.7%
Applied rewrites73.7%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6476.7%
Applied rewrites76.7%
if 0.029999999999999999 < y < 3.0000000000000001e228Initial program 41.7%
Taylor expanded in x around 0
lower-*.f64N/A
lower-*.f6456.0%
Applied rewrites56.0%
(FPCore (c x y)
:precision binary64
(let* ((t_0 (* (log (fma y x 1.0)) c)))
(if (<= y -4.8e+131)
t_0
(if (<= y 0.03)
(* (* (expm1 x) c) y)
(if (<= y 3e+228) (* c (* x y)) t_0)))))double code(double c, double x, double y) {
double t_0 = log(fma(y, x, 1.0)) * c;
double tmp;
if (y <= -4.8e+131) {
tmp = t_0;
} else if (y <= 0.03) {
tmp = (expm1(x) * c) * y;
} else if (y <= 3e+228) {
tmp = c * (x * y);
} else {
tmp = t_0;
}
return tmp;
}
function code(c, x, y) t_0 = Float64(log(fma(y, x, 1.0)) * c) tmp = 0.0 if (y <= -4.8e+131) tmp = t_0; elseif (y <= 0.03) tmp = Float64(Float64(expm1(x) * c) * y); elseif (y <= 3e+228) tmp = Float64(c * Float64(x * y)); else tmp = t_0; end return tmp end
code[c_, x_, y_] := Block[{t$95$0 = N[(N[Log[N[(y * x + 1.0), $MachinePrecision]], $MachinePrecision] * c), $MachinePrecision]}, If[LessEqual[y, -4.8e+131], t$95$0, If[LessEqual[y, 0.03], N[(N[(N[(Exp[x] - 1), $MachinePrecision] * c), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[y, 3e+228], N[(c * N[(x * y), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
t_0 := \log \left(\mathsf{fma}\left(y, x, 1\right)\right) \cdot c\\
\mathbf{if}\;y \leq -4.8 \cdot 10^{+131}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 0.03:\\
\;\;\;\;\left(\mathsf{expm1}\left(x\right) \cdot c\right) \cdot y\\
\mathbf{elif}\;y \leq 3 \cdot 10^{+228}:\\
\;\;\;\;c \cdot \left(x \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if y < -4.7999999999999999e131 or 3.0000000000000001e228 < y Initial program 41.7%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6441.7%
Applied rewrites51.7%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f6440.2%
Applied rewrites40.2%
lift-+.f64N/A
+-commutativeN/A
remove-double-negN/A
mul-1-negN/A
metadata-evalN/A
metadata-evalN/A
mul-1-negN/A
remove-double-negN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6440.2%
Applied rewrites40.2%
if -4.7999999999999999e131 < y < 0.029999999999999999Initial program 41.7%
Taylor expanded in y around 0
lower-*.f64N/A
lower-*.f64N/A
lower-expm1.f6473.7%
Applied rewrites73.7%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6476.7%
Applied rewrites76.7%
if 0.029999999999999999 < y < 3.0000000000000001e228Initial program 41.7%
Taylor expanded in x around 0
lower-*.f64N/A
lower-*.f6456.0%
Applied rewrites56.0%
(FPCore (c x y) :precision binary64 (* (copysign 1.0 c) (if (<= (fabs c) 200000000000.0) (* (fabs c) (* y (expm1 x))) (* (* (expm1 x) (fabs c)) y))))
double code(double c, double x, double y) {
double tmp;
if (fabs(c) <= 200000000000.0) {
tmp = fabs(c) * (y * expm1(x));
} else {
tmp = (expm1(x) * fabs(c)) * y;
}
return copysign(1.0, c) * tmp;
}
public static double code(double c, double x, double y) {
double tmp;
if (Math.abs(c) <= 200000000000.0) {
tmp = Math.abs(c) * (y * Math.expm1(x));
} else {
tmp = (Math.expm1(x) * Math.abs(c)) * y;
}
return Math.copySign(1.0, c) * tmp;
}
def code(c, x, y): tmp = 0 if math.fabs(c) <= 200000000000.0: tmp = math.fabs(c) * (y * math.expm1(x)) else: tmp = (math.expm1(x) * math.fabs(c)) * y return math.copysign(1.0, c) * tmp
function code(c, x, y) tmp = 0.0 if (abs(c) <= 200000000000.0) tmp = Float64(abs(c) * Float64(y * expm1(x))); else tmp = Float64(Float64(expm1(x) * abs(c)) * y); end return Float64(copysign(1.0, c) * tmp) end
code[c_, x_, y_] := N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[c]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[Abs[c], $MachinePrecision], 200000000000.0], N[(N[Abs[c], $MachinePrecision] * N[(y * N[(Exp[x] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(Exp[x] - 1), $MachinePrecision] * N[Abs[c], $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]]), $MachinePrecision]
\mathsf{copysign}\left(1, c\right) \cdot \begin{array}{l}
\mathbf{if}\;\left|c\right| \leq 200000000000:\\
\;\;\;\;\left|c\right| \cdot \left(y \cdot \mathsf{expm1}\left(x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{expm1}\left(x\right) \cdot \left|c\right|\right) \cdot y\\
\end{array}
if c < 2e11Initial program 41.7%
Taylor expanded in y around 0
lower-*.f64N/A
lower-*.f64N/A
lower-expm1.f6473.7%
Applied rewrites73.7%
if 2e11 < c Initial program 41.7%
Taylor expanded in y around 0
lower-*.f64N/A
lower-*.f64N/A
lower-expm1.f6473.7%
Applied rewrites73.7%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6476.7%
Applied rewrites76.7%
(FPCore (c x y) :precision binary64 (if (<= x -2e-27) (* c (* y (expm1 x))) (* (* x c) y)))
double code(double c, double x, double y) {
double tmp;
if (x <= -2e-27) {
tmp = c * (y * expm1(x));
} else {
tmp = (x * c) * y;
}
return tmp;
}
public static double code(double c, double x, double y) {
double tmp;
if (x <= -2e-27) {
tmp = c * (y * Math.expm1(x));
} else {
tmp = (x * c) * y;
}
return tmp;
}
def code(c, x, y): tmp = 0 if x <= -2e-27: tmp = c * (y * math.expm1(x)) else: tmp = (x * c) * y return tmp
function code(c, x, y) tmp = 0.0 if (x <= -2e-27) tmp = Float64(c * Float64(y * expm1(x))); else tmp = Float64(Float64(x * c) * y); end return tmp end
code[c_, x_, y_] := If[LessEqual[x, -2e-27], N[(c * N[(y * N[(Exp[x] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * c), $MachinePrecision] * y), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;x \leq -2 \cdot 10^{-27}:\\
\;\;\;\;c \cdot \left(y \cdot \mathsf{expm1}\left(x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot c\right) \cdot y\\
\end{array}
if x < -2.0000000000000001e-27Initial program 41.7%
Taylor expanded in y around 0
lower-*.f64N/A
lower-*.f64N/A
lower-expm1.f6473.7%
Applied rewrites73.7%
if -2.0000000000000001e-27 < x Initial program 41.7%
Taylor expanded in x around 0
lower-*.f64N/A
lower-*.f6456.0%
Applied rewrites56.0%
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6459.0%
Applied rewrites59.0%
(FPCore (c x y) :precision binary64 (* (copysign 1.0 c) (if (<= (fabs c) 1e-18) (* (* y (fabs c)) x) (* (* x (fabs c)) y))))
double code(double c, double x, double y) {
double tmp;
if (fabs(c) <= 1e-18) {
tmp = (y * fabs(c)) * x;
} else {
tmp = (x * fabs(c)) * y;
}
return copysign(1.0, c) * tmp;
}
public static double code(double c, double x, double y) {
double tmp;
if (Math.abs(c) <= 1e-18) {
tmp = (y * Math.abs(c)) * x;
} else {
tmp = (x * Math.abs(c)) * y;
}
return Math.copySign(1.0, c) * tmp;
}
def code(c, x, y): tmp = 0 if math.fabs(c) <= 1e-18: tmp = (y * math.fabs(c)) * x else: tmp = (x * math.fabs(c)) * y return math.copysign(1.0, c) * tmp
function code(c, x, y) tmp = 0.0 if (abs(c) <= 1e-18) tmp = Float64(Float64(y * abs(c)) * x); else tmp = Float64(Float64(x * abs(c)) * y); end return Float64(copysign(1.0, c) * tmp) end
function tmp_2 = code(c, x, y) tmp = 0.0; if (abs(c) <= 1e-18) tmp = (y * abs(c)) * x; else tmp = (x * abs(c)) * y; end tmp_2 = (sign(c) * abs(1.0)) * tmp; end
code[c_, x_, y_] := N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[c]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[Abs[c], $MachinePrecision], 1e-18], N[(N[(y * N[Abs[c], $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], N[(N[(x * N[Abs[c], $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]]), $MachinePrecision]
\mathsf{copysign}\left(1, c\right) \cdot \begin{array}{l}
\mathbf{if}\;\left|c\right| \leq 10^{-18}:\\
\;\;\;\;\left(y \cdot \left|c\right|\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot \left|c\right|\right) \cdot y\\
\end{array}
if c < 1.0000000000000001e-18Initial program 41.7%
Taylor expanded in x around 0
lower-*.f64N/A
lower-*.f6456.0%
Applied rewrites56.0%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6461.6%
Applied rewrites61.6%
if 1.0000000000000001e-18 < c Initial program 41.7%
Taylor expanded in x around 0
lower-*.f64N/A
lower-*.f6456.0%
Applied rewrites56.0%
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6459.0%
Applied rewrites59.0%
(FPCore (c x y) :precision binary64 (if (<= x -7e+71) (* 0.0 (* x y)) (* (* x c) y)))
double code(double c, double x, double y) {
double tmp;
if (x <= -7e+71) {
tmp = 0.0 * (x * y);
} else {
tmp = (x * c) * y;
}
return tmp;
}
real(8) function code(c, x, y)
use fmin_fmax_functions
real(8), intent (in) :: c
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-7d+71)) then
tmp = 0.0d0 * (x * y)
else
tmp = (x * c) * y
end if
code = tmp
end function
public static double code(double c, double x, double y) {
double tmp;
if (x <= -7e+71) {
tmp = 0.0 * (x * y);
} else {
tmp = (x * c) * y;
}
return tmp;
}
def code(c, x, y): tmp = 0 if x <= -7e+71: tmp = 0.0 * (x * y) else: tmp = (x * c) * y return tmp
function code(c, x, y) tmp = 0.0 if (x <= -7e+71) tmp = Float64(0.0 * Float64(x * y)); else tmp = Float64(Float64(x * c) * y); end return tmp end
function tmp_2 = code(c, x, y) tmp = 0.0; if (x <= -7e+71) tmp = 0.0 * (x * y); else tmp = (x * c) * y; end tmp_2 = tmp; end
code[c_, x_, y_] := If[LessEqual[x, -7e+71], N[(0.0 * N[(x * y), $MachinePrecision]), $MachinePrecision], N[(N[(x * c), $MachinePrecision] * y), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;x \leq -7 \cdot 10^{+71}:\\
\;\;\;\;0 \cdot \left(x \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot c\right) \cdot y\\
\end{array}
if x < -6.9999999999999998e71Initial program 41.7%
Taylor expanded in x around 0
lower-*.f64N/A
lower-*.f6456.0%
Applied rewrites56.0%
Taylor expanded in undef-var around zero
Applied rewrites30.6%
if -6.9999999999999998e71 < x Initial program 41.7%
Taylor expanded in x around 0
lower-*.f64N/A
lower-*.f6456.0%
Applied rewrites56.0%
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6459.0%
Applied rewrites59.0%
(FPCore (c x y) :precision binary64 (if (<= x -7e+71) (* 0.0 (* x y)) (* c (* x y))))
double code(double c, double x, double y) {
double tmp;
if (x <= -7e+71) {
tmp = 0.0 * (x * y);
} else {
tmp = c * (x * y);
}
return tmp;
}
real(8) function code(c, x, y)
use fmin_fmax_functions
real(8), intent (in) :: c
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-7d+71)) then
tmp = 0.0d0 * (x * y)
else
tmp = c * (x * y)
end if
code = tmp
end function
public static double code(double c, double x, double y) {
double tmp;
if (x <= -7e+71) {
tmp = 0.0 * (x * y);
} else {
tmp = c * (x * y);
}
return tmp;
}
def code(c, x, y): tmp = 0 if x <= -7e+71: tmp = 0.0 * (x * y) else: tmp = c * (x * y) return tmp
function code(c, x, y) tmp = 0.0 if (x <= -7e+71) tmp = Float64(0.0 * Float64(x * y)); else tmp = Float64(c * Float64(x * y)); end return tmp end
function tmp_2 = code(c, x, y) tmp = 0.0; if (x <= -7e+71) tmp = 0.0 * (x * y); else tmp = c * (x * y); end tmp_2 = tmp; end
code[c_, x_, y_] := If[LessEqual[x, -7e+71], N[(0.0 * N[(x * y), $MachinePrecision]), $MachinePrecision], N[(c * N[(x * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;x \leq -7 \cdot 10^{+71}:\\
\;\;\;\;0 \cdot \left(x \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;c \cdot \left(x \cdot y\right)\\
\end{array}
if x < -6.9999999999999998e71Initial program 41.7%
Taylor expanded in x around 0
lower-*.f64N/A
lower-*.f6456.0%
Applied rewrites56.0%
Taylor expanded in undef-var around zero
Applied rewrites30.6%
if -6.9999999999999998e71 < x Initial program 41.7%
Taylor expanded in x around 0
lower-*.f64N/A
lower-*.f6456.0%
Applied rewrites56.0%
(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)
use fmin_fmax_functions
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(c * Float64(x * y)) end
function tmp = code(c, x, y) tmp = c * (x * y); end
code[c_, x_, y_] := N[(c * N[(x * y), $MachinePrecision]), $MachinePrecision]
c \cdot \left(x \cdot y\right)
Initial program 41.7%
Taylor expanded in x around 0
lower-*.f64N/A
lower-*.f6456.0%
Applied rewrites56.0%
(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]
c \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(x\right) \cdot y\right)
herbie shell --seed 2025322
(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)))))