Numerical Integration Methods | Trapezoidal to Weddle’s Rules
Numerical Methods - Integration Rules

Lab 5: Numerical Integration Methods

Lab 5: Numerical Integration Methods – Trapezoidal to Weddle’s Rules

Experiment Information

Experiment: Numerical Integration Methods (Trapezoidal, Simpson’s, Boole’s, Weddle’s Rules)

Course Code: Numerical Methods

Description: Complete lab report covering theory, algorithms, Python implementations for both function and tabular data integration

Complete Lab Report PDF

1. Theory of Numerical Integration

1.1 Trapezoidal rule derivation

1.2 Simpson’s 1/3 and 3/8 rules

1.3 Boole’s and Weddle’s rules

1.4 Error analysis and comparisons

2. Algorithms

2.1 Step-by-step procedures for each method

2.2 Conditions for applicability

2.3 Computational complexity

3. Implementation

3.1 Python code for function integration

3.2 Python code for tabular data integration

3.3 Input/output specifications

4. Observations

4.1 Data recording tables

4.2 Sample calculations

4.3 Accuracy comparisons

5. Results

5.1 Integral approximations

5.2 Error analysis

5.3 Convergence rates

6. Discussion

6.1 Advantages and limitations of each method

6.2 Practical applications in engineering

6.3 Recommendations for method selection

Python Implementation for Function Integration

numerical_integration_function.py
import math def F(x): return x**2 a,b,n=1,5,12 def sim3by8(F,a,b,n): if n%3!=0: return None h=(b-a)/n result =0.0 for i in range (0,n,3): x0=a+i*h x1=x0+h x2=x1+h x3=x2+h result +=F(x0)+3*F(x1)+3*F(x2)+F(x3) result*=3*h/8 return result def sim1by3(F,a,b,n): if n%2!=0: return None h=(b-a)/n result =0.0 for i in range (0,n,2): x0=a+i*h x1=x0+h x2=x1+h result +=F(x0)+4*F(x1)+F(x2) result*=h/3 return result def Bool(F,a,b,n): if n%4!=0: return None h=(b-a)/n result =0.0 for i in range (0,n,4): x0=a+i*h x1=x0+h x2=x1+h x3=x2+h x4=x3+h result +=7*F(x0)+32*F(x1)+12*F(x2)+32*F(x3)+7*F(x4) result*=2*h/45 return result def weddle(F,a,b,n): if n%6!=0: return None h=(b-a)/n result =0.0 for i in range (0,n,6): x0=a+i*h x1=x0+h x2=x1+h x3=x2+h x4=x3+h x5=x4+h x6=x5+h result +=F(x0)+5*F(x1)+F(x2)+6*F(x3)+F(x4)+5*F(x5)+F(x6) result*=3*h/10 return result def Trap(F,a,b,n): h=(b-a)/n result =0.0 for i in range (0,n): x0=a+i*h x1=x0+h result +=F(x0)+F(x1) result*=h/2 return result print(“Trapezoidal Rule: “,Trap(F,a,b,n)) print(“Simpson’s 1/3 Rule: “, sim1by3(F,a,b,n)) print(“Simpson’s 3/8 Rule: “, sim3by8(F,a,b,n)) print(“Boole’s Rule: “, Bool(F,a,b,n)) print(“Weddle’s Rule: “,weddle(F,a,b,n))

Python Implementation for Tabular Data Integration

numerical_integration_tabular.py
from math import * x=[1,2,3,4,5,6,7,8,9,10,11,12,13] y=[1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169] n = len(y) – 1 def sim3by8(y, h): if n % 3 != 0: return None result = 0.0 for i in range(0, n, 3): result += y[i] + 3 * y[i+1] + 3 * y[i+2] + y[i+3] result *= 3 * h / 8 return result def sim1by3(y, h): if n % 2 != 0: return None result = 0.0 for i in range(0, n, 2): result += y[i] + 4 * y[i+1] + y[i+2] result *= h / 3 return result def Bool(y, h): if n % 4 != 0: return None result = 0.0 for i in range(0, n, 4): result += 7 * y[i] + 32 * y[i+1] + 12 * y[i+2] + 32 * y[i+3] + 7 * y[i+4] result *= 2 * h / 45 return result def weddle(y, h): if n % 6 != 0: return None result = 0.0 for i in range(0, n, 6): result += y[i] + 5 * y[i+1] + y[i+2] + 6 * y[i+3] + y[i+4] + 5 * y[i+5] + y[i+6] result *= 3 * h / 10 return result def Trap(y, h): result = 0.0 for i in range(0, n, 1): result += y[i]+y[i+1] result *= h / 2 return result h = x[1] – x[0] print(“Trapezoidal Rule: “, Trap(y, h)) print(“Simpson’s 1/3 Rule: “, sim1by3(y, h)) print(“Simpson’s 3/8 Rule: “, sim3by8(y, h)) print(“Boole’s Rule: “, Bool(y, h)) print(“Weddle’s Rule: “, weddle(y, h))
×

Disclaimer

The educational materials provided on this website are intended as supplementary resources to support your learning journey. These lab reports are sample documents designed to help students understand proper formatting and content organization.

We have made every effort to ensure the accuracy of the content. However, we recommend students to perform their own experiments and prepare original reports. These samples should be used as references only.

We respect intellectual property rights. If you believe any content should be credited differently or removed, please don’t hesitate to contact us. We’re happy to make appropriate corrections or give proper attribution.

Leave a Comment

Scroll to Top