simultaneous equations

This is a discussion on simultaneous equations within the C Programming forums, part of the General Programming Boards category; how would i go about the following: read in three coefficents and the constant term for three simultaneous equations in ...

  1. #1
    Registered User
    Join Date
    Apr 2003
    Posts
    2

    simultaneous equations

    how would i go about the following: read in three coefficents and the constant term for three simultaneous equations in three unknowns: aix+biy+ciz=di for i=1,2,3 find the solution (for x,y and z).any help would be very much appreciated!

  2. #2
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    use linear algebra. Put the equations in matrix form (Ax = b) and then use gauss elimination. Make sure you get no zeros in the diagonal by using pivoting.

    More in-depth info:
    http://www.damtp.cam.ac.uk/user/fdl/...h98/linear.htm

    If time is critical, you can first split A into two triangular matrices L & R (left triangular and right triangular):

    LR = A
    Ax = b

    LRx = b
    L(Rx) = b

    Rx = y
    Ly= b

    First, solve Ly = b, then Rx = y. Since L and R are triangular, solving them will be easier.
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  3. #3
    Registered User
    Join Date
    Apr 2003
    Posts
    2

    Unhappy matrices

    ok thanks.i know how to do matrices by hand but how do i incorporate them into a program?i really do not understand programming!please help me!!

  4. #4
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    Since you know the dimensions:
    Code:
    typedef struct
    {
       double _11, _12, _13;
       double _21, _22, _23;
       double _31, _32, _33;
    }Matrix3x3;
    
    typedef struct
    {
       double _1;
       double _2;
       double _3;
    }Matrix1x3;
    
    Matrix3x3 A;
    Matrix1x3 b;
    i really do not understand programming
    Then perhaps you should start with something easier...
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Read coefficients of linear equations from file into 2d array
    By omaralqady in forum C++ Programming
    Replies: 6
    Last Post: 06-20-2009, 07:39 AM
  2. Simultaneous linear Equations
    By dvd4alll in forum C# Programming
    Replies: 8
    Last Post: 02-08-2008, 06:11 PM
  3. LUP Decomposition (simultaneous equations)
    By Markallen85 in forum C Programming
    Replies: 6
    Last Post: 08-24-2003, 02:08 AM
  4. Solving linear equations
    By PJYelton in forum C++ Programming
    Replies: 1
    Last Post: 12-05-2002, 05:00 PM
  5. equations for a program
    By anthonye in forum C Programming
    Replies: 4
    Last Post: 06-19-2002, 04:38 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21