Discounted symmetric random-walk exit transform (source code)

= Discounted symmetric random-walk exit transform

For simple symmetric random walk stopped on hitting $-a$ or $b$ and $0<z<1$, choose $w>1$ by
$$
z=\frac2{w+w^{-1}},
\qquad
w=\frac{1+\sqrt{1-z^2}}z.
$$
Then $z^nw^{\pm X_n}$ are martingales. Solving the two boundary equations gives
$$
\mathbb E_0z^T
=\frac{w^a+w^b-w^{-a}-w^{-b}}
{w^{a+b}-w^{-(a+b)}}.
$$