math tool pari/gp
Although linux is my platform of choice, I work extensively on windows. Open source and free compilers determine the applications. One of my favorite math tools is pari/gp. The website url is http://pari.math.u-bordeaux.fr/
If you want to compile the source code use the download link and have a fairly complete installation of cygwin on your development system.
The cygwin dll's required to run the application are cygcrypt-0.dll, cygncurses-8.dll,
cygperl5_8_5.dll, cygreadline5.dll and cygwin1.dll.
Here is an example of solving a system of linear equations using pari/gp
via two methods.
The example problem is a 3 x 3 matrix a and a column matrix b such that
a * x = b where x is the solution
Using pari/gp, begin by defining matrix a and column vector b
gp > a = [ 1, 2, 1 ; 3, -1, -3; 2, 3, 1 ]
a is a 3 x 3 matrix where each row is separated by a semicolon ;
gp > b = [ 3; -1; 4 ]
b is a 3 x 1 column vector or matrix
To solve the system of linear equations we can use the function matsolve(a,b)
c = matsolve(a, b) and the result is the column vector [ 3; -2; 4 ]
another method is to use the inverse matrix of a
inva = 1/a
since inva * a = identity matrix then inva * a * x = inva * b
so x = inva * b
x = (1/a)* b
a third method is to use the adjoint matrix of a and the determinant of a
which is the same as calculating the inverse of a
adja = matadjoint(a)
deta = matdet(a)
inva = adja / deta
x = inva * b
Later I will provide more information about the adjoint and inverse of a
square matrix
If you want to compile the source code use the download link and have a fairly complete installation of cygwin on your development system.
The cygwin dll's required to run the application are cygcrypt-0.dll, cygncurses-8.dll,
cygperl5_8_5.dll, cygreadline5.dll and cygwin1.dll.
Here is an example of solving a system of linear equations using pari/gp
via two methods.
The example problem is a 3 x 3 matrix a and a column matrix b such that
a * x = b where x is the solution
Using pari/gp, begin by defining matrix a and column vector b
gp > a = [ 1, 2, 1 ; 3, -1, -3; 2, 3, 1 ]
a is a 3 x 3 matrix where each row is separated by a semicolon ;
gp > b = [ 3; -1; 4 ]
b is a 3 x 1 column vector or matrix
To solve the system of linear equations we can use the function matsolve(a,b)
c = matsolve(a, b) and the result is the column vector [ 3; -2; 4 ]
another method is to use the inverse matrix of a
inva = 1/a
since inva * a = identity matrix then inva * a * x = inva * b
so x = inva * b
x = (1/a)* b
a third method is to use the adjoint matrix of a and the determinant of a
which is the same as calculating the inverse of a
adja = matadjoint(a)
deta = matdet(a)
inva = adja / deta
x = inva * b
Later I will provide more information about the adjoint and inverse of a
square matrix

0 Comments:
Post a Comment
<< Home