usingMaths.com
Demonstrating and showing pupils and students one application of Mathematics.







<< Previous Next >>

Code for Simultaneous Equations With 3 Unknowns in Visual Basic (VB.Net)



3 by 3 Simultaneous Equations Code in Visual Basic (VB.Net)

To solve 3 by 3 simultaneous equations, we will simply eliminate the z variable, then call out to our simultaneous2unknown code module.



Algorithm Steps to Follow for Simultaneous Equations with 3 unknowns in VB.Net

Consider the equations:
         x + 2y - z = 2; and
         3x - y + 2z = 4
         2x + 3y + 4z = 9

Step 1:

Multiply equations 1, 2 & 3 by the LCM of the coefficients of variable z, divided by the z coefficient of the respective equation.
         (4/-1) X (x + 2y - z = 2)
    ⇒     -4x - 8y + 4z = -8
         (4/2) X (3x - y + 2z = 4)
    ⇒     6x - 2y + 4z = 8
         (4/4) X (2x + 3y + 4z = 9)
    ⇒     2x + 3y + 4z = 9

Step 2:

Subtract the new equations obtained in Step 2; eqn (2) from eqn (1) and eqn (3) from eqn (2).
         -4x - 8y + 4z = -8
    -     6x - 2y + 4z = 8
    ⇒     -10x - 6y = -16
         6x - 2y + 4z = 8
    -     2x + 3y + 4z = 9     ⇒     4x - 5y = -1

Step 3:

Call out to our simultaneous2unknown code module to solve for x and y.
⇒         (x, y) = (1, 1);

Step 4:

Obtain z by solving for z from any of the original equations, using the found values of x and y.
         x + 2y - z = 2
⇒         1 + 2(1) - z = 2;
⇒         -z = 2 - 3 = -1;
⇒         z = -1/-1 = 1;


Create a new class file; Project, Add Class.
Call it Simultaneous3Unknown.vb.
Optionally, create a new module file; Project, Add Module.
Call it Simultaneous3UnknownModule.vb.
Type out the adjoining Visual Basic (VB.Net) codes for solving simultaneous equations with 3 unknowns.



Note: The code module for finding LCM has been explained in the Primary Category.

You can instead comment out the previous VB.Net code from the main module or simply continue from where it stopped.


So!

Feel free to try out your own set of x_coefficients, y_coefficients, z_coefficients and equals values for 3 by 3 Simultaneous Equations.









<< Previous Next >>