Re: Adding Two-Dimensional arrays together
Oh yes I can calculate simultaneous equations by hand. I just found it difficult using a loop to attempt to calculate them with like addition. I just don't understand the whole calculation via a loop with a 2D Array of [3] [4]. I'm a total noob at C++. I've tried an attempt and to me it doesn't seem correct.
Re: Adding Two-Dimensional arrays together
Please, lay out the sequence of steps you'd use to solve this pair of equations, and we'll go from there.
9 = 4x + 6y
-3 = x - 10y
Re: Adding Two-Dimensional arrays together
Quote:
Originally Posted by
TBsparky
Oh yes I can calculate simultaneous equations by hand.
The issue is how you are solving these by hand. If you're solving them by hand using the algrebaic way of doing things, you will be here for months writing a program to simulate what you learned in junior high school. Heck, an expert would be here for weeks writing such a program.
The easiest way that simultaneous equations are solved by computer is to use Gaussian elimination. Did your teacher discuss that? If not, please look that up, as you cannot possibly write a program to solve equations in the "traditional" math book way.
Regards,
Paul McKenzie
Re: Adding Two-Dimensional arrays together
No she did not discuss the Gaussain method. As far as i know its Solving Simultaneous equations by the use of matrices
Re: Adding Two-Dimensional arrays together
Quote:
Originally Posted by
TBsparky
by the use of matrices
Key phrase. Do you know what this means? "use of matrices" can mean anything.
Re: Adding Two-Dimensional arrays together
Quote:
Originally Posted by
TBsparky
No she did not discuss the Gaussain method. As far as i know its Solving Simultaneous equations by the use of matrices
And Guassian method uses matrices.
Again, you cannot write a program within a reasonable time trying to solve equations the way you do by hand using traditional math. The routine you want is called Guassian elimination. Just do a google search, and you will see the routine explained to you.
If your teacher wants you to solve equations as you do with traditional math you learned in school, he or she is playing a very cruel joke on you. You won't, and I bet your entire class won't be able to complete the assignment, or even know where to start if that is really what the teacher is expecting. So I'm assuming your teacher is wanting you to solve the equations using Gaussian elimination (there are other methods, but this is the easiest to implement).
Edit:
Here is a link to a previous topic. Please read:
http://www.codeguru.com/forum/showth...light=gaussian
Regards,
Paul McKenzie
Re: Adding Two-Dimensional arrays together
Quote:
Originally Posted by
Paul McKenzie
Again, you cannot write a program within a reasonable time trying to solve equations the way you do by hand using traditional math.
You can actually, for this specific case: 2 equations in 2 unknowns. It's simple enough in that case to write out the substitutions explicitly.
Gaussian elimination is the more general solution for handling n equations in n unknowns, of course.