Evaluate matrix expressions in Python.
- Windows
python matrix.py
- Mac/Linux
python3 matrix.py
CREATE MATRIX
*Enter name*: {name_of_matrix}
*Enter order*: mxn
*Enter row 1*: [a(1,1) a(1, 2) ... a(1, n)]
.
.
*Enter row m*
DISPLAY MATRIX {name_of_matrix}
INDEX MATRIX {name_of_matrix} x(int) y(int)
EVAL {expression}
EVAL C=A+B+..
EVAL C=A-B-..
EVAL C=AxBx..
TRANSPOSE MATRIX B=A
here, B becomes the transpose matrix of A
- What is a matrix?
Matrices are an ordered rectangular array of numbers(real or complex) or functions arranged into rows and columns. Example:
A = ┏1 2 3┓
┃4 5 6┃
┗7 8 9┛
The horizontal lines are called rows and the vertical lines are called columns. Matrices are always represented usign capital letter. Matrices are represented by square or simple brackets. A matrix of order
mxn
is represented asA = [aᵢⱼ]ₘₓₙ
.
- What is the order of matrix?
It gives use the number of rows and columns of a matrix. For a matrix of
m
rows andn
columns, its order ismxn
and is read asm by n
- What is the logic for matrix addition?
For two matrices
A = [aᵢⱼ]ₘₓₙ
andB = [bᵢⱼ]ₘₓₙ
,A + B = [aᵢⱼ + bᵢⱼ]ₘₓₙ
Order of both matrices should be the same
- What is the logic for matrix subtraction?
For two matrices
A = [aᵢⱼ]ₘₓₙ
andB = [bᵢⱼ]ₘₓₙ
,A - B = [aᵢⱼ - bᵢⱼ]ₘₓₙ
Order of both matrices should be the same
- What is the logic for matrix multiplication?
For two matrices
A = [aᵢⱼ]ₘₓₙ
andB = [bⱼₖ]ₙₓₚ
,A x B = C
Here,C = [cᵢₖ]ₘₓₚ
wherecᵢₖ
is sum of product of iᵗʰ row of A and kᵗʰ column of B Number of columns of A should be the same as number of rows of B [n = n]
- What is the transpose of a matrix?
The transpose of a matrix can be obtaiend by interchainging rows and columns of a matrix. For a matrix
A = [aᵢⱼ]ₘₓₙ
, its transpose isA' = [aⱼᵢ]ₙₓₘ
. For example,
A = ┏1 2 3┓
┃4 5 6┃
┗7 8 9┛
then,
A' = ┏1 4 7┓
┃2 5 8┃
┗3 6 9┛
Note
You can contribute to this repository by creating a pull request