On Thu, Jun 19, 2008 at 2:06 PM, tom <[EMAIL PROTECTED]> wrote: > > On Jun 19, 12:34 pm, "Ondrej Certik" <[EMAIL PROTECTED]> wrote: >> however, generally the factor function is fragile, as you have >> find out. > > Ok, fair enough. Thanks - 'collect' does appear to do what I > want here. I know factorisation is a tricky problem in general, > I just wanted to get the hang of some simple examples. > > I'm not sure if I'm going about things the right way here; I > was looking for a tool for manipulating equations I can do by > hand, but want to avoid errors when the expressions are larger. > Specifically for electronic circuits. Say I want to solve for > the output of a simple potential divider. Basic circuit > theory would start me at: > > (Vin-Vout)/R1 + (0-Vout)/R2 = 0 > > And I'm looking for Vout/Vin (or just Vout). (obviously I can > do this one myself, but I'm learning here) > > Was trying just manipulating the lhs as an expression first, > doing things like: > > vin, vout, r1, r2 = symbols(["Vin", "Vout", "R1", "R2"]) > a = (vin-vout)/r1 + (0-vout)/r2 > a.expand() > b = collect(a.expand(), vout) > b > b/vout > c = (b/vout).expand() > c > d = (c*r1).expand() > > Now I can see Vout/vin by inspection. > > Am I going about this the 'right' way? > > I also see Eq for building the equation properly, but can't > then seem to manipulate the result in the same way with > collect. > > any tips?
Right. I think you are doing it right. The other (maybe simple) option is to use solve, here is my session where I tried that: In [1]: vin, vout, r1, r2 = symbols(["Vin", "Vout", "R1", "R2"]) In [2]: a = (vin-vout)/r1 + (0-vout)/r2 In [3]: solve? In [4]: solve(a, vout) Out[4]: ⎡ R₂*Vin⎤ ⎢───────⎥ ⎣R₁ + R₂⎦ Please report all bugs and all things that don't work as expected (like you did with the factor function), that would help as a lot. We'll then create a new issue for each problem and fix it. Also don't hesitate to ask again if you have any other problems/questions. Thanks, Ondrej --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sympy" group. To post to this group, send email to sympy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sympy?hl=en -~----------~----~----~----~------~----~------~--~---