License Information Read this section if you want to use the programs in this book on a computer. You'll need to read the following Disclaimer of Warranty,get the programs onto your computer,and acquire a Numerical Recipes software license.(Without this license. which can be the free "immediate license"under terms described below,the book is intended as a text and reference book,for reading purposes only. Disclaimer of Warranty We make no warranties,express or implied,that the programs contained in this volume are free of error,or are consistent with any particular standard of merchantability,or that they will meet your requirements for any particular application.They should not be relied on for solving a problem whose incorrect 1-800-8 NUMERICAL solution could result in injury to a person or loss of property.If you do use the programs in such a manner,it is at your own risk.The authors and publisher Cambridge disclaim all liability for direct or consequential damages resulting from your use of the programs. (North How to Get the Code onto Your Computer a Press C:THE A Pick one of the following methods: You can type the programs from this book directly into your computer.In this Programs case,the only kind of license available to you is the free "immediate license" (see below).You are not authorized to transfer or distribute a machine-readable SCIENTIFIC copy to any other person,nor to have any other person type the programs into a computer on your behalf.We do not want to hear bug reports from you if you 6 choose this option,because experience has shown that virtually all reported bugs in such cases are typing errors! COMPUTING You can download the Numerical Recipes programs electronically from the Numerical Recipes On-Line Software Store,located at http://www.nr.com,our r Numerical 18-1892 Web site.All the files (Recipes and demonstration programs)are packaged as Further a single compressed file.You'll need to purchase a license to download and unpack them.Any number of single-screen licenses can be purchased instantly Numerical (with discount for multiple screens)from the On-Line Store,with fees that depend on your operating system (Windows or Macintosh versus Linux or UNIX)and Recipes 561.0621491069 whether you are affiliated with an educational institution.Purchasing a single- screen license is also the way to start if you want to acquire a more general (site or corporate)license;your single-screen cost will be subtracted from the cost of (outside any later license upgrade. North Software. You can purchase media containing the programs from Cambridge University Press. A CD-ROM version in ISO-9660 format for Windows and Macintosh systems contains the complete C software,and also the C++version.More extensive CD- America). ROMs in ISO-9660 format for Windows,Macintosh,and UNIX/Linux systems are also available;these include the C.C++,and Fortran versions on a single CD-ROM (as well as versions in Pascal and BASIC from the first edition).These CD-ROMs are available with a single-screen license for Windows or Macintosh (order ISBN 0 521 750350),or (at a slightly higher price)with a single-screen license for UNIX/Linux workstations (order ISBN 0 521 750369).Orders for media from Cambridge University Press can be placed at 800 872-7423(North America only) or by email to orders@cup.org (North America)or directcustserv @cambridge.org (rest of world).Or,visit the Web site http://www.cambridge.org. XVi
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 machinereadable 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). License Information Read this section if you want to use the programs in this book on a computer. You’ll need to read the following Disclaimer of Warranty, get the programs onto your computer, and acquire a Numerical Recipes software license. (Without this license, which can be the free “immediate license” under terms described below, the book is intended as a text and reference book, for reading purposes only.) Disclaimer of Warranty We make no warranties, express or implied, that the programs contained in this volume are free of error, or are consistent with any particular standard of merchantability, or that they will meet your requirements for any particular application. They should not be relied on for solving a problem whose incorrect solution could result in injury to a person or loss of property. If you do use the programs in such a manner, it is at your own risk. The authors and publisher disclaim all liability for direct or consequential damages resulting from your use of the programs. How to Get the Code onto Your Computer Pick one of the following methods: • You can type the programs from this book directly into your computer. In this case, the only kind of license available to you is the free “immediate license” (see below). You are not authorized to transfer or distribute a machine-readable copy to any other person, nor to have any other person type the programs into a computer on your behalf. We do not want to hear bug reports from you if you choose this option, because experience has shown that virtually all reported bugs in such cases are typing errors! • You can download the Numerical Recipes programs electronically from the Numerical Recipes On-Line Software Store, located at http://www.nr.com, our Web site. All the files (Recipes and demonstration programs) are packaged as a single compressed file. You’ll need to purchase a license to download and unpack them. Any number of single-screen licenses can be purchased instantly (with discount for multiple screens) from the On-Line Store, with fees that depend on your operating system (Windows or Macintosh versus Linux or UNIX) and whether you are affiliated with an educational institution. Purchasing a singlescreen license is also the way to start if you want to acquire a more general (site or corporate) license; your single-screen cost will be subtracted from the cost of any later license upgrade. • You can purchase media containing the programs from Cambridge University Press. A CD-ROM version in ISO-9660 format for Windows and Macintosh systems contains the complete C software, and also the C++ version. More extensive CDROMs in ISO-9660 format for Windows, Macintosh, and UNIX/Linux systems are also available; these include the C, C++, and Fortran versions on a single CD-ROM (as well as versions in Pascal and BASIC from the first edition). These CD-ROMs are available with a single-screen license for Windows or Macintosh (order ISBN 0 521 750350), or (at a slightly higher price) with a single-screen license for UNIX/Linux workstations (order ISBN 0 521 750369). Orders for media from Cambridge University Press can be placed at 800 872-7423 (North America only) or by email to orders@cup.org (North America) or directcustserv@cambridge.org (rest of world). Or, visit the Web site http://www.cambridge.org. xvi
License Information xvii Types of License Offered Here are the types of licenses that we offer.Note that some types are automatically acquired with the purchase of media from Cambridge University Press,or of an unlocking password from the Numerical Recipes On-Line Software Store,while other types of licenses require that you communicate specifically with Numerical Recipes Software (email:orders@nr.com or fax:781 863-1739).Our Web site http://www.nr.com has additional information. .["Immediate License"]If you are the individual owner of a copy of this book and you type one or more of its routines into your computer,we authorize you to use them on that computer for your own personal and noncommercial purposes.You are not authorized to transfer or distribute machine-readable copies to any other person,or to use the routines on more than one machine,or to distribute executable programs containing our routines.This is the only free license. .["Single-Screen License"]This is the most common type of low-cost license,with terms governed by our Single Screen(Shrinkwrap)License document (complete terms available through our Web site).Basically,this license lets you use Numerical Recipes routines on any one screen (PC,workstation,X-terminal,etc.).You may also,under this license,transfer pre-compiled,executable programs incorporating our routines to other,unlicensed,screens or computers,providing that (i)your America University Press. THE application is noncommercial (i.e.,does not involve the selling of your program for a fee),(ii)the programs were first developed,compiled,and successfully run ART on a licensed screen,and (iii)our routines are bound into the programs in such a manner that they cannot be accessed as individual routines and cannot practicably 9 Programs be unbound and used in other programs.That is,under this license,your program user must not be able to use our programs as part of a program library or"mix-and- match"workbench.Conditions for other types of commercial or noncommercial distribution may be found on our Web site (http://www.nr.com). 言 to dir ["Multi-Screen,Server,Site,and Corporate Licenses"]The terms of the Single Screen License can be extended to designated groups of machines,defined by number of screens,number of machines,locations,or ownership. Significant OF SCIENTIFIC COMPUTING (ISBN discounts from the corresponding single-screen prices are available when the 1988-19920 estimated number of screens exceeds 40.Contact Numerical Recipes Software (email:orders@nr.com or fax:781 863-1739)for details. 10-621 .["Course Right-to-Copy License"]Instructors at accredited educational institutions who have adopted this book for a course,and who have already purchased a Single Numerical Recipes 43106 Screen License(either acquired with the purchase of media,or from the Numerical Recipes On-Line Software Store),may license the programs for use in that course as follows:Mail your name,title,and address;the course name,number,dates, (outside and estimated enrollment;and advance payment of S5 per (estimated)student to Numerical Recipes Software,at this address:P.O.Box 243,Cambridge,MA Software. 02238 (USA).You will receive by return mail a license authorizing you to make ying of copies of the programs for use by your students,and/or to transfer the programs to a machine accessible to your students (but only for the duration of the course). About Copyrights on Computer Programs Like artistic or literary compositions,computer programs are protected by copyright.Generally it is an infringement for you to copy into your computer a program from a copyrighted source.(It is also not a friendly thing to do,since it deprives the program's author of compensation for his or her creative effort.)Under
License Information xvii 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 machinereadable 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). Types of License Offered Here are the types of licenses that we offer. Note that some types are automatically acquired with the purchase of media from Cambridge University Press, or of an unlocking password from the Numerical Recipes On-Line Software Store, while other types of licenses require that you communicate specifically with Numerical Recipes Software (email: orders@nr.com or fax: 781 863-1739). Our Web site http://www.nr.com has additional information. • [“Immediate License”] If you are the individual owner of a copy of this book and you type one or more of its routines into your computer, we authorize you to use them on that computer for your own personal and noncommercial purposes. You are not authorized to transfer or distribute machine-readable copies to any other person, or to use the routines on more than one machine, or to distribute executable programs containing our routines. This is the only free license. • [“Single-Screen License”] This is the most common type of low-cost license, with terms governed by our Single Screen (Shrinkwrap) License document (complete terms available through our Web site). Basically, this license lets you use Numerical Recipes routines on any one screen (PC, workstation, X-terminal, etc.). You may also, under this license, transfer pre-compiled, executable programs incorporating our routines to other, unlicensed, screens or computers, providing that (i) your application is noncommercial (i.e., does not involve the selling of your program for a fee), (ii) the programs were first developed, compiled, and successfully run on a licensed screen, and (iii) our routines are bound into the programs in such a manner that they cannot be accessed as individual routines and cannot practicably be unbound and used in other programs. That is, under this license, your program user must not be able to use our programs as part of a program library or “mix-andmatch” workbench. Conditions for other types of commercial or noncommercial distribution may be found on our Web site (http://www.nr.com). • [“Multi-Screen, Server, Site, and Corporate Licenses”] The terms of the Single Screen License can be extended to designated groups of machines, defined by number of screens, number of machines, locations, or ownership. Significant discounts from the corresponding single-screen prices are available when the estimated number of screens exceeds 40. Contact Numerical Recipes Software (email: orders@nr.com or fax: 781 863-1739) for details. • [“Course Right-to-Copy License”] Instructors at accredited educational institutions who have adopted this book for a course, and who have already purchased a Single Screen License (either acquired with the purchase of media, or from the Numerical Recipes On-Line Software Store), may license the programs for use in that course as follows: Mail your name, title, and address; the course name, number, dates, and estimated enrollment; and advance payment of $5 per (estimated) student to Numerical Recipes Software, at this address: P.O. Box 243, Cambridge, MA 02238 (USA). You will receive by return mail a license authorizing you to make copies of the programs for use by your students, and/or to transfer the programs to a machine accessible to your students (but only for the duration of the course). About Copyrights on Computer Programs Like artistic or literary compositions, computer programs are protected by copyright. Generally it is an infringement for you to copy into your computer a program from a copyrighted source. (It is also not a friendly thing to do, since it deprives the program’s author of compensation for his or her creative effort.) Under
xviii License Information copyright law,all "derivative works"(modified versions,or translations into another computer language)also come under the same copyright as the original work. Copyright does not protect ideas,but only the expression of those ideas in a particular form.In the case of a computer program,the ideas consist of the program's methodology and algorithm,including the necessary sequence of steps adopted by the programmer.The expression of those ideas is the program source code(particularly any arbitrary or stylistic choices embodied in it),its derived object code,and any other derivative works. If you analyze the ideas contained in a program,and then express those ideas in your own completely different implementation,then that new program implementation belongs to you.That is what we have done for those programs in this book that are not entirely of our own devising.When programs in this book are said to be "based"on programs published in copyright sources,we mean that the ideas are the same.The expression of these ideas as source code is our own.We believe that no material in this book infringes on an existing copyright. w Trademarks 令 Several registered trademarks appear within the text of this book:Sun is a trademark of Sun Microsystems,Inc.SPARC and SPARCstation are trademarks of SPARC International,Inc.Microsoft,Windows 95,Windows NT,PowerStation, Press. and MS are trademarks of Microsoft Corporation.DEC,VMS,Alpha AXP,and ULTRIX are trademarks of Digital Equipment Corporation.IBM is a trademark of Programs International Business Machines Corporation.Apple and Macintosh are trademarks of Apple Computer,Inc.UNIX is a trademark licensed exclusively through X/Open Co.Ltd.IMSL is a trademark of Visual Numerics,Inc.NAG refers to proprietary 是之 computer software of Numerical Algorithms Group (USA)Inc.PostScript and 6 Adobe Illustrator are trademarks of Adobe Systems Incorporated.Last,and no doubt least,Numerical Recipes(when identifying products)is a trademark of Numerical Recipes Software 兰分 Attributions 10621 The fact that ideas are legally "free as air"in no way supersedes the ethical 43106 requirement that ideas be credited to their known originators.When programs in Numerical Recipes this book are based on known sources,whether copyrighted or in the public domain, published or"handed-down,"we have attempted to give proper attribution.Unfor- (outside tunately,the lineage of many programs in common circulation is often unclear.We would be grateful to readers for new or corrected information regarding attributions, North Software. which we will attempt to incorporate in subsequent printings
xviii License Information 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 machinereadable 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). copyright law, all “derivative works” (modified versions, or translations into another computer language) also come under the same copyright as the original work. Copyright does not protect ideas, but only the expression of those ideas in a particular form. In the case of a computer program, the ideas consist of the program’s methodology and algorithm, including the necessary sequence of steps adopted by the programmer. The expression of those ideas is the program source code (particularly any arbitrary or stylistic choices embodied in it), its derived object code, and any other derivative works. If you analyze the ideas contained in a program, and then express those ideas in your own completely different implementation, then that new program implementation belongs to you. That is what we have done for those programs in this book that are not entirely of our own devising. When programs in this book are said to be “based” on programs published in copyright sources, we mean that the ideas are the same. The expression of these ideas as source code is our own. We believe that no material in this book infringes on an existing copyright. Trademarks Several registered trademarks appear within the text of this book: Sun is a trademark of Sun Microsystems, Inc. SPARC and SPARCstation are trademarks of SPARC International, Inc. Microsoft, Windows 95, Windows NT, PowerStation, and MS are trademarks of Microsoft Corporation. DEC, VMS, Alpha AXP, and ULTRIX are trademarks of Digital Equipment Corporation. IBM is a trademark of International Business Machines Corporation. Apple and Macintosh are trademarks of Apple Computer, Inc. UNIX is a trademark licensed exclusively through X/Open Co. Ltd. IMSL is a trademark of Visual Numerics, Inc. NAG refers to proprietary computer software of Numerical Algorithms Group (USA) Inc. PostScript and Adobe Illustrator are trademarks of Adobe Systems Incorporated. Last, and no doubt least, Numerical Recipes (when identifying products) is a trademark of Numerical Recipes Software. Attributions The fact that ideas are legally “free as air” in no way supersedes the ethical requirement that ideas be credited to their known originators. When programs in this book are based on known sources, whether copyrighted or in the public domain, published or “handed-down,” we have attempted to give proper attribution. Unfortunately, the lineage of many programs in common circulation is often unclear. We would be grateful to readers for new or corrected information regarding attributions, which we will attempt to incorporate in subsequent printings