Hi, excellent! Thank you very much!
Joa Den onsdagen den 21:e maj 2014 kl. 17:12:51 UTC+2 skrev Dima Pasechnik: > > On 2014-05-21, st...@joa.me.uk <javascript:> <st...@joa.me.uk<javascript:>> > wrote: > > Hi, > > > > it is a system of resitors and capacitors. I can in principle do a bit > of > > math and calculate Ztotal of my circuit. And calculate Itotal. From this > I > > can get the current I want by repeated current splitting in parallel > > impedances. I have tried this as well. The results are the same. The > > problem is not the solution itself > > > > sage: Rin*S[0][i8].subs({Uut:1}) > > -I*Cplunger*R1*Rin*w/((I*(C*Rin + (Ccable3 + > > Cin)*Rin)*Ccable2*Cplunger*R1*R2 + I*((C*Rin + (Ccable3 + > > Cin)*Rin)*Ccable2*R2 + (C*Rin + (Ccable3 + > > Cin)*Rin)*Cplunger*R2)*Ccable1*R1)*Rut*w^3 + (((C*Rin + (Ccable3 + > > Cin)*Rin)*Ccable2*R2 + (C*Rin + (Ccable3 + Cin)*Rin)*Cplunger*R2)*R1 + > > ((Ccable2*(R2 + Rin) + C*Rin + (Ccable3 + Cin)*Rin)*Cplunger*R1 + (C*Rin > + > > (Ccable3 + Cin)*Rin)*Cplunger*R2 + ((Ccable2*(R2 + Rin) + Cplunger*(R2 + > > Rin) + C*Rin + (Ccable3 + Cin)*Rin)*R1 + (C*Rin + (Ccable3 + > > Cin)*Rin)*R2)*Ccable1)*Rut)*w^2 + (-I*(Ccable2*(R2 + Rin) + Cplunger*(R2 > + > > Rin) + C*Rin + (Ccable3 + Cin)*Rin)*R1 - I*(C*Rin + (Ccable3 + > Cin)*Rin)*R2 > > + (-I*Ccable1*(R1 + R2 + Rin) - I*Cplunger*R1 - I*Cplunger*(R2 + > > Rin))*Rut)*w - R1 - R2 - Rin) > > > > which is not so complicated as, as it should, the same independant of > way > > of getting it (btw, sage is supposed to do the hard work for me, no? ;) > > > > > > > sage: Rin*S[0][i8].subs({Uut:1}).real() > > > -(C*Ccable1*Ccable2*Cplunger*R1^2*R2*Rin*Rut*w^4/(C^2*Ccable1^2*Ccable2^2*R1^2*R2^2*Rin^2*Rut^2*w^6 > > > > + 2*C*Ccable1^2*Ccable2^2*Ccable3*R1^2*R2^2*Rin^2*Rut^2*w^6 + > > Ccable1^2*Ccable2^2*Ccabl.... > > > > which continues for some 65000 terms... and this does not seem to > optimized > > to me. So, can I simplify this or not? I go to sympy after this stage > only > > to creat the c code > > Yes, I think Sage (or, rather, it's probably Maxima which does the > hard lifting behind the scene) that does not know a good way to do > the real part of a rational function. You can help it as follows, > by doing numerator and denominator separately: > > e=Rin*S[0][i8].subs({Uut:1}) > > e_d=e.denominator() > e_num=(e_d.conjugate()*e.numerator()).expand() > e_denom=(e_d.conjugate()*e_d).expand() > # now e==e_num/e_denom, with e_denom real > # and the following are your real and complex parts > # use simplify_rational() to cancel common factors > e_real=(e_num.real()/e_denom).simplify_rational() > e_imag=(e_num.imag()/e_denom).simplify_rational() > > # now your e_real and e_imag have just a hundred terms or so... > > HTH > Dmitrii > > -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.