# Two Equations, Three variables

1. Jul 28, 2010

I'm working on a project where I have two equations with three variables. I know that the solution will be a line; however I need specific values. Is there a way for me to do this if I know some general parameters for each variable? For example, if a=n1*x+n2*y+n2*z and b=m1*x+m2*y+m3*z, and I know that x, y, and z are all greater than zero or equal to zero, but less than 100, is there a way to solve this?

I can solve this the "manual" way of extracting this data from my program for each set of equations. However, there are literally 100s of systems of equations that I need to solve, so I was wondering if there was a way I could save time :)

Thanks for any help!

Much appreciated,
Kelsey

2. Jul 28, 2010

### Staff: Mentor

If you have two equations in three unknowns, what you have geometrically is two planes in three-dimensional space. There are three possibilities: the system has no solutions at all (the planes are parallel and don't intersect); the planes intersect in a line; the planes are coincident (every point on one plane is also on the other).

Knowing that x, y, and z are nonnegative and less than 100 doesn't really help all that much. It means only that solutions are limited to a part of the first octant. I don't know of any shortcuts for finding solutions to your systems.

3. Jul 28, 2010

### sshzp4

Read the wikipedia entries on the topics optimization and linear programming.

If you know that your solution is a line then you need to find out the exact conditions of the line where the 0\leq x,y,z <100 are all satisfied simultaneously. Assuming you can obtain x(z) and y(z), you can then think about plotting x and y on the same plot vs. z. Now chop off the sides that dont satisfy the constraint equation you have for 0<=z<100. Then cut the lines x and y into line segments where the values of x and y lie between 0 and 100. Examine if there are any portions of the line segments that lie with in the truncated z region on the plot simultaneously.

A different way of saying the same thing as above: Take your x(z), and y(z) regions and find values of z for which x(z) is lesser than 100 and greater than 0. You get two values of z here which indicate the set of values of z for which x satisfies the given constraint. Next repeat the same for y(z), you again get 2 values of z denoting another set of values z can take to satisfy the constrain on y. Now find the intersection of these two sets and the third set $z \in [0,100)$. If the intersection is a null set, well, you don't have any solutions to the system. Otherwise, you should have several values of z to choose from which should satisfy all the equations you are given. The final regions depend on each value of a,b,m_i, n_i that you select out of your 'literally 100s of systems of equations'.

There might be more succinct answers, but this process gives you the basic idea of how the linear algebra solution has to be implemented.

Edit: I am assuming that your 100s of equations come from real measured data. If so, then the method will apply almost surely always. However, if you are using a random number generator that generates whole numbers or are simulating a finite element/finite difference type system, you might want to check, or enforce, that the expression m1*n2 - m2*n1 \neq 0, always. This relates to the linear independence of x and y variables. If that expression is zero, then you can think of constructing another strategy using a similar approach. And note that you can have no solution, single solution or many solutions as Mark44 says. Again, if your system comes from measured data, you will usually have many solutions. How you choose which value to use is completely up to you.

Last edited: Jul 28, 2010