# Grids and arrays on a shape This page explains how a solution on a region of the plane gets onto a uniform grid and to any point, and how an array on a uniform grid is read by the method. The method itself, with its mesh and its elements, is explained under [spectral elements](spectral-elements.md). ## The solution on a grid The points of the elements lie where the mesh puts them. The solution is handed back on a uniform grid over the rectangle that holds the region: each grid point is located in its element, and the polynomial of that element is evaluated there. This is exact for the computed solution. The grid is a choice about the output, like the times of a problem in time, and does not affect the accuracy. A point of the grid outside the region holds no number (`nan`). ### Values anywhere On [grids](index.md#values-between-the-points-of-a-grid) a solution has values between its points as well. On a region the solution also keeps its values at the points of the elements, and gives its value at any point from them: the point is located in its element, by Newton's method on the map of the element, and the polynomial of the element is evaluated there. That is the computed solution itself, not an interpolation of the grid, so it is as accurate between the points of the grid and on the boundary as it is anywhere: the membrane on a disk, $(1 - r^2)/4$, comes out to $10^{-14}$ along 50 rays up to the rim. Twenty thousand points take 0.06 s. A piece of the boundary that is curved is followed by the sides of elements, which are polynomials: at degree 4 they are off the curve by about $10^{-5}$ of their length, at degree 8 by $10^{-11}$. A point on the curve may therefore lie a little beside every element. A point that no element holds is looked for once more, with room for a thousandth of a side, and gets the value at the nearest point of the side. A point further out holds no number. ## What is given as an array The method needs what is given at the points of its elements: the source and the coefficients at the Gauss–Lobatto points, the boundary values at those on the boundary. They are points of no grid. A formula is evaluated there. An array on a uniform grid is read there: - **Where the grid holds numbers all around the point**, by the polynomial of degree five in each coordinate through the six by six grid points around it. That is exact for such polynomials, and for a smooth function the error falls with the sixth power of the spacing. - **Where some of those hold no number**, which is so beside the boundary for an array that is known in the region alone, by a polynomial of total degree five that is fitted to the numbers in the eight by eight grid points around the point, by least squares that weigh a number by $1/(d^2 + \tfrac14)$ at the distance of $d$ steps. A point on the boundary is then read from the inner side. If there are fewer than 42 numbers, the window is twelve by twelve, and if that does not have them either, the degree is three. A point with no number within a step and a half is refused: the array does not cover the region. Poisson's equation on the unit disk, with the source and the value on the rim as arrays, for $u = \cos 2x\,e^{y/2}$: | Points along a side | Error, with numbers beyond the rim | Error, with none | |---|---|---| | 33 | $2\cdot10^{-8}$ | $3\cdot10^{-6}$ | | 65 | $4\cdot10^{-10}$ | $4\cdot10^{-8}$ | | 129 | $7\cdot10^{-12}$ | $7\cdot10^{-10}$ | | 257 | $1\cdot10^{-13}$ | $9\cdot10^{-12}$ | Both fall with the sixth power. The fit beside the boundary costs two digits against the polynomial through the points, so an array that is known beyond the boundary is better given there. The planner reads the arrays as it reads formulas, to see how fine the elements must be. The elements and the grid of the data have nothing to do with each other. ## Limits - **An array is read to the sixth order.** What an array adds to the error falls with the sixth power of the spacing of its grid, not faster than every power. Its grid is uniform, and all arrays of a problem lie on one grid.