Search This Blog

Fixed-point iteration Method for Solving non-linear equations in MATLAB(mfile)



% Fixed-point Algorithm 
 % Find the fixed point of y = cos(x).

 g = @(x) cos(x);
 p0 = input('Please enter initial approximation, p0:  ');
 n = input('Please enter no. of ierations, n: ');
 tol = input('Please enter tolerance, tol: ');

 i = 1;
 while i <= n
     p = g(p0);
     if abs(p-p0) < tol
        fprintf('\nApproximate solution p = %11.8f \n\n', p)
        break;
     else
        i = i+1;
        p0 = p;
     end
 end


Output:

>> Fixed_point_method_m
Please enter initial approximation, p0:  1
Please enter no. of ierations, n: 30
Please enter tolerance, tol: 0.001

Approximate solution p =  0.73876032 

>> 




7 comments:

  1. Your site is truly cool and this is an extraordinary moving article and If it's not too much trouble share more like that. Thank You..
    Digital Marketing Course in Hyderabad

    ReplyDelete
  2. Thank a lot. You have done excellent job. I enjoyed your blog . Nice efforts
    Data Science Certification in Hyderabad

    ReplyDelete
  3. Wow, happy to see this awesome post. I hope this think help any newbie for their awesome work and by the way thanks for share this awesomeness, i thought this was a pretty interesting read when it comes to this topic. Thank you..
    Artificial Intelligence Course

    ReplyDelete
  4. I need to thank you for this very good read and i have bookmarked to check out new things from your post. Thank you very much for sharing such a useful article and will definitely saved and revisit your site.
    Data Science Course

    ReplyDelete
  5. Thanks for your marvelous posting! I really enjoyed reading it, you could be a great author. I will be sure to bookmark your blog and definitely will come back in the foreseeable future. I want to encourage you to continue your great posts, have a nice afternoon! Digital Marketing Course in Bangalore with Placement

    ReplyDelete
  6. Not too lengthy. Crisp and the meaning is conveyed. Nice blog.

    Mobile app development company in Hyderabad

    ReplyDelete
  7. An excellent topic that will be useful to others. I enjoyed reading.

    Software development company in Hyderabad

    ReplyDelete

MATLAB