IITDU Forum
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Methods collection zone

3 posters

Go down

Methods collection zone Empty Re: Methods collection zone

Post by BIT0101-rayhan Fri May 21, 2010 1:15 pm

a slight mistake u have made toma.....at jacobi iteration ....inside the fabs function u forgot to divide the x[i]-xo[i] by a x[i]..... Very Happy
BIT0101-rayhan
BIT0101-rayhan
Release Candidate
Release Candidate

Posts : 107
Points : 177

Back to top Go down

Methods collection zone Empty Re: Methods collection zone

Post by BIT0101-rayhan Fri May 21, 2010 1:24 pm

[#include
#include

int main(void){
int n = 3, r = 1.5;
//if r is over relaxed then set the value between 1 and 2, if underelaxed
//then set it at the value between 0 and 1
//if r=0, then there is no relaxation at all and it is identical
//to the gauss seidel method
double x[3], b[3] = {5, 15, 8}, e=.000001;
double a[3][3] = {
2, 1, 1,
3, 5, 2,
2, 1, 4
};

int count=0;

int i, j;
for(i=0; i
BIT0101-rayhan
BIT0101-rayhan
Release Candidate
Release Candidate

Posts : 107
Points : 177

Back to top Go down

Methods collection zone Empty Re: Methods collection zone

Post by BIT0122-Amit Fri May 21, 2010 1:39 pm

wow!! Razz ray is here as well..
ray, you need to give the codes inside the code tag.
like this:

Code:

[code]
#include<stdio.h>
int main(void){
      return 0;
}
[/code]
BIT0122-Amit
BIT0122-Amit
Founder
Founder

Course(s) :
  • BIT

Blood Group : O+
Posts : 4187
Points : 6605

https://iitdu.forumotion.com

Back to top Go down

Methods collection zone Empty Re: Methods collection zone

Post by BIT0101-rayhan Fri May 21, 2010 3:44 pm

i tried it like that... but i think my browser is giving me some probs...
BIT0101-rayhan
BIT0101-rayhan
Release Candidate
Release Candidate

Posts : 107
Points : 177

Back to top Go down

Methods collection zone Empty Re: Methods collection zone

Post by BIT0107-Toma Fri May 21, 2010 3:45 pm

@Ray:
Thanks dosto. [You must be registered and logged in to see this image.]

In Jacobi & Gauss method I didn't divide x[i]-xo[i] by a x[i] coz it means
relativity and sir told that sometimes it makes problem. So we can
remove it. [You must be registered and logged in to see this image.]

In relaxation method if we set no relaxation then r=1 but you wrote r=0. [You must be registered and logged in to see this image.]
BIT0107-Toma
BIT0107-Toma
Programmer
Programmer

Course(s) :
  • BIT

Blood Group : B+
Posts : 280
Points : 453

Back to top Go down

Methods collection zone Empty Re: Methods collection zone

Post by BIT0101-rayhan Fri May 21, 2010 3:49 pm

oh... yes.. typing mistakes...
BIT0101-rayhan
BIT0101-rayhan
Release Candidate
Release Candidate

Posts : 107
Points : 177

Back to top Go down

Methods collection zone Empty Re: Methods collection zone

Post by BIT0101-rayhan Fri May 21, 2010 3:50 pm

these are chapter 12 sources...
[You must be registered and logged in to see this link.]
BIT0101-rayhan
BIT0101-rayhan
Release Candidate
Release Candidate

Posts : 107
Points : 177

Back to top Go down

Methods collection zone Empty Re: Methods collection zone

Post by BIT0101-rayhan Fri May 21, 2010 3:52 pm

method of relaxation...
Code:

#include
#include

int main(void){
    int n = 3, r = 1.5;
    //if r is over relaxed then set the value between 1 and 2, if underelaxed
    //then set it at the value between 0 and 1
    //if r=1, then there is no relaxation at all and it is identical
    //to the gauss seidel method
    double x[3], b[3] = {5, 15, 8}, e=.000001;
    double a[3][3] = {
    2, 1, 1,
    3, 5, 2,
    2, 1, 4   
    };

    int count=0;

    int i, j;
    for(i=0; i
        x[i] = b[i]/a[i][i];

    int isError;
    do{
        isError=0;

        for(i=0; i
            double sum = b[i];
            for(j=0; j
                if(i!=j)
                    sum = sum - a[i][j]*x[j];
            double dummy = sum/a[i][i];
            dummy = r*dummy + (1-r)*x[i];
            if(isError==0 && fabs(dummy-x[i])>e)
                isError = 1;
            x[i] = dummy;
        }
        count++;
    }while(isError);

    printf("Roots are: ");
    for(i=0; i
        printf("%f  ", x[i]);
    printf("& solved by %d iterations\n", count);

    return 0;
}

BIT0101-rayhan
BIT0101-rayhan
Release Candidate
Release Candidate

Posts : 107
Points : 177

Back to top Go down

Methods collection zone Empty Re: Methods collection zone

Post by BIT0122-Amit Fri May 21, 2010 3:54 pm

Still a little bit of problem. are the heaeder files stdio and math used here? I can edit it for you if your browser problem persists. (It happens sometimes..)
And Thanks for the chapter 12 codes Very Happy
BIT0122-Amit
BIT0122-Amit
Founder
Founder

Course(s) :
  • BIT

Blood Group : O+
Posts : 4187
Points : 6605

https://iitdu.forumotion.com

Back to top Go down

Methods collection zone Empty Re: Methods collection zone

Post by BIT0107-Toma Fri May 21, 2010 4:11 pm

Ray amarta copy koira edit koira paste marche.. [You must be registered and logged in to see this image.]
BIT0107-Toma
BIT0107-Toma
Programmer
Programmer

Course(s) :
  • BIT

Blood Group : B+
Posts : 280
Points : 453

Back to top Go down

Methods collection zone Empty Re: Methods collection zone

Post by BIT0122-Amit Fri May 21, 2010 4:14 pm

BIT0107-toma wrote:Ray amarta copy koira edit koira paste marche.. [You must be registered and logged in to see this image.]

kongula :O
BIT0122-Amit
BIT0122-Amit
Founder
Founder

Course(s) :
  • BIT

Blood Group : O+
Posts : 4187
Points : 6605

https://iitdu.forumotion.com

Back to top Go down

Methods collection zone Empty Re: Methods collection zone

Post by BIT0107-Toma Fri May 21, 2010 4:37 pm

BIT0122-Amit wrote:
kongula :O

Method of relaxation
BIT0107-Toma
BIT0107-Toma
Programmer
Programmer

Course(s) :
  • BIT

Blood Group : B+
Posts : 280
Points : 453

Back to top Go down

Methods collection zone Empty Re: Methods collection zone

Post by BIT0122-Amit Fri May 21, 2010 4:40 pm

BIT0107-toma wrote:
BIT0122-Amit wrote:
kongula :O

Method of relaxation

Hmm..
I have prepared the [You must be registered and logged in to see this link.] in the zone. mind taking a look at it and verifying?
BIT0122-Amit
BIT0122-Amit
Founder
Founder

Course(s) :
  • BIT

Blood Group : O+
Posts : 4187
Points : 6605

https://iitdu.forumotion.com

Back to top Go down

Methods collection zone Empty Re: Methods collection zone

Post by BIT0101-rayhan Fri May 21, 2010 6:06 pm

nothing ti copy paste... its just adding a line to convert the gauss seidel to a relaxation method....
i did it intentionally.. otherwise 2 different code of a same problem would create confusions...
whatever no need to write this public .... :S:S:S
u ppls really sucks... :S:S:S
BIT0101-rayhan
BIT0101-rayhan
Release Candidate
Release Candidate

Posts : 107
Points : 177

Back to top Go down

Methods collection zone Empty Re: Methods collection zone

Post by BIT0122-Amit Fri May 21, 2010 7:39 pm

peoples? :/ ahem......
And NOW I understood what ray did.
Considering his intention, I would say good work Ray Very Happy
BIT0122-Amit
BIT0122-Amit
Founder
Founder

Course(s) :
  • BIT

Blood Group : O+
Posts : 4187
Points : 6605

https://iitdu.forumotion.com

Back to top Go down

Methods collection zone Empty Re: Methods collection zone

Post by Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum