Thursday, April 10, 2014

Freemat Matrix Operations

Being an oil industry guy and the interest of using Freemat is mainly for using seismic, logs and related application i will mainly concentrate on these and some basic mathematical operations.

Matrix Addition. 
--------------------------------------------------------------------------------------------------

Source - mathsisfun.com

In order to add two matrices the size of matrix has to be same . Whats size? click here
If 
A is (5X2) and B is (5X2 ) then they can be added or else not possible.
You can individually add each element of the same location like the image.
Location of '3' of first matrix is (1,1) and
Location of '4' of second matix is (1,1) 

so they can be added (3+4) = 7 for the same location (1,1)


Matrix subtraction.
--------------------------------------------------------------------------------------------------------------


Source :- mathsisfun.com

The theory is same as the addition but here we are just subtracting. 


Matrix Multiplication
------------------------------------------------------------------------------------------------------------------

1. Scalar Multiplication

Multiply a matrix by a constant value is a scalar multiplication. Like

Source :- mathplanet.com


2. Vector Multiplication



This is an operation where we don't require a similar size of matrix but we need to check the number of columns of first matrix and number of rows of second matrix.
If they match then we can multiply two Matrix.
Result = Column * Row
The multiplication is shown in the above pic.

Matrix Division
----------------------------------------------------------------------------------------------------------------------------------
1. Scalar Division

This means you can divide a matrix by a scalar like

A= | 4 8 10|
      |6 4  12|

A/2= |4/2 8/2 10/2|
         |6/2 4/2 12/2|

So that is easy but what about dividing a matrix by another matrix
That part is a little tricky
Direct Matrix Division is not possible where you divide each element by another 
So if

A= | 4 8 10|                                    B= | 1 2 3 |
      |6 4  12|                                          | 5 8 9 |

then A/B = tricky
A/B can be done by A*B(Inverse)
Just like in real number 10/2 = 10*2(inverse)
           2 inverse is 1/2 = 0.5

But finding  the inverse of a matrix is not so easy .
But in Freemat you can do it easily 
Points to remember is that 
a. Only Square Matrix have Inverse 
b. Not all square matrix have inverse . Those who dont have inverse are called Singular.



No comments:

Post a Comment