1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Help w/ Jacobi Iterative

Discussion in 'C' started by bluelolypop, Dec 1, 2006.

  1. bluelolypop

    bluelolypop New Member

    Dec 1, 2006
    Likes Received:
    Trophy Points:
    Hi I can't find how to do this in my book ANYWHERE so i dunno how to do this.. it's my hw and it's due tomorrow at 9 pm... if anyone can help that'd be nice... thanks a lot. These are the instructions but I don't even know how to start it..

    /* In void prob1() you are asked to solve the system of equations:

    a[0]*x[0]+a[1]*x[1]+...+a[4]*x[4] = b for i=0, 1, ..., 4

    using the Jacobi iterative method, where a[5][5] and b[5] are defined
    as follows:
    double a[5][5]={ 5., 0., 1., 0., -1.,
    0., 4., 3., -1., 0.,
    0., 0., 3., 1., -5.,
    1., -1., 0., 3., 0.,
    1., 1., 0., 0., -4.}
    double b[5]={-1., -4., 1.,-3., 3.0}, x0[5]={0.}, x1[5];

    In the method, one starts with an approximate x0[] and obtains an
    improved solution x1[]:

    x1 =1/a *(b - (sum on j, except j=i)a[j]*x0[j]))
    for i=0,...,4.

    Perform six** iterations to find an approximate solution
    x1[] starting from the initial guess x0[0]=x0[1]=...=x0[4]=0.0.
    After each iteration, print the values of x1[] by using %12.3e.*/

Share This Page