Skip to content

Numerical Application - My Part ๐Ÿงฎ A Java-based numerical computation tool implementing matrix operations, root-finding methods, differential equations, and iterative solutions. ๐Ÿš€

Notifications You must be signed in to change notification settings

Mehedi-86/Numerical_Application-My_Part

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

11 Commits
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ“Œ Numerical Methods in C++

This project implements various Numerical Methods using C++. The implemented methods include:

  • Jacobi Iterative Method
  • Gauss-Seidel Iterative Method
  • Gauss Elimination Method
  • Gauss-Jordan Elimination
  • LU Factorization
  • Root Finding Methods (Bi-section, False Position, Secant, Newton-Raphson)
  • Runge-Kutta Method (Solving Differential Equations)
  • Matrix Inversion

๐Ÿ“‚ File Structure

๐Ÿ“ Numerical_Methods/
โ”‚โ”€โ”€ ๐Ÿ“„ main.cpp        # Main entry point
โ”‚โ”€โ”€ ๐Ÿ“„ 2107100.hpp     # Header file 1
โ”‚โ”€โ”€ ๐Ÿ“„ 2107086.hpp     # Header file 2
โ”‚โ”€โ”€ ๐Ÿ“„ 2107102.hpp     # Header file 3
โ”‚โ”€โ”€ ๐Ÿ“„ README.md       # Documentation

๐Ÿš€ How to Run the Program

๐Ÿ”น Prerequisites

  • A C++ compiler (g++ recommended)
  • Basic understanding of numerical methods

๐Ÿ”น Compilation Steps

  1. Open a terminal and navigate to the project directory:
    cd path/to/Numerical_Methods
  2. Compile the program:
    g++ -o numerical_methods main.cpp -std=c++11
  3. Run the compiled program:
    ./numerical_methods

๐Ÿ”น Jacobi Iterative Method

The Jacobi Method is an iterative algorithm used to solve systems of linear equations. It starts with an initial guess and iteratively updates the solution using:

[ x_i^{(k+1)} = \frac{b_i - \sum_{j \neq i} a_{ij} x_j^{(k)}}{a_{ii}} ]

โœ… Advantages:

  • Works well for diagonally dominant matrices.
  • Parallelizable, as updates donโ€™t depend on previous iterations.

โŒ Disadvantages:

  • Slow convergence for large matrices.
  • Might not converge if the matrix is not diagonally dominant.

๐Ÿ”น Gauss-Seidel Iterative Method

An improvement over the Jacobi method. It updates each variable immediately, using the latest computed values:

[ x_i^{(k+1)} = \frac{b_i - \sum_{j < i} a_{ij} x_j^{(k+1)} - \sum_{j > i} a_{ij} x_j^{(k)}}{a_{ii}} ]

โœ… Advantages:

  • Faster convergence than Jacobi.
  • Uses previously updated values, improving accuracy.

โŒ Disadvantages:

  • Sequential, so harder to parallelize.
  • Might not converge for non-diagonally dominant matrices.

๐Ÿ”น Gauss Elimination Method

A direct method that systematically eliminates variables to solve linear equations using row operations.

Steps:

1๏ธโƒฃ Convert the system into Upper Triangular Form.
2๏ธโƒฃ Perform back-substitution to get the solution.

โœ… Advantages:

  • Efficient for small to medium-sized systems.
  • Works for any square system.

โŒ Disadvantages:

  • Computationally expensive (O(n^3)) for large matrices.
  • Prone to numerical instability.

๐Ÿ”น Gauss-Jordan Elimination

An extension of Gauss Elimination, where the system is transformed into Reduced Row Echelon Form (RREF).

Steps:

1๏ธโƒฃ Convert the matrix into an identity matrix.
2๏ธโƒฃ The remaining matrix contains the solution.

โœ… Advantages:

  • Finds exact solution directly.
  • Can be used for matrix inversion.

โŒ Disadvantages:

  • More computationally expensive than Gauss Elimination.
  • Not practical for very large systems.

๐Ÿ”น LU Factorization

Decomposes a matrix A into lower (L) and upper (U) triangular matrices, where:

[ A = LU ]

Steps:

1๏ธโƒฃ Solve Ly = b using forward substitution.
2๏ธโƒฃ Solve Ux = y using back substitution.

โœ… Advantages:

  • Efficient for multiple linear systems with the same A but different b.
  • Reduces computational complexity.

โŒ Disadvantages:

  • Requires matrix decomposition, which adds overhead.
  • Not always stable for ill-conditioned matrices.

๐Ÿ”น Root Finding Methods

Finding the roots of a function ( f(x) = 0 ) is essential in numerical methods.

1๏ธโƒฃ Bi-Section Method

  • Bracket-based method: Requires two points where ( f(a) \cdot f(b) < 0 ).
  • Repeatedly halves the interval until the root is found.

โœ… Always converges, but slow.

2๏ธโƒฃ False Position (Regula Falsi)

  • Uses linear interpolation to approximate the root.

โœ… Faster than Bi-section, but may converge slowly for some functions.

3๏ธโƒฃ Secant Method

  • Uses two previous points to approximate the derivative.

โœ… No need for derivative calculations.

4๏ธโƒฃ Newton-Raphson Method

  • Uses the first derivative to iteratively refine the root:

[ x_{n+1} = x_n - \frac{f(x_n)}{f'(x_n)} ]

โœ… Fast convergence for well-behaved functions.

โŒ Fails for non-differentiable functions.


๐Ÿ”น Runge-Kutta Method (Solving Differential Equations)

A powerful method for solving Ordinary Differential Equations (ODEs) of the form:

[ \frac{dy}{dx} = f(x, y) ]

4th Order Runge-Kutta uses:

[ y_{n+1} = y_n + \frac{h}{6} (k_1 + 2k_2 + 2k_3 + k_4) ]

where:

[ k_1 = h f(x_n, y_n) ] [ k_2 = h f(x_n + h/2, y_n + k_1/2) ] [ k_3 = h f(x_n + h/2, y_n + k_2/2) ] [ k_4 = h f(x_n + h, y_n + k_3) ]

โœ… More accurate than Eulerโ€™s Method.
โœ… Suitable for non-linear ODEs.

โŒ Computationally expensive.


๐Ÿ”น Matrix Inversion

Used to find the inverse of a matrix ( A^{-1} ), such that:

[ A A^{-1} = I ]

Using Gauss-Jordan Method: 1๏ธโƒฃ Append identity matrix to ( A ).
2๏ธโƒฃ Perform row operations to convert ( A ) into identity matrix.
3๏ธโƒฃ The result is ( A^{-1} ).

โœ… Used for solving simultaneous equations.

โŒ Computationally expensive for large matrices.


๐Ÿ“œ Summary

These numerical methods are widely used in engineering and science for solving complex equations efficiently.

If you have any suggestions or contributions, feel free to fork this project and create a pull request! ๐Ÿš€


๐Ÿ“ References:

๐Ÿ“Œ Numerical Methods in Engineering
๐Ÿ“Œ Applied Mathematics Textbooks


๐Ÿ“œ License

This project is open-source. Feel free to modify, share, and contribute!

๐Ÿš€ Happy Coding! ๐Ÿ˜Š

About

Numerical Application - My Part ๐Ÿงฎ A Java-based numerical computation tool implementing matrix operations, root-finding methods, differential equations, and iterative solutions. ๐Ÿš€

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages