matlab数值分析程序--高等数学,数值代数的matlab实现-文字版, matlab电子书, 和matlab 有关的电子书:

9.7.4 无界函数反常积分的近似计算及其MATLAB程序

9.7.4  无界函数反常积分的近似计算及其MATLAB程序

 

(一) 无界函数的反常积分的“挖去”法及其MATLAB程序

     例9.7.14  近似计算I=d,误差在左右.

解  输入程序

>> syms r

r=solve('r*(1-(log(r)))=10^(-8)',r), R= double(r)

运行后屏幕显示r的值为

r =

[exp(lambertw(-1/100000000*exp(-1))+1)]

[ exp(lambertw(-1,-1/100000000*exp(-1))+1)]

R =

   2.71828181845905

   0.00000000044374

输入程序

>> r=[2.71828181845905, 0.00000000044374];

y= r.*(1-(log(r)))

运行后屏幕显示r处的函数值为

y =

  1.0e-007 *

   0.09999995049004   0.10000028042507

取r=0.000 000 000 443 74时,使   d,所以只需用数值方法计算d.用梯形公式计算的近似值Q,输入程序

>> x=0.00000000044374:0.0001:1;

 y=(2*x).*abs(log(x))./(1+x.^2);z=trapz(x,y)

运行后屏幕显示

z =

   0.41123349222004

用洛巴托求积公式计算,在MATLAB工作区输入程序

>> syms x

Y=inline('(2*x).*abs(log(x))./(1+x.^2)');

Y1=(2*x).*abs(log(x))./(1+x.^2);

 [Qql,FCNTl]=quadl(Y, 0.00000000044374,1),

Q1=int(Y1, 0.00000000044374,1), Q1d=double(Q1),

juewuQql= Q1d-Qql,

运行后屏幕显示

Qql =

   0.41123345753925

FCNTl =

    78

Q1d =

  0.41123351671206

juewuQql =

     5.917280476719355e-008

 

 (二)高斯—切比雪夫求积公式及其MATLAB程序

高斯—切比雪夫求积公式计算d及其截断误差公式的MATLAB主程序

function [GC,X,Y,RCn]=GaussC1(fun,n)

n2=2*n; X=zeros(1,n); A=(pi/n)*ones(1,n);

for k=1:n

X(k)=-cos((2*k-1)*pi/(2*n));

end

Y=feval(fun,X); GC=sum(A.*Y); su2n=1;

for k=1:n2

su2n=su2n*k;

end

su2n; syms df2n,RCn = (2*pi)*df2n/( 2^(2*n)*su2n);

例9.7.16  用高斯—切比雪夫求积公式计算d,取n=15,再根据截断误差公式写出误差公式,并将计算结果与精确值进行比较.

解  输入程序

>> n=15; [GC,X,Y,RCn]=GaussC1(@fun,n)

syms x

fi=int(sqrt(2+x)./sqrt(1-x.^2),x,-1,1); Fs= double (fi)

wGL = double (abs(fi- GC))

运行后屏幕显示如下

GC =

   4.36887628549240

X =

  Columns 1 through 9

-0.99452189536827  -0.95105651629515  -0.86602540378444  -0.74314482547739  -0.58778525229247  -0.40673664307580  -0.20791169081776  -0.00000000000000

   0.20791169081776

  Columns 10 through 15

0.40673664307580   0.58778525229247   0.74314482547739   0.86602540378444

   0.95105651629515   0.99452189536827

Y =

  Columns 1 through 9

1.00273531135177   1.02417941968429   1.06488243304863   1.12109552426303   1.18836641979969   1.26224536320170   1.33868902631726   1.41421356237309

   1.48590433434248

  Columns 10 through 15

1.55136605708511   1.60865945814907   1.65624419258677   1.69293396320838

   1.71786393998336   1.73046869239760

RCn =

1/142406544757979148169424935503213094764544*pi*df2n

Fs =

   4.36887628549240

wGL =

    8.919048090161604e-016

n个节点的高斯—切比雪夫求积公式计算d及其误差估计的MATLAB主程序

function [GC, X, Y, RCn]=GaussC2(fun,n ,df2n)

n2=2*n; X=zeros(1,n); A=(pi/n)*ones(1,n);

for k=1:n

X(k)=-cos((2*k-1)*pi/(2*n));

end

Y=feval(fun,X); GC=sum(A.*Y); su2n=1;

for k=1:n2

su2n=su2n*k;

end

su2n; mfun2n =max(df2n);

RCn = (2*pi)*mfun2n /( 2^(2*n)*su2n);

 

例9.7.17  用高斯—切比雪夫求积公式计算d,取n=6,估计其误差,并将计算结果与精确值进行比较.

解  输入程序

>> x=-1:0.0001:1;

df2n=64*exp(-x.^2).*(10395-124740*x.^2+207900*x.^4-110880*x.^6+23760*x.^8-2112*x.^10+64*x.^12);

n=6; [GC, X, Y, RCn]=GaussC2 (@fun,n ,df2n)

syms t a b

fi1=int(exp(-t.^2)./sqrt(1-t.^2),t,0,a);

fia=limit(fi1,a,1)

fi2=int(exp(-t.^2)./sqrt(1-t.^2),t, -b,0);

fib=limit(fi2,b,1), fi=fia+fib;

Fs= double (fi), wGL = double (abs(fi- GC))

运行后屏幕显示结果依次如下

GC =

2.02643676313532

X = 

Columns 1 through 4

-0.96592582628907  -0.70710678118655  -0.25881904510252   0.25881904510252

  Columns 5 through 6

   0.70710678118655   0.96592582628907

Y = 

Columns 1 through 4

0.39336682642326   0.60653065971263   0.93520708016087   0.93520708016087

  Columns 5 through 6

   0.60653065971263   0.39336682642326

RCn =

    2.130528872063391e-006

Warning: Explicit integral could not be found.

fia =

1/2*pi*hypergeom([1/2],[1],-1)

Warning: Explicit integral could not be found.

fib =

int(exp(-t^2)/(1-t^2)^(1/2),t = -1 .. 0)

Fs =                         wGL =

   2.02643806694936                1.303814033355041e-006

欢迎转载,转载请注明来自一手册:http://yishouce.com/book/3/3090704.html
友情链接It题库(ittiku.com)| 版权归yishouce.com所有| 友链等可联系 admin#yishouce.com|粤ICP备16001685号-1