Advertisement
Guest User

Untitled

a guest
May 19th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. clc;
  2. clear all;
  3. c=4; b=16;
  4. h=input('Введите шаг: ')
  5. i=1; a=[0;0;0;0;0]; x=c;
  6. while x<=b %выполнение цикла
  7. y1=sin(x)-sqrt(x)+3; %разность функций
  8. y2=sin(x+h)-sqrt(x+h)+3;
  9. if y1*y2<0 %идентификация пересечения
  10. a(i)=x;
  11. i=i+1;
  12. end; x=x+h;
  13. end;
  14. disp('Начинаем находить интервал, в который входят 5 первых корней уравнения sin(x)=sqrt(x)-3');
  15. disp('Со значения');
  16. disp(a(1));
  17. disp('до значения');
  18. disp(a(5));
  19. x=c:h:b; % задание массива точек для построения графика
  20. y1=sin(x);
  21. y2=sqrt(x)-3;
  22. hold on;
  23. grid on;
  24. plot(x,y1,'color','red','LineWidth',1) %построение графика
  25. plot(x,y2,'color','green','LineWidth',1)
  26. dl=a(5)+h-a(1);
  27. disp('Длина=');
  28. disp(dl);
  29. legend('y1=sin(x)','y2=sqrt(x)-3');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement