1. ## need php code

I need to work with a matrix. The technique I learned in linear algebra was row reduction. Is there a php code to do that, or is there a superior method since I'll have use of a computer to do the calculations?

2. I don't know of any language that specifically supports matrices, but PHP does have something called two dimensional arrays. C, Basic, Pascal< PHP, and many other programming languages support 2d arrays.

2d arrays are, for all intents and purposes, matrices.

3. ## way to solve...

I understand that I can use the 2d arrays to duplicate the way I wish to store data...

What I need is a way to solve this system of equations. The way I learned in college was to use row reduction. Is there a better method since I have use of a computer, and does anyone know where there is code already written for this task?

5. I'm not familiar with row reduction (unforunately, I never studied matrices -- I miss doing academic math).

Can you explain, briefly? Maybe we can come up with some code that will do it.

S

ps - I found this, but I'm not following basic matrix terminology/markup.. sorry.

6. Definitely, I agree with scoates. If it can be done mathematically, we can figure out a way to do it with a computer and PHP with a bit of deductive reasoning. Unfortunately, I also do not understand row reduction. Can you give an example and explanation?\

Sketch

7. Before and After data would help, too. (-:
Inputs and Outputs. You know what I mean. (-:

S

8. I don't know the english math terms, but I think you mean the Gausse-Jordan method by row reduction?
If so, then here's a basic explanation...

If you have
x + 2y + 4z = 31
3x - y + z = 10
5x + y + 2 = 29

Then you can write that in a matrix

1 2 4 31
3 -1 1 10
5 1 2 29

You could find this by just solving the first step, but if you have different coëficcients, then it could be hard to calculate that, so we use Gausse-Jordan to simplify the matrix with "row operations":

-switch rows (Rij) //i=row1, j=row2
-multiply a row by a value (nRi) //i is the n°of the row
-Ri + nRj
or all together
nRi + mRj (with n!=0)

We are gonna search for a matrix like
1 0 0 r
0 1 0 s
0 0 1 t
so x=r, y=s and z=t

We do this with a limited ammount of row operations, and there's a little trick, the method of Gauss-Jordan

With the row operations R2-3R1 and R3-5R1 we get:
(1) 2 4 31
0 -7 -11 -83
0 -9 -18 -126

You could follow the row operations (slower) or do this:
eg the -1 on R2 becomes (-7*(1))-(2*0)=-7
the 1 on R2 becomes (1*(1))-(4*3)=-11
...

You get it?
-R2 and -1/9R3 gives

1 2 4 31
0 (7) 11 83
0 1 2 14

No need to use the trick here...
Then 7R1-2R2 and 7R3-R2 and 1/3R3 gives

7 0 6 51
0 7 11 83
0 0 (1) 5 //first 0 0 3 15 but we did 1/3R3...

eg the 1 on R1 becomes (1*(7))-(2*0)=7
the 2 on R3 becomes (2*(7))-(11*1)=3 (after wich we diveded R3 with 3 so it becomes 1
...
Let's continue

R1+6R3, R2+11R3, 1/7R1 and 1/7R2 ->

1 0 0 3 //x=3
0 1 0 4 //y=4
0 0 1 5 //z=5

eg the 51 on R1: (51*(1))-(6*5)=21 divided by 7=3

Is there anyone that understands this or did I explain it that bad?

Ofcourse this is just the basic stuff, I doubt it will be easy in PHP
You can get solutions with more unknown terms then there are rows, so you are free to choose it then - or the other way around is possible too.
If the ammount of rows of the matrix WITH known terms does not equel those of the matrix WITHOUT the known terms (in this case
1 2 4
3 -1 1
5 1 2)
then the matrix is false.

S

actually this is just the veryveryvery basic of matrices

but i like them, and you are all using them without knowing -> eg if you go to school, you get grades

------- chemistry | math | fysics | ...
John***********4*************9***********4
Homer**********8*************6***********4
Leela**********2*************10**********10

and look! we have a matrix

11. sorry.. that might have been a perfect example.
Here's my hour total for the past 2 weeks (and I'm still not done today):

Total 102.55

ouch.

That calls for some beer and some sleep -- possible a cigar, even.

ok, NOW we're offtopic. (-:

S

12. Thanks guy for picking up the post again... I still need some help! I dont understand arrays in PHP well enough. The explaination was a good try on what row reduction is. The project needs to be able to be done over the web on the fly, so I hope there is a solution we can all come up with in PHP!

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•