数值分析综合例题

更新时间:2024-05-27 04:01:01 阅读量: 综合文库 文档下载

说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。

第二章 线性方程组的直接解法 .......................................................................................................... 2 第三章 解线性方程组的迭代法 .......................................................................................................... 7 第五章 非线性方程和方程组的数值解法 ........................................................................................ 10 第六章 插值法与数值微分 ................................................................................................................ 14 第七章 数据拟合与函数逼近 ............................................................................................................ 19 第八章 数值积分 ................................................................................................................................ 23 第九章 常微分方程的数值解法 ........................................................................................................ 28

1

第二章 线性方程组的直接解法

1、用LU分解法求如下方程组的解

?335??1??323??5??????X??3? 220(1)?359????0?,(2)??????5917??1????????3012???7??解:(1)

(2)

?????5?A??1??33?11????24??L?U ???52??321??????3??L?Y?(101)T?Y?(1,?1,4)T3UX?Y?X?(392,?2,2)T??3??323???1??32??220????2?31??2?2???3012??????3??1?31????3????1??2??5??5??1???3?y???3?1???y????3?? ?1?31????7????1????323?????1???2???5?1????2?X??1?3??3???X????

?3????1???2??1??3??

2

?5?b???3????7??

??2426?2、对4阶矩阵A??49615???26918??进行LU分解 ?6151840????2426???1??2426?解:A??49615??26918?????21??121????123??36?? ?6151840????3321????1??3、用高斯列主元素消去法解线性方程组

?2x1?x2?3x3?1①??4x1?2x2?5x3?4 ??x1?2x2?7?11x1?3x2?2x3?3②???23x1?11x2?x3?0 ??x1?2x2?2x3??1解:对增广矩阵进行初等行变换

????2?131?r??1r3?(?5)r2?2?131?①??4254?2+(-2)r?2?131??8?2?? ????04?12???04?1?1207??r13?(?2)r1??5313??721??02?22????00?84????2x1?x2?3x3同解方程组为??1?4x2?x3?2 ????78x213?4回代求解得X?(9,?1,?6)T

此种方法叫高斯消去法,下面用高斯列主元素消去法

??2?13154??r?r?42?25r?(?1?42)r1??4254?21?131???2?21?120????27????1207????0?r23?(?14)r1??3?02?54 3

4????1??6??? ??54??r3?3?42??4r2??0?21?2?1??

??00?721?84??得同解方程组

???4x1?2x2?5x3?4???2x1?2?2x3??1 ????7218x3?4回代求解得

X?(9,?1,?6)T

??11?3?23?11??2311r?r??231110?r2?r1?②?52??231110???21?11?3?23??23?122?1??????122?1??0??r?1r?233231??57?023???231110?????231110??r3?r2????5747?r3?(?5257)r2??0?1??2323?1????5747?0?

?5235??2323223??023?233????00?1935757??得同解方程组

????23x1?11x2?x3?0??0?57x?47x?232233??1 ???0?0?(?19322357)x3?57回代得

X?(0.212435,0.549222,?1.15544)T4

10???35?233??47?23?1??

4、用Jordan消去法解矩阵方程,AX?B其中:

?11?1??10??,B??01? A??12?2????????211???10??解:容易验证A?0,故A可逆,有X?A?1?B .因此,写出方程组的增广矩阵,对其进行初等变换得

??11?1?10??11?110??11?1?12?2?01???01?1?11???01??211??30????1??10????03?1???002?????10?1002?1???02?1??01?1?11??????01????0013?3??102?

2??2????0013?3?2??????2?1???X?A?1?B??1?2??2??

??3?3?2???25?6??x1??10?5、用LU分解法求解如下方程组??413?19??x???19? ??6?3?6???2???????x3?????30???100?解:A?LU???210???25?6?03?7? ??341????????004??(1)解Ly?b??1??y1??10??21??y???19??41???2?????3???y 3?????30??得y1?10,y2?19?20??1,y3?34?30?4即y?(10,?1,4)T 5

10??11? 6?3???

(2)解Ux?y?25?6??x1??10??3?7??x????1????2????4?????x3????4??解得:x3?1,x2?2,x1?3

所以方程组的解为x?(3,2,1)T。 6

第三章 解线性方程组的迭代法

?1aa?a131、

A????a1a?orA???a?R

???1a2??aa1?????32a???若Jacobi迭代收敛,求a的范围

??1aa??解:(1)、A??a1a?0?a时的Jacobi迭代矩阵B???a0????aa1?????a?a?aa?E?B?a?a?(??2a)(??a)2

aaaJacobi迭代收敛??(B)?1?????2a?1???1?a?1 ?a?122?a13?(2)、A???1a2?Jacobi迭代矩阵 ?32a??????a?1?3B?1??a??10?2? ?3?20?????13aa2121?E?B?1aa?a?2?a??2?1a?3a2

?32a?a?3a?a?3aaaa?=?(?2?4a2)?116323a(a???a2)?a(a2?a?) ??(?2?48a???(?24a2)?2?a2)

???221?0?2ai?3??ai

7

?a??a?0??? ??1?12?Jacobi迭代收敛??(B)?1???2?1??i?1?a?2

a???1?32、讨论AX?b的Jacobi迭代和Gauss-Seidel迭代的收敛性

?1?22???11?1其中,A???????2?21??b?(1,1,0)T

?1??02?2?????解:Jacobi迭代法的迭代矩阵BJ??1?(I?A)??101?

??220?1??????1则?I?BJ??3?0??(BJ)?0?1

?Jacobi迭代收敛 Gauss-Seidel迭代矩阵

?1??????11???2?21????1BG?S?02?2??1??02?2??02?2?????????01?1101?02?1???????? ??????0?0????421????08?6??I?BG?S??(?2?4??4)?0??(B2)?2?22?1

?Gauss-Seidel迭代发散 3、讨论下列迭代法的收敛性

①AX?b的G-S迭代

?211?? A??131????125??②X(K?1)?BX(k)?b

?0.1?0.5B???0.02??0.50.20.10.30.10.30.1?0.20.1?? 0.20.3??0.20.05????0?0.5?0.5???11解:①?(D?L)?1?U??0???B

?66??11??0?306?? 8

?E?B?1?(30?2?10??1)?0 30?1?0?2?3?10??20

2?30??1故(?B)=max?i?1?Gauss?Seidel迭代收敛

②||B||??0.9?1,故B的谱半径?(B)?||B||??1,由迭代法收敛的充分必要条件知该迭代格式收敛

9

第五章 非线性方程和方程组的数值解法

1、给定函数f(x),设对一切x,f'(x)存在且0?m?f'(x)?M

证明:?0???2,迭代过程xk?1?xk??f(xk)均收敛于f(x)?0的根? M证明:f(x)?0的等价形式为x?x??f(x)

则xk?1?xk??f(xk)对应的迭代函数

?(x)?x??f(x) ?'(x)?1??f'(x)

0?m?f'(x)?M0??m??f'(x)???M?20???m???f(x)???M??21?1??m?1??f'(x)?1??M??1??'(x)?1??f'(x)?max?1??m,1??M??1

'

易证f(x)?0有根,故迭代过程xk?1?xk??f(xk)收敛于f(x)?0的根? 2、证明:?x0?R,由xk?1?cosxk(k?0,1,2)所产生的序列收敛于x?cosx的根

证:①考虑区间??1,1?

?x???1,1??x???1,1?,,?(x)?cosx???1,1??(x)?sinx?sin1?1'

??x0???1,1?由xk?1?cosxk所得序列收敛于cosx?x的根

②?x0?R,x1?cosx0???1,1?,将x1看作新的迭代初值,则由①知序列必收敛于x?cosx的根 3、利用适当的迭代格式证明

lim2?2???2?2

??????k?????k个2 10

??x?2?xk证:考虑迭代式?k?1x0?0??(k?0,1,2,?)则

x1?2x2?2?2 ?xk?2?2???2?

显然xk??0,2? 记迭代函数?(x)?2?x,x??0,2?则:?'(x)?1

22?x??x??0,2?

有1°?(x)??0,2? 2°?'(x)??'(0)?1?1 22由迭代法的全局收敛定理(压缩映像原理)知

?x0??0,2?由xk?1?2?xk所产生序列收敛于x??(x)?2?x的根 在?0,2?上解方程x?2?x得惟一根x=2。

?limxk?2

k??

4、研究求a的牛顿公式

1axk?1?(xk?),x?0,k?0,1,?

2xk证明:对一切k?1,2,?,xk?a,且?xk?单调递减,从而收敛。 分析,令x?a,x?0,则x2?a,x?0,令f(x)?x2?a 由牛顿公式

2f(xk)xk?a1axk?1?xk?'?xk??(xk?)

f(xk)2xk2xk证:a?0,x0?0,故xk?0,(k?1,2,?)

1a1axk?1?(xk?)??2?xk??a

2xk2xk

11

xk?11a?(1?2)?1 xk2xk??xk?单调递减有下界,必收敛

5、设?(x)?x?c(x2?3),应如何选取c才能使迭代式xk?1??(xk)具有局部收敛性

2?xk?1??(xk)?xk?c(xk?3)解:迭代格式??x0给定k?0,1,2,?

局部收敛,设迭代序列的极限值为?,则有

????c(??3)

得?2?3或???3

?'(x)?1?2cx

当?'(3)?1,即1?23c?1,即?1?c?0时,由局部收敛定理知 3迭代格式xk?1??(xk)局部收敛于3 '(?3)?1,即1?23c?1,即0?c?当?1时,由局部收敛定理知 3迭代格式xk?1??(xk)局部收敛于?3 6、给出计算x?11?11??的迭代公式,讨论迭代过程的收敛性并证明x?5?1 2解:令x1?111,x2?,?,xn?1?,?

111?11?1?1?11??其中,xn中有n条分数线 则:xn?1?令f(x)?1,且limxn?x n??1?xn1则xn?1?f(xn) 1?x12

?1?显然,?x0?0,x1?(0,1),xk??,1?,k?2,3,?

?2??1?我们不妨在?,1?上讨论迭代式xn?1?f(xn)的收敛性

?2??1?ⅰ:?x??,1?,?2??1?ⅱ:?x??,1?,?2?f(x)?1?1???,1? 1?x?2?14??1 2(1?x)9f'(x)?ⅲ:f'(x)??11 ?C?1?2,11?x?2???1?1?所得序?由全局收敛定理(压缩映像原理)?x0??,1?,xk?1?f(xk)?1?xk?2?列必收敛于方程x?f(x)?解方程x?1的根。 1?x15?1得x? 1?x2?limxn?n??5?1 2?5?12即:

1?111?? 13

第六章 插值法与数值微分

1、设f(x)?c2?a,b?,且f(a)?f(b)?0,求证

(b?a)2maxf(x)?maxf''(x) a?x?ba?x?b8证:以a,b为插值节点进行线性插值,其插值多项式为

L1(x)?x?bx?af(a)?f(b)?0 a?bb?a由插值余项定理

f''(?)f(x)?L1(x)?(x?a)(x?b)2!??(a,b)

f''(?)1?f(x)?(x?a)(x?b)?maxf''(?)?max(x?a)(x?b)a?x?b2!2a???b1?(b?a)2maxf''(x)a?x?b82、试构造一个三次Hermite插值多项式,使其满足:

H(0)?1,H'(0)?0.5,H(1)?2,H'(1)?0.5

解:(法一)首先构造如下的基函数表

则:

函数值 0 1 0 0 0 1 0 1 0 0 导数值 0 0 0 1 0 1 0 0 0 1 ?1(x) ?2(x) H1(x) H2(x) ?1(x)?(ax?b)(x?1)2??1(x)?(2x?1)(x?1)2 ?2(x)?(ax?b)?(x?0)2??2(x)?(?2x?3)?x2

