18 - Quadrature of data Adaptive quadrature Numerical...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
Quadrature of data Adaptive quadrature Numerical Integration of Functions Dhavide Aruliah UOIT MATH 2070U c ± D. Aruliah (UOIT) Numerical Integration of Functions MATH 2070U 1 / 24
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Quadrature of data Adaptive quadrature Numerical Integration of Functions 1 Numerical integration (quadrature) of numerical data sum and cumsum trapz and cumtrapz 2 Numerical integration of functions: adaptive quadrature Adaptive Simpson’s quadrature quad in MATLAB Extensions of quad in MATLAB c ± D. Aruliah (UOIT) Numerical Integration of Functions MATH 2070U 2 / 24
Background image of page 2
Quadrature of data Adaptive quadrature Reminder: Quadrature rules: Z b a f ( x ) dx n k = 0 w k f ( x k ) Rules derived from polynomial interpolation Common rules: trapezoidal rule, Simpson’s 1/3 rule Composite rules: break into smaller pieces c ± D. Aruliah (UOIT) Numerical Integration of Functions MATH 2070U 4 / 24
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Quadrature of data Adaptive quadrature sum cumsum sum and cumsum sum(y) returns sum of elements of y y = 1:7 S = sum(y) % returns a single scalar value cumsum(y) returns vector of cumulative sums (partial sums) of y y = 1:7 s = cumsum(y) % returns a *vector* For matrices/arrays, sum / cumsum operates on leading dimension Can be applied along other dimensions One-line command replacing traditional loop Similar functionality for prod and cumprod for arrays c ± D. Aruliah (UOIT) Numerical Integration of Functions MATH 2070U 5 / 24
Background image of page 4
Quadrature of data Adaptive quadrature trapz cumtrapz Integrating discrete data Data prescribed from measurements { ( x k , y k ) } n k = 0 Trapezoidal rule (assume a = x 0 < x 1 ··· < x n = b ): Z b a f ( x ) dx 1 2 n k = 1 h k ( y k - 1 + y k ) with h k : = x k - x k - 1 ( k = 1: n ) MATLAB “one-liner”: I_trap = 0.5*sum( diff(x) .* ( y(1:end-1)+y(2:end) ) Essential computation of MATLAB routine trapz cumtrapz Notice does not assume uniform spacing in x c ± D. Aruliah (UOIT) Numerical Integration of Functions MATH 2070U 6 / 24
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Adaptive quadrature trapz cumtrapz Using trapz and cumtrapz Assume vectors x , y with y k = f ( x k ) ( k = 0: N ) trapz(x,y) Z x N x 0 f ( t ) dt : returns a single number x = (0:10)’; y = [0,1,4,9,16,25,36,49,64,81,100]’; I_approx = trapz (x,y) For k = 0: N , cumtrapz(x,y) k Z x k x 0 f ( t ) dt : returns a vector (samples of a function) x = (0:10)’; y = [0,1,4,9,16,25,36,49,64,81,100]’;
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 20

18 - Quadrature of data Adaptive quadrature Numerical...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online