× back

Numerical Integration

Trapezoidal Rule

Q1- Using Trapezoidal rule, calculate the value of integral ∫ logx dx given that:

x      4.0     4.2     4.4     4.6     4.8     5.0     5.2
y   1.3863  1.4251  1.4816  1.5260  1.5686  1.6094  1.6486
            

Solution:

  • x0 = 4.0 which is the first value of x and x6 = 5.2 which is last value of x
    These becomes upper and lower limit of ∫logx dx
  • Calculate y which equal to logx and which is already given in that question
    x0 = 4.0 and y0 = 1.3863
    x1 = 4.2 and y1 = 1.4351
    x2 = 4.4 and y2 = 1.4816
    x3 = 4.6 and y3 - 1.5266
    x4 = 4.8 and y4 = 1.5686
    x5 = 5.0 and y5 = 1.6094
    x6 = 5.2 and y6 = 1.6486
                        
  • Trapezoidal Rule Formula:
    ∫ f(x) dx = h 2 [(y0 + y6) + 2 (y1 + y2 + ... + y5)]
    ∫ f(x) dx = h 2 [(first y value + last y value) + 2 (remaining y value in between first and last)]
    h is the difference between two x , 4.2 - 4.0 = 0.2
    ∫ logx dx = 0.2 2 [(1.3863 + 1.6486) + 2 (1.4351 + 1.4816 + 1.5266 + 1.5686 + 1.6094)]
    ∫ logx dx = 0.1[(3.0349) + 2 (7.6213)]
    ∫ logx dx = 0.1[3.0349 + 15.2426]
    ∫ logx dx = 0.1[18.2775]
    ∫ logx dx = 1.8278 (answer)

Q2- \( \int_{0}^{6} \frac{1}{1+x^2} \) using Trapezoidal rule.

Solution:

  • x0 = 0 and xn = 6
    Now for h we can assume it whatever like 1, 2 etc. or we can calculate it by assuming n
    as x0 + nh = xn
    0 + nh = 6
    taking n = 6
    h = 1
  • Now create the table
    x1 = x0 + h
    y0 = \(\frac{1}{1+x0^2}\)
    x0 = 0 and y0 = 1
    x1 = 1 and y1 = 0.5
    x2 = 2 and y2 = 0.2
    x3 = 3 and y3 = 0.1
    x4 = 4 and y4 = 0.0588
    x5 = 5 and y5 = 0.0385
    x6 = 6 and y6 = 0.0270
                        
  • Now putting values into the formula:
    ∫ f(x) dx = h 2 [(y0 + y6) + 2 (y1 + y2 + ... + y5)]
    \( \int_{0}^{6} \frac{1}{1+x^2}\ dx \) = h 2 [(1 + 0.0270) + 2 (0.5 + 0.2 + 0.1 + 0.0588 + 0.0385)]
    \( \int_{0}^{6} \frac{1}{1+x^2}\ dx \) = h 2 [(1.0270) + 2 (0.8973)]
    \( \int_{0}^{6} \frac{1}{1+x^2}\ dx \) = h 2 [(1.0270) + 1.7946]
    \( \int_{0}^{6} \frac{1}{1+x^2}\ dx \) = 1 2 [2.8216]
    \( \int_{0}^{6} \frac{1}{1+x^2}\ dx \) = 0.5 * 2.8216
    \( \int_{0}^{6} \frac{1}{1+x^2}\ dx \) = 1.4108 (answer)

Q3 - \( \int_{0}^{1} \frac{1}{1+x^2}\ dx \) taking h = 1/4 by Trapezoidal rule

