# Network Synthesis : example 12.2 : (pg 12.2)
import numpy
p1 = numpy.array([1,0,5,0,4])
p2 = numpy.array([1,0,3,0])
[q,r]=numpy.polydiv(p1,p2);
[q1,r1]=numpy.polydiv(p2,r);
[q2,r2]=numpy.polydiv(r,r1);
[q3,r3]=numpy.polydiv(r1,r2);
print "\nEven part of P(s) = (s^4)+(5s^3)+4"
print "\nOdd part of P(s) = (s^3)+(3s)"
print "\nQ(s)= m(s)/n(s)"
# values of quotients in continued fraction expansion
print (q);
print (q1);
print (q2);
print (q3);
print "Since all the quotient terms are positive, P(s) is hurwitz";
#Network Synthesis : example 12.3 : (pg 12.2 & 12.3)
import numpy
p1=numpy.array([1,0,5,0])
p2=numpy.array([4,0,2])
[q,r]=numpy.polydiv(p1,p2);
[q1,r1]=numpy.polydiv(p2,r);
[q2,r2]=numpy.polydiv(r,r1);
print("\nEven part of P(s) = ((4*s^2)+(2))");
print("\nOdd part of P(s) = ((s^3)+(5*(s)))");
print("\nQ(s)= n(s)/m(s)");
# values of quotients in continued fraction expansion
print(q);
print(q1);
print(q2);
print("\nSince all the quotient terms are positive, P(s) is hurwitz");
## Network Synthesis : example 12.4 : (pg 12.3)
import numpy
p1=numpy.array([1,0,3,0,12])
p2=numpy.array([1,0,2,0])
[q,r]=numpy.polydiv(p1,p2);
[q1,r1]=numpy.polydiv(p2,r);
[q2,r2]=numpy.polydiv(r,r1);
[q3,r3]=numpy.polydiv(r1,r2);
print("\nEven part of P(s) = ((s^4)+(3*(s)^2)+12)");
print("\nOdd part of P(s) = ((s^3)+(2*s))");
print("\nQ(s)= m(s)/n(s)");
## values of quotients in continued fraction expansion
print(q);
print(q1);
print(q2);
print(q3);
print("\nSince two quotient terms are negative, P(s) is not hurwitz");
## Network Synthesis : example 12.5 : (pg 12.3 & 12.4)
import numpy
p1=numpy.array([1,0,2,0,2])
p2=numpy.array([1,0,3,0])
[q,r]=numpy.polydiv(p1,p2);
[q1,r1]=numpy.polydiv(p2,r);
[q2,r2]=numpy.polydiv(r,r1);
[q3,r3]=numpy.polydiv(r1,r2);
print("\nEven part of P(s) = ((s^4)+(2*(s)^2)+2)");
print("\nOdd part of P(s) = (s^3)+(3s)");
print("\nQ(s)= m(s)/n(s)");
## values of quotients in continued fraction expansion
print(q);
print(q1);
print(q2);
print(q3);
print("\nSince two terms are negative, P(s) is not hurwitz");
## Network Synthesis : example 12.6 : (pg 12.4)
import numpy
p1=numpy.array([2,0,6,0,1])
p2=numpy.array([5,0,3,0])
[q,r]=numpy.polydiv(p1,p2);
[q1,r1]=numpy.polydiv(p2,r);
[q2,r2]=numpy.polydiv(r,r1);
[q3,r3]=numpy.polydiv(r1,r2);
print("\nEven part of P(s) = ((2*s^4)+(6*(s)^2)+1)");
print("\nOdd part of P(s) = ((5*s^3)+(3*s))");
print("\nQ(s)= m(s)/n(s)");
## values of quotients in continued fraction expansion
print(q);
print(q1);
print(q2);
print(q3);
print("\nSince all the quotient terms are positive, P(s) is hurwitz");
## Network Synthesis : example 12.7 : (pg 12.4 & 12.5)
import numpy
p1=numpy.array([1,0,6,0,8])
p2=numpy.array([7,0,21,0])
[q,r]=numpy.polydiv(p1,p2);
[q1,r1]=numpy.polydiv(p2,r);
[q2,r2]=numpy.polydiv(r,r1);
[q3,r3]=numpy.polydiv(r1,r2);
print("\nEven part of P(s) = ((s^4)+(6*(s)^2)+8)");
print("\nOdd part of P(s) = (7*(s^3)+(21*s))");
print("\nQ(s)= m(s)/n(s)");
## values of quotients in continued fraction expansion
print(q);
print(q1);
print(q2);
print(q3);
print("\nSince all the quotient terms are positive, P(s) is hurwitz");
## Network Synthesis : example 12.8 : (pg 12.5)
import numpy
p1=numpy.array([1,0,5,0,10])
p2=numpy.array([5,0,4,0])
[q,r]=numpy.polydiv(p1,p2);
[q1,r1]=numpy.polydiv(p2,r);
[q2,r2]=numpy.polydiv(r,r1);
[q3,r3]=numpy.polydiv(r1,r2);
print("\nEven part of P(s) = ((s^4)+(5*(s)^2)+10)");
print("\nOdd part of P(s) = (5*(s^3)+(4*s))");
print("\nQ(s)= m(s)/n(s)");
## values of quotients in continued fraction expansion
print(q);
print(q1);
print(q2);
print(q3);
print("\nSince two terms are negative, P(s) is not hurwitz");
## Network Synthesis : example 12.9 : (pg 12.6)
import numpy
p1=numpy.array([1,0,3,0,2,0])
p2=numpy.array([5,0,9,0,2])
[q,r]=numpy.polydiv(p1,p2);
[q1,r1]=numpy.polydiv(p2,r);
[q2,r2]=numpy.polydiv(r,r1);
[q3,r3]=numpy.polydiv(r1,r2);
[q4,r4]=numpy.polydiv(r2,r3);
print("\n P(s) = ((s^5)+(3*(s^3))+(2*s))");
print("\n d/ds.P(s)= ((5*(s^4))+9*(s^2)+2)");
print("\nQ(s)=P(s)/d/ds.P(s)");
## values of quotients in continued fraction expansion
print(q);
print(q1);
print(q2);
print(q3);
print(q4);
print("\nSince all the quotient terms are positive, P(s) is hurwitz");
## Network Synthesis : example 12.10 : (pg 12.6 & 12.7)
import numpy
p1=numpy.array([1,0,1,0,1,0])
p2=numpy.array([5,0,3,0,1])
[q,r]=numpy.polydiv(p1,p2);
[q1,r1]=numpy.polydiv(p2,r);
[q2,r2]=numpy.polydiv(r,r1);
[q3,r3]=numpy.polydiv(r1,r2);
[q4,r4]=numpy.polydiv(r2,r3);
print("\n P(s) = ((s^5)+((s^3))+(s))");
print("\n d/ds.P(s)= ((5*(s^4))+3*(s^2)+1)");
print("\nQ(s)=P(s)/d/ds.P(s)");
## values of quotients in continued fraction expansion
print(q);
print(q1);
print(q2);
print(q3);
print(q4);
print("\nSince two quotient terms are negative, P(s) is not hurwitz");