环工数学模式课程大纲_第1页
环工数学模式课程大纲_第2页
环工数学模式课程大纲_第3页
环工数学模式课程大纲_第4页
环工数学模式课程大纲_第5页
已阅读5页,还剩5页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、環工數學模式課程大綱Syllabus of Numerical Methods in Environmental Engineering· Lecturer: Prof. Chungsying Lu· Time: Thursday, 14:10 17:00· Location: Room 406· Grading:Exams: 45% Homework: 55%· Course Outlines:1. Review of Fortran 77 (Homework 1)2. Initial Value Problem (IVP)(Homework

2、 2)3. Boundary Value Problem (BVP)(Homework 3)4. Partial Differential Equation (PDE)(Homework 4)5. Mathematics application on environmental problemExamination: 14:10 17:00, 11/27/2008Class notes:NEWTON'S METHOD (NEWTON-RAPHSON)Consider a point x0 which is not a root of the function f(x), but is

3、”reasonably close” to a root. We expand f(x) in a Taylor series about x0 :(1)If f(x) is set equal to zero, then x must be a root and the right-hand side of (1) constitutes an equation for the root x. Unfortunately, the equation is a polynomial of degree infinity. However, an approximate value of the

4、 root x can be obtained by setting f(x) to zero and taking only the first two terms of the right-hand side of (1) to yield(2)Solving for x gives(3)or(4)Now x represents an improved estimate of the root, and can replace x0 in (3) to yield an even better estimate of the root on the next iteration. The

5、 general expression for Newton's method can thus be written as(5)where the superscript n denotes values obtained on the nth iteration and n+1 indicates values to be found on the (n+l)th iteration. This iterative procedure will converge to a root for most functions, and if it does converge; it wi

6、ll usually do so extremely rapidly. A flow chart of the algorithm is shown, in Fig. 3.Fig. 3 Newton's methodThe algorithm is terminated when the magnitude of the computed change in the value of the root, , is less than some predetermined quantity . This does not guarantee an accuracy of in the r

7、oot. Although more sophisticated convergence analyses are possible, a useful and conservative rule of thumb is to choose as one-tenth of the permissible error in the root. An additional point should be made concerning Fig. 3. and in fact all flow charts given in this chapter. No error exits have bee

8、n provided in case the method diverges or does not find a root in a reasonable number of iterations. A computer program written from this flow chart should include such exits as the programmer feels necessary, but it should be noted that these exits require logic which will increase the running time

9、 of the program. If enough is known about the character of the function, such exits may not be necessary.Despite its rapid convergence, Newton's method has some difficulties with certain types of functions. These difficulties can best be examined, and the most intelligent use made of this powerf

10、ul method, by considering the graphical interpretation of the algorithm. Figure 4 shows the first iteration for a typical function. The next guess for the root, x(1), is the intersection with the x axis of a straight line tangent to the function at x0. The value x(1) is much closer to the root than

11、the original guess x0, and it is clear that succeeding iterations will converge rapidly to the root.Fig 4.Consider next the simple oscillatory function shown in Fig. 5. The first guess, x0, is reasonably close to the root A. However, the tangent line strikes the axis at x(1), which is closer to the

12、root B. The next iteration yields x(2), and it becomes clear that the procedure will converge to the root B. This illustrates one of the possible difficulties of Newton's method ; an initial guess which is close to one root may result in convergence to a different more distant root. There is no

13、simple method for avoiding this type of behavior with certain functions. However, the rough plots or tabulations of the function discussed earlier will usually be sufficient to permit first guesses from which the method will eventually yield the desired roots. In any case, these plots will ensure th

14、at the programmer is aware of the presence of any roots which the method may have missed.Newton's method also has a tendency to home-in on a local minimum or maximum in a function (not a root) and then as the zero slope region is approached to be thrown far from any region of interest. The algor

15、ithm can also occasionally oscillate back and forth between two regions containing roots for a fairly large number of iterations before finding either root. These difficulties can be readily avoided with some prior knowledge of the behavior of the function.It should be noted that some difficulty wil

16、l be encountered in attempting to use Newton's method to find multiple roots. For smooth functions, these multiple roots correspond to points where the function becomes tangent to the x axis and then may or may not cross the axis. This behavior means that as f(x) approaches zero, so does f(x). W

17、hile Newton's method can be shown to be formally convergent for such roots, the rate of convergence is slow, and in practice can make the computation of multiple roots difficult and expensive. A modified Newton's method, which is very well suited to multiple roots, will be discussed in the n

18、ext section.PRINCIPLE OF ENVIRONMENTAL MATHEMATICSHomework 1Due: November 6, 2008Instructor: Dr. Chungsying Lu (Familiarity with the PC system, Review of FORTRAN)1) Work on the personal computer and become familiar with the Editing System. Learn how to create directories, manage files (save and dele

19、te), and print and type files. You do not need to submit anything for this problem.2) Write a FORTRAN subroutine to find one root of a general function f(x) using Newton's method. Assume that the method will converge to a root. Then, write a main program to drive the subroutine. The main program

20、 should contain all the READ and WRITE statements. Verify the general programs above by finding the positive root of the following equations:1. 2. 3. Fortran exsample1. 主程式(Main program)C*C* HOMEWORK #0 QUADRATIC EQUATION *C* STUDENT'S NAME: LU, CHUNG-SYING *C* THIS PROGRAM IS USED TO SOLVE A GE

21、NERAL QUADRATIC EQUATION AS FOLLOWING:*C* AX*2+BX+C=0 *C* THE PROGRAM LU1.FOR USES THE SUBROUTINE SOLVE.FOR TO FIND THE ROOTS *C* FOR A QUADRATIC EQUATION. THE VALUES FOR A, B, AND C ARE INPUTTED *C* FROM THE TERMINAL AND OUTPUT IS IN A FILE. THIS PROGRAM WAS WRITTEN *C* BY LU, CHUNG-SYING, APRIL, 2

22、0, 1987 *C*CC*C* MAIN PROFRAM *C* IMPLICIT REAL*8 (A-H,O-Z) CHARACTER *15 NAME CHARACTER *1 ANDSET WRITE(6,10) 10 FORMAT(1X,'ENTER OUTPUT FILE NAME ( MAX 15 CHARACTER )')!KEYIN FILE NAME READ(5,20) NAME 20 FORMAT(A15) OPEN(UNIT=9,FILE=NAME,STATUS='NEW')!MAKE A NEW FILE 25 WRITE(6,30)

23、 30 FORMAT(1X,'ENTER THE VALUES OF A,B,C FOR THE QUADRATIC EQUATION:' +,/,1X,'AX*2+BX+C=0',1X)!KEYIN VALUES READ(5,40) A,B,C 40 FORMAT(3F8.3)C*C* CALL SUBROUTINE ' SOLVE.FOR' TO SOLVE THE ROOTS *C* CALL SOLVE(A,B,C,X1,X2,DIS)C WRITE(6,50) A,B,C WRITE(9,50) A,B,C 50 FORMAT(1X,

24、'FOR THE QUADRATIC EQUATION:',F8.3,'X*2+',F8.3,'X+', +F8.3,'=0') WRITE(6,60) X1,X2!ROOT X1 & X2 WRITE(9,60) X1,X2 60 FORMAT(1X,'THE REAL ROOTS ARE:',F8.3,3X,'AND',F8.3) GO TO 85 70 WRITE(6,80) X1,X2,X1,X2 WRITE(9,80) X1,X2,X1,X2 80 FORMAT(1X,'T

25、HE COMPLEX ROOTS ARE:',/,5X,F8.3,' + ',F8.3,'I AND' +,F8.3,' - ',F8.3,'I') 85 WRITE(6,90) 90 FORMAT(1X,'DO YOU WANT TO SOLVE ANOTHER SER?(Y/N)') READ(5,100) ANDSET!ANSWER 100 FORMAT(1A) IF(ANDSET .EQ. 'Y') GO TO 25 STOP END2.副程式(Subroutine)C*C THE

26、SUBROUTINE SOLVE.FOR IS USED WITH THE MAIN PROGRAM LU1.FOR *C TO FIND THE ROOTS FOR A QUADRATIC EQUATION. THE SUBROUTINE *C WILL FIND BOTH REAL AND IMAGINARY ROOTS. THIS SUBROUTINE WAS *C WRITTEN BY LU, CHUNG-SYING, APRIL 20, 1987. *C* SUBROUTINE SOLVE(A,B,C,X1,X2,DIS) IMPLICIT REAL*8 (A-H,O-Z) DIS=B*2-4*A*C!EQUATION IF(DIS) 13,14,15! IF(DIS) <0, =0, >0 15 D=SQRT(DIS) X1=(-B+D)/(2*A) X2=(-B-D)/(2*A) GO TO 35 14 X1=-B/(2*A) X2=X1 GO TO 35 13 X1=-B/(2*A) X2=SQRT(-DIS)/(2*A) 35 RETURN END3. 解答(Solution)FOR THE QUADRATI

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论