readme markdown added

This commit is contained in:
Sirin Puenggun 2022-12-11 16:41:57 +07:00
parent 9dd0dec3f9
commit 05f34c7a0b
2 changed files with 122 additions and 2 deletions

98
README.md Normal file
View File

@ -0,0 +1,98 @@
# Calculator for Matrix and Algebra
This is Text-based user interface program that use to solve matrix and algebra problems.
## Table of Content
- [Calculator for Matrix and Algebra](#calculator-for-matrix-and-algebra)
- [Table of Content](#table-of-content)
- [Overview](#overview)
- [Features](#features)
- [Requirement](#requirement)
- [Program design](#program-design)
- [Code structure](#code-structure)
- [Install and Usage](#install-and-usage)
- [Guide/Documentation](#guidedocumentation)
- [Polynomial](#polynomial)
- [Contributing](#contributing)
## Overview
...
## Features
**Calculator for Matrix and Algebra** provide the following function.
- Ability to solve for basic quadratic, cubic and quartic function.
- Calculate operations of Polynomial function e.g. +/-/*/÷/^.
- Calculate operations of Matrix e.g. Inverse/Tranpose/Basic Operation/Determinant.
- Evaluate the expression(No Variable) that has complex parentheses.
- Some basic algebra operation. e.g. Find reduce form of Fraction etc.
## Requirement
This program has been created in **Python 3.10.5** and has the following built-in module.
- [ast](https://docs.python.org/3/library/ast.html) : Abstract Syntax Trees
- [math](https://docs.python.org/3/library/math.html)
## Program design
...
## Code structure
...
## Install and Usage
Clone this repository and run the **main.py**
````
$ git clone https://github.com/Sosokker/Algebraic-Solving-Tool
````
## Guide/Documentation
After the running of the **main.py**. You can type the command and input into the terminal that look like this.
````
[1] <- This is line-count.
````
There are two types of command, input style.\
*No need expression command* and *Need expression command.*
>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;***Command***
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;***or***
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;***Command[expression]***
Whitespace and Case are not matter. Command is same as command.
For example.
````py
[1] history
# RESULT OF THE INPUT COMMAND
[2] det[[1,2],[3,4]]
# RESULT OF THE INPUT COMMAND
````
Every command you put in and result of it will be save in **history.json** file.
### Polynomial
&nbsp;&nbsp;&nbsp;&nbsp;Polynomial in this class is store in form of array. This are the following command.
- <span style="color:yellow">Polynomial[<span style="color:lightblue">expression</span>]</span>
-> expression str or list
- This Command use to print all property of the polynomial that user input.
````
[1] polynomial[x^2+2x+1]
````
## Contributing
Pull requests are always welcome and that would be a honor. This first Python project I've dones. I practice using OOP and using github in this work so many parts of code look a bit messy. 🙈
Thank you so much.

View File

@ -46,7 +46,7 @@ class Matrix:
self.array[row_index][column_index] -= other.array[row_index][column_index]
return self
def __mul__(self, other):
def __mul__(self, other: "int | float"):
"""
Multiply matrix up and those matrix need same dimesional.
>>> m1 = Matrix([[1, 2], [3, 4]])
@ -141,8 +141,30 @@ class Matrix:
return new_matrix
def inverse(self):
"""
Find Inverse Matrix.
>>> m1 = Matrix([[4, 3],[3, 2]])
>>> m1.inverse().array
[[-2.0, 3.0], [3.0, -4.0]]
>>> m1 = Matrix([[3, 0, 2],[2, 0, -2],[0, 1, 1]])
>>> m1.inverse().array
[[0.2, 0.2, 0.0],[-0.2, 0.3, 1.0],[0.2, -0.3, 0.0]]
"""
det = self.determinant()
pass
if det==0:
raise ValueError(f"Can't Find Inverse of this Matrix")
if len(self.array) == 2 and len(self.array[0]) == 2:
return Matrix([[self.array[1][1], -self.array[0][1]], [-self.array[1][0], self.array[0][0]]]) * (1/det)
temp = self.copy_matrix()
for row in range(self.row):
for col in range(self.column):
minor = lambda i, j : [row[:j] + row[j+1:] for row in (temp.array[:i]+temp.array[i+1:])]
minor_det = Matrix(minor(col, row)).determinant()
temp.array[row][col] = minor_det * (-1)**(row+col+2)
temp = temp.tranpose()
return temp * (1/det)
def __str__(self):
return f'Matrix({self.array})'