Quadrature. 二阶 : 中点公式 : 梯形公式 : 四阶公式 : Simpson’s 1/3 rd Rule.

Slides:



Advertisements
Similar presentations
Prof. Muhammad Saeed ( Differentiation and Integration )
Advertisements

Recursion Prog #include <stdio.h> #include<conio.h> main()
DS:Lab-1 Prepared by: Shipra Shukla Assistant Professor Kaziranga University.
Numerical Integration
PROGRAM 8 consider a function y = f(x). In order to evaluate definite integral I = a ∫ b y dx = a ∫ b f(x) dx Divide the interval (b-a) of x into n equal.
Computational Physics Numerical Integration Dr. Guy Tel-Zur Tulips by Anna Cervova, publicdomainpictures.net.
What is shape function ? shape function is a function that will give the displacements inside an element if its displacement at all the node locations.
ES 240: Scientific and Engineering Computation. Chapter 17: Numerical IntegrationIntegration  Definition –Total area within a region –In mathematical.
Scientific Programming for(i=0; i b) { a = func1(c,d,i*10); } else if(a < b) { a = func2(e,f,i*10); } else { a = func3(g,h,i*10);
Sort the given string, without using string handling functions.
Lecture 26: Numerical Integration Trapezoid rule Simpson's rule Simpson's 3/8 rule Boole’s rule Newton-Cotes Formulas.
By Senem Kumova Metin 1 POINTERS + ARRAYS + STRINGS REVIEW.
A Riemann sum is a method for approximating the total area underneath a curve on a graph. This method is also known as taking an integral. There are 3.
Numerical Integration of Functions
Chapter 7 Numerical Differentiation and Integration
Numerical Integration
Quadrature. 二阶 : 中点公式 : 梯形公式 : 四阶公式 : Simpson’s 1/3 rd Rule.
Chapter 5 Numerical Differentiation and Integration.
MECH300H Introduction to Finite Element Methods Lecture 2 Review.
CISE301_Topic7KFUPM1 SE301: Numerical Methods Topic 7 Numerical Integration Lecture KFUPM Read Chapter 21, Section 1 Read Chapter 22, Sections 2-3.
CISE301_Topic71 SE301: Numerical Methods Topic 7 Numerical Integration Lecture KFUPM (Term 101) Section 04 Read Chapter 21, Section 1 Read Chapter.
Numerical Integration UC Berkeley Fall 2004, E77 Copyright 2005, Andy Packard. This work is licensed under the.
Simpson’s 1/3 rd Rule of Integration. What is Integration? Integration The process of measuring the area under a.
Chapter 4, Integration of Functions. Open and Closed Formulas x 1 =a x 2 x 3 x 4 x 5 =b Closed formula uses end points, e.g., Open formulas - use interior.
Numerical Integration
3. Numerical integration (Numerical quadrature) .
Lecture 19 - Numerical Integration CVEN 302 July 22, 2002.
Numerical Computation
1 Chapter 7 NUMERICAL INTEGRATION. 2 PRELIMINARIES We use numerical integration when the function f(x) may not be integrable in closed form or even in.
1 Numerical Analysis Lecture 12 Numerical Integration Dr. Nader Okasha.
1 Simpson’s 1/3 rd Rule of Integration. 2 What is Integration? Integration The process of measuring the area under a curve. Where: f(x) is the integrand.
4.6 Numerical Integration Trapezoid and Simpson’s Rules.
IIT BOMBAY JANUARY, 2015 ‘Numerical Analysis’ with Visualization by Rasik R. Shah.
EE3561_Unit 7Al-Dhaifallah EE 3561 : Computational Methods Unit 7 Numerical Integration Dr. Mujahed AlDhaifallah ( Term 342)
Chapter 4 Integration.
MECH345 Introduction to Finite Element Methods Chapter 1 Numerical Methods - Introduction.
Integration For a function f, The “integral of f from a to b” is the area under the graph of the function. If f is continuous, then the area is well defined,
數值方法 2008, Applied Mathematics NDHU 1 Numerical Integration.
Use of Newton-Cotes Formulas and eventual shortcomings Matlab code to increase number of segments with trapezoid, 1/3 and 3/8 rule.
Techniques for Numerical Integration
The purpose of Chapter 5 is to develop the basic principles of numerical integration Usefule Words integrate, integral 积分(的), integration 积分(法), quadrature.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Part 5 Integration and Differentiation.
Integration Review Part I When you see the words… This is what you think of doing…  A Riemann Sum equivalent to the definite integral is… -- 1.
Int fact (int n) { If (n == 0) return 1; else return n * fact (n – 1); } 5 void main () { Int Sum; : Sum = fact (5); : } Factorial Program Using Recursion.
SE301_Topic 6Al-Amer20051 SE301:Numerical Methods Topic 6 Numerical Integration Dr. Samir Al-Amer Term 053.
Quadrature – Concepts (numerical integration) Don Allen.
數值方法 2008, Applied Mathematics NDHU 1 Numerical Integration.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Chapter 20 Numerical Integration of Functions.
Numerical Integration
Air Force Admin College, Coimbatore
Programming in C Paper – VIII B.
Chapter 7 Numerical Differentiation and Integration
Midpoint and Trapezoidal Rules
1. 2 What is Integration? Integration The process of measuring the area under a curve. Where: f(x) is the integrand a= lower limit of integration b=
Integration Review Problems
Integration with Unequal Segments
مبانی کامپیوتر و برنامه سازی
Recursion.
NUMERICAL INTEGRATION
Chapter 7 Numerical Differentiation and Integration
Trapezoidal Rule of Integration
4.3 Elements of Numerical Integration
Elements of Numerical Integration
Unit I C Language Review Ref. Book: Yashavant Kanetkar, “Let Us C”, BPB Publications, 10/E, 2010.
MATH 174: NUMERICAL ANALYSIS I
Numerical Computation and Optimization
CPE 332 Computer Engineering Mathematics II
Numerical Integration
Air Force Admin College, Coimbatore
Presentation transcript:

Quadrature

二阶 : 中点公式 : 梯形公式 : 四阶公式 : Simpson’s 1/3 rd Rule

Boole ’ s rule,The 6-th Newton-Cotes rule (the first step of Romberg integration) The extrapolated Simpson ’ s rule.

#include #define TRUE 1 struct t_bc{float a, b, h;} bc; void main() { int isimp, k, n; float s; void simps(), trapz(); printf( "\nComputer Soft/C7-1 Trapezoidal/Simpson's Rule \n\n" ); while( TRUE ){ printf( "Type 0 for trapezoidal, or 1 for Simpson's\n " );scanf( "%d", &isimp ); printf( "Number of intervals ? " ); scanf( "%d", &n ); printf( "Lower limit of integration? " ); scanf( "%f", &bc.a ); printf( "Upper limit of integration? " ); scanf( "%f", &bc.b ); bc.h = (bc.b - bc.a)/n; if( isimp == 0 ){ trapz( &s, n ); /*-- Trapezoidal rule */ } else{ simps( &s, n ); /*-- Simpson's rule */ } printf( " \n" ); printf( " Result = %g \n", s ); printf( " \n" ); printf( "\nType 1 to continue, or 0 to stop.\n"); scanf( "%d", &k ); if( k != 1 ) exit(0); }

void simps(ss, n) /* Simpson's rule*/ float *ss; int n; { int i, ls; float sum, s, w, x; double func(); s = 0; sum = 0; if( n/2*2 == n ) ls = 0; else { ls = 3; for( i = 0; i <= 3; i++ ) { /* Simpson's 3/8 rule if n is odd */ x = bc.a + bc.h*i; w = 3; if( i == 0 || i == 3 ) w = 1; sum = sum + w*func( x ); } sum = sum*bc.h*3/8L; if( n == 3 ) return; } for( i = 0; i <= (n - ls); i++ ){ /* Simpson's 1/3 rule */ x = bc.a + bc.h*(i + ls); w = 2; if( (int)( i/2 )*2 + 1 == i ) w = 4; if( i == 0 || i == n - ls ) w = 1; s = s + w*func( x ); } *ss = sum + s*bc.h/3; return; } void trapz(ss, n) /* Trapezoidal rule */ float *ss; int n; { int i; float sum, w, x; double func(); sum = 0; for( i = 0; i <= n; i++ ){ x = bc.a + i*bc.h; w = 2; if( i == 0 || i == n ) w = 1; sum = sum + w*func( x ); } *ss = sum*bc.h/2; return; } double func(x) float x; { float func_v; func_v = pow(1 + pow(x/2, 2), 2)* ; return( func_v ); }

a = 0;b = 1; M = 10; H = (b-a)/M; % 2M intervals x = linspace(a,b,M+1); fpm = feval('fquad',x); fpm(2:end-1) = 2*fpm(2:end-1); csq = H*sum(fpm)/6; x = linspace(a+H/2,b-H/2,M); fpm = feval('fquad',x); csq = csq + 4/6*H*sum(fpm); Composite Simpson numerical integration

quad 基于变步长 Simpson 公式 (recursive adaptive Simpson quadrature) quad8 基于 Newton-Cotes 公式 (adaptive recursive Newton-Cotes 8 panel rule) quadl adaptive Lobatto quadrature % 1 f = inline('sin(x)/x'); f = vectorize(f); Q = quad(f,realmin,pi) % 2 anonymous function, beginning with MATLAB 7 f sin(x)/x Q = quad(f,realmin,pi) % 3 use an M-file Q =

Dblquad 二重积分 Triplequad 三重积分 计算 %1 function f = fxy(x,y) f = exp(-x.^2/2).*sin(x.^2+y.^2); I = dblquad('fxy',-2,2,-1,1) %2 I = dblquad(inline('exp(-x.^2/2).*sin(x.^2+y.^2)','x','y'),-2,2,-1,1) 符号计算 int

% integrating discrete data x = 0:10; y = x; % composite trapezoid rule T = sum(diff(x).*(y(1:end-1)+y(2:end))/2)

n 点求积公式若具有 2n-1 阶代数精度就成为 Gauss 型求积公式. Gauss-Legendre 公式 Gauss-Chebyshev 公式 Gauss-Laguerre 公式 Gauss-Hermite 公式

是正交多项式的实根, 定理: 其中 是权函数,

三项递推:

勒让德多项式 (Legendre) [-1,1],  (x)=1 递推关系 : P 0 (x)=1, P 1 (x)=x,

Legendre 多项式

Christoffel-Darboux identity 设 则 对 Legendre 多项式

T n (x)=cos(narccosx) 切比雪夫多项式 (Chebyshev) 递推关系 : T 0 (x)=1, T 1 (x)=x, T 2 (x)=2x 2 -1, T 3 (x)= 4x 3 -3x,………

埃尔米特多项式 (Hermite) (- ,+  ),  (x)=e -x 2 Hermite 多项式的三项递推关系

拉盖尔多项式 (Laguerre) [0,+  ),  (x)=e -x Laguerre 多项式的三项递推关系

无穷积分 令 Gauss-Laguerre 方法 ( 定义在 [0,∞), 无复合公式 )

区间 [ x i, x i +1 ], s=x-x i, h=h i = x i+1 - x i 补充 : 分段多项式插值 三阶 Hermite 插值

区间 [ x i, x i +1 ]

三次样条插值

区间 [ x i, x i +1 ], s=x-x i, y i =f(x i ), d i =f’(x i ) 区间 [ x i-1, x i ],

端点条件 : 1. 固定斜率 2. 自然端点 3. 非节点 代入 d 3

The road to wisdom? Well, it’s plain and simple to express: Err and err and err again but less and less PIET HEIN, Grooks(1966)