Impact-Site-Verification: dbe48ff9-4514-40fe-8cc0-70131430799e

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 

>> 




4 comments:

  1. 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
  2. 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
  3. Not too lengthy. Crisp and the meaning is conveyed. Nice blog.

    Mobile app development company in Hyderabad

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

    Software development company in Hyderabad

    ReplyDelete