Updates:
        Labels: Matrices

Comment #1 on issue 2184 by asmeurer: Wrong rref()
http://code.google.com/p/sympy/issues/detail?id=2184

What should the correct answer be? Maybe this is correct, when you pass simplifed=True to rref():


In [16]: M.rref(simplified=True)
Out[16]:
⎛⎡ ⎛ 2 ⎞ ⎞ ⎤ ⎞ ⎜⎢ ⎛ ⎛ qc⋅qs ⎞ ⎞ ⎜ ⎛ qc⋅qs ⎞ ⎜ qc ⎟ ⎟ ⎥ ⎟ ⎜⎢ ⎜qc⋅⎜-qc + ──────────⎟ ⎟ ⎜ ⎜-qc + ──────────⎟⋅(-qs + 2⋅qc)⋅⎜qs - ──────────⎟ ⎟ ⎥ ⎟ ⎜⎢ ⎛ 2 ⎞ ⎜ ⎝ -qs + 2⋅qc⎠ qs ⎟ ⎜ ⎝ -qs + 2⋅qc⎠ ⎝ -qs + 2⋅qc⎠ qc⋅qs ⎟ ⎥ ⎟ ⎜⎢ ⎜ qc ⎟ (-qs + 3⋅qc)⋅⎜────────────────────── + ──────────⎟⋅⎜-qc - ───────────────────────────────────────────────── + ──────────⎟ ⎥ ⎟ ⎜⎢ qc⋅⎜qs - ──────────⎟ ⎜ 2 2 -qs + 2⋅qc⎟ ⎜ 2 2 -qs + 2⋅qc⎟ ⎥ ⎟ ⎜⎢ ⎝ -qs + 2⋅qc⎠ ⎝-4⋅qc⋅qs + qs + 3⋅qc ⎠ ⎝ -4⋅qc⋅qs + qs + 3⋅qc ⎠ qc ⎥ ⎟ ⎜⎢1 0 0 ────────────────────── - ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── - ──────────⎥, [0, 1, 2]⎟ ⎜⎢ 2 2 2 -qs + 2⋅qc⎥ ⎟ ⎜⎢ -4⋅qc⋅qs + qs + 3⋅qc -4⋅qc⋅qs + 4⋅qc ⎥ ⎟ ⎜⎢ ⎜⎢ ⎛ 2 ⎞ ⎞ ⎥ ⎟ ⎜⎢ ⎛ qc⋅qs ⎞ ⎜ qc ⎟ ⎟ ⎥ ⎟ ⎜⎢ ⎜-qc + ──────────⎟⋅(-qs + 2⋅qc)⋅⎜qs - ──────────⎟ ⎟ ⎥ ⎟ ⎜⎢ ⎛ 2 ⎞ ⎛ qc⋅qs ⎞ ⎜ ⎝ -qs + 2⋅qc⎠ ⎝ -qs + 2⋅qc⎠ qc⋅qs ⎟ ⎥ ⎟ ⎜⎢ ⎜ qc ⎟ ⎜-qc + ──────────⎟⋅(-qs + 2⋅qc)⋅(-qs + 3⋅qc)⋅⎜-qc - ───────────────────────────────────────────────── + ──────────⎟ ⎥ ⎟ ⎜⎢ (-qs + 2⋅qc)⋅⎜qs - ──────────⎟ ⎝ -qs + 2⋅qc⎠ ⎜ 2 2 -qs + 2⋅qc⎟ ⎥ ⎟ ⎜⎢ ⎝ -qs + 2⋅qc⎠ ⎝ -4⋅qc⋅qs + qs + 3⋅qc ⎠ ⎥ ⎟ ⎜⎢0 1 0 ────────────────────────────── - ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────── ⎥ ⎟ ⎜⎢ 2 2 ⎛ 2⎞ ⎛ 2 2⎞ ⎥ ⎟ ⎜⎢ -4⋅qc⋅qs + qs + 3⋅qc ⎝-4⋅qc⋅qs + 4⋅qc ⎠⋅⎝-4⋅qc⋅qs + qs + 3⋅qc ⎠ ⎥ ⎟ ⎜⎢ ⎜⎢ ⎛ ⎛ 2 ⎞ ⎞ ⎥ ⎟ ⎜⎢ ⎜ ⎛ qc⋅qs ⎞ ⎜ qc ⎟ ⎟ ⎥ ⎟ ⎜⎢ ⎜ ⎜-qc + ──────────⎟⋅(-qs + 2⋅qc)⋅⎜qs - ──────────⎟ ⎟ ⎥ ⎟ ⎜⎢ ⎜ ⎝ -qs + 2⋅qc⎠ ⎝ -qs + 2⋅qc⎠ qc⋅qs ⎟ ⎥ ⎟ ⎜⎢ (-qs + 3⋅qc)⋅⎜-qc - ───────────────────────────────────────────────── + ──────────⎟ ⎥ ⎟ ⎜⎢ ⎜ 2 2 -qs + 2⋅qc⎟ ⎥ ⎟ ⎜⎢ ⎝ -4⋅qc⋅qs + qs + 3⋅qc ⎠ ⎥ ⎟ ⎜⎢0 0 1 ─────────────────────────────────────────────────────────────────────────────────── ⎥ ⎟ ⎜⎢ 2 ⎜⎢ -4⋅qc⋅qs + 4⋅qc ⎥ ⎟ ⎜⎢ ⎝⎣0 0 0 0 ⎦ ⎠


The correctness of the reduced row echelon form algorithm relies on the ability to determine if an expression is identically zero. By default, Matrix.rref() does not try to simplify expressions to zero, but simplified=True has it do this. So sometimes, it will not reduce symbolic expressions to zero without this. I would recommend using it for symbolic matrices (note that for very large/complex matrices, this can slow things down though).

--
You received this message because you are subscribed to the Google Groups 
"sympy-issues" 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-issues?hl=en.

Reply via email to