New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Matrix rank() produces wrong result #11434

Closed
JayHoe opened this Issue Jul 26, 2016 · 4 comments

Comments

Projects
None yet
3 participants
@JayHoe
Copy link

JayHoe commented Jul 26, 2016

Consider the following code:

ax,ay,bx,by,cx,cy,dx,dy,ex,ey,t0,t1 = symbols('a_x a_y b_x b_y c_x c_y d_x d_y e_x e_y t_0 t_1')
M=Matrix([[ax,ay,ax*t0,ay*t0,0],[bx,by,bx*t0,by*t0,0],[cx,cy,cx*t0,cy*t0,1],[dx,dy,dx*t0,dy*t0,1],[ex,ey,2*ex*t1-ex*t0,2*ey*t1-ey*t0,0]])

M.rank()
5

M.det()
0

You cannot have full rank of 5 and zero determinant. Cross-checked it on wolframalpha.com which gives 4 for the matrix rank. Thus, the rank calculation must be wrong.

skirpichev added a commit to skirpichev/diofant that referenced this issue Jul 26, 2016

@moorepants

This comment has been minimized.

Copy link
Member

moorepants commented Jul 26, 2016

We have an issue open for these types of errors here: #9480

@JayHoe

This comment has been minimized.

Copy link

JayHoe commented Jul 27, 2016

M.rank(simplify=True) works as expected and yields 4 as matrix rank.

siefkenj added a commit to siefkenj/sympy that referenced this issue Aug 29, 2016

Impliment smart pivoting in `Matrix.rref`
	This patch addresses issues sympy#10718, sympy#9480, sympy#11434

	Now, during row reduction, when searching for
	a pivot, all elements are checked using
	is_zero.  If an element is proved to be non-zero,
	then it is used as a pivot.  If no elements can
	be proved to be non-zero, elements are simplified
	to see if one can be proved to be non-zero.  If
	that fails an assumption is made that one of the
	undetermined elements is non-zero.

	This patch also impliments partial pivoting if
	all entries in a matrix column are floats.
@siefkenj

This comment has been minimized.

Copy link
Contributor

siefkenj commented Sep 8, 2016

This should be resolved by PR #11554. @JayHoe can you verify this and close the issue if true?

@moorepants

This comment has been minimized.

Copy link
Member

moorepants commented Dec 28, 2016

Tested here:


In [1]: from sympy import *

In [2]: %paste
ax,ay,bx,by,cx,cy,dx,dy,ex,ey,t0,t1 = symbols('a_x a_y b_x b_y c_x c_y d_x d_y e_x e_y t_0 t_1')
M=Matrix([[ax,ay,ax*t0,ay*t0,0],[bx,by,bx*t0,by*t0,0],[cx,cy,cx*t0,cy*t0,1],[dx,dy,dx*t0,dy*t0,1],[ex,ey,2*ex*t1-ex*t0,2*ey*t1-ey*t0,0]])

## -- End pasted text --

In [3]: M.rank()
Out[3]: 4

@moorepants moorepants closed this Dec 28, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment