Skip to content

Sayed-Hossein-Hosseini/Gram_Schmidt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gram-Schmidt Algorithm Implementation

📖 Introduction to the Gram-Schmidt Algorithm

The Gram-Schmidt process is a key algorithm in linear algebra used to convert a set of linearly independent vectors into an orthogonal or orthonormal set. This process is essential in various mathematical and computational applications, including:

  • Solving linear systems: By forming orthogonal bases, it simplifies computations.
  • QR decomposition: Often used in numerical methods for decomposing matrices.
  • Fourier series analysis: Ensures orthogonality of basis functions.
  • Least squares regression: Helps find the best fit in multidimensional spaces.

🧮 Mathematical Description

Let's consider a set of vectors {v₁, v₂, ..., vₙ} in a Euclidean space. The Gram-Schmidt process transforms this set into an orthogonal set {u₁, u₂, ..., uₙ} and orthonormal set {e₁, e₂, ..., eₙ} using the following steps:

  1. Start by setting u₁ = v₁.

  2. For each subsequent vector vᵢ (with i > 1), subtract the projection of vᵢ onto all preceding vectors uⱼ (with j < i), and set this result as uᵢ. The projection of vᵢ onto uⱼ can be found using the formula:

where "·" denotes the dot product. Thus, the formula for uᵢ becomes:

  1. To obtain an orthonormal basis, normalize each vector uᵢ by dividing it by its magnitude |uᵢ|.

🔍 Code Functionality

Methods Overview

  1. projection(vector, orthogonal_vector)

    • Purpose: Computes the projection of a vector onto another vector.
  2. create_orthogonal_vector(index)

    • Purpose: Constructs an orthogonal vector by subtracting the projections of the current vector onto all previously computed orthogonal vectors.
    • Workflow: Iteratively updates the current vector by removing projection components.
  3. create_orthogonal_unit_vector(index)

    • Purpose: Normalizes the orthogonal vectors to create unit vectors.
  4. get_vectors()

    • Purpose: Collects user input for the number of vectors, their dimensions, and their values. Initializes data structures for computations.
  5. main()

    • Purpose: Orchestrates the input, processing, and output of the algorithm. Displays the results in tabular format using the pandas library.

Libraries and Language Used

  • Python: The implementation language for its simplicity and robust numerical capabilities.
  • NumPy: Used for efficient numerical computations, including dot products and vector normalization.
  • Pandas: Utilized to present results in a clear and structured tabular format.

👨‍💻 Authors

  • Sayyed Hossein Hosseini Dolat Abadi

📜 License

This project is licensed under the MIT License.


⏳🏋️‍♂️ Try It Now

Feel free to run the program to explore how it works or experiment with the algorithm using real-world data! 😊

To see how the algorithm works, I suggest you visit the following site:

Gram-Schmidt Calculator

About

In mathematics, particularly linear algebra and numerical analysis, the Gram–Schmidt process or Gram-Schmidt algorithm is a way of finding a set of two or more vectors that are perpendicular to each other.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages