function poly(a,b,p,q)
% Polynomial x^2 + ax + b
% p = x_max, q = y_max

h=p/100;
k=q/50;
x(1) = 0;
y(1) = q;
u1(1) = x(1)^2-y(1)^2+a*x(1)+b;
w1(1) = 2*x(1)*y(1)+a*y(1);
for i=2:101
    x(i) = 0;
    y(i) = y(i-1)-k;
    u1(i) = x(i)^2-y(i)^2+a*x(i)+b;
    w1(i) = 2*x(i)*y(i)+a*y(i);
end
for i=102:201
    x(i) = x(i-1)+h;
    y(i) = -q;
    u2(i-101) = x(i)^2-y(i)^2+a*x(i)+b;
    w2(i-101) = 2*x(i)*y(i)+a*y(i);
end
for i=202:301
    x(i) = p;
    y(i) = y(i-1)+k;
    u3(i-201) = x(i)^2-y(i)^2+a*x(i)+b;
    w3(i-201) = 2*x(i)*y(i)+a*y(i);
end
for i=302:401
    x(i) = x(i-1)-h;
    y(i) = q;
    u4(i-301) = x(i)^2-y(i)^2+a*x(i)+b;
    w4(i-301) = 2*x(i)*y(i)+a*y(i);
end
plot(u1,w1,'b-',u2,w2,'r-',u3,w3,'g-',u4,w4,'m-');grid
