question about columnspace()
wang-zm18 opened this issue · 1 comments
wang-zm18 commented
asmeurer commented
Please post questions on the SymPy mailing list. This is the issue tracker for the SymPy website, and should only be used for issues with the website.
To answer your question, the reason the matrix is not being computed as a rank 2 matrix is because the float values 0.6 and 0.9 are not represented exactly as the rational numbers 6/10 and 9/10, so according to the values those floats actually represent, the matrix has full rank. If you want this calculation to use exactly 0.6 and 0.9, use rational numbers, like
>>> Matrix([[1, 2, 3], [3, 2, 5], [Rational('0.6'), Rational('0.9'), Rational('1.5')]])
Matrix([
[ 1, 2, 3],
[ 3, 2, 5],
[3/5, 9/10, 3/2]])
>>> Matrix([[1, 2, 3], [3, 2, 5], [Rational('0.6'), Rational('0.9'), Rational('1.5')]]).columnspace()
[Matrix([
[ 1],
[ 3],
[3/5]]), Matrix([
[ 2],
[ 2],
[9/10]])]
It is also recommended to avoid creating SymPy objects using NumPy, as NumPy cannot represent the exact rational numbers used by SymPy.