Accurate and efficient forward models of photon migration in heterogeneous geometries are important for many applications of light in medicine because many biological tissues exhibit a layered structure, with each layer having independent optical properties and thickness. Unfortunately, closed form analytical solutions are not readily available for layered tissue-models, and often are modeled using computationally expensive numerical techniques or theoretical approximations that limit accuracy and real-time analysis. Here, we develop an open-source accurate, efficient, and stable numerical routine to solve the diffusion equation in the steady-state and time-domain for a layered cylinder tissue model with an arbitrary number of layers and specified thickness and optical coefficients. We show that the steady-state (< 0.1 ms) and time-domain (< 0.5 ms) fluence (for an 8-layer medium) can be calculated with absolute numerical errors approaching machine precision. The numerical implementation increased computation speed by 3 to 4 orders of magnitude compared to previously reported theoretical solutions in layered media. We verify our solutions asymptotically to homogeneous tissue geometries using closed form analytical solutions to assess convergence and numerical accuracy. Approximate solutions to compute the reflected intensity are presented which can decrease the computation time by an additional 2-3 orders of magnitude. We also compare our solutions for 2, 3, and 5 layered media to gold-standard Monte Carlo simulations in layered tissue models of high interest in biomedical optics (e.g. skin/fat/muscle and brain). The presented routine could enable more robust real-time data analysis tools in heterogeneous tissues that are important in many clinical applications such as functional brain imaging and diffuse optical spectroscopy.