> I just discovered the following (imho unsatisfactory) behavior of
> Matrix.det:
>
> In <211>: from sympy.abc import a,b,c,d, C
> In <212>: M = Matrix([[a+b, 0, cos(c)], [0, d, 0], [cos(c), 0,  1]])
> In <213>: M
> Out<213>:
> [ a + b, 0, cos(c)]
> [     0, d,      0]
> [cos(c), 0,      1]
>
> In <214>: M.det()
> Out<214>: d*a**2/(a + b) + d*b**2/(a + b) + 2*a*b*d/(a + b) -
> a*d*cos(c)**2/(a + b) - b*d*cos(c)**2/(a + b)
>
> I wonder why there are fractions in the result (all the more as in the
> docstring of det_bareis one reads, that the algorihtm "will result in a
> determinant with minimal number of fractions".).

copyrights has been helping to test the 1766 branch at github/smichr.
In that branch I get:

>>> from sympy.abc import a,b,c,d, C
>>> M = Matrix([[a+b, 0, cos(c)], [0, d, 0], [cos(c), 0,  1]])
>>> M.det()
a*d + b*d - d*cos(c)**2


There is also a method for matrices to remove the gcd from termps:

>>> M = Matrix([[2*a, 4*a],[3*a, 6*a]])
>>> M.gcdfactor()
a
>>> M
[2, 4]
[3, 6]

You might give that a try until 1766 is finally merged into master.

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to [email protected].
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.

Reply via email to