├── .gitignore ├── LICENSE ├── README.md ├── chapters ├── about-exam.tex ├── chp-1.tex ├── chp-2.tex ├── chp-3.tex ├── chp-4.tex ├── chp-5.tex ├── chp-6.tex ├── chp-7.tex ├── chp-8.tex └── preface.tex ├── cover.png ├── main.tex ├── makefile ├── qyxf-book.cls ├── structure.tex └── zhindex.ist /.gitignore: -------------------------------------------------------------------------------- 1 | ## personal need 2 | wsy 3 | wth 4 | main.pdf 5 | desktop.ini 6 | 7 | ## Core latex/pdflatex auxiliary files: 8 | *.aux 9 | *.lof 10 | *.log 11 | *.lot 12 | *.fls 13 | *.out 14 | *.toc 15 | *.fmt 16 | *.fot 17 | *.cb 18 | *.cb2 19 | .*.lb 20 | 21 | ## Intermediate documents: 22 | *.dvi 23 | *.xdv 24 | *-converted-to.* 25 | # these rules might exclude image files for figures etc. 26 | # *.ps 27 | # *.eps 28 | # *.pdf 29 | 30 | ## Generated if empty string is given at "Please type another file name for output:" 31 | .pdf 32 | 33 | ## Bibliography auxiliary files (bibtex/biblatex/biber): 34 | *.bbl 35 | *.bcf 36 | *.blg 37 | *-blx.aux 38 | *-blx.bib 39 | *.run.xml 40 | 41 | ## Build tool auxiliary files: 42 | *.fdb_latexmk 43 | *.synctex 44 | *.synctex(busy) 45 | *.synctex.gz 46 | *.synctex.gz(busy) 47 | *.pdfsync 48 | 49 | ## Auxiliary and intermediate files from other packages: 50 | # algorithms 51 | *.alg 52 | *.loa 53 | 54 | # achemso 55 | acs-*.bib 56 | 57 | # amsthm 58 | *.thm 59 | 60 | # beamer 61 | *.nav 62 | *.pre 63 | *.snm 64 | *.vrb 65 | 66 | # changes 67 | *.soc 68 | 69 | # cprotect 70 | *.cpt 71 | 72 | # elsarticle (documentclass of Elsevier journals) 73 | *.spl 74 | 75 | # endnotes 76 | *.ent 77 | 78 | # fixme 79 | *.lox 80 | 81 | # feynmf/feynmp 82 | *.mf 83 | *.mp 84 | *.t[1-9] 85 | *.t[1-9][0-9] 86 | *.tfm 87 | 88 | #(r)(e)ledmac/(r)(e)ledpar 89 | *.end 90 | *.?end 91 | *.[1-9] 92 | *.[1-9][0-9] 93 | *.[1-9][0-9][0-9] 94 | *.[1-9]R 95 | *.[1-9][0-9]R 96 | *.[1-9][0-9][0-9]R 97 | *.eledsec[1-9] 98 | *.eledsec[1-9]R 99 | *.eledsec[1-9][0-9] 100 | *.eledsec[1-9][0-9]R 101 | *.eledsec[1-9][0-9][0-9] 102 | *.eledsec[1-9][0-9][0-9]R 103 | 104 | # glossaries 105 | *.acn 106 | *.acr 107 | *.glg 108 | *.glo 109 | *.gls 110 | *.glsdefs 111 | 112 | # gnuplottex 113 | *-gnuplottex-* 114 | 115 | # gregoriotex 116 | *.gaux 117 | *.gtex 118 | 119 | # htlatex 120 | *.4ct 121 | *.4tc 122 | *.idv 123 | *.lg 124 | *.trc 125 | *.xref 126 | 127 | # hyperref 128 | *.brf 129 | 130 | # knitr 131 | *-concordance.tex 132 | # TODO Comment the next line if you want to keep your tikz graphics files 133 | *.tikz 134 | *-tikzDictionary 135 | 136 | # listings 137 | *.lol 138 | 139 | # makeidx 140 | *.idx 141 | *.ilg 142 | *.ind 143 | *.ist 144 | !zhindex.ist 145 | 146 | # minitoc 147 | *.maf 148 | *.mlf 149 | *.mlt 150 | *.mtc[0-9]* 151 | *.slf[0-9]* 152 | *.slt[0-9]* 153 | *.stc[0-9]* 154 | 155 | # minted 156 | _minted* 157 | *.pyg 158 | 159 | # morewrites 160 | *.mw 161 | 162 | # nomencl 163 | *.nlg 164 | *.nlo 165 | *.nls 166 | 167 | # pax 168 | *.pax 169 | 170 | # pdfpcnotes 171 | *.pdfpc 172 | 173 | # sagetex 174 | *.sagetex.sage 175 | *.sagetex.py 176 | *.sagetex.scmd 177 | 178 | # scrwfile 179 | *.wrt 180 | 181 | # sympy 182 | *.sout 183 | *.sympy 184 | sympy-plots-for-*.tex/ 185 | 186 | # pdfcomment 187 | *.upa 188 | *.upb 189 | 190 | # pythontex 191 | *.pytxcode 192 | pythontex-files-*/ 193 | 194 | # thmtools 195 | *.loe 196 | 197 | # TikZ & PGF 198 | *.dpth 199 | *.md5 200 | *.auxlock 201 | 202 | # todonotes 203 | *.tdo 204 | 205 | # easy-todo 206 | *.lod 207 | 208 | # xmpincl 209 | *.xmpi 210 | 211 | # xindy 212 | *.xdy 213 | 214 | # xypic precompiled matrices 215 | *.xyc 216 | 217 | # endfloat 218 | *.ttt 219 | *.fff 220 | 221 | # Latexian 222 | TSWLatexianTemp* 223 | 224 | ## Editors: 225 | # WinEdt 226 | *.bak 227 | *.sav 228 | 229 | # Texpad 230 | .texpadtmp 231 | 232 | # Kile 233 | *.backup 234 | 235 | # KBibTeX 236 | *~[0-9]* 237 | 238 | # auto folder when using emacs and auctex 239 | ./auto/* 240 | *.el 241 | 242 | # expex forward references with \gathertags 243 | *-tags.tex 244 | 245 | # standalone packages 246 | *.sta 247 | 248 | # generated if using elsarticle.cls 249 | *.spl 250 | test.* 251 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The LaTeX Project Public License 2 | =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- 3 | 4 | LPPL Version 1.3c 2008-05-04 5 | 6 | Copyright 1999 2002-2008 LaTeX3 Project 7 | Everyone is allowed to distribute verbatim copies of this 8 | license document, but modification of it is not allowed. 9 | 10 | 11 | PREAMBLE 12 | ======== 13 | 14 | The LaTeX Project Public License (LPPL) is the primary license under 15 | which the LaTeX kernel and the base LaTeX packages are distributed. 16 | 17 | You may use this license for any work of which you hold the copyright 18 | and which you wish to distribute. This license may be particularly 19 | suitable if your work is TeX-related (such as a LaTeX package), but 20 | it is written in such a way that you can use it even if your work is 21 | unrelated to TeX. 22 | 23 | The section `WHETHER AND HOW TO DISTRIBUTE WORKS UNDER THIS LICENSE', 24 | below, gives instructions, examples, and recommendations for authors 25 | who are considering distributing their works under this license. 26 | 27 | This license gives conditions under which a work may be distributed 28 | and modified, as well as conditions under which modified versions of 29 | that work may be distributed. 30 | 31 | We, the LaTeX3 Project, believe that the conditions below give you 32 | the freedom to make and distribute modified versions of your work 33 | that conform with whatever technical specifications you wish while 34 | maintaining the availability, integrity, and reliability of 35 | that work. If you do not see how to achieve your goal while 36 | meeting these conditions, then read the document `cfgguide.tex' 37 | and `modguide.tex' in the base LaTeX distribution for suggestions. 38 | 39 | 40 | DEFINITIONS 41 | =========== 42 | 43 | In this license document the following terms are used: 44 | 45 | `Work' 46 | Any work being distributed under this License. 47 | 48 | `Derived Work' 49 | Any work that under any applicable law is derived from the Work. 50 | 51 | `Modification' 52 | Any procedure that produces a Derived Work under any applicable 53 | law -- for example, the production of a file containing an 54 | original file associated with the Work or a significant portion of 55 | such a file, either verbatim or with modifications and/or 56 | translated into another language. 57 | 58 | `Modify' 59 | To apply any procedure that produces a Derived Work under any 60 | applicable law. 61 | 62 | `Distribution' 63 | Making copies of the Work available from one person to another, in 64 | whole or in part. Distribution includes (but is not limited to) 65 | making any electronic components of the Work accessible by 66 | file transfer protocols such as FTP or HTTP or by shared file 67 | systems such as Sun's Network File System (NFS). 68 | 69 | `Compiled Work' 70 | A version of the Work that has been processed into a form where it 71 | is directly usable on a computer system. This processing may 72 | include using installation facilities provided by the Work, 73 | transformations of the Work, copying of components of the Work, or 74 | other activities. Note that modification of any installation 75 | facilities provided by the Work constitutes modification of the Work. 76 | 77 | `Current Maintainer' 78 | A person or persons nominated as such within the Work. If there is 79 | no such explicit nomination then it is the `Copyright Holder' under 80 | any applicable law. 81 | 82 | `Base Interpreter' 83 | A program or process that is normally needed for running or 84 | interpreting a part or the whole of the Work. 85 | 86 | A Base Interpreter may depend on external components but these 87 | are not considered part of the Base Interpreter provided that each 88 | external component clearly identifies itself whenever it is used 89 | interactively. Unless explicitly specified when applying the 90 | license to the Work, the only applicable Base Interpreter is a 91 | `LaTeX-Format' or in the case of files belonging to the 92 | `LaTeX-format' a program implementing the `TeX language'. 93 | 94 | 95 | 96 | CONDITIONS ON DISTRIBUTION AND MODIFICATION 97 | =========================================== 98 | 99 | 1. Activities other than distribution and/or modification of the Work 100 | are not covered by this license; they are outside its scope. In 101 | particular, the act of running the Work is not restricted and no 102 | requirements are made concerning any offers of support for the Work. 103 | 104 | 2. You may distribute a complete, unmodified copy of the Work as you 105 | received it. Distribution of only part of the Work is considered 106 | modification of the Work, and no right to distribute such a Derived 107 | Work may be assumed under the terms of this clause. 108 | 109 | 3. You may distribute a Compiled Work that has been generated from a 110 | complete, unmodified copy of the Work as distributed under Clause 2 111 | above, as long as that Compiled Work is distributed in such a way that 112 | the recipients may install the Compiled Work on their system exactly 113 | as it would have been installed if they generated a Compiled Work 114 | directly from the Work. 115 | 116 | 4. If you are the Current Maintainer of the Work, you may, without 117 | restriction, modify the Work, thus creating a Derived Work. You may 118 | also distribute the Derived Work without restriction, including 119 | Compiled Works generated from the Derived Work. Derived Works 120 | distributed in this manner by the Current Maintainer are considered to 121 | be updated versions of the Work. 122 | 123 | 5. If you are not the Current Maintainer of the Work, you may modify 124 | your copy of the Work, thus creating a Derived Work based on the Work, 125 | and compile this Derived Work, thus creating a Compiled Work based on 126 | the Derived Work. 127 | 128 | 6. If you are not the Current Maintainer of the Work, you may 129 | distribute a Derived Work provided the following conditions are met 130 | for every component of the Work unless that component clearly states 131 | in the copyright notice that it is exempt from that condition. Only 132 | the Current Maintainer is allowed to add such statements of exemption 133 | to a component of the Work. 134 | 135 | a. If a component of this Derived Work can be a direct replacement 136 | for a component of the Work when that component is used with the 137 | Base Interpreter, then, wherever this component of the Work 138 | identifies itself to the user when used interactively with that 139 | Base Interpreter, the replacement component of this Derived Work 140 | clearly and unambiguously identifies itself as a modified version 141 | of this component to the user when used interactively with that 142 | Base Interpreter. 143 | 144 | b. Every component of the Derived Work contains prominent notices 145 | detailing the nature of the changes to that component, or a 146 | prominent reference to another file that is distributed as part 147 | of the Derived Work and that contains a complete and accurate log 148 | of the changes. 149 | 150 | c. No information in the Derived Work implies that any persons, 151 | including (but not limited to) the authors of the original version 152 | of the Work, provide any support, including (but not limited to) 153 | the reporting and handling of errors, to recipients of the 154 | Derived Work unless those persons have stated explicitly that 155 | they do provide such support for the Derived Work. 156 | 157 | d. You distribute at least one of the following with the Derived Work: 158 | 159 | 1. A complete, unmodified copy of the Work; 160 | if your distribution of a modified component is made by 161 | offering access to copy the modified component from a 162 | designated place, then offering equivalent access to copy 163 | the Work from the same or some similar place meets this 164 | condition, even though third parties are not compelled to 165 | copy the Work along with the modified component; 166 | 167 | 2. Information that is sufficient to obtain a complete, 168 | unmodified copy of the Work. 169 | 170 | 7. If you are not the Current Maintainer of the Work, you may 171 | distribute a Compiled Work generated from a Derived Work, as long as 172 | the Derived Work is distributed to all recipients of the Compiled 173 | Work, and as long as the conditions of Clause 6, above, are met with 174 | regard to the Derived Work. 175 | 176 | 8. The conditions above are not intended to prohibit, and hence do not 177 | apply to, the modification, by any method, of any component so that it 178 | becomes identical to an updated version of that component of the Work as 179 | it is distributed by the Current Maintainer under Clause 4, above. 180 | 181 | 9. Distribution of the Work or any Derived Work in an alternative 182 | format, where the Work or that Derived Work (in whole or in part) is 183 | then produced by applying some process to that format, does not relax or 184 | nullify any sections of this license as they pertain to the results of 185 | applying that process. 186 | 187 | 10. a. A Derived Work may be distributed under a different license 188 | provided that license itself honors the conditions listed in 189 | Clause 6 above, in regard to the Work, though it does not have 190 | to honor the rest of the conditions in this license. 191 | 192 | b. If a Derived Work is distributed under a different license, that 193 | Derived Work must provide sufficient documentation as part of 194 | itself to allow each recipient of that Derived Work to honor the 195 | restrictions in Clause 6 above, concerning changes from the Work. 196 | 197 | 11. This license places no restrictions on works that are unrelated to 198 | the Work, nor does this license place any restrictions on aggregating 199 | such works with the Work by any means. 200 | 201 | 12. Nothing in this license is intended to, or may be used to, prevent 202 | complete compliance by all parties with all applicable laws. 203 | 204 | 205 | NO WARRANTY 206 | =========== 207 | 208 | There is no warranty for the Work. Except when otherwise stated in 209 | writing, the Copyright Holder provides the Work `as is', without 210 | warranty of any kind, either expressed or implied, including, but not 211 | limited to, the implied warranties of merchantability and fitness for a 212 | particular purpose. The entire risk as to the quality and performance 213 | of the Work is with you. Should the Work prove defective, you assume 214 | the cost of all necessary servicing, repair, or correction. 215 | 216 | In no event unless required by applicable law or agreed to in writing 217 | will The Copyright Holder, or any author named in the components of the 218 | Work, or any other party who may distribute and/or modify the Work as 219 | permitted above, be liable to you for damages, including any general, 220 | special, incidental or consequential damages arising out of any use of 221 | the Work or out of inability to use the Work (including, but not limited 222 | to, loss of data, data being rendered inaccurate, or losses sustained by 223 | anyone as a result of any failure of the Work to operate with any other 224 | programs), even if the Copyright Holder or said author or said other 225 | party has been advised of the possibility of such damages. 226 | 227 | 228 | MAINTENANCE OF THE WORK 229 | ======================= 230 | 231 | The Work has the status `author-maintained' if the Copyright Holder 232 | explicitly and prominently states near the primary copyright notice in 233 | the Work that the Work can only be maintained by the Copyright Holder 234 | or simply that it is `author-maintained'. 235 | 236 | The Work has the status `maintained' if there is a Current Maintainer 237 | who has indicated in the Work that they are willing to receive error 238 | reports for the Work (for example, by supplying a valid e-mail 239 | address). It is not required for the Current Maintainer to acknowledge 240 | or act upon these error reports. 241 | 242 | The Work changes from status `maintained' to `unmaintained' if there 243 | is no Current Maintainer, or the person stated to be Current 244 | Maintainer of the work cannot be reached through the indicated means 245 | of communication for a period of six months, and there are no other 246 | significant signs of active maintenance. 247 | 248 | You can become the Current Maintainer of the Work by agreement with 249 | any existing Current Maintainer to take over this role. 250 | 251 | If the Work is unmaintained, you can become the Current Maintainer of 252 | the Work through the following steps: 253 | 254 | 1. Make a reasonable attempt to trace the Current Maintainer (and 255 | the Copyright Holder, if the two differ) through the means of 256 | an Internet or similar search. 257 | 258 | 2. If this search is successful, then enquire whether the Work 259 | is still maintained. 260 | 261 | a. If it is being maintained, then ask the Current Maintainer 262 | to update their communication data within one month. 263 | 264 | b. If the search is unsuccessful or no action to resume active 265 | maintenance is taken by the Current Maintainer, then announce 266 | within the pertinent community your intention to take over 267 | maintenance. (If the Work is a LaTeX work, this could be 268 | done, for example, by posting to comp.text.tex.) 269 | 270 | 3a. If the Current Maintainer is reachable and agrees to pass 271 | maintenance of the Work to you, then this takes effect 272 | immediately upon announcement. 273 | 274 | b. If the Current Maintainer is not reachable and the Copyright 275 | Holder agrees that maintenance of the Work be passed to you, 276 | then this takes effect immediately upon announcement. 277 | 278 | 4. If you make an `intention announcement' as described in 2b. above 279 | and after three months your intention is challenged neither by 280 | the Current Maintainer nor by the Copyright Holder nor by other 281 | people, then you may arrange for the Work to be changed so as 282 | to name you as the (new) Current Maintainer. 283 | 284 | 5. If the previously unreachable Current Maintainer becomes 285 | reachable once more within three months of a change completed 286 | under the terms of 3b) or 4), then that Current Maintainer must 287 | become or remain the Current Maintainer upon request provided 288 | they then update their communication data within one month. 289 | 290 | A change in the Current Maintainer does not, of itself, alter the fact 291 | that the Work is distributed under the LPPL license. 292 | 293 | If you become the Current Maintainer of the Work, you should 294 | immediately provide, within the Work, a prominent and unambiguous 295 | statement of your status as Current Maintainer. You should also 296 | announce your new status to the same pertinent community as 297 | in 2b) above. 298 | 299 | 300 | WHETHER AND HOW TO DISTRIBUTE WORKS UNDER THIS LICENSE 301 | ====================================================== 302 | 303 | This section contains important instructions, examples, and 304 | recommendations for authors who are considering distributing their 305 | works under this license. These authors are addressed as `you' in 306 | this section. 307 | 308 | Choosing This License or Another License 309 | ---------------------------------------- 310 | 311 | If for any part of your work you want or need to use *distribution* 312 | conditions that differ significantly from those in this license, then 313 | do not refer to this license anywhere in your work but, instead, 314 | distribute your work under a different license. You may use the text 315 | of this license as a model for your own license, but your license 316 | should not refer to the LPPL or otherwise give the impression that 317 | your work is distributed under the LPPL. 318 | 319 | The document `modguide.tex' in the base LaTeX distribution explains 320 | the motivation behind the conditions of this license. It explains, 321 | for example, why distributing LaTeX under the GNU General Public 322 | License (GPL) was considered inappropriate. Even if your work is 323 | unrelated to LaTeX, the discussion in `modguide.tex' may still be 324 | relevant, and authors intending to distribute their works under any 325 | license are encouraged to read it. 326 | 327 | A Recommendation on Modification Without Distribution 328 | ----------------------------------------------------- 329 | 330 | It is wise never to modify a component of the Work, even for your own 331 | personal use, without also meeting the above conditions for 332 | distributing the modified component. While you might intend that such 333 | modifications will never be distributed, often this will happen by 334 | accident -- you may forget that you have modified that component; or 335 | it may not occur to you when allowing others to access the modified 336 | version that you are thus distributing it and violating the conditions 337 | of this license in ways that could have legal implications and, worse, 338 | cause problems for the community. It is therefore usually in your 339 | best interest to keep your copy of the Work identical with the public 340 | one. Many works provide ways to control the behavior of that work 341 | without altering any of its licensed components. 342 | 343 | How to Use This License 344 | ----------------------- 345 | 346 | To use this license, place in each of the components of your work both 347 | an explicit copyright notice including your name and the year the work 348 | was authored and/or last substantially modified. Include also a 349 | statement that the distribution and/or modification of that 350 | component is constrained by the conditions in this license. 351 | 352 | Here is an example of such a notice and statement: 353 | 354 | %% pig.dtx 355 | %% Copyright 2005 M. Y. Name 356 | % 357 | % This work may be distributed and/or modified under the 358 | % conditions of the LaTeX Project Public License, either version 1.3 359 | % of this license or (at your option) any later version. 360 | % The latest version of this license is in 361 | % http://www.latex-project.org/lppl.txt 362 | % and version 1.3 or later is part of all distributions of LaTeX 363 | % version 2005/12/01 or later. 364 | % 365 | % This work has the LPPL maintenance status `maintained'. 366 | % 367 | % The Current Maintainer of this work is M. Y. Name. 368 | % 369 | % This work consists of the files pig.dtx and pig.ins 370 | % and the derived file pig.sty. 371 | 372 | Given such a notice and statement in a file, the conditions 373 | given in this license document would apply, with the `Work' referring 374 | to the three files `pig.dtx', `pig.ins', and `pig.sty' (the last being 375 | generated from `pig.dtx' using `pig.ins'), the `Base Interpreter' 376 | referring to any `LaTeX-Format', and both `Copyright Holder' and 377 | `Current Maintainer' referring to the person `M. Y. Name'. 378 | 379 | If you do not want the Maintenance section of LPPL to apply to your 380 | Work, change `maintained' above into `author-maintained'. 381 | However, we recommend that you use `maintained', as the Maintenance 382 | section was added in order to ensure that your Work remains useful to 383 | the community even when you can no longer maintain and support it 384 | yourself. 385 | 386 | Derived Works That Are Not Replacements 387 | --------------------------------------- 388 | 389 | Several clauses of the LPPL specify means to provide reliability and 390 | stability for the user community. They therefore concern themselves 391 | with the case that a Derived Work is intended to be used as a 392 | (compatible or incompatible) replacement of the original Work. If 393 | this is not the case (e.g., if a few lines of code are reused for a 394 | completely different task), then clauses 6b and 6d shall not apply. 395 | 396 | 397 | Important Recommendations 398 | ------------------------- 399 | 400 | Defining What Constitutes the Work 401 | 402 | The LPPL requires that distributions of the Work contain all the 403 | files of the Work. It is therefore important that you provide a 404 | way for the licensee to determine which files constitute the Work. 405 | This could, for example, be achieved by explicitly listing all the 406 | files of the Work near the copyright notice of each file or by 407 | using a line such as: 408 | 409 | % This work consists of all files listed in manifest.txt. 410 | 411 | in that place. In the absence of an unequivocal list it might be 412 | impossible for the licensee to determine what is considered by you 413 | to comprise the Work and, in such a case, the licensee would be 414 | entitled to make reasonable conjectures as to which files comprise 415 | the Work. 416 | 417 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 计算方法撷英 2 | 3 | 这是一份电子版的**计算方法**课程笔记,底稿来自于西安交通大学 2014 级少年班王天浩同学的纸质笔记,由 2015 级少年班的尤佳睿([@xjtu-blacksmith](https://github.com/xjtu-blacksmith))整理、增补为电子版本。 4 | 5 | 欲下载 PDF 文件,请转至 [release](https://github.com/xjtu-blacksmith/notes-on-computing-methods/releases/) 页面;其他信息,请检查本笔记的「前言」部分。 6 | 7 | 本作品由[钱院学辅](https://qyxf.site/)出品。作品内容由 [CC BY-NC-ND 4.0 协议](https://creativecommons.org/licenses/by-nc-nd/4.0/)授权,欢迎分享、发布;作品源代码按 [LPPL v1.3c 协议](/LICENSE)授权。 8 | 9 | ## 目录结构 10 | 11 | - `main.tex`:主文件,请编译它 12 | - `qyxf-book.cls`:[钱院学辅通用书籍模板](https://github.com/qyxf/qyxf-sets),有改动 13 | - `cover.png`:模板所需的封面背景图 14 | - `structure.tex`:补充宏包声明与符号、命令定义 15 | - `chapters` 目录:嵌入 `main.tex` 的章节子文件目录 16 | - `zhindex.ist`:中文索引样式文件,不需要索引时可删去(见下「文件编译」部分的说明) 17 | - `makefile`:Makefile 文件 18 | 19 | ## 文件编译 20 | 21 | 本份文档需采用 `xelatex` 方式编译。文末的索引由 `zhmakeindex` 程序生成(请访问其 [GitHub 仓库](https://github.com/leo-liu/zhmakeindex)获取该程序),建议与 `xelatex` 命令按如下次序组合: 22 | 23 | ```shell 24 | xelatex main.tex 25 | zhmakeindex -s zhindex.ist main.idx 26 | xelatex main.tex 27 | xelatex main.tex 28 | ``` 29 | 30 | 其中 `zhindex.ist` 为索引样式文件,已在本份文档目录中。如您难以获取 `zhmakeindex` 程序或不需要索引,请在 `main.tex` 中的 `\backmatter` 部分将 `\printindex` 命令及其上生成目录的命令去除(有注释说明)。 31 | 32 | 本项目内有一个比较简陋的 Makefile,可执行以上操作。 -------------------------------------------------------------------------------- /chapters/about-exam.tex: -------------------------------------------------------------------------------- 1 | \chapter{附录:考试内容评析} 2 | \begin{itemize} 3 | \item 在本校,与「数值计算方法」相关的课程大致可以分为工科生的\emph{计算方法}与数学系学生的\emph{数值分析}两大类。后者较前者难度更高,对计算与证明过程有更详细的考察;而目前流传的「往年试卷」中,往往以\emph{数值分析}的考卷居多,这会给修\emph{计算方法}课程的同学造成误导。因此,请不要过于相信这些「往年考卷」。 4 | \item 关于\emph{复习}:复习过程中并不需要做太多的「练习」,只需牢记相关知识点和例题即可。仅就这份笔记而言,考试中所有可能出现的知识点均已涉及到了。 5 | \item 关于\emph{考试题型}:从近几年的情况来看,一般分为\emph{填空题}和\emph{计算题}两大类,各占一半左右的分数。其中: 6 | \begin{itemize} 7 | \item 填空题主要考察知识点,基本上不需要计算(口算就能解决)。大多数题目都有「窍门」,很多看似复杂的题目之结果其实非常简单。课程中所有的基础知识点都有可能涉及到。分值很高,注意不要丢分。 8 | \item 计算题更像是「证明题」或「简答题」,主要目的在于考察学生对各类计算方法原理的理解应用能力(主要)或推导证明能力(次要)。具体的数值计算量并不大。 9 | \end{itemize} 10 | \item 计算题常见考点:以下考点基本上是固定的,在作业题中也时常操练,不需要特别担心。 11 | \begin{itemize}\tl 12 | \item 对矩阵做 LU 分解; 13 | \item 判断三种线性方程迭代法的收敛性(近年来较少考,但有可能出此类题目); 14 | \item 对给定数据点做 Newton 插值; 15 | \item 利用待定系数法推导简单的数值积分公式,使之达到指定代数精度; 16 | \item 判断非线性方程迭代格式的收敛性。 17 | \end{itemize} 18 | \end{itemize} 19 | -------------------------------------------------------------------------------- /chapters/chp-1.tex: -------------------------------------------------------------------------------- 1 | \chapter{误差} 2 | \section{真值与误差} 3 | \entry 有测量就会有误差。通常,将某数学量、物理量的\key{真值}记为$x$(不加任何修饰符),而将测量或计算所得的$x$的\key{近似值}记作$\tilde{x}$。 4 | 5 | \entry 两种误差:$\begin{cases}\Delta x=x-\tilde{x} \text{\ (绝对误差)}\\ \delta x=\frac{x-\tilde{x}}{x}\text{\ (相对误差)}\end{cases}$ 6 | 7 | \entry 两种误差限:$\begin{cases}|\Delta x|\leq\varepsilon\text{\ (绝对误差限)}\\|\delta x|\leq\varepsilon_r\text{\ (相对误差限)}\end{cases}$ 8 | 9 | \entry 相对误差较小时,有近似计算式\footnote{在估计误差时,真值$x$往往难以确定,但绝对误差$|\Delta x|$或绝对误差限$\varepsilon$往往能够确定下来。} 10 | :$|\delta x|\approx\frac{|x-\tilde{x}|}{\tilde{x}}=\frac{\Delta x}{\tilde{x}}\leq\frac{|\varepsilon|}{\tilde{x}}$ 11 | 12 | \entry 若$|\Delta x|=|x-\tilde{x}|\leq0.5\times10^{-n}$,则称$x$的近似值$\tilde{x}$ \emph{准确到第 $n$ 位小数}。 13 | 14 | \example 设$x=0.31682$,则$\tilde{x}_1=0.3$精确到$1$位有效数字,$\tilde{x}_2=0.32$精确到$2$位,$\tilde{x}_3=0.317$精确到$3$位,$\tilde{x}_4=0.3168$精确到$4$位。若取$\tilde{x}_5=0.3169$为$x$的近似值,则其仅精确到$3$位小数。 15 | 16 | \section{浮点运算与浮点数集} 17 | \entry 在计算机中,实数将被储存为\key{浮点数},故计算机中的实数运算常被称作\key{浮点运算}。为此,有下面的一些概念与理论。 18 | 19 | \entry \key{浮点运算量}:记\emph{一次加法和一次乘法}(如$a+b\times c$)所需的时间为一个\key{时间单位},记为flop。 20 | 21 | \example 设$\mathbf{A}_1$为一$10\times20$的矩阵,$\mathbf{A}_2$为一$20\times50$的矩阵,欲计算$\mathbf{A}_1\cdot\mathbf{A}_2$,则运算量为$10\times20\times50=10000$ flop 22 | \footnote{$\mathbf{A}_1$的行乘以$\mathbf{A}_2$的列,每次的浮点运算量为 $20$ flop,总计 $10\times50$ 种组合。}。 23 | 24 | \entry \key{浮点数集}:在10进制中,浮点数$\tilde{x}$(或一实数$x$的近似$t$位有效数字的浮点数$\tilde{x}$)可表示如下: 25 | \[fl(x)=\tilde{x}=\pm\left\{\frac{x_1}{10}+\frac{x_2}{10^2}+\frac{x_3}{10^3}+\cdots+\frac{x_t}{10^t}\right\}\times10^l\ (\tilde{x}=0.x_1x_2x_3\cdots x_t\times10^l)\] 26 | 其中$1\leq x_1<10$,$0\leq x_j<10$,$j=2,3,\cdots,t$。类似的,在$\beta$进制中,一个数的表示方式: 27 | \[fl(x)=\tilde{x}=\pm\left\{\frac{x_1}{\beta}+\frac{x_2}{\beta^2}+\cdots+\frac{x_t}{\beta^t}\right\}\times\beta^l\] 28 | 其中$1\leq x_1<\beta$,$0\leq x_j<\beta$,$j=2,3,\cdots,t$。$\beta^l$称为指数部分,指数$l$满足$L\leq l\leq U$,$L$与$U$分别为下界与上界;$0.x_1x_2\cdots x_t$称为尾数。$fl(x)$称为一个\key{规格化浮点数}。 29 | 30 | \entry 称计算机中所能表示的全体数的集合称为\key{浮点数集},记为$F(\beta,t,L,U)$。 31 | \begin{equation} 32 | F(\beta,t,L,U)=\{0\}\cup\left\{\pm\left(\frac{x_1}{\beta}+\frac{x_2}{\beta^2}+\cdots+\frac{x_t}{\beta^t}\right)\times\beta^l:L\leq l\leq U\right\} 33 | \end{equation} 34 | 35 | \example \textsf{C++}里的 \verb|float|:4 字节、32 位,如图 \ref{1-2} 所示。可以将这一浮点数集记为$F(2,23,-128,127)$。 36 | \begin{figure}[htbp] 37 | \small\centering 38 | \begin{tikzpicture}[scale=.8] 39 | \draw (0, 0) rectangle (1, 1); 40 | \draw (1, 0) rectangle (2, 1); 41 | \draw (2, 0) rectangle (3, 1); 42 | \draw[dashed] (3, 0) rectangle (4, 1); 43 | \draw (4, 0) rectangle (5, 1); 44 | \draw (5, 0) rectangle (6, 1); 45 | \draw[dashed] (6, 0) rectangle (7, 1); 46 | \draw (7, 0) rectangle (8, 1); 47 | \draw (8, 0) rectangle (9, 1); 48 | \node at (0.5, 0.5) {$0$}; \node at (0.5, 1.3) {$31$}; 49 | \node at (1.5, 0.5) {$0$}; \node at (1.5, 1.3) {$30$}; 50 | \node at (2.5, 0.5) {$1$}; \node at (2.5, 1.3) {$29$}; 51 | \node at (3.5, 0.5) {\ldots}; 52 | \node at (4.5, 0.5) {$0$}; \node at (4.5, 1.3) {$23$}; 53 | \node at (5.5, 0.5) {$0$}; \node at (5.5, 1.3) {$22$}; 54 | \node at (6.5, 0.5) {\ldots}; 55 | \node at (7.5, 0.5) {$1$}; \node at (7.5, 1.3) {$1$}; 56 | \node at (8.5, 0.5) {$1$}; \node at (8.5, 1.3) {$0$}; 57 | \node at (0.5, -0.3) {$\downarrow$}; 58 | \node at (0.5, -0.8) {底数符号}; 59 | \draw (3, -0.3) node [xscale=3.5, rotate=90] {$\Biggl\{$}; 60 | \node at (3, -0.8) {指数位(含符号)}; 61 | \draw (7, -0.3) node [xscale=3.5, rotate=90] {$\Biggl\{$}; 62 | \node at (7, -0.8) {底数位}; 63 | \end{tikzpicture} 64 | \caption{\textsf{C++}中\texttt{float}类型变量的储存原理}\label{1-2} 65 | \end{figure} 66 | 67 | \entry 浮点数集中的数的个数:$N=2\cdot(\beta-1)\cdot\beta^{t-1}\cdot(U-L+1)+1$ 68 | 69 | \entry 浮点数$fl(x)$与对应真值$x$的误差: 70 | \begin{itemize}\tl 71 | \item 绝对误差:$|x-fl(x)|\leq\dfrac12\beta^{-t}\times\beta^l=\dfrac12\beta^{l-t}$ 72 | \item 相对误差:由$|x|\geq0.1\times\beta^l$,有$\dfrac{|x-fl(x)|}{|x|}\leq\dfrac{\beta^{l-t}/2}{\beta^{l-1}}=\dfrac12\beta^{1-t}$ 73 | \end{itemize} 74 | 此类误差称为\key{舍入误差}。 75 | 76 | \entry 计算结果的错误/误差: 77 | \begin{enumerate}\tl 78 | \item $l\notin[L,U]$:\key{上溢}($l\geq L$)会出错,\key{下溢}($l\leq U$)变为$0$。 79 | \item 尾数多于$t$位:自动进行舍入处理,造成误差 80 | \item 有效数字丢失:「\emph{大数吃小数}」 81 | \end{enumerate} 82 | 83 | 84 | \example 设计算时保留4位有效数字,则$1234+0.3678=1234.3678\approx1234$,在此发生了「大数吃小数」的现象。 85 | 86 | \entry 设计数值计算的算法时,应结合浮点数具有的特性,避免上面所提到的各类计算错误。为此,提出以下几条\emph{浮点运算原则}: 87 | \begin{enumerate}\tl 88 | \item 避免产生大结果的运算,避免小数作为除数。 89 | \item 避免「大」、「小」数相加减,防止大数吃小数。 90 | \item 避免相近数直接相减,防止有效数字损失。 91 | \item 简化运算步骤,减少运算次数 92 | \footnote{由此避免各类误差的逐次累计。——编者注}。 93 | \end{enumerate} 94 | 若原有的计算公式不符合以上的这些原则,则可以通过对原式的等价变换或近似处理,使之符合上面的原则。 95 | 96 | \example 设$|x|\ll1$,则可改写数值计算公式$\ln\dfrac{1-\sqrt{1-x^2}}{|x|}$为以下形式,以避免小数作分母: 97 | \[\ln\frac{1-\sqrt{1-x^2}}{|x|}=\ln\frac{x^2}{|x|\cdot(1+\sqrt{1-x^2})}=\ln\frac{|x|}{1+\sqrt{1-x^2}}\] 98 | 99 | \section{计算方法的研究内容} 100 | \entry 计算方法课程,并不仅仅包含各类数值计算方法。归结而言,计算方法课程的研究内容可以归纳为: 101 | \begin{enumerate}\tl 102 | \item 某一问题的数值计算算法(即通常意义上的「计算方法」); 103 | \item 这些算法的误差、复杂性或收敛速度之估计。 104 | \end{enumerate} 105 | 后者至关重要。对于算法的误差或复杂性分析,使这门课程区别于一般的工具性课程。 106 | 107 | \entry 针对一些模型,还存在着一类特定的问题,即\textbf{病态问题}。为度量这类问题的性质,需要用到\key{条件数}。 108 | \begin{itemize}\tl 109 | \item 根据输入数据的微小变化能引起问题之解变化的大小程度,可以将数值计算问题区别为两类:若由此能引起解的很大变化,则称问题是\textbf{病态}的;否则,称一个问题是\textbf{良态}的。病态问题不易精确求解。 110 | \item \key{条件数}:输入数据$x,\tilde{x}$,输出$f(x),f(\tilde{x})$。设$x\neq0$,$f(x)\neq0$,若存在$m>0$使: 111 | \[\frac{|f(x)-f(\tilde{x})|}{|f(x)|}\leq m\cdot\frac{|x-\tilde{x}|}{|x|}\ (\text{输出误差}\leq m\cdot\text{输入误差})\] 112 | 则将$m$称为该问题的\textbf{条件数},记为$\cond(f)$。 113 | \end{itemize} 114 | 115 | \example $y=\varphi(x_1,x_2,\cdots,x_n)$。输入为$\tilde{x}_1,\tilde{x}_2,\cdots,\tilde{x}_n$,近似解$\tilde{y}=\varphi(\tilde{x}_1,\tilde{x}_2,\cdots,\tilde{x}_n)$,则有 116 | \begin{gather} 117 | \Delta y=\varphi(x_1,x_2,\cdots,x_n)-\varphi(\tilde{x}_1,\tilde{x}_2,\cdots,\tilde{x}_n) 118 | \approx\sum_{i=1}^n\frac{\partial\varphi(\tilde{x}_1,\tilde{x}_2,\cdots,\tilde{x}_n)}{\partial x_i}\Delta x_i\\ 119 | \delta y=\frac{\Delta y}{y}\approx\sum_{i=1}^n\frac{\partial\varphi(\tilde{x}_1,\tilde{x}_2,\cdots,\tilde{x}_n)}{\partial x_i}\cdot\frac{\Delta x_i}{y} 120 | =\sum_{i=1}^n\frac{\partial\varphi(\tilde{x}_1,\tilde{x}_2,\cdots,\tilde{x}_n)}{\partial x_i}\cdot\frac{x_i}{y}\cdot\delta x_i 121 | \end{gather} 122 | 故可见$\left|\frac{\partial\varphi(\tilde{x}_1,\tilde{x}_2,\cdots,\tilde{x}_n)}{\partial x_i}\cdot\frac{x_i}{y}\right|$即条件数。 123 | 124 | \entry \key{稳定性}(数值稳定性):运算中\textbf{舍入误差积累}是否影响结果的可靠性。 125 | 126 | \example 欲用数值计算方法求解由$I_k=\e^{-1}\int_0^1x^k\e^x\di x,\ k=0,1,\cdots,7$所定义的一系列定积分的值。 127 | \begin{itemize}\tl 128 | \item 算法1:构建递推公式 129 | \begin{equation}\label{1-e1} 130 | \left\{ 131 | \begin{aligned} 132 | I_0&=\e^{-1}\int_0^1\di x=1-\dfrac1\e\\ 133 | I_k&=\e^{-1}\int_0^1x^k\e^x\di x=1-kI_{k-1} 134 | \end{aligned} 135 | \right. 136 | \end{equation} 137 | 利用递推关系依次计算$I_0\rightarrow I_1\rightarrow I_1\rightarrow\cdots\rightarrow I_7$。 138 | \item 算法2:近似计算$I_7$,利用递推关系 139 | \footnote{即将(\ref{1-e1})式移项,反得$I_{k-1}=\dfrac{1-I_k}{k}$。——编者注} 140 | 依次计算$I_7\rightarrow I_6\rightarrow\cdots\rightarrow I_0$。 141 | \end{itemize} 142 | 实际上就整体而言,算法2精度更高。对算法1递推公式$I_k=1-kI_{k-1}$。若$I_{k-1}$有舍入误差$\Delta I_{k-1}$(或记作$\Delta$),则$\tilde{I}_k=1-k(I_{k-1}+\Delta)=I_k-k\cdot\Delta$,误差被放大 143 | \footnote{对算法2的递推公式做类似分析,可见$\tilde{I}_{k-1}=I_{k-1}-\Delta/k$,即误差被减小到原来的$1/k$倍,这是大大缩小了。故算法2较算法1更为稳定。——编者注}。 144 | -------------------------------------------------------------------------------- /chapters/chp-2.tex: -------------------------------------------------------------------------------- 1 | \chapter{线性方程组直接解法} 2 | \section{Gauss消元法的引入} 3 | 4 | \entry 整体思路: 5 | \begin{enumerate}\tl 6 | \item 先推得$\mathbf{Ax}=\mathbf{b}\sothat\mathbf{x}=\mathbf{A}^{-1}\mathbf{b}$,再求$\mathbf{A}^{-1}$(初等行变换法、伴随矩阵法、Gauss-Jordan消去法) 7 | \item Crammer法则:$\mathbf{Ax}=\mathbf{b}\sothat x_i=\frac{|\mathbf{A}_i|}{|\mathbf{A}|}$,浮点运算量 $N=(n^2-1)\cdot n!+n$ flop(很大) 8 | \end{enumerate} 9 | 10 | \entry \key{Gauss消去法}:降维($n\to (n-1)\to\cdots\to1$) 11 | \begin{figure}[htbp] 12 | \small\centering 13 | \begin{align*}\scriptstyle 14 | \phantom{\displaystyle\ \Rightarrow\ }\begin{pmatrix} 15 | \ast & \ast & \ast & \ast & \ast \\ 16 | \ast & \ast & \ast & \ast & \ast \\ 17 | \ast & \ast & \ast & \ast & \ast \\ 18 | \ast & \ast & \ast & \ast & \ast \\ 19 | \ast & \ast & \ast & \ast & \ast 20 | \end{pmatrix} 21 | \cdot \mathbf{\displaystyle x =} 22 | \begin{pmatrix} 23 | \ast \\ \ast \\ \ast \\ \ast \\ \ast 24 | \end{pmatrix} 25 | {\displaystyle\ \Rightarrow\ } 26 | \begin{pmatrix} 27 | \ast & \ast & \ast & \ast & \ast \\ 28 | & \ast & \ast & \ast & \ast \\ 29 | & \ast & \ast & \ast & \ast \\ 30 | & \ast & \ast & \ast & \ast \\ 31 | & \ast & \ast & \ast & \ast 32 | \end{pmatrix} 33 | \cdot \mathbf{\displaystyle x =} 34 | \begin{pmatrix} 35 | \ast \\ \ast \\ \ast \\ \ast \\ \ast 36 | \end{pmatrix} 37 | {\displaystyle\ \Rightarrow\ } 38 | \begin{pmatrix} 39 | \ast & \ast & \ast & \ast & \ast \\ 40 | & \ast & \ast & \ast & \ast \\ 41 | & & \ast & \ast & \ast \\ 42 | & & & \ast & \ast \\ 43 | & & & & \ast 44 | \end{pmatrix} 45 | \cdot \mathbf{\displaystyle x =} 46 | \begin{pmatrix} 47 | \ast \\ \ast \\ \ast \\ \ast \\ \ast 48 | \end{pmatrix}\\[0.5ex]\scriptstyle 49 | {\displaystyle\ \Rightarrow\ } 50 | \begin{pmatrix} 51 | \ast & \ast & \ast & \ast & \\ 52 | & \ast & \ast & \ast & \\ 53 | & & \ast & \ast & \\ 54 | & & & \ast & \\ 55 | & & & & \ast 56 | \end{pmatrix} 57 | \cdot \mathbf{\displaystyle x =} 58 | \begin{pmatrix} 59 | \ast \\ \ast \\ \ast \\ \ast \\ \ast 60 | \end{pmatrix} 61 | {\displaystyle\ \Rightarrow\ } 62 | \begin{pmatrix} 63 | \ast & \ast & \ast & & \\ 64 | & \ast & \ast & & \\ 65 | & & \ast & & \\ 66 | & & & \ast & \\ 67 | & & & & \ast 68 | \end{pmatrix} 69 | \cdot \mathbf{\displaystyle x =} 70 | \begin{pmatrix} 71 | \ast \\ \ast \\ \ast \\ \ast \\ \ast 72 | \end{pmatrix} 73 | {\displaystyle\ \Rightarrow\ } 74 | \begin{pmatrix} 75 | \ast & & & & \\ 76 | & \ast & & & \\ 77 | & & \ast & & \\ 78 | & & & \ast & \\ 79 | & & & & \ast 80 | \end{pmatrix} 81 | \cdot \mathbf{\displaystyle x =} 82 | \begin{pmatrix} 83 | \ast \\ \ast \\ \ast \\ \ast \\ \ast 84 | \end{pmatrix} 85 | \end{align*} 86 | \caption{Gauss消去法步骤示意图(上排降维消元,下排回代求解)}\label{2-f1} 87 | \end{figure} 88 | \begin{itemize}\tl 89 | \item 消去运算量:$N_1=\sum\limits_{k=1}^{n-1}(n-k)(n-k+2)=\frac{n^3}3+n^2-\frac{5n}6$ 90 | \item 回代运算量:$N_2=1+2+\cdots+n=\frac{n(n+1)}2$ 91 | \item 总计运算量:$N=N_1+\frac32N_2=\frac{n^3}3+n^2-\frac n3=O(n^3)$ 92 | \end{itemize} 93 | 94 | \entry 可能出现的问题:(主要是消去过程中) 95 | \begin{enumerate}\tl 96 | \item $a_{kk}^{(k-1)}=0$,无法进行 97 | \item $|a_{kk}^{(k-1)}|\ll|a_{ik}^{(k-1)}|\ (i=k+1,k+2,\cdots,n)$,误差极大(大/小=大,误差被放大) 98 | \end{enumerate} 99 | 对问题 1,只要满足:(1)$\mathbf{A}$是方阵;(2)$|\mathbf{A}|\neq0$,即可通过换行达到解决问题。 100 | 对问题 2,则不易解决\footnote{参见下一节中的「列主元Gauss消元法」。}。 101 | 102 | \trm $a_{kk}^{(k-1)}$不为$0$的\emph{充要条件}是:$\mathbf{A}$的$1$阶与$k$阶主子式均不为$0$,即 103 | \[a_{kk}^{(k-1)}\neq0\ \Leftrightarrow\ D_1=a_{11}\neq0,\ D_k=\left|\begin{array}{cccc}a_{11}&a_{12}&\cdots&a_{1k}\\a_{21}&a_{22}&\cdots&a_{2k}\\\vdots&\vdots&\ddots&\vdots\\a_{k1}&a_{k2}&\cdots&a_{kk}\end{array}\right|\] 104 | 105 | \define 设矩阵$\mathbf{A}$满足$\sum\limits_{j=1,j\neq i}^n|a_{ij}|<|a_{ii}|$~,则称$\mathbf{A}$是\key{严格对角占优矩阵}。 106 | 107 | \entry Gauss消去法\emph{顺利进行条件}(满足其一即可): 108 | \begin{enumerate}\tl 109 | \item $\mathbf{A}$各阶顺序主子式不等于$0$。 110 | \item $\mathbf{A}$是对称正定阵。 111 | \item $\mathbf{A}$是严格对角占优矩阵。 112 | \end{enumerate} 113 | 114 | 115 | \section{Gauss消元法的改进} 116 | \entry \key{列主元Gauss消元法}. 消去进行到第$k$步时如下所示: 117 | \[\begin{pmatrix}a_{11}^{(k-1)}&a_{12}^{(k-1)}&\cdots&a_{1k}^{(k-1)}&\cdots&a_{1n}^{(k-1)}\\0&a_{22}^{(k-1)}&\cdots&a_{2k}^{(k-1)}&\cdots&a_{2n}^{(k-1)}\\\vdots&\vdots&&\vdots&&\vdots\\0&0&\cdots&a_{kk}^{(k-1)}&\cdots&a_{kn}^{(k-1)}\\\vdots&\vdots&&\vdots&&\vdots\\0&0&\cdots&a_{nk}^{(k-1)}&\cdots&a_{nn}^{(k-1)}\end{pmatrix}\] 118 | 选取$\max(|a_{ik}^{(k-1)}|)\ i=k,k+1,\cdots,n$的一行与第$k$行互换,继续消去(算法较稳定) 119 | 120 | \entry \emph{Gauss消去法矩阵形式}:将消去前后过程用矩阵表示,可以有 121 | \[\mathbf{A}=\mathbf{A}^{(0)}=\begin{pmatrix}\ast&\ast&\ast&\ast\\\ast&\ast&\ast&\ast\\\ast&\ast&\ast&\ast\\\ast&\ast&\ast&\ast\end{pmatrix}\sothat\mathbf{A}^{(1)}=\begin{pmatrix}\ast&\ast&\ast&\ast\\&\ast&\ast&\ast\\&\ast&\ast&\ast\\&\ast&\ast&\ast\end{pmatrix}\] 122 | 则存在唯一的单位下三角阵 123 | \footnote{即线性代数中用于表征初等行变换的\emph{初等矩阵}。} 124 | $\mathbf{L}_1$ 使 $\mathbf{A}^{(1)}=\mathbf{L}_1\mathbf{A}^{(0)}$,其中$\mathbf{L}_1=\begin{spmatrix}1&0&\cdots&0\\-l_{21}&1&\cdots&0\\\vdots&\vdots&\ddots&\vdots\\-l_{n1}&0&\cdots&1\end{spmatrix}$。按此方式依次变换得一系列 $\mathbf{L}_i$: 125 | \[\mathbf{A}^{(n)}=\mathbf{L}_n\mathbf{A}^{(n-1)}=\cdots=\mathbf{L}_n\mathbf{L}_{n-1}\cdots\mathbf{L}_2\mathbf{L}_1\mathbf{A}^{(0)}\] 126 | 反推得到 127 | \[\mathbf{A}=\mathbf{L}_1^{-1}\mathbf{L}_2^{-1}\cdots\mathbf{L}_{n-1}^{-1}\mathbf{A}^{(n-1)}\] 128 | 记 $\mathbf{U}=\mathbf{A}^{(n-1)}=\begin{spmatrix}\mu_{11}&\mu_{12}&\cdots&\mu_{1n}\\0&\mu_{22}&\cdots&\mu_{2n}\\\vdots&\vdots&\ddots&\vdots\\0&0&\cdots&\mu_{nn}\end{spmatrix}$ 为一上三角阵,则$\mathbf{A}=\mathbf{L}_1^{-1}\mathbf{L}_2^{-1}\cdots\mathbf{L}_{n-1}^{-1}\mathbf{U}=\mathbf{LU}$。 129 | 130 | \trm 设$\mathbf{A}$为$n$阶矩阵,$D_k\neq0$,则$\mathbf{A}$可唯一分解为一单位下三角阵$\mathbf{L}$与一上三角阵$\mathbf{U}$之积 131 | \begin{equation}\label{2-e1} 132 | \mathbf{A}=\mathbf{LU} 133 | \end{equation} 134 | 称为\textbf{LU分解}(Doolittle分解)。 135 | 136 | % 此处缺少 L 与 U 的元素表示。 137 | 138 | \entry LU分解的算法实现:设 $\mathbf{L}=\begin{spmatrix}1&0&\cdots&0\\-l_{21}&1&\cdots&0\\\vdots&\vdots&\ddots&\vdots\\-l_{n1}&0&\cdots&1\end{spmatrix}$,$\mathbf{U}=\mathbf{A}^{(n-1)}=\begin{spmatrix}\mu_{11}&\mu_{12}&\cdots&\mu_{1n}\\0&\mu_{22}&\cdots&\mu_{2n}\\\vdots&\vdots&\ddots&\vdots\\0&0&\cdots&\mu_{nn}\end{spmatrix}$,根据式(\ref{2-e1})可知:$\mathbf{A}$中的元素$a_{ij}$满足 139 | \begin{align*} 140 | a_{ij}&=(l_{i1}\ l_{i2}\ \cdots\ l_{i,i-1}\ 1\ 0\ \cdots\ 0)\cdot(\mu_{1j}\ \mu_{2j}\ \cdots\ \mu_{jj}\ 0\ \cdots\ 0)^{\mathrm{T}}\\ 141 | &=\begin{cases}\sum\limits_{k=1}^{i-1}l_{ik}\mu_{kj}+\mu_{ij}&,j\geq i,\ i=1,2,\cdots,n\\\sum\limits_{k=1}^jl_{ik}\mu_{kj}&,jn$,方程一般无解; 35 | \item $m] (-0.2,0) -- (4.5,0) node[right] {$x$}; 248 | \draw[->] (0,-0.2) -- (0,2.5) node[above] {$y$}; 249 | \draw plot[mark=ball,ball color=black] coordinates {(0.5,1) (1,2) (2,1) (3,0.5) (4,0.3)}; 250 | \end{tikzpicture} 251 | \caption{分段线性插值图示}\label{4-f3} 252 | \end{figure} 253 | 254 | \entry 分段线性插值的\emph{缺陷}:在各个节点处导数不连续。 255 | 256 | \entry \key{分段二次插值}:在$[x_{i-1},x_{i+1}]$上作 Newton 二次插值多项式$N_{2i}(x)$,则 257 | \begin{equation} 258 | f(x)\approx N_{2i}(x)=y_{i-1}+f[x_{i-1},x_i](x-x_{i-1})+f[x_{i-1},x_i,x_{i+1}] 259 | (x-x_{i-1})(x-x_i). 260 | \end{equation} 261 | 262 | \entry 分段二次插值的误差估计: 263 | \begin{equation} 264 | R_{2i}(x)=\frac{f'''(\xi)}{3!}(x-x_{i-1})(x-x_i)(x-x_{i+1})\leq\frac{M_3}6\cdot 265 | \frac14\Delta^2\cdot2\Delta=\frac1{12}M_3\Delta^3 266 | \end{equation} 267 | 其中$M_3$为$f'''(x)$在插值区间上的最大值,$\Delta$为各相邻插值节点的最大距离。 268 | 269 | \entry 分段二次插值的缺陷:在一半的节点上导数仍不连续;要求有奇数个插值节点。 270 | 271 | \begin{figure}[htbp] 272 | \small\centering 273 | \begin{tikzpicture} 274 | \draw[->] (-0.2,0) -- (4.5,0) node[right] {$x$}; 275 | \draw[->] (0,-0.2) -- (0,2.5) node[above] {$y$}; 276 | \draw (0.5,1) parabola bend (1.25,2.125) (2,1); 277 | \draw (2,1) parabola[bend at end] (4,0.3); 278 | \draw[white] plot[mark=ball,ball color=black] coordinates {(0.5,1) (1,2) (2,1) (3,0.5) (4,0.3)}; 279 | \end{tikzpicture} 280 | \caption{分段二次插值图示}\label{4-f4} 281 | \end{figure} 282 | 283 | \entry \key{分段三次 Hermite 插值}:在相邻插值节点处利用两个函数值、两个导数值构造插值多项式。 284 | 285 | \entry 分段三次 Hermite 插值的误差估计: 286 | \begin{equation} 287 | R_{3,i}(x)=\frac{f^{(4)}(\xi)}{4!}(x-x_{i-1})^2(x-x_i)^2\leq\frac{M_4}{24} 288 | \left[\frac14(x-x_{i-1})^2\right]^2\leq\frac{M_4}{384}\Delta^4. 289 | \end{equation} 290 | 291 | \entry 分段三次 Hermite 插值的缺陷:二阶导数仍不连续;导数条件太苛刻,插值时一般缺少相应导数。 292 | 293 | \entry \key{三次样条插值}:给定$n+1$个数据点,要求分段插值曲线的二阶导数连续。 294 | 由此可知,插值函数及其导数也应连续。此时: 295 | \begin{itemize}\tl 296 | \item \emph{需求}:在$n$个插值子区间上构造\emph{分段三次插值函数},共计$4n$个未知数; 297 | \item \emph{约束条件}:$n+1$个数据点,$3(n-1)$个各阶导数连续条件,共计$4n-2$个方程; 298 | \item 补充 2 个\emph{边界条件}:一阶导数边界条件$f'(a)$、$f'(b)$,或二阶导数边界条件 299 | $f'(a)$、$f'(b)$,或周期性边界条件$f'(a)=f'(b)$、$f''(a)=f''(b)$。 300 | \end{itemize} 301 | 由此即可求解出所有的分段三次插值函数,称这些函数为\key{三次样条函数}。 302 | 303 | \entry \key{三弯矩方程}:设 $S(x)$ 在 $x_i$ 处二阶导数值为 $M_i$,根据插值函数为三次可知 $S''(x)$ 为连续的分段线性函数,对 $S''(x)$ 积两次分并用 $n$ 个数据点条件消去未知参数得: 304 | \begin{equation}\label{4-e7}\begin{aligned} 305 | S(x)=&\frac{(x_i-x)^3}{6h_i}M_{i-1}+\frac{(x-x_{i-1})^3}{6h_i}M_i+\left(y_{i-1}-\frac{h_i^2}6M_{i-1}\right)\frac{x_i-x}{h_i}\\ 306 | &+\left(y_i-\frac{h_i^2}6M_i\right)\frac{x-x_{i-1}}{h_i},\ x_{i-1}\leq x\leq x_i 307 | \end{aligned}\end{equation} 308 | 为求出 $M_i$,可对 $S(x)$ 在不同区间上的表达式求导,并应用 $(n-1)$ 个一阶导数连续条件获得 $(n-1)$ 个方程: 309 | \begin{equation}\label{4-e6} 310 | \mu_iM_{i-1}+2M_i+\lambda M_{i+1}=d_i,\quad i=1,2,\cdots,n-1 311 | \end{equation} 312 | 其中 313 | \[ 314 | \mu_i=\frac{h_i}{h_i+h_{i+1}}.,\quad\lambda_i=\frac{h_{i+1}}{h_i+h_{i+1}}=1-\mu_i,\quad d_i=6f[x_{i-1},x_i,x_{i+1}] 315 | \] 316 | 若将 $S(x)$ 视为一根梁的挠度,则以上的 $M_i$ 可视为作用在 $x_i$ 处的弯矩,故称方程 \eqref{4-e6} 为\emph{三弯矩方程}。 317 | 318 | \entry 三种边界条件下的三弯矩方程:三弯矩方程不足以解出 $n+1$ 个未知量,补充两个边界条件后方程即可封闭。 319 | \begin{itemize} 320 | \item \emph{一阶导数边条}:对式 \eqref{4-e7} 求一次导,并代入边界导数 $f'(a)$ 与 $f'(b)$,可最终获得两个补充方程: 321 | \begin{equation} 322 | 2M_0+M_1=d_0,\quad M_{n-1}+2M_n=d_n 323 | \end{equation} 324 | 其中 $d_0$ 与 $d_n$ 与其他 $d_i$ 的定义一致。方程组变为 $n+1$ 个式子的 325 | \begin{equation} 326 | \begin{cases} 327 | 2M_0+M_1=d_0\\ 328 | \mu_iM_{i-1}+2M_i+\lambda_iM_{i+1}=d_i,\quad i=1,2,\ldots,n-1\\ 329 | M_{n-1}+2M_n=d_n 330 | \end{cases} 331 | \end{equation} 332 | 此时的系数矩阵是\emph{严格三对角占优矩阵}($\mu_i+\lambda_i=1<2$),可用\emph{追赶法}快速求解。 333 | \item \emph{二阶导数边条}:$M_0=f''(a)$ 和 $M_n=f''(b)$ 给定,方程组变为 $n-1$ 个式子的 334 | \begin{equation} 335 | \begin{cases} 336 | 2M_1+\lambda_1M_2=d_1-\mu_1M_0\\ 337 | \mu_iM_{i-1}+2M_i+\lambda_iM_{i+1}=d_i,\quad i=2,3,\ldots,n-2\\ 338 | \mu_{n-1}M_{n-2}+2M_{n-1}=d_{n-1}-\lambda_{n-1}M_n 339 | \end{cases} 340 | \end{equation} 341 | 此时系数矩阵也是\emph{严格三对角占优矩阵}。 342 | \item \emph{周期性边条}:根据周期性 343 | \footnote{此时 $M_0=M_n$,同时少去一个未知数和一个方程,仍需补充两个方程。} 344 | ,从边界点处「回环」得满足三弯矩方程的序列 $(M_{n-1},M_n,M_1)$ 与 $(M_n,M_1,M_2)$,由此补充两个方程,方程组变为 $n$ 个式子的: 345 | \begin{equation} 346 | \begin{cases} 347 | 2M_1+\lambda_1M_2+\mu_1M_n=d_1\\ 348 | \mu_iM_{i-1}+2M_i+\lambda_iM_{i+1}=d_i,\quad i=2,3,\ldots,n-1\\ 349 | \lambda_nM_1+\mu_nM_{n-1}+2M_n=d_n 350 | \end{cases} 351 | \end{equation} 352 | 此时的系数矩阵为\emph{严格对角占优矩阵}(不是三对角),可用一般的 LU 分解求解 353 | \footnote{在 LU 分解的过程中,会发现此形式的系数矩阵有与追赶法类似的简化算法,参见李乃成、梅立泉《数值分析》习题 2.4。} 354 | 。 355 | \end{itemize} 356 | 357 | \entry 三次样条插值的\emph{特点}: 358 | \begin{itemize} 359 | \item [$\sqrt{}$] 求解的三弯矩方程为严格对角占优矩阵,方程形式简洁且容易求解,解存在唯一、稳定性好; 360 | \item [$\sqrt{}$] 为提高精度,只需增加插值节点,不需要提高次数; 361 | \item [$\sqrt{}$] 随节点增多,$S(x)$ 及其一二阶导数一致收敛于 $f(x)$ 及其对应导数;若节点间等距,则 $S'''(x)$ 随节点加密而一致收敛于 $f'''(x)$。 362 | \item [$\times$] 三弯矩方程计算量仍很大; 363 | \item [$\times$] 需要额外的边界条件,有时难以获得; 364 | \item [$\times$] 对图形的控制不够灵活,绘图上使用并不方便 365 | \footnote{绘图上常用 B\'ezier 曲线、B 样条曲线等专用于拟合几何边界的插值/曲线构造方式。} 366 | 。 367 | \end{itemize} -------------------------------------------------------------------------------- /chapters/chp-5.tex: -------------------------------------------------------------------------------- 1 | \chapter{函数最优逼近} 2 | \entry \emph{逼近}与\emph{插值}的区别:插值要求通过数据点,逼近则不要求;逼近追求\emph{在给定的函数形式下}整个区间或所有值点 3 | 上的\emph{总体误差}最小。 4 | 5 | \entry 用\emph{多项式}逼近:便于计算;便于用其做微积分。 6 | 7 | \section{内积、范数与正交多项式} 8 | \define \setkey{函数在点集上的内积}{函数内积(点集)}:设$f(x)$,$g(x)$在$X=\{x_1,x_2, 9 | \ldots,x_m\}$上有定义,并有相应的$m$个\emph{权系数}$\omega_i$,则定义 10 | \[(f,g)=\sum_{i=1}^m\omega_if(x_i)g(x_i)\] 11 | 为$f$与$g$在$X$上关于权系数$\omega_i$的\emph{内积}。 12 | 13 | \define \setkey{函数在区间上的内积}{函数内积(区间)}:设$f,g\in C[a,b]$,$\omega(x) 14 | \in C[a,b]$为权系数,定义 15 | \[(f,g)=\int_a^b\omega(x)f(x)g(x)\di x\] 16 | 为$f$与$g$在$[a,b]$上关于$\omega(x)$的内积。 17 | 18 | \entry 对权系数的要求:$\omega_i>0$或$\omega(x)\geq0$。常取$\omega_i=1$及 19 | $\omega(x)\equiv1$。 20 | 21 | \trm 内积的性质 22 | \footnote{该四条性质对一切「内积空间」都是成立的。} 23 | : 24 | \begin{enumerate}\tl 25 | \item 对称性:$(f,g)=(g,f)$。 26 | \item 齐性:对任意的常数$\alpha$,$(\alpha f,g)=(f,\alpha g)=\alpha\cdot(f,g)$。 27 | \item 可加性:$(f+h,g)=(f,g)+(h,g)$。 28 | \item 正定性:$(f,f)\geq0$,且仅当$f\equiv0$时$(f,f)=0$。 29 | \end{enumerate} 30 | 31 | \define \setkey{函数在点集或区间上的范数}{函数范数}:对点集$X$上所有函数$f$,或对区间上 32 | 所有连续函数$f\in C[a,b]$定义运算$\|f\|$,满足: 33 | \begin{enumerate}\tl 34 | \item (正定性)$\|f\|\geq0$,且仅当$f\equiv0$时$\|f\|=0$。 35 | \item (线性)对任意的常数$\alpha$,$\|\alpha f\|=|\alpha|\cdot\|f\|$。 36 | \item (三角不等式)$\|f+g\|\leq\|f\|+\|g\|$。 37 | \end{enumerate} 38 | 39 | \entry 常用范数: 40 | \begin{itemize}\tl 41 | \item 由函数内积导出的$2$-范数:$\|f(x)\|_2=\sqrt{(f,f)}$。 42 | \item $1$-范数:$\|f\|_1=\sum\limits_{i=1}^m|f(x_i)|$或$\|f\|_1=\int_a^b|f(x)|\di x$。 43 | \item $\infty$-范数:$\|f\|_\infty=\max\limits_{1\leq i\leq m}|f(x_i)|$或 44 | $\|f\|_\infty=\max\limits_{a\leq x\leq b}|f(x)|$。 45 | \end{itemize} 46 | 47 | \entry 函数的\key{正交}: 48 | \begin{itemize}\tl 49 | \item 在权函数$\omega_i$(或$\omega(x)$)下,若$(f,g)=0$,则称两函数关于权函数 50 | $\omega_i$(或$\omega(x)$)正交,称$f$与$g$为\key{正交函数}。 51 | \item 设有函数族$\{g_k\}$,若其中各函数$g_0(x),g_1(x),\cdots,g_k(x),\cdots$满足 52 | $(g_i,g_j)=0\,(i\neq j)$,则称$\{g_k\}$为关于$\omega$\setkey{正交}{正交函数族}的函数族。 53 | \item 若正交函数族$\{g_k\}$进一步满足$\|g_i(x)\|=1\,(\forall i)$,则称其为一个 54 | \key{标准正交函数族}。 55 | \item 若正交函数族$\{g_k\}$中的$g_k(x)$为$k$次多项式,则称$g_0(x),\cdots,g_k(x), 56 | \cdots$为\key{正交多项式}。 57 | \end{itemize} 58 | 59 | \trm \emph{正交多项式基本性质}:各正交多项式之间线性无关 60 | \footnote{证明:利用正交性与正定性。} 61 | 。(由此,可用一族正交多项式线性表示各阶多项式。) 62 | 63 | \trm 推论 1:对$k] (-0.2,0) -- (1.2,0) node [right] {$x$}; 263 | \draw [->] (0,-0.2) -- (0,1.2) node [above] {$y$}; 264 | \draw [rotate=90] (0,0) parabola (1.2,-1.44) node [right] {$f(x)=\sqrt x$}; 265 | \draw (-1/3,0) -- (1.2,1.227) node [above] {$p(x)=\frac45x+\frac4{15}$}; 266 | \node at (0,0) [below left] {$O$}; 267 | \draw [dashed] (1,0) node [below] {$1$} -- (1,16/15); 268 | \end{tikzpicture} 269 | \caption{$y=\sqrt x$ 的最优逼近一次多项式示意图} 270 | \end{figure} -------------------------------------------------------------------------------- /chapters/chp-6.tex: -------------------------------------------------------------------------------- 1 | \chapter{数值积分与数值微分} 2 | 3 | \entry 常规(解析)积分的\emph{局限性}:往往难以求得原函数,无法应用 Newton-Leibniz 公式;有时 4 | 仅知函数在个别离散点的取值(列表函数)。 5 | 6 | \entry \emph{数值积分}/\emph{数值微分}的共同思路:用个别点处\emph{函数值 $f(x_i)$ 的线性组合},来估计整个区 7 | 间上的积分值或个别点附近的微分值。 8 | \begin{gather} 9 | \int_a^bf(x)\di x=\sum_{i=0}^nA_if(x_i)\\ 10 | f'(x)=\sum_{i=0}^nB_if(x_i) 11 | \end{gather} 12 | 13 | \entry 主要问题:节点$x_i$的选取;求积系数$A_k$的计算;误差估计与评价。 14 | 15 | \entry 记号:对于$f(x)$,记其准确积分值为 $I[f]=\int_a^bf(x)\di x$,而记其数值估计公式为 16 | \[Q[f]=\sum_{i=0}^nA_if(x_i)\approx I[f].\] 17 | 并将数值积分公式的误差记为$R[f]=I[f]-Q[f]$. 18 | 19 | \section{插值型积分及其延伸} 20 | \entry\label{6-et1} 两种近似积分思路: 21 | \begin{enumerate} 22 | \item 按 Riemann 积分定义,作区间的划分,按若干小矩形估算: 23 | \[\int_a^bf(x)\di x\approx\sum_{i=o}^nf(x_i)(x_{i+1}-x_i)\] 24 | \item 取若干数据点插值,用插值多项式$p(x)$的积分估计函数的积分: 25 | \[\begin{aligned} 26 | \int_a^bf(x)\di x&\approx\int_a^bp(x)\di x 27 | =\int_a^b\left[\sum_{i=0}^nl_i(x)f(x_i)\right]\di x\\ 28 | &=\sum_{i=0}^n\left(\int_a^bl_i(x)\di x\right)\cdot f(x_i). 29 | \end{aligned}\] 30 | \end{enumerate} 31 | 共同特点是:用若干点上函数值$f(x_i)$之\emph{线性组合}估计整个区间上的积分值。问题:无法估计 32 | 误差。应当从此种思路出发,直接构造估计公式,进而就可估计误差。 33 | 34 | \entry \key{Newton-Cotes 型求积公式}:在区间上等距取定若干\emph{插值点},构造\emph{插值多项式}并以其积分代替$f(x)$的积分。 35 | 36 | \entry 记号:设节点数为$n+1$个:$x_0,x_1,\cdots,x_n$(一般常取$n=1,2,4$),记此时各点的距离为$h=\frac{b-a}n$。 37 | 38 | \entry \key{梯形公式}:当$n=1$时,取定区间的左右两端点为$x_0$与$x_1$,可得到 39 | \begin{equation} 40 | Q_1[f]=\frac{b-a}2\left[f(a)+f(b)\right]. 41 | \end{equation} 42 | 此即\emph{梯形求积公式},常将$Q_1[f]$记为$T_1$。由第一积分中值定理 43 | \footnote{设$f,g\in C[a,b]$且$g$在$[a,b]$不变号,则存在$\eta\in[a,b]$使 44 | $\int_a^bf(x)g(x)\di x=f(\eta)\int_a^bg(x)\di x$。} 45 | 可估计误差为 46 | \begin{equation} 47 | R_1[f]=\frac{(b-a)^3}{12}f''(\eta),\,\eta\in(a,b) 48 | \end{equation} 49 | 50 | \entry \key{Simpson 公式}:当$n=2$时,$h=\frac{b-a}2$,将取得以下等距节点: 51 | \[x_0=a,\,x_1=\frac{a+b}2,\,x_2=b.\] 52 | 作插值多项式并积分,可得求积公式为 53 | \begin{equation} 54 | Q_2[f]=\frac h3\left[f(a)+4f\left(\frac{a+b}2\right)+f(b).\right] 55 | \end{equation} 56 | 此即 \emph{Simpson 公式},常将$Q_2[f]$简记为$S_1$。利用之后的方法 57 | \footnote{即广义 Peano 定理与「24K金法」。} 58 | 可估计误差为 59 | \begin{equation} 60 | R_2[f]=-\frac{(b-a)^5}{2880}f^{(4)}(\eta). 61 | \end{equation} 62 | 63 | \entry \key{Cotes 求积公式}:当$n=4$时,$h=\frac{b-a}4$,插值并积分可得 64 | \begin{equation} 65 | Q_4[f]=\frac{b-a}{90}[7f(a)+32f(a+h)+12f(a+2h)+32f(a+3h)+7f(b).] 66 | \end{equation} 67 | 此即 \emph{Cotes 求积公式},常将$Q_4[f]$简记为$C_1$。利用之后的方法可估计误差为 68 | \begin{equation} 69 | R_4[f]=-\frac{(b-a)^7}{1935360}f^{(6)}(\eta). 70 | \end{equation} 71 | 72 | \entry \key{代数精度}:设有数值积分公式,且对于不超过$m$次的多项式$f$均 73 | 有$R[f]=0$成立,而对某$m+1$次多项式$f$即有$R[f]\neq0$,则称该数值积分公式的代数精度为$m$。 74 | 75 | \entry 对\emph{梯形公式},其代数精度为 $1$;对 \emph{Simpson 公式},其代数精度为 $2$;对 \emph{Cotes 公式}, 76 | 其代数精度为 $4$。 77 | 78 | \entry 不宜采用次数过高的多项式插值:\emph{Runge 现象} 79 | \footnote{且根据后面的内容可知,次数过高的 Newton-Cotes 公式稳定性差,结果易发散}。 80 | 81 | \entry \key{复化求积公式}:对每个小区间 $[x_{k-1},x_k]$ 分别运用积分公式,再将结果求和。 82 | 83 | \entry 公式表述:对由 $n+1$ 个数据点所划分的 $n$ 个小区间,对以上三种插值型积分公式的 84 | 结果如下。 85 | \begin{itemize} 86 | \item 取 $n=1$,得\key{复化梯形公式}: 87 | \begin{equation} 88 | T_n=\frac h2\left[f(a)+2\dsum_{i=1}^{n-1}f(x_i)+f(b)\right], 89 | \end{equation} 90 | 其误差估计为 $R_{T_n}=-\frac{b-a}{12}h^2f''(\eta)$。 91 | \item 取 $n=2$,得\key{复化 Simpson 公式}: 92 | \begin{equation} 93 | S_n=\frac h2\left[f(a)+2\dsum_{i=1}^{n-1}f(x_i)+f(b)\right], 94 | \end{equation} 95 | 其误差估计为 $R_{S_n}=-\frac{b-a}{2880}h^4f^{(4)}(\eta)$。 96 | \item 取 $n=4$,得\key{复化 Cotes 公式}: 97 | \begin{equation}\begin{aligned} 98 | C_n=&\frac h{90}\left\{7f(a)+32\dsum_{i=0}^{n-1}\left[ 99 | f\left(x_i+\frac h4\right)+f\left(x_i+\frac{3h}4\right)\right]+\right.\\ 100 | &\left.12\dsum_{i=0}^{n-1}f\left(x_i+\frac h2\right)+14\dsum_{i=1}^{n-1}f(x_i) 101 | +7f(b)\right\}. 102 | \end{aligned}\end{equation} 103 | 其误差估计为 $R_{c_n}=-\frac{b-a}{1935360}h^6f^{(6)}(\eta)$。 104 | \end{itemize} 105 | 106 | \entry \key{变步长积分法}:为进一步减小误差,考虑在用复化求积公式时不断缩小步长。为此,先凑出一个近似的误差估计式(减小步长的依据)。设用复化梯形公式 $T_n$ 求积分,当取得 $n+1$ 个点时的误差估计式为 107 | \begin{equation} 108 | R_n[f]=I[f]-T_n=-\frac{b-a}{12}h^2f''(\eta_1) 109 | \end{equation} 110 | 将子区间数量翻倍,则取得 $2n+1$ 个点时的误差估计式为 111 | \begin{equation} 112 | R_{2n}[f]=I[f]-T_{2n}=-\frac{b-a}{12}\left(\frac h2\right)^2f''(\eta_2) 113 | \end{equation} 114 | 若估计$f''(\eta_1)\approx f''(\eta_2)$,则联立两式即可得到 115 | \begin{equation}\label{6-e1} 116 | R_{2n}[f]=I[f]-T_{2n}\approx\frac13(T_{2n}-T_n) 117 | \end{equation} 118 | 即积分误差可以用变步长结果间的差距 $T_{2n}-T_n$ 所估计。因此,若希望实现 $R[f]<\vepsilon$,可按如下步骤实施变步长复化积分: 119 | \begin{enumerate}\tl 120 | \item $n=1$,$h=b-a$,计算$T_n$; 121 | \item 缩小步长$h$至原来的一半,计算$T_{2n}$; 122 | \item 验证误差估计条件 $|T_{2n}-T_n|<\vepsilon$ 是否满足,若满足则停止,若不满足则重复上一步。 123 | \end{enumerate} 124 | 125 | \entry $T_{2n}$的迭代算法: 126 | \begin{equation} 127 | T_{2n}=\frac12T_n+\frac h2\sum_{k=1}^nf\left(\frac{x_{k-1}+x_k}2\right) 128 | \end{equation} 129 | 130 | \entry 变步长积分公式中,同样可采用复化 Simpson 公式或复化 Cotes 公式: 131 | \begin{gather} 132 | I-S_{2n}\approx\frac1{4^2-1}(S_{2n}-S_n),\\ 133 | I-C_{2n}\approx\frac1{4^3-1}(C_{2n}-C_n). 134 | \end{gather} 135 | 136 | \entry 启发:由误差估计式 (\ref{6-e1}) 可以猜想,以下的估计式同样成立: 137 | \[ I\approx T_{2n}+\frac1{4-1}(T_{2n}-T_n) \] 138 | 而将 $T_n$ 与 $T_{2n}$ 的表达式代入之后「竟然」发现 139 | \begin{equation} 140 | T_{2n}+\frac1{4-1}(T_{2n}-T_n)=S_n 141 | \end{equation} 142 | 由此说明,\emph{可用低精度公式组合出高精度公式} 143 | \footnote{本质上是由插值点的增加所致。} 144 | 。对复化 Simpson 公式实行类似操作可推得 145 | \begin{equation} 146 | S_{2n}+\frac1{4^2-1}(S_{2n}-S_n)=\frac{4^2S_{2n}-S_n}{4^2-1}=C_n 147 | \end{equation} 148 | 149 | 150 | \entry \key{Romberg 积分}:进一步考虑对 Cotes 公式的结果,将得到一个新的积分公式: 151 | \begin{equation} 152 | C_{2n}+\frac1{4^3-1}(C_{2n}-C_n)=\frac{4^3C_{2n}-C_n}{4^3-1}=R_n 153 | \end{equation} 154 | 称由上式表述的 $R_n$ 为 \key{Romberg 积分},其代数精度 $m=7$,误差估计式为 155 | \begin{equation} 156 | R[f]=K\cdot h^8f^{(8)}(\eta). 157 | \end{equation} 158 | 159 | \entry 一般不在 Romberg 积分的基础上进一步递推,因被积函数的高阶导数性态不易估计,仍可能出现 Runge 现象;且$R_{2n}-R_n$ 一项很小,舍入误差较大;计算量也过大。 160 | 161 | \entry Romberg 积分可由最基本的复化梯形公式逐阶递推而来,常用 \key{Romberg 计算图}辅助 162 | 计算。 163 | 164 | \begin{figure}[htbp] 165 | \small\renewcommand{\arraystretch}{0.7}\centering 166 | \begin{tabular}{ccccccc} 167 | \toprule 168 | $T$ && $S$ && $C$ && $R$ \\ 169 | \midrule 170 | $T_1$ && && && \\ 171 | & $\searrow$ & && && \\ 172 | $T_2$ & $\rightarrow$ & $S_1$ && &&\\ 173 | & $\searrow$ & & $\searrow$ & && \\ 174 | $T_3$ & $\rightarrow$ & $S_2$ & $\rightarrow$ & $C_1$ && \\ 175 | & $\searrow$ & & $\searrow$ & & $\searrow$ & \\ 176 | $T_4$ & $\rightarrow$ & $S_3$ & $\rightarrow$ & $C_2$ & $\rightarrow$ & $R_1$ \\ 177 | & $\searrow$ & & $\searrow$ & & $\searrow$ & \\ 178 | $T_5$ & $\rightarrow$ & $S_4$ & $\rightarrow$ & $C_3$ & $\rightarrow$ & $R_2$ \\ 179 | $\vdots$ && $\vdots$ && $\vdots$ && $\vdots$ \\ 180 | \bottomrule 181 | \end{tabular} 182 | \caption{Romberg 计算图}\label{6-f1} 183 | \end{figure} 184 | 185 | \section{待定系数法与 Gauss 型积分} 186 | \trm 积分公式 $Q[f]$ 之\emph{代数精度}为 $m$ 的充要条件是 187 | \[R[x^k]=0,\,(k=0,1,2,\cdots,m),\,R[x^{m+1}]\neq0.\] 188 | 可利用此结果,在积分公式中分别代入$f(x)=x^k$,验算积分公式的代数精度。 189 | 190 | \entry \key{待定系数法}:根据数值积分公式的一般形式 $Q[f]=\dsum_{i=0}^kA_if(x_i)$, 191 | 在给定条件下(如达到指定的代数精度、给定已知节点),代入若干不同的 $f(x)$,求解出公式中未知的节点$x_i$与系数$A_i$。 192 | 193 | \example 待定系数法导出梯形公式:设 $Q[f]=A_1f(a)+A_2f(b)$,希望其代数精度为 $m=1$,则有 194 | \begin{itemize} 195 | \item 令 $f(x)=1$,由 $I[f]=Q[f]$ 有 $A_1-A_2=b-a$; 196 | \item 令 $f(x)=x$,由 $I[f]=Q[f]$ 有 $A_1\cdot a + A_2\cdot b=\frac12(b^2-a^2)$。 197 | \end{itemize} 198 | 解得 $A_1=A_2=\frac{b-a}2$。故积分公式为 199 | \[Q[f]=\frac{b-a}2[f(a)+f(b)],\] 200 | 此即梯形公式。 201 | 202 | \entry \key{广义 Peano 定理}:设 $Q[f]$ 的截断误差 $R[f]$是区间上 $m+1$ 阶导数连续的函数 203 | 之线性泛函\footnote{线性泛函满足:$R[c_1f_1+c_2f_2]=c_1R[f_1]+c_2R[f_2]$。},且其代数精度为 $m$,则有 $R[f(x)]=R[e(x)]$,其中 204 | \begin{equation}\label{6-e2} 205 | e(x)=\frac{f^{(m+1)}(\xi)}{(m+1)!}(x-\tilde{x}_0)(x-\tilde{x}_1)\cdots 206 | (x-\tilde{x}_m) 207 | \end{equation} 208 | $\tilde{x}_0,\tilde{x}_1,\cdots,\tilde{x}_m$ 为 $[a,b]$ 上任意一点,$\xi\in[a,b]$ 209 | 与这 $m+1$ 个点的选取有关。 210 | 211 | \entry 通过合适的\emph{取点},可由广义 Peano 定理求得各积分公式的误差估计。一般要求: 212 | \begin{itemize}\tl 213 | \item $e(x)$表达式中的 $(x-\tilde{x}_0)(x-\tilde{x}_1)\cdots(x-\tilde{x}_m)$ 项在 $[a,b]$ 不变号; 214 | \item 选取 $\tilde{x}_0,\tilde{x}_1,\cdots,\tilde{x}_m$ 最好使 $Q[e]$ 为 $0$,从而 $R[f]=I[e]$ 可直接算出 215 | \footnote{若 $Q[f]$ 的形式对称,则可以通过取若干对称的点实现这一点,参见下面的例子(\arabic{chapter}.\ref{6-ex1})。} 216 | 。 217 | \end{itemize} 218 | 219 | \example\label{6-ex1} 用广义 Peano 定理估计 Simpson 公式 220 | \[ \int_{-1}^1f(x)\di x\approx Q[f]=\frac13[f(-1)+4f(0)+f(1)] \] 221 | 的误差,可考虑取 $-1,0,0,1$ 四点(其中 $0$ 为\emph{重节点}),代入 (\ref{6-e2}) 式即得 222 | \[ e(x)=\frac{f^{(4)}(\xi)}{4!}(x+1)x^2(x-1) \] 223 | 可以算得 $Q[e]=0$,故直接有 224 | \[\begin{aligned} 225 | R[f]&=I[e]=\int_{-1}^1\frac{f^{(4)}(\xi)}{4!}(x+1)(x-1)x^2\di x\\ 226 | &=\frac1{90}f^{(4)}(\eta)\,(\eta\in[a,b]) 227 | \end{aligned}\] 228 | 其中,在 $(x+1)(x-1)x^2$ 不变号的前提下应用了第一积分中值定理。 229 | 230 | \entry \setkey{简化解法}{24K金法}:设数值积分公式 $Q[f]$ 的代数精度为 $m$,据广义 Peano 定理知其误差项 231 | 一定为 $Kf^{(m+1)}(\eta)$ 的形式;代入 $f(x)=x^{m+1}$ 即有 232 | \[ K\cdot m! = R[f] = I[f] - Q[f] \] 233 | 将 $I[f]$ 与 $Q[f]$ 算出,即可求得系数 $K$。 234 | (当 $m=4$ 时,方程左侧为 $24K$,故戏称此法为「24K金法」。) 235 | 236 | \example 用「24K金法」估计 Simpson 公式的误差。(答案与例 \arabic{chapter}.\ref{6-ex1} 相同。) 237 | 238 | \example 用「24K金法」估计积分公式 239 | \[ \int_{-1}^1f(x)\di x\approx Q[f]=\frac43f\left(-\frac12\right)-\frac23f(0)+ 240 | \frac43f\left(\frac12\right) \] 241 | 的误差。(答案:$R[f]=\frac7{720}f^{(4)}(\eta)$。) 242 | 243 | \entry 在一般的积分公式 $Q[f]=\dsum_{i=0}^nA_if(x_i)$ 中,全部的待定参数共 $2n+2$ 个, 244 | 可将它们全部通过待定系数法解出(而不必预先给定);因此,对由 $n+1$ 个节点确定的积分公式, 245 | 可以期望其\emph{最高具有 $m=2n+1$ 的代数精度},进而列出 $m+1=2n+2$ 个方程将待定参数解出。 246 | 247 | \entry 对代数精度为 $2n+1$ 的积分公式 $Q[f]=\dsum_{i=0}^nA_if(x_i)$, 248 | 可代入以下的 $2n+2$ 次多项式 249 | \[ p(x)=(x-x_0)^2(x-x_1)^2\cdots(x-x_n)^2 \] 250 | 则有 $Q[p(x)]=\dsum_{i=0}^nA_ip(x_i)=0$,而 $I[p(x)]$ 必然为正数,故可见 $Q[f]$ 的代数精度\emph{不可能}达到 $2n+2$,任何情况下的最高代数精度只能是 $2n+1$。 251 | 252 | \example 求解使积分公式 253 | \[ \int_{-1}^1f(x)\di x=Q[f]=A_0f(x_0)+A_1f(x_1) \] 254 | 代数精度尽可能高的 $A_0,A_1,x_0,x_1$,并估计误差。 255 | (答案:$Q[f]=f(-1/\sqrt3)+f(1/\sqrt3)$,$m=3$,$R[f]=\frac1{135}f^{(4)}(\eta)$.) 256 | 257 | \entry \key{Gauss 求积公式}:具有 $n+1$ 个节点,代数精度达到 $2n+1$ 的数值积分公式。相应的节点称为 \key{Gauss 点}。 258 | 259 | \trm 求积公式 $Q[f]=\dsum_{i=0}^nA_if(x_i)$ 是 Gauss 求积公式的\setkey{充要条件}{Gauss 求积公式充要条件}为: 260 | \begin{itemize}\tl 261 | \item $x_i$ 为 $[a,b]$ 上关于权系数 $\omega(x)$ 正交的多项式 $g_{n+1}(x)$ 之零点; 262 | \item 求积系数 $A_i$ 按下式确定: 263 | \begin{equation}\label{6-e5} 264 | A_i=\int_a^b\omega(x)l_i(x)\di x 265 | \end{equation} 266 | \end{itemize} 267 | 268 | \trm 引理:设$\{g_k(x)\}$ 为 $[a,b]$ 上关于 $\omega(x)$ 正交的\emph{首一正交多项式},则有 269 | \begin{equation} 270 | \frac{g_{k+1}(x)}{x-x_i}=\frac{\gamma_n}{g_n(x_i)}\sum_{k=0}^n\frac{g_k(x) 271 | g_n(x_i)}{\gamma_k} 272 | \end{equation} 273 | 其中 $x_i\ (i=0,1,\ldots,n)$ 为 $g_{n+1}$ 的零点,$\gamma_k=(g_k,g_k)$ 与正交多项式\emph{三项递推关系}(条目 5.\ref{5-t1})中的含义一致 274 | \footnote{推导也须采用 5.\ref{5-t1} 中的三项递推关系:对其中 $g_{k+1}(x)$ 的表达式进行若干变换,再对 $k$ 求和就可得到此式。} 275 | 。 276 | 277 | \trm \key{Gauss 求积公式系数公式}:给定一组首一正交多项式$\{g_k(x)\}$,则 Gauss 求积公式 $Q[f]=\dsum_{i=0}^nA_if(x_i)$ 中的系数 $A_i$ 可按 278 | \begin{equation}\label{6-e3} 279 | A_i=\frac{\gamma_n}{g'_{n+1}(x_i)g_n(x_i)}\quad(i=0,1,\ldots,n) 280 | \end{equation} 281 | 计算 282 | \footnote{证明思路:根据 $x_i$ 为 $g_{n+1}(x)$ 的条件,将式 \eqref{6-e5} 中的 Langrange 插值基函数变换为 $l_i(x)=\frac{g_{n+1}(x)}{(x-x_i)g'_{n+1}(x_i)}$ 即可。} 283 | 。 284 | 285 | \trm \key{Gauss 求积公式截断误差}:若 $f\in C^{2n+2}[a,b]$,且 $g_{n+1}(x)$ 为一个首一多项式,则有 286 | \begin{equation}\label{6-e4} 287 | R[f]=\frac{\gamma_{n+1}}{(2n+2)!}f^{(2n+2)}(\eta). 288 | \end{equation} 289 | 290 | \trm Gauss 型求积公式的系数全大于 $0$。 291 | \footnote{证明:对 $f(x)=l_k^2(x)$ 应用 Gauss 求积公式。与之相反,Newton-Cotes 公式的系数无法满足此种条件。} 292 | 293 | \entry Gauss 型求积公式的\emph{求解过程}: 294 | \begin{enumerate}\tl 295 | \item 按三项递推关系 (\ref{5-e1}) 求出在 $[a,b]$ 上关于 $\omega(x)$ 正交的 296 | 多项式 $g_{n+1}(x)$; 297 | \item 求出 $g_{n+1}(x)$ 的 $n+1$ 个根 $x_0,x_1,\cdots,x_n$。 298 | \item 按式 (\ref{6-e3}) 求解积分公式中的系数。 299 | \item 按 (\ref{6-e4}) 式的结果求解误差。 300 | \end{enumerate} 301 | 302 | \entry Gauss 求积公式的\emph{稳定性}:设计算函数值 $f(x_i)$ 时的舍入误差可表示为 303 | \[ |f(x_i)-\tilde{f}(x_i)|\leq\vepsilon \] 304 | 其中 $\vepsilon$ 为各子区间上\emph{最大}的舍入误差限,则总的舍入误差估计为 305 | \begin{equation} 306 | E=\left|\sum_{i=0}^nA_if(x_i)-\sum_{i=0}^nA_i\tilde{f}(x_i)\right|\leq\sum_{i=0}% 307 | ^n\bigl|A_i\bigr|\vepsilon. 308 | \end{equation} 309 | 对 Gauss 求积公式,所有的 $A_i$ 均为正,故有 310 | \[ \sum_{i=0}^n\bigl|A_i\bigr|=\sum_{i=0}^nA_i=\int_a^b\omega(x)\di x=\gamma_0 \] 311 | 从而说明 $E\leq\gamma_0\vepsilon$,舍入误差可控。这说明 \emph{Gauss 求积公式是稳定的}。 312 | 313 | \section{数值微分公式} 314 | \entry 最基本的算法:\emph{割线代切线} 315 | \[ f'(x_i)\approx\frac{f(x_{i+1})-f(x_i)}{x_{i+1}-x_i}=A_if(x_i)+A_{i+1}f(x_{i+1}) \] 316 | 可见数值微分公式与数值积分公式本质相同,均为个别点\emph{函数值的组合}。其缺陷与近似积分法(条目 \arabic{chapter}.\ref{6-et1})相同:\emph{误差无法估计}。为此,应直接从一般的公式入手,在给定条件下直接求解节点与系数,并估计误差。 317 | 318 | \entry \key{插值型数值微分公式}:用插值多项式 $L_n(x)$ 代替原有函数 $f(x)$ ,求其导数: 319 | \[ f(x)=L_n(x)+R_n(x)\,\Rightarrow\,f^{(k)}(x)=L_n^{(k)}(x)+R_n^{(k)}(x).\] 320 | 321 | \entry 插值型公式的\emph{误差估计}: 322 | \[ R_n^{(k)}(x)=\frac{\di^k}{\di x^k}\left[\frac{f^{(n+1)}(\xi)}{(n+1)!} 323 | \pi_{n+1}(x)\right]=\frac{\di^k}{\di x^k}\bigl(f[x_0,x_1,\cdots,x_n,x]\pi_{n+1}(x) 324 | \bigr) \] 325 | 326 | \trm 差商的导数有如下性质: 327 | \begin{equation} 328 | \frac{\di^k}{\di x^k}\bigl(f[x_0,x_1,\cdots,x_m,x]\bigr)=(k!)\cdot f[x_0,x_1,\cdots,x_m,x,x,\cdots,x]. 329 | \end{equation} 330 | 331 | \entry 两点数值微分公式($n=1,k=1$):对 $x_0,x_1,x$ 三点作 Newton 插值 332 | \footnote{也可用 Lagrange 插值法,并直接使用 Lagrange 插值法的误差估计式。} 333 | ,利用差商导数的性质对插值多项式 $f(x)$ 求导,可以求得 334 | \[ f'(x)=f[x_0,x_1] + f[x_0,x_1,x,x](x-x_0)(x-x_1)+ f[x_0,x_1,x](2x-x_0-x_1) \] 335 | 分别代入 $x_0$ 与 $x_1$ 可得两个数值微分公式: 336 | \begin{gather} 337 | f'(x_0)=\frac{f(x_1)-f(x_0)}{x_1-x_0}+\frac12f''(\xi_0)(x_0-x_1)\label{7-e3}\\ 338 | f'(x_1)=\frac{f(x_1)-f(x_0)}{x_1-x_0}+\frac12f''(\xi_1)(x_0-x_1)\label{7-e4} 339 | \end{gather} 340 | 可用记号 $h=x_1-x_0$ 简化写法。 341 | 342 | \entry 三点数值微分公式($n=2,k=1$):设三个等距(间距为 $h$)节点分别为 $x_0,x_1,x_2$,用 Newton 插值多项式可得到 343 | \begin{gather} 344 | f'(x_0)=\frac1{2h}[-3f(x_0)+4f(x_1)-f(x_1)]+\frac{h^2}3f'''(\xi_0)\\ 345 | f'(x_1)=\frac1{2h}[-f(x_0)+f(x_2)]-\frac{h^2}6f'''(\xi_1)\\ 346 | f'(x_2)=\frac1{2h}[f(x_0)-4f(x_1)+3f(x_2)]+\frac{h^2}3f'''(\xi_2). 347 | \end{gather} 348 | 349 | \entry 三点二阶数值微分公式($n=2,k=2$):在以上公式推导过程中再求一次导,分别代入三个 350 | 等距节点即得 351 | \begin{gather} 352 | f''(x_0)=\frac1{h^2}[f(x_0)-2f(x_1)+f(x_2)]-hf'''(\xi_1)+\frac{h^2}6f^{(4)}(\xi_2)\\ 353 | f''(x_1)=\frac1{h^2}[f(x_2)-2f(x_1)+f(x_2)]-\frac{h^2}{12}f^{(4)}(\xi) 354 | \label{7-e-mid}\\ 355 | f''(x_2)=\frac1{h^2}[f(x_0)-2f(x_1)+f(x_2)]+hf'''(\xi_1)+\frac{h^2}6f^{(4)}(\xi_2). 356 | \end{gather} 357 | 358 | \entry 一般,常用以下两个在区间中点$x_1$取得的数值微分公式: 359 | \begin{gather} 360 | f'(x)=\frac{f(x+h)-f(x-h)}{2h}-\frac{h^2}6f'''(\xi),\\ 361 | f''(x)=\frac{f(x+h)-2f(x)+f(x+h)}{h^2}-\frac{h^2}{12}f^{(4)}(\xi). 362 | \end{gather} 363 | 364 | \entry 数值微分的\setkey{待定系数法}{数值微分待定系数法}:类似于数值积分,用待定系数法追求更高的\emph{代数精度} 365 | \footnote{此处,代数精度的定义与插值函数、数值积分中的相同。} 366 | 。 367 | 368 | \example 给定 $x_0,x_1$,为求得下列形式的数值微分公式 369 | \[ f''(x_0)\approx c_0f(x_0)+c_1f'(x_0)+c_2f(x_1) \] 370 | 中系数 $c_0,c_1,c_2$ 的值,首先期望该公式具有 $m=2$ 的代数精度 371 | \footnote{此时刚好可列出三个方程解出三个系数。} 372 | ,进而可依次代入 373 | $f(x)=1$、$f(x)=x$、$f(x)=x^2$: 374 | \[\begin{cases}-c_0-c_2=0\\-c_1-c_2h=0\\2-c_2h^2=0\end{cases}\sothat 375 | \begin{cases}c_0=-\frac{2}{h^2}\\c_1=-\frac2h\\c_2=\frac2{h^2}\end{cases}\] 376 | 可将 $f(x)=x^3$ 代入最终的公式中,解得 $R[f]=-2h\neq0$,故该公式的代数精度止于 $2$。 377 | 此处可用广义 Peano 定理,取$x_0,x_0,x_1$ 三个节点构筑 $e(x)$,从而 378 | \[\begin{aligned} 379 | R[f]&=R[e(x)]=e''(x_0)-\left[-\frac2{h^2}e(x_0)+\frac2he'(x_0)-\frac2{h^2}e(x_1)\right]\\ 380 | &=e''(x_0)=-\frac h3f'''(\xi). 381 | \end{aligned}\] 382 | (当然,也可以用「24K金法」,将 $f(x)=x^3$ 直接代入 $I[f]=R[f]$ 之中, 383 | 求得系数 $K=-\frac h3$。) 384 | 385 | \entry \key{Richardson 外推法}:类似于 Romberg 积分法,用低精度公式递推出高精度公式。 386 | 387 | \entry \key{变步长微分法}:类于数值积分中的类似方法。 388 | 389 | \example 欲求得数值微分公式 390 | \[ f''(x)\approx Af(x-h)+Bf(x)+Cf(x+h) \] 391 | 中的系数 $A,B,C$,可利用 \emph{Taylor 公式}展开等式右侧的 $f(x-h)$ 与 $f(x-h)$: 392 | \[ f''(x)=(A+B+C)f(x)+(-A+C)hf'(x)+(A+C)\frac{h^2}2f''(x)+R(x) \] 393 | 其中 $R(x)$ 为余项。左右对应项相等,故有 394 | \[ 395 | \begin{cases}A+B+C=0\\-A+C=0\\A+C=\frac2{h^2}\end{cases}\sothat 396 | \begin{cases}A=-\frac1{h^2}\\B=-\frac2{h^2}\\C=\frac1{h^2}\end{cases} 397 | \] 398 | 故可推出数值微分公式为 399 | \[ D_h[f]=\frac1{h^2}[f(x-h)-2f(x)+f(x+h)] \] 400 | 为提高该公式的精度,可再取 $h/2$ 为步长 401 | \footnote{从这里出发,就可以如 Romberg 积分法的推导过程一样,导出形式类似的 Richardson 外推法。详见李乃成、梅立泉《数值分析》第 205 -- 206 页6.4.3节「外推求导法」。} 402 | ,能递推出近似关系 403 | \[ f''(x)-D_{\frac12h}[f]\approx\frac14(f''(x)-D_h[f])\sothat 404 | f''(x)\approx\frac13\left[4D_{\frac h2}[f]-D_h[f]\right]. \] 405 | 记 $\overline{D}[f]=\frac43D_{\frac h2}[f]-\frac13D_h[f]$,该公式相较于上式更为精确。 -------------------------------------------------------------------------------- /chapters/chp-7.tex: -------------------------------------------------------------------------------- 1 | \chapter{非线性方程迭代解法} 2 | \entry \key{非线性方程}:在化简方程为 $f(x)=0$ 的形式后,$f(x)$ 中含有 $x$ 的非线性项,如 $x^2$、$\sin x$、$\e^x$ 等。 3 | 线性方程以外的代数、函数方程均是非线性方程。 4 | 5 | \entry 非线性方程的\emph{迭代解法}:泛指在已知结果的基础上,从给定初值 $x^{(0)}$ 6 | 出发,利用统一的迭代格式 $x^{(k+1)}=f(x^{(k)})$ ,使递推数列 $\{x^{(k)}\}$ 逼近方程解 $x^\ast$ 的解法。 7 | 8 | \entry 迭代解的要素: 9 | \begin{enumerate}\tl 10 | \item 迭代格式 $x^{(k+1)}=f(x^{(k)})$ 的构造; 11 | \item 初值 $x^{(0)}$ 的选取; 12 | \item 迭代数列 $\{x^{(k)}\}$ 的收敛性与正确性; 13 | \item 迭代终止条件与误差估计。 14 | \end{enumerate} 15 | 16 | \section{迭代法简述} 17 | \entry \key{二分法}:根据零点存在定理,不断二分方程之解所在的区间,用「区间套」逼近方程之解。二分法过程稳定,但运算量大(需反复计算函数值),且收敛较慢 18 | \footnote{每迭代 $10$ 次,解所在的区间范围缩小到原来的 $1/1024\approx1/1000$,相当于提高了 $3$ 位有效数字。也即:需要迭代超过 $3$ 次才能增加解的一位有效数字。} 19 | ,故常用于初步确定初值 $x^{(0)}$ 的范围(而不用于确定最终解)。 20 | \begin{figure}[htbp] 21 | \small\centering 22 | \begin{tikzpicture}[scale=2,fill opacity=0.25,text opacity=1] 23 | \draw[->] (-0.2,0) -- (5,0) node [below] {$x$}; 24 | \draw[->] (0,-0.4) -- (0,0.4) node [right] {$y$}; 25 | \draw (0,-0.3) parabola (4,0.4); 26 | \draw[dashed] (4,0.4) -- (4,0); 27 | \fill[black] (2,-0.05) rectangle (4,0.05) node [right] {$x^{(0)}$}; 28 | \fill[black] (2,-0.1) rectangle (3,0.1) node [right] {$x^{(1)}$}; 29 | \fill[black] (2.5,-0.2) rectangle (3,0.2) node [above right] {$x^{(2)}$}; 30 | \fill[black] (2.5,-0.4) rectangle (2.75,0.4) node [right] {$x^{(3)}$}; 31 | \end{tikzpicture} 32 | \caption{二分法示意(重叠的灰色格子即不断缩窄的区间套)}\label{7-f1} 33 | \end{figure} 34 | 35 | 36 | \entry \key{简单迭代法}:构造非线性方程 $f(x)=0$ 的同解变形 $x=\vphi(x)$,例如 37 | \[ x = x - f(x),\quad x=\sqrt{x^2-kf(x)} \] 38 | 等,再构造对应迭代格式为 39 | \begin{equation} 40 | x_{k+1}=\vphi(x_k). 41 | \end{equation} 42 | 若 $\{x_k\}$ 收敛到 $x^\ast$,且 $\vphi(x)$ 也在 $x^\ast$ 处连续,则对以上方程左右取极限即得 $x^\ast=\vphi(x^\ast)$,说明该迭代法可以逼近方程之解。 43 | 44 | \entry \key{Newton 法}:设非线性方程 $f(x)=0$ 之解为 $x^\ast$,即 $x^\ast = 0$,将其 45 | 在 $x_k$ 处展开可得 46 | \begin{equation}\label{7-e2} 47 | f(x_k)+f'(x_k)(x^\ast-x_k)+\cdots = 0 48 | \end{equation} 49 | 舍去二阶项,有 $f(x_k)+f'(x_k)(x^\ast-x_k)\approx0$,进而可变换得到 50 | \[x^\ast\approx x_k-\frac{f(x_k)}{f'(x_k)}\] 51 | 改写其为一个迭代格式即得 52 | \begin{equation}\label{7-e1} 53 | x_{k+1} = x_k-\frac{f(x_k)}{f'(x_k)} 54 | \end{equation} 55 | 可验证该方程确为 $f(x)=0$ 的同解变形,故该迭代格式收敛时必能得到方程之解。(根据 Newton 法的几何意义,其又被称为\key{切线法}。) 56 | 57 | \entry \key{改进 Newton 法}:在上面的展开式 \eqref{7-e2} 中保留到二次项,可解得: 58 | \[ x^\ast\approx x_k+\frac{-f'(x_k)\pm\sqrt{f'(x_k)^2-2f(x_k)f''(x_k)}}{f''(x_k)} \] 59 | 分母中的正负号不定,故可写出两种迭代格式: 60 | \begin{gather} 61 | \tilde{x}_{k+1}=x_k-\frac{f'(x_k)+\sgn(f'(x_k))\sqrt{f'(x_k)^2-2f(x_k)f''(x_k)} 62 | }{f''(x_k)},\\ 63 | \overline{x}_{k+1}=x_k-\frac{2f(x_k)}{f'(x_k)+\sgn(f'(x_k))\sqrt{f'(x_k)^2-2f(x_k) 64 | f''(x_k)}}. 65 | \end{gather} 66 | 选取 $\tilde{x}_{k+1}$ 与 $\overline{x}_{k+1}$ 中距离 $x_k$ 更近者,作为下一步迭代 67 | 时的 $x_{k+1}$ 即可。 68 | 69 | \entry \key{简化 Newton 法}:若 $f'(x)$ 难以计算,可将迭代格式 (\ref{7-e1}) 改写为 70 | \begin{equation} 71 | x_{k+1}=x_k-\frac{f(x_k)}{f'(x_0)} 72 | \end{equation} 73 | 即始终采用\emph{初值点处导数}近似表示 $f'(x_k)$。 74 | 75 | \entry \key{弦割法} 76 | \footnote{弦割法的提出已有相当历史,西安交大 120 周年校庆时提出的「风云两甲子,\emph{弦割}三世纪」即是为纪念其悠久的历史而作。} 77 | :将迭代格式 (\ref{7-e1}) 中的导数 $f'(x_k)$ 用两点数值微分公式代替,可 78 | 得到: 79 | \begin{itemize} 80 | \item 若用 $x_k$ 与 $x_{k-1}$ 作为迭代格式中的两点,则得 81 | \begin{equation} 82 | x_{k+1} = x_k-\frac{f(x_k)}{\frac{f(x_k)-f(x_{k-1})}{x_k-x_{k-1}}} = 83 | x_k-\frac{f(x_k)(x_k-x_{k-1})}{f(x_k)-f(x_{k-1})} 84 | \end{equation} 85 | 此即\key{两点弦割法}。 86 | \item 若用 $x_k$ 与 $x_0$ 作为迭代格式中的两点,则得 87 | \begin{equation} 88 | x_{k+1} = x_k-\frac{f(x_k)}{\frac{f(x_k)-f(x_0)}{x_k-x_0}} = 89 | x_k-\frac{f(x_k)(x_k-x_0)}{f(x_k)-f(x_0)} 90 | \end{equation} 91 | 此即\key{单点弦割法}。 92 | \end{itemize} 93 | 94 | \entry 弦割法需要给定\emph{两步}初值 $x_0$ 与 $x_1$ 才能进行,它们通常由其他方法获得。 95 | 96 | \entry 切线法与弦割法的几何意义:如图 \ref{7-f2} 所示。 97 | \begin{figure}[htbp] 98 | \small\centering 99 | \begin{tikzpicture}[xscale=2,yscale=4] 100 | \draw[->] (0,0) -- (1.2,0) node [above] {$x$}; 101 | \draw[->] (0,-0.2) -- (0,1) node [right] {$y$}; 102 | \draw (0,-0.15) parabola (1.2,1) node [left] {$f(x)$}; 103 | \draw[dashed] (1,0.65) -- (1,0) node [below] {$x^{(0)}$}; 104 | \draw[red] (1.2,0.95) -- (1,0.65) -- (0.567, 0) node [below,black] {$x^{(1)}$}; 105 | \draw[dashed] (0.567,0) -- (0.567,0.108); 106 | \draw[blue] (0.801,0.324) -- (0.567,0.108) -- (0.45,0); 107 | \draw[dashed] (0.45,0) -- (0.45,0.3) node [above] {$x^{(2)}$}; 108 | \node at (0.6,-0.2) {Newton 法}; 109 | \end{tikzpicture}\hfil 110 | \begin{tikzpicture}[xscale=2,yscale=4] 111 | \draw[->] (0,0) -- (1.2,0) node [above] {$x$}; 112 | \draw[->] (0,-0.2) -- (0,1) node [right] {$y$}; 113 | \draw (0,-0.15) parabola (1.2,1) node [left] {$f(x)$}; 114 | \draw[dashed] (1,0.65) -- (1,0) node [below] {$x^{(0)}$}; 115 | \draw[red] (1.2,0.95) -- (1,0.65) -- (0.567, 0) node [below,black] {$x^{(1)}$}; 116 | \draw[dashed] (0.567,0) -- (0.567,0.108); 117 | \draw[blue] (0.644,0.216) -- (0.49,0); 118 | \draw[dashed] (0.49,0) -- (0.49,0.3) node [above] {$x^{(2)}$}; 119 | \node at (0.6,-0.2) {简化 Newton 法}; 120 | \end{tikzpicture}\hfil 121 | \begin{tikzpicture}[xscale=2,yscale=4] 122 | \draw[->] (0,0) -- (1.2,0) node [above] {$x$}; 123 | \draw[->] (0,-0.2) -- (0,1) node [right] {$y$}; 124 | \draw (0,-0.15) parabola (1.2,1) node [left] {$f(x)$}; 125 | \draw[dashed] (1.1,0) -- (1.1,0.807) node [left] {$x^{(0)}$}; 126 | \draw[dashed] (0.679,0) -- (0.679,0.22) node [right] {$x^{(1)}$}; 127 | \draw[red] (1.2,0.95) -- (1,0.67) -- (0.679,0.22) -- (0.521,0) node [below,black] {$x^{(2)}$}; 128 | \draw[dashed] (0.521,0) -- (0.521,0.068); 129 | \draw[blue] (0.986,0.524) -- (0.679,0.22) -- (0.521,0.068) -- (0.456,0); 130 | \draw[dashed] (0.456,0) -- (0.456,0.2) node [above] {$x^{(3)}$}; 131 | \node at (0.6,-0.2) {两点弦割法}; 132 | \end{tikzpicture}\hfil 133 | \begin{tikzpicture}[xscale=2,yscale=4] 134 | \draw[->] (0,0) -- (1.2,0) node [above] {$x$}; 135 | \draw[->] (0,-0.2) -- (0,1) node [right] {$y$}; 136 | \draw (0,-0.15) parabola (1.2,1) node [left] {$f(x)$}; 137 | \draw[dashed] (1.1,0) -- (1.1,0.807) node [left] {$x^{(0)}$}; 138 | \draw[dashed] (0.679,0) -- (0.679,0.22) node [right] {$x^{(1)}$}; 139 | \draw[red] (1.2,0.95) -- (1,0.67) -- (0.679,0.22) -- (0.521,0) node [below,black] {$x^{(2)}$}; 140 | \draw[dashed] (0.521,0) -- (0.521,0.068); 141 | \draw[blue] (1.2,0.934) -- (0.521,0.068) -- (0.468,0); 142 | \draw[dashed] (0.468,0) -- (0.468,0.2) node [above] {$x^{(3)}$}; 143 | \node at (0.6,-0.2) {单点弦割法}; 144 | \end{tikzpicture} 145 | \caption{迭代解法的几何意义}\label{7-f2} 146 | \end{figure} 147 | 148 | \section{迭代法的收敛理论} 149 | \entry 迭代法的两种\setkey{收敛性}{迭代法收敛性}:设非线性方程 $f(x)=0$ 在 $[a,b]$ 上有解 $x^\ast$,取定迭代格式 $x_{k+1}=\vphi(x_k)$ 与初值 $x_0$。若 150 | \begin{itemize}\tl 151 | \item 存在 $x^\ast$ 的一个小邻域,使得只要 $x_0$ 在此邻域中就能保证 $\{x_k\}$ 收 152 | 敛\footnote{根据迭代格式的意义,当 $\{x_k\}$ 收敛时其必收敛于 $x^\ast$。} 153 | ,则称迭代格式\key{局部收敛}; 154 | \item 对任意的 $x_0\in[a,b]$,都有 $\{x_k\}$ 收敛,则称迭代格式\key{全局收敛}。 155 | \end{itemize} 156 | 157 | \trm \key{全局收敛定理}(压缩映射原理):设 $\vphi(x)\in C[a,b]$,且满足: 158 | \begin{enumerate}\tl 159 | \item $x\in[a,b]$ 时,$\vphi(x)\in[a,b]$; 160 | \item 存在 $L\in[0,1)$,使得对任意的 $x\in[a,b]$都有 161 | \begin{equation} 162 | |\vphi'(x)|\leq L<1. 163 | \end{equation} 164 | \end{enumerate} 165 | 则由 $\vphi(x)$ 所构造的 $x_{k+1}=\vphi(x_k)$ 将是一个在 $[a,b]$ 上全局收敛的迭代 166 | 数列,且其满足以下\emph{误差估计式}: 167 | \begin{gather} 168 | |x^\ast-x_k|\leq\frac{L^k}{1-L}|x_1-x_0|,\quad\text{(先验估计)}\\ 169 | |x^\ast-x_k|\leq\frac1{1-L}|x_{k+1}-x_k|.\quad\text{(事后估计)} 170 | \end{gather} 171 | 172 | \entry 以上定理的结果,仅是全局收敛的\emph{充分条件},而非\emph{必要条件}。 173 | 174 | \trm \key{局部收敛定理}:设方程 $f(x)=0$ 有解 $x^\ast$,利用其同解变形构造了一个迭代格式 175 | $x_{k+1}=\vphi(x_k)$。若存在 $x^\ast$ 的某邻域 $[x^\ast-\delta,x^\ast+\delta]$ 使 176 | \[ |\vphi'(x)|\leq L<1 \] 177 | 则迭代格式 $x_{k+1}=\vphi(x_k)$ 在该邻域上\emph{局部收敛}。 178 | 179 | \trm Newton 迭代法的\emph{局部收敛定理}:设非线性方程 $f(x)=0$ 有解 $x^\ast$,在 $x^\ast$ 180 | 附近 $f(x)$ 二阶连续可微,$f'(x^\ast)\neq0$,则 Newton 迭代格式 (\ref{7-e1}) 在 181 | $x^\ast$ 的充分小邻域内局部收敛。(或:当初值 $x_0$ \emph{充分靠近} $x^\ast$ 时,Newton 182 | 迭代法收敛。) 183 | 184 | \trm Newton 迭代法的\emph{全局收敛定理}:设非线性方程 $f(x)=0$ 在 $[a,b]$ 上有解 $x^\ast$, 185 | 且 $f(x)$ 在 $[a,b]$ 上二阶连续可微。则 Newton 迭代格式 (\ref{7-e1}) 在 $[a,b]$ 上 186 | 全局收敛的充分条件是: 187 | \begin{enumerate}\tl 188 | \item $f(a)\cdot f(b)<0$; 189 | \item 对任意的$x\in[a,b]$,$f'(x)\neq0$; 190 | \item $f''(x)$ 在 $[a,b]$ 上不变号; 191 | \item 初值 $x_0$ 满足 $f(x_0)f''(x_0)>0$。 192 | \end{enumerate} 193 | 194 | \trm 弦割法\emph{局部收敛}的条件与 Newton 法类似,只要 $x_0,x_1$ 两步初值充分靠近 $x^\ast$。 195 | 196 | \trm 弦割法\emph{全局收敛定理}:在 Newton 法的所有条件之基础上,还应附加满足 $f(x_1)f''(x_1) 197 | >0$。 198 | 199 | \define \key{收敛阶}:设 $\{x_k\}$ 按某种迭代格式收敛于方程的解 $x^\ast$,若存在常数 $p\geq1$ 200 | 与 $c>0$ 使条件 201 | \begin{equation} 202 | \lim_{k\to\infty}\frac{|x^\ast-x_{k+1}|}{|x^\ast-x_k|^p}=c\neq0 203 | \end{equation} 204 | 成立,则称 $\{x_k\}$ 以 $p$ 阶收敛到方程之解。称 $c$ 为\emph{渐进误差常数}。 205 | 206 | \entry $p=1$时,称为\key{线性收敛},否则称为\key{超线性收敛}。 207 | 208 | \trm (整数)\key{收敛阶定理}:设 $\vphi(x)$ 在不动点上 $x^\ast$ 的邻域内有连续的 $p$ 阶 209 | 导数,则由 $x_{n+1}=\vphi(x_k)$ 生成的 $\{x_k\}$ 以 $p$ 阶收敛的充要条件是: 210 | \[\vphi'(x^\ast)=\vphi''(x^\ast)=\cdots=\vphi^{(p-1)}(x^\ast)=0,\,\vphi^{(p)} 211 | (x^\ast)\neq0.\] 212 | 213 | \entry 常见迭代格式的\emph{收敛阶}: 214 | \begin{itemize}\tl 215 | \item \emph{简单迭代法}:当 $0<|\vphi'(x^\ast)|<1$时\emph{线性收敛}。 216 | \item \emph{Newton 法}:当 $f'(x)\neq0$时\emph{二阶收敛}。 217 | \item \emph{两点弦割法}:满足收敛条件时具有 $p=\frac{1+\sqrt5}2\approx1.618$ 的收敛阶,\emph{超线性收敛}。 218 | \item \emph{单点弦割法}:满足收敛条件时\emph{线性收敛}。 219 | \end{itemize} 220 | 221 | \entry \key{加速收敛方法}:促使原来收敛较慢的算法更快收敛,或使原来发散的迭代格式变为收敛。 222 | 223 | \entry \key{松弛因子加速法}:对迭代格式 $x=\vphi(x)$,在方程左右减去一带\emph{松弛因子} $\omega$ 224 | 的项 $\omega x$,得 225 | \[ x-\omega x=\vphi(x)-\omega x \] 226 | 进而可得新的收敛格式 227 | \begin{equation} 228 | x=\frac{\vphi(x)-\omega x}{1-\omega}=\psi(x) 229 | \end{equation} 230 | 为检查该迭代格式的收敛性,可以对其求导得 231 | \[ \psi'(x)=\frac1{1-\omega}(\vphi'(x)-\omega) \] 232 | 若代入 $\omega=\vphi'(x^\ast)$,则在 $x^\ast$ 附近时 $|\psi(x^\ast)|$ 相当小,由此即 233 | 可保证 $|\psi'(x)|\leq L<1$ 的条件成立(将发散的迭代格式改进为收敛的),并提高收敛速率。 234 | 235 | \entry \key{Aitken 加速法}:略 236 | \footnote{参见李乃成、梅立泉《数值分析》第228页「艾特肯加速法」,该加速方法是在假设迭代格式线性收敛的情况下作出的。}。 237 | -------------------------------------------------------------------------------- /chapters/chp-8.tex: -------------------------------------------------------------------------------- 1 | \chapter{常微分方程数值解} 2 | \entry 本章只涉及\emph{一阶常微分方程初值问题} 3 | \footnote{其他可能的问题包括:更高阶的常微分方程初值问题,以及常微分方程\emph{边值问题}等。} 4 | : 5 | \begin{equation}\label{8-e1} 6 | \begin{cases} 7 | y'(x)=f(x,y(x)),\quad x\in[a,b]\\ 8 | y(a)=y_0. 9 | \end{cases} 10 | \end{equation} 11 | 12 | \trm \setkey{解的存在唯一性}{常微分方程解存在唯一性}:在由式 (\ref{8-e1}) 所述的初值问题中,若 $f(x,y)$ 在区域 13 | \[D=\{(x,y)|a\leq x\leq b,-\infty