Monday, February 25, 2013

Gauss Jordan Calculator Using PHP Code

Here I am, once again I write a post. -_-'
What a pain, sure. But, I think for this time I'll be like it. For the time being, its the first time for me to write a code using PHP. Its not that difficult, but not easy too. The real pain on this code is the algorithm of Gauss Jordan and how to implement it using PHP on web development. I don't know much about it.

So, I'll tell you what I've been trough.

1. Understand the Gauss Jordan Elimination

If you are not sure how to solve a Gauss Jordan Elimination problem, the first advice of me is watching this video. Its Good. interesting explanation out there. :D




If you still don't understand, just skip it, watch another video or read another book. It will work out somehow and you'll understand it. Trust me! ;)

2. Sketch the Idea of the User Interface

The second thing that I did was make the user interface of the calculator. So, the use case that I made is

  • User enter the dimension of the matrix by using the sum of equation.
  • User click a button of "Submit"
  • User enter all of the coefficient according to the sum of equation.
  • User will click the other "Submit" button
  • The Result will be Shown on the other page. 

3. Write the Code

I think its too early to write the code (bad feeling). But, I do really want to see the User interface. Without a second thought, I write it down on my text editor. And then, the user interface is done! 
Right after that, I don't know what should I do! >.<

4. Don't Forget to Learn the Concept

The thing that should done first is Learning the Concept, don't forget that if you don't want to stuck on your project. That's my bad feeling. I should rely on it more. (LOL)
Then I learn it again using a lot of resource, ebook, video, forum, thanks google for that. :D
And now, the Gauss Jordan of my version is Already finished!

You can get the source code

here

. Let me show you the screenshot of the program. Its bad though. LOL



The Result Will Be like This

Tampilan Matrik Awal

1 4 5 6
5 6 7 8
3 4 2 13

Persamaan 1 menjadi pivot dan Persamaan 1 dirubah
1 4 5 6
5 6 7 8
3 4 2 13

Persamaan 2 dirubah
1 4 5 6
0 -14 -18 -22
3 4 2 13

Persamaan 3 dirubah
1 4 5 6
0 -14 -18 -22
0 -8 -13 -5

Persamaan 2 menjadi pivot dan Persamaan 1 dirubah
1 0 -0.14285714285714 -0.28571428571429
0 1 1.2857142857143 1.5714285714286
0 -8 -13 -5

Persamaan 2 dirubah
1 0 -0.14285714285714 -0.28571428571429
0 1 1.2857142857143 1.5714285714286
0 -8 -13 -5

Persamaan 3 dirubah
1 0 -0.14285714285714 -0.28571428571429
0 1 1.2857142857143 1.5714285714286
0 0 -2.7142857142857 7.5714285714286

Persamaan 3 menjadi pivot dan Persamaan 1 dirubah
1 0 0 -0.68421052631579
0 1 1.2857142857143 1.5714285714286
-0 -0 1 -2.7894736842105

Persamaan 2 dirubah
1 0 0 -0.68421052631579
0 1 0 5.1578947368421
-0 -0 1 -2.7894736842105

Persamaan 3 dirubah
1 0 0 -0.68421052631579
0 1 0 5.1578947368421
-0 -0 1 -2.7894736842105

Jadi,
X0: -0.68421052631579
X1: 5.1578947368421
X2: -2.7894736842105



Hope it useful!