Numerical Methods for Solving First-Order Differential Equations | 一阶微分方程的数值解法

📚 Numerical Methods for Solving First-Order Differential Equations | 一阶微分方程的数值解法

When a first-order differential equation cannot be solved analytically, numerical methods provide approximate solutions by marching forward in small steps from the initial condition. These techniques are essential tools in both pure and applied mathematics, and they form a core part of the AQA A-Level Mathematics specification.

当一阶微分方程无法解析求解时,数值方法通过从初值条件出发逐步推进,给出近似解。这些技术在纯数学与应用数学中都是必不可少的工具,也是 AQA A-Level 数学考纲的核心内容之一。


1. Introduction | 引言

Many first-order differential equations of the form dy/dx = f(x, y) cannot be solved using standard analytical techniques such as separation of variables or integrating factors. For example, equations involving complicated nonlinear terms often have no closed-form solution. In such cases, we turn to numerical methods, which generate a sequence of approximate values for y at discrete points x₀, x₁, x₂, ….

许多形如 dy/dx = f(x, y) 的一阶微分方程无法使用分离变量法或积分因子法等标准解析技巧求解。例如,涉及复杂非线性项的方程往往没有闭式解。在这种情况下,我们转而使用数值方法,在离散点 x₀、x₁、x₂…… 处生成 y 的一系列近似值。

Numerical methods do not give a formula for y as a function of x; instead, they produce a table of approximate values. The accuracy of these approximations depends on both the method chosen and the step size h. The two main methods studied at A-Level are Euler’s method and the improved Euler (midpoint) method.

数值方法并不给出 y 关于 x 的函数公式,而是生成一张近似值表格。这些近似解的精度既取决于所选方法,也取决于步长 h。A-Level 阶段学习的两种主要方法是欧拉法和改进欧拉法(中点法)。


2. Why Numerical Methods? | 为什么需要数值方法?

Analytical solutions are always preferred when they exist, because they give exact values and reveal the long-term behaviour of the solution. However, many differential equations modelling real-world phenomena — such as population growth with competition, or motion with nonlinear drag — simply cannot be solved exactly.

当解析解存在时,我们总是优先使用解析解,因为它能给出精确值并揭示解的长期行为。然而,许多模拟现实世界现象的微分方程——例如带竞争的种群增长、或带非线性阻力的运动——根本无法精确求解。

Numerical methods allow us to obtain useful approximations to any required degree of accuracy by choosing a sufficiently small step size. They are also straightforward to implement, either by hand for a few steps or by computer for thousands of steps. In the AQA examination, you will typically be asked to carry out one or two steps of a method by hand and to comment on the accuracy of your result.

数值方法通过选择足够小的步长,使我们能够获得满足任意精度要求的近似值。它们也非常容易实现——手工计算几步,或者用计算机计算成千上万步。在 AQA 考试中,通常要求你手工完成一到两步,并对结果的精度进行评述。

A general first-order initial value problem: dy/dx = f(x, y), y(x₀) = y₀


3. Euler’s Method — The Core Idea | 欧拉法——核心思想

Euler’s method is the simplest numerical technique for first-order ordinary differential equations. Given the initial condition y(x₀) = y₀ and a step size h, we estimate the gradient of the solution at the current point and extrapolate linearly over one step.

欧拉法是求解一阶常微分方程最简单的数值技巧。给定初值条件 y(x₀) = y₀ 和步长 h,我们估计当前点的切线斜率,并线性外推一个步长。

yₙ₊₁ = yₙ + h × f(xₙ, yₙ)

The reasoning is that for a small step h, the tangent line drawn at (xₙ, yₙ) closely tracks the true solution curve across the interval [xₙ, xₙ₊₁]. The slope of this tangent is exactly f(xₙ, yₙ), the value of the right-hand side of the differential equation at the starting point of the interval.

其推理是:当步长 h 较小时,在点 (xₙ, yₙ) 处所作的切线在区间 [xₙ, xₙ₊₁] 内与真实解曲线非常接近。该切线的斜率恰好是 f(xₙ, yₙ),即微分方程右端函数在该区间起点处的值。

To apply Euler’s method, repeat the following process: evaluate the slope at the current point, multiply by h to obtain the vertical increment, add this to the current y-value, and advance x by h. Each repetition is called a step.

应用欧拉法时,重复以下步骤:计算当前点处的斜率,乘以 h 得到垂直增量,将其加到当前的 y 值上,并将 x 增加 h。每重复一次称为一步。


4. Euler’s Method — Worked Example | 欧拉法——例题演示

Consider the initial value problem dy/dx = x + y with y(0) = 1. Use Euler’s method with step size h = 0.1 to estimate y(0.2).

考虑初值问题 dy/dx = x + y,y(0) = 1。用欧拉法以步长 h = 0.1 估计 y(0.2)。

Here f(x, y) = x + y, so at any point we simply add the x-coordinate to the y-coordinate to find the gradient.

这里 f(x, y) = x + y,因此在任意点处,只需将 x 坐标与 y 坐标相加即可得到斜率。

Step 1: At x₀ = 0, y₀ = 1. The gradient is f(0, 1) = 0 + 1 = 1. The increment is h × f(0, 1) = 0.1 × 1 = 0.1. Hence y₁ = 1 + 0.1 = 1.1 at x₁ = 0.1.

第一步:在 x₀ = 0 处,y₀ = 1。斜率为 f(0, 1) = 0 + 1 = 1。增量为 h × f(0, 1) = 0.1 × 1 = 0.1。因此在 x₁ = 0.1 处,y₁ = 1 + 0.1 = 1.1。

Step 2: At x₁ = 0.1, y₁ = 1.1. The gradient is f(0.1, 1.1) = 0.1 + 1.1 = 1.2. The increment is 0.1 × 1.2 = 0.12. Hence y₂ = 1.1 + 0.12 = 1.22 at x₂ = 0.2.

第二步:在 x₁ = 0.1 处,y₁ = 1.1。斜率为 f(0.1, 1.1) = 0.1 + 1.1 = 1.2。增量为 0.1 × 1.2 = 0.12。因此在 x₂ = 0.2 处,y₂ = 1.1 + 0.12 = 1.22。

The calculations can be organised into a table:

计算过程可以整理成表格:

Step n xₙ yₙ f(xₙ, yₙ) h × f(xₙ, yₙ) yₙ₊₁
0 0 1 1 0.1 1.1
1 0.1 1.1 1.2 0.12 1.22

Thus Euler’s method with h = 0.1 gives the approximation y(0.2) ≈ 1.22. The exact solution is y(x) = 2eˣ − x − 1, so the true value is y(0.2) ≈ 1.2428. The absolute error is approximately 0.0228.

因此,当 h = 0.1 时欧拉法给出近似值 y(0.2) ≈ 1.22。精确解为 y(x) = 2eˣ − x − 1,真实值为 y(0.2) ≈ 1.2428。绝对误差约为 0.0228。


5. The Improved Euler (Midpoint) Method | 改进欧拉法(中点法)

The midpoint method, also called the improved Euler method, achieves greater accuracy by using the gradient at the midpoint of the interval rather than at the left endpoint. This gives a better estimate of the average slope across the interval [xₙ, xₙ₊₁].

中点法(又称改进欧拉法)通过使用区间中点处的斜率而非左端点处的斜率,获得了更高的精度。这样能更好地估计整个区间 [xₙ, xₙ₊₁] 上的平均斜率。

The method proceeds in two stages. First, we use Euler’s method to predict the y-value at the midpoint of the interval:

该法分两个阶段进行。首先,用欧拉法预测区间中点处的 y 值:

yₘ = yₙ + (h/2) × f(xₙ, yₙ)

We then evaluate the slope at this midpoint and use it to step across the whole interval:

然后计算中点处的斜率,并用它跨过整个区间:

yₙ₊₁ = yₙ + h × f(xₙ + h/2, yₘ)

Equivalently, the whole step can be written in one combined formula:

等价地,整个步长可以写成组合公式:

yₙ₊₁ = yₙ + h × f(xₙ + h/2, yₙ + (h/2) × f(xₙ, yₙ))

Because the midpoint gradient is generally closer to the true average slope than the left-endpoint gradient, the midpoint method is markedly more accurate for the same step size — at the cost of one extra function evaluation per step.

由于中点处的斜率通常比左端点处的斜率更接近真实平均斜率,因此在相同步长下中点法明显更精确——代价是每一步多计算一次函数值。


6. Midpoint Method — Worked Example | 中点法——例题演示

Apply the midpoint method with h = 0.1 to the same problem: dy/dx = x + y, y(0) = 1. Estimate y(0.2).

用步长 h = 0.1 的中点法求解同一问题:dy/dx = x + y,y(0) = 1。估计 y(0.2)。

Step 1: With x₀ = 0 and y₀ = 1, first compute the Euler prediction at the midpoint: yₘ = 1 + 0.05 × f(0, 1) = 1 + 0.05 × 1 = 1.05. The midpoint x-coordinate is 0 + 0.05 = 0.05. Evaluate the slope there: f(0.05, 1.05) = 1.10. Then y₁ = 1 + 0.1 × 1.10 = 1.11 at x₁ = 0.1.

第一步:在 x₀ = 0、y₀ = 1 处,先计算中点的欧拉预测值:yₘ = 1 + 0.05 × f(0, 1) = 1 + 0.05 × 1 = 1.05。中点 x 坐标为 0 + 0.05 = 0.05。在该点求斜率:f(0.05, 1.05) = 1.10。因此 y₁ = 1 + 0.1 × 1.10 = 1.11,对应 x₁ = 0.1。

Step 2: Now x₁ = 0.1 and y₁ = 1.11. The midpoint prediction is yₘ = 1.11 + 0.05 × f(0.1, 1.11) = 1.11 + 0.05 × 1.21 = 1.1705. The midpoint x-coordinate is 0.1 + 0.05 = 0.15. Evaluate the slope: f(0.15, 1.1705) = 1.3205. Hence y₂ = 1.11 + 0.1 × 1.3205 = 1.24205 at x₂ = 0.2.

第二步:此时 x₁ = 0.1、y₁ = 1.11。中点预测为 yₘ = 1.11 + 0.05 × f(0.1, 1.11) = 1.11 + 0.05 × 1.21 = 1.1705。中点 x 坐标为 0.1 + 0.05 = 0.15。计算斜率:f(0.15, 1.1705) = 1.3205。因此 y₂ = 1.11 + 0.1 × 1.3205 = 1.24205,对应 x₂ = 0.2。

The midpoint method gives y(0.2) ≈ 1.24205, compared with the exact value 1.2428. The absolute error is only about 0.0008 — a dramatic improvement over Euler’s error of 0.0228 with the same step size.

中点法给出 y(0.2) ≈ 1.24205,而精确值为 1.2428。绝对误差只有约 0.0008——与欧拉法在相同步长下的误差 0.0228 相比,精度有了显著提升。


7. Step Size and Truncation Error | 步长与截断误差

The error introduced by a numerical method at a single step is called the local truncation error. For Euler’s method, the local error is proportional to h², denoted O(h²). For the midpoint method, the local error is O(h³).

数值方法在单步中引入的误差称为局部截断误差。欧拉法的局部误差与 h² 成正比,记作 O(h²)。中点法的局部误差为 O(h³)。

Over a fixed interval, the number of steps taken is proportional to 1/h, so the global (accumulated) error is one order lower: O(h) for Euler’s method and O(h²) for the midpoint method. This means that if we halve h, Euler’s error is roughly halved, whereas the midpoint method’s error is roughly divided by four.

在固定区间上,步数大约与 1/h 成正比,因此全局(累积)误差的阶数比局部误差低一阶:欧拉法为 O(h),中点法为 O(h²)。这意味着若将 h 减半,欧拉法的误差大约减半,而中点法的误差大约变为原来的四分之一。

Halving the step size doubles the number of calculations required. Therefore there is always a trade-off between accuracy and computational effort. In an examination, you must follow the requested step size exactly, even if you suspect it is large.

将步长减半会使计算量翻倍。因此,在精度与计算量之间总是存在取舍。在考试中,必须严格按照题目要求的步长计算,即使你认为步长偏大。

Euler: global error O(h) — Midpoint: global error O(h²)


8. Comparing the Two Methods | 两种方法的对比

The table below summarises the key differences between Euler’s method and the improved Euler (midpoint) method for the same initial value problem.

下表总结了欧拉法与改进欧拉法(中点法)在求解同一初值问题时的关键区别。

Property Euler’s Method Midpoint Method
Slope used per step Left endpoint f(xₙ, yₙ) Midpoint f(xₙ + h/2, yₘ)
Function evaluations per step 1 2
Local error O(h²) 更多咨询请联系16621398022(同微信)

Comments

屏轩国际教育cambridge primary/secondary checkpoint, cat4, ukiset,ukcat,igcse,alevel,PAT,STEP,MAT, ibdp,ap,ssat,sat,sat2课程辅导,国外大学本科硕士研究生博士课程论文辅导

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from aleveler.com

Subscribe now to keep reading and get access to the full archive.

Continue reading