equations-solvers


Nameequations-solvers JSON
Version 0.1.1 PyPI version JSON
download
home_pagehttps://github.com/hammailriaz/Equations_Solvers
SummaryA Python package for matrix operations and solving linear equations
upload_time2025-10-14 14:48:59
maintainerNone
docs_urlNone
authorHammail Riaz
requires_python>=3.7
licenseMIT
keywords matrix linear-equations mathematics algebra
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Equations Solvers

A comprehensive Python package for matrix operations and solving linear equations. This package provides easy-to-use classes for working with 2x2 and 3x3 matrices, along with a powerful linear equation solver.

[![Python Version](https://img.shields.io/badge/python-3.8%2B-blue.svg)](https://www.python.org/downloads/)
[![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE.txt)

## Features

✨ **Matrix Operations**
- Addition and Subtraction
- Matrix and Scalar Multiplication
- Matrix and Scalar Division
- Determinant Calculation
- Adjoint Matrix
- Multiplicative Inverse

🔢 **Linear Equation Solver**
- Solve 2x2 and 3x3 systems
- Multiple solving methods (Cramer's Rule, Matrix Inversion)
- Parse equations from string format
- Fraction results for exact solutions

🛡️ **Robust Error Handling**
- Invalid matrix detection
- Singular matrix handling
- Division by zero protection
- Equation parsing validation

## Installation

```bash
pip install equations_solvers
```

For development installation:
```bash
git clone https://github.com/yourusername/equations_solvers.git
cd equations_solvers
pip install -e .
```

## Quick Start

```python
from equations_solvers import Matrices2x2, LinearEquationsSolver

# Create a 2x2 matrix calculator
calc = Matrices2x2()

# Define matrices
A = [[2, 3], [1, 4]]
B = [[5, 2], [3, 1]]

# Perform operations
result = calc.add(A, B)
print(result)  # [[7.0, 5.0], [4.0, 5.0]]

# Solve linear equations
solver = LinearEquationsSolver("2x + 4y = 5, 3x - 3y = -1")
solution = solver.solve('cramer')
for var, val in solution:
    print(f"{var} = {val}")
# Output: x = 11/18, y = 17/18
```

## Documentation

### Table of Contents
1. [2x2 Matrix Operations](#2x2-matrix-operations)
2. [3x3 Matrix Operations](#3x3-matrix-operations)
3. [Linear Equation Solver](#linear-equation-solver)
4. [Error Handling](#error-handling)

---

## 2x2 Matrix Operations

The `Matrices2x2` class provides comprehensive operations for 2x2 matrices.

### Basic Usage

```python
from equations_solvers import Matrices2x2

# Create an instance
calc = Matrices2x2()

# Define matrices
A = [[2, 3], [1, 4]]
B = [[5, 2], [3, 1]]
```

### Addition

```python
result = calc.add(A, B)
print(result)
```

**Output:**
```
[[7.0, 5.0], [4.0, 5.0]]
```

### Subtraction

```python
result = calc.subtract(A, B)
print(result)
```

**Output:**
```
[[-3.0, 1.0], [-2.0, 3.0]]
```

### Matrix Multiplication

```python
result = calc.multiply(A, B)
print(result)
```

**Output:**
```
[[19, 7], [17, 6]]
```

### Scalar Multiplication

```python
result = calc.multiply(A, num=2)
print(result)
```

**Output:**
```
[[4, 6], [2, 8]]
```

### Scalar Division

```python
result = calc.divide(A, num=2)
print(result)
```

**Output:**
```
[[1.0, 1.5], [0.5, 2.0]]
```

### Determinant

```python
det = calc.determinant(A)
print(det)
```

**Output:**
```
5.0
```

### Adjoint Matrix

```python
adj = calc.adjoint(A)
print(adj)
```

**Output:**
```
[[4.0, -3.0], [-1.0, 2.0]]
```

### Multiplicative Inverse

```python
inv = calc.multiplicative_inverse(A)
print(inv)
```

**Output:**
```
[[0.8, -0.6], [-0.2, 0.4]]
```

---

## 3x3 Matrix Operations

The `Matrices3x3` class provides comprehensive operations for 3x3 matrices.

### Basic Usage

```python
from equations_solvers import Matrices3x3

# Create an instance
calc = Matrices3x3()

# Define matrices
C = [[1, 2, 3], [0, 1, 4], [5, 6, 0]]
D = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]  # Identity matrix
```

### Addition

```python
result = calc.add(C, D)
print(result)
```

**Output:**
```
[[2.0, 2.0, 3.0], [0.0, 2.0, 4.0], [5.0, 6.0, 1.0]]
```

### Subtraction

```python
result = calc.subtract(C, D)
print(result)
```

**Output:**
```
[[0.0, 2.0, 3.0], [0.0, 0.0, 4.0], [5.0, 6.0, -1.0]]
```

### Matrix Multiplication

```python
result = calc.matrix_multiply(C, D)
print(result)
```

**Output:**
```
[[1, 2, 3], [0, 1, 4], [5, 6, 0]]
```

### Scalar Multiplication

```python
result = calc.scalar_multiply(C, 3)
print(result)
```

**Output:**
```
[[3, 6, 9], [0, 3, 12], [15, 18, 0]]
```

### Scalar Division

```python
result = calc.scalar_divide(C, 3)
print(result)
```

**Output:**
```
[[0.333, 0.667, 1.0], [0.0, 0.333, 1.333], [1.667, 2.0, 0.0]]
```

### Determinant

```python
det = calc.determinant(C)
print(det)
```

**Output:**
```
1.0
```

### Adjoint Matrix

```python
adj = calc.adjoint(C)
print(adj)
```

**Output:**
```
[[-24.0, 18.0, 5.0], [20.0, -15.0, -4.0], [-5.0, 4.0, 1.0]]
```

### Multiplicative Inverse

```python
inv = calc.multiplicative_inverse(C)
print(inv)
```

**Output:**
```
[[-24.0, 18.0, 5.0], [20.0, -15.0, -4.0], [-5.0, 4.0, 1.0]]
```

### Matrix Division

```python
result = calc.matrix_divide(C, D)
print(result)
```

**Output:**
```
[[1.0, 2.0, 3.0], [0.0, 1.0, 4.0], [5.0, 6.0, 0.0]]
```

---

## Linear Equation Solver

The `LinearEquationsSolver` class solves systems of 2x2 and 3x3 linear equations.

### Solving 2x2 Systems

```python
from equations_solvers import LinearEquationsSolver

# Define the system of equations
solver = LinearEquationsSolver("2x + 4y = 5, 3x - 3y = -1")

# Get coefficient matrix
print("Coefficient Matrix:")
for row in solver.A():
    print(row)
```

**Output:**
```
Coefficient Matrix:
[2.0, 4.0]
[3.0, -3.0]
```

#### Using Cramer's Rule

```python
solution = solver.solve('cramer')
for var, val in solution:
    print(f"{var} = {val}")
```

**Output:**
```
x = 11/18
y = 17/18
```

#### Using Matrix Inversion

```python
solution = solver.solve('inverse')
for var, val in solution:
    print(f"{var} = {val}")
```

**Output:**
```
x = 11/18
y = 17/18
```

### Solving 3x3 Systems

```python
# Define a 3x3 system
solver = LinearEquationsSolver("3x + y - z = 10, -3x + 4y - z = 10, 3x + y + 4z = 0")

# Solve using Cramer's rule
solution = solver.solve('cramer')
for var, val in solution:
    print(f"{var} = {val}")
```

**Output:**
```
x = 8/5
y = 16/5
z = -2
```

### Complete Example with Verification

```python
# System: 2x + 3y = 8, x + 4y = 10
solver = LinearEquationsSolver("2x + 3y = 8, x + 4y = 10")

# Solve
solution = solver.solve('cramer')
x_val = float(solution[0][1])
y_val = float(solution[1][1])

print(f"Solution: x = {solution[0][1]}, y = {solution[1][1]}")

# Verify
eq1 = 2 * x_val + 3 * y_val
eq2 = x_val + 4 * y_val

print(f"\nVerification:")
print(f"2x + 3y = {eq1} (should be 8)")
print(f"x + 4y = {eq2} (should be 10)")
```

**Output:**
```
Solution: x = 2/5, y = 12/5

Verification:
2x + 3y = 8.0 (should be 8)
x + 4y = 10.0 (should be 10)
```

---

## Error Handling

The package includes robust error handling for common issues.

### Singular Matrix (Non-Invertible)

```python
from equations_solvers import Matrices3x3, InvalidMatrixError

calc = Matrices3x3()
singular = [[1, 2, 3], [2, 4, 6], [3, 6, 9]]

try:
    inv = calc.multiplicative_inverse(singular)
except InvalidMatrixError as e:
    print(f"Error: {e}")
```

**Output:**
```
Error: Matrix is singular and cannot be inverted.
```

### Division by Zero

```python
from equations_solvers import Matrices2x2, InvalidMatrixError

calc = Matrices2x2()
A = [[2, 3], [1, 4]]

try:
    result = calc.divide(A, num=0)
except InvalidMatrixError as e:
    print(f"Error: {e}")
```

**Output:**
```
Error: Division by zero is not allowed.
```

### Invalid Equation Format

```python
from equations_solvers import LinearEquationsSolver

try:
    # Missing equals sign
    solver = LinearEquationsSolver("2x + 3y")
except Exception as e:
    print(f"Error: {e}")
```

**Output:**
```
Error: Equation must contain '=': 2x+3y
```

### Inconsistent Variables

```python
try:
    # Variables don't match across equations
    solver = LinearEquationsSolver("x + y = 1, x + z = 2")
except Exception as e:
    print(f"Error: {e}")
```

**Output:**
```
Error: Equation 2 has inconsistent variables. Expected ['x', 'y'], got ['x', 'z']
```

---

## API Reference

### Matrices2x2

**Methods:**
- `add(matrix1, matrix2)` - Add two matrices
- `subtract(matrix1, matrix2)` - Subtract matrix2 from matrix1
- `multiply(matrix1, matrix2=None, num=None)` - Multiply matrices or by scalar
- `divide(matrix, matrix2=None, num=None)` - Divide matrix by scalar or another matrix
- `determinant(matrix)` - Calculate determinant
- `adjoint(matrix)` - Calculate adjoint matrix
- `multiplicative_inverse(matrix)` - Calculate inverse matrix

### Matrices3x3

**Methods:**
- `add(matrix1, matrix2)` - Add two matrices
- `subtract(matrix1, matrix2)` - Subtract matrix2 from matrix1
- `matrix_multiply(matrix1, matrix2)` - Multiply two matrices
- `scalar_multiply(matrix, scalar)` - Multiply matrix by scalar
- `matrix_divide(matrix1, matrix2)` - Divide matrix1 by matrix2
- `scalar_divide(matrix, scalar)` - Divide matrix by scalar
- `determinant(matrix)` - Calculate determinant
- `adjoint(matrix)` - Calculate adjoint matrix
- `multiplicative_inverse(matrix)` - Calculate inverse matrix

### LinearEquationsSolver

**Constructor:**
- `LinearEquationsSolver(equations_str)` - Parse equations from string

**Methods:**
- `A()` - Get coefficient matrix
- `solve(method='cramer')` - Solve system using 'cramer' or 'inverse' method

**Returns:** List of tuples `[(variable, value), ...]`

### InvalidMatrixError

Custom exception raised for matrix-related errors.

---

## Contributing

Contributions are welcome! Please follow these steps:

1. Fork the repository
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request

---

## License

This project is licensed under the MIT License - see the [LICENSE.txt](LICENSE.txt) file for details.

---

## Author

**Your Name**
- GitHub: [@Hammail-Riaz](https://github.com/Hammail-Riaz)
- Email: hammailriaz.dev@gmail.com

---

## Changelog

### Version 0.1.0 (Initial Release)
- 2x2 and 3x3 matrix operations
- Linear equation solver with multiple methods
- Comprehensive error handling
- Full documentation and examples

---

## Acknowledgments

- Built with Python 3.8+
- Inspired by linear algebra education needs
- Thanks to all contributors

---

## Support

If you encounter any issues or have questions:
- Open an issue on [GitHub Issues](https://github.com/yourusername/equations_solvers/issues)
- Check the [documentation](#documentation)
- Contact: hammailriaz.dev@gmail.com

---

**Made with ❤️ for mathematics and Python enthusiasts**

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/hammailriaz/Equations_Solvers",
    "name": "equations-solvers",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "matrix, linear-equations, mathematics, algebra",
    "author": "Hammail Riaz",
    "author_email": "Hammail Riaz <hammailriaz.dev@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/f3/15/e3b33e233b1c56c23f837862ad8aeb754f5f982aa4bd4efd49ed9293239a/equations_solvers-0.1.1.tar.gz",
    "platform": null,
    "description": "# Equations Solvers\r\n\r\nA comprehensive Python package for matrix operations and solving linear equations. This package provides easy-to-use classes for working with 2x2 and 3x3 matrices, along with a powerful linear equation solver.\r\n\r\n[![Python Version](https://img.shields.io/badge/python-3.8%2B-blue.svg)](https://www.python.org/downloads/)\r\n[![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE.txt)\r\n\r\n## Features\r\n\r\n\u2728 **Matrix Operations**\r\n- Addition and Subtraction\r\n- Matrix and Scalar Multiplication\r\n- Matrix and Scalar Division\r\n- Determinant Calculation\r\n- Adjoint Matrix\r\n- Multiplicative Inverse\r\n\r\n\ud83d\udd22 **Linear Equation Solver**\r\n- Solve 2x2 and 3x3 systems\r\n- Multiple solving methods (Cramer's Rule, Matrix Inversion)\r\n- Parse equations from string format\r\n- Fraction results for exact solutions\r\n\r\n\ud83d\udee1\ufe0f **Robust Error Handling**\r\n- Invalid matrix detection\r\n- Singular matrix handling\r\n- Division by zero protection\r\n- Equation parsing validation\r\n\r\n## Installation\r\n\r\n```bash\r\npip install equations_solvers\r\n```\r\n\r\nFor development installation:\r\n```bash\r\ngit clone https://github.com/yourusername/equations_solvers.git\r\ncd equations_solvers\r\npip install -e .\r\n```\r\n\r\n## Quick Start\r\n\r\n```python\r\nfrom equations_solvers import Matrices2x2, LinearEquationsSolver\r\n\r\n# Create a 2x2 matrix calculator\r\ncalc = Matrices2x2()\r\n\r\n# Define matrices\r\nA = [[2, 3], [1, 4]]\r\nB = [[5, 2], [3, 1]]\r\n\r\n# Perform operations\r\nresult = calc.add(A, B)\r\nprint(result)  # [[7.0, 5.0], [4.0, 5.0]]\r\n\r\n# Solve linear equations\r\nsolver = LinearEquationsSolver(\"2x + 4y = 5, 3x - 3y = -1\")\r\nsolution = solver.solve('cramer')\r\nfor var, val in solution:\r\n    print(f\"{var} = {val}\")\r\n# Output: x = 11/18, y = 17/18\r\n```\r\n\r\n## Documentation\r\n\r\n### Table of Contents\r\n1. [2x2 Matrix Operations](#2x2-matrix-operations)\r\n2. [3x3 Matrix Operations](#3x3-matrix-operations)\r\n3. [Linear Equation Solver](#linear-equation-solver)\r\n4. [Error Handling](#error-handling)\r\n\r\n---\r\n\r\n## 2x2 Matrix Operations\r\n\r\nThe `Matrices2x2` class provides comprehensive operations for 2x2 matrices.\r\n\r\n### Basic Usage\r\n\r\n```python\r\nfrom equations_solvers import Matrices2x2\r\n\r\n# Create an instance\r\ncalc = Matrices2x2()\r\n\r\n# Define matrices\r\nA = [[2, 3], [1, 4]]\r\nB = [[5, 2], [3, 1]]\r\n```\r\n\r\n### Addition\r\n\r\n```python\r\nresult = calc.add(A, B)\r\nprint(result)\r\n```\r\n\r\n**Output:**\r\n```\r\n[[7.0, 5.0], [4.0, 5.0]]\r\n```\r\n\r\n### Subtraction\r\n\r\n```python\r\nresult = calc.subtract(A, B)\r\nprint(result)\r\n```\r\n\r\n**Output:**\r\n```\r\n[[-3.0, 1.0], [-2.0, 3.0]]\r\n```\r\n\r\n### Matrix Multiplication\r\n\r\n```python\r\nresult = calc.multiply(A, B)\r\nprint(result)\r\n```\r\n\r\n**Output:**\r\n```\r\n[[19, 7], [17, 6]]\r\n```\r\n\r\n### Scalar Multiplication\r\n\r\n```python\r\nresult = calc.multiply(A, num=2)\r\nprint(result)\r\n```\r\n\r\n**Output:**\r\n```\r\n[[4, 6], [2, 8]]\r\n```\r\n\r\n### Scalar Division\r\n\r\n```python\r\nresult = calc.divide(A, num=2)\r\nprint(result)\r\n```\r\n\r\n**Output:**\r\n```\r\n[[1.0, 1.5], [0.5, 2.0]]\r\n```\r\n\r\n### Determinant\r\n\r\n```python\r\ndet = calc.determinant(A)\r\nprint(det)\r\n```\r\n\r\n**Output:**\r\n```\r\n5.0\r\n```\r\n\r\n### Adjoint Matrix\r\n\r\n```python\r\nadj = calc.adjoint(A)\r\nprint(adj)\r\n```\r\n\r\n**Output:**\r\n```\r\n[[4.0, -3.0], [-1.0, 2.0]]\r\n```\r\n\r\n### Multiplicative Inverse\r\n\r\n```python\r\ninv = calc.multiplicative_inverse(A)\r\nprint(inv)\r\n```\r\n\r\n**Output:**\r\n```\r\n[[0.8, -0.6], [-0.2, 0.4]]\r\n```\r\n\r\n---\r\n\r\n## 3x3 Matrix Operations\r\n\r\nThe `Matrices3x3` class provides comprehensive operations for 3x3 matrices.\r\n\r\n### Basic Usage\r\n\r\n```python\r\nfrom equations_solvers import Matrices3x3\r\n\r\n# Create an instance\r\ncalc = Matrices3x3()\r\n\r\n# Define matrices\r\nC = [[1, 2, 3], [0, 1, 4], [5, 6, 0]]\r\nD = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]  # Identity matrix\r\n```\r\n\r\n### Addition\r\n\r\n```python\r\nresult = calc.add(C, D)\r\nprint(result)\r\n```\r\n\r\n**Output:**\r\n```\r\n[[2.0, 2.0, 3.0], [0.0, 2.0, 4.0], [5.0, 6.0, 1.0]]\r\n```\r\n\r\n### Subtraction\r\n\r\n```python\r\nresult = calc.subtract(C, D)\r\nprint(result)\r\n```\r\n\r\n**Output:**\r\n```\r\n[[0.0, 2.0, 3.0], [0.0, 0.0, 4.0], [5.0, 6.0, -1.0]]\r\n```\r\n\r\n### Matrix Multiplication\r\n\r\n```python\r\nresult = calc.matrix_multiply(C, D)\r\nprint(result)\r\n```\r\n\r\n**Output:**\r\n```\r\n[[1, 2, 3], [0, 1, 4], [5, 6, 0]]\r\n```\r\n\r\n### Scalar Multiplication\r\n\r\n```python\r\nresult = calc.scalar_multiply(C, 3)\r\nprint(result)\r\n```\r\n\r\n**Output:**\r\n```\r\n[[3, 6, 9], [0, 3, 12], [15, 18, 0]]\r\n```\r\n\r\n### Scalar Division\r\n\r\n```python\r\nresult = calc.scalar_divide(C, 3)\r\nprint(result)\r\n```\r\n\r\n**Output:**\r\n```\r\n[[0.333, 0.667, 1.0], [0.0, 0.333, 1.333], [1.667, 2.0, 0.0]]\r\n```\r\n\r\n### Determinant\r\n\r\n```python\r\ndet = calc.determinant(C)\r\nprint(det)\r\n```\r\n\r\n**Output:**\r\n```\r\n1.0\r\n```\r\n\r\n### Adjoint Matrix\r\n\r\n```python\r\nadj = calc.adjoint(C)\r\nprint(adj)\r\n```\r\n\r\n**Output:**\r\n```\r\n[[-24.0, 18.0, 5.0], [20.0, -15.0, -4.0], [-5.0, 4.0, 1.0]]\r\n```\r\n\r\n### Multiplicative Inverse\r\n\r\n```python\r\ninv = calc.multiplicative_inverse(C)\r\nprint(inv)\r\n```\r\n\r\n**Output:**\r\n```\r\n[[-24.0, 18.0, 5.0], [20.0, -15.0, -4.0], [-5.0, 4.0, 1.0]]\r\n```\r\n\r\n### Matrix Division\r\n\r\n```python\r\nresult = calc.matrix_divide(C, D)\r\nprint(result)\r\n```\r\n\r\n**Output:**\r\n```\r\n[[1.0, 2.0, 3.0], [0.0, 1.0, 4.0], [5.0, 6.0, 0.0]]\r\n```\r\n\r\n---\r\n\r\n## Linear Equation Solver\r\n\r\nThe `LinearEquationsSolver` class solves systems of 2x2 and 3x3 linear equations.\r\n\r\n### Solving 2x2 Systems\r\n\r\n```python\r\nfrom equations_solvers import LinearEquationsSolver\r\n\r\n# Define the system of equations\r\nsolver = LinearEquationsSolver(\"2x + 4y = 5, 3x - 3y = -1\")\r\n\r\n# Get coefficient matrix\r\nprint(\"Coefficient Matrix:\")\r\nfor row in solver.A():\r\n    print(row)\r\n```\r\n\r\n**Output:**\r\n```\r\nCoefficient Matrix:\r\n[2.0, 4.0]\r\n[3.0, -3.0]\r\n```\r\n\r\n#### Using Cramer's Rule\r\n\r\n```python\r\nsolution = solver.solve('cramer')\r\nfor var, val in solution:\r\n    print(f\"{var} = {val}\")\r\n```\r\n\r\n**Output:**\r\n```\r\nx = 11/18\r\ny = 17/18\r\n```\r\n\r\n#### Using Matrix Inversion\r\n\r\n```python\r\nsolution = solver.solve('inverse')\r\nfor var, val in solution:\r\n    print(f\"{var} = {val}\")\r\n```\r\n\r\n**Output:**\r\n```\r\nx = 11/18\r\ny = 17/18\r\n```\r\n\r\n### Solving 3x3 Systems\r\n\r\n```python\r\n# Define a 3x3 system\r\nsolver = LinearEquationsSolver(\"3x + y - z = 10, -3x + 4y - z = 10, 3x + y + 4z = 0\")\r\n\r\n# Solve using Cramer's rule\r\nsolution = solver.solve('cramer')\r\nfor var, val in solution:\r\n    print(f\"{var} = {val}\")\r\n```\r\n\r\n**Output:**\r\n```\r\nx = 8/5\r\ny = 16/5\r\nz = -2\r\n```\r\n\r\n### Complete Example with Verification\r\n\r\n```python\r\n# System: 2x + 3y = 8, x + 4y = 10\r\nsolver = LinearEquationsSolver(\"2x + 3y = 8, x + 4y = 10\")\r\n\r\n# Solve\r\nsolution = solver.solve('cramer')\r\nx_val = float(solution[0][1])\r\ny_val = float(solution[1][1])\r\n\r\nprint(f\"Solution: x = {solution[0][1]}, y = {solution[1][1]}\")\r\n\r\n# Verify\r\neq1 = 2 * x_val + 3 * y_val\r\neq2 = x_val + 4 * y_val\r\n\r\nprint(f\"\\nVerification:\")\r\nprint(f\"2x + 3y = {eq1} (should be 8)\")\r\nprint(f\"x + 4y = {eq2} (should be 10)\")\r\n```\r\n\r\n**Output:**\r\n```\r\nSolution: x = 2/5, y = 12/5\r\n\r\nVerification:\r\n2x + 3y = 8.0 (should be 8)\r\nx + 4y = 10.0 (should be 10)\r\n```\r\n\r\n---\r\n\r\n## Error Handling\r\n\r\nThe package includes robust error handling for common issues.\r\n\r\n### Singular Matrix (Non-Invertible)\r\n\r\n```python\r\nfrom equations_solvers import Matrices3x3, InvalidMatrixError\r\n\r\ncalc = Matrices3x3()\r\nsingular = [[1, 2, 3], [2, 4, 6], [3, 6, 9]]\r\n\r\ntry:\r\n    inv = calc.multiplicative_inverse(singular)\r\nexcept InvalidMatrixError as e:\r\n    print(f\"Error: {e}\")\r\n```\r\n\r\n**Output:**\r\n```\r\nError: Matrix is singular and cannot be inverted.\r\n```\r\n\r\n### Division by Zero\r\n\r\n```python\r\nfrom equations_solvers import Matrices2x2, InvalidMatrixError\r\n\r\ncalc = Matrices2x2()\r\nA = [[2, 3], [1, 4]]\r\n\r\ntry:\r\n    result = calc.divide(A, num=0)\r\nexcept InvalidMatrixError as e:\r\n    print(f\"Error: {e}\")\r\n```\r\n\r\n**Output:**\r\n```\r\nError: Division by zero is not allowed.\r\n```\r\n\r\n### Invalid Equation Format\r\n\r\n```python\r\nfrom equations_solvers import LinearEquationsSolver\r\n\r\ntry:\r\n    # Missing equals sign\r\n    solver = LinearEquationsSolver(\"2x + 3y\")\r\nexcept Exception as e:\r\n    print(f\"Error: {e}\")\r\n```\r\n\r\n**Output:**\r\n```\r\nError: Equation must contain '=': 2x+3y\r\n```\r\n\r\n### Inconsistent Variables\r\n\r\n```python\r\ntry:\r\n    # Variables don't match across equations\r\n    solver = LinearEquationsSolver(\"x + y = 1, x + z = 2\")\r\nexcept Exception as e:\r\n    print(f\"Error: {e}\")\r\n```\r\n\r\n**Output:**\r\n```\r\nError: Equation 2 has inconsistent variables. Expected ['x', 'y'], got ['x', 'z']\r\n```\r\n\r\n---\r\n\r\n## API Reference\r\n\r\n### Matrices2x2\r\n\r\n**Methods:**\r\n- `add(matrix1, matrix2)` - Add two matrices\r\n- `subtract(matrix1, matrix2)` - Subtract matrix2 from matrix1\r\n- `multiply(matrix1, matrix2=None, num=None)` - Multiply matrices or by scalar\r\n- `divide(matrix, matrix2=None, num=None)` - Divide matrix by scalar or another matrix\r\n- `determinant(matrix)` - Calculate determinant\r\n- `adjoint(matrix)` - Calculate adjoint matrix\r\n- `multiplicative_inverse(matrix)` - Calculate inverse matrix\r\n\r\n### Matrices3x3\r\n\r\n**Methods:**\r\n- `add(matrix1, matrix2)` - Add two matrices\r\n- `subtract(matrix1, matrix2)` - Subtract matrix2 from matrix1\r\n- `matrix_multiply(matrix1, matrix2)` - Multiply two matrices\r\n- `scalar_multiply(matrix, scalar)` - Multiply matrix by scalar\r\n- `matrix_divide(matrix1, matrix2)` - Divide matrix1 by matrix2\r\n- `scalar_divide(matrix, scalar)` - Divide matrix by scalar\r\n- `determinant(matrix)` - Calculate determinant\r\n- `adjoint(matrix)` - Calculate adjoint matrix\r\n- `multiplicative_inverse(matrix)` - Calculate inverse matrix\r\n\r\n### LinearEquationsSolver\r\n\r\n**Constructor:**\r\n- `LinearEquationsSolver(equations_str)` - Parse equations from string\r\n\r\n**Methods:**\r\n- `A()` - Get coefficient matrix\r\n- `solve(method='cramer')` - Solve system using 'cramer' or 'inverse' method\r\n\r\n**Returns:** List of tuples `[(variable, value), ...]`\r\n\r\n### InvalidMatrixError\r\n\r\nCustom exception raised for matrix-related errors.\r\n\r\n---\r\n\r\n## Contributing\r\n\r\nContributions are welcome! Please follow these steps:\r\n\r\n1. Fork the repository\r\n2. Create a feature branch (`git checkout -b feature/amazing-feature`)\r\n3. Commit your changes (`git commit -m 'Add amazing feature'`)\r\n4. Push to the branch (`git push origin feature/amazing-feature`)\r\n5. Open a Pull Request\r\n\r\n---\r\n\r\n## License\r\n\r\nThis project is licensed under the MIT License - see the [LICENSE.txt](LICENSE.txt) file for details.\r\n\r\n---\r\n\r\n## Author\r\n\r\n**Your Name**\r\n- GitHub: [@Hammail-Riaz](https://github.com/Hammail-Riaz)\r\n- Email: hammailriaz.dev@gmail.com\r\n\r\n---\r\n\r\n## Changelog\r\n\r\n### Version 0.1.0 (Initial Release)\r\n- 2x2 and 3x3 matrix operations\r\n- Linear equation solver with multiple methods\r\n- Comprehensive error handling\r\n- Full documentation and examples\r\n\r\n---\r\n\r\n## Acknowledgments\r\n\r\n- Built with Python 3.8+\r\n- Inspired by linear algebra education needs\r\n- Thanks to all contributors\r\n\r\n---\r\n\r\n## Support\r\n\r\nIf you encounter any issues or have questions:\r\n- Open an issue on [GitHub Issues](https://github.com/yourusername/equations_solvers/issues)\r\n- Check the [documentation](#documentation)\r\n- Contact: hammailriaz.dev@gmail.com\r\n\r\n---\r\n\r\n**Made with \u2764\ufe0f for mathematics and Python enthusiasts**\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A Python package for matrix operations and solving linear equations",
    "version": "0.1.1",
    "project_urls": {
        "Documentation": "https://github.com/Hammail-Riaz/equations_solvers#readme",
        "Homepage": "https://github.com/Hammail-Riaz/equations_solvers",
        "Repository": "https://github.com/Hammail-Riaz/equations_solvers"
    },
    "split_keywords": [
        "matrix",
        " linear-equations",
        " mathematics",
        " algebra"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "07e6e41c886de15731ef9f8090212450abe7f59b05fa7d7959cabeb2feaebe06",
                "md5": "1a9075c82e86935729fef70967071ad6",
                "sha256": "2f64b0072fb945bfb8dc9ab05d83938918e098fd31e29772bc5572275dc57fdd"
            },
            "downloads": -1,
            "filename": "equations_solvers-0.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "1a9075c82e86935729fef70967071ad6",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 23700,
            "upload_time": "2025-10-14T14:48:57",
            "upload_time_iso_8601": "2025-10-14T14:48:57.937556Z",
            "url": "https://files.pythonhosted.org/packages/07/e6/e41c886de15731ef9f8090212450abe7f59b05fa7d7959cabeb2feaebe06/equations_solvers-0.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "f315e3b33e233b1c56c23f837862ad8aeb754f5f982aa4bd4efd49ed9293239a",
                "md5": "fdca0820890c02acf2e25bfc23b680af",
                "sha256": "f915238d13f110184288bdc5b12a58bfecff8bb50213818e300d97a094212f38"
            },
            "downloads": -1,
            "filename": "equations_solvers-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "fdca0820890c02acf2e25bfc23b680af",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 22318,
            "upload_time": "2025-10-14T14:48:59",
            "upload_time_iso_8601": "2025-10-14T14:48:59.269584Z",
            "url": "https://files.pythonhosted.org/packages/f3/15/e3b33e233b1c56c23f837862ad8aeb754f5f982aa4bd4efd49ed9293239a/equations_solvers-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-10-14 14:48:59",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "hammailriaz",
    "github_project": "Equations_Solvers",
    "github_not_found": true,
    "lcname": "equations-solvers"
}
        
Elapsed time: 2.06062s