欢迎来到淘文阁 - 分享文档赚钱的网站! | 帮助中心 好文档才是您的得力助手!
淘文阁 - 分享文档赚钱的网站
全部分类
  • 研究报告>
  • 管理文献>
  • 标准材料>
  • 技术资料>
  • 教育专区>
  • 应用文书>
  • 生活休闲>
  • 考试试题>
  • pptx模板>
  • 工商注册>
  • 期刊短文>
  • 图片设计>
  • ImageVerifierCode 换一换

    计算物理ComputationalPhysics计算物理 (4).pdf

    • 资源ID:67730791       资源大小:671.10KB        全文页数:38页
    • 资源格式: PDF        下载积分:8金币
    快捷下载 游客一键下载
    会员登录下载
    微信登录下载
    三方登录下载: 微信开放平台登录   QQ登录  
    二维码
    微信扫一扫登录
    下载资源需要8金币
    邮箱/手机:
    温馨提示:
    快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。
    如填写123,账号就是123,密码也是123。
    支付方式: 支付宝    微信支付   
    验证码:   换一换

     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    计算物理ComputationalPhysics计算物理 (4).pdf

    Isaac NewtonGottfried Leibniz Computational physiCsNumerical calculusxpositionvvelocityaaccelerationderivative derivative integralintegralNumerical calculus Numerical differentiation Numerical integration Roots of an equation Extremes of a functionNumerical differentiationTaylor expansion:To calculate f,f,f.single-variable:)(!)()(!2)()()()()(0)(0020000 xfnxxxfxxxfxxxfxfnnmultivariable:),(!2)(2),(!2)(),(!2)(),()(),()(),(),(00000020002000000000yxfyyxxyxfyyyxfxxyxfyyyxfxxyxfyxfxyyyxxyxyxffxy/2Now if we divide the space into discrete points xi with evenly spaced intervals xi+1-xi=h and label the function at the lattice points as fi=f(xi),we obtain the simplest expression for the first-order derivative.x)f(xx)f(x)(xfii0 xilimThe first-order derivative of a single-variable function f(x)around a point xi is defined from the limit.the two-point formula for the first-order derivative)(1hOhfffiiiAn improved choice:The accuracy is improved from O(h)to O(h2).3/0206/2/6/2/311321321iiiiiiiiiiiiiifhfhfffhfhfhfffhfhfhffThe three-point formula for the first-order derivative)(O2211hhfffiii)(O2311hfhffiii)()88(121)2(8)1(42112hOffffhfiiiii(1)(2)A five-point formula can be derived by including the expansions of fi+2 and fi-2 around xi.)(O325)3(311hfhfhffiiii)(O3845)3(322hfhfhffiiiiMore pointsHigher accuracySmaller hnumber of pointsinaccuracy2O(h)3O(h2)5O(h4)SummarySimilarly,we can combine the expansions of fi2 and fi1 around xi and fi to cancel the fi,f(3)i,f(4)i,and f(5)i terms;then we havethe five-point formula for the second-order derivative)(O163016121421122hfffffhfiiiiii )(The three-point formula for the second-order derivative 6/2/6/2/321321iiiiiiiiiifhfhfhfffhfhfhff)(O2)(O222114211hhffffhfhfffiiiiiiii Example Given f(x)=sin(x),lets calculate f(x)&f(x).Divide the region from 0 to p/2 to 100 equal-length intervals with 101 points i*p/200(i=0,1,2.100).For boundary points(i=0,1&99,100),we can use Lagrange interpolation to extrapolate the derivatives.Code example:3.1.Differentiation.cpp Three-point formula for fThree-point formula for fNumerical calculus Numerical differentiation Numerical integration Roots of an equation Extremes of a functionNumerical integrationDivide the region a,b into n slices,evenly spaced with an interval h.If we label the data points as xi with i=0,1,.,n,we can write the entire integral as a summation of integrals,with each over an individual slice.In general,we want to obtain the numerical value of an integral,defined in the region a,b,.)(dxxfSba 101)()(nixxbaiidxxfdxxf)()(2/)()(21011hOffhShffxxfxfniiiiiiiThe above quadrature is commonly referred as the trapezoidal rule,which has an overall accuracy up to O(h2).The simplest quadrature is obtained if we approximate f(x)in the region xi,xi+1 linearly,that is,Trapezoidal rule We can obtain a quadrature with a higher accuracy by working on two slices together.If we apply the Lagrange interpolation to the function f(x)in the region xi-1,xi+1,we have)()()()()()()()(311111111111111hOfxxxxxxxxfxxxxxxxxfxxxxxxxxxfiiiiiiiiiiiiiiiiiiiii)()4(3412/022122hOfffhSnjjjjExample Given f=sin(x),integrate f from 0 to p/2.The analytic function:-cos(x)The exact value:cos(0)-cos(p/2)=1.We can use trapezoidal rule to see how the numerical value converges to 1.Code example 3.2.Integration.cppHomework Improved integration with the three-point Lagrange interpolation implemented.Comparison with the trapezoidal rule method.)()4(3412/022122hOfffhSnjjjjNumerical calculus Numerical differentiation Numerical integration Roots of an equation Extremes of a functionRoots of an equationIf we need to find a root for f(x)=a,then how?define g(x)=f(x)-a,and find a root for g(x)=0.In physics,we often encounter situations in which we need to find the possible value of x that ensures the equation f(x)=0,where f(x)can either be an explicit or an implicit function of x.If such a value exists,we call it a root or zero of the equation.Bisection method If we know that there is a root xr in the region a,b for f(x)=0,we can use the bisection method to find it within a required accuracy.Most intuitive method.f(a)f(b)0 x0=(a+b)/2|f(x0)|d?output!yesnof(a)f(x0)0 f(x0)f(b)0f(a)f(x0)0 or f(x0)f(b)0?b=x0 a=x0Code Example f(x)=sin(x)=0.5;x is within 0 to p/2.Analytically,we know the root is p/6.Numerically,the procedure is:since sin(0)-0.5*sin(p/2)-0.50 and sin(0)-0.5*sin(p/4)-0.50;then the root must be within(0,p/4).Then we calculate the value at p/8.3.3.Bisection.cppThe Newton method0)()()()(xfxxxfxfrrwhere x can be viewed as a trial value for the root of xi at the ith step and the approximate value of the next step xi+1 can be derived.This method is based on linear approximation of a smooth function around its root.We can formally expand the function f(xr)=0 in the neighborhood of the root xr through the Taylor expansion.(i=0,1,.)iiiiiiffxxxx/1Code example 3.4.NewtonRoot.cppExample:f(x)=sin(x)=0.5;g(x)=f(x)-0.5=sin(x)-0.5ixigigi00-0.5110.5Possible bugs If the function is not monotonous If fi=0 or very small at some points Works well when the function is monotonous,especially with moderate f.Secant method-discrete Newton methodIn many cases,especially when f(x)has an implicit dependence on x,an analytic expression for the first-order derivative needed in the Newton method may not exist or may be very difficult to obtain.We have to find an alternative scheme to achieve a similar algorithm.One way to do this is to replace the analytic f(x)with the two-point formula for the first-order derivative,which gives)/()(111iiiiiiifffxxxxCode example3.5.Secant.cppExample:f(x)=sin(x)=0.5;g(x)=f(x)-0.5=sin(x)-0.5ixigi00-0.51p/20.52p/4)/()(111iiiiiiigggxxxx4)5.05.0/(5.0)02(22pppxNumerical calculus Numerical differentiation Numerical integration Roots of an equation Extremes of a functionExtremes of a function An associated problem to find the root of an equation is finding the maxima and/or minima of a function.Examples of such situations in physics occur when considering the equilibrium position of an object,the potential surface of a field,and the optimized structures of molecules and small clusters.We know that an extreme of g(x)occurs at the point with which is a minimum(maximum)if f(x)=g(x)is greater(less)than zero.So all the root-search schemes discussed so far can be generalized here to search for the extremes of a single-variable function.0)()(dxxdgxfExample)exp(4)(0002rrVrerVpwhere e is the charge of a proton,0 is the electric permittivity of vacuum,and V0 and r0 are parameters of this effective interaction.The first term comes from the Coulomb interaction between the two ions,but the second term is the result of the electron distribution in the system.The(ionic)bond length of the diatomic moleculeNaClThe force:At equilibrium,the force between the two ions is zero.Therefore,we search for the root of f(x)=-dV(x)/dx=0.)exp(4)()(000202rrrVredrrdVrfpcode example parameters for NaCl e2/4p0=14.4 AeV V0=1.09 x 103 eV r0=0.33 A r starts from 1 A 3.6.NaCl.cpp/iiiffxIn the example program above,the search process is forced to move along the direction of descending the function g(x)when looking for a minimum.In other words,for xi+1=xi+xi,the increment xi has the sign opposite to g(xi).Based on this observation,an update scheme can be formulated:with a being a positive,small,and adjustable parameter.For the minimum,f(or g)must be positive.iiifagax This scheme can be generalized to the multivariable case asNote that step xi here is scaled by|g(xi)|and is forced to move toward the direction of the steepest descent.This is why this method is known as the steepest-descent method.where x=(x1,x 2,.,x l)and g(x)=(g/x1,g/x 2,.,g/xl).|)(|/)(1iiiiiixgxgaxxxxHomework Search for the minimum of the function g(x,y)=sin(x+y)+cos(x+2*y)in the whole space

    注意事项

    本文(计算物理ComputationalPhysics计算物理 (4).pdf)为本站会员(奉***)主动上传,淘文阁 - 分享文档赚钱的网站仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知淘文阁 - 分享文档赚钱的网站(点击联系客服),我们立即给予删除!

    温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




    关于淘文阁 - 版权申诉 - 用户使用规则 - 积分规则 - 联系我们

    本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

    工信部备案号:黑ICP备15003705号 © 2020-2023 www.taowenge.com 淘文阁 

    收起
    展开