Giter Site home page Giter Site logo

ele527groupproject's Introduction

This code solves a system of linear equations using the Gauss-Seidel method. It takes as input a coefficient matrix, a right-hand side vector, an initial guess for the solution vector, and the number of iteration steps to perform.

Function:

gauss_seidel(A, b, x0, num_of_iteration)

Description:

This function implements the Gauss-Seidel method for solving a system of linear equations.

Parameters:

  • A: Coefficient matrix (list of lists)
  • b: Right-hand side vector (list)
  • x0: Initial guess for the solution vector (list)
  • num_of_iteration: Number of iteration steps to perform (integer)

Returns:

  • The final solution vector (list)

IMPORTED MODULES

Module:

art

Description: This module provides ASCII art text for the program logo.

USED METHOD

Method:

copy()

Description: This method is used to create a deep copy of the initial guess solution vector 'x0'. It ensures that the original 'x0' remains unchanged during the iterations.

MAIN CODE

  • Coefficient matrix:

    • A = [[1, 9, -2], [2, -1, 8], [6, 1, 1]]
  • Right-hand side vector:

    • b = [36, 121, 107]
  • Initial guess for the solution vector:

    • x0 = [0, 0, 0]
  • Number of iteration steps:

    • num_steps = 10
  • Solve the system of equations using the Gauss-Seidel method:

    • solution = gauss_seidel(A, b, x0, num_steps)
  • Print the program logo:

    • print(logo)
  • Print the solution rounded to 6 significant digits:

    • for i, value in enumerate(solution):
      • print(f"x{i + 1} = {value:.6g}")

HOW TO RUN LOCALLY

  1. Ensure that you have the required dependencies installed. You can install the necessary packages using pip:

  2. Copy the code into a Python file (e.g., linear_equations_solver.py).

  3. Run the Python script:

The solution for the system of linear equations will be displayed in the console output.

ele527groupproject's People

Contributors

damieee avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.