分享
分销 收藏 举报 申诉 / 92

类型计算物理lecture1102.ppt

  • 上传人:仙人****88
  • 文档编号:14767095
  • 上传时间:2026-11-17
  • 格式:PPT
  • 页数:92
  • 大小:1.35MB
  • 下载积分:10 金币
  • 配套讲稿:

    如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。

    特殊限制:

    部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。

    关 键  词:
    计算 物理 lecture1102
    资源描述:
    单击此处编辑母版标题样式,单击此处编辑母版文本样式,第二级,第三级,第四级,第五级,*,*,*,Numerical differentiation:(,微分法,求导数,),f,The mathematical definition of the derivative of a function,第二章:,Numerical differentiation,f,=,1,The two-point formula for the first-order derivative,The first-order derivative,2,3,Calculate the first derivative of,When x=2,exact,Example,h=0.1,h=0.01,4,h=0.1,exact,h=0.01,5,exact,h=0.01,h=0.1,6,h=0.1,exact,h=0.01,7,The three-point formula for the first-order derivative,8,exact,h=0.1,9,10,The five-point formula for the first-order derivative,11,The three-point formula for the second-order derivative,The second-order derivative,12,13,The five-point formula for the second-order derivative,14,Calculate the second derivative of,x=2,exact,Example,h=0.1,15,exact,16,Calculate the second derivative of,h=0.5,0.1,0.01,0.001,0.0000001,x=0-5,exact,17,x,h=0.1,h=0.01,h=0.001,h=0.0001,h=0.0000001,Exact,0.0,1.000834,1.000008,1.000000,1.000000,1.010303,1.000000,1.0,2.720548,2.718304,2.718282,2.718282,2.753353,2.718282,2.0,7.395216,7.389118,7.389057,7.389056,7.283063,7.389056,3.0,20.102280,20.085704,20.085539,20.085537,20.250467,20.085537,4.0,54.643664,54.598605,54.598155,54.598151,54.711789,54.598150,5.0,148.536878,148.414396,148.413172,148.413161,150.635056,148.413159,18,Figure:Log-log plot of the relative error of the second derivative of exp(x)as function of decreasing step lengths h.The second derivative was computed for x=10.,19,the second derivative of,exp(x,),h,20,The total numerical error is the summation of the truncation and round-off errors.In general,the only way to minimize round-off errors is to increase the number of significant figures of the computer.Furthermore,we have noted that round-off errors will increase due to subtractive cancellation or due to an increase in the number of computations in an analysis.In contrast,the truncation error can be reduced by decreasing the step size.,21,Because a decrease in step size can lead to subtractive cancellation or an increase in computations,the truncation errors are decreased as the round-off errors are increased.Therefore,we are faced by the following dilemma:The strategy for decreasing one component of the total error leads to an increase of the other component!,One challenge in calculations that we face is,to determine an appropriate step size for a particular computation.,22,We would like to choose a large(,an adequately large,)step size in order to decrease the amount of calculations and round-off errors without incurring the penalty of a large truncation error.,23,truncation errors,which result when approximations are used to represent exact mathematical procedures.,24,exact,h=0.1,25,设已知某个函数关系的列表函数值,我们所知道仅仅上述的表列值,它们常常是间接求得的,.,例如是由实验,(,观测,),得来的,或者是从级数或微分方程求得的。问应该如何估算任意一点,x,的值,?,如何估算函数关系,y=,f(x,),第三章:插值,(,Inter,polation),26,设,y=,f(x,),是实变量,x,的单值函数,且已知在给定的,n+1,个互异点处的值,即,插值的基本问题是,寻求多项式,p,(x,),使得,27,Linear interpolation,Parabolic Interpolation,The Lagrange interpolation,The,Aitken,method,The Newton Interpolation,Hermite,Interpolation,插值方法,28,Consider a given discrete data set(,x,i,y,i,)with,i=1,2,3,n+1.T,he simplest way to obtain the approximation of y for,x,x,i,x,i+1,is to construct a straight line between,x,i,and,x,i+1,.Then y is given by,Linear interpolation,线性插值,29,With,being a parameter determined by the specific form y,(x),of the,given discrete data set(,x,i,y,i,).If one draws a quadratic curve pass through,f(x),f(x,i,),f(x,i+1,),then,30,a,x,i,x,i+1,31,Example,f(x)=sin(x);,x,i,=/4,x,i+1,=/2,Let us use linear inter,polation,scheme to find the approximate value of f(3/8).,f(/4)=0.7071,f(/2)=1.0000,32,y,i,=f(/4)=0.7071,y,i+1,=f(/2)=1.0000,y,(3/8)=0.7071+(3/8-/4)(1.0000-0.7071)/(/2-/4),=0.8536,Sin(3/8)=0.9239,33,Parabolic Interpolation,Linear interpolation,34,Parabolic Interpolation,Linear interpolation,35,The,Lagrange,inter,polation,Consider a given discrete data set(,x,i,y,i,)with,i=1,2,3,n+1.,In order to obtain the generalized,inter,polation formula,36,37,显然,满足,38,a,x,i,x,i+1,x,x,i,x,i+1,39,40,例,1,已知,。求,的,Lagrange,插值多项式,从而,解,依公式有,41,关于,Langrange,插值的几点说明,仅与已知数据 有关,与 的原来形式无关,但余式与 密切相关。,若 本身是一个不超过,n,次多项式,则,42,Lagrange,插值公式的缺点是,当插值结点的个数有所变动时(例如,为了提高精度,有时需增加插值节点的个数),Lagrange,因子就要虽之发生变化,从而整个公式的结构也要发生变化,这在计算实践中是不方便的,.,43,为了克服,Lagrange,插值的上述缺点,在这一节中我们引进了,Newton,形的插值公式。,2.Newton,插值,(,Newton Interpolation),显然,n+1,个结点上的,n,次,Lagrange,插值多项式也可以写成下列形式:,44,),(,),(,!,),(,.,),(,!,2,),(,),(,!,1,),(,),(,),(,0,0,),(,2,0,0,0,0,0,x,R,x,x,n,x,f,x,x,x,f,x,x,x,f,x,f,x,f,n,n,n,+,-,+,+,-,+,-,+,=,45,差商,),(,),(,),(,),(,1,2,1,2,1,2,0,1,0,1,0,1,x,x,f,x,x,x,f,x,f,x,x,f,x,x,x,f,x,f,=,-,-,=,-,-,),(,),(,j,i,j,i,j,i,x,x,f,x,x,x,f,x,f,=,-,-,一般地,一阶差商:,由导数的概念引入,差商,:,46,2,1,0,2,0,2,1,1,0,x,x,x,f,x,x,x,x,f,x,x,f,.,.,.,1,2,1,0,0,2,1,1,1,0,n,n,n,n,n,x,x,x,x,x,f,x,x,x,x,x,f,x,x,x,f,-,-,=,-,-,k,j,i,k,i,k,j,j,i,x,x,x,f,x,x,x,x,f,x,x,f,=,-,-,=,-,-,n,阶差商为:,一般地,二阶差商:,,,二阶差商是一阶差商的差商,47,Newton,插值公式,1,),2,(,)式得:,式代入(,48,),4,(,),(,2,1,0,2,2,1,0,1,0,x,x,x,x,f,x,x,x,x,x,f,x,x,x,f,-,+,=,2,1,0,2,2,1,0,1,0,x,x,x,x,f,x,x,x,x,x,f,x,x,x,f,=,-,-,),3,(,),)(,(,),(,),(,),(,1,0,1,0,1,0,0,0,x,x,x,f,x,x,x,x,x,x,f,x,x,x,f,x,f,-,-,+,-,+,=,得,2,x,,则,为了提高精度,增加节,点,)式得:,式代入(,3,),4,(,49,上有,一般的,在节点,n,x,x,x,x,.,2,1,0,x,x,x,x,f,x,x,x,x,x,x,),)(,)(,(,2,1,0,2,1,0,-,-,-,+,),(,),(,.,),)(,).(,)(,(,.,),).(,)(,(,.,),)(,(,),(,),(,),(,1,0,1,1,0,1,1,0,2,1,0,2,1,0,1,0,1,0,0,0,n,n,n,n,n,n,n,x,R,x,N,x,x,x,x,f,x,x,x,x,x,x,x,x,x,x,x,f,x,x,x,x,x,x,x,x,x,f,x,x,x,x,x,x,f,x,x,x,f,x,f,+,=,-,-,-,-,+,-,-,-,+,+,-,-,+,-,+,=,-,-,-,插值公式和余项。,上的,在节点,分别为,、,其中,Newton,),(,),(,),(,0,n,i,n,n,x,x,f,x,R,x,N,x,x,f,x,x,x,x,x,x,f,x,x,x,f,x,f,),)(,(,),(,),(,),(,1,0,1,0,1,0,0,0,-,-,+,-,+,=,x,2,50,),(,),(,!,),(,.,),(,!,2,),(,),(,!,1,),(,),(,),(,0,0,),(,2,0,0,0,0,0,x,R,x,x,n,x,f,x,x,x,f,x,x,x,f,x,f,x,f,n,n,n,+,-,+,+,-,+,-,+,=,),(,),(,.,),)(,).(,)(,(,.,),).(,)(,(,.,),)(,(,),(,),(,),(,1,0,1,1,0,1,1,0,2,1,0,2,1,0,1,0,1,0,0,0,n,n,n,n,n,n,n,x,R,x,N,x,x,x,x,f,x,x,x,x,x,x,x,x,x,x,x,f,x,x,x,x,x,x,x,x,x,f,x,x,x,x,x,x,f,x,x,x,f,x,f,+,=,-,-,-,-,+,-,-,-,+,+,-,-,+,-,+,=,-,-,-,51,x,y,一阶差商,二阶差商,三阶差商,),)(,)(,(,),)(,(,),(,),(,),(,1,0,1,0,2,1,0,1,0,1,0,0,0,x,x,x,f,x,x,x,x,x,x,x,x,x,f,x,x,x,x,x,x,f,x,x,x,f,x,f,-,-,-,+,-,-,+,-,+,=,2,2,x,3,52,例,1,已知以下列表函数:求这个函数的插值多项式。,x,y,(Newton,插值公式,),),)(,)(,(,),)(,(,),(,),(,),(,1,0,1,0,2,1,0,1,0,1,0,0,0,x,x,x,f,x,x,x,x,x,x,x,x,x,f,x,x,x,x,x,x,f,x,x,x,f,x,f,-,-,-,+,-,-,+,-,+,=,2,2,x,3,53,x,y,一阶差商,二阶差商,三阶差商,5,2,3,4,-3,1/2,1,7/6,1/6,-1/4,x,y,54,x,y,一阶差商,二阶差商,三阶差商,5,2,3,4,-3,1/2,1,7/6,1/6,-1/4,),)(,)(,(,),)(,(,),(,),(,),(,1,0,1,0,2,1,0,1,0,1,0,0,0,x,x,x,f,x,x,x,x,x,x,x,x,x,f,x,x,x,x,x,x,f,x,x,x,f,x,f,-,-,-,+,-,-,+,-,+,=,2,2,x,3,55,因为在个不同的点上取给定值的次数不超过的多项式是唯一的,所以次数相同的,Newton,插值多项式与,Lagrange,插值多项式是恒等的,它们的差异仅是书写形式不同而已。,但是,这种差异却为计算实践带来了很大的方便。实际上,对于,Newton,插值公式来说,当需要增加一个插值结点时,只需在原插值多项式的后面再添加一个新项就可以了。,56,在实际应用中,常是等距节点情况,即,这里,h0,为常数,称为步长,这时,Newton,插值公式就可以简化,为此我们引入差分概念。,等距节点,Newton,插值公式,设函数,f(x,),在等距节点,上值为,f,i,=,f(x,i,),,则,为,f(x,),在点,处的一阶向前差分(简称差分),57,为,f(x,),在点,处的一阶差分,一阶差分的一阶差分叫二阶差分,,一般说来,,n,阶差分定义为,n-1,阶差分的一阶差分:,58,实际计算差分时,常用如下表格(差分表):,59,例题,设函数,y,=,f,(,x,),在各节点的,取值,如,下,表,所示,试计算各阶差分值。,60,61,62,插商与差分的关系,在等距节点条件下有:,0,2,2,0,1,0,2,1,0,2,1,2,1,0,!,2,1,2,1,1,f,h,h,f,h,f,h,x,x,x,x,f,x,x,f,x,x,x,f,D,=,D,-,D,=,-,-,=,63,0,1,0,!,1,.,f,h,n,x,x,x,f,n,n,n,D,=,0,2,2,2,1,0,!,2,1,f,h,x,x,x,f,D,=,一般有,.,),)(,).(,)(,(,.,),).(,)(,(,.,),)(,(,),(,),(,),(,1,0,1,1,0,1,1,0,2,1,0,2,1,0,1,0,1,0,0,0,n,n,n,n,n,x,x,x,x,f,x,x,x,x,x,x,x,x,x,x,x,f,x,x,x,x,x,x,x,x,x,f,x,x,x,x,x,x,f,x,x,x,f,x,f,-,-,-,-,+,-,-,-,+,+,-,-,+,-,+,=,-,-,-,64,),(,),(,),).(,1,(,)!,1,(,),(,!,),1,).(,1,(,.,!,2,),1,(,!,1,),(,),(,0,0,),1,(,1,0,0,2,0,0,0,h,x,x,f,n,t,t,t,n,h,x,R,f,n,n,t,t,t,f,t,t,f,t,f,th,x,N,x,N,n,n,n,n,n,n,+,-,-,+,=,D,+,-,-,+,+,D,-,+,D,+,=,+,=,+,+,x,x,0,Newton,th,x,x,+,=,式,插值公式和余式具有形,则,若令,.,),)(,).(,)(,(,.,),).(,)(,(,.,),)(,(,),(,),(,),(,1,0,1,1,0,1,1,0,2,1,0,2,1,0,1,0,1,0,0,0,n,n,n,n,n,x,x,x,x,f,x,x,x,x,x,x,x,x,x,x,x,f,x,x,x,x,x,x,x,x,x,f,x,x,x,x,x,x,f,x,x,x,f,x,f,-,-,-,-,+,-,-,-,+,+,-,-,+,-,+,=,-,-,-,65,上面介绍的差分叫向前差分。鉴于计算实践的需要,我们再介绍向后差分概念。,设函数,f(x,),在等距节点,上值为,f,i,=,f(x,i,),,则,为,f(x,),在点,处的一阶向后差分,1,-,-,=,i,i,i,f,f,f,为,f(x,),在点,x,i,处的,n,阶向后差分。,i,i,i,f,f,f,-,=,D,+,1,66,67,插商与,向后,差分的关系,68,用后插表示,N(x,),69,用后插表示,N(x,),70,对于给定的等距结点的数据,我们可以灵活运用插值余项极小化原则,给出适应具体要求的插值公式。一般说来,在左端点附近进行插值,宜用,Newton,向前插值公式;在右端点附近插值,宜用,Newton,向后插值公式。,71,Lagrange,插值公式所求得,L(x,),保证了节点处的函数值相等,也就是保证了函数的连续性,但不少实际问题还需要插值得光滑,也就是还要求在节点处的导数值也相等,导数的阶数越高则光滑度越高。现代的仿生学就是一个典型的例子。在设计交通工具的外形,就是参照海豚的标本上已知点及已知点的导数,做插值在计算机上模拟海豚的外形制成飞机、汽车等外形。,Hermite,插值,72,所谓,Hermite,插值是插值函数与被插值函数,不仅在节点处函数值相等,而且导数相等,.,设函数,f,(,x,),在区间,a,b,上具有一阶连续导数,如果有不超,过,2n+1,次多项式,H,2n+1,(x),满足,),.,2,1,0,(,i,n,=,),(,1,2,x,f,H,i,n,=,+,),(,),(,1,2,x,f,x,H,i,i,n,=,+,则称,为,f,(,x,),关于节点,的,Hermite,插值,多项式,。,H,2n+1,(x),x,i,73,构造,Hermite,插值多项式,H,(,x,),74,前面我们根据区间,a,b,上给出的节点做插值多项式,Ln(x,),近似表示,f,(x),。一般总以为,Ln(x,),的次数越高,逼近,f,(x),的精度越好,但实际并非如此,次数越高,计算量越大,也不一定收敛。因此高次插值一般要慎用,实际上较多采用分段低次插值。,分段插值,75,),(,.,1,0,1,1,=,-,-,x,x,x,f,x,x,x,n,j,y,x,j,j,j,j,j,j,。,上的线性插值函数表示,用,则,判断,),已知(,分段线性插值,),/(,),)(,(,),/(,),)(,(,1,1,1,1,1,1,1,1,1,1,1,1,1,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,+,=,-,-,+,-,-,=,-,-,-,+,=,j,j,j,j,j,j,j,j,j,j,j,j,j,j,j,j,j,j,j,j,j,j,x,x,y,y,x,x,y,y,x,x,x,x,y,x,x,x,x,y,x,x,y,y,x,u,y,u,x,u,x,这是因为,则线性插值函数为,一般的,,76,缺点:,I(x,),连续,但不光滑,精度较低,仅在,分段线性插值,分段三次,Hermite,插值,。,足够小才能较好的逼近,max,1,1,-,-,=,=,j,j,j,n,j,x,x,h,h,77,Hermite,插值,一般来说,给定,m,+1,个插值条件,就可以构造出一个,m,次,Hermite,插值多项式,两个典型的,Hermite,插值,三点三次,Hermite,插值,两点三次,Hermite,插值,插值节点:,x,0,x,1,x,2,插值条件:,P,(,x,i,)=,f,(,x,i,),,,i=,0,1,2,,,P,(,x,1,)=,f,(,x,1,),插值节点:,x,0,x,1,插值条件:,P,(,x,i,)=,f,(,x,i,),,,P,(,x,i,)=,f,(,x,i,),,,i=,0,1,78,三点三次,Hermite,插值,插值节点:,x,0,x,1,x,2,插值条件:,P,(,x,i,)=,f,(,x,i,),,,i=,0,1,2,,,P,(,x,1,)=,f,(,x,1,),设,将,P,(,x,1,)=,f,(,x,1,),代入可得,79,插值举例,例:,函数,f,(,x,),=,x,3/2,,插值条件如下,解,:,作差商表,试给出三次,Hermite,插值多项式,x,i,(,x,i,),一阶差商,二阶差商,1/4,1,9/4,1/8,1,27/8,7/6,19/10,11/30,将,P,(1),=,f,(1),=3/2,代入可得,A,=,-,14/225,f,(1/4),=1/8,,,f,(1),=1,,,f,(9/4),=27/8,,,f,(1),=3/2,80,插值举例,将,P,(1),=,f,(1),=3/2,代入可得,A,=,-,14/225,81,One way to achieve the Lagrange,inter,polation efficiently is by performing a sequence of linear,inter,polations.This scheme was first developed by,Aitken(1932).,We can first work out n linear,inter,polations with each constructed from a neighboring pair of the n+1 data points.Then we can use these n,inter,polated data points to achieve another level of n-1 linear,inter,polations.We repeat this until we obtain the final result after n levels of consecutive linear,inter,polations.,The,Aitken,method,82,83,Example,Let us take as an actual numerical example evaluating y(0.9)from the given set y(0.0)=1.000000,y(0.5)=0.938470,y(1.0)=0.765198,y(1.5)=0.511828,and y(2.0)=0.223891.These are the values of the Bessel function of the first kind of order zero.,84,We can show that the consecutive linear,inter,polations outlined in above figure recovers the standard Lagrange,inter,polation,but it is easier to implement.,85,x,i,y,i,y,ij,y,ijk,y,i,jkl,y,ijklm,0.0,1.000000,0.5,0.938470,1.0,0.765198,1.5,0.511828,2.0,0.223891,86,x,i,y,i,y,ij,y,ijk,y,i,jkl,y,ijklm,0.0,1.000000,0.889246,0.5,0.938470,0.808792,0.799852,0.807272,1.0,0.765198,0.806260,0.807473,0.815872,0.807717,1.5,0.511828,0.811725,0.857352,2.0,0.223891,87,88,PROGRAM INTERPOLATION,!Main program for the Lagrange interpolation with the,Aitken,method.,IMPLICIT NONE,INTEGER,PARAMETER:N=5,REAL:X,F,DF,REAL,DIMENSION(N):XI,FI,DATA XI/0.0,0.5,1.0,1.5,2.0/,&FI/1.0,0.938470,0.765198,0.511828,0.223891/,X=0.9,CALL AITKEN(N,XI,FI,X,F,DF),WRITE(6,(3F16.8)X,F,DF,END PROGRAM INTERPOLATION,89,SUBROUTINE AITKEN(N,XI,FI,X,F,DF),!Subroutine performing the Lagrange interpolation with the!,Aitken,method.F:interpolated value.DF:error estimated.,INTEGER,PARAMETER:NMAX=21,INTEGER,INTENT(IN):N,INTEGER:I,J,REAL:X,REAL:F,DF,REAL:X1,X2,F1,F2,REAL,DIMENSION(N):XI,FI,REAL,DIMENSION(NMAX):FT,90,IF(N.GT.NMAX)STOP,Dimension of the data is too large,.DO I=1,N FT(I)=FI(I)END DO,DO I=1,N-1,DO J=1,N-I,X1=XI(J)X2=XI(J+I),F1=FT(J)F2=FT(J+1),FT(J)=(X-X1)/(X2-X1)*F2+(X-X2)/(X1-X2)*F1 END DO,END DO,F=FT(1)DF=(ABS(F-F1)+ABS(F-F2)/2.0,END SUBROUTINE AITKEN,91,Other Inter,polation,Qubic,spline,Inter,polation,92,
    展开阅读全文

    开通VIP折扣优惠下载文档

    提示  咨信网声明:本文档由用户上传并分享,仅供学习交流、研究之用,未经授权,严禁复制、发行、汇编、翻译或网络传播等,侵权必究。

    咨信网小贴示:
    1、浏览或下载可查看了解,请点击【咨信网告知】。
    2、下载文件中如有侵权或不适当内容,将立即纠正。
    3、如果因为网速或其他原因下载失败请重新下载,重复下载[60天内]不扣币。
    4、开具发票登录电脑端申请,请点击【索取发票】。

    咨信网客服组:【微信客服】

    自信AI创作助手
    关于本文
    本文标题:计算物理lecture1102.ppt
    链接地址:https://www.zixin.com.cn/doc/14767095.html

    Copyright ©2010-2026   All Rights Reserved  宁波自信网络信息技术有限公司 版权所有   |  客服电话:0574-28810668    微信客服:咨信网客服    投诉电话:18658249818   

    违法和不良信息举报邮箱:help@zixin.com.cn    文档合作和网站合作邮箱:fuwu@zixin.com.cn    意见反馈和侵权处理邮箱:1219186828@qq.com   | 证照中心

    12321jubao.png12321网络举报中心 电话:010-12321  jubao.png中国互联网举报中心 电话:12377   gongan.png浙公网安备33021202000488号  icp.png浙ICP备2021020529号-1 浙B2-20240490   


    关注我们 :微信公众号  抖音  微博  LOFTER               

    自信网络  |  ZixinNetwork