正在加载图片...
5.1 Series and Their Convergence 167 number of terms directly,through term n-1 say,then apply the transformation to the rest of the series beginning with term n.The formula(for n even)is ∑(-1r,=o-4+g-u-1+∑Aud (5.1.5) s= Here A is the forward difference operator,i.e., △un三un+1-ln △2un≡un+2-2un+1+un (5.1.6) △3un≡un+3-3un+2+3un+1-un etc. Of course you don't actually do the infinite sum on the right-hand side of(5.1.5). but only the first,say,p terms,thus requiring the first p differences(5.1.6)obtained from the terms starting at un. Euler's transformation can be applied not only to convergent series.In some 令 cases it will produce accurate answers from the first terms of a series that is formally divergent.It is widely used in the summation of asymptotic series.In this case it is generally wise not to sum farther than where the terms start increasing in ,%4 Press. magnitude;and you should devise some independent numerical check that the results ART Programs are meaningful. 9 There is an elegant and subtle implementation of Euler's transformation due to van Wijngaarden [1]:It incorporates the terms of the original alternating series SCIENTIFIC one at a time,in order.For each incorporation it either increases p by 1,equivalent to computing one further difference (5.1.6),or else retroactively increases n by 1, without having to redo all the difference calculations based on the old n value!The decision as to which to increase,n or p,is taken in such a way as to make the convergence most rapid.Van Wijngaarden's technique requires only one vector of COMPUTING (ISBN 18881092 saved partial differences.Here is the algorithm: #include <math.h> 10-621 void eulsum(float *sum,float term,int jterm,float wksp[]) idge.org FuurrgPgoglrion Numerical Recipes 43106 Incorporates into sum the jterm'th term,with value term,of an alternating series.sum is input as the previous partial sum,and is output as the new partial sum.The first call to this routine,with the first term in the series,should be with jterm=1.On the second call,term should be set to the second term of the series,with sign opposite to that of the first call,and (outside jterm should be 2.And so on.wksp is a workspace array provided by the calling program, Software. dimensioned at least as large as the maximum number of terms to be incorporated. North int j; static int nterm; float tmp,dum; if (jterm ==1){ Initialize: nterm=1; Number of saved differences in wksp. *sum=0.5*(wksp[1]=term); Return first estimate. else tmp=wksp[1]: wksp[1]=term; for (j=1;j<=nterm-1;j++){ Update saved quantities by van Wijn- dum=wksp[j+1]; gaarden's algorithm.5.1 Series and Their Convergence 167 Permission is granted for internet users to make one paper copy for their own personal use. Further reproduction, or any copyin Copyright (C) 1988-1992 by Cambridge University Press. Programs Copyright (C) 1988-1992 by Numerical Recipes Software. Sample page from NUMERICAL RECIPES IN C: THE ART OF SCIENTIFIC COMPUTING (ISBN 0-521-43108-5) g of machine￾readable files (including this one) to any server computer, is strictly prohibited. To order Numerical Recipes books or CDROMs, visit website http://www.nr.com or call 1-800-872-7423 (North America only), or send email to directcustserv@cambridge.org (outside North America). number of terms directly, through term n − 1 say, then apply the transformation to the rest of the series beginning with term n. The formula (for n even) is ∞ s=0 (−1)s us = u0 − u1 + u2 ... − un−1 +∞ s=0 (−1)s 2s+1 [∆sun] (5.1.5) Here ∆ is the forward difference operator, i.e., ∆un ≡ un+1 − un ∆2un ≡ un+2 − 2un+1 + un ∆3un ≡ un+3 − 3un+2 + 3un+1 − un etc. (5.1.6) Of course you don’t actually do the infinite sum on the right-hand side of (5.1.5), but only the first, say, p terms, thus requiring the first p differences (5.1.6) obtained from the terms starting at un. Euler’s transformation can be applied not only to convergent series. In some cases it will produce accurate answers from the first terms of a series that is formally divergent. It is widely used in the summation of asymptotic series. In this case it is generally wise not to sum farther than where the terms start increasing in magnitude; and you should devise some independent numerical check that the results are meaningful. There is an elegant and subtle implementation of Euler’s transformation due to van Wijngaarden [1]: It incorporates the terms of the original alternating series one at a time, in order. For each incorporation it either increases p by 1, equivalent to computing one further difference (5.1.6), or else retroactively increases n by 1, without having to redo all the difference calculations based on the old n value! The decision as to which to increase, n or p, is taken in such a way as to make the convergence most rapid. Van Wijngaarden’s technique requires only one vector of saved partial differences. Here is the algorithm: #include <math.h> void eulsum(float *sum, float term, int jterm, float wksp[]) Incorporates into sum the jterm’th term, with value term, of an alternating series. sum is input as the previous partial sum, and is output as the new partial sum. The first call to this routine, with the first term in the series, should be with jterm=1. On the second call, term should be set to the second term of the series, with sign opposite to that of the first call, and jterm should be 2. And so on. wksp is a workspace array provided by the calling program, dimensioned at least as large as the maximum number of terms to be incorporated. { int j; static int nterm; float tmp,dum; if (jterm == 1) { Initialize: nterm=1; Number of saved differences in wksp. *sum=0.5*(wksp[1]=term); Return first estimate. } else { tmp=wksp[1]; wksp[1]=term; for (j=1;j<=nterm-1;j++) { Update saved quantities by van Wijn￾dum=wksp[j+1]; gaarden’s algorithm
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有