Solution:

  • x0 = 0 and xn = 1
    h = 0.25
  • Now we know that xn = xn-1 + h
    x1 = x0 + h
    y0 = \(\frac{1}{1+x0^2}\) , so using this we can create the table
    x0 = 0      and y0 = 1
    x1 = 0.25   and y1 = 0.9412
    x2 = 0.5    and y2 = 0.8
    x3 = 0.75   and y3 = 0.64
    x4 = 1      and y4 = 0.5
                
  • Now putting values into the formula:
    ∫ f(x) dx = h 2 [(y0 + y6) + 2 (y1 + y2 + ... + y5)]
    \( \int_{0}^{6} \frac{1}{1+x^2}\ dx \) = h 2 [(1 + 0.5) + 2 (0.9412 + 0.8 + 0.64)]
    \( \int_{0}^{6} \frac{1}{1+x^2}\ dx \) = h 2 [(1.5) + 2 (2.3812)]
    \( \int_{0}^{6} \frac{1}{1+x^2}\ dx \) = h 2 [1.5 + 4.7624]
    \( \int_{0}^{6} \frac{1}{1+x^2}\ dx \) = 0.25 2 [6.2624]
    \( \int_{0}^{6} \frac{1}{1+x^2}\ dx \) = 0.125 * 6.2624
    \( \int_{0}^{6} \frac{1}{1+x^2}\ dx \) = 0.7828 (answer)

Q4- Using Trapezoidal Rule evaluate \( \int_{0}^{1} x^3 dx \) & taking 5 sub intervals.

Solution:

  • As sub intervals is given as 5 so n = 5
    x0 = 0 and xn = 1
    h = xn - x0 / n
    h = 1/5
    h = 0.2
  • x1 = x0 + h
    y0 = \( \int_{0}^{1} x^3 dx \)
    x0 = 0   and y0 = 0
    x1 = 0.2 and y1 = 0.008
    x2 = 0.4 and y2 = 0.064
    x3 = 0.6 and y3 = 0.216
    x4 = 0.8 and y4 = 0.512
    x5 = 1   and y5 = 1
                                
  • Formula:
    ∫ f(x) dx = h 2 [(y0 + y6) + 2 (y1 + y2 + ... + y5)]
    \( \int_{0}^{1} x^3 dx \) = h 2 [(0 + 1) + 2 (0.008 + 0.064 + 0.216 + 0.512)]
    \( \int_{0}^{1} x^3 dx \) = h 2 [1 + 2 (0.8)]
    \( \int_{0}^{1} x^3 dx \) = h 2 [1 + 1.6]
    \( \int_{0}^{1} x^3 dx \) = 0.2 2 [2.6]
    \( \int_{0}^{1} x^3 dx \) = 0.1 * 2.6
    \( \int_{0}^{1} x^3 dx \) = 0.26 (answer)

Simpson's 1/3rd Rule

Q1- Using Simpson's 1/3rd Rule, calculate the value of integral \( \int_{0}^{1} \frac{1}{1+x^2}\ dx \) and h = 1/4

Solution:

  • h = 0.25
  • x1 = x0 + h
    y0 = \(\frac{1}{1+x0^2}\)
    x0 = 0    and y0 = 1
    x1 = 0.25 and y1 = 0.9412
    x2 = 0.5  and y2 = 0.8
    x3 = 0.75 and y3 = 0.64
    x4 = 1    and y4 = 0.5
                            
  • Formula:
    ∫ f(x) dx = h 3 [(y0 + y4) + 4 (y1 + y3) + 2(y2)]
    ∫ f(x) dx = h 3 [(sum of first and last y) + 4 (sum of odd y) + 2(sum of even y)]
    \( \int_{0}^{1} \frac{1}{1+x^2}\ dx \) = 0.25 3 [(1 + 0.5) + 4(0.9412 + 0.64) + 2(0.8)]
    \( \int_{0}^{1} \frac{1}{1+x^2}\ dx \) = 0.7860 (approx)

Q2- Evaluate \( \int_{0}^{1} e^{-x^2} \, dx \) by Simpson's 1/3rd Rule.

  • x0 = 0 and xn = 1
    taking n = 4 (we try to take even sub intervals)
    x0 + nh = xn
    0 + 4h = 1
    h = 0.25
  • x1 = x0 + h
    y0 = \( \int_{0}^{1} e^{-x0^2} \, dx \)
    x0 = 0    and y0 = 1
    x1 = 0.25 and y1 = 0.9394
    x2 = 0.5  and y2 = 0.7788
    x3 = 0.75 and y3 = 0.5697
    x4 = 1    and y4 = 0.3679
                            
  • \( \int_{0}^{1} e^{-x^2} \, dx \) = 0.25 3 [(1 + 0.3679) + 4(0.9394 + 0.5697) + 2(0.7788)]
    \( \int_{0}^{1} e^{-x^2} \, dx \) = 0.7468 (approx)

Q3- Evaluate \( \int_{1}^{2} e^{x^3} \, dx \) by Simpson's 1/3rd Rule.

Simpson's 3/8th Rule

Q1- Using Simpson's 3/8th Rule, calculate the value of integral \(\int_{0}^{6} \frac{1}{1+x^2}\ dx\)

Solution:

  • x0 = 0 and xn = 6
    x0 + nh = 6
    taking n = 6
    0 + 6h = 6
    h = 1
  • x1 = x0 + h
    y0 = \( \frac{1}{1+x0^2}\ \)
    x0 = 0 and y0 = 1
    x1 = 1 and y1 = 0.5
    x2 = 2 and y2 = 0.2
    x3 = 3 and y3 = 0.1
    x4 = 4 and y4 = 0.0588
    x5 = 5 and y3 = 0.0385
    x6 = 6 and y4 = 0.027
                            
  • Formula:
    ∫ f(x) dx = 3h 8 [(y0 + y6) + 2(y3+...) + 3(y1 + y2 + y4 + y5 + ...)]
    ∫ f(x) dx = 3h 8 [(sum of first and last y) + 2(y, which are multiple of 3) + 3(rest of y)]
    \( \int_{0}^{6} \frac{1}{1+x^2}\ dx \) = 3 8 [(1 + 0.027) + 2(0.1) + 3(0.5 + 0.2 + 0.0588 + 0.0385)]
    \( \int_{0}^{6} \frac{1}{1+x^2}\ dx \) = 1.3571 (approx)

Q2- Using Simpson's 3/8th Rule, calculate the value of integral \( \int_{0}^{3} \frac{1}{1+x^5}\ dx \) and n = 6

Solution:

  • x0 = 0 and xn = 3
    x0 + nh = 3
    0 + 6h = 3
    h = 0.5
  • x1 = x0 + h
    y0 = \(\frac{1}{1+x0^2}\)
    x0 = 0   and y0 = 1
    x1 = 0.5 and y1 = 0.9697
    x2 = 1   and y2 = 0.5
    x3 = 1.5 and y3 = 0.11636
    x4 = 2   and y4 = 0.03031
    x5 = 2.5 and y3 = 0.01014
    x6 = 3   and y4 = 0.00410
                            
  • \( \int_{0}^{3} \frac{1}{1+x^5}\ dx \) = 3*05 8 [(1 + 0.00410) + 2(0.11636) + 3(1.5102)]
    \( \int_{0}^{3} \frac{1}{1+x^5}\ dx \) = 1.0814 (approx)

Boole's Rule

Formula:

\( \int_{x0}^{xn} f(x) dx \) = 2h 45 [(7y0 + 32y1 + 12y2 + 32y3 + 7y4 + 7y4 + 32y5 + 12 y6 + ....)]

7 - 32 - 12 - 32 - 7 again repeat
y4 is repeated twice because this method works with instance of 4

Q- Evaluate \( \int_{0}^{4} \frac{1}{1+x^2}\ dx \) using Boole's Rule taking h = 0.5

  • x0 = 0   and y0 = 1
    x1 = 0.5 and y1 = 0.8
    x2 = 1   and y2 = 0.5
    x3 = 1.5 and y3 = 0.3077
    x4 = 2   and y4 = 0.2
    x5 = 2.5 and y3 = 0.1379
    x6 = 3   and y4 = 0.1
    x7 = 3.5 and y3 = 0.0755
    x8 = 4   and y4 = 0.0588
                                    
  • \( \int_{0}^{4} \frac{1}{1+x^2}\ dx \) = 2 * 0.5 45 [7(1) + 32(0.8) + 12(0.5) + 32(0.3077) + 7(0.2) + 7(0.2) + 32(0.1379) + 12(0.1) + 32(0.0755) + 7(0.0588)]
    \( \int_{0}^{4} \frac{1}{1+x^2}\ dx \) = 1.3250

Weedle's Rule

Note:

Formula:\( \int_{x0}^{xn} f(x) dx \) = 3h 10 [1(y0) + 5(y1) + 1(y2) + 6(y3) + 1(y4) + 5(y5) + 1(y6)]
the sequence goes like: 1,5,1,6,1,5,1,5,1,6,1,5,2,5,1,6,1,5

Reference