
(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 7 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 (* wj (exp wj))) (t_1 (+ (* x -4.0) (* x 1.5))))
(if (<= (+ wj (/ (- x t_0) (+ (exp wj) t_0))) 1e-12)
(+
x
(+
(* -2.0 (* wj x))
(+
(*
(pow wj 3.0)
(- -1.0 (+ (* x -3.0) (+ (* -2.0 t_1) (* x 0.6666666666666666)))))
(* (pow wj 2.0) (- 1.0 t_1)))))
(- wj (/ (- wj (/ x (exp wj))) (+ wj 1.0))))))
double code(double wj, double x) {
double t_0 = wj * exp(wj);
double t_1 = (x * -4.0) + (x * 1.5);
double tmp;
if ((wj + ((x - t_0) / (exp(wj) + t_0))) <= 1e-12) {
tmp = x + ((-2.0 * (wj * x)) + ((pow(wj, 3.0) * (-1.0 - ((x * -3.0) + ((-2.0 * t_1) + (x * 0.6666666666666666))))) + (pow(wj, 2.0) * (1.0 - t_1))));
} else {
tmp = wj - ((wj - (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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = wj * exp(wj)
t_1 = (x * (-4.0d0)) + (x * 1.5d0)
if ((wj + ((x - t_0) / (exp(wj) + t_0))) <= 1d-12) then
tmp = x + (((-2.0d0) * (wj * x)) + (((wj ** 3.0d0) * ((-1.0d0) - ((x * (-3.0d0)) + (((-2.0d0) * t_1) + (x * 0.6666666666666666d0))))) + ((wj ** 2.0d0) * (1.0d0 - t_1))))
else
tmp = wj - ((wj - (x / exp(wj))) / (wj + 1.0d0))
end if
code = tmp
end function
public static double code(double wj, double x) {
double t_0 = wj * Math.exp(wj);
double t_1 = (x * -4.0) + (x * 1.5);
double tmp;
if ((wj + ((x - t_0) / (Math.exp(wj) + t_0))) <= 1e-12) {
tmp = x + ((-2.0 * (wj * x)) + ((Math.pow(wj, 3.0) * (-1.0 - ((x * -3.0) + ((-2.0 * t_1) + (x * 0.6666666666666666))))) + (Math.pow(wj, 2.0) * (1.0 - t_1))));
} else {
tmp = wj - ((wj - (x / Math.exp(wj))) / (wj + 1.0));
}
return tmp;
}
def code(wj, x): t_0 = wj * math.exp(wj) t_1 = (x * -4.0) + (x * 1.5) tmp = 0 if (wj + ((x - t_0) / (math.exp(wj) + t_0))) <= 1e-12: tmp = x + ((-2.0 * (wj * x)) + ((math.pow(wj, 3.0) * (-1.0 - ((x * -3.0) + ((-2.0 * t_1) + (x * 0.6666666666666666))))) + (math.pow(wj, 2.0) * (1.0 - t_1)))) else: tmp = wj - ((wj - (x / math.exp(wj))) / (wj + 1.0)) return tmp
function code(wj, x) t_0 = Float64(wj * exp(wj)) t_1 = Float64(Float64(x * -4.0) + Float64(x * 1.5)) tmp = 0.0 if (Float64(wj + Float64(Float64(x - t_0) / Float64(exp(wj) + t_0))) <= 1e-12) 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_1) + Float64(x * 0.6666666666666666))))) + Float64((wj ^ 2.0) * Float64(1.0 - t_1))))); else tmp = Float64(wj - Float64(Float64(wj - Float64(x / exp(wj))) / Float64(wj + 1.0))); end return tmp end
function tmp_2 = code(wj, x) t_0 = wj * exp(wj); t_1 = (x * -4.0) + (x * 1.5); tmp = 0.0; if ((wj + ((x - t_0) / (exp(wj) + t_0))) <= 1e-12) tmp = x + ((-2.0 * (wj * x)) + (((wj ^ 3.0) * (-1.0 - ((x * -3.0) + ((-2.0 * t_1) + (x * 0.6666666666666666))))) + ((wj ^ 2.0) * (1.0 - t_1)))); else tmp = wj - ((wj - (x / exp(wj))) / (wj + 1.0)); end tmp_2 = tmp; end
code[wj_, x_] := Block[{t$95$0 = N[(wj * N[Exp[wj], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x * -4.0), $MachinePrecision] + N[(x * 1.5), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(wj + N[(N[(x - t$95$0), $MachinePrecision] / N[(N[Exp[wj], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1e-12], 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$1), $MachinePrecision] + N[(x * 0.6666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Power[wj, 2.0], $MachinePrecision] * N[(1.0 - t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(wj - N[(N[(wj - N[(x / N[Exp[wj], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := wj \cdot e^{wj}\\
t_1 := x \cdot -4 + x \cdot 1.5\\
\mathbf{if}\;wj + \frac{x - t_0}{e^{wj} + t_0} \leq 10^{-12}:\\
\;\;\;\;x + \left(-2 \cdot \left(wj \cdot x\right) + \left({wj}^{3} \cdot \left(-1 - \left(x \cdot -3 + \left(-2 \cdot t_1 + x \cdot 0.6666666666666666\right)\right)\right) + {wj}^{2} \cdot \left(1 - t_1\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;wj - \frac{wj - \frac{x}{e^{wj}}}{wj + 1}\\
\end{array}
\end{array}
if (-.f64 wj (/.f64 (-.f64 (*.f64 wj (exp.f64 wj)) x) (+.f64 (exp.f64 wj) (*.f64 wj (exp.f64 wj))))) < 9.9999999999999998e-13Initial program 65.0%
div-sub65.0%
associate-/l*65.0%
distribute-rgt1-in65.0%
associate-/l*65.0%
*-inverses65.0%
/-rgt-identity65.0%
distribute-rgt1-in65.6%
associate-/l/65.5%
div-sub65.5%
Simplified65.5%
Taylor expanded in wj around 0 98.7%
if 9.9999999999999998e-13 < (-.f64 wj (/.f64 (-.f64 (*.f64 wj (exp.f64 wj)) x) (+.f64 (exp.f64 wj) (*.f64 wj (exp.f64 wj))))) Initial program 95.4%
div-sub95.4%
associate-/l*95.5%
distribute-rgt1-in95.5%
associate-/l*95.5%
*-inverses98.5%
/-rgt-identity98.5%
distribute-rgt1-in100.0%
associate-/l/99.9%
div-sub99.9%
Simplified99.9%
Final simplification99.0%
(FPCore (wj x) :precision binary64 (if (<= wj -6.2e-9) (- wj (/ (- wj (/ x (exp wj))) (+ wj 1.0))) (+ x (fma (* wj wj) (+ 1.0 (* x 2.5)) (* wj (* x -2.0))))))
double code(double wj, double x) {
double tmp;
if (wj <= -6.2e-9) {
tmp = wj - ((wj - (x / exp(wj))) / (wj + 1.0));
} else {
tmp = x + fma((wj * wj), (1.0 + (x * 2.5)), (wj * (x * -2.0)));
}
return tmp;
}
function code(wj, x) tmp = 0.0 if (wj <= -6.2e-9) tmp = Float64(wj - Float64(Float64(wj - Float64(x / exp(wj))) / Float64(wj + 1.0))); else tmp = Float64(x + fma(Float64(wj * wj), Float64(1.0 + Float64(x * 2.5)), Float64(wj * Float64(x * -2.0)))); end return tmp end
code[wj_, x_] := If[LessEqual[wj, -6.2e-9], N[(wj - N[(N[(wj - N[(x / N[Exp[wj], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(wj * wj), $MachinePrecision] * N[(1.0 + N[(x * 2.5), $MachinePrecision]), $MachinePrecision] + N[(wj * N[(x * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;wj \leq -6.2 \cdot 10^{-9}:\\
\;\;\;\;wj - \frac{wj - \frac{x}{e^{wj}}}{wj + 1}\\
\mathbf{else}:\\
\;\;\;\;x + \mathsf{fma}\left(wj \cdot wj, 1 + x \cdot 2.5, wj \cdot \left(x \cdot -2\right)\right)\\
\end{array}
\end{array}
if wj < -6.2000000000000001e-9Initial program 71.4%
div-sub71.4%
associate-/l*71.8%
distribute-rgt1-in71.8%
associate-/l*71.8%
*-inverses71.8%
/-rgt-identity71.8%
distribute-rgt1-in89.8%
associate-/l/89.8%
div-sub89.8%
Simplified89.8%
if -6.2000000000000001e-9 < wj Initial program 73.0%
div-sub73.0%
associate-/l*73.1%
distribute-rgt1-in73.1%
associate-/l*73.1%
*-inverses73.9%
/-rgt-identity73.9%
distribute-rgt1-in73.9%
associate-/l/73.9%
div-sub73.9%
Simplified73.9%
Taylor expanded in wj around 0 98.2%
+-commutative98.2%
fma-def98.2%
unpow298.2%
sub-neg98.2%
distribute-rgt-out98.2%
distribute-rgt-neg-in98.2%
metadata-eval98.2%
metadata-eval98.2%
*-commutative98.2%
associate-*l*98.2%
Simplified98.2%
Final simplification97.8%
(FPCore (wj x) :precision binary64 (if (<= wj -2.2e-11) (- wj (/ (- wj (/ x (exp wj))) (+ wj 1.0))) (+ x (* wj wj))))
double code(double wj, double x) {
double tmp;
if (wj <= -2.2e-11) {
tmp = wj - ((wj - (x / exp(wj))) / (wj + 1.0));
} else {
tmp = x + (wj * wj);
}
return tmp;
}
real(8) function code(wj, x)
real(8), intent (in) :: wj
real(8), intent (in) :: x
real(8) :: tmp
if (wj <= (-2.2d-11)) then
tmp = wj - ((wj - (x / exp(wj))) / (wj + 1.0d0))
else
tmp = x + (wj * wj)
end if
code = tmp
end function
public static double code(double wj, double x) {
double tmp;
if (wj <= -2.2e-11) {
tmp = wj - ((wj - (x / Math.exp(wj))) / (wj + 1.0));
} else {
tmp = x + (wj * wj);
}
return tmp;
}
def code(wj, x): tmp = 0 if wj <= -2.2e-11: tmp = wj - ((wj - (x / math.exp(wj))) / (wj + 1.0)) else: tmp = x + (wj * wj) return tmp
function code(wj, x) tmp = 0.0 if (wj <= -2.2e-11) tmp = Float64(wj - Float64(Float64(wj - Float64(x / exp(wj))) / Float64(wj + 1.0))); else tmp = Float64(x + Float64(wj * wj)); end return tmp end
function tmp_2 = code(wj, x) tmp = 0.0; if (wj <= -2.2e-11) tmp = wj - ((wj - (x / exp(wj))) / (wj + 1.0)); else tmp = x + (wj * wj); end tmp_2 = tmp; end
code[wj_, x_] := If[LessEqual[wj, -2.2e-11], N[(wj - N[(N[(wj - N[(x / N[Exp[wj], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(wj * wj), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;wj \leq -2.2 \cdot 10^{-11}:\\
\;\;\;\;wj - \frac{wj - \frac{x}{e^{wj}}}{wj + 1}\\
\mathbf{else}:\\
\;\;\;\;x + wj \cdot wj\\
\end{array}
\end{array}
if wj < -2.2000000000000002e-11Initial program 73.8%
div-sub73.8%
associate-/l*74.2%
distribute-rgt1-in74.1%
associate-/l*74.1%
*-inverses74.1%
/-rgt-identity74.1%
distribute-rgt1-in90.7%
associate-/l/90.5%
div-sub90.5%
Simplified90.5%
if -2.2000000000000002e-11 < wj Initial program 72.9%
div-sub72.9%
associate-/l*72.9%
distribute-rgt1-in72.9%
associate-/l*72.9%
*-inverses73.8%
/-rgt-identity73.8%
distribute-rgt1-in73.8%
associate-/l/73.8%
div-sub73.8%
Simplified73.8%
Taylor expanded in wj around 0 72.5%
associate-*r*72.5%
neg-mul-172.5%
Simplified72.5%
Taylor expanded in wj around 0 98.1%
+-commutative98.1%
fma-def98.1%
unpow298.1%
associate--l+98.1%
cancel-sign-sub-inv98.1%
metadata-eval98.1%
*-lft-identity98.1%
sub-neg98.1%
mul-1-neg98.1%
distribute-rgt-out98.1%
metadata-eval98.1%
Simplified98.1%
Taylor expanded in x around 0 98.0%
unpow298.0%
Simplified98.0%
Final simplification97.6%
(FPCore (wj x) :precision binary64 (if (<= wj -2.8e-7) (/ x (* (exp wj) (+ wj 1.0))) (+ x (* wj wj))))
double code(double wj, double x) {
double tmp;
if (wj <= -2.8e-7) {
tmp = x / (exp(wj) * (wj + 1.0));
} else {
tmp = x + (wj * wj);
}
return tmp;
}
real(8) function code(wj, x)
real(8), intent (in) :: wj
real(8), intent (in) :: x
real(8) :: tmp
if (wj <= (-2.8d-7)) then
tmp = x / (exp(wj) * (wj + 1.0d0))
else
tmp = x + (wj * wj)
end if
code = tmp
end function
public static double code(double wj, double x) {
double tmp;
if (wj <= -2.8e-7) {
tmp = x / (Math.exp(wj) * (wj + 1.0));
} else {
tmp = x + (wj * wj);
}
return tmp;
}
def code(wj, x): tmp = 0 if wj <= -2.8e-7: tmp = x / (math.exp(wj) * (wj + 1.0)) else: tmp = x + (wj * wj) return tmp
function code(wj, x) tmp = 0.0 if (wj <= -2.8e-7) tmp = Float64(x / Float64(exp(wj) * Float64(wj + 1.0))); else tmp = Float64(x + Float64(wj * wj)); end return tmp end
function tmp_2 = code(wj, x) tmp = 0.0; if (wj <= -2.8e-7) tmp = x / (exp(wj) * (wj + 1.0)); else tmp = x + (wj * wj); end tmp_2 = tmp; end
code[wj_, x_] := If[LessEqual[wj, -2.8e-7], N[(x / N[(N[Exp[wj], $MachinePrecision] * N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(wj * wj), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;wj \leq -2.8 \cdot 10^{-7}:\\
\;\;\;\;\frac{x}{e^{wj} \cdot \left(wj + 1\right)}\\
\mathbf{else}:\\
\;\;\;\;x + wj \cdot wj\\
\end{array}
\end{array}
if wj < -2.80000000000000019e-7Initial program 74.2%
div-sub74.2%
associate-/l*74.6%
distribute-rgt1-in74.6%
associate-/l*74.6%
*-inverses74.6%
/-rgt-identity74.6%
distribute-rgt1-in99.4%
associate-/l/99.4%
div-sub99.4%
Simplified99.4%
Taylor expanded in x around inf 87.4%
+-commutative87.4%
Simplified87.4%
if -2.80000000000000019e-7 < wj Initial program 72.9%
div-sub72.9%
associate-/l*73.0%
distribute-rgt1-in72.9%
associate-/l*72.9%
*-inverses73.8%
/-rgt-identity73.8%
distribute-rgt1-in73.8%
associate-/l/73.7%
div-sub73.7%
Simplified73.7%
Taylor expanded in wj around 0 72.5%
associate-*r*72.5%
neg-mul-172.5%
Simplified72.5%
Taylor expanded in wj around 0 97.6%
+-commutative97.6%
fma-def97.6%
unpow297.6%
associate--l+97.6%
cancel-sign-sub-inv97.6%
metadata-eval97.6%
*-lft-identity97.6%
sub-neg97.6%
mul-1-neg97.6%
distribute-rgt-out97.6%
metadata-eval97.6%
Simplified97.6%
Taylor expanded in x around 0 97.3%
unpow297.3%
Simplified97.3%
Final simplification97.0%
(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 72.9%
div-sub72.9%
associate-/l*73.0%
distribute-rgt1-in73.0%
associate-/l*73.0%
*-inverses73.8%
/-rgt-identity73.8%
distribute-rgt1-in74.6%
associate-/l/74.5%
div-sub74.5%
Simplified74.5%
Taylor expanded in wj around 0 71.9%
associate-*r*71.9%
neg-mul-171.9%
Simplified71.9%
Taylor expanded in wj around 0 95.9%
+-commutative95.9%
fma-def95.9%
unpow295.9%
associate--l+95.9%
cancel-sign-sub-inv95.9%
metadata-eval95.9%
*-lft-identity95.9%
sub-neg95.9%
mul-1-neg95.9%
distribute-rgt-out95.9%
metadata-eval95.9%
Simplified95.9%
Taylor expanded in x around 0 95.1%
unpow295.1%
Simplified95.1%
Final simplification95.1%
(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 72.9%
div-sub72.9%
associate-/l*73.0%
distribute-rgt1-in73.0%
associate-/l*73.0%
*-inverses73.8%
/-rgt-identity73.8%
distribute-rgt1-in74.6%
associate-/l/74.5%
div-sub74.5%
Simplified74.5%
Taylor expanded in wj around inf 4.3%
Final simplification4.3%
(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 72.9%
div-sub72.9%
associate-/l*73.0%
distribute-rgt1-in73.0%
associate-/l*73.0%
*-inverses73.8%
/-rgt-identity73.8%
distribute-rgt1-in74.6%
associate-/l/74.5%
div-sub74.5%
Simplified74.5%
Taylor expanded in wj around 0 80.9%
Final simplification80.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)
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 2023268
(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))))))