Despite being based on a fairly simple stochastic differential equation
the corresponding partial differential equation
for the SABR model – derived using the variable transformation together with Ito’s lemma and the Feynman-Kac formula – is quite difficult to solve numerically. Part of the problem is the process of the underlying, which corresponds to a constant elasticity of variance (CEV) model if is zero. This model exhibits a variety of different behaviours depending on the value of and on the boundary conditions. The authors in  give a comprehensive overview on this topic. To limit the possible model zoo let’s define
and assume absorbing boundary conditions at if . First step for an implementation of a finite difference scheme is to find efficient limits for the discretization grid. These limits can e.g. be derived from the cumulative distribution function of the underlying process.
Please notice that the underlying in the first case appears in the non centrality parameter of the non central chi-squared distribution , hence the calculation of the inverse can only be carried out by a numerical root-finding algorithm. Sankaran’s approximation of the non central chi-squared distribution can be used to speed-up this method . In the second case the inverse of the equation is
which can be computed using the boost library. In addition adaptive grid refinement around important points and cell averaging around special points of the payoff at maturity  improve the accuracy of the CEV finite difference scheme. is only a local martingale when or equivalent . In this case the call-put parity reads 
and acts as a litmus test for the implementation of the boundary conditions and the finite difference scheme.
The variance direction matches a Brownian motion, hence the discretization is straight forward. Operator splitting schemes like Craig-Syned or Hundsdorfer-Verwer  are tailor made to solve the two dimensional partial differential equation.
The finite difference solver can now be used to compare different approximations with the correct model behaviour and also to compare it with high accurate Monte-Carlo simulations . The model configuration 
should act as a test bed. As can be seen in the diagram below the Monte-Carlo results are in line with the results from finite difference methods within very small error bars. The standard Hagen et al. formula as well as the Le Floc’h-Kennedy  log-normal formula deviate significantly from the correct implied volatilities.
The approximations are not arbitrage free. The probability densities for small strikes turn negative. Hagen’s formula exhibits this behaviour already for larger strikes than the Le Floc’h-Kennedy formula as can be seen in the following diagram. As expected the finite difference solution does not produce negative probabilities.
A note on the Floc’h-Kennedy approximation, the formula becomes numerically unstable around ATM strike levels, hence a second order Taylor expansion is used for moneyness
The following diagram shows the difference between second order Taylor expansion and the formula evaluated using IEEE-754 double precision.
The source code is part of the PR #589 and available here.
 D.R. Brecher, A.E. Lindsay: Results on the CEV Process, Past and Present.
 B. Chen, C.W. Oosterlee, H. Weide, Efficient unbiased simulation scheme for the SABR stochastic volatility model.
 K. in’t Hout: Numerical Partial Differential Equations in Finance explained.
 K. in’t Hout, S. Foulon: ADI Finite Difference Schemes for Option Pricing in the Heston Model with Correlation.
 P. Hagen, D. Kumar, A. Lesnieski, D. Woodward: Arbitrage free SABR.
 F. Le Floc’h, G. Kennedy: Explicit SABR Calibration through Simple Expansions.