8.14 数字解决数字方法
Section outline
-
Often, the ordinary differential equations that model a system are so complex that an analytical solution is not possible. In these situations, numerical methods can be used to get an accurate approximate solution to a differential equation . Numerical techniques to solve 1 st order ODEs are well established and a few of these will be discussed in this concept. These are worth looking at not only because they are important tools for solving 1 st order ODEs, but also because a higher order ODE can often be transformed to a system of 1 st order ODEs each of which can then be solved numerically using the methods to be discussed.
::通常情况下,以普通差分方程式为模型的系统非常复杂,因此不可能找到分析解决办法。在这种情况下,可以使用数字方法来为差异方程式找到准确的近似解决办法。解决一等数的数值技术已经确立,其中几个将在这个概念中加以讨论。这些方法值得研究,不仅因为它们是解决一等数代码的重要工具,而且因为它们往往可以转换为一等数的系统,每个系统都可以使用将要讨论的方法从数字上解决。Try your hand at transforming the 2 nd order ODE y ′ ′ ( t ) + 2 y ′ = sin ( t y ) (initial conditions y ( 0 ) = 1 , y ′ ( 0 ) = 2 ) to a system of two 1 st order ODEs by making the simple substitution v ( t ) = y ′ ( t ) . Can you figure out how this substitution helps?
::尝试用手将 ODE y(t)+2y@sin(ty) (初始条件 Y(0)= 1,y(0)=2) 转换为两个第 1 顺序 DEO 的系统, 进行简单的替换 v(t) =y(t) 。 您能知道这个替换有何帮助吗 ?Numerical Methods for Solving ODEs
::数字解决数字方法A brief look is given here to the following three numerical methods used to solve first-order ordinary differential equations:
::此处简要回顾用于解决一级普通差分方程的以下三种数字方法:-
Improved Euler (Heun) Method
::改进 Euler (休) 方法 -
Runge-Kutta Method
::Runge- Kutta 方法
The methods are discussed in order of increasing accuracy.
::讨论这些方法是为了提高准确性。Recall, that the first-order ODE has the form y ′ = F ( x , y ) , where the y ′ is a function of the independent variable x and the dependent variable y .
::回想一下,第一级 ODE 具有 yF(x,y) 的形态, y` 是独立的变量 x 和依附变量 y 的函数 。Euler's Method
::Euler 方法Euler's method is the simplest numerical method for finding an approximation to the solution curve of the initial value problem : y ′ = F ( x , y ) with y ( x 0 ) = y 0 . Approximations of y are found at N equally spaced points on the interval [ x 0 , x N ] , using the algorithm:
::Euler 的方法是找到与初始值问题答案曲线近似的最简单的数字方法:yF(x,y)与 y(x0)=y0.。y的相似度在间隔[x0,xN] 的N相等空格点上找到,使用算法:y n + 1 = y n + h F ( x n , y n ) for n = 0 , 1 , … N − 1 ,
::n= 0, 1 的 yn+1 =yn+hF( xn, yn) = 0, 1,... N- 1 的 yn+1=yn+hF( xn, yn) 。where h is the step size, given by h = x N − x 0 N , and each x n is computed as x n = x 0 + h n for n = 0 , 1 , … N . In general, the shorter the step size, the better is the approximation to the solution curve.
::h 是用 h=xN- x0N 给定的阶梯大小, 而每个 xn 以 xn=x0+h 计算为 n= 0, 1 . N。 一般而言, 阶梯大小越短, 越是接近溶液曲线越好 。Euler's method is considered inefficient because of the large number of steps required to achieve a specified accuracy. The reason for poor accuracy is that the Euler method approximation y n + 1 = y n + h F ( x n , y n ) is best suited for when y ( x ) is a polynomial of degree 1.
::Euler的方法被认为效率低下,因为实现特定准确性需要大量步骤。 准确性差的原因是,当y(x)为一等多等时,Euler方法的近似 yn+1=yn+hF(xn,yn)最适合于y(x)为一等多等时。The local truncation error , e n , associated with using Euler’s method is given by
::与使用 Euler 方法相关的本地短时误差( en) 由| e n | = | y n − y ( x n ) | ≈ | h 2 2 d 2 y d x 2 | x = x n | .
::{\fn黑体\fs22\bord1\shad0\3aHBE\4aH00\fscx67\fscy66\2cHFFFFFF\3cH808080}哦... {\fn黑体\fs22\bord1\shad0\3aHBE\4aH00\fscx67\fscy66\2cHFFFFFF\3cH808080}哦... {\fn黑体\fs22\bord1\shad0\3aHBE\4aH00\fscx67\fscy66\2cHFFFFFF\3cH808080}哦...This is the error of the Euler estimate y n (at any x n ) and the true value y ( x n ) , and it scales as h 2 .
::这是 Euler 估计 yn (在任何 xn) 和真实值 y( xn) 的错误, 它以 h2 缩放为 h2 。The global truncation error , E 0 n , i.e., the accumulated truncation error from x 0 to x n , is roughly estimated as:
::全局短跑错误E0n,即从x0到xn的累计短跑错误,大致估计如下:E 0 n = n ∑ i = 1 | e i | = n ∑ i = 1 [ h 2 2 d 2 y d x 2 | x = x i ] < ( x n − x 0 h ) ( h 2 2 M ) = ( x n − x 0 2 M ) h
::E0n=ni=1eini=1[h22d2ydx2}x=xxxx] <(xn-x0h)(h22M)=(xn-x02M)hwhere | d 2 y d x 2 m a x | ≤ M .
::上面写着"d2ydx2max"MThe global truncation error, E 0 n , will scale as h , i.e., linearly, which means that if we halve the step size, the error will be cut in half. Since the global truncation error is proportional to the first power of the step size h , the global error in the Euler method is of the first order.
::全球减速错误 E0n 将缩放为 h, 也就是说, 线性, 这意味着如果我们把步数减半, 错误将会被减半。 由于全球减速错误与步数大小 h 的第一个功率成正比, 尤勒方法中的全球差错是第一顺序 。For the ODE d y d x = y with the initial condition y ( 0 ) = 1 , apply Euler's method to approximate the solution in 5 steps from x = 0 to x = 1 . Since the exact solution is y = e x , determine the relative accuracy.
::对于初始状态为y(0)=1的 ODE dydx=y, 应用 Euler 的方法将溶液大约在 x=0 至 x=1 的5 步内。 由于确切的溶液是 y=ex, 确定相对精度 。The Euler algorithm is: y n + 1 = y n + h F ( x n , y n ) .
::Euler 算法是: yn+1=yn+hF( xn, yn) 。For this problem: F ( x , y ) = y , with y ( x 0 = 0 ) = 1 = y 0 ;
::对于这个问题: F(x,y)=y, 带有y(x0=0)=1=y0;h = 1 − 0 5 = 0.2 , so that x n = x 0 + 0.2 n = 0.2 n for n = 0 , 1 , … 5 .
::h=1-05=0.2, 所以n=x0+0. 2n=0. 2n, n=0. 1,... 5。The Euler algorithm is: y n + 1 = y n + h y n = ( 1 + h ) y n = 1.2 y n
::Euler 算法是: yn+1=yn+hyn=(1+h)yn=1.2ynThe table below provides the Euler estimates of the solution curve values at each x n .
::下表提供了Euler对每xn溶液曲线值的估计。Table of Euler Method Results & Accuracy n
::n 内x n
::xn 进y n e x n △ = e x n − y n △ e x n 0
0
1.0000
1.0000
---
---
1
0.2
1.2000
1.2214
0.0214
0.0175
2
0.4
1.4400
1.4918
0.0518
0.0347
3
0.6
1.7280
1.8221
0.0941
0.0516
4
0.8
2.0736
2.2255
0.1519
0.0682
5
1.0
2.48832
2.71828
0.22996
0.0846
The relative error is <9% over the interval.
::相对误差在间隔期间 < 9% 。Improved Euler (Heun) Method
::改进 Euler (休) 方法The Improved Euler (Heun) method adapts the Euler's method by using the Euler Method result as a predictor, and then averaging with a corrector that estimates the derivative at the end point of the step interval:
::改进的 Euler (Heun) 方法通过使用以 Euler 方法结果作为预测器来调整 Euler 方法,然后与在步骤间隔末点估计衍生物的校正器平均:y n + 1 = y n + h 2 [ F ( x n , y n ) + F ( x n + 1 , y n + 1 ) ]
::yn+1=yn+h2[F(xn,yn)+F(xn+1,yn+1)]Since y n + 1 also appears on the right side, it can be replaced by Euler's formula, and the Improved Euler method becomes:
::由于yn+1也出现在右侧,可以由Euler的公式取代,改进的Euler方法成为:y n + 1 = y n + h 2 [ F ( x n , y n ) + F ( x n + 1 , y n + h F ( x n , y n ) ) ]
::yn+1=yn+h2[F(xn,yn)+F(xn+1,yn+hF(xn,yn)]The local truncation error of Heun Method method goes a h 3 ; the global truncation error goes as h 2 . The Improved Euler (Heun) Method is of second order.
::Heun 方法的本地减速错误为 h3; 全局减速错误为 h2。 改进 Euler (Heun) 方法为第二顺序 。For on the ODE d y d x = y with the initial condition y ( 0 ) = 1 , apply the Improved Euler (Heun) method to approximate the solution from x = 0 to x = 1 . Let h = 0.2 . Since the exact solution is y = e x , determine the relative accuracy.
::对于初始状态为y(0)=1的 ODE dydx=y 上,应用改进的 Euler (Heun) 方法来接近从 x=0 到 x=1. Let h=0.2 的溶液。由于确切的溶液是 y=ex,因此确定相对精度。The Euler-Heun algorithm is: y n + 1 = y n + h 2 [ F ( x n , y n ) + F ( x n + 1 , y n + h F ( x n , y n ) ) ] .
::Euler- Heun 算法是: yn+1=yn+h2[F(xn,yn)+F(xn+1,yn)+hF(xn,yn)]。For this problem: F ( x , y ) = y , with y ( x 0 = 0 ) = 1 = y 0 ;
::对于这个问题: F(x,y)=y, 带有y(x0=0)=1=y0;h = 1 − 0 5 = 0.2 , so that x n = x 0 + 0.2 n = 0.2 n for n = 0 , 1 , … 5 .
::h=1-05=0.2, 所以n=x0+0. 2n=0. 2n, n=0. 1,... 5。The Euler-Heun algorithm to use is: y n + 1 = y n + h 2 [ y n + y n + h y n ] = [ 1 + h + h 2 2 ] y n
::要使用的 Euler- Heun 算法是: yn+1=yn+h2 [yn+yn+hyn+hyn] = [1+h+h22] yuny n + 1 = 1.22 y n
::yyn+1=1.22 yynThe table below provides the Euler estimates of the solution curve values at each x n .
::下表提供了Euler对每xn溶液曲线值的估计。Table of Improved Euler (Heun) Method Results & Accuracy n
::n 内x n
::xn 进y n e x n △ = e x n − y n △ e x n 0
0
1.0000
1.0000
---
---
1
0.2
1.2200
1.2214
0.0014
0.0011
2
0.4
1.4884
1.4918
0.0034
0.0023
3
0.6
1.815848
1.8221
0.0062
0.0034
4
0.8
2.21533456
2.2255
0.0102
0.0046
5
1.0
2.702708163
2.71828
0.0156
0.0057
The relative error ( △ e x n ) using Euler-Heun method is lower than with the use of Euler’s method. The error is <0.6% over the interval.
::使用 Euler-Heun 方法的相对错误(exn) 低于使用 Euler 方法的错误。 间隔内错误 < 0. 6% 。Runge-Kutta Method
::Runge- Kutta 方法The Runge-Kutta methods are a family of iterative methods for the approximation of solutions of ODE. There are many formulations of Runge-Kutta methods, as well as 2 nd , 3 rd , and 4 th order methods.
::龙格-库塔方法是一个迭代方法的组合,可以近似ODE的解决方案。 龙格-库塔方法有许多配方,以及第二、第三和第四级方法。The following is a 3 rd order Runge-Kutta method formulation:
::以下是龙格-库塔方法的第3级配方:y n + 1 = y n + 1 6 h ( k 1 + 4 k 2 + k 3 ) , where k 1 = F ( x n , y n ) k 2 = F ( x n + h 2 , y n + k 2 h 2 ) k 3 = F ( x n + h , y n − k 1 h + 2 k 2 h )
::yn+1=yn+16h(k1+4k2+k3),其中k1=F(xn,yn)k2=F(xn+h2,yn+k2h2)k3=F(xn+h,yn-k1h+2k2h)The local truncation error of this Runge-Kutta Method goes as h 4 ; the global truncation error goes as h 3 . This Runge-Kutta Method is third order.
::此龙格- Kutta 方法的本地短跑错误为 h4; 全局短跑错误为 h3。 此龙格- Kutta 方法为第三顺序 。For on the ODE d y d x = y with the initial condition y ( 0 ) = 1 , apply the 3 rd -order Runge-Kutta algorithm to approximate the solution from x = 0 to x = 1 . Let h = 0.2 . Since the exact solution is y = e x , determine the relative accuracy.
::对于初始状态为y(0)=1的 ODE dydx=y 上,应用三阶龙格-Kutta算法来估计从 x=0 到 x=1. Let h=0.2的溶液。 由于确切的溶液是 y=ex, 请确定相对精度 。The 3 rd -order Runge-Kutta algorithm is:
::第三顺序龙格库塔算法是:y n + 1 = y n + 1 6 h ( k 1 + 4 k 2 + k 3 ) , where k 1 = F ( x n , y n ) k 2 = F ( x n + h 2 , y n + k 1 h 2 ) k 3 = F ( x n + h , y n − k 1 h + 2 k 2 h )
::yn+1=yn+16h(k1+4k2+k3),其中k1=F(xn,yn)k2=F(xn+h2,yn+k1h2)k3=F(xn+h,yn-k1h+2k2h)For this problem: F ( x , y ) = y , with y ( x 0 = 0 ) = 1 = y 0 ;
::对于这个问题: F(x,y)=y, 带有y(x0=0)=1=y0;h = 1 − 0 5 = 0.2 , so that x n = x 0 + 0.2 n = 0.2 n for n = 0 , 1 , … 5 .
::h=1-05=0.2, 所以n=x0+0. 2n=0. 2n, n=0. 1,... 5。k 1 = F ( x n , y n ) = y n k 2 = F ( x n + h 2 , y n + k 1 h 2 ) = y n + k 1 h 2 = ( 1 + h 2 ) y n k 3 = F ( x n + h , y n − k 1 h + 2 k 2 h ) = ( 1 + h + h 2 ) y n
::k1=F( xn,yn)=ynk2=F( xn+h2,yn+k1h2)=yn+k1h2=yn+k1h2=(1+h2)ynk3=F( xn+h,yn-k1h+2k2h)=(1+h+h2)ynThe Runge-Kutta algorithm is: y n + 1 = y n + 1 6 h ( k 1 + 4 k 2 + k 3 ) = 1.221 ¯ 3 y n
::龙格- 库塔算法是: yn+1=yn+16h( k1+4k2+k3) =1.221 =3ynThe table below provides the Euler estimates of the solution curve values at each x n .
::下表提供了Euler对每xn溶液曲线值的估计。n
::n 内x n
::xn 进y n e x n △ = e x n − y n △ e x n 0
0
1.0000
1.0000
---
---
1
0.2
1.2213
1.2214
0.0001
0.0001
2
0.4
1.4916
1.4918
0.0002
0.0001
3
0.6
1.8216
1.8221
0.0005
0.0003
4
0.8
2.2248
2.2255
0.0007
0.0003
5
1.0
2.7171
2.71828
0.0012
0.0004
The relative errors ( △ e x n ) using the 3 rd -order Runge-Kutta method are very much lower than those of the Improved Euler (Heun) method. The relative error is <0.04%.
::使用三阶龙格-库塔方法的相对误差(exn)大大低于改进的欧勒(Heun)方法的误差。相对误差为 < 0.04% 。Examples
::实例Example 1
::例1Earlier, you were asked to perform the transformation of the 2 nd order ODE y ′ ′ ( t ) + 2 y ′ = sin ( t y ) (initial conditions y ( 0 ) = 1 , y ′ ( 0 ) = 2 ) to a system of two 1 st order ODEs by the simple dependent variable substitution v ( t ) = y ′ ( t ) .
::早些时候,您被要求用简单的依附变量替代 v(t) =y_(t) =y_(t) 执行第二顺序ODE y_(t)+2ysin(ty) (初始条件y(0)=1,y_(0)=2)的转换为两个顺序ODE的系统。Were you able to figure out how to do it using v ( t ) = y ′ ( t ) ?
::你能用 v(t) =y_(t) 来找出怎么做吗 ?Here’s how: since v ( t ) = y ′ ( t ) , then v ′ ( t ) = y ′ ′ ( t ) .
::下面是:从 v(t) =y_(t) 开始, 然后v_(t) =y_(t) 。The two 1 st order ODEs are now :
::第1号命令现在的代码是:-
v
(
t
)
=
y
′
(
t
)
, with
y
′
(
0
)
=
2
, and
::v( t) =y_ (t) , 加上 y_( 0) = 2, 并且 -
original equation
y
′
′
(
t
)
+
2
y
′
=
sin
(
t
y
)
⇒
v
′
+
2
v
=
sin
(
t
y
)
, with
y
(
0
)
=
1
.
::原始等式 Y(t)+2y@sin(ty)@v2v=sin(ty),加上y(0)=1。
All the information is present to apply any of the techniques in this concept to solving the system.
::所有信息都存在,可以运用这一概念中的任何一种技术来解决系统问题。Example 2
::例2Use the Improved Euler Method with step size h = 0.1 to approximate y ( 0.2 ) for the initial value problem: y ′ = x + y 2 with y ( 0 ) = 1 .
::对初始值问题使用带步数 h=0.1 的改进的 Euler 方法, 约等于 y( 0.2) : yx+y2 加上 y( 0)= 1 。The Improved Euler Method algorithm is: y n + 1 = y n + h 2 [ F ( x n , y n ) + F ( x n + 1 , y n + h F ( x n , y n ) ) ] .
::改进的 Euler 方法算法是: yn+1=yn+h2[F(xn,yn)+F(xn+1,yn+hF(xn,yn)]。For this problem: F ( x , y ) = x + y 2 , with y ( x 0 = 0 ) = 1 = y 0 ;
::对于这个问题: F(x,y) =x+y2, 加上 y(x0=0) = 1=y0;h = 0.1 , x 1 = 0.1 , x 2 = 0.2 F ( x n , y n ) = x n + y n 2 F ( x n + 1 , y n + h F ( x n , y n ) ) = x n + 1 + [ y n + h ( x n , y n 2 ) ] 2 .
::h=0.1,x1=0.1,x2=0.2F(xn,yn)=xn+yn2F(xn+1,yn+hF(xn,yn))=xn+1+[yn+h(xn,yn2) 2。The Improved Euler Method algorithm steps are:
::改进的Euler方法算法步骤是:y 1 = y 0 + h 2 [ x 0 + y 0 2 + x 1 + [ y 0 + h ( x 0 + y 0 2 ) ] 2 ] = 1 + 0.1 2 [ 0 + 1 2 + 0.1 + [ 1 + 0.1 ( 0 + 1 2 ) ] 2 ] y 1 = 1.1155 y 2 = y 1 + h 2 [ x 1 + y 1 2 + x 2 + [ y 1 + h ( x 1 + y 1 2 ) ] 2 ] = 1.1155 + 0.1 2 [ 0.1 + 1.1155 2 + 0.2 + [ 1.1155 + 0.1 ( 0.1 + 1.1155 2 ) ] 2 ] y 2 = 1.2708
::y1=y0+h2[x0+y02+x1+[y0+h(x0+y02)]2)=1+0.12[0+12+0.1+[1+0.1.1(0+12)]2)y1=1.1155y2=y1+h2[x1+y12+x2+[y1+h+h(x1++y12)]2)=1.1155+0.12[0.1+111552+0.2+[1.1155+0.1(0.1+1.11552)]2)y2=1.2708The solution is y ( 0.2 ) = y 2 = 1.2708
::溶液是 Y( 0.2)=y2=1. 2708Review
::回顾For #1-3, state the Euler’s method formula which would be used to solve the ODE.
::对于 #1-3, 请说明用于解析 ODE 的 Euler 方法公式 。-
y
′
=
2
x
y
with
y
(
x
0
)
=
y
0
::y(x0)=y0 y2xy -
y
′
=
x
−
y
with
y
(
x
0
)
=
y
0
::y(x0)=y0 的 yx-y -
y
′
=
x
y
with
y
(
x
0
)
=
y
0
::y(x0)=y0 的 yxy
For #4-6, approximate the function y at the specified value of x for the the initial value problem using Euler's Method.
::对于# 4-6, 使用 Euler 方法, 将函数y 接近于初始值问题x的指定值x。-
y
′
=
2
x
y
with
y
(
0
)
=
1
and
h
=
0.1
; what is the relative error?
::y( 0) = 1 和 h= 0 1 的y2xy; 相对错误是什么? -
y
′
=
x
−
y
with
y
(
0
)
=
2
and
h
=
0.1
; what is the relative error?
::yx-y with y( 0)=2 and h=0.1; 相对错误是什么? -
y
′
=
x
y
with
y
(
0
)
=
3
and
h
=
0.1
; what is the relative error?
::y( 0) = 3 和 h= 0.1 的yxy; 相对错误是什么?
For #7-9, state the Improved Euler Method formula which would be used to solve the ODE:
::对于#7-9,请说明用于解析 ODE 的改进的 Euler 方法公式:-
y
′
=
2
x
y
with
y
(
x
0
)
=
y
0
::y(x0)=y0 y2xy -
y
′
=
x
−
y
with
y
(
x
0
)
=
y
0
::y(x0)=y0 的 yx-y -
y
′
=
x
y
with
y
(
x
0
)
=
y
0
::y(x0)=y0 的 yxy
For #10-12, approximate the function y at the specified value of x for the initial value problem using the Improved Euler method.
::对于# 10-12, 使用改进的 Euler 方法, 将函数y 与初始值问题x 的指定值相近。-
y
′
=
2
x
y
with
y
(
0
)
=
1
and
h
=
0.1
; what is the relative error?
::y( 0) = 1 和 h= 0 1 的y2xy; 相对错误是什么? -
y
′
=
x
−
y
with
y
(
0
)
=
2
and
h
=
0.1
; what is the relative error?
::yx-y with y( 0)=2 and h=0.1; 相对错误是什么? -
y
′
=
x
y
with
y
(
0
)
=
3
and
h
=
0.1
; what is the relative error?
::y( 0) = 3 和 h= 0.1 的yxy; 相对错误是什么?
For #13-15, state the 3 rd -order Runge-Kutta method formula which would be used to solve the ODE.
::对于 # 13-15, 说明用于解析 ODE 的三阶龙格- 库塔方法公式 。-
y
′
=
2
x
y
with
y
(
0
)
=
1
and
h
=
0.1
::y(0)=1和h=0.1,y2xy与y(0)=1和h=0.1 -
y
′
=
x
−
y
with
y
(
0
)
=
2
and
h
=
0.1
::yx-y, y( 0)=2 和 h=0. 1 -
y
′
=
x
y
with
y
(
0
)
=
3
and
h
=
0.1
::y( 0)=3 和 h=0. 1 的yxy
Review (Answers)
::回顾(答复)Click to see the answer key or go to the Table of Contents and click on the Answer Key under the 'Other Versions' option.
::单击可查看答题键, 或转到目录中, 单击“ 其他版本” 选项下的答题键 。