  Consider a sequence (indexed by n) of Markov chains Z^n in R^d characterized
by transition kernels that approximately (in n) depend only on the rescaled
state n^{-1} Z^n. Subject to a smoothness condition, such a family can be
closely coupled on short time intervals to a Brownian motion with quadratic
drift. This construction is used to determine the first two terms in the
asymptotic (in n) expansion of the probability that the rescaled chain exits a
convex polytope. The constant term and the first correction of size n^{-1/6}
admit sharp characterization by solutions to associated differential equations
and an absolute constant. The error is smaller than O(n^{-b}) for any b < 1/4.
  These results are directly applied to the analysis of randomized algorithms
at phase transitions. In particular, the `peeling' algorithm in large random
hypergraphs, or equivalently the iterative decoding scheme for low-density
parity-check codes over the binary erasure channel is studied to determine the
finite size scaling behavior for irregular hypergraph ensembles.
