0
$\begingroup$

I need to make a grid [0,1] with points that are concentrated close to the edges (close to 0 and 1) while the remaining points in the middle can be equally spaced. The reason for doing this is that I know the solution is very sensitive at the edges. Any ideas on how I can do this?

$\endgroup$

1 Answer 1

2
$\begingroup$

Presumably you are trying to use a finite difference method to solve a differential equation. The non-uniformity of the grid has an impact on accuracy. Hence, it is useful to include a parameter in the grid-generation algorithm that controls the rate at which the spacing increases away from the boundary.

There are many approaches for generating non-uniform grids (eg., exponential stretching, etc.) Searching on "numerical grid generation" should provide you with more information.

Here is a simple approach where the grid spacing increases geometrically. For the interval $[0,1/2]$ generate grid points using $x_0 = 0$ and for $k = 1,2,\ldots,n$,

$$x_k = \frac{\alpha\sum_{j=1}^k(1 + \alpha)^{j-1}}{2[(1 + \alpha)^n-1]}.$$

Simply reflect the points across $x = 1/2$ to generate the grid over $[1/2,1].$

Control the spacing and the difference $x_1-x_0$ by choosing appropriate values for the parameters $\alpha >0$ and $n$. Larger values for $\alpha$ will produce finer grids near the boundary.

$\endgroup$
2
  • $\begingroup$ Thanks for your response. I was able to make the grid using the CDF of the beta distribution fairly easily (in about 10 lines). I ran this question by an applied math professor and she showed me a method that is based on the integral of tanh. The method is a bit complicated but is rather flexible in making the grid conform to a number of pre-specified restriction (eg. degree of concentration, symmetry, etc). $\endgroup$
    – Cuedrah
    Feb 3, 2015 at 22:35
  • $\begingroup$ @Cuedrah: You're welcome. Looks like you've covered some ground -- I was aware of the tanh method but have not looked at these things for a while. Out of curiosity, what are you trying to solve on the grid? $\endgroup$
    – RRL
    Feb 3, 2015 at 22:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.