学校代码: 11059 学 号:1107011027
Hefei University
毕业论文(设计)
BACHELOR DISSERTATION
论文题目: 一个通用数值积分的MATLAB实现 学位类别: 理学学士 学科专业: 信息与计算科学 作者姓名: 黄 凯
导师姓名: 段 敏 完成时间: 2015年5月20 日
一个通用数值积分的MATLAB实现
摘 要
当我们在现实生活和学习研究中需要运用积分来解决某些问题的时候,我们常常会因为这个积分是否能求出精确解以及积分求解的难易程度而感到苦恼。虽然数值积分中巧妙的利用积分中值定理利用各种算法可以近似的求出积分的近似解,但是往往利用单一公式求出的解精确度不是很高,如果要提高精度就涉及到公式的复化问题。在复化公式中我们采用多区间逐步逼近的方法可以让计算结果更加接近精确值,但这样我们的计算量也会跟着加大。Matlab的出现虽然将人们从繁复的计算中解放出来,但若要利用matlab来解决问题就会涉及到matlab编程问题,这会给一般的用户带来很大困难。虽然在各个文献中数值积分的各个公式的matlab程序已屡见不鲜,但终究都是零散单一的对单个公式的编程,没有统一的通用数值积分程序。
本文通过对数值积分的各种算法如:矩形公式、梯形公式、牛顿-柯茨公式等以及这些公式在matlab中的算法实现的比较,将尝试编写出统一的调用程序。根据问题的实际要求选择性的调用某种算法,这样不仅能将错综复杂的数值积分问题集中化、简单化,更能提高解决问题的效率。所以这篇文章的着重点也就在通用数值积分程序的编写及使用上。
关键词:数值积分;方法比较;通用算法
A general numerical integration MATLAB
ABSTRACT
When we are in the real life and learning needs to use integral to solve some problems in the research, we often because the integral is able to find out the exact solution and to the difficulty of the integral solution. Although the clever use of integral mean value theorem in numerical integration using various algorithm can approximate the approximate solution of integral, but tend to use a single formula and the solution accuracy is not high, it involves the formula of complex problems. We used in compound formula range more gradual approximation method can make a more accurate calculation results more close to, but this way we will increase the amount of calculation. Matlab while people will be liberated from the calculation of heavy and complicated, but if you want to use Matlab to solve the problem will involve the Matlab programming problems, it will bring considerable difficulties to the general user. Although in the literature of numerical integration formula matlab has become common, but they were scattered on a single formula of single programming, there is no uniform general numerical integration program.
Based on the numerical integration of all kinds of algorithms such as: rectangle formula, the trapezoid formula, Newton - ke, formula, and the comparison of these formulas in the matlab algorithm, will try to write a unified the caller. Problem according to the actual requirements of selective call some algorithms, such not only can centralizing fault in the complex numerical integration problems, simple, more can improve the efficiency of problem solving. So the emphasis of this article is in writing and using general numerical integral program.
KEY WORDS: Numerical integration; Method of comparison; General algorithm
目 录
第一章 前言 .............................................................. 1
1.1研究背景与课题意义 ............................................... 1 第二章 数值积分几种公式探析 .............................................. 2
2.1 数值积分方法的原理 .............................................. 2 2.2矩形公式......................................................... 2 2.3梯形公式......................................................... 3 2.4辛普森公式....................................................... 3 2.5牛顿-柯茨公式 .................................................... 4 2.6自适应数值积分 ................................................... 4 第三章Matlab编程程序 .................................................... 5
3.1主程序 .......................................................... 5 3.2调试实例......................................................... 5
3.2.1矩形公式调用实例 .......................................... 6 3.2.2梯形公式调用实例(计算不同等分份数的积分值) ................ 7 3.2.3辛普森公式调用实例 ........................................ 8 3.2.4牛顿-柯茨公式调用实例 .................................... 10 3.2.5自适应积分调用实例 ....................................... 11 3.3小结 ........................................................... 12 第四章 结语 ............................................................ 13 参考文献 ................................................................ 14 附 录................................................................... 15
主程序 ............................................................. 15 致 谢 ................................................................ 21
第一章 前言
1.1研究背景与课题意义
随着数值积分问题在日常生活中的应用越来越多,人们对数值积分的研究也越来越深。单从美国数学评论的走向来说,从1975年到1979年之间,与数值积分问题有关的文献在美国数学评论上有评论的就有上百份之多。当我们对这些文章做一个比较分析就会看到这些文章有着以下四个共同点即:研究方法的多样性、研究对象的特殊性、研究问题的具体性以及带微商项的积分公式明显增多。
另外, Matlab软件的诞生可以说是数学界一个福音,因为matlab是一个功能非常强大的科学计算软件,它是集数值处理、图形处理、图像处理、符号计算、文字处理、数学建模、实时控制、动态逼真、信号处理为一体的数学应用软件。Matlab的出现瞬间将人们从繁重的计算中解放出来,并且利用matlab来计算的准确性往往也会比人工计算的精确度高。因此,利用Matlab来计算数值积分是一种有效的积分数值计算方法,同时也可验证数值积分一般算法的准确性。
数值积分的计算方法很多,诸如矩形、梯形、辛普森、牛顿柯斯特、龙贝格、高斯算法等,还有相应的自适应算法。一般是一种算法,编写一个模块,这是常用的思想方法,若能在一个模块中通过输入接口,选择不同的算法,则又前进了一步,MATLAB中的数值积分多数是能完成这种功能的,但能实现更通用的功能,如输入接口中能提供更多的算法选择,更多的要求,如划分节点数,精度要求,是否自适应,耗时等数据,目前尚未有人开展研究。
本论文编写出的数值积分通用程序,将达到集成统一的调用方式,这就是本课题研究的目的;其意义在于调用处理模块名称统一,通过选择参数来选择不同的算法处理过程。
1