A comprehensive C++ application for numerical integration with multiple methods, detailed step-by-step calculations, and comparison capabilities.
- Numerical Integration Calculator
- Multiple Integration Methods: Includes Trapezoidal Rule, Simpson's Rules, Boole's Rule, and Romberg Integration
- Step-by-Step Calculation Display: See how each method works with detailed intermediate steps
- Method Comparison: Compare the accuracy and results of different integration methods
- Multiple Functions: Choose from a variety of predefined mathematical functions
- Result Storage: Save integration results to files and load them later
- Cross-Platform: Works on Windows, macOS, and Linux
- User-Friendly Interface: Clear console-based interface with easy navigation
-
Trapezoidal Rule: Uses linear approximation between points
- Formula:
h/2 * [f(a) + f(b) + 2 * sum(f(x_i))]
- Formula:
-
Simpson's 1/3 Rule: Uses quadratic approximation
- Formula:
h/3 * [f(a) + f(b) + 4 * sum(f(x_odd)) + 2 * sum(f(x_even))] - Requires an even number of intervals
- Formula:
-
Simpson's 3/8 Rule: Uses cubic approximation
- Formula:
3h/8 * [f(a) + f(b) + 3 * sum(f(not divisible by 3)) + 2 * sum(f(divisible by 3))] - Requires a number of intervals divisible by 3
- Formula:
-
Boole's Rule: Uses fourth-degree polynomial approximation
- Formula:
4h/90 * [7(f(a) + f(b)) + 32(f(x1) + f(x3) + ...) + 12(f(x2) + f(x6) + ...) + 14(f(x4) + f(x8) + ...)] - Requires a number of intervals divisible by 4
- Formula:
-
Romberg Integration: Uses Richardson extrapolation to improve accuracy
- Highly accurate for smooth functions
- Adjustable order for precision control
- C++17 compatible compiler (GCC 7+, Clang 5+, MSVC 19.14+)
- CMake 3.10 or higher (for building from source)
- Git (optional, for cloning the repository)
-
Clone the repository:
git clone https://github.com/prathameshkhade/Numerical-Integration.git cd Numerical-Integration -
Create a build directory and navigate to it:
mkdir build cd build -
Configure with CMake and build:
cmake .. cmake --build . -
Run the executable:
- Windows:
.\Debug\NumericalIntegration.exeor.\Release\NumericalIntegration.exe - macOS/Linux:
./NumericalIntegration
- Windows:
Pre-built binaries for Windows, macOS, and Linux are available in the Releases section.
- Start the application
- Select "Perform Integration" from the main menu
- Choose a function to integrate
- Enter the lower and upper bounds of integration
- Specify the number of intervals
- Select an integration method
- View the result and step-by-step calculation
- Trapezoidal Rule: Good general-purpose method, works with any number of intervals
- Simpson's 1/3 Rule: Better accuracy than Trapezoidal for most functions, requires even number of intervals
- Simpson's 3/8 Rule: Similar accuracy to 1/3 rule, requires intervals divisible by 3
- Boole's Rule: Higher accuracy for smooth functions, requires intervals divisible by 4
- Romberg Integration: Highest accuracy, especially for smooth functions
- Select "Compare All Integration Methods" from the main menu
- Enter integration parameters (function, bounds, intervals)
- The program will calculate the integral using all available methods
- Results are displayed in a comparison table with error estimates
- After performing an integration, you can save the result to a file
- Use "Load Previous Results" to view previously saved results
- Result files include all parameters and intermediate values
Numerical integration methods approximate definite integrals using various techniques:
- Trapezoidal Rule: Approximates the area under the curve using trapezoids
- Simpson's Rules: Use quadratic (1/3) or cubic (3/8) polynomials to approximate the function
- Boole's Rule: Uses fourth-degree polynomials for higher accuracy
- Romberg Integration: Applies Richardson extrapolation to the trapezoidal rule
For a function f(x) and an interval [a, b], the definite integral is approximated by dividing the interval into n subintervals and applying the specific formula for each method.
numerical-integration/
βββ include/ # Header files
β βββ function.h # Mathematical function definitions
β βββ input.h # Input handling class
β βββ integrator.h # Base integrator class
β βββ methods/ # Integration methods
β β βββ trapezoidal.h
β β βββ simpson13.h
β β βββ simpson38.h
β β βββ boole.h
β β βββ romberg.h
β βββ utils.h # Utility functions
βββ src/ # Implementation files
β βββ function.cpp
β βββ input.cpp
β βββ integrator.cpp
β βββ methods/
β β βββ trapezoidal.cpp
β β βββ simpson13.cpp
β β βββ simpson38.cpp
β β βββ boole.cpp
β β βββ romberg.cpp
β βββ utils.cpp
β βββ main.cpp # Program entry point
βββ CMakeLists.txt # CMake build configuration
βββ LICENSE # License file
βββ README.md # This file
- Open Visual Studio
- Select "Open a local folder" and navigate to the repository
- Visual Studio should detect the CMakeLists.txt and configure the project
- Build using Build > Build All
- Run the executable from the output directory
- Open Command Prompt or PowerShell
- Navigate to the project directory
- Create and navigate to a build directory:
mkdir build cd build
- Configure and build with CMake:
cmake .. cmake --build . --config Release
- Run the executable:
.\Release\NumericalIntegration.exe
- Open Terminal
- Navigate to the project directory
- Create and navigate to a build directory:
mkdir build cd build - Configure and build with CMake:
cmake .. make
- Run the executable:
./NumericalIntegration
- Open a terminal
- Navigate to the project directory
- Create and navigate to a build directory:
mkdir build cd build - Configure and build with CMake:
cmake .. make
- Run the executable:
./NumericalIntegration
Contributions are welcome! Here's how you can contribute:
- Fork the repository
- Create a new branch (
git checkout -b feature/amazing-feature) - Make your changes
- Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Please ensure your code follows the project's coding style and includes appropriate tests.
- Complete rewrite with modular C++ design
- Added new integration methods (Boole's Rule, Romberg Integration)
- Improved error handling and robustness
- Added method comparison functionality
- Added support for saving/loading results
- Cross-platform compatibility improvements
- Comprehensive documentation
- Basic implementation with Trapezoidal, Simpson's 1/3, and Simpson's 3/8 rules
- Console-based interface
- Step-by-step calculation display
This project is licensed under the MIT License - see the LICENSE file for details.
- Prathamesh Khade - GitHub
If you find this project useful, please consider giving it a star on GitHub!