正在加载图片...
772 Chapter 17.Two Point Boundary Value Problems for (j-jz1;j<-jz2;j++){ Loop over columns to be zeroed. for(1=jm1:1<=jm2:1+) Loop over columns altered. vx-c[ic][l+loff][kc]; for(i=1z1;i<=1z2;i+)s[1][1]-=s[1][j]*vx; Loop over rows. vx=c[ic][jcf][kc]; for(i=iz1;1<=iz2;1++)s[i][jmf]-=s[1][j]*vx; Plus final element. 1c+=1; "Algebraically Difficult"Sets of Differential Equations 8= Relaxation methods allow you to take advantage of an additional opportunity that,while not obvious,can speed up some calculations enormously.It is not necessary that the set of variables y.correspond exactly with the dependent variables of the original differential equations.They can be related to those variables through algebraic equations.Obviously,it is necessary only that the solution variables allow us to evaluate the functions y,g,B,C that are used to construct the FDEs from the ODEs.In some problems g depends on functions of y that are known only implicitly,so that iterative solutions are necessary to evaluate functions in the ODEs.Often one can dispense with this "internal"nonlinear problem by defining a new set of variables from which both y,g and the boundary conditions can be obtained directly.A typical example occurs in physical problems where the equations require solution of a complex equation of state that can be expressed in more convenient terms using variables s是%ad的 2 Press. other than the original dependent variables in the ODE.While this approach is analogous to performing an analytic change of variables directly on the original ODEs,such an analytic transformation might be prohibitively complicated.The change of variables in the relaxation method is easy and requires no analytic manipulations. SCIENTIFIC CITED REFERENCES AND FURTHER READING: Eggleton,P.P.1971,Monthly Notices of the Royal Astronomical Society,vol.151,pp.351-364.[1] 6 Keller,H.B.1968,Numerical Methods for Two-Point Boundary-Value Problems (Waltham,MA: Blaisdell). Kippenhan,R.,Weigert,A.,and Hofmeister,E.1968,in Methods in Computational Physics, vol.7 (New York:Academic Press),pp.129ff. Numerica 10621 17.4 A Worked Example:Spheroidal Harmonics 431 Recipes The best way to understand the algorithms of the previous sections is to see (outside them employed to solve an actual problem.As a sample problem,we have selected the computation of spheroidal harmonics.(The more common name is spheroidal North angle functions,but we prefer the explicit reminder of the kinship with spherical harmonics.)We will show how to find spheroidal harmonics,first by the method of relaxation ($17.3),and then by the methods of shooting (817.1)and shooting to a fitting point ($17.2). Spheroidal harmonics typically arise when certain partial differential equations are solved by separation of variables in spheroidal coordinates.They satisfy the following differential equation on the interval-1 <x<1: a-+(-x-)s=0 (17.4.1)772 Chapter 17. Two Point Boundary Value Problems 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). for (j=jz1;j<=jz2;j++) { Loop over columns to be zeroed. for (l=jm1;l<=jm2;l++) { Loop over columns altered. vx=c[ic][l+loff][kc]; for (i=iz1;i<=iz2;i++) s[i][l] -= s[i][j]*vx; Loop over rows. } vx=c[ic][jcf][kc]; for (i=iz1;i<=iz2;i++) s[i][jmf] -= s[i][j]*vx; Plus final element. ic += 1; } } “Algebraically Difficult” Sets of Differential Equations Relaxation methods allow you to take advantage of an additional opportunity that, while not obvious, can speed up some calculations enormously. It is not necessary that the set of variables yj,k correspond exactly with the dependent variables of the original differential equations. They can be related to those variables through algebraic equations. Obviously, it is necessary only that the solution variables allow us to evaluate the functions y, g,B, C that are used to construct the FDEs from the ODEs. In some problems g depends on functions of y that are known only implicitly, so that iterative solutions are necessary to evaluate functions in the ODEs. Often one can dispense with this “internal” nonlinear problem by defining a new set of variables from which both y, g and the boundary conditions can be obtained directly. A typical example occurs in physical problems where the equations require solution of a complex equation of state that can be expressed in more convenient terms using variables other than the original dependent variables in the ODE. While this approach is analogous to performing an analytic change of variables directly on the original ODEs, such an analytic transformation might be prohibitively complicated. The change of variables in the relaxation method is easy and requires no analytic manipulations. CITED REFERENCES AND FURTHER READING: Eggleton, P.P. 1971, Monthly Notices of the Royal Astronomical Society, vol. 151, pp. 351–364. [1] Keller, H.B. 1968, Numerical Methods for Two-Point Boundary-Value Problems (Waltham, MA: Blaisdell). Kippenhan, R., Weigert, A., and Hofmeister, E. 1968, in Methods in Computational Physics, vol. 7 (New York: Academic Press), pp. 129ff. 17.4 A Worked Example: Spheroidal Harmonics The best way to understand the algorithms of the previous sections is to see them employed to solve an actual problem. As a sample problem, we have selected the computation of spheroidal harmonics. (The more common name is spheroidal angle functions, but we prefer the explicit reminder of the kinship with spherical harmonics.) We will show how to find spheroidal harmonics, first by the method of relaxation (§17.3), and then by the methods of shooting (§17.1) and shooting to a fitting point (§17.2). Spheroidal harmonics typically arise when certain partial differential equations are solved by separation of variables in spheroidal coordinates. They satisfy the following differential equation on the interval −1 ≤ x ≤ 1: d dx  (1 − x2) dS dx  +  λ − c2x2 − m2 1 − x2  S =0 (17.4.1)
<<向上翻页
©2008-现在 cucdc.com 高等教育资讯网 版权所有