Adaptive Quadrature

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 8

7 Numerical Integration

28-7.4 Adaptive Quadrature

Dr. Lai Shengjian


Research Building 710#, UESTC
 The composite quadrature rules necessitate the use of equally spaced
points. A small step size h was used uniformly across entire interval.
 It is useful to introduce a method that adjusts the step size to be smaller
over portions of the curve where a larger functional variation occurs.
 Adaptive quadrature method is based on Simpson’s rule.
h
S (ak , bk )   f (ak )  4 f (ck )  f (bk )  ck  (bk  ak ) / 2
3 h  (bk  ak ) / 2
( 4)
bk f (d1 )

ak
f ( x )dx  S (ak , bk )  h5
90
 Only two additional evaluations of 𝒇 𝒙 are needed, ante the result is
h
S (ak1 , bk1 )  S (ak 2 , bk 2 )   f (ak1 )  4 f (ck1 )  f (bk1 )  
6
h
 f (ak 2 )  4 f (ck 2 )  f (bk 2 ) 
6 5 ( 4)
bk h f (d 2 )
ak f ( x )dx  S (ak1 , bk1 )  S (ak 2 , bk 2 )  16 90 2
12/15/2019 6:21 PM [email protected]
bk h5 f ( 4 ) (d 2 )
 ak
f ( x )dx  S (ak1 , bk1 )  S (ak 2 , bk 2 ) 
16 90
 The relationship of two integral equations
( 4) 5 ( 4)
f ( d ) h f (d 2 )
S (ak , bk )  h5 2
 S (ak1 , bk1 )  S (ak 2 , bk 2 ) 
90 16 90
 Rewrite as
f ( 4 ) (d 2 ) 16
h 5
  S (ak1 , bk1 )  S (ak 2 , bk 2 )  S (ak , bk ) 
90 15
 The error estimate
bk 1

ak
f ( x )dx  S (ak1 , bk1 )  S (ak 2 , bk 2 ) 
15
S (ak1 , bk1 )  S (ak 2 , bk 2 )  S (ak , bk )

 Because of the assumption 𝒇 𝟒 (𝒅𝟏 ) ≈ 𝒇 𝟒 (𝒅𝟐 ) , the fraction 𝟏/𝟏𝟓 is


replace with 𝟏/𝟏𝟎 on the right.

12/15/2019 6:21 PM [email protected] 3


bk 1

ak
f ( x )dx  S (ak1 , bk1 )  S (ak 2 , bk 2 ) 
15
S (ak1 , bk1 )  S (ak 2 , bk 2 )  S (ak , bk )

 Assume that the tolerance 𝜺𝒌 > 𝟎 is specified for the interval [𝒂𝒌 , 𝒃𝒌 ]
1
S (ak1 , bk1 )  S (ak 2 , bk 2 )  S (ak , bk )   k
10
bk
 ak
f ( x )dx  S (ak1 , bk1 )  S (ak 2 , bk 2 )   k

 Thus the composite Simpson rule is used to approximate the integral


bk
ak
f ( x )dx  S (ak1 , bk1 )  S (ak 2 , bk 2 )

 Adaptive quadrature is implemented by applying Simpson’s rules


h
S (ak , bk )   f (ak )  4 f (ck )  f (bk ) 
3
h
S (ak1 , bk1 )  S (ak 2 , bk 2 )   f (ak1 )  4 f (ck1 )  f (bk1 )  
6
h
 f (ak 2 )  4 f (ck 2 )  f (bk 2 ) 
6
12/15/2019 6:21 PM [email protected] 4
bk 1
ak
f ( x )dx  S (ak1 , bk1 )  S (ak 2 , bk 2 ) 
15
S (ak1 , bk1 )  S (ak 2 , bk 2 )  S (ak , bk )

 Start with { 𝒂𝟎 , 𝒃𝟎 , 𝝐𝟎 }. The interval is refined into subintervals labeled


