Qurak

Check the results of NDSolve

操作指南 8 步,在同一个会话中按顺序运行。每一步都在引擎上执行过,下面的输出就是它实际产生的。

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

无输出——这一步是在为下一步做准备。

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

无输出——这一步是在为下一步做准备。

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

无输出——这一步是在为下一步做准备。

第 5 步
Plot[Evaluate[RealExponent[{residual[x] /. lowsol, residual[x] /. highsol}]], {x, 0, 1}, PlotStyle -> {GrayLevel[0], RGBColor[1, 0, 0]}, AxesOrigin -> {0, 0}]
输出
-Graphics-
第 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];

无输出——这一步是在为下一步做准备。

第 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];

无输出——这一步是在为下一步做准备。

第 8 步
Plot[Evaluate[RealExponent[(x[t] /. sol) - (x[t] /. hpsol)]], {t, 0, 100}]
输出
-Graphics-

用到的函数

相关操作示例

全部操作示例 · 函数参考 · 从 MCP 客户端使用