a newbe question ---- divide inconsistancies between 591 and 592



Using the code given latter,  I get different results from 5.9.1 and 5.9.2.
The difference is in the results of the divide function. In 5.9.1 the 
results are ordered in powers of  "s" which is what you would expect but 
5.9.2 does not do this. How do I force 5.9.2 to order the polynomial in 
power of "s"?

The code works fine in 5.9.1 so thanks to R. Fateman and S. Macrakis for 
the help.

Doug Stewart

pidmath.mac


kill(all);
globalsolve:true;
pid:(KD*s^2+KP*s+KI)/s;
plant:2/(s^2+4*s+3);
/* plant:64/(s^2+12*s+32); */

/*  make the closed loop equation */
cl:pid*plant/(1+pid*plant);
careq1:denom(cl),ratsimp;

/* show the characteristic equation. */
careq:careq1=0;

/* factor out a real root. */
q1:divide(careq1,(s+a),s),polysimp;

/* get the quadratic part and the remainder */
quadr1:part(q1,1);
rem:part(q1,2);

/* now set the first order root a=(real part of complex roots)  */
a1:part(quadr1,2)/(2*s),ratsimp;
a2:a1=a;

/* get the numeric value for a */
solve(a2,a);

/* now set up the settling time  (set for 1 second)  */
Ts:1.0;
Ts1:5/a1=Ts,ratsimp;
/* solve these two for KD and a   */
solve([a2,Ts1],[KD , a]),numer;
/* now choose a damping ratio  (.707)  */
dr:sqrt(2)/2;

/* these are for debuging only */
part(quadr1,2);
part(quadr1,3);
part(quadr1,4);

eq3:(part(quadr1,3)+part(quadr1,4))=((part(quadr1,2)/s)/(2*dr))^2,ratsimp;

/* now solve these two eq. for KP and KI */
solve([eq3,rem],[KP,KI]),numer;
/* show all the results  */
a;
KP;
KI;
KD;