𝒂𝟎𝟏 , 𝒃𝟎𝟏 and 𝒂𝟎𝟐 , 𝒃𝟎𝟐 . If the accuracy test fails, the two subintervals are
relabeled 𝒂𝟏 , 𝒃𝟏 and 𝒂𝟐 , 𝒃𝟐 over which use the tolerances 𝝐𝟏 = 𝝐𝟎 /
𝟐, 𝝐𝟐 = 𝝐𝟎 /𝟐 , respectively. { 𝒂𝟏 , 𝒃𝟏 , 𝝐𝟏 } and { 𝒂𝟐 , 𝒃𝟐 , 𝝐𝟐 } .
 In the second step we first consider { 𝒂𝟏 , 𝒃𝟏 , 𝝐𝟏 } and refine the interval
𝒂𝟏𝟏 , 𝒃𝟏𝟏 and 𝒂𝟏𝟐 , 𝒃𝟏𝟐 . if the accuracy test fails, respectively. { 𝒂𝟏 , 𝒃𝟏 , 𝝐𝟏 }
𝒂𝟐 , 𝒃𝟐 , 𝝐𝟐 , { 𝒂𝟑 , 𝒃𝟑 , 𝝐𝟑 }, { 𝒂𝟒 , 𝒃𝟒 , 𝝐𝟒 }. Where 𝝐𝟏 + 𝝐𝟐 + 𝝐𝟑 + 𝝐𝟒 =𝝐𝟎
 Ex. 7.16 use adaptive quadrature to numerically approximate the value of
𝟒
definite integral ‫ 𝒙(𝟑𝟏 𝟎׬‬− 𝒙𝟐 )𝒆−𝟑𝒙/𝟐 𝒅𝒙 with the starting tolerance 𝝐𝟎 = 𝟏𝒆−𝟓

4
0
13( x  x 2 )e 3 x / 2 dx  1.548788372527948

12/15/2019 6:21 PM [email protected] 5


1.548788373  ( 1.54878823413)  0.0000001384

12/15/2019 6:21 PM [email protected] 6


 state=done;
 SR1vec=SR0vec;
 SR2vec=SR0vec;
 a=SR0vec(1);
 b=SR0vec(2);
 c=(a+b)/2;
 function  err=SR0vec(5);
[SRmat,quad,err]=adapt(f,a,b,tol)  tol=SR0vec(6);
 tol2=tol/2;
 SRmat = zeros(30,6);
 SR1vec=srule(f,a,c,tol2);
 iterating=0;  SR2vec=srule(f,c,b,tol2);
 done=1;  err=abs(SR0vec(3)-SR1vec(3)-SR2vec(3))/10;
 SRvec=zeros(1,6); 
 SRvec=srule(f,a,b,tol);  %Accuracy test
 SRmat(1,1:6)=SRvec;  if (err<tol)
 m=1;  SRmat(p,:)=SR0vec;
 SRmat(p,4)=SR1vec(3)+SR2vec(3);
 state=iterating;
 SRmat(p,5)=err;
 while(state==iterating)  else
 n=m;  SRmat(p+1:m+1,:)=SRmat(p:m,:);
 for j=n:-1:1  m=m+1;
 p=j;  SRmat(p,:)=SR1vec;
 SR0vec=SRmat(p,:);  SRmat(p+1,:)=SR2vec;
 err=SR0vec(5);  state=iterating;
 end
 tol=SR0vec(6);
 end
 if (tol<=err)  end
 %Bisect interval,apply end
Simpson's rule  quad=sum(SRmat(:,4));
 %recursively, and determine
12/15/2019 6:21 PM
 err=sum(abs(SRmat(:,5)));
[email protected] 7
error  SRmat=SRmat(1:m,1:6);
Program (Report7: 数值积分算法实验)
Algorithm and Progamming7.2.3 P262 3
Algorithm and Progamming7.3.3 P273 3
Algorithm and Progamming7.4.3 P276 1,2;

Report File Format: 学号_姓名_report7.doc


Upload the Online Class(互动教学空间网络学堂物理学院数值计算方法).
Deadline :

12/15/2019 6:21 PM [email protected] 8

You might also like