利用Matlab近似计算圆周率的若干方法
2012-04-29叶提芳
叶提芳
摘 要 本文分别采取幂级数展开式的方法、随机数的方法、数值积分的方法和公式法结合Matlab程序实现对圆周率的近似计算,分析实验结果,比较每种方法的近似程度的高低,实现了Matlab实验和数学理论的很好结合。
关键词 Matlab实验 圆周率 幂级数 随机数 数值积分
中图分类号:TP312 文献标识码:A
Some Methods of Approximatively Calculating Using Matlab Experiments
YE Tifang
(Industrial and Commercial College, Wuhan Polytechnic University, Wuhan, Hubei 430065)
Abstract In this paper, we used expanding power series, random number, numerical integration and formula methods combining matlab experiments to achieve the approximate value of. Then, we analyzed the experiments results, and compared the degree approximation of every method. It achieved the satisfying results of combination withMatlab experiment and mathematics theory.
Key words Matlab experiments; ; power series; random number; numerical integration
古今中外,历史上有许多人积极致力于圆周率的研究与计算。我国的刘徽用正3072边形得到小数点后的5位精度值,Ludolph Van Ceulen用262正边形得到了小数点后的35位精度值。这种方法虽然经典,但相当耗时。20世纪,很多数学家采取级数来近似计算圆周率的方法,已经能把圆周率近似计算精确到了上亿位,可以说,我们对圆周率的近似计算研究已经相当成熟。本文试在利用Matlab实验和高等数学中的知识有机结合起来,分别采取幂级数展开式的方法、随机数的方法、数值积分的方法和公式法结合Matlab程序实现对圆周率的近似计算。
1 利用幂级数展开式的计算方法
设是以2 为周期的周期函数,在[- , )上的表达式如下:
显然,为奇函数,利用我们在高等数学幂级数一章知识①,可以将其展开为正弦级数为:= 4
当我们取 = 时,得到一数项级数4,因为,则有4 =,求其部分和为 = 4,显然有 =,下面我们分别给出 = 1000,10000,50000时,利用Matlab程序求得的 的近似值。程序如下:
>> s=0;
>> n=50000;
>> digits(22)
>> for k=1:n
s=s+(-1)^(k-1)/(2*k-1);
end
>> s=vpa(4*s,20)
s =
3.1415726535897814387
= 1000,10000,50000时, 的近似值如下:
2 采取随机数的近似计算方法
设一制作均匀的冰激凌可以看做是由圆锥面 = 和球面 ++ ()2= 1围成②。我们利用积分知识求得它的体积为:
其中。
我们还可以采取随机数的方法,由于……
