https://github.com/adisen99/numerical-integration
Python and MATLAB code to find the definite integral of a user-defined function within given limits and defined iterations.
https://github.com/adisen99/numerical-integration
integration monte-carlo-integration numerical-analysis numerical-integration numerical-methods simpsons trapezoidal
Last synced: 11 months ago
JSON representation
Python and MATLAB code to find the definite integral of a user-defined function within given limits and defined iterations.
- Host: GitHub
- URL: https://github.com/adisen99/numerical-integration
- Owner: adisen99
- License: mit
- Created: 2020-04-03T05:04:09.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-09-24T03:57:28.000Z (over 5 years ago)
- Last Synced: 2025-05-19T17:15:48.864Z (about 1 year ago)
- Topics: integration, monte-carlo-integration, numerical-analysis, numerical-integration, numerical-methods, simpsons, trapezoidal
- Language: Python
- Homepage:
- Size: 26.4 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Numerical-Integration
Python and MATLAB code to find the definite integral of a user-defined function within given limits and defined iterations.
_______________________________________________________________________________________________________________________________
### Included files
There are in total 4 files in the repository, each following a different algorithms, namely **Monte Carlo**, **Trapezoidal** Rule and the **two Simpson's Rules**. Code for the **Legendre-Gauss Quadrature formula** will be added soon. Each folder contains **MATLAB or .m** and **Python or .py**. So you can use either syntax and program/language to numerically determine the roots of an equation/function using the given Methods or algorithms.
To access the files you can either Download the zip file or use the following command from your terminal
``
git clone https://github.com/adisen99/Numerical-Integration.git
``
then
``
cd Numerical-Integration
``
### Note-
Then you can access the `.py files` or `.m` files depending on the program you wish to run. Please note than **Simpson's3** is the **Simpson's 1/3** and the **Simpson's8** is the **Simpson's 3/8** rule. The **Simpson's3** folder contains two MATLAB files one of which has a much simpler algorithm as compared to the other more difficult one. Also the **Trapezoidal_Rule** folder contains two MATLAB and two Python files. One set is marked as easy and thus has a much easier algorithm, however the user can choose to run the more complex ones.
## Dependencies for Python -
This program uses the following libraries as dependencies-
* Matplotlib
* NumPy
* SciPy
* Code2pdf (Optional, only to get your code as a pdf file)
### Installing dependencies/packages
* For Windows/Linux/Mac users
You can install these libraries using ``pip`` (if you have a virtual environment created and only want to install the libraries for that particular file/directory)
``
pip install
``
or Alternatively you can install using pip for your own user system-wide
``
python -m pip install --user
``
or you could use ``conda`` (if you are using Anaconda IDE)
``
conda install
``
or (If you are using a Linux distribution) then you can simply use you distro's package manager to install the packages (but it will install the packages system wide)
* For Debian/Ubuntu users-
``
sudo apt install python-
``
* For Fedora users-
``
sudo dnf install numpy scipy python-matplotlib
``
* For Arch users-
``
sudo pacman -S python-
``
or
``
yay -S python-
``
Most python packages are in the ArchLinux repositories and the packages that are not are in AUR (ArchLinux User Repositories) - for these packages you have to download the PKGBUILD file and compile. After that, you have to use PACMAN to finish the installation
``
makepkg -s
``
``
sudo pacman -U 'compiled-package'
``
* For Mac users-
Mac doesn’t have a preinstalled package manager, but there are a couple of popular package managers you can install. For Python 3.5 with Macports , execute this command in a terminal:
``
sudo port install py35-numpy py35-scipy py35-matplotlib
``
or Alternatively [Homebrew](https://brew.sh) has an incomplete coverage of the SciPy ecosystem, but does install these packages:
``
brew install numpy scipy matplotlib ipython jupyter
``
#### All the instructions related to the code are given in the code as Comments.
## Happy Coding
_______________________________________________________________________________________________________________________________