hi there, im a student in gr11 currenting taking computer science.
I have a summative due 2-3 days from now and need help with explantion on one part of my program that im missing.

So far I've learned, functions,loops, and some understanding of arrays.
The project is to write a program that solves linear system of equations by elimination. a 4 by 5. example...

3a +2b -7c + 5d = -9
-2 -b + 5c -d = 14
a + B + C + d = 8
5a + 2b -3c +4d =8

solution: A=2, b-1,c=4, d=3

There was two possible solution. one was make a really long repetitive elimination for each varable by isolating them and then solving it for each of the remaining 3. then you solve for 2 then 1.

Another one was when i saw a buddy of mine do something called matrix gaussian elimination. He helped me get the basic understanding as in he told me to look on the internet and this is what i've concluded.
you want an result to look like..

aa bb cc dd :A
0a eb fc gd :B
0a 0b hc id :C
0a 0b 0c jd :D

i've done the problem on paper solving by using my head and i think you want all the numbers below a to be the same then subtract, then all the numbers under e, under h and solve in some way.

Can anyone please explain how to get this into a program in C++. I'm sorry this is very long to read.

PS:teacher never taught or even understand that much of matrix(though i think he lied on that part that he doesnt know alot about it.)

PPS: basic rules inorder to get the results...
-you can add/subtract one of the rows A B C D to another changing all the numbers.
-you can add/subtract any two rows and the sum/value can replace another row
e.g A+B = C or A+B=D

unfortunetily.. the computer is dumb and you have to find a way to make the computer do such a thing :(

Recommended Answers

All 5 Replies

thanks but I've read that its how i got started

thats exactly what i did and how i found out about this website. allot of times that i was looking at past topics about this and i still don't quite get it.

Please note that i am only a high schooler who JUST started programing.

i also whiling offline found out about how in gaussian elimation, you can also multiply/divide as well.

what a learned additionally was that the set of numbers...

3 +2 -7 + 5 = -9
-2 -1 + 5 -1 = 14
1 + 1 + 1 + 1 = 8
5 + 2 -3 +4 =8

you can do (-2/3) to get 0.6666 and then multiply the "row with =9" as the answer by that amount and subtract to the "row with =14". What i was wondering is.. can you do the same with (3/-2)? and multi "Row with =14" by the amount and then subtract by that means? or not?

I would start by looking at the set of equations on wikipedia that you have every step for. This will let you know if/where you have gone wrong. Then once it works on the case that you have the solution for, you can run it on your actual class problem.

It will be tough to write this for general sets of equations, but I would imagine your instructor would be OK with you writing it for "nice" cases of sets of equations - that is, when you can do the whole thing and come out with integers in each step.

Dave

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.