I am interested in generating a 1D non-uniform grid on the interval [0, L] with N points, where a region of width $\sigma$ and centred at $\mu$ is at a higher density and where the transition from low and high densities of grid points occurs over a length $\ell$. This is for a finite-difference code, where particular attention is required to a region with large gradients.
In my current implementation I specify low and high grid spacings and interpolate between these using a pair of tanh functions. However in this scheme the total number of points isn't known a priori. I can then iteratively adjust the low and high densities until the total number of points is N but this is quite convoluted in practice.
My question then is: can anyone help by describing a scheme for generating such a grid in a simpler way, perhaps something analogous to the way you might generate Gauss-Lobato points x(i) = cos(i PI / N) where i is the grid index.
Npoints out now - your answer has been very useful. If I understand correctly, I could replace the $\tanh$ interpolation between high and low densities with a linear interpolation - this would allow me to have a simpler analytic expression for finding $x_i$ from $x_{i-1}$. See: http://i.imgur.com/bYf5LzZ.png – Hemmer Jan 18 '16 at 14:24