Advertisement
Guest User

Untitled

a guest
Nov 16th, 2018
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.86 KB | None | 0 0
  1. a = -1;
  2. b = 3/2;
  3. x = linspace(a, b, 100);
  4. g = @(x)((3+x-2*x.^2).^(1/4));
  5. plot(x, g(x), '-r');
  6. hold on;
  7.  
  8. x1 = [a, b, b, a, a];
  9. y1 = [a, a, b, b, a];
  10. plot (x1, y1, 'Linewidth', 3)
  11. plot(x, x, '-g');
  12.  
  13. syms arg;
  14. dg = matlabFunction(diff(g(arg)));
  15. figure;
  16. hold on;
  17. plot(x, dg(x));
  18. plot([a, b],[1, 1]);
  19. plot([a, b],[-1, -1]);
  20.  
  21. a = 0.8;
  22. b = 1.27;
  23. % x = linspace(a, b, 100);
  24. % g = @(x)((3+x-2*x.^2).^(1/4));
  25. % syms arg;
  26. % dg = matlabFunction(diff(g(arg)));
  27. % figure;
  28. % hold on;
  29. % plot(x, dg(x));
  30. % plot([a, b],[1, 1]);
  31. % plot([a, b],[-1, -1]);
  32.  
  33. figure;
  34. hold on;
  35. f = @(x)(x.^4 + 2*x.^2 - x - 3);
  36. plot(x, f(x));
  37. plot([a, b], 0)
  38. xsol = punctFix(g, 1, 10^(-5));
  39.  
  40. plot(xsol, f(xsol), 'o', 'MarkerSize', 10);
  41.  
  42. function xsol = punctFix(g, x0, eps)
  43.  
  44. x = g(x0);
  45. while(abs(x - x0) < eps)
  46.    
  47.    x0 = x;
  48.    x = g(x0);
  49.    
  50. end
  51.  
  52. xsol = x;
  53.  
  54. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement