Go to file
2022-12-12 05:27:53 +07:00
nessesary Update insert_mul_sign 2022-12-12 05:27:53 +07:00
classes_myproject.png Add Picture From pyreverse 2022-12-11 23:39:11 +07:00
file_read_write.py Add read_history function to read history from history.json 2022-12-11 13:56:00 +07:00
main.py Implement poly solve and sim 2022-12-12 05:26:05 +07:00
matrix.py Initial Commit 2022-11-01 02:22:36 +07:00
packages_myproject.png Add Picture From pyreverse 2022-12-11 23:39:11 +07:00
README.md update Readme 2022-12-11 23:37:47 +07:00
testing.py processing test 2022-12-12 05:26:34 +07:00

Calculator for Matrix and Algebra

This is Text-based user interface program that use to solve matrix and algebra problems.

Table of Content

Overview

Calculator for Matrix and Algebra can solve some expression that not too complex such as expression that doesn't have much nested parentheses.

It can solve Single Variable Equation and can expand the polynomial.

Some function maybe buggy but If the expression is not contain math function or nested parentheses, It works at its finest.

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.

Program design

  • This is UML Class Diagram of this program.

Code structure

main.py

  • This file is the main file that read the input and return the result.

file_read_write.py

  • Contains function that use to read and write json file.

polynomial.py

  • Implement Class Polynomial that contain function to solve, change between array and string form.

matrix.py

  • Implement Class Matrix that contain function to find determiannt, inverse and Tranpose.

fraction.py

  • Implement Class Fraction that contain function to turn float into fraction and can evaluate reduce form.

parser.py

  • Contain all parsing function such as function that parse string of polynomial to array list.

processing.py

  • process the string data inside the program. Use function in this file with polynomial.py to solve the single-variable equation.

Install and Usage

Clone this repository and run the main.py

$ git clone https://github.com/Sosokker/Calculator-for-Matrix-and-Algebra

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.

      Command       or       Command[expression]

Whitespace and Case are not matter. Command is same as command.

For example.

[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

    Polynomial in this class is store in form of array. This are the following command.

  • Polynomial[expression] -> expression str or list

    • This Command use to print all property of the polynomial that user input.
    [1]: poly[3x^2-4x-10] 
    Input Polynoimial: 3x^2-4x-10
    ===============================
    Solution to 3x^2-4x-10 = 0
    Answer #1: x = -1.2769839649484336 | x = -798114978092771/625000000000000
    Answer #2: x = 2.610317298281767 | x = 2610317298281767/1000000000000000
    
    [2]: poly[x+31-x^2] 
    Input Polynoimial: x+31-x^2
    =============================
    Solution to x+31-x^2 = 0
    Answer #1: x = 6.0901699437494745 | x = 12180339887498949/2000000000000000
    Answer #2: x = -5.0901699437494745 | x = -10180339887498949/2000000000000000
    ===============================
    
    

Basic Operation

    Evaluate operation of Matrix, Polynomial, algebra element.

  • evaluate[expression] -> expression: string(mathematic expression) e.g. evaluate[1+2(5)]

    • Evaluate the operation of expression, Matrix, Polynomial.
    [1]: evaluate[1+2(5)]       
    Result: 11
    

Matrix

    Matrix in this class store in form of nested list.

  • Matrix[expression] -> expression: nested list

    • This Command use to print all property of the Matrix that user input.
    [1]: Matrix[[1,2],[3,4]]
    Input Matrix: Matrix(([1, 2], [3, 4]))
    Determinant: -2
    Tranpose Matrix: Matrix([[1, 3], [2, 4]])
    Inverse Matrix: Matrix([[-2.0, 1.0], [1.5, -0.5]])
    
  • det[expression] -> expression: nested list

    • This Command use to find determinant of matrix.
    [1]: det[[1,2],[3,4]]    
    Determinant: -2
    
  • tranpose[expression] -> expression: nested list

    • This Command use to find tranpose of matrix.
    [1]: det[[1,2],[3,4]]    
    Determinant: -2
    
  • inverse[expression] -> expression: nested list

    • This Command use to find inverse of matrix.
    [1]: det[[1,2],[3,4]]    
    Determinant: -2
    

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.