McGill University
School of Computer Science

Computer Science COMP 199 (Winter term)
Excursions in Computing Science

%MATLABpak_iii: plot32768quartic.m

% plot32768quartic.m		THM		080917
% plot 3x^4 + 2x^3 + 7x^2 + 6x + 8 and its two factors
% following data from quartic([3,2,7,6,8])
% pNum = -0.73678006553031 
% qNum = 2.09370677108510 + 0.00000000000000i 
% rNum = 1.40344673219697 
% sNum = 1.27365813756461 + 0.00000000000000i 
% Achk = A
% Bchk = A*(p+r)
% Cchk = A*(q + p*r +s)
% Dchk = A*(q*r + p*s)
% Echk = A*q*s
p = -0.73678006553031;
q = 2.09370677108510;
r = 1.40344673219697;
s = 1.27365813756461;
x = -2.5:.1:2.5;
quad1 = x.^2 + p.*x + q;
quad2 = x.^2 + r.*x + s;
% quar  = sym((x.^2 + p.*x + q).*(x.^2 + r.*x + s))	% not what I want
quart = (x.^2 + p.*x + q).*(x.^2 + r.*x + s);
plot(x,quad1,'b')
hold on
plot(x,quad2,'g')
plot(x,quart,'r')
xlabel('x')
ylabel('3x^4 + 2x^3 + 7x^2 + 6x + 8 and two factors')
axis([-2.5 2.5 0 50])
hold off
Achk = 3
Bchk = 3*(p+r)
Cchk = 3*(q + p*r +s)
Dchk = 3*(q*r + p*s)
Echk = 3*q*s

% plot stored as plotLinFact32768quartic.fig, .eps