Re: algebra code
| From: | Juhan Kundla | Date: | Thu, 24 Oct 2002 13:25:50 +0000 |
| Subject: | Re: algebra code | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-121246@lists.php.net to get a copy of this message | ||
Hei.
Ühel ilusal päeval [24-10-2002 15:16] kirjutas Diana Castillo:
>
> does anyone know where I can get the code to solve equations with three
> unknowns?
> eg.
> 2x+4y+3z=234
> 3x+2y+44z=70
> 8x+33y+9z= 8
> I need the code to solve for x , y and z
> Thanks
The simplest way is probably use matrixes. You have a following matrix:
2 4 3 234
3 2 44 70
8 33 9 8
You must transform this matrix -- the main diagonal has to have values 1
and other values must be 0. This can be done via adding and subracting
the matrix rows. The result is:
1 0 0 x
0 1 0 y
0 0 1 z
Simple. :-)
And the method works no matter how many different equations/variables
you have, but there must be at least one independent equation for every
single variable.
Juhan
--
Vastus: Sest inimene loeb suunaga ülevalt alla.
Küsimus: Miks ülalpool vastamine on halb?