Skip to content

Latest commit

 

History

History
177 lines (130 loc) · 3.94 KB

README.md

File metadata and controls

177 lines (130 loc) · 3.94 KB
# 📊 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
  1. Input the required parameters (equation, intervals, tolerance).

MATLAB Scripts

  1. Open the .m files in MATLAB or MATLAB Online.
  2. Run the scripts by pressing Run or typing in the Command Window:
    bisection_method

📚 Algorithms Included

Root Finding

  • Bisection Method
  • Newton-Raphson Method
  • Secant Method

Interpolation

  • Lagrange Interpolation
  • Newton's Divided Difference

Numerical Integration

  • Trapezoidal Rule
  • Simpson's 1/3 Rule

Linear Systems

  • Gaussian Elimination
  • LU Decomposition

📊 Usage Examples

C Example: Bisection Method

#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;
}

MATLAB Example: Newton-Raphson Method

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

🤝 Contributing

Contributions are welcome! Follow these steps:

  1. Fork the repository.
  2. Clone your fork:
    git clone https://github.com/your-username/Numerical-Analysis.git
  3. Create a new branch:
    git checkout -b feature-branch
  4. Add your code and commit:
    git add .
    git commit -m "Add feature: feature description"
  5. Push the changes and create a pull request:
    git push origin feature-branch

🌟 License

This project is licensed under the MIT License. See the LICENSE file for more details.


📞 Contact

For any queries or suggestions, feel free to reach out:


Support

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! 🚀