notPlancha

Código da parte 1 vFinal

Dec 9th, 2021 (edited)
1,158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 2.50 KB | None | 0 0
  1. syms x T;
  2. assume (x ~= -1);
  3.  
  4. figure(1)
  5. title("Função")
  6. axis([-5 4 -10 50])
  7. fplot(f(x))
  8.  
  9. figure(2)
  10. title("É par ou ímpar")
  11. axis([-5 4 -10 50])
  12. hold on
  13. par = logical(f(x) == f(-x)) %0 false, 1 true
  14. impar = logical(-f(x) == f(-x)) %0 false, 1 true
  15. fplot(f(x) - f(-x))
  16. fplot(f(x) + f(-x))
  17. fplot(0, 'LineStyle', '- -')
  18. hold off
  19.  
  20. [periodo, ~, conditions] = solve(f(x + T) - f(x) == 0, x, 'ReturnConditions',true) %if returns with no conditions then
  21.  
  22. figure(3)
  23. title("Zeros")
  24. hold on
  25. zeros = solve(f(x) == 0)
  26. axis([-1 1 -1 1])
  27. fplot(f(x))
  28. fplot(0)
  29. for zero = zeros
  30.     scatter(zero, 0)
  31. end
  32. hold off
  33. figure(4)
  34. title("Zeros")
  35. hold on
  36. zeros = solve(f(x) == 0)
  37. axis([-5 4 -10 50])
  38. fplot(f(x))
  39. fplot(0)
  40. for zero = zeros
  41.     scatter(zero, 0)
  42. end
  43. hold off
  44.  
  45. figure(5)
  46. title("Assíntotas")
  47. axis([-20 20 -2 14])
  48. hold on
  49. fplot(f(x))
  50. limiteNaDescontinuidade = limit(f(x), x, -1) %Se +-Inf, ent x = -1 é uma assintota vertical
  51. xline(-1, 'b')
  52. %Assíntotas horizontais e oblíquas
  53. m = limit(f(x)/x, x, inf);
  54. assintota1 = limit(f(x) - m*x, x, inf)
  55. fplot(assintota1)
  56. m = limit(f(x)/x, x, -inf);
  57. assintota2 = limit(f(x) - m*x, x, -inf)
  58. %aqui a assintota1 = assintota2 portanto não é preciso desenhar essa segunda
  59. legend('y = f(x)', 'x = -1', 'y = 2')
  60. hold off
  61.  
  62. figure(6)
  63. title("Derivadas")
  64. hold on
  65. axis([-5 4 -10 20]);
  66. l = axis;
  67. derivada1 = diff(f(x))
  68. derivada2 = diff(derivada1)
  69. fplot(f(x))
  70. fplot(derivada1, 'r')
  71. fplot(derivada2, 'b')
  72. zerosD1 = solve(derivada1 == 0, x);
  73. for zero = zerosD1
  74.     scatter(zero, 0, 'r')
  75. end
  76. zerosD2 = solve(derivada2 == 0, x);
  77. for zero = zerosD2
  78.     scatter(zero, 0, 'b')
  79. end
  80. fplot(0, 'LineStyle', '- -')
  81. legend('y = f(x)', "y = f'(x)", "y = f''(x)")
  82. ylD2 = l(3)+8;
  83. ylD1 = l(3)+5;
  84. ylD0 = l(3)+2;
  85. ylD0D1 = ylD0+0.5;
  86. ylD0D2 = ylD0-0.5;
  87. text(l(2), ylD2 , "f''");
  88. text(l(2), ylD1, "f'");
  89. text(l(2), ylD0 , "f");
  90. mid = (l(1) + -1)/2;
  91. text(mid, ylD1, '+')
  92. text(mid, ylD0D1, '↗')
  93. text(mid, ylD2, '+')
  94. text(mid, ylD0D2, '◡')
  95. text((-1 + zerosD1)/2, ylD1, '-')
  96. text((-1 + zerosD1)/2, ylD0D1, '↘')
  97. text((-1 + zerosD2)/2, ylD2, "+")
  98. text((-1 + zerosD2)/2, ylD0D2, "◡")
  99. text(zerosD1, ylD1, '0')
  100. text(zerosD1-0.1, ylD0D1, num2str(double(f(zerosD1))))
  101. text((zerosD1 + l(2))/2, ylD1, "+")
  102. text((zerosD1 + l(2))/2, ylD0D1, '↗')
  103. text(zerosD2, ylD2, "0")
  104. text(zerosD2, ylD0D2, num2str(double(f(zerosD2))))
  105. text((zerosD2 + l(2))/2, ylD2, "-")
  106. text((zerosD2 + l(2))/2, ylD0D2, "◠")
  107. hold off
  108. function y = f(x)
  109.     y = (2*(x ^ 2) + x) /((x + 1)^2);
  110. end
Add Comment
Please, Sign In to add comment