Skip to content

The RREF Convertor performs Row Reduction to Echelon Form (RREF) on a given matrix and solves the associated system of linear equations via the gaussian elimination method

Notifications You must be signed in to change notification settings

palak-b19/Row-Reduced-Echelon-Form-Convertor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

RREF Matrix and System Solver

This repository contains Python code for performing Row Reduction to Echelon Form (RREF) on a given matrix and solving the associated system of linear equations. The code uses the Gaussian elimination method to convert the input matrix to its reduced row-echelon form and then extracts information about the variables and constants to represent the system of linear equations. This project involves understanding of Linear Algebra and Python implementation

Table of Contents

Introduction

The provided Python code consists of three main functions:

  1. rref: Converts a given matrix to its Reduced Row-Echelon Form (RREF).
  2. dict_val: Extracts information about variables and constants from the RREF matrix.
  3. para_eq: Represents the system of linear equations based on the RREF matrix and variable information.

The code is designed to handle square and rectangular matrices.

Usage

To use the code, you can call the rref function with a matrix as an argument. The resulting RREF matrix can be used with the dict_val and para_eq functions to obtain information about the system of linear equations.

# Example Usage
matrix_input =  [[4,4,4],[2,2,2],[1,1,1]]
rref_matrix = rref(matrix_input)
variable_info = dict_val(rref_matrix)
modified_dict = simp_dic(variable_info)
para_eq(modified_dict, rref_matrix)

Functions

rref(A)

Converts the input matrix A to its Reduced Row-Echelon Form (RREF).

  • Input:

    • A: The input matrix as a list of lists.
  • Output:

    • Returns the RREF matrix.

dict_val(rref_mt)

Extracts information about variables and constants from the RREF matrix.

  • Input:

    • rref_mt: The RREF matrix.
  • Output:

    • Returns a dictionary containing information about variables and constants.

simp_dic(dict_main)

Simplifies the variable information dictionary by setting coefficients to zero for variables corresponding to free columns.

  • Input:

    • dict_main: The variable information dictionary.
  • Output:

    • Returns the simplified variable information dictionary.

para_eq(modify_dict, rref)

Represents the system of linear equations based on the RREF matrix and variable information.

  • Input:

    • modify_dict: The simplified variable information dictionary.
    • rref: The RREF matrix.
  • Output:

    • Prints the system of linear equations.

Example

# Example Usage
matrix_input =  [[4,4,4],[2,2,2],[1,1,1]]
rref_matrix = rref(matrix_input)
variable_info = dict_val(rref_matrix)
modified_dict = simp_dic(variable_info)
para_eq(modified_dict, rref_matrix)

Output:

['X0', 'X1', 'X2']=[[-0.0, 1.0, -2.0]X2 + 0.0X0 + 0.0X1, 1.0X0 + 1.0X1 + 1.0X2, 0.0X0 + 0.0X1 + 0.0X2]

File Input

You can also provide the input matrix via a text file. The file should have the following format:

Rows: <number_of_rows>
Cols: <number_of_columns>
<element_11> <element_12> ... <element_1n>
<element_21> <element_22> ... <element_2n>
...
<element_m1> <element_m2> ... <element_mn>

You can use the provided matrix_input.txt file as an example.

License

This code is provided under the MIT License.

About

The RREF Convertor performs Row Reduction to Echelon Form (RREF) on a given matrix and solves the associated system of linear equations via the gaussian elimination method

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages