Submit
Path:
~
/
/
proc
/
thread-self
/
root
/
opt
/
alt
/
python35
/
lib64
/
python3.5
/
site-packages
/
scipy
/
special
/
__pycache__
/
File Content:
lambertw.cpython-35.opt-1.pyc
�<WW� � @ sB d d l m Z m Z m Z d d l m Z d d d d � Z d S)� )�division�print_function�absolute_import� )� _lambertwg:�0�yE>c C s t | | | � S)a� lambertw(z, k=0, tol=1e-8) Lambert W function [1]_. The Lambert W function `W(z)` is defined as the inverse function of ``w * exp(w)``. In other words, the value of ``W(z)`` is such that ``z = W(z) * exp(W(z))`` for any complex number ``z``. The Lambert W function is a multivalued function with infinitely many branches. Each branch gives a separate solution of the equation ``z = w exp(w)``. Here, the branches are indexed by the integer `k`. Parameters ---------- z : array_like Input argument. k : int, optional Branch index. tol : float, optional Evaluation tolerance. Returns ------- w : array `w` will have the same shape as `z`. Notes ----- All branches are supported by `lambertw`: * ``lambertw(z)`` gives the principal solution (branch 0) * ``lambertw(z, k)`` gives the solution on branch `k` The Lambert W function has two partially real branches: the principal branch (`k = 0`) is real for real ``z > -1/e``, and the ``k = -1`` branch is real for ``-1/e < z < 0``. All branches except ``k = 0`` have a logarithmic singularity at ``z = 0``. **Possible issues** The evaluation can become inaccurate very close to the branch point at ``-1/e``. In some corner cases, `lambertw` might currently fail to converge, or can end up on the wrong branch. **Algorithm** Halley's iteration is used to invert ``w * exp(w)``, using a first-order asymptotic approximation (O(log(w)) or `O(w)`) as the initial estimate. The definition, implementation and choice of branches is based on [2]_. References ---------- .. [1] http://en.wikipedia.org/wiki/Lambert_W_function .. [2] Corless et al, "On the Lambert W function", Adv. Comp. Math. 5 (1996) 329-359. http://www.apmaths.uwo.ca/~djeffrey/Offprints/W-adv-cm.pdf Examples -------- The Lambert W function is the inverse of ``w exp(w)``: >>> from scipy.special import lambertw >>> w = lambertw(1) >>> w (0.56714329040978384+0j) >>> w * np.exp(w) (1.0+0j) Any branch gives a valid inverse: >>> w = lambertw(1, k=3) >>> w (-2.8535817554090377+17.113535539412148j) >>> w*np.exp(w) (1.0000000000000002+1.609823385706477e-15j) **Applications to equation-solving** The Lambert W function may be used to solve various kinds of equations, such as finding the value of the infinite power tower :math:`z^{z^{z^{\ldots}}}`: >>> def tower(z, n): ... if n == 0: ... return z ... return z ** tower(z, n-1) ... >>> tower(0.5, 100) 0.641185744504986 >>> -lambertw(-np.log(0.5)) / np.log(0.5) (0.64118574450498589+0j) )r )�z�kZtol� r �/lambertw.py�lambertw s ar N)Z __future__r r r Z_ufuncsr r r r r r �<module> s
Submit
FILE
FOLDER
Name
Size
Permission
Action
__init__.cpython-35.opt-1.pyc
23337 bytes
0644
__init__.cpython-35.pyc
23337 bytes
0644
_ellip_harm.cpython-35.opt-1.pyc
5949 bytes
0644
_ellip_harm.cpython-35.pyc
5949 bytes
0644
_mptestutils.cpython-35.opt-1.pyc
13427 bytes
0644
_mptestutils.cpython-35.pyc
13427 bytes
0644
_spherical_bessel.cpython-35.opt-1.pyc
5467 bytes
0644
_spherical_bessel.cpython-35.pyc
5467 bytes
0644
_testutils.cpython-35.opt-1.pyc
10670 bytes
0644
_testutils.cpython-35.pyc
10670 bytes
0644
add_newdocs.cpython-35.opt-1.pyc
132479 bytes
0644
add_newdocs.cpython-35.pyc
132479 bytes
0644
basic.cpython-35.opt-1.pyc
72955 bytes
0644
basic.cpython-35.pyc
72955 bytes
0644
generate_ufuncs.cpython-35.opt-1.pyc
41799 bytes
0644
generate_ufuncs.cpython-35.pyc
41799 bytes
0644
lambertw.cpython-35.opt-1.pyc
3191 bytes
0644
lambertw.cpython-35.pyc
3191 bytes
0644
orthogonal.cpython-35.opt-1.pyc
54319 bytes
0644
orthogonal.cpython-35.pyc
54319 bytes
0644
setup.cpython-35.opt-1.pyc
3206 bytes
0644
setup.cpython-35.pyc
3206 bytes
0644
spfun_stats.cpython-35.opt-1.pyc
2299 bytes
0644
spfun_stats.cpython-35.pyc
2299 bytes
0644
N4ST4R_ID | Naxtarrr