function polynom
close all % zavira vsechna graficka okna
p=[2,4,3,7,6,5];
q=[3,0,0,-1,0];
xp=roots(p);
disp(p);
disp(xp);
xq=roots(q);
disp(q);
disp(xq);
disp('Do polynomu p dosazeno za x 3')
disp(polyval(p,3))
disp('Do polynomu p dosazeno za x 0')
disp(polyval(p,0))
disp('Do polynomu p dosazeno za x reseni')
disp(polyval(p,xp))
disp('Do polynomu q dosazeno za x 3')
disp(polyval(q,3))
disp('Do polynomu q dosazeno za x 0')
disp(polyval(q,0))
disp('Do polynomu p dosazeno za x reseni')
disp(polyval(q,xq))
disp(3.*(xq.^4)-xq)
subplot(2,2,1)
plot(xp,'rp')
xlabel('Re')
ylabel('Im')
grid
title('reseni 2x^5+4x^4+3x^3+7x^2+6x+5')
subplot(2,2,3)
compass(xp,'r')
subplot(2,2,2)
plot(xq,'g*')
xlabel('Re')
ylabel('Im')
grid
title('reseni 3x^4-x')
subplot(2,2,4)
compass(xq,'g')
figure
subplot(2,1,1)
x=[-4:0.1:4];
y=polyval(p,x);
plot(x,y,'o-')
xlabel('x')
ylabel('hodnoty polynomu p')
subplot(2,1,2)
y2=polyval(q,x);
plot(x,y2,'x-')
xlabel('x')
ylabel('hodnoty polynomu q')
disp('Nasobeni polynomu')
r=conv(p,q);
disp(r)
disp('pocet prvku ve vektoru')
disp(length(r))
disp('Deleni polynomu')
[s,t]=deconv(r,q);
disp('Vysledek')
disp(s)
disp('Zbytek')
disp(t)
[u,z]=deconv(p,q);
disp('Vysledek')
disp(u)
disp('Zbytek')
disp(z)
disp('Zkouska - vyjde polynom p')
disp(conv(u,q)+z)
end

