# 📊 Numerical Analysis using C and MATLAB
Welcome to the **Numerical Analysis** repository! This project contains implementations of various **numerical analysis algorithms** in **C** and **MATLAB**. These methods are fundamental for solving numerical problems like root-finding, interpolation, differentiation, integration, and solving linear systems.
---
## 🚀 **Features**
- ⚙️ Numerical methods implemented in **C** and **MATLAB**.
- 🧮 Algorithms for:
- Root finding (e.g., Bisection, Newton-Raphson).
- Interpolation and polynomial approximations.
- Numerical integration and differentiation.
- Solving linear and non-linear systems.
- 📈 MATLAB scripts for data visualization.
- 💻 Optimized C programs for efficient computation.
---
## 🛠️ **Technologies Used**
- **C Programming Language** (for performance and precision)
- **MATLAB** (for visualization and high-level numerical computing)
---
## 💻 **Setup and Installation**
### **C Programs**
1. **Compile the programs** using a C compiler like `gcc`:
```bash
gcc bisection_method.c -o bisection
./bisection
- Input the required parameters (equation, intervals, tolerance).
- Open the
.m
files in MATLAB or MATLAB Online. - Run the scripts by pressing Run or typing in the Command Window:
bisection_method
- Bisection Method
- Newton-Raphson Method
- Secant Method
- Lagrange Interpolation
- Newton's Divided Difference
- Trapezoidal Rule
- Simpson's 1/3 Rule
- Gaussian Elimination
- LU Decomposition
#include <stdio.h>
#include <math.h>
double func(double x) {
return x*x - 4; // Example function: x^2 - 4 = 0
}
int main() {
double a = 0, b = 3, tol = 0.001, c;
while ((b - a) >= tol) {
c = (a + b) / 2;
if (func(c) == 0.0)
break;
else if (func(c) * func(a) < 0)
b = c;
else
a = c;
}
printf("Root: %.5f\n", c);
return 0;
}
f = @(x) x^2 - 4; % Function definition
df = @(x) 2*x; % Derivative of the function
x0 = 2; % Initial guess
tol = 1e-6; % Tolerance
max_iter = 100;
for i = 1:max_iter
x1 = x0 - f(x0)/df(x0); % Newton-Raphson formula
if abs(x1 - x0) < tol
fprintf('Root: %.5f\n', x1);
break;
end
x0 = x1;
end
Contributions are welcome! Follow these steps:
- Fork the repository.
- Clone your fork:
git clone https://github.com/your-username/Numerical-Analysis.git
- Create a new branch:
git checkout -b feature-branch
- Add your code and commit:
git add . git commit -m "Add feature: feature description"
- Push the changes and create a pull request:
git push origin feature-branch
This project is licensed under the MIT License. See the LICENSE file for more details.
For any queries or suggestions, feel free to reach out:
- Md Emon Hasan
- 📧 Email: iconiemon01@gmail.com
- 🌐 GitHub: Md-Emon-Hasan
If you find this repository helpful, give it a ⭐ and share it with your peers!
Happy Coding! 🎉
---
### **Key Additions:**
1. Updated **features** and structure for C and MATLAB.
2. Added **C program** and **MATLAB script** examples for better understanding.
3. Included **usage instructions** and **visualization placeholders**.
4. A clear **folder structure** is outlined for easy navigation.
Let me know if you'd like further customization! 🚀