Question

I need a matlab code for given question. Please send matlab code sctript.

Question 1) (60 p) Consider following equation: axt-bx+ex=dx-e Find the value of x via; a) Fixed Point iteration method with

a:2

b:3:

c:4

d:2.1

e:3.1

0 0
Add a comment Improve this question Transcribed image text
Answer #1

(a)
function[r]=fixed(x0,g,tol,n)
x(1)=x0;
for k=1:n
   x(k+1)=g(x(k));
   err=abs(x(k+1)-x(k));
   if(err<tol)
       break;
   end
end
r=x(k+1);

Above is the matlab code for fixed point iteration method. As per the question, x0=1 and tol=0.0004.

(b)

function[r]=newton(x0,f,df,tol,n)
x(1)=x0;
j=@(x) f(x)/df(x);
for k=1:n
   x(k+1)=x(k)-j(x(k));
   err=abs(x(k+1)-x(k));
   if(err<tol)
       break;
   end
end
c=x(k+1);

Above is the matlab code for newton's method. As per the question, x0=1 and tol=0.0004. df is the first derivative of the function.

Add a comment
Know the answer?
Add Answer to:
I need a matlab code for given question. Please send matlab code sctript. a:2 b:3: c:4...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT