My description was a little compressed, so i had to clean up the code to match my description again ... The code is available here: http://pastebin.com/MMW3B88h I hope its readable for you.
Am Donnerstag, 9. Juni 2016 20:24:35 UTC+2 schrieb Jason Moore: > > Can you please share the code so we can see what you are doing? > > > Jason > moorepants.info > +01 530-601-9791 > > On Wed, Jun 8, 2016 at 11:58 PM, <[email protected] <javascript:>> > wrote: > >> I am trying to solve a system of equations with sympy that arises from a >> constraint of the form: >> >> (A x B) x C = D >> >> where >> >> * A, B, C and D are 3x3 matrices >> * the diagonal of D should be zero >> * B is a "rigid motion 2D" transformation, with elements cos(phi), >> +-sin(phi), x and y >> * A and C are fully filled with (supposedly known) values >> * I want to solve for phi, x and y >> >> This gives me four equations: >> >> * one for each diagonal element in D >> * one additional (quadratic) equation sin^2(phi) + cos^2(phi) = 1 >> >> When feeding those to equations directly to sympy, this takes some hours >> and then breaks with an out of memory message. >> >> My next approach was to help sympy by guiding the solution step by step >> (*). >> >> * First i took two of the linear equations and let sympy solve for x and >> y (works great) >> * Instead of having cos(phi) and sin(phi) in the B matrix, i introduced >> new symbols cosphi and sinphi >> * Then i took the resulting expressions for x and y, and solve with the >> third linear equation for the cosphi element (works too) >> * Finally i tried to solve the quadratic equation for sinphi by inserting >> the just gathered cosphi expression >> * The last step was not feasible without transforming the expression to a >> polynom in sinphi and by replacing all coefficient expressions by new >> symbols, then it worked >> >> The resulting expressions for x, y and phi (written as python >> expressions) are about 3 MB (!) of text. >> >> This does not seem to be adequate to the problem, and when converting to >> a theano function i get "maximum recursion depth exceeded". >> When i look at the expressions they are very repetitive, so i tried CSE, >> which brings it down to about 30 KB, but they are still very repetitive and >> full of patterns. >> >> I suspect that the resulting expressions actually just perform some >> matrix operations, so probably there would be an efficient way to compute >> the solution if only one could get back to matrix expressions. >> I tried to guess what the appropriate matrix operations are, but without >> success (**). And this feels of course very wrong and backwards. >> >> Is there some obvious approach to such problems that i missed? Is the >> problem actually that hard? >> >> I am aiming for a mostly automated solution process without steps like >> (*) and (**), because i have a hand full of very similar problems ahead ... >> Any hint appreciated! >> >> -- >> Best regards >> Janosch >> >> -- >> 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 [email protected] <javascript:>. >> To post to this group, send email to [email protected] <javascript:> >> . >> 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/8555837f-d87d-484c-b882-2d8f7085d3b2%40googlegroups.com >> >> <https://groups.google.com/d/msgid/sympy/8555837f-d87d-484c-b882-2d8f7085d3b2%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 the Google Groups "sympy" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. 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/ccde273d-ee0e-46bc-a822-7d1b9ff88f7e%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
