Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

http://www.webpages.uidaho.edu/~barannyk/Teaching/hw7_Math432.pdf

Can someone help with #2? This is NOT homework. This was a website for Fall 2011, but it is a very interesting question and I would greatly appreciate help

Thanks

share|improve this question
    
What have you tried so far? What exactly is the problem you are facing? Give us some hints. –  sonystarmap Jan 31 '13 at 10:49
    
I really need help in starting it. Can you please provide a solution? Thanks –  Buddy Holly Feb 1 '13 at 1:16
    
Do you know how CG works ? –  sonystarmap Feb 1 '13 at 6:03
    
I do, its a bunch of formulas. Can you please provide solution to this? –  Buddy Holly Feb 1 '13 at 7:54

1 Answer 1

up vote 2 down vote accepted

We can use the CG algorithm, presented e.g. here at Wikipedia.

function [x] = conjgrad(A,b,x)
    r=b-A*x;
    p=r;
    rsold=r'*r;

    for i=1:10000000
        Ap=A*p;
        alpha=rsold/(p'*Ap);
        x=x+alpha*p;
        r=r-alpha*Ap;
        rsnew=r'*r;
        if sqrt(rsnew)<0.05 
            disp(i)          % Note: I added this to see the number of Iteration
            break;
        end
        p=r+rsnew/rsold*p;
        rsold=rsnew;
    end
end

We then have to set up our matrices as described in the pdf, lets also call it $A$. We have $b$ as our right hande side and need a startvector $x$. For $x$ I simply took $x=rand(size(b))$, so just a random vector of the same size as $b$. Running the code, we can see that it takes 7 Iteration.

For b) you should take a look at this. You have to modify the code above. Then c) is just playing with your code. It would be nice if you provide Information on what you tried. Also instead of calling CG "a bunch of formulas" you could simply understand and apply these formulas.

share|improve this answer
    
Thanks, but I was interested in a hand computational solution. Can you please illustrate it for this case problem and work out a few by hand? –  Buddy Holly Feb 1 '13 at 9:15
    
Above comment was for part a. For part b, can you also elaborate by hand. Thanks!! –  Buddy Holly Feb 1 '13 at 9:16
    
Well you can simply do the code "by hand". Just move from line to line and see what you have to do. –  sonystarmap Feb 1 '13 at 9:40

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.