H1(x)?ax(x?1)2?H1(x)?x(x?1)2

14

H2(x)?a(x?1)?x2?H2(x)?(x?1)?x2

?H(x)?(2x?1)(x?1)2?2(?2x?3)?x2?11x(x?1)2?(x?1)?x2 22(法二):令H(x)?a0?a1x?a2x2?a3x3

?a0?a1?0?a2?02?a3?03?1?23?a0?a1?1?a2?1?a3?1?2 ?2?a1?2a2?0?3a3?0?0.52??a1?2a2?1?3a3?1?0.513a0?1a1?a2?a3??1

2213?H(x)?1?x?x2?x3

22则H'(x)?a1?2a2x?3a3x2

3、确定一个不高于四次的多项式H(x),使得:

H(0)?H'(0)?0,H(1)?H'(1)?H(2)?1

解:(法一)首先构造如下的基函数表

则:

54?1(x)?(ax?b)x2(x?2)??1(x)?x2(x?2)2 0 1 0 0 0 0 函数值 1 0 1 0 0 0 2 0 0 1 0 0 导数值 0 0 0 0 1 0 1 0 0 0 0 1 ?0(x) ?1(x) ?2(x) ?0(x) ?1(x) ?0(x)?(ax?b)(x?1)2(x?2)??0(x)?(?x?)(x?1)2(x?2)

12x(x?1)2412?2(x)?a(x?1)2x2??2(x)? 15

1 2?1(x)?a?(x?1)(x?2)?x2??1(x)??(x?1)(x?2)?x2?0(x)?a(x?1)2?x?(x?2)??0(x)??x(x?2)(x?1)2?H(x)?0??0(x)?1??1(x)?1??2(x)?0??0(x)?1??1(x)?x2(x?2)2??12x(x?3)2412x(x?1)2?(x?1)(x?2)x24

(法二)令H(x)?a0?a1x?a2x2?a3x3?a4x4 则H'(x)?a1?2a2x?3a3x2?4a4x3

?a0?a1?0?a2?02?a3?03?a4?04?0?a0?0?a0?a1?1?a2?12?a3?13?a4?14?1??234 ?a0?a1?2?a2?2?a3?2?a4?2?1?a?2a?0?3a?02?4a?03?0?a?02341?123??a1?2a2?1?3a3?1?4a4?1?1得

H(x)?923314x?x?x424

121?x(9?6x?x2)?x2(x?3)244'4、求三次多项式P3(x),使得PPP3(0)?P3(0)?0,3(1)?1,3(2)?3

解:令P(x)?a0?a1x?a2x2?a3x3 则P'(x)?a1?2a2x?3a3x2

?a0?a1?0?a2?02?a3?03?0?2?a1?2a2?0?3a3?0?0?23?a0?a1?1?a2?1?a3?1?123??a0?a1?2?a2?2?a3?2?3a0?0a1?0 a2?a3?14a2?8a3?3

P3(x)?5211x?(?)?x3?x2(5?x) 4445?a???24?? 1?a??3??45、求一个次数?3的多项式P3(x),使得P3(0)?1,P3(1)?2,P3(0)?P3(1)?解:令P(x)?a0?a1x?a2x2?a3x3

16

''1 2则P'(x)?a1?2a2x?3a3x2

?a0?a1?0?a2?02?a3?03?1?2?a1?2a2?0?3a3?0?0.5?23?a0?a1?1?a2?1?a3?1?22?a?2a?1?3a?1?0.5123?(1)(2)(3)(4)

由(1)得a0?1 由(2)得a1?0.5 由(3)得

a0?a1?a2?a3?2 (5)

由(1)得

a1?2a2?3a3?0.5 (6)

把a0?1、a1?0.5代入(5)、(6)得

a2?1.5、a3??1

?6、给出概率积分y(x)?2P(x)?1?0.5x?1.5x2?x3

??x0e?xdx的数据表如下:

