Thank you for your response. Coincedentally I was just progressing along a similar route myself. What I came up with was
eqs = eq.coeffs() solution = {} solution[K_C] = sympy.solve(eqs[1], K_C)[0] solution[tau_D] = sympy.solve(eqs[0], tau_D)[0].subs(solution) solution[tau_I] = sympy.solve(eqs[2], tau_I)[0].subs(solution).simplify() This matches your method. So this has saved me some tedious algebra, but not the effort of finding the order in which to evaluate the equations. I wish that sympy could do this automatically. I seem to remember Sage being able to solve this set of equations, but I can’t find the worksheet now. > On 23 Feb 2016, at 18:35, Carsten Knoll <carstenkn...@gmx.de> wrote: > > Hi, > > I already had similar problems. The system of equation is of order 3 > which might be too hard. But there is a linear part and if this is > solved first and then plugged into the remaining 2 equations, sympy can > manage it. > > I documented my attempt here: > > https://gist.github.com/cknoll/c03dcf8443c0409d37da > > > (Generally, I think sympy.solve could sometimes be a little bit smarter, > to use such structural properties.) > > > > On 02/23/2016 06:43 AM, Carl Sandrock wrote: >> I am attempting to work a problem from a textbook in sympy, but sympy >> fails to find a solution which appears valid. For interest, it is the >> design of a PID controller using direct synthesis with a second order >> plus dead time model. >> >> The whole problem can be reduced to finding K_C, tau_I and tau_D which >> will make >> >> K_C*(s**2*tau_D*tau_I + s*tau_I + 1)/(s*tau_I) = (s**2*tau_1*tau_2 + >> s*tau_1 + s*tau_2 + 1)/(K*s*(-phi + tau_c)) >> >> >> for given tau_1, tau_2, K and phi. >> >> >> I have tried to solve this by matching coefficients: >> >> >> import sympy >> >> >> s, tau_c, tau_1, tau_2, phi, K = sympy.symbols('s, tau_c, tau_1, tau_2, >> phi, K') >> >> target = (s**2*tau_1*tau_2 + s*tau_1 + s*tau_2 + 1)/(K*s*(-phi + tau_c)) >> >> K_C, tau_I, tau_D = sympy.symbols('K_C, tau_I, tau_D', real=True) >> PID = K_C*(1 + 1/(tau_I*s) + tau_D*s) >> >> eq = (target - PID).together() >> eq *= sympy.denom(eq).simplify() >> eq = sympy.poly(eq, s) >> >> sympy.solve(eq.coeffs(), [K_C, tau_I, tau_D]) >> >> This returns an empty matrix. However, the textbook provides the >> following solution: >> >> booksolution = {K_C: 1/K*(tau_1 + tau_2)/(tau_c - phi), >> tau_I: tau_1 + tau_2,a >> tau_D: tau_1*tau_2/(tau_1 + tau_2)} >> >> Which appears to satisfy the equations I'm trying to solve: >> >> [c.subs(booksolution).simplify() for c in eq.coeffs()] >> >> returns >> >> [0, 0, 0] >> >> Can I massage this into a form which sympy can solve? What am I doing wong? >> >> -- >> You received this message because you are subscribed to the Google >> Groups "sympy" group. >> To unsubscribe from this group and stop receiving emails from it, send >> an email to sympy+unsubscr...@googlegroups.com >> <mailto:sympy+unsubscr...@googlegroups.com>. >> To post to this group, send email to sympy@googlegroups.com >> <mailto:sympy@googlegroups.com>. >> Visit this group at https://groups.google.com/group/sympy. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/sympy/4d922cfe-9f54-4196-b7d8-15abb053e091%40googlegroups.com >> <https://groups.google.com/d/msgid/sympy/4d922cfe-9f54-4196-b7d8-15abb053e091%40googlegroups.com?utm_medium=email&utm_source=footer>. >> For more options, visit https://groups.google.com/d/optout. > > -- > You received this message because you are subscribed to a topic in the Google > Groups "sympy" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/sympy/JJVkM7Cs9MA/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > sympy+unsubscr...@googlegroups.com. > To post to this group, send email to sympy@googlegroups.com. > Visit this group at https://groups.google.com/group/sympy. > To view this discussion on the web visit > https://groups.google.com/d/msgid/sympy/56CC8A6B.4080107%40gmx.de. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "sympy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sympy+unsubscr...@googlegroups.com. To post to this group, send email to sympy@googlegroups.com. Visit this group at https://groups.google.com/group/sympy. To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/45A4032F-2FFD-4381-B090-BDD4653B5E4A%40gmail.com. For more options, visit https://groups.google.com/d/optout.