Skip to content

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Numerical Integration

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.

Requirements

  • C++ compiler with C++17 support (e.g., g++, clang++)
  • GNU Make

Quick Start


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

Example Output

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.)

Project Structure

.
├── Makefile
├── README.md
├── .gitignore
├── LICENSE
├── src/
│   ├── main.cpp
│   ├── functions.cpp
│   └── functions.h
└── build/                  # object files (ignored)

Author

Name: Philip Karev @g30613740

Year: 2024

License

This project is distributed under the MIT License.

About

Composite quadrature (rectangle, trapezoidal, Simpson's, Newton–Cotes, Gauss–Legendre) with relative error analysis.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages