nou

intro numerical integration

2 mins read ·

Numerical integration: A short introduction

outline

intro

Suppose that there is f(x)f(x) with x[a,b]x \in [a, b], where

abf(x)dx.(1)\tag{1} \int_a^b f(x) dx.

is to be calculated.

discretization

Value of xx can be disretized as follow

xi=a+Δx(i1),    i=0,1,..,n1,n,(2)\tag{2} x_i = a + \Delta x (i - 1), \ \ \ \ i = 0, 1, .., n-1, n,

where

Δx=ban(3)\tag{3} \Delta x = \frac{b-a}{n}

is increment step.

Assignment 1. Proove that x0=ax_0 = a and xn=bx_n = b using (2) and (3).

formula

In general (4) can be approximated

abf(x)dxi=1nge(xi1,xi)Δx,(4)\tag{4} \int_a^b f(x) dx \approx \sum_{i = 1}^n g_e(x_{i-1}, x_i) \Delta x,

where ge(xi,xj)g_e(x_i, x_j) is different for various types of Riemann sums and index ee stands for certain type of Rieman sum.

lhr & rhl

Left hand rule (LHR) is using

gL(xi,xj)=f(xi),(5)\tag{5} g_L(x_i, x_j) = f(x_i),

while

gR(xi,xj)=f(xj),(6)\tag{6} g_R(x_i, x_j) = f(x_j),

is used for right hand rule (RHR).

mpr & trapezoid rule

Mid point rule (MPR) is using

gM(xi,xj)=f(12(xi+xj)),(7)\tag{7} g_M(x_i, x_j) = f( \tfrac12 (x_i + x_j) ),

which is different than trapezoid rule

gT(xi,xj)=12(f(xi)+f(xj)).(8)\tag{8} g_T(x_i, x_j) = \tfrac12 ( f(x_i) + f(x_j) ).

Notice the difference between (6) and (7).

simpson’s rule

Other approach in Riemann sum is

gS(xi,xj)={13(f(xi)+2f(xj)),i/2=i/2,13(2f(xi)+f(xj)),i/2i/2,(9)\tag{9} g_S(x_i, x_j) = \left\{ \begin{array}{cc} \tfrac13 ( f(x_i) + 2 f(x_j)), & \lfloor i / 2 \rfloor = i/2, \newline \newline \tfrac13 ( 2 f(x_i) + f(x_j)), & \lfloor i / 2 \rfloor \ne i/2, \end{array} \right.

which is known as Simpson’s rule. Note that nn or number of partitions must be even or there should be at least three points xix_i, xi+1x_{i+1}, and xi+2x_{i+2} for (8) to work.

refs

Tags: