
(FPCore (wj x) :precision binary64 (let* ((t_0 (* wj (exp wj)))) (- wj (/ (- t_0 x) (+ (exp wj) t_0)))))
double code(double wj, double x) {
double t_0 = wj * exp(wj);
return wj - ((t_0 - x) / (exp(wj) + t_0));
}
real(8) function code(wj, x)
use fmin_fmax_functions
real(8), intent (in) :: wj
real(8), intent (in) :: x
real(8) :: t_0
t_0 = wj * exp(wj)
code = wj - ((t_0 - x) / (exp(wj) + t_0))
end function
public static double code(double wj, double x) {
double t_0 = wj * Math.exp(wj);
return wj - ((t_0 - x) / (Math.exp(wj) + t_0));
}
def code(wj, x): t_0 = wj * math.exp(wj) return wj - ((t_0 - x) / (math.exp(wj) + t_0))
function code(wj, x) t_0 = Float64(wj * exp(wj)) return Float64(wj - Float64(Float64(t_0 - x) / Float64(exp(wj) + t_0))) end
function tmp = code(wj, x) t_0 = wj * exp(wj); tmp = wj - ((t_0 - x) / (exp(wj) + t_0)); end
code[wj_, x_] := Block[{t$95$0 = N[(wj * N[Exp[wj], $MachinePrecision]), $MachinePrecision]}, N[(wj - N[(N[(t$95$0 - x), $MachinePrecision] / N[(N[Exp[wj], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
t_0 := wj \cdot e^{wj}\\
wj - \frac{t\_0 - x}{e^{wj} + t\_0}
\end{array}
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (wj x) :precision binary64 (let* ((t_0 (* wj (exp wj)))) (- wj (/ (- t_0 x) (+ (exp wj) t_0)))))
double code(double wj, double x) {
double t_0 = wj * exp(wj);
return wj - ((t_0 - x) / (exp(wj) + t_0));
}
real(8) function code(wj, x)
use fmin_fmax_functions
real(8), intent (in) :: wj
real(8), intent (in) :: x
real(8) :: t_0
t_0 = wj * exp(wj)
code = wj - ((t_0 - x) / (exp(wj) + t_0))
end function
public static double code(double wj, double x) {
double t_0 = wj * Math.exp(wj);
return wj - ((t_0 - x) / (Math.exp(wj) + t_0));
}
def code(wj, x): t_0 = wj * math.exp(wj) return wj - ((t_0 - x) / (math.exp(wj) + t_0))
function code(wj, x) t_0 = Float64(wj * exp(wj)) return Float64(wj - Float64(Float64(t_0 - x) / Float64(exp(wj) + t_0))) end
function tmp = code(wj, x) t_0 = wj * exp(wj); tmp = wj - ((t_0 - x) / (exp(wj) + t_0)); end
code[wj_, x_] := Block[{t$95$0 = N[(wj * N[Exp[wj], $MachinePrecision]), $MachinePrecision]}, N[(wj - N[(N[(t$95$0 - x), $MachinePrecision] / N[(N[Exp[wj], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
t_0 := wj \cdot e^{wj}\\
wj - \frac{t\_0 - x}{e^{wj} + t\_0}
\end{array}
(FPCore (wj x)
:precision binary64
(let* ((t_0 (- 0.0 (* 0.0 (- 1.0 (* -2.0 x))))))
(if (<= wj -0.102)
t_0
(if (<= wj 155000.0)
(fma
(fma
(fma
x
2.5
(-
1.0
(fma
(fma -3.0 x (fma x 5.0 (* 0.6666666666666666 x)))
wj
wj)))
wj
(* -2.0 x))
wj
x)
t_0))))double code(double wj, double x) {
double t_0 = 0.0 - (0.0 * (1.0 - (-2.0 * x)));
double tmp;
if (wj <= -0.102) {
tmp = t_0;
} else if (wj <= 155000.0) {
tmp = fma(fma(fma(x, 2.5, (1.0 - fma(fma(-3.0, x, fma(x, 5.0, (0.6666666666666666 * x))), wj, wj))), wj, (-2.0 * x)), wj, x);
} else {
tmp = t_0;
}
return tmp;
}
function code(wj, x) t_0 = Float64(0.0 - Float64(0.0 * Float64(1.0 - Float64(-2.0 * x)))) tmp = 0.0 if (wj <= -0.102) tmp = t_0; elseif (wj <= 155000.0) tmp = fma(fma(fma(x, 2.5, Float64(1.0 - fma(fma(-3.0, x, fma(x, 5.0, Float64(0.6666666666666666 * x))), wj, wj))), wj, Float64(-2.0 * x)), wj, x); else tmp = t_0; end return tmp end
code[wj_, x_] := Block[{t$95$0 = N[(0.0 - N[(0.0 * N[(1.0 - N[(-2.0 * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[wj, -0.102], t$95$0, If[LessEqual[wj, 155000.0], N[(N[(N[(x * 2.5 + N[(1.0 - N[(N[(-3.0 * x + N[(x * 5.0 + N[(0.6666666666666666 * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * wj + wj), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * wj + N[(-2.0 * x), $MachinePrecision]), $MachinePrecision] * wj + x), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := 0 - 0 \cdot \left(1 - -2 \cdot x\right)\\
\mathbf{if}\;wj \leq -0.102:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;wj \leq 155000:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x, 2.5, 1 - \mathsf{fma}\left(\mathsf{fma}\left(-3, x, \mathsf{fma}\left(x, 5, 0.6666666666666666 \cdot x\right)\right), wj, wj\right)\right), wj, -2 \cdot x\right), wj, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if wj < -0.10199999999999999 or 155000 < wj Initial program 41.1%
Taylor expanded in wj around 0
lower-fma.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f6462.6%
Applied rewrites62.6%
Taylor expanded in wj around 0
lower-*.f6439.0%
Applied rewrites39.0%
Taylor expanded in wj around inf
lower-*.f64N/A
lower--.f64N/A
lower-*.f6425.3%
Applied rewrites25.3%
Taylor expanded in undef-var around zero
Applied rewrites3.1%
Taylor expanded in undef-var around zero
Applied rewrites49.8%
if -0.10199999999999999 < wj < 155000Initial program 41.1%
Taylor expanded in wj around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
Applied rewrites51.1%
Applied rewrites51.1%
(FPCore (wj x)
:precision binary64
(let* ((t_0 (- 0.0 (* 0.0 (- 1.0 (* -2.0 x))))))
(if (<= wj -0.102)
t_0
(if (<= wj 155000.0)
(+ x (* wj (- (* wj (+ 1.0 (* -1.0 wj))) (* 2.0 x))))
t_0))))double code(double wj, double x) {
double t_0 = 0.0 - (0.0 * (1.0 - (-2.0 * x)));
double tmp;
if (wj <= -0.102) {
tmp = t_0;
} else if (wj <= 155000.0) {
tmp = x + (wj * ((wj * (1.0 + (-1.0 * wj))) - (2.0 * x)));
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(wj, x)
use fmin_fmax_functions
real(8), intent (in) :: wj
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = 0.0d0 - (0.0d0 * (1.0d0 - ((-2.0d0) * x)))
if (wj <= (-0.102d0)) then
tmp = t_0
else if (wj <= 155000.0d0) then
tmp = x + (wj * ((wj * (1.0d0 + ((-1.0d0) * wj))) - (2.0d0 * x)))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double wj, double x) {
double t_0 = 0.0 - (0.0 * (1.0 - (-2.0 * x)));
double tmp;
if (wj <= -0.102) {
tmp = t_0;
} else if (wj <= 155000.0) {
tmp = x + (wj * ((wj * (1.0 + (-1.0 * wj))) - (2.0 * x)));
} else {
tmp = t_0;
}
return tmp;
}
def code(wj, x): t_0 = 0.0 - (0.0 * (1.0 - (-2.0 * x))) tmp = 0 if wj <= -0.102: tmp = t_0 elif wj <= 155000.0: tmp = x + (wj * ((wj * (1.0 + (-1.0 * wj))) - (2.0 * x))) else: tmp = t_0 return tmp
function code(wj, x) t_0 = Float64(0.0 - Float64(0.0 * Float64(1.0 - Float64(-2.0 * x)))) tmp = 0.0 if (wj <= -0.102) tmp = t_0; elseif (wj <= 155000.0) tmp = Float64(x + Float64(wj * Float64(Float64(wj * Float64(1.0 + Float64(-1.0 * wj))) - Float64(2.0 * x)))); else tmp = t_0; end return tmp end
function tmp_2 = code(wj, x) t_0 = 0.0 - (0.0 * (1.0 - (-2.0 * x))); tmp = 0.0; if (wj <= -0.102) tmp = t_0; elseif (wj <= 155000.0) tmp = x + (wj * ((wj * (1.0 + (-1.0 * wj))) - (2.0 * x))); else tmp = t_0; end tmp_2 = tmp; end
code[wj_, x_] := Block[{t$95$0 = N[(0.0 - N[(0.0 * N[(1.0 - N[(-2.0 * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[wj, -0.102], t$95$0, If[LessEqual[wj, 155000.0], N[(x + N[(wj * N[(N[(wj * N[(1.0 + N[(-1.0 * wj), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(2.0 * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := 0 - 0 \cdot \left(1 - -2 \cdot x\right)\\
\mathbf{if}\;wj \leq -0.102:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;wj \leq 155000:\\
\;\;\;\;x + wj \cdot \left(wj \cdot \left(1 + -1 \cdot wj\right) - 2 \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if wj < -0.10199999999999999 or 155000 < wj Initial program 41.1%
Taylor expanded in wj around 0
lower-fma.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f6462.6%
Applied rewrites62.6%
Taylor expanded in wj around 0
lower-*.f6439.0%
Applied rewrites39.0%
Taylor expanded in wj around inf
lower-*.f64N/A
lower--.f64N/A
lower-*.f6425.3%
Applied rewrites25.3%
Taylor expanded in undef-var around zero
Applied rewrites3.1%
Taylor expanded in undef-var around zero
Applied rewrites49.8%
if -0.10199999999999999 < wj < 155000Initial program 41.1%
Taylor expanded in wj around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
Applied rewrites51.1%
Taylor expanded in x around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6451.0%
Applied rewrites51.0%
(FPCore (wj x)
:precision binary64
(let* ((t_0 (- 0.0 (* 0.0 (- 1.0 (* -2.0 x))))))
(if (<= wj -0.102)
t_0
(if (<= wj 0.00021) (fma (* wj (- 1.0 wj)) wj x) t_0))))double code(double wj, double x) {
double t_0 = 0.0 - (0.0 * (1.0 - (-2.0 * x)));
double tmp;
if (wj <= -0.102) {
tmp = t_0;
} else if (wj <= 0.00021) {
tmp = fma((wj * (1.0 - wj)), wj, x);
} else {
tmp = t_0;
}
return tmp;
}
function code(wj, x) t_0 = Float64(0.0 - Float64(0.0 * Float64(1.0 - Float64(-2.0 * x)))) tmp = 0.0 if (wj <= -0.102) tmp = t_0; elseif (wj <= 0.00021) tmp = fma(Float64(wj * Float64(1.0 - wj)), wj, x); else tmp = t_0; end return tmp end
code[wj_, x_] := Block[{t$95$0 = N[(0.0 - N[(0.0 * N[(1.0 - N[(-2.0 * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[wj, -0.102], t$95$0, If[LessEqual[wj, 0.00021], N[(N[(wj * N[(1.0 - wj), $MachinePrecision]), $MachinePrecision] * wj + x), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := 0 - 0 \cdot \left(1 - -2 \cdot x\right)\\
\mathbf{if}\;wj \leq -0.102:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;wj \leq 0.00021:\\
\;\;\;\;\mathsf{fma}\left(wj \cdot \left(1 - wj\right), wj, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if wj < -0.10199999999999999 or 2.1000000000000001e-4 < wj Initial program 41.1%
Taylor expanded in wj around 0
lower-fma.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f6462.6%
Applied rewrites62.6%
Taylor expanded in wj around 0
lower-*.f6439.0%
Applied rewrites39.0%
Taylor expanded in wj around inf
lower-*.f64N/A
lower--.f64N/A
lower-*.f6425.3%
Applied rewrites25.3%
Taylor expanded in undef-var around zero
Applied rewrites3.1%
Taylor expanded in undef-var around zero
Applied rewrites49.8%
if -0.10199999999999999 < wj < 2.1000000000000001e-4Initial program 41.1%
Taylor expanded in wj around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
Applied rewrites51.1%
Applied rewrites51.1%
Taylor expanded in x around 0
lower-*.f64N/A
lower--.f6450.7%
Applied rewrites50.7%
(FPCore (wj x)
:precision binary64
(if (<= wj -0.102)
(- 0.0 (* 0.0 (- 1.0 (* -2.0 x))))
(if (<= wj 400.0)
(fma (* wj (- 1.0 wj)) wj x)
(/ x (* wj (exp wj))))))double code(double wj, double x) {
double tmp;
if (wj <= -0.102) {
tmp = 0.0 - (0.0 * (1.0 - (-2.0 * x)));
} else if (wj <= 400.0) {
tmp = fma((wj * (1.0 - wj)), wj, x);
} else {
tmp = x / (wj * exp(wj));
}
return tmp;
}
function code(wj, x) tmp = 0.0 if (wj <= -0.102) tmp = Float64(0.0 - Float64(0.0 * Float64(1.0 - Float64(-2.0 * x)))); elseif (wj <= 400.0) tmp = fma(Float64(wj * Float64(1.0 - wj)), wj, x); else tmp = Float64(x / Float64(wj * exp(wj))); end return tmp end
code[wj_, x_] := If[LessEqual[wj, -0.102], N[(0.0 - N[(0.0 * N[(1.0 - N[(-2.0 * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[wj, 400.0], N[(N[(wj * N[(1.0 - wj), $MachinePrecision]), $MachinePrecision] * wj + x), $MachinePrecision], N[(x / N[(wj * N[Exp[wj], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;wj \leq -0.102:\\
\;\;\;\;0 - 0 \cdot \left(1 - -2 \cdot x\right)\\
\mathbf{elif}\;wj \leq 400:\\
\;\;\;\;\mathsf{fma}\left(wj \cdot \left(1 - wj\right), wj, x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{wj \cdot e^{wj}}\\
\end{array}
if wj < -0.10199999999999999Initial program 41.1%
Taylor expanded in wj around 0
lower-fma.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f6462.6%
Applied rewrites62.6%
Taylor expanded in wj around 0
lower-*.f6439.0%
Applied rewrites39.0%
Taylor expanded in wj around inf
lower-*.f64N/A
lower--.f64N/A
lower-*.f6425.3%
Applied rewrites25.3%
Taylor expanded in undef-var around zero
Applied rewrites3.1%
Taylor expanded in undef-var around zero
Applied rewrites49.8%
if -0.10199999999999999 < wj < 400Initial program 41.1%
Taylor expanded in wj around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
Applied rewrites51.1%
Applied rewrites51.1%
Taylor expanded in x around 0
lower-*.f64N/A
lower--.f6450.7%
Applied rewrites50.7%
if 400 < wj Initial program 41.1%
Taylor expanded in x around inf
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-*.f64N/A
lower-exp.f6469.4%
Applied rewrites69.4%
Taylor expanded in wj around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6488.4%
Applied rewrites88.4%
Taylor expanded in wj around inf
lower-/.f64N/A
lower-*.f64N/A
lower-exp.f6427.0%
Applied rewrites27.0%
(FPCore (wj x)
:precision binary64
(let* ((t_0 (- wj (* (+ 1.0 (+ x x)) wj))))
(if (<= wj -0.49)
t_0
(if (<= wj 95000.0) (fma (* wj (- 1.0 wj)) wj x) t_0))))double code(double wj, double x) {
double t_0 = wj - ((1.0 + (x + x)) * wj);
double tmp;
if (wj <= -0.49) {
tmp = t_0;
} else if (wj <= 95000.0) {
tmp = fma((wj * (1.0 - wj)), wj, x);
} else {
tmp = t_0;
}
return tmp;
}
function code(wj, x) t_0 = Float64(wj - Float64(Float64(1.0 + Float64(x + x)) * wj)) tmp = 0.0 if (wj <= -0.49) tmp = t_0; elseif (wj <= 95000.0) tmp = fma(Float64(wj * Float64(1.0 - wj)), wj, x); else tmp = t_0; end return tmp end
code[wj_, x_] := Block[{t$95$0 = N[(wj - N[(N[(1.0 + N[(x + x), $MachinePrecision]), $MachinePrecision] * wj), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[wj, -0.49], t$95$0, If[LessEqual[wj, 95000.0], N[(N[(wj * N[(1.0 - wj), $MachinePrecision]), $MachinePrecision] * wj + x), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := wj - \left(1 + \left(x + x\right)\right) \cdot wj\\
\mathbf{if}\;wj \leq -0.49:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;wj \leq 95000:\\
\;\;\;\;\mathsf{fma}\left(wj \cdot \left(1 - wj\right), wj, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if wj < -0.48999999999999999 or 95000 < wj Initial program 41.1%
Taylor expanded in wj around 0
lower-fma.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f6462.6%
Applied rewrites62.6%
Taylor expanded in wj around 0
lower-*.f6439.0%
Applied rewrites39.0%
Taylor expanded in wj around inf
lower-*.f64N/A
lower--.f64N/A
lower-*.f6425.3%
Applied rewrites25.3%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6425.3%
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
lower-+.f64N/A
count-2-revN/A
lower-+.f6425.3%
Applied rewrites25.3%
if -0.48999999999999999 < wj < 95000Initial program 41.1%
Taylor expanded in wj around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
Applied rewrites51.1%
Applied rewrites51.1%
Taylor expanded in x around 0
lower-*.f64N/A
lower--.f6450.7%
Applied rewrites50.7%
(FPCore (wj x)
:precision binary64
(let* ((t_0 (* wj (exp wj)))
(t_1 (- wj (/ (- t_0 x) (+ (exp wj) t_0))))
(t_2 (/ x (+ 1.0 (* 2.0 wj)))))
(if (<= t_1 -2e+76)
t_2
(if (<= t_1 5e-8) (fma (* wj (- 1.0 wj)) wj x) t_2))))double code(double wj, double x) {
double t_0 = wj * exp(wj);
double t_1 = wj - ((t_0 - x) / (exp(wj) + t_0));
double t_2 = x / (1.0 + (2.0 * wj));
double tmp;
if (t_1 <= -2e+76) {
tmp = t_2;
} else if (t_1 <= 5e-8) {
tmp = fma((wj * (1.0 - wj)), wj, x);
} else {
tmp = t_2;
}
return tmp;
}
function code(wj, x) t_0 = Float64(wj * exp(wj)) t_1 = Float64(wj - Float64(Float64(t_0 - x) / Float64(exp(wj) + t_0))) t_2 = Float64(x / Float64(1.0 + Float64(2.0 * wj))) tmp = 0.0 if (t_1 <= -2e+76) tmp = t_2; elseif (t_1 <= 5e-8) tmp = fma(Float64(wj * Float64(1.0 - wj)), wj, x); else tmp = t_2; end return tmp end
code[wj_, x_] := Block[{t$95$0 = N[(wj * N[Exp[wj], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(wj - N[(N[(t$95$0 - x), $MachinePrecision] / N[(N[Exp[wj], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(x / N[(1.0 + N[(2.0 * wj), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -2e+76], t$95$2, If[LessEqual[t$95$1, 5e-8], N[(N[(wj * N[(1.0 - wj), $MachinePrecision]), $MachinePrecision] * wj + x), $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
t_0 := wj \cdot e^{wj}\\
t_1 := wj - \frac{t\_0 - x}{e^{wj} + t\_0}\\
t_2 := \frac{x}{1 + 2 \cdot wj}\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{+76}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-8}:\\
\;\;\;\;\mathsf{fma}\left(wj \cdot \left(1 - wj\right), wj, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
if (-.f64 wj (/.f64 (-.f64 (*.f64 wj (exp.f64 wj)) x) (+.f64 (exp.f64 wj) (*.f64 wj (exp.f64 wj))))) < -2.0000000000000001e76 or 4.9999999999999998e-8 < (-.f64 wj (/.f64 (-.f64 (*.f64 wj (exp.f64 wj)) x) (+.f64 (exp.f64 wj) (*.f64 wj (exp.f64 wj))))) Initial program 41.1%
Taylor expanded in x around inf
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-*.f64N/A
lower-exp.f6469.4%
Applied rewrites69.4%
Taylor expanded in wj around 0
lower-+.f64N/A
lower-*.f6458.1%
Applied rewrites58.1%
if -2.0000000000000001e76 < (-.f64 wj (/.f64 (-.f64 (*.f64 wj (exp.f64 wj)) x) (+.f64 (exp.f64 wj) (*.f64 wj (exp.f64 wj))))) < 4.9999999999999998e-8Initial program 41.1%
Taylor expanded in wj around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
Applied rewrites51.1%
Applied rewrites51.1%
Taylor expanded in x around 0
lower-*.f64N/A
lower--.f6450.7%
Applied rewrites50.7%
(FPCore (wj x) :precision binary64 (/ x (+ 1.0 (* 2.0 wj))))
double code(double wj, double x) {
return x / (1.0 + (2.0 * wj));
}
real(8) function code(wj, x)
use fmin_fmax_functions
real(8), intent (in) :: wj
real(8), intent (in) :: x
code = x / (1.0d0 + (2.0d0 * wj))
end function
public static double code(double wj, double x) {
return x / (1.0 + (2.0 * wj));
}
def code(wj, x): return x / (1.0 + (2.0 * wj))
function code(wj, x) return Float64(x / Float64(1.0 + Float64(2.0 * wj))) end
function tmp = code(wj, x) tmp = x / (1.0 + (2.0 * wj)); end
code[wj_, x_] := N[(x / N[(1.0 + N[(2.0 * wj), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{x}{1 + 2 \cdot wj}
Initial program 41.1%
Taylor expanded in x around inf
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-*.f64N/A
lower-exp.f6469.4%
Applied rewrites69.4%
Taylor expanded in wj around 0
lower-+.f64N/A
lower-*.f6458.1%
Applied rewrites58.1%
(FPCore (wj x) :precision binary64 x)
double code(double wj, double x) {
return x;
}
real(8) function code(wj, x)
use fmin_fmax_functions
real(8), intent (in) :: wj
real(8), intent (in) :: x
code = x
end function
public static double code(double wj, double x) {
return x;
}
def code(wj, x): return x
function code(wj, x) return x end
function tmp = code(wj, x) tmp = x; end
code[wj_, x_] := x
x
Initial program 41.1%
Taylor expanded in wj around 0
Applied rewrites45.9%
(FPCore (wj x) :precision binary64 (- wj (- (/ wj (+ wj 1.0)) (/ x (+ (exp wj) (* wj (exp wj)))))))
double code(double wj, double x) {
return wj - ((wj / (wj + 1.0)) - (x / (exp(wj) + (wj * exp(wj)))));
}
real(8) function code(wj, x)
use fmin_fmax_functions
real(8), intent (in) :: wj
real(8), intent (in) :: x
code = wj - ((wj / (wj + 1.0d0)) - (x / (exp(wj) + (wj * exp(wj)))))
end function
public static double code(double wj, double x) {
return wj - ((wj / (wj + 1.0)) - (x / (Math.exp(wj) + (wj * Math.exp(wj)))));
}
def code(wj, x): return wj - ((wj / (wj + 1.0)) - (x / (math.exp(wj) + (wj * math.exp(wj)))))
function code(wj, x) return Float64(wj - Float64(Float64(wj / Float64(wj + 1.0)) - Float64(x / Float64(exp(wj) + Float64(wj * exp(wj)))))) end
function tmp = code(wj, x) tmp = wj - ((wj / (wj + 1.0)) - (x / (exp(wj) + (wj * exp(wj))))); end
code[wj_, x_] := N[(wj - N[(N[(wj / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision] - N[(x / N[(N[Exp[wj], $MachinePrecision] + N[(wj * N[Exp[wj], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
wj - \left(\frac{wj}{wj + 1} - \frac{x}{e^{wj} + wj \cdot e^{wj}}\right)
herbie shell --seed 2025313 -o setup:search
(FPCore (wj x)
:name "Jmat.Real.lambertw, newton loop step"
:precision binary64
:alt
(! :herbie-platform c (let ((ew (exp wj))) (- wj (- (/ wj (+ wj 1)) (/ x (+ ew (* wj ew)))))))
(- wj (/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj))))))