数值实验指导书.doc数值实验一
实验名称:非线性方程求根(Solution of Non-linear Equation)
实验目的:掌握二分法、不动点迭代、牛顿迭代法等常用的非线性方程迭代算法;加深对不同算法
收敛速度、对初值的依赖性等的认识。
基本要求:应用C语言或Fortran语言及Matlab编程,并上机调试通过;2学时。
算法描述:
f(x) =。的二分法(bisection Method):
PURPOSE: To find a solution to F(x)=0 given the continuous function F on the interval [A,B], where F(A)
and F(B) have opposite signs
INPUT: endpoints: A,B, tolerance: TOL>, maximum number of iterations N
OUTPUT: approximation solution P or message that the algorithm fails
Step 1Step 2
Set 1=1
FA = F(A); FB=F(B)
While I < N do Steps3-6
Step 3 Set P=A+(B-A)/2; FP=F(P).
Step 4 IF FP=0 or (B-A)/2<TOL THEN
OUTPUT (P) (Procedure completed successfully)
STOP
END IF
Step 5 Set 1=1+1
Step 6 IF FAxFP>0 THEN
Set A=P; FA=FP
ELSE
Set B=P; FB=FP
END IF
Step 7 OUTPUT (Method failed after N iteration)
STOP x = g (x)的不动点迭代(Fixed-Point Iteration):
PURPOSE: To find a solution to 1 = g (尤)given an initial approximation p°
INPUT: initial approximation p°; tolerance TOL; maximum number of iterations N OUTPUT: approximation solution p or message of fails
Step 1 Set 1=1
Step 2 While
I < N do Steps 3-6
Step 3
Set P = G(P0) (compute g)
Step 4
IF \P-P0\<TOL THEN
OUTPOT (P) (the procedure was successful.)
STOP
END IF
Step 5 Set 1=1+1
Step 6 Set PG = P (Update PG)
Step 7 OUTPUT (Method failed after N iteration)
STOP
/(x) = 0 的牛顿法(Mewton Method):
PURPOSE: To find a solution to f (尤)=0 given an initial approximation p° :
INPUT: initial approximation p。; tolerance TOL; maximum number of iteration N.
OUTPUT: approximate solution p or message of failure.
Step 1 Set i = 1
Step 2 While i < N do Steps 3-6
f'M
Step 4
If \p~P0\<TOL
then
Step 3 Set p = p ,(Po) (^Compute pt *)
Output(p)
Step 5
StopSet py p
Set i = i + 1
Step 6 Set z = z +1
Step 7
Output (The method failed after N iterations)
(* The procedure was unsuccessful *)
Stop.
实验步骤与注意事项:
选择C、Fortran语言或Mat lab编写以上三种算法的通用程序。
用同一初值,用不同的迭代式求方程f(x) = ?+x2-3x-3 = ,比较
数值实验指导书 来自淘豆网www.taodocs.com转载请标明出处.