First-Order Differential Equations: Graphical & Numerical Methods | 一阶微分方程:图解与数值求解方法

📚 First-Order Differential Equations: Graphical & Numerical Methods | 一阶微分方程:图解与数值求解方法

First-order differential equations of the form dy/dx = f(x, y) appear throughout physics, from radioactive decay to RC circuits. While some can be solved analytically, many real-world equations cannot be expressed in terms of elementary functions. This is where graphical and numerical methods become essential tools for understanding and predicting physical behaviour.

形如 dy/dx = f(x, y) 的一阶微分方程在物理学中随处可见,从放射性衰变到 RC 电路。虽然其中一部分可以解析求解,但许多现实中的方程无法用初等函数表达。这时,图解法和数值方法便成为理解和预测物理行为的关键工具。


1. The Slope Field: A Visual Portrait of Solutions | 斜率场:解的直观图像

A slope field (or direction field) is constructed by evaluating f(x, y) at a grid of points and drawing a short line segment at each point with slope equal to f(x, y). These segments form a family of miniature tangents that visually trace the shape of solution curves without solving the equation.

斜率场(或称方向场)的构建方法是在一组网格点上计算 f(x, y),并在每个点画一条斜率为 f(x, y) 的短线段。这些线段构成一族微型切线,在不解方程的情况下直观勾勒出解曲线的形状。

For example, consider the equation dy/dx = x. At the point (1, 0), the slope is 1; at (2, 3), the slope is 2. Drawing these segments across the plane reveals that the solutions are parabolas of the form y = x²/2 + C.

例如,考虑方程 dy/dx = x。在点 (1, 0) 处斜率为 1;在点 (2, 3) 处斜率为 2。在整个平面上画出这些线段后可以看出,解是形如 y = x²/2 + C 的抛物线。

dy/dx = f(x, y) → slope at each grid point

dy/dx = f(x, y) → 每个网格点处的斜率


2. Constructing Slope Fields Step by Step | 逐步构建斜率场

The procedure for drawing a slope field is straightforward. First, choose a rectangular region of the xy-plane. Second, select a set of evenly spaced grid points. Third, compute f(x, y) at each point. Finally, draw a short line segment centred at each point with the computed slope.

绘制斜率场的步骤非常直接。首先,在 xy 平面上选择一个矩形区域。其次,选取一组均匀分布的网格点。第三,在每个点处计算 f(x, y)。最后,以每个点为中心,按计算出的斜率画一条短线。

  • Grid spacing: finer grids give smoother fields but require more computation.
  • Slope scale: keep segment length constant; only the angle changes.
  • Symmetry: if f(x, y) depends only on x, slopes are constant along vertical lines.
  • 网格间距:网格越细,场越平滑,但计算量越大。
  • 斜率比例:保持线段长度不变,只改变角度。
  • 对称性:若 f(x, y) 只依赖于 x,则斜率沿竖直线方向保持不变。

For the differential equation dy/dx = y − x, the slope at (0, 0) is 0, at (1, 0) is −1, and at (0, 1) is 1. Connecting the segments smoothly gives solution curves that rise to the right and fall to the left of the line y = x + 1.

对于微分方程 dy/dx = y − x,点 (0, 0) 处斜率为 0,点 (1, 0) 处斜率为 −1,点 (0, 1) 处斜率为 1。将各线段平滑连接后得到的解曲线在直线 y = x + 1 右侧上升、左侧下降。


3. Isoclines: Curves of Constant Slope | 等斜线:等斜率曲线

An isocline is a curve along which the slope f(x, y) is constant. Setting f(x, y) = c for various constants c produces a family of curves that simplifies the construction of slope fields and helps locate equilibrium behaviour.

等斜线是沿其方向斜率 f(x, y) 保持恒定的曲线。令 f(x, y) = c,其中 c 取不同常数值,便可得到一族等斜线,这简化了斜率场的构建,并有助于定位平衡行为。

Take the equation dy/dx = x + y. Setting x + y = c gives isoclines y = c − x, a family of straight lines with slope −1. Along each such line, every solution curve crosses with the same slope c.

以方程 dy/dx = x + y 为例。令 x + y = c,得到等斜线 y = c − x,这是一族斜率为 −1 的直线。沿每一条这样的直线,所有解曲线都以相同的斜率 c 穿过。

c value | c 值 Isocline | 等斜线 Slope | 斜率
0 y = −x 0
1 y = 1 − x 1
−1 y = −1 − x −1

4. Equilibrium Solutions and Stability | 平衡解与稳定性

Equilibrium solutions occur where dy/dx = 0 for all x, meaning f(x, y) = 0 along a horizontal line y = y₀. These constant solutions act as barriers that other solution curves approach or move away from, revealing the system’s long-term behaviour.

平衡解出现在 dy/dx 对所有 x 均为 0 的情形,即沿水平线 y = y₀ 有 f(x, y) = 0。这些常数解充当屏障,其他解曲线要么趋近它、要么远离它,从而揭示系统的长期行为。

Consider the logistic equation dy/dx = y(1 − y). Setting y(1 − y) = 0 gives equilibrium solutions y = 0 and y = 1. For 0 < y < 1, the slope is positive and solutions rise toward y = 1; for y > 1, the slope is negative and solutions fall back toward y = 1. Thus y = 1 is stable, while y = 0 is unstable.

考虑逻辑斯蒂方程 dy/dx = y(1 − y)。令 y(1 − y) = 0,得到平衡解 y = 0 和 y = 1。当 0 < y < 1 时斜率为正,解曲线上升趋向 y = 1;当 y > 1 时斜率为负,解曲线回落趋向 y = 1。因此 y = 1 是稳定的,而 y = 0 是不稳定的。

Stable: nearby curves converge; Unstable: nearby curves diverge

稳定:附近曲线收敛;不稳定:附近曲线发散


5. Euler’s Method: The Foundation of Numerical Solving | 欧拉方法:数值求解的基础

Euler’s method approximates the solution of an initial value problem dy/dx = f(x, y), y(x₀) = y₀ by stepping forward in small increments h. At each step, the slope at the current point is used to extrapolate linearly to the next point.

欧拉方法通过以小步长 h 向前推进,来近似求解初值问题 dy/dx = f(x, y),y(x₀) = y₀。在每一步中,利用当前点的斜率线性外推至下一点。

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

The method is simple to implement but introduces two types of error: local truncation error, proportional to h², and global accumulated error, proportional to h. This makes Euler’s method first-order accurate and suitable only for small step sizes or rough estimates.

该方法实现简单,但会引入两类误差:局部截断误差正比于 h²,全局累计误差正比于 h。这使得欧拉方法只有一阶精度,仅适用于较小步长或粗略估算。


6. Worked Example: Euler’s Method in an RC Circuit | 实例分析:RC 电路中的欧拉方法

In an RC discharging circuit, the voltage across the capacitor obeys dV/dt = −V/RC. Take R = 1 kΩ, C = 1 mF, so RC = 1 s, and initial voltage V(0) = 10 V. Let h = 0.2 s and compute the voltage at t = 1 s.

在 RC 放电电路中,电容器两端电压满足 dV/dt = −V/RC。取 R = 1 kΩ,C = 1 mF,因此 RC = 1 s,初始电压 V(0) = 10 V。令 h = 0.2 s,计算 t = 1 s 时的电压。

tₙ (s) Vₙ (V) Slope dV/dt | 斜率 ΔV = h × slope | 电压增量
0.0 10.00 −10.00 −2.00
0.2 8.00 −8.00 −1.60
0.4 6.40 −6.40 −1.28
0.6 5.12 −5.12 −1.024
0.8 4.096 −4.096 −0.819
1.0 3.277

The exact solution at t = 1 s is V = 10e⁻¹ ≈ 3.679 V. Euler’s method gives 3.277 V, an error of about 0.4 V. Halving h to 0.1 s would reduce the error to approximately 0.2 V, demonstrating the first-order convergence of the method.

t = 1 s 时的精确解为 V = 10e⁻¹ ≈ 3.679 V。欧拉方法得到 3.277 V,误差约为 0.4 V。将 h 减半至 0.1 s 后,误差将降至约 0.2 V,这体现了该方法的一阶收敛性。


7. Improved Euler Method (Heun’s Method) | 改进欧拉方法(海恩方法)

Heun’s method refines Euler’s approach by computing the slope at both the beginning and end of each interval, then averaging the two. This correction produces a much more accurate estimate with only a small additional computational cost.

海恩方法对欧拉方法进行了改进:在每个区间的起点和终点处各计算一次斜率,然后取两者的平均值。这一修正大大提高了估算精度,而额外计算成本却很小。

yₙ₊₁ = yₙ + (h/2) · [f(xₙ, yₙ) + f(xₙ₊₁, yₙ + h·f(xₙ, yₙ))]

For the RC circuit example with h = 0.2 s, Heun’s method would first predict V₁ = 8.00 V as in Euler, then compute the slope at (0.2, 8.00), which is −8.00. The average slope is (−10.00 + −8.00)/2 = −9.00, giving V₁ = 10 + 0.2 × (−9.00) = 8.20 V. The exact value is 10e⁻⁰·² ≈ 8.187 V, so the error is only 0.013 V — far better than Euler’s error of 0.187 V.

对于 h = 0.2 s 的 RC 电路例子,海恩方法首先像欧拉方法一样预测 V₁ = 8.00 V,然后计算 (0.2, 8.00) 处的斜率,即 −8.00。平均斜率为 (−10.00 + −8.00)/2 = −9.00,因此 V₁ = 10 + 0.2 × (−9.00) = 8.20 V。精确值为 10e⁻⁰·² ≈ 8.187 V,误差仅为 0.013 V,远优于欧拉方法的 0.187 V 误差。


8. Runge-Kutta Methods: Higher Accuracy | 龙格-库塔方法:更高精度

The fourth-order Runge-Kutta method (RK4) is the most widely used numerical solver for ordinary differential equations. It evaluates the slope at four carefully chosen points within each interval and combines them with weighted averages, achieving an error proportional to h⁴.

四阶龙格-库塔方法(RK4)是求解常微分方程时应用最广泛的数值方法。它在每个区间内选取四个精心设计的点计算斜率,并按加权平均组合,使误差正比于 h⁴。

k₁ = f(xₙ, yₙ)

k₂ = f(xₙ + h/2, yₙ + h·k₁/2)

k₃ = f(xₙ + h/2, yₙ + h·k₂/2)

k₄ = f(xₙ + h, yₙ + h·k₃)

yₙ₊₁ = yₙ + (h/6)(k₁ + 2k₂ + 2k₃ + k₄)

Applying RK4 to the same RC problem with h = 0.2 s would yield V(1) ≈ 3.679 V, matching the exact solution to four decimal places. This remarkable accuracy makes RK4 the default choice in simulation software and physics laboratories.

将 RK4 应用于同样的 RC 问题,取 h = 0.2 s,所得 V(1) ≈ 3.679 V,与精确解吻合至四位小数。这种卓越的精度使 RK4 成为仿真软件和物理实验室中的默认选择。


9. Error Analysis and Step Size Control | 误差分析与步长控制

Every numerical method carries a trade-off: smaller step sizes reduce truncation error but increase round-off error and computational cost. In practice, an optimal step size balances these competing effects.

每一种数值方法都面临权衡:较小的步长降低截断误差,但会增加舍入误差和计算成本。在实际应用中,最优步长需要在两类相互竞争的效应之间取得平衡。

  • Truncation error | 截断误差: decreases as h decreases; proportional to h for Euler, h⁴ for RK4.
  • Round-off error | 舍入误差: grows as more steps are taken; limited by machine precision.
  • Adaptive step size | 自适应步长: codes automatically halve or double h based on local error estimates.

A practical indicator of error is to run the calculation twice with step sizes h and h/2. If the results differ by more than an acceptable tolerance, the step size must be reduced. This is the foundation of embedded Runge-Kutta pairs such as the Runge-Kutta-Fehlberg method.

一个实用的误差指标是用步长 h 和 h/2 各计算一次。如果两次结果之差超过可接受的容差,就必须减小步长。这正是嵌入型龙格-库塔对,如龙格-库塔-费尔贝格方法的基础。


10. Qualitative Analysis Without Solving | 不解方程的定性分析

Even without any computation, slope fields immediately reveal key features: where solutions increase or decrease, where they approach a horizontal asymptote, and whether they oscillate or diverge. This qualitative understanding is invaluable before committing to a full numerical solution.

即使不进行任何计算,斜率场也能立即揭示关键特征:解在何处递增或递减、何处趋近水平渐近线、是否振荡或发散。在进行完整数值求解之前,这种定性理解极具价值。

For the pendulum equation d²θ/dt² = −(g/L)sin θ, rewriting as a first-order system leads to slope fields with closed curves around the origin, indicating periodic motion. Large-amplitude solutions appear as wavy curves that loop around the phase plane, revealing energy-dependent behaviour.

对于摆的方程 d²θ/dt² = −(g/L)sin θ,改写成一级系统后,其斜率场在原点附近呈闭合曲线,表明运动具有周期性。大幅度解表现为在相平面上环绕的波浪形曲线,揭示出依赖于能量的行为。

Thus, graphical methods serve as a powerful diagnostic tool, guiding physicists toward appropriate analytical or numerical approaches and preventing blind computation.

因此,图解法是一种强有力的诊断工具,它引导物理学家选择恰当的解析或数值方法,避免盲目计算。


11. Practical Comparison of Methods | 各方法实用对比

To choose the right method, one must consider required accuracy, computational budget, and the stiffness of the differential equation. The table below summarises the typical behaviour of each method.

要选择合适的方法,必须考虑所需精度、计算预算以及微分方程的刚性。下表总结了各方法的典型表现。

Method | 方法 Local Error | 局部误差 Global Error | 全局误差 Cost per Step | 每步成本
Euler | 欧拉 O(h²) O(h) 1 evaluation | 1 次求值
Heun | 海恩 O(h³) O(h²) 2 evaluations | 2 次求值
RK4 O(h⁵) O(h⁴) 4 evaluations | 4 次求值

For stiff systems, where solution components evolve on vastly different timescales, explicit methods like Euler and RK4 require impractically small step sizes. Implicit methods, though beyond the scope of this article, are designed precisely for such cases.

对于刚性系统——其中各解分量在不同时间尺度上演化——欧拉和 RK4 等显式方法需要小到不切实际的步长。隐式方法虽然超出本文范围,但正是为这类情况而设计的。


12. Summary: From Slope Fields to Simulation | 总结:从斜率场到数值模拟

This article has walked through the complete journey from visualising differential equations with slope fields and isoclines to computing accurate numerical solutions with Euler, Heun, and RK4 methods. Each tool serves a distinct purpose: slope fields provide intuition, isoclines reveal structure, equilibrium analysis exposes stability, and numerical methods deliver quantitative precision.

本文完整地走过了从用斜率场和等斜线可视化微分方程,到用欧拉、海恩和 RK4 方法计算精确数值解的旅程。每种工具都有其独特用途:斜率场提供直觉,等斜线揭示结构,平衡分析暴露稳定性,数值方法则提供量化精度。

For IB Physics students, mastery of these techniques is not merely an exercise in computation. It is a gateway to understanding how physicists model everything from planetary orbits to quantum tunnelling, where analytical solutions are rare and numerical simulation is the only practical path forward.

对于 IB 物理学生而言,掌握这些技术不仅仅是计算练习,更是理解物理学家如何建模从行星轨道到量子隧穿等一切现象的敲门砖——在这些领域中,解析解极为罕见,数值模拟是唯一可行的前进之路。

Published by TutorHao | Physics Revision Series | aleveler.com

更多咨询请联系16621398022(同微信)

Comments

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

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

Exit mobile version