# Get more digits Use this when a result is not as accurate as you need, or when you want to know how accurate it is. ## Steps 1. Read the diagnostics of the solution. `spectral_tail` and `solution_tail` say how far the spectrum of what is given, and of the solution, has decayed on the grid. Tiny is good. 2. Find the entry of the plan that sets the accuracy, in the table below. 3. Change it, solve again, and compare the two solutions. The digits that agree are the digits of the coarser one. | Where | Entry | |---|---| | free space, periodic boxes, boxes with walls, round domains | `grid.shape` | | a source that reaches the faces of the box, in free space | `grid.lower`, `grid.upper` | | a shape in the plane | `method.degree`, `method.spacing` | | bodies | `method.panels` | | an iteration, Newton's method, time stepping | `method.tolerance` | | a source or boundary values that depend on time | `method.steps` | ## Example Burgers' equation steepens a sine into a front. The planner sees only the initial state, and its 32 points do not hold the front: ```python import sympy as sp import pdemagic as pm x, t = sp.symbols("x t", real=True) v = sp.Function("v")(x, t) burgers = pm.Problem( sp.Eq(v.diff(t) + v * v.diff(x), v.diff(x, 2) / 10), domain=pm.Space(x, periodic={x: (0, 2 * sp.pi)}), time=(t, 0.0, 2.0), initial={v: sp.sin(x)}, ) coarse = pm.solve(burgers) assert coarse.plan.grid.shape == [32] assert coarse.diagnostics["solution_tail"] > 1e-2 # far too much plan = pm.plan(burgers) plan.grid.shape = (256,) fine = pm.solve(burgers, plan) fine.plot() assert fine.diagnostics["solution_tail"] < 1e-8 # Compare the two at the same points, at the end. (xs,) = coarse.axes difference = abs(coarse(xs)[-1] - fine(xs)[-1]).max() assert 1e-3 < difference < 1e-1 # the coarse solution had two digits ``` ## Notes - Most methods are spectral: once the grid resolves the solution, a few more points bring many digits. Two methods are of second order: a cylinder with vacuum outside, where half the size of the cells divides the error by four, and bodies, where four times the triangles do. - A tail that does not fall on finer grids points to a kink or a singularity. More points help little there: see [What to do when a plan says NOT resolved](what-to-do-when-not-resolved.md). - In free space `source_boundary_ratio` says whether the box holds the source. If it is not tiny, widen the box. - On a shape in the plane the grid is where the solution is given, and does not affect the accuracy. - The planner judges the resolution by what is given. A solution with finer structure than its data, as here, shows in `solution_tail` alone. - [Accuracy and diagnostics](../topics/accuracy.md) explains the measures, [the diagnostics](../ref/diagnostics.md) lists them, and [How accurate it is](../ref/accuracy.md) says what each method reaches.