Bug or unfortunate feature?

79 views
Skip to first unread message

David Guichard

unread,
Sep 5, 2019, 6:29:26 PM9/5/19
to sage-devel
When is a linear system consistent?

This isn't helpful:

a,b,c=var('a b c')
A=matrix([[-4,5,9,a],[1, -2, 1, b],[-2,4,-2,c]])
A.echelon_form()
A.rref()

[    1     0 -23/3     0]
[    0     1 -13/3     0]
[    0     0     0     1]

[ 1 0 -23/3 0] [ 0 1 -13/3 0] [ 0 0 0 1]

But this works, so I know how to get what I want:

R.<a,b,c>=QQ[]
A=matrix(R,[[-4,5,9,a],[1, -2, 1, b],[-2,4,-2,c]])
A.echelon_form()

[ 1 0 -23/3   -2/3*a - 5/3*b]
[ 0 1 -13/3   -1/3*a - 4/3*b]
[ 0 0     0             2*b + c]

So [a,b,c] is in the span of the columns iff 2b+c==0.

Somewhat oddly, rref doesn't work here:

A.rref()

[    1     0 -23/3     0]
[    0     1 -13/3     0]
[    0     0     0     1]

David Joyner

unread,
Sep 5, 2019, 6:33:49 PM9/5/19
to sage-devel
This is because the CAS used assumes  2*b + c is non-zero.
I would call it an "unfortunate feature", except that it (this "feature")
gives teachers of linear algebra examples for tests and quizzes that
can't be correctly solved using a CAS, and have to be solved by hand.

--
You received this message because you are subscribed to the Google Groups "sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/3db327ca-9826-4fc8-92b1-b14aa80dfe82%40googlegroups.com.

Thierry

unread,
Sep 6, 2019, 4:19:48 AM9/6/19
to sage-...@googlegroups.com
Hi,
I would say that there is a bug in the 'default' algorithm. Note that
changing the algorithm leads to:

sage: A.echelon_form(algorithm='partial_pivoting')
[ 1 0 -23/3 -2/3*a + 5/6*c]
[ 0 1 -13/3 -1/3*a + 2/3*c]
[ 0 0 0 b + 1/2*c]

Ciao,
Thierry


> --
> > You received this message because you are subscribed to the Google Groups
> > "sage-devel" group.
> > To unsubscribe from this group and stop receiving emails from it, send an
> > email to sage-devel+...@googlegroups.com.
> > To view this discussion on the web visit
> > https://groups.google.com/d/msgid/sage-devel/3db327ca-9826-4fc8-92b1-b14aa80dfe82%40googlegroups.com
> > <https://groups.google.com/d/msgid/sage-devel/3db327ca-9826-4fc8-92b1-b14aa80dfe82%40googlegroups.com?utm_medium=email&utm_source=footer>
> > .
> >
>
> --
> You received this message because you are subscribed to the Google Groups "sage-devel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/CAEQuuAX6p-Tn8uTsYrW_F7PR_gbtxuqz0rV4AJs_PB%2B4CuqCiA%40mail.gmail.com.

Nils Bruin

unread,
Sep 6, 2019, 12:38:18 PM9/6/19
to sage-devel
On Friday, September 6, 2019 at 1:19:48 AM UTC-7, Thierry (sage-googlesucks@xxx) wrote:

I would say that there is a bug in the 'default' algorithm. Note that
changing the algorithm leads to:

sage: A.echelon_form(algorithm='partial_pivoting')
[             1              0          -23/3 -2/3*a + 5/6*c]
[             0              1          -13/3 -1/3*a + 2/3*c]
[             0              0              0      b + 1/2*c]


While that may be a useful answer for this particular problem, the real issue is that linear algebra over rings that are not fields is more complicated. Over PIDs one can use Hermite Normal Form as a substitute for reduced row echelon form, in general this gets more complicated. Even unique factorization domains are not so easy to handle.

For instance, over QQ[a,b,c,d], how would you echelonize the following matrix?

[ a b ]
[ c d ]

There are algorithms to compute with modules over polynomial rings (i.e., do linear algebra over polynomial rings), but they require more complicated methods (basically groebner bases) and the answers one gets are more complicated too, because these modules are not just determined by their free rank (the analogue of dimension).

So for the original problem I'd go with: "unfortunate mathematical reality" rather than "unfortunate feature".
Reply all
Reply to author
Forward
0 new messages