Qurak

Check the results of NDSolve

How-to 8 steps, run in order in one session. Every step was executed against the engine and the output below is what it produced.

Step 1
lowsol = NDSolve[{y'[x] == 1 / (2 y[x]), y[0] == 1 / 10}, y, {x, 0, 1}, InterpolationOrder -> All];

No output - this step sets something up for the next one.

Step 2
highsol = NDSolve[{y'[x] == 1 / (2 y[x]), y[0] == 1 / 10}, y, {x, 0, 1}, WorkingPrecision -> 22, InterpolationOrder -> All];

No output - this step sets something up for the next one.

Step 3
Plot[Evaluate[RealExponent[(y[x] /. lowsol) - (y[x] /. highsol)]], {x, 0, 1}]
Output
-Graphics-
Step 4
residual[x_] = y'[x] - 1 / (2 y[x]);

No output - this step sets something up for the next one.

Step 5
Plot[Evaluate[RealExponent[{residual[x] /. lowsol, residual[x] /. highsol}]], {x, 0, 1}, PlotStyle -> {GrayLevel[0], RGBColor[1, 0, 0]}, AxesOrigin -> {0, 0}]
Output
-Graphics-
Step 6
sol = NDSolve[{x''[t] + 1 / 10 x'[t] + x[t] (x[t]^2 - 1) == 3 / 10 Cos[t], x[0] == x'[0] == 0}, x, {t, 0, 100}, InterpolationOrder -> All];

No output - this step sets something up for the next one.

Step 7
hpsol = NDSolve[{x''[t] + 1 / 10 x'[t] + x[t] (x[t]^2 - 1) == 3 / 10 Cos[t], x[0] == x'[0] == 0}, x, {t, 0, 100}, WorkingPrecision -> 24, InterpolationOrder -> All];

No output - this step sets something up for the next one.

Step 8
Plot[Evaluate[RealExponent[(x[t] /. sol) - (x[t] /. hpsol)]], {t, 0, 100}]
Output
-Graphics-

Functions used

Related recipes

All recipes · Function reference · Use this from an MCP client