Sunteți pe pagina 1din 13

Introduction: Solving equations systems is a very important matter of study especially when it comes down to choosing the best

method to solve them. As a Systems engineering student its very important for me to use the computational tools that technology offers in order to make the best solution or choose among the existing solutions to find the best method that can lead me to the solutions in the least execution time and use, in an optimal way, the resources of the computer. In this report we will try to compare two direct methods versus an indirect method, then after comparing we will try to say which of them is the best based in three specific criteria. The direct methods chosen for this paper are Gauss and Gauss-Jordan method. These methods have already been implemented by the tool we will be using (Matlab). The indirect method that has been chosen is Gauss-Seidel method. We will apply these methods to sparse matrices. As comparison criteria we will use the time of execution, the error existing in each method and the memory consumed by each one of them during the execution. At the end several conclusions will be given as a result of the analysis exposed in this report. 1. A BRIEF REVIEW OF SPARSE MATRICES A sparse matrix is a matrix populated primarily with zeros. The term itself was coined by Harry M. Markowitz. Conceptually, sparsity corresponds to systems which are loosely coupled. Consider a line of balls connected by springs from one to the next; this is a sparse system. By contrast, if the same line of balls had springs connecting each ball to all other balls, the system would be represented by a dense matrix. The concept of sparsity is useful in combinatorics and application areas such as network theory, which have a low density of significant data or connections.

2. SOLVING SPARSE EQUATIONS WITH DIRECT METHODS 2.1 GAUSS METHOD This method consists in obtaining, from an n-order matrix given, an equivalent lineal system of equations characterized for having in the last equation n unknown variables, in the n-1 equation n-1 variables and so on until having the number 1 equation with only 1 unknown variable. If we represent this solution through a matrix we will see a triangle matrix. This method can be used in Matlab with the following code

Where A is the sparse equation, B is the solution of that equations system and n is the order of the square matrix A. 2.2 GAUSS-JORDAN METHOD Gauss Jordan method allows us to solve up to 15 or 20 simultaneous equations, with 8 or 10 significant digits in the computers arithmetic operations. This procedure is characterized from the Gaussian method because when an unknown is eliminated it is also eliminated from all the leftover equations.

This method is applied in this report by means of the following function implemented in Matlab.

3. INDIRECT METHODS 3.1 GAUSS-SEIDEL METHOD This method is an iterative method in which from an array of solutions called Ki we can find another array of solutions that approaches to the true solutions of the system given, by means of an algorithm that little by little uses the new array of solutions and generates another to use it again and so on until getting the most approached array to the original solution of the system. This method is implemented by means of a created function in matlab:

4. SOLUTIONS GIVEN BY EACH METHOD TO AN SPARSE EQUATION OF 10X10. Right now we only want to show the way results are given by each method and see how similar those solutions are. The tolerance is 0.001.

We can see that effectively the results are almost the same, we can also see that while Gauss and Gauss-Jordan are very accurate methods (our direct methods), Gauss-Seidel is still close to them. 5. EXECUTION TIME Now we have come to one of the most important criteria to establish which is the most effective method. For this purpose we will measure the time that each method takes when solving the same equations system while the order of the sparse matrix varies. These data will be displayed by an specific function in Matlab:

in the first column we see the order of the sparse matrix that each method will be given to solve, the second column corresponds to the Gauss method and we can see that its timing is really low and almost constant, Gauss-Jordan method on the other hand begins taking longer with matrices of order 50 and on, we will appreciate that later with some graphics that compare Gauss and Gauss-Jordan methods. So we can also see in the fourth column that unfortunately our GaussSeidel algorithm becomes the most inefficient and delayed method if we compare it with Gauss and Gauss-Jordan methods. But its important to see the point or the moment when our Gauss-Seidel algorithm begins to differ from the other ones. so we will make a graph showing time versus order. As we can see in the times above it is not necessary to do it with a high order for the matrix because our Gauss-Seidel method begins to take a lot of time with an order of 50, so we will make this graph for an order of 20. The graph shows that for an order n each method has a time that each one took to solve the system.

In this graph we can notice that for an order of 10 in the spare matrix the time that our algorithm of Gauss-Seidel takes is very high compared with the other methods thus we can say that Gauss-Jordan and Gaussian methods are even more effective than our algorithm for solving equations systems. The toletance used here is 0.001. Now lets do the same graphic but with a tolerance of 0.01:

Here we can see that if we reduce the tolerance, the execution time for Seidel will decrease this is because the tolerance will be reached in less iterations, but the time is still very high though. Therefore its interesting to see what is the most effective method (the best implemented in the computer) between Gauss and Gauss-Jordan. For this reason we will increase the order of the sparse matrix. This time we will use a matrix of 100x100 and see what happens with both methods when being used to solve this system.

Here we can see that Gauss-Jordan method reaches times a way less than Seidel but theyre very high if we compare this method with Gaussian method. Gauss doesnt seem to change, its times are very close to zero, so lets look closer:

We can still see that the times are really low but Gaussian method is a way lower from Gauss-Jordan. Although the curve for Gauss-Jordan method is not soft at all we can see that the tendency to increase its time still remains.

6. ERROR ANALYSIS Regarding errors we can also make a comparison with these methods, for this purpose we will set the solutions given by Gaussian method as the exact solutions for our sparse equations. So we will compare the errors of Gauss-Jordan and Gauss-Seidel methods and then we will plot them to see what is the most accurate. For a 10th order matrix we obtain these errors

The graphs are even clearer when trying to see which one is the most accurate. So for a tolerance of 0.001 and a maximum order of 10.

Well we can notice the great difference with these methods regarding errors, now lets see if they increase if the order of the matrix is higher, lets try an order of 50.

Here we see that certainly the error increases when the order of the matrix increases. So the higher the number of iterations is the higher error we will obtain. 7. MEMORY USAGE ANALYSIS At this point we have already seen which method is the most effective regarding time and error, but the memory usage is very important if we are working with computers that have some limits in their hardware, so we will list the variables used by each method and their space in memory after solving a 50x50 matrix. Gaussian method:

Gauss-Jordan method:

Gauss-Seidel:

As we can see our Gauss-Seidel method uses more variables than any of the remaining methods for this report. Gaussian method seems to be the most effective because even the solution has a low amount of bytes than the other two methods.

CONCLUSIONS y The algorithm created to study and compare Gauss-Seidel method was not the best and most effective algorithm. y When comparing the timing of the three methods we found out that Gaussian method is the best computational method to solve matrices of highest orders with an almost-constant time as if it was solving a low order matrix. Regarding the Gauss-Jordan and Seidel methods we conclude that Gauss-Jordan is effective as well but if it is compared with Gaussian method we become aware of their difference especially when the order of the matrix they both are solving increases. Our Gauss-Seidel implemented solution seems to be the least effective regarding time because its timing rises almost exponentially as the order increases. y The error of Gauss-Jordan and Gauss-Seidel method increases as the order of the matrix increases we can see this behavior in the graph at numeral 7th ERROR ANALYSIS. It important to know that the method we assumed as exact is the Gaussian Method. Gauss-Jordan method error also increases when the order of the matrix increases. y Regarding the amount of memory and space used per variable we can see in the solution of the Gaussian method that it is perhaps the most effective. The results can be seen in the numeral 7.

S-ar putea să vă placă și