After reading some more documentation and browsing the internet, I found
out that I can get expr2 from expr1 by doing this:
expr3 = expr1.collect(x11).collect(x12).collect(x13)
a = Wild('a')
b = Wild('b')
expr4 = expr3.replace(x12*a+b, Mul(-x12, -a, evaluate = False) + b, exact =
True).collect(x11).collect(x13)
# Now, expr4 is in the same form as expr2
But is this the recommended approach?
On Wednesday, 4 November 2015 04:47:20 UTC+8, Hugh wrote:
>
> import sympy
> sympy.init_session()
>
>
> x11, x12, x13, x21, x22, x23, x31, x32, x33 = symbols('x_1:4(1:4)')
>
> A = Matrix(3,3,symbols('x_1:4(1:4)'))
> expr1 = A.det()
>
> expr2 = x11*(x22*x33 - x23*x32) - x12*(x21*x33 -x23*x31) + x13*(x21*x32 -
> x22*x31)
>
> # How to get expr2 from expr1?
>
> I would like to use sympy to rewrite expressions just like how people
> would commonly do when writing proofs or doing homework. What are the
> documentation that I must read so that I can be proficient at this?
>
> I've read the tutorial and some of the modules in the module reference
> <http://docs.sympy.org/dev/modules/index.html> but feel that I have just
> barely touched the surface of sympy's capabilities. For example, in the
> above code snippet, I don't know how to manipulate expr1 to get expr2. I
> thought expr1.factor() would work but it didn't.
>
> Please advise.
>
--
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 http://groups.google.com/group/sympy.
To view this discussion on the web visit
https://groups.google.com/d/msgid/sympy/cabbc702-d238-4851-b96d-cb639ba09020%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.