Thread: Solving systems of linear equations with C programming?

  1. #1
    Registered User
    Join Date
    Jun 2011
    Posts
    1

    Solving systems of linear equations with C programming?

    How would you solve a system of linear equations using C programming?
    The equations are like this:

    3a +4b +6c +7d....=34
    4a +6b +3c +8d....=26
    2a +2b +9c +2d....=84
    ..............................

    Basically, you have 'x' many variables and 'x' many equations, where 'x' is a variable number. I tried converting the system of equations into matrices, like this:

    [3, 4, 6, 7,...]______[a]_______[34]
    [4, 6, 3, 8,...]_X____[b]____=__[26]
    [2, 2, 9, 2,...]______[c]_______[84]
    [................]______[...]______[...]

    But I have no idea what to do now. I tried looking it up online, and found something called Gaussian Elimination, which seems to be able to solve these types of problems, but I have no idea how it works or how to code it.
    Last edited by Dog; 06-21-2011 at 09:50 AM.

  2. #2
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,909
    Then you need to study Gaussian elimination. You can not program the solution to a problem you don't understand. Work through some simple Gaussian elimination problems by hand on paper until you totally understand the process. Google should turn up plenty of resources on that. Then, begin coding in small chunks, testing as you go. If you get stuck, post back and we'll help you.

  3. #3
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Gaussian elimination is as good a way to go as any to begin with. If you've found it online, then you have found either a text description or the algorithm itself, or both. If I were to post something, it would be a text description or the algorithm, so I don't know what value I can add exactly. I would start with a fixed number of variables/equations, rather than trying to be fancy and solve general nxn.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. LINEAR EQUATIONS please help
    By apple_ranger in forum C Programming
    Replies: 18
    Last Post: 09-08-2008, 05:49 AM
  2. Simultaneous linear Equations
    By dvd4alll in forum C# Programming
    Replies: 8
    Last Post: 02-08-2008, 07:11 PM
  3. Solving linear equations
    By PJYelton in forum C++ Programming
    Replies: 1
    Last Post: 12-05-2002, 06:00 PM
  4. Linear equations
    By amandad40 in forum C Programming
    Replies: 1
    Last Post: 10-29-2002, 04:54 AM
  5. Linear equations
    By amandad40 in forum C Programming
    Replies: 5
    Last Post: 10-24-2002, 09:06 AM