UF6

EAS 501-01 Homework I

UF6
Jan 25th, 2021
1,911
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ga=@(x) x-x^5;
  2. gb=@(x) x+x^5;
  3. x(1)=2.5;
  4. tolerence=10^-8;
  5. x(2)=ga(x(1));
  6. n=1;
  7. %x-x^5
  8. while(abs(x(n+1)-x(n))>tolerence)
  9. n=n+1;
  10. x(n+1)=ga(x(n));
  11. end
  12. fprintf("Solution for ga is %f and iteratoiion is %d\n",x(length(x)),n);
  13. %x+x^5
  14. x=[];
  15. x(1)=2.4;
  16. x(2)=gb(x(1));
  17. n=1;
  18. while(abs(x(n+1)-x(n))>tolerence)
  19. n=n+1;
  20. x(n+1)=gb(x(n));
  21. end
  22. fprintf("Solution for gb is %f and iteratoiion is %d\n",x(length(x)),n);
RAW Paste Data