Any way to factor a quadratic

33 views
Skip to first unread message

Jason Moore

unread,
Apr 7, 2016, 12:31:10 AM4/7/16
to sy...@googlegroups.com
Say I have an expression that I know is quadratic in u1, u2, u3:

expr = k00*u1**2 + k01*u1*u2 + k02*u1*u3 + k10*u1*u2 + k11*u2**2 + k12*u2*u3 + k20*u1*u3 + k21*u2*u3 + k22*u3**2

Is there a simple way to transform this into:

expr = u^T * K * u

Where u = [u1, u2, u3]^T and K is a 3 x 3 matrix?

I know I can expand the expression with respect to the u variables and pick off coefficients, but I was wondering if we happened to have anything implemented that doe this.

Aaron Meurer

unread,
Apr 7, 2016, 12:17:40 PM4/7/16
to sy...@googlegroups.com
I was going to suggest solve_undetermined_coeffs, but it doesn't seem
to work on multivariate polynomials.

Aaron Meurer
> --
> 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+un...@googlegroups.com.
> To post to this group, send email to sy...@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/CAP7f1AiYi1CeE%3D2yFX1GMfNmvi56PksinPYcN5AX%2B%2BEccFiHxg%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages