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

Incorrect result with rref() #15141

sylee957 opened this Issue Aug 24, 2018 · 4 comments


None yet
3 participants

sylee957 commented Aug 24, 2018

While tracing down the issue #15118, #15125, I had found another issue from rref.

from sympy import *

q = symbols("q", positive = True)
m = Matrix([
[-2*cosh(q/3),      exp(-q),            1],
[      exp(q), -2*cosh(q/3),            1],
[           1,            1, -2*cosh(q/3)]])
 [1, 0, 0],
 [0, 1, 0],
 [0, 0, 1]]), (0, 1, 2))

While the result from Mathematica is

$Assumptions = q>0;
{-2*Cosh[q/3], Exp[-q],1},
{Exp[q], -2*Cosh[q/3], 1},
{1, 1, -2*Cosh[q/3]}
{{1, 0, -E^(-q/3)}, {0, 1, -E^(q/3)}, {0, 0, 0}}

I think there are some fundamental issue from the algorithm, that it fails to detect some complex formula like below

(-exp(q) - 2*cosh(q/3))*(-2*cosh(q/3) - exp(-q)) - (4*cosh(q/3)**2 - 1)**2

that it is zero, some weird cross canceling occurs after recognizing it as a pivot rather than zero, and then the row multiplied with these kinds of formula gets broken.

See Also

#15322, #13087, #10279, #10120, #9060, #7567, #4227


This comment has been minimized.


jksuom commented Aug 25, 2018

This is a known issue. It has been suggested that rref should call simplify by default but that may be time consuming (see e.g. #10120).


This comment has been minimized.


sylee957 commented Aug 25, 2018

But I can confirm that even simplify fails on this particular expression for determining zero.

expr = ((-exp(q) - 2*cosh(q/3))*(-2*cosh(q/3) - exp(-q)) - (4*cosh(q/3)**2 - 1)**2)
2*exp(q)*cosh(q/3) - 16*cosh(q/3)**4 + 12*cosh(q/3)**2 + 2*exp(-q)*cosh(q/3)

This comment has been minimized.


jksuom commented Aug 25, 2018

It seems that simplification of hyperbolic functions should be improved. For trigonometric functions, there is fu, but support for hyperbolic functions is minimal.


This comment has been minimized.


smichr commented Aug 25, 2018

support for hyperbolic functions is minimal.

As I recall, it converts hyperbolics to trigs and runs the simplification on them.

In this case, however, simplifying expr.rewrite(exp) returns 0.

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