syms s gm1 gmp ro1 rop R2 R1 Cgs Cout Zcgs Zcgd Zcout Z1 Z2 Vinp Vinm Vout1 Vd Vout2 Htf
eqn1 = Vout1 == (-gm1*Vinp + gm1*Vinm)*Z1;
eqn2 = Z1 == 1/(1/ro1 + 1/Zcgs);
eqn3 = Vd == (-gmp*Vout1)*Z2;
%eqn4 = Iout1 == (Vout1 - Vd)/Zcgd;
eqn5 = Z2 == 1/(1/rop + 1/(R2 + R1) + 1/Zcout);
eqn6 = Vinm == Vd*(R1/(R1 + R2));
eqn7 = Vout2 == Vd*(Zcout/(Zcout));
eqn8 = Zcgs == 1/(s*Cgs);
%eqn9 = Zcgd == 1/(s*Cgd);
eqn10 = Zcout == 1/(s*Cout);
eqn11 = Htf == Vout2/Vinp;
%S = solve(eqn1,eqn2,eqn3,eqn5,eqn6,eqn7,eqn8,eqn10,eqn11,Zcgs,Zcgd,Zcout,Z1,Z2,Vinp,Vinm,Vout1,Vd,Vout2,Iout1,Htf,ReturnConditions=true);
S = solve(eqn1,eqn2,eqn3,eqn5,eqn6,eqn7,eqn8,eqn10,eqn11,Zcgs,Zcgd,Zcout,Z1,Z2,Vinp,Vinm,Vout1,Vd,Vout2,Htf);
[N,D] = numden(S.Htf);
R = solve(D, s);
HTF = N / ((R(1) - s) * (R(2) - s))
pretty(HTF)