This program computes the definite integral of the function f(x) = x7 on the interval [0, 1] using five composite quadrature formulas:
- Rectangle rule (midpoint)
- Trapezoidal rule
- Simpson's rule
- Newton–Cotes (5‑point)
- Gauss–Legendre (3‑point)
The calculations are performed for two partitions: with K intervals and with 2K intervals. Relative errors are computed and displayed in a table.
- C++ compiler with C++17 support (e.g., g++, clang++)
- GNU Make
git clone <your-repo-url>
cd <project-folder>
make # compile the program
make run # compile and run
Alternatively:
make
./num_integ
To clean up:
make clean
After running ./num_integ, the console shows:
Table of relative errors –––––––––––––––––––––––––––––––––––––––––––– | | K | 2 * K | –––––––––––––––––––––––––––––––––––––––––––– | Rectangle | 1.234e-03 | 3.086e-04 | –––––––––––––––––––––––––––––––––––––––––––– | Trapezoid | 2.468e-03 | 6.172e-04 | –––––––––––––––––––––––––––––––––––––––––––– | Simpson | 1.524e-06 | 9.527e-08 | –––––––––––––––––––––––––––––––––––––––––––– | Newton-Kotes | 1.234e-08 | 1.929e-10 | –––––––––––––––––––––––––––––––––––––––––––– | Gauss | 1.234e-08 | 1.929e-10 | ––––––––––––––––––––––––––––––––––––––––––––
(The exact values depend on the chosen function f(x) and the integration limits.)
. ├── Makefile ├── README.md ├── .gitignore ├── LICENSE ├── src/ │ ├── main.cpp │ ├── functions.cpp │ └── functions.h └── build/ # object files (ignored)
Name: Philip Karev @g30613740
Year: 2024
This project is distributed under the MIT License.