15.12.2012 Views

scipy tutorial - Baustatik-Info-Server

scipy tutorial - Baustatik-Info-Server

scipy tutorial - Baustatik-Info-Server

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

SciPy Reference Guide, Release 0.8.dev<br />

0.56714329040978387299996866221035555 >>> w*exp(w) 1.0<br />

Any branch gives a valid inverse:<br />

>>> w = lambertw(1, k=3)<br />

>>> w<br />

(-2.8535817554090378072068187234910812 + 17.113535539412145912607826671159289j) >>> w*exp(w)<br />

(1.0 + 3.5075477124212226194278700785075126e-36j)<br />

Applications to equation-solving<br />

The Lambert W function may be used to solve various kinds of equations, such as finding the value of the infinite<br />

power tower z^{z^{z^{ldots}}}:<br />

>>> def tower(z, n):<br />

... if n == 0: ... return z ... return z ** tower(z, n-1) ... >>> tower(0.5, 100) 0.641185744504986 >>> -lambertw(log(0.5))/log(0.5)<br />

0.6411857445049859844862004821148236665628209571911<br />

Properties<br />

The Lambert W function grows roughly like the natural logarithm for large arguments:<br />

>>> lambertw(1000)<br />

5.2496028524016 >>> log(1000) 6.90775527898214 >>> lambertw(10**100) 224.843106445119 >>><br />

log(10**100) 230.258509299405<br />

The principal branch of the Lambert W function has a rational Taylor series expansion around z = 0:<br />

>>> nprint(taylor(lambertw, 0, 6), 10)<br />

[0.0, 1.0, -1.0, 1.5, -2.666666667, 5.208333333, -10.8]<br />

Some special values and limits are:<br />

>>> lambertw(0)<br />

0.0 >>> lambertw(1) 0.567143290409784 >>> lambertw(e) 1.0 >>> lambertw(inf) +inf >>> lambertw(0, k=-1)<br />

-inf >>> lambertw(0, k=3) -inf >>> lambertw(inf, k=3) (+inf + 18.8495559215388j)<br />

The k = 0 and k = -1 branches join at z = -1/e where W(z) = -1 for both branches. Since -1/e can only be<br />

represented approximately with mpmath numbers, evaluating the Lambert W function at this point only gives -1<br />

approximately:<br />

>>> lambertw(-1/e, 0)<br />

-0.999999999999837133022867 >>> lambertw(-1/e, -1) -1.00000000000016286697718<br />

If -1/e happens to round in the negative direction, there might be a small imaginary part:<br />

>>> lambertw(-1/e)<br />

(-1.0 + 8.22007971511612e-9j)<br />

zeta<br />

y=zeta(x,q) returns the Riemann zeta function of two arguments: sum((k+q)**(-x),k=0..inf)<br />

446 Chapter 3. Reference

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!