2x y(x) 0.46 0.484655 0.47 0.493745 0.48 0.502750 0.49 0.511668 试用拉格朗日插值法计算x?0.427时,该积分值等于多少? 解:记

x1?0.46x2?0.47x3?0.48x4?0.49y4?0.511668y1?0.484655y2?0.493745y3?0.502750

将y看成x的函数y?y(x),以x1,x2,x3,x4式:

为插值节点作y(x)的3次插值多项

L3(x)?y1?l1(x)?y2?l2(x)?y3?l3(x)?y4?l4(x)?y1?(x?x2)(x?x3)(x?x4)(x?x1)(x?x3)(x?x4)

?y2(x1?x2)(x1?x3)(x1?x4)(x2?x1)(x2?x3)(x2?x4) 17

?y3(x?x1)(x?x2)(x?x3)(x?x1)(x?x2)(x?x4) ?y4(x3?x1)(x3?x2)(x3?x4)(x4?x1)(x4?x2)(x4?x3)y(0.472)?L3(0.472)??0.02326344?0.42659568?0.108594?0.016373376 ?0.495582864?当x?0.472时,概率积分y(0.472)?

2??0.4720e?xdx

2?0.495582864

7、利用y?x在x0?100,x1?121,x2?144处函数值计算115的近似值并估计误差.

解: y?x过点(100,10)、(121,11)、(144,12),

令x0?100,y0?10,x1?121,y1?11,x2?144,y2?12, 则y?x的二次Lagrange插值多项式

L2(x)?y0l0(x)?y1l1(x)?y2l2(x)(x?121)(x?144)(x?100)(x?144)

?10??11?(100?121)(100?144)(121?100)(121?144) ?12?(x?100)(x?144)

(144?100)(144?121)?115?y(115)?L2(115)?10.722756y'''(?)|R(115)|?|(115?100)(115?121)(115?144)|3!13?5?|??2?15?6?29|3!85?13???1002?15?6?29 68?1.63125?10?3??[100,144]

18

第七章 数据拟合与函数逼近

1、用最小二乘法求一个形如y?a?bx2的经验公式,使它与下列数据相拟合

xi yi 19 19.0 25 32.3 31 49.0 38 73.3 44 97.8 ?19.0?a?b?192?232.3?a?b?25??解:(法一)建立超定方程组?49.0?a?b?312

?73.3?a?b?382?2??97.8?a?b?44?1??1即:?1??1?1?192??19.0???32.3?252???a2???31?????49.0?

b??2???73.338????442??97.8????1?11???2?144???1?1?192??252?a2???31???b2???38?442???19.0??32.3??1???49.0? 442???73.3?????97.8??解

?1?192?125213121382?1?192?1112523123825327??a??271.4??5得????????53277277699??b??369321.5??a?0.972606 ??b?0.0500351?(法二)利用公式建立正规方程组

?5??1?i?1?52??xi?i?1??5?x?y??i??a??i?1i?1??????

55b????22?2x?xxy?ii???ii?i?1??i?1?2i5 19

5327??a??271.4??5?53277277699??b???369321.5? ???????a?0.972606 ???b?0.05003512、求形如y?a?ebx(a,b为常数且a?0)的经验方式,使它能和下表数据相拟合

xi yi 1.00 5.10 1.25 5.79 1.50 6.53 1.75 7.45 2.00 8.46 解:对经验方式y?a?ebx作变换,有lny?lna?bx,令

y?lny,?A?l则na,???yAbx,为了用最小二乘法求出A,b将(xi,yi)转化为

(xi,yi)

?

xi yi 1.00 1.25 1.50 1.75 2.00 1.629 1.756 1.876 2.008 2.135 (法一)建立超定方程组

?1.629?A?1.00b?1.756?A?1.25b???1.876?A?1.50b ?2.008?A?1.75b???2.135?A?2.00b即:

?1?1??1??1??11.00??1.629??1.756?1.25???A???1.50??????1.876?

??b???1.75?2.008???2.00???2.135??得正规方程组

20

?1?11111???1?1.001.251.501.752.00??1????1??11.00?1.25???A?1.50??????b?1.75?2.00???1.629??1.756????1.876? ??2.008????2.135??1111??1?1.001.251.501.752.00???即:

?5??1?i?1?5??xi?i?1??5??x????yi?A??i?1?????i?1? 55??b??x2y?2?x?i???ii?i?1??i?1?2i57.5??A??9.404??5?7.511.875??b???14.422? ??????解之得:

A?1.1224a?eA?3.0722b?0.5056

?y?3.0722e0.5056x?2x?4y?11?3x?5y?3?3、解超定方程组?

?x?2y?6??2x?y?7?24??11??3?5?x?3????解:由????得正规方程组 ???12??y??6?????21???7??24??11??????2312??3?5??x??2312??3??4?521??12??y???4?521??6? ??????????21???7??18?3??x??51?即:???? ?????346??y??48?

21

解之得

x?3.0409,y?1.2418

22

第八章 数值积分

1、用复化梯形求积公式求?e?xdx的近似值,问要将?0,1?分成多少等分才能保证

01结果有四位有效数字,若用复化抛物线公式呢?

1解:要求结果有四位有效数字?此处误差???10?4

2b?a2''?hf(?)12b?a1b?a?1?0?1h??hnR(f,Tn)?????0,1?

f''(x)?e?xh2''111???4f(?)??e?????10要使R(f,Tn)? 221212n12n21只需n2??1046,即n?40.8n?41

若用复化抛物线公式,则

b?a4(4)h4??11R(f,Sn)??hf(?)?e???10?4 4288028802880n2?n?2

故:用复化梯形求积公式至少需要41等分才能保证结果有四位有效数字,而用复化抛物线公式只需2等分就可以保证结果有四位有效数字。

2、对于积分?ex?sinxdx,当要求误差小于10?6时,用复化梯形公式计算所需节

13点数是多少?

f(x)?ex?sinx a?1,b?3,??10?6解: b?a2h??, 则nnR(f,Tn)??b?a23?122h?f''(?)???()?f''(?) 1212n2''f(?) ???1,3? ??23n

f'(x)?2exsin(x?)4

f''(x)?2excosx

23

?maxf''(x)?max2excosx?2e3

1?x?31?x?3214e33?R(f,Tn)??2?2e?2

3n3n4e3要使R(f,Tn)??,只需2??

3n4e3e即:n??2e?103?5175.01

3?3取n?5176

?要使误差小于10?6,至少要取5176个节点

113、用Romberg方法求I??exdx,使误差不超过?10?5

02解:

k T0(k) 1.8591409 1.7539311 1.7272219 1.7205186 T1(k?1) 1.7188612 1.7183188 1.7182842 T2(k?2) 1.7182827 1.7182818 T3(k?3) 1.7182818 0 1 2 3 1T3(0)?T2(0)?9?10?7??10?5

24、用Romberg求积法求积分I??4解:f(x)?1?x2a?041?4dx?10的近似值要求误差不超过 01?x221b?1T(k)m(k?1)(k)4mTm?1?Tm?1?,则

4m?1xi 0 1 0.5 0.25 0.75 0.125 0.625

24

f(xi) 4.0000000 2.0000000 3.2000000 3.7647059 2.5600000 3.9384615 2.8764045 0.875 2.2654867 按公式计算如下:

k T0(k) 3.0000000 3.1000000 3.1311765 3.1389885 3.1409416 T1(k?1) 3.1333333 3.1415678 3.1415925 3.1415927 T2(k?2) 3.1421176 3.1415941 3.1415927 T3(k?3) 3.1415858 3.1415926 0 1 2 3 4 1|R2?R1|?|3.145926?3.1415858|??10?4

214dx?R2?3.1415926为所求近似值 故?01?x25、分别用抛物线公式和三点高斯公式计算积分?x2cosxdx,并比较它们的精度,

?11准确值为0.478267254

解:设f(x)?x2cosx,则f(1)?f(?1)?0.540302305,f(0)?0 由抛物线(辛普森)公式

?1?1x2cosxdx?22?f(?1)?4f(0)?f(1)???0.540302305 63?0.360201537由三点高斯公式

?1?1x2cosxdx?53853f(?)?f(0)?f() 95995f(0)?0

而f(33)?f(?)?0.428821915,55153故?x2cosxdx??2?f(?)?0.476468795

?195与准确值比较知:Simpson公式的计算结果无有效数字;三点高斯公式有两位有效数字。

6、确定如下求积公式中的待定参数,使其代数精度尽量高,并指出代数精度

?

1?1f(x)dx?1?f(?1)?2f(?)?3f(?)? 325

解:当f(x)?1时,左边??1dx?2

?11

右边?1?1?2?1?3?1??2 31 左边=右边

?1 当f(x)?x时,左边??xdx?0

1??1?2??3?? 312 当f(x)?x2时,左边??x2dx?

?131222?(?1)?2??3? 右边??? 3? 右边?要使求积公式具有2次代数精度,当且仅当

?1(?1?2??3?)?0??3 ?12?(1?2?2?3?2)??3?3?2??3??1即?2 2?2??3??1?1?6???1?5得? ???3?261?15??1?6???2?5或? ???3?262?15?

将(?1,?1)代?求积公式得

1?1?63?26???1f(x)dx?3?f(?1)?2f(5)?3f(15)?

??1当f(x)?x时,左边??x3dx?0

3?111?1?633?263?)?3()??0 右边??(?1)3?2?(3?515?左边?右边,故此时求积公式具2次代数精度; 将(?2,?2)代入求积公式得

1?1?63?26?f(x)dx?f(?1)?2f()?3f()? ???13?515?1 26

当f(x)?x时,左边??x3dx?0

3?11

1?1?633?26?)?3()??0 右边???1?2(3?515?左边?右边,故此时求积公式具2次代数精度

1?63?261?63?26综上:??5,??式具最高代数精度2。

15或??27

5,??15时,所得求积公第九章 常微分方程的数值解法

1、用Euler预估—校正格式求解初值问题

?dy2??y?ysinx?0 ?dx??y(1)?1要求步长h?0.2,计算y(1.2)及y(1.4)的近似值 解:设f(x,y)??y?y2sinx,x0?1,y0?1,xn?x0?nh?1?0.2h

?yn?1?yn?hf(xn,yn)?Euler预估—校正式为? h???yn?1?yn??f(xn,yn)?f(xn?1),yn?1??22??yn?1?yn?0.2(yn?ynsinxn) ??22??yn?1?yn?0.1(yn?ynsinxn?yn?1?yn?1sinxn?1)由y0?1计算得:

??y1?0.631706 ???y(1.2)?y1?0.715489

??y2?0.476965 ???y(1.4)?y2?0.5261122、用欧拉法解初值问题

?y'?10x(1?y)??y(0)?0(0?x?1.0)

2取步长h?0.1,保留5位有效数字,并与准确解y?1?e?5x相比较 解:h?0.1,xi?ih,i?0,1,2?,10

f(x,y)?10x(1?y)欧拉公式如下:

y(x)?1?e?5x2

?yi?1?yi?hf(xi,yi)?yi?10hxi(1?yi) ??y0?0?yi?1?xi?(1?xi)?yi即:??yo?0计算结果如下表所示

i?0,1,?,9

28

i xi 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 yi 0 0.10000 0.28000 0.49600 0.69760 0.84880 0.93952 0.98186 0.99637 0.99964 y(xi) 0.048771 0.18127 0.36237 0.55067 0.71350 0.83470 0.91371 0.95924 0.98258 0.99326 y(xi)?yi 0.048771 0.081269 0.082372 0.054671 0.015895 0.014099 0.025814 0.037132 0.013792 0.006378 1 2 3 4 5 6 7 8 9 10

?dy2?hn???y),②3、对初值问题?dx①步长为h时,用梯形公式得近似解yn?(2?h??y(0)?1h?0时,yn收敛于准确解

解:y'??y?dy??dx?lny??x?C?y?e?x?c y又y(0)?1,故y?e?x(准确值)

?x?[0,R],考虑区间[0,x],步长为h时,等分数为n,显然有h=x-0 n①由梯形公式f(x,y)??y

yn?1?yn?h?f(xn,yn)?f(xn?1,yn?1)?2

h?yn???yn?yn?1?22?h2?h22?hn?1?yn?()?yn?1???()?y02?h2?h2?h

2?hn?yn?()2?h?yn?1? 29

x?02?hnn)n ②limyn?lim()?lim(h?0h?02?hh?0x?02?n2?x2x11??1n1nnnnn?lim()?lim(1?)?lim(1?)?lim[(1?)x22]xn??n??n??xxn1n??n12?2???nnx2x2

111???1n1n1?1x22xx2?[lim(1?)]?[lim(1?)lim(1?)2]x?[e?1?1]x?e?xn??n??n??n1n1n1???x2x2x22?4、取h?0.2,用改进Euler法的预估—校正式求解初值问题

?dy2?2?xy??dx3??y(0)?10?x?1.2

2?2xy 3解:h?0.2,xn?nh(n?0,1,2,?,6),f(x,y)?Eute预估—校正式

?yn?1?yn?hf(xn,yn)? ?hf(xn,yn)?f(xn?1,yn?1)??yn?1?yn?????22??2y?y??x?ynnnn?1?15?即:?1?22??2?yn?1?yn???xn?yn??xn?1?(yn?1)?2??10?33??由y0?1出发,计算结果列于下表

n 0 1 2 3 4 5 xn 0 0.2 0.4 0.6 0.8 1.0 yn 1 1.013333 1.051006 1.108248 1.179552 1.260130 yn?1 1 1.039303 1.099288 1.173383 1.256216 1.344097 yn?1 1.013333 1.051006 1.108248 1.179552 1.260130 1.346395 30

6 1.2 1.346395 ?y'??y?x?15、已知?,0?x?1,取h?0.1,用Euler公式求各点上的近似值

y?1?0解:取步长h?0.1x0?0,xj?x0?jh?0.1j(j?0,1,?,10)

f(x,y)??y?x?1,由Euler公式得

故f(xj,yj)??yj?xj?1

?y0?1??yj?1?yi?hf(xj,yj)??y0?1 即:??yj?1?yj?0.1(?yj?xj?1)?y0?1 ?y?0.9y?0.1x?0.1jj?j?1计算结果列于下表

xj 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 yj 1.00000 1.00000 1.01000 1.02900 1.0561 1.09049 1.13144 1.17830 1.23047 xj 0.9 1.0 yj 1.28742 1.34868 6、取步长h=0.1,用Euler法求解如下初值问题并与精确解y?1?2x进行比较.

2x?dy?y?0?x?1? y?dx?y(0)?1?解:取h?0.1,计算x?[0,1]上结果,此时 Euler法:yn?1?yn?0.1(yn?2xn)yn(n?0,1,2,...)?1?yn?1?yn?(k1?k2)2??2xn改进的Euler法:)?k1?0.1(yn?yn??2(xn?0.1))?k2?0.1(yn?k1?y?kn1?计算结果如下表所示:

31

(n?0,1,2,...) x Euler法y 改进的Euler法y 精确解 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0

1.000000 1.000000 1.191818 1.277438 1.358213 1.435133 1.508966 1.580338 1.649783 1.717779 1.784770 1.000000 1.095909 1.184097 1.266201 1.343360 1.416402 1.485956 1.552514 1.616475 1.678166 1.737867 1.000000 1.095445 1.183216 1.264911 1.341641 1.414214 1.483240 1.549193 1.612452 1.673320 1.732051 32

本文来源:https://www.bwwdw.com/article/h3p7.html

Top