
(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)
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}
\\
\begin{array}{l}
t_0 := wj \cdot e^{wj}\\
wj - \frac{t_0 - x}{e^{wj} + t_0}
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 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)
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}
\\
\begin{array}{l}
t_0 := wj \cdot e^{wj}\\
wj - \frac{t_0 - x}{e^{wj} + t_0}
\end{array}
\end{array}
(FPCore (wj x)
:precision binary64
(let* ((t_0 (+ (* x -4.0) (* x 1.5))))
(if (<= wj 6.2e-6)
(+
x
(+
(* -2.0 (* wj x))
(+
(*
(pow wj 3.0)
(- -1.0 (+ (* x -3.0) (+ (* -2.0 t_0) (* x 0.6666666666666666)))))
(* (pow wj 2.0) (- 1.0 t_0)))))
(+ wj (- (/ (/ x (+ wj 1.0)) (exp wj)) (/ wj (+ wj 1.0)))))))
double code(double wj, double x) {
double t_0 = (x * -4.0) + (x * 1.5);
double tmp;
if (wj <= 6.2e-6) {
tmp = x + ((-2.0 * (wj * x)) + ((pow(wj, 3.0) * (-1.0 - ((x * -3.0) + ((-2.0 * t_0) + (x * 0.6666666666666666))))) + (pow(wj, 2.0) * (1.0 - t_0))));
} else {
tmp = wj + (((x / (wj + 1.0)) / exp(wj)) - (wj / (wj + 1.0)));
}
return tmp;
}
real(8) function code(wj, x)
real(8), intent (in) :: wj
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = (x * (-4.0d0)) + (x * 1.5d0)
if (wj <= 6.2d-6) then
tmp = x + (((-2.0d0) * (wj * x)) + (((wj ** 3.0d0) * ((-1.0d0) - ((x * (-3.0d0)) + (((-2.0d0) * t_0) + (x * 0.6666666666666666d0))))) + ((wj ** 2.0d0) * (1.0d0 - t_0))))
else
tmp = wj + (((x / (wj + 1.0d0)) / exp(wj)) - (wj / (wj + 1.0d0)))
end if
code = tmp
end function
public static double code(double wj, double x) {
double t_0 = (x * -4.0) + (x * 1.5);
double tmp;
if (wj <= 6.2e-6) {
tmp = x + ((-2.0 * (wj * x)) + ((Math.pow(wj, 3.0) * (-1.0 - ((x * -3.0) + ((-2.0 * t_0) + (x * 0.6666666666666666))))) + (Math.pow(wj, 2.0) * (1.0 - t_0))));
} else {
tmp = wj + (((x / (wj + 1.0)) / Math.exp(wj)) - (wj / (wj + 1.0)));
}
return tmp;
}
def code(wj, x): t_0 = (x * -4.0) + (x * 1.5) tmp = 0 if wj <= 6.2e-6: tmp = x + ((-2.0 * (wj * x)) + ((math.pow(wj, 3.0) * (-1.0 - ((x * -3.0) + ((-2.0 * t_0) + (x * 0.6666666666666666))))) + (math.pow(wj, 2.0) * (1.0 - t_0)))) else: tmp = wj + (((x / (wj + 1.0)) / math.exp(wj)) - (wj / (wj + 1.0))) return tmp
function code(wj, x) t_0 = Float64(Float64(x * -4.0) + Float64(x * 1.5)) tmp = 0.0 if (wj <= 6.2e-6) tmp = Float64(x + Float64(Float64(-2.0 * Float64(wj * x)) + Float64(Float64((wj ^ 3.0) * Float64(-1.0 - Float64(Float64(x * -3.0) + Float64(Float64(-2.0 * t_0) + Float64(x * 0.6666666666666666))))) + Float64((wj ^ 2.0) * Float64(1.0 - t_0))))); else tmp = Float64(wj + Float64(Float64(Float64(x / Float64(wj + 1.0)) / exp(wj)) - Float64(wj / Float64(wj + 1.0)))); end return tmp end
function tmp_2 = code(wj, x) t_0 = (x * -4.0) + (x * 1.5); tmp = 0.0; if (wj <= 6.2e-6) tmp = x + ((-2.0 * (wj * x)) + (((wj ^ 3.0) * (-1.0 - ((x * -3.0) + ((-2.0 * t_0) + (x * 0.6666666666666666))))) + ((wj ^ 2.0) * (1.0 - t_0)))); else tmp = wj + (((x / (wj + 1.0)) / exp(wj)) - (wj / (wj + 1.0))); end tmp_2 = tmp; end
code[wj_, x_] := Block[{t$95$0 = N[(N[(x * -4.0), $MachinePrecision] + N[(x * 1.5), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[wj, 6.2e-6], N[(x + N[(N[(-2.0 * N[(wj * x), $MachinePrecision]), $MachinePrecision] + N[(N[(N[Power[wj, 3.0], $MachinePrecision] * N[(-1.0 - N[(N[(x * -3.0), $MachinePrecision] + N[(N[(-2.0 * t$95$0), $MachinePrecision] + N[(x * 0.6666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Power[wj, 2.0], $MachinePrecision] * N[(1.0 - t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(wj + N[(N[(N[(x / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision] / N[Exp[wj], $MachinePrecision]), $MachinePrecision] - N[(wj / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot -4 + x \cdot 1.5\\
\mathbf{if}\;wj \leq 6.2 \cdot 10^{-6}:\\
\;\;\;\;x + \left(-2 \cdot \left(wj \cdot x\right) + \left({wj}^{3} \cdot \left(-1 - \left(x \cdot -3 + \left(-2 \cdot t_0 + x \cdot 0.6666666666666666\right)\right)\right) + {wj}^{2} \cdot \left(1 - t_0\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;wj + \left(\frac{\frac{x}{wj + 1}}{e^{wj}} - \frac{wj}{wj + 1}\right)\\
\end{array}
\end{array}
if wj < 6.1999999999999999e-6Initial program 76.7%
div-sub76.7%
distribute-rgt1-in76.7%
times-frac76.7%
*-inverses76.7%
associate-*l/76.7%
*-rgt-identity76.7%
distribute-rgt1-in77.1%
associate-/l/77.1%
div-sub77.1%
Simplified77.1%
Taylor expanded in wj around 0 98.4%
if 6.1999999999999999e-6 < wj Initial program 55.0%
div-sub55.0%
distribute-rgt1-in55.0%
times-frac55.0%
*-inverses99.5%
associate-*l/99.5%
*-rgt-identity99.5%
distribute-rgt1-in99.7%
associate-/l/99.5%
div-sub99.5%
Simplified99.5%
sub-div99.5%
associate-/l/99.7%
associate-/r*99.8%
Applied egg-rr99.8%
Final simplification98.5%
(FPCore (wj x)
:precision binary64
(if (<= wj 5.4e-7)
(+
x
(+
(* -2.0 (* wj x))
(+
(*
(pow wj 3.0)
(-
-1.0
(+
(* x -3.0)
(+ (* -2.0 (+ (* x -4.0) (* x 1.5))) (* x 0.6666666666666666)))))
(* wj wj))))
(+ wj (- (/ (/ x (+ wj 1.0)) (exp wj)) (/ wj (+ wj 1.0))))))
double code(double wj, double x) {
double tmp;
if (wj <= 5.4e-7) {
tmp = x + ((-2.0 * (wj * x)) + ((pow(wj, 3.0) * (-1.0 - ((x * -3.0) + ((-2.0 * ((x * -4.0) + (x * 1.5))) + (x * 0.6666666666666666))))) + (wj * wj)));
} else {
tmp = wj + (((x / (wj + 1.0)) / exp(wj)) - (wj / (wj + 1.0)));
}
return tmp;
}
real(8) function code(wj, x)
real(8), intent (in) :: wj
real(8), intent (in) :: x
real(8) :: tmp
if (wj <= 5.4d-7) then
tmp = x + (((-2.0d0) * (wj * x)) + (((wj ** 3.0d0) * ((-1.0d0) - ((x * (-3.0d0)) + (((-2.0d0) * ((x * (-4.0d0)) + (x * 1.5d0))) + (x * 0.6666666666666666d0))))) + (wj * wj)))
else
tmp = wj + (((x / (wj + 1.0d0)) / exp(wj)) - (wj / (wj + 1.0d0)))
end if
code = tmp
end function
public static double code(double wj, double x) {
double tmp;
if (wj <= 5.4e-7) {
tmp = x + ((-2.0 * (wj * x)) + ((Math.pow(wj, 3.0) * (-1.0 - ((x * -3.0) + ((-2.0 * ((x * -4.0) + (x * 1.5))) + (x * 0.6666666666666666))))) + (wj * wj)));
} else {
tmp = wj + (((x / (wj + 1.0)) / Math.exp(wj)) - (wj / (wj + 1.0)));
}
return tmp;
}
def code(wj, x): tmp = 0 if wj <= 5.4e-7: tmp = x + ((-2.0 * (wj * x)) + ((math.pow(wj, 3.0) * (-1.0 - ((x * -3.0) + ((-2.0 * ((x * -4.0) + (x * 1.5))) + (x * 0.6666666666666666))))) + (wj * wj))) else: tmp = wj + (((x / (wj + 1.0)) / math.exp(wj)) - (wj / (wj + 1.0))) return tmp
function code(wj, x) tmp = 0.0 if (wj <= 5.4e-7) tmp = Float64(x + Float64(Float64(-2.0 * Float64(wj * x)) + Float64(Float64((wj ^ 3.0) * Float64(-1.0 - Float64(Float64(x * -3.0) + Float64(Float64(-2.0 * Float64(Float64(x * -4.0) + Float64(x * 1.5))) + Float64(x * 0.6666666666666666))))) + Float64(wj * wj)))); else tmp = Float64(wj + Float64(Float64(Float64(x / Float64(wj + 1.0)) / exp(wj)) - Float64(wj / Float64(wj + 1.0)))); end return tmp end
function tmp_2 = code(wj, x) tmp = 0.0; if (wj <= 5.4e-7) tmp = x + ((-2.0 * (wj * x)) + (((wj ^ 3.0) * (-1.0 - ((x * -3.0) + ((-2.0 * ((x * -4.0) + (x * 1.5))) + (x * 0.6666666666666666))))) + (wj * wj))); else tmp = wj + (((x / (wj + 1.0)) / exp(wj)) - (wj / (wj + 1.0))); end tmp_2 = tmp; end
code[wj_, x_] := If[LessEqual[wj, 5.4e-7], N[(x + N[(N[(-2.0 * N[(wj * x), $MachinePrecision]), $MachinePrecision] + N[(N[(N[Power[wj, 3.0], $MachinePrecision] * N[(-1.0 - N[(N[(x * -3.0), $MachinePrecision] + N[(N[(-2.0 * N[(N[(x * -4.0), $MachinePrecision] + N[(x * 1.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x * 0.6666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(wj * wj), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(wj + N[(N[(N[(x / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision] / N[Exp[wj], $MachinePrecision]), $MachinePrecision] - N[(wj / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;wj \leq 5.4 \cdot 10^{-7}:\\
\;\;\;\;x + \left(-2 \cdot \left(wj \cdot x\right) + \left({wj}^{3} \cdot \left(-1 - \left(x \cdot -3 + \left(-2 \cdot \left(x \cdot -4 + x \cdot 1.5\right) + x \cdot 0.6666666666666666\right)\right)\right) + wj \cdot wj\right)\right)\\
\mathbf{else}:\\
\;\;\;\;wj + \left(\frac{\frac{x}{wj + 1}}{e^{wj}} - \frac{wj}{wj + 1}\right)\\
\end{array}
\end{array}
if wj < 5.40000000000000018e-7Initial program 76.6%
div-sub76.6%
distribute-rgt1-in76.6%
times-frac76.6%
*-inverses76.6%
associate-*l/76.6%
*-rgt-identity76.6%
distribute-rgt1-in77.0%
associate-/l/77.0%
div-sub77.0%
Simplified77.0%
Taylor expanded in wj around 0 98.4%
Taylor expanded in x around 0 98.4%
unpow298.4%
Simplified98.4%
if 5.40000000000000018e-7 < wj Initial program 59.5%
div-sub59.5%
distribute-rgt1-in59.5%
times-frac59.5%
*-inverses99.5%
associate-*l/99.5%
*-rgt-identity99.5%
distribute-rgt1-in99.7%
associate-/l/99.4%
div-sub99.4%
Simplified99.4%
sub-div99.4%
associate-/l/99.7%
associate-/r*99.7%
Applied egg-rr99.7%
Final simplification98.5%
(FPCore (wj x) :precision binary64 (if (<= wj 2.5e-10) (+ x (* wj wj)) (- wj (- (/ wj (+ wj 1.0)) (* x (/ (exp (- wj)) (+ wj 1.0)))))))
double code(double wj, double x) {
double tmp;
if (wj <= 2.5e-10) {
tmp = x + (wj * wj);
} else {
tmp = wj - ((wj / (wj + 1.0)) - (x * (exp(-wj) / (wj + 1.0))));
}
return tmp;
}
real(8) function code(wj, x)
real(8), intent (in) :: wj
real(8), intent (in) :: x
real(8) :: tmp
if (wj <= 2.5d-10) then
tmp = x + (wj * wj)
else
tmp = wj - ((wj / (wj + 1.0d0)) - (x * (exp(-wj) / (wj + 1.0d0))))
end if
code = tmp
end function
public static double code(double wj, double x) {
double tmp;
if (wj <= 2.5e-10) {
tmp = x + (wj * wj);
} else {
tmp = wj - ((wj / (wj + 1.0)) - (x * (Math.exp(-wj) / (wj + 1.0))));
}
return tmp;
}
def code(wj, x): tmp = 0 if wj <= 2.5e-10: tmp = x + (wj * wj) else: tmp = wj - ((wj / (wj + 1.0)) - (x * (math.exp(-wj) / (wj + 1.0)))) return tmp
function code(wj, x) tmp = 0.0 if (wj <= 2.5e-10) tmp = Float64(x + Float64(wj * wj)); else tmp = Float64(wj - Float64(Float64(wj / Float64(wj + 1.0)) - Float64(x * Float64(exp(Float64(-wj)) / Float64(wj + 1.0))))); end return tmp end
function tmp_2 = code(wj, x) tmp = 0.0; if (wj <= 2.5e-10) tmp = x + (wj * wj); else tmp = wj - ((wj / (wj + 1.0)) - (x * (exp(-wj) / (wj + 1.0)))); end tmp_2 = tmp; end
code[wj_, x_] := If[LessEqual[wj, 2.5e-10], N[(x + N[(wj * wj), $MachinePrecision]), $MachinePrecision], N[(wj - N[(N[(wj / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision] - N[(x * N[(N[Exp[(-wj)], $MachinePrecision] / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;wj \leq 2.5 \cdot 10^{-10}:\\
\;\;\;\;x + wj \cdot wj\\
\mathbf{else}:\\
\;\;\;\;wj - \left(\frac{wj}{wj + 1} - x \cdot \frac{e^{-wj}}{wj + 1}\right)\\
\end{array}
\end{array}
if wj < 2.50000000000000016e-10Initial program 76.6%
div-sub76.6%
distribute-rgt1-in76.6%
times-frac76.6%
*-inverses76.6%
associate-*l/76.6%
*-rgt-identity76.6%
distribute-rgt1-in77.0%
associate-/l/77.0%
div-sub77.0%
Simplified77.0%
Taylor expanded in wj around 0 98.4%
+-commutative98.4%
fma-def98.4%
unpow298.4%
distribute-rgt-out98.4%
metadata-eval98.4%
associate-*r*98.4%
*-commutative98.4%
Simplified98.4%
Taylor expanded in x around 0 98.6%
unpow298.6%
Simplified98.6%
if 2.50000000000000016e-10 < wj Initial program 64.6%
div-sub64.6%
distribute-rgt1-in64.6%
times-frac64.9%
*-inverses93.5%
associate-*l/93.5%
*-rgt-identity93.5%
distribute-rgt1-in93.5%
associate-/l/93.2%
div-sub93.2%
Simplified93.2%
div-sub93.2%
div-inv92.9%
div-inv92.9%
*-commutative92.9%
associate-*l*92.9%
div-inv93.2%
*-inverses64.7%
times-frac64.4%
distribute-rgt1-in64.4%
associate-/l/64.6%
distribute-rgt1-in64.6%
div-sub64.6%
div-inv64.1%
*-commutative64.1%
sub-neg64.1%
distribute-lft-in64.1%
Applied egg-rr93.6%
Final simplification98.3%
(FPCore (wj x) :precision binary64 (if (<= wj 7.2e-11) (+ x (* wj wj)) (+ wj (- (/ (/ x (+ wj 1.0)) (exp wj)) (/ wj (+ wj 1.0))))))
double code(double wj, double x) {
double tmp;
if (wj <= 7.2e-11) {
tmp = x + (wj * wj);
} else {
tmp = wj + (((x / (wj + 1.0)) / exp(wj)) - (wj / (wj + 1.0)));
}
return tmp;
}
real(8) function code(wj, x)
real(8), intent (in) :: wj
real(8), intent (in) :: x
real(8) :: tmp
if (wj <= 7.2d-11) then
tmp = x + (wj * wj)
else
tmp = wj + (((x / (wj + 1.0d0)) / exp(wj)) - (wj / (wj + 1.0d0)))
end if
code = tmp
end function
public static double code(double wj, double x) {
double tmp;
if (wj <= 7.2e-11) {
tmp = x + (wj * wj);
} else {
tmp = wj + (((x / (wj + 1.0)) / Math.exp(wj)) - (wj / (wj + 1.0)));
}
return tmp;
}
def code(wj, x): tmp = 0 if wj <= 7.2e-11: tmp = x + (wj * wj) else: tmp = wj + (((x / (wj + 1.0)) / math.exp(wj)) - (wj / (wj + 1.0))) return tmp
function code(wj, x) tmp = 0.0 if (wj <= 7.2e-11) tmp = Float64(x + Float64(wj * wj)); else tmp = Float64(wj + Float64(Float64(Float64(x / Float64(wj + 1.0)) / exp(wj)) - Float64(wj / Float64(wj + 1.0)))); end return tmp end
function tmp_2 = code(wj, x) tmp = 0.0; if (wj <= 7.2e-11) tmp = x + (wj * wj); else tmp = wj + (((x / (wj + 1.0)) / exp(wj)) - (wj / (wj + 1.0))); end tmp_2 = tmp; end
code[wj_, x_] := If[LessEqual[wj, 7.2e-11], N[(x + N[(wj * wj), $MachinePrecision]), $MachinePrecision], N[(wj + N[(N[(N[(x / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision] / N[Exp[wj], $MachinePrecision]), $MachinePrecision] - N[(wj / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;wj \leq 7.2 \cdot 10^{-11}:\\
\;\;\;\;x + wj \cdot wj\\
\mathbf{else}:\\
\;\;\;\;wj + \left(\frac{\frac{x}{wj + 1}}{e^{wj}} - \frac{wj}{wj + 1}\right)\\
\end{array}
\end{array}
if wj < 7.19999999999999969e-11Initial program 76.6%
div-sub76.6%
distribute-rgt1-in76.6%
times-frac76.6%
*-inverses76.6%
associate-*l/76.6%
*-rgt-identity76.6%
distribute-rgt1-in77.0%
associate-/l/77.0%
div-sub77.0%
Simplified77.0%
Taylor expanded in wj around 0 98.4%
+-commutative98.4%
fma-def98.4%
unpow298.4%
distribute-rgt-out98.4%
metadata-eval98.4%
associate-*r*98.4%
*-commutative98.4%
Simplified98.4%
Taylor expanded in x around 0 98.6%
unpow298.6%
Simplified98.6%
if 7.19999999999999969e-11 < wj Initial program 64.6%
div-sub64.6%
distribute-rgt1-in64.6%
times-frac64.9%
*-inverses93.5%
associate-*l/93.5%
*-rgt-identity93.5%
distribute-rgt1-in93.5%
associate-/l/93.2%
div-sub93.2%
Simplified93.2%
sub-div93.2%
associate-/l/93.5%
associate-/r*93.5%
Applied egg-rr93.5%
Final simplification98.3%
(FPCore (wj x) :precision binary64 (if (<= wj 7.2e-11) (+ x (* wj wj)) (+ wj (/ (- (/ x (exp wj)) wj) (+ wj 1.0)))))
double code(double wj, double x) {
double tmp;
if (wj <= 7.2e-11) {
tmp = x + (wj * wj);
} else {
tmp = wj + (((x / exp(wj)) - wj) / (wj + 1.0));
}
return tmp;
}
real(8) function code(wj, x)
real(8), intent (in) :: wj
real(8), intent (in) :: x
real(8) :: tmp
if (wj <= 7.2d-11) then
tmp = x + (wj * wj)
else
tmp = wj + (((x / exp(wj)) - wj) / (wj + 1.0d0))
end if
code = tmp
end function
public static double code(double wj, double x) {
double tmp;
if (wj <= 7.2e-11) {
tmp = x + (wj * wj);
} else {
tmp = wj + (((x / Math.exp(wj)) - wj) / (wj + 1.0));
}
return tmp;
}
def code(wj, x): tmp = 0 if wj <= 7.2e-11: tmp = x + (wj * wj) else: tmp = wj + (((x / math.exp(wj)) - wj) / (wj + 1.0)) return tmp
function code(wj, x) tmp = 0.0 if (wj <= 7.2e-11) tmp = Float64(x + Float64(wj * wj)); else tmp = Float64(wj + Float64(Float64(Float64(x / exp(wj)) - wj) / Float64(wj + 1.0))); end return tmp end
function tmp_2 = code(wj, x) tmp = 0.0; if (wj <= 7.2e-11) tmp = x + (wj * wj); else tmp = wj + (((x / exp(wj)) - wj) / (wj + 1.0)); end tmp_2 = tmp; end
code[wj_, x_] := If[LessEqual[wj, 7.2e-11], N[(x + N[(wj * wj), $MachinePrecision]), $MachinePrecision], N[(wj + N[(N[(N[(x / N[Exp[wj], $MachinePrecision]), $MachinePrecision] - wj), $MachinePrecision] / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;wj \leq 7.2 \cdot 10^{-11}:\\
\;\;\;\;x + wj \cdot wj\\
\mathbf{else}:\\
\;\;\;\;wj + \frac{\frac{x}{e^{wj}} - wj}{wj + 1}\\
\end{array}
\end{array}
if wj < 7.19999999999999969e-11Initial program 76.6%
div-sub76.6%
distribute-rgt1-in76.6%
times-frac76.6%
*-inverses76.6%
associate-*l/76.6%
*-rgt-identity76.6%
distribute-rgt1-in77.0%
associate-/l/77.0%
div-sub77.0%
Simplified77.0%
Taylor expanded in wj around 0 98.4%
+-commutative98.4%
fma-def98.4%
unpow298.4%
distribute-rgt-out98.4%
metadata-eval98.4%
associate-*r*98.4%
*-commutative98.4%
Simplified98.4%
Taylor expanded in x around 0 98.6%
unpow298.6%
Simplified98.6%
if 7.19999999999999969e-11 < wj Initial program 64.6%
div-sub64.6%
distribute-rgt1-in64.6%
times-frac64.9%
*-inverses93.5%
associate-*l/93.5%
*-rgt-identity93.5%
distribute-rgt1-in93.5%
associate-/l/93.2%
div-sub93.2%
Simplified93.2%
Final simplification98.3%
(FPCore (wj x) :precision binary64 (if (<= wj 6.8e-7) (+ x (* wj wj)) (- wj (/ (/ x (- -1.0 wj)) (exp wj)))))
double code(double wj, double x) {
double tmp;
if (wj <= 6.8e-7) {
tmp = x + (wj * wj);
} else {
tmp = wj - ((x / (-1.0 - wj)) / exp(wj));
}
return tmp;
}
real(8) function code(wj, x)
real(8), intent (in) :: wj
real(8), intent (in) :: x
real(8) :: tmp
if (wj <= 6.8d-7) then
tmp = x + (wj * wj)
else
tmp = wj - ((x / ((-1.0d0) - wj)) / exp(wj))
end if
code = tmp
end function
public static double code(double wj, double x) {
double tmp;
if (wj <= 6.8e-7) {
tmp = x + (wj * wj);
} else {
tmp = wj - ((x / (-1.0 - wj)) / Math.exp(wj));
}
return tmp;
}
def code(wj, x): tmp = 0 if wj <= 6.8e-7: tmp = x + (wj * wj) else: tmp = wj - ((x / (-1.0 - wj)) / math.exp(wj)) return tmp
function code(wj, x) tmp = 0.0 if (wj <= 6.8e-7) tmp = Float64(x + Float64(wj * wj)); else tmp = Float64(wj - Float64(Float64(x / Float64(-1.0 - wj)) / exp(wj))); end return tmp end
function tmp_2 = code(wj, x) tmp = 0.0; if (wj <= 6.8e-7) tmp = x + (wj * wj); else tmp = wj - ((x / (-1.0 - wj)) / exp(wj)); end tmp_2 = tmp; end
code[wj_, x_] := If[LessEqual[wj, 6.8e-7], N[(x + N[(wj * wj), $MachinePrecision]), $MachinePrecision], N[(wj - N[(N[(x / N[(-1.0 - wj), $MachinePrecision]), $MachinePrecision] / N[Exp[wj], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;wj \leq 6.8 \cdot 10^{-7}:\\
\;\;\;\;x + wj \cdot wj\\
\mathbf{else}:\\
\;\;\;\;wj - \frac{\frac{x}{-1 - wj}}{e^{wj}}\\
\end{array}
\end{array}
if wj < 6.79999999999999948e-7Initial program 76.6%
div-sub76.6%
distribute-rgt1-in76.6%
times-frac76.6%
*-inverses76.6%
associate-*l/76.6%
*-rgt-identity76.6%
distribute-rgt1-in77.0%
associate-/l/77.0%
div-sub77.0%
Simplified77.0%
Taylor expanded in wj around 0 97.8%
+-commutative97.8%
fma-def97.8%
unpow297.8%
distribute-rgt-out97.8%
metadata-eval97.8%
associate-*r*97.8%
*-commutative97.8%
Simplified97.8%
Taylor expanded in x around 0 97.9%
unpow297.9%
Simplified97.9%
if 6.79999999999999948e-7 < wj Initial program 59.5%
div-sub59.5%
distribute-rgt1-in59.5%
times-frac59.5%
*-inverses99.5%
associate-*l/99.5%
*-rgt-identity99.5%
distribute-rgt1-in99.7%
associate-/l/99.4%
div-sub99.4%
Simplified99.4%
Taylor expanded in x around inf 69.8%
distribute-rgt-in69.7%
*-lft-identity69.7%
distribute-rgt1-in69.8%
*-commutative69.8%
associate-/r*69.5%
associate-*r/69.5%
associate-*r/69.5%
neg-mul-169.5%
Simplified69.5%
neg-mul-169.5%
associate-/l/69.8%
neg-mul-169.8%
neg-sub069.8%
div-sub69.8%
sub-neg69.8%
div069.8%
distribute-frac-neg69.8%
neg-mul-169.8%
associate-/l/69.5%
neg-mul-169.5%
frac-2neg69.5%
distribute-frac-neg69.5%
remove-double-neg69.5%
+-commutative69.5%
distribute-neg-in69.5%
metadata-eval69.5%
unsub-neg69.5%
Applied egg-rr69.5%
+-lft-identity69.5%
*-rgt-identity69.5%
associate-*l/69.5%
associate-*r/69.5%
associate-*l/69.8%
associate-*r/69.8%
*-rgt-identity69.8%
Simplified69.8%
Final simplification96.8%
(FPCore (wj x) :precision binary64 (if (<= wj 1.55) (+ x (* wj wj)) (- wj (/ wj (+ wj 1.0)))))
double code(double wj, double x) {
double tmp;
if (wj <= 1.55) {
tmp = x + (wj * wj);
} else {
tmp = wj - (wj / (wj + 1.0));
}
return tmp;
}
real(8) function code(wj, x)
real(8), intent (in) :: wj
real(8), intent (in) :: x
real(8) :: tmp
if (wj <= 1.55d0) then
tmp = x + (wj * wj)
else
tmp = wj - (wj / (wj + 1.0d0))
end if
code = tmp
end function
public static double code(double wj, double x) {
double tmp;
if (wj <= 1.55) {
tmp = x + (wj * wj);
} else {
tmp = wj - (wj / (wj + 1.0));
}
return tmp;
}
def code(wj, x): tmp = 0 if wj <= 1.55: tmp = x + (wj * wj) else: tmp = wj - (wj / (wj + 1.0)) return tmp
function code(wj, x) tmp = 0.0 if (wj <= 1.55) tmp = Float64(x + Float64(wj * wj)); else tmp = Float64(wj - Float64(wj / Float64(wj + 1.0))); end return tmp end
function tmp_2 = code(wj, x) tmp = 0.0; if (wj <= 1.55) tmp = x + (wj * wj); else tmp = wj - (wj / (wj + 1.0)); end tmp_2 = tmp; end
code[wj_, x_] := If[LessEqual[wj, 1.55], N[(x + N[(wj * wj), $MachinePrecision]), $MachinePrecision], N[(wj - N[(wj / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;wj \leq 1.55:\\
\;\;\;\;x + wj \cdot wj\\
\mathbf{else}:\\
\;\;\;\;wj - \frac{wj}{wj + 1}\\
\end{array}
\end{array}
if wj < 1.55000000000000004Initial program 76.9%
div-sub76.9%
distribute-rgt1-in76.9%
times-frac76.9%
*-inverses76.9%
associate-*l/76.9%
*-rgt-identity76.9%
distribute-rgt1-in77.3%
associate-/l/77.3%
div-sub77.3%
Simplified77.3%
Taylor expanded in wj around 0 97.2%
+-commutative97.2%
fma-def97.2%
unpow297.2%
distribute-rgt-out97.2%
metadata-eval97.2%
associate-*r*97.2%
*-commutative97.2%
Simplified97.2%
Taylor expanded in x around 0 97.0%
unpow297.0%
Simplified97.0%
if 1.55000000000000004 < wj Initial program 42.4%
div-sub42.4%
distribute-rgt1-in42.4%
times-frac42.4%
*-inverses99.6%
associate-*l/99.6%
*-rgt-identity99.6%
distribute-rgt1-in99.8%
associate-/l/99.6%
div-sub99.6%
Simplified99.6%
Taylor expanded in x around 0 71.7%
+-commutative71.7%
Simplified71.7%
Final simplification96.3%
(FPCore (wj x) :precision binary64 (if (<= wj 2.9e-71) x (if (<= wj 3.1e-63) (* wj wj) x)))
double code(double wj, double x) {
double tmp;
if (wj <= 2.9e-71) {
tmp = x;
} else if (wj <= 3.1e-63) {
tmp = wj * wj;
} else {
tmp = x;
}
return tmp;
}
real(8) function code(wj, x)
real(8), intent (in) :: wj
real(8), intent (in) :: x
real(8) :: tmp
if (wj <= 2.9d-71) then
tmp = x
else if (wj <= 3.1d-63) then
tmp = wj * wj
else
tmp = x
end if
code = tmp
end function
public static double code(double wj, double x) {
double tmp;
if (wj <= 2.9e-71) {
tmp = x;
} else if (wj <= 3.1e-63) {
tmp = wj * wj;
} else {
tmp = x;
}
return tmp;
}
def code(wj, x): tmp = 0 if wj <= 2.9e-71: tmp = x elif wj <= 3.1e-63: tmp = wj * wj else: tmp = x return tmp
function code(wj, x) tmp = 0.0 if (wj <= 2.9e-71) tmp = x; elseif (wj <= 3.1e-63) tmp = Float64(wj * wj); else tmp = x; end return tmp end
function tmp_2 = code(wj, x) tmp = 0.0; if (wj <= 2.9e-71) tmp = x; elseif (wj <= 3.1e-63) tmp = wj * wj; else tmp = x; end tmp_2 = tmp; end
code[wj_, x_] := If[LessEqual[wj, 2.9e-71], x, If[LessEqual[wj, 3.1e-63], N[(wj * wj), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;wj \leq 2.9 \cdot 10^{-71}:\\
\;\;\;\;x\\
\mathbf{elif}\;wj \leq 3.1 \cdot 10^{-63}:\\
\;\;\;\;wj \cdot wj\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if wj < 2.8999999999999999e-71 or 3.09999999999999984e-63 < wj Initial program 77.6%
div-sub77.6%
distribute-rgt1-in77.6%
times-frac77.6%
*-inverses79.2%
associate-*l/79.2%
*-rgt-identity79.2%
distribute-rgt1-in79.6%
associate-/l/79.5%
div-sub79.5%
Simplified79.5%
Taylor expanded in wj around 0 84.8%
if 2.8999999999999999e-71 < wj < 3.09999999999999984e-63Initial program 18.0%
div-sub18.0%
distribute-rgt1-in18.0%
times-frac18.0%
*-inverses18.0%
associate-*l/18.0%
*-rgt-identity18.0%
distribute-rgt1-in18.0%
associate-/l/18.0%
div-sub18.0%
Simplified18.0%
clear-num18.2%
inv-pow18.2%
Applied egg-rr18.2%
unpow-118.2%
Simplified18.2%
Taylor expanded in x around 0 4.3%
+-commutative4.3%
Simplified4.3%
Taylor expanded in wj around 0 86.0%
unpow286.0%
Simplified86.0%
Final simplification84.9%
(FPCore (wj x) :precision binary64 (+ x (* wj wj)))
double code(double wj, double x) {
return x + (wj * wj);
}
real(8) function code(wj, x)
real(8), intent (in) :: wj
real(8), intent (in) :: x
code = x + (wj * wj)
end function
public static double code(double wj, double x) {
return x + (wj * wj);
}
def code(wj, x): return x + (wj * wj)
function code(wj, x) return Float64(x + Float64(wj * wj)) end
function tmp = code(wj, x) tmp = x + (wj * wj); end
code[wj_, x_] := N[(x + N[(wj * wj), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + wj \cdot wj
\end{array}
Initial program 75.9%
div-sub75.9%
distribute-rgt1-in75.9%
times-frac75.9%
*-inverses77.5%
associate-*l/77.5%
*-rgt-identity77.5%
distribute-rgt1-in77.9%
associate-/l/77.9%
div-sub77.9%
Simplified77.9%
Taylor expanded in wj around 0 94.8%
+-commutative94.8%
fma-def94.8%
unpow294.8%
distribute-rgt-out94.8%
metadata-eval94.8%
associate-*r*94.8%
*-commutative94.8%
Simplified94.8%
Taylor expanded in x around 0 94.6%
unpow294.6%
Simplified94.6%
Final simplification94.6%
(FPCore (wj x) :precision binary64 wj)
double code(double wj, double x) {
return wj;
}
real(8) function code(wj, x)
real(8), intent (in) :: wj
real(8), intent (in) :: x
code = wj
end function
public static double code(double wj, double x) {
return wj;
}
def code(wj, x): return wj
function code(wj, x) return wj end
function tmp = code(wj, x) tmp = wj; end
code[wj_, x_] := wj
\begin{array}{l}
\\
wj
\end{array}
Initial program 75.9%
div-sub75.9%
distribute-rgt1-in75.9%
times-frac75.9%
*-inverses77.5%
associate-*l/77.5%
*-rgt-identity77.5%
distribute-rgt1-in77.9%
associate-/l/77.9%
div-sub77.9%
Simplified77.9%
Taylor expanded in wj around inf 4.5%
Final simplification4.5%
(FPCore (wj x) :precision binary64 x)
double code(double wj, double x) {
return x;
}
real(8) function code(wj, x)
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
\begin{array}{l}
\\
x
\end{array}
Initial program 75.9%
div-sub75.9%
distribute-rgt1-in75.9%
times-frac75.9%
*-inverses77.5%
associate-*l/77.5%
*-rgt-identity77.5%
distribute-rgt1-in77.9%
associate-/l/77.9%
div-sub77.9%
Simplified77.9%
Taylor expanded in wj around 0 83.0%
Final simplification83.0%
(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)
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]
\begin{array}{l}
\\
wj - \left(\frac{wj}{wj + 1} - \frac{x}{e^{wj} + wj \cdot e^{wj}}\right)
\end{array}
herbie shell --seed 2023297
(FPCore (wj x)
:name "Jmat.Real.lambertw, newton loop step"
:precision binary64
:herbie-target
(- wj (- (/ wj (+ wj 1.0)) (/ x (+ (exp wj) (* wj (exp wj))))))
(- wj (/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj))))))