On Sun, 16 Apr 2023, 15:52 Trevor Karn, <trevor.k.k...@gmail.com> wrote:

> I don't have much understanding of how floating point arithmetic works,
> but the argument
>
> >If you're writing python code, you should expect 2*0.5 to return a
> >float. But if you're learning linear algebra for the first time and
> >typing a matrix into the Sage notebook, typing 0.5 instead of 1/2
> >should not ruin the entire assignment without so much as a warning.
>
> seems important to me. I also sometimes worry that Sage seems to be
> written for users who are both experts in [insert mathematical field here]
> and Python. This prevents (a) mathematical experts who don't know python
> from using Sage and (b) more junior students from using sage. Maybe one can
> make the argument that mathematical experts should just learn python
> (although I would disagree), but I think (b) is a genuine problem.
> Mathematica doesn't seem to require the user to be expert in either math or
> Wolfram language (or maybe I haven't used it enough). I don't have an
> actionable complaint here, but it is something I encounter when helping
> folks around my math department with their code. I'm trying to keep it in
> mind as I develop code.
>
> I see that
>
> sage: A = matrix([[-3, 2, 1 ],[ 2,-4, 4 ], [ 1, 2,-5 ]])
> sage: B = (2*0.5*A)
> sage: rank(B)
> 3
>
> What about floating point arithmetic makes this break? I print (B) and see
>
> [-3.00000000000000  2.00000000000000  1.00000000000000]
> [ 2.00000000000000 -4.00000000000000  4.00000000000000]
> [ 1.00000000000000  2.00000000000000 -5.00000000000000]
>
> which doesn't have any obvious reason to be not rank-2. Could someone ELI5?
>

probably because B.echelon_form() returns the identity matrix - obviously
wrong too



> It is also not unprecedented for an error to be thrown for the rank
> method. From the documentation:
>
>       sage: m = matrix(Integers(4), 2, [2,2,2,2])
>
>       sage: m.rank()
>
>       Traceback (most recent call last):
>
>       ...
>
>       NotImplementedError: Echelon form not implemented over 'Ring of
> integers modulo 4'.
>
> It seems reasonable to me that a similar NotImplementedError could be
> thrown for generic dense matrices. Is that an acceptable solution @Dima and
> @Michael? It seems easy enough to add a `.rank()` method in
> `matrix/matrix_generic_dense.pyx` which throws the error. I'd be happy to
> make this PR if that is reasonable to folks.
> On Sunday, April 16, 2023 at 6:53:36 AM UTC-5 Dima Pasechnik wrote:
>
>> On Sun, Apr 16, 2023 at 12:25 AM Michael Orlitzky <mic...@orlitzky.com>
>> wrote:
>> >
>> > On Sat, 2023-04-15 at 18:20 -0400, David Roe wrote:
>> > > I agree with William that you should refrain from insulting the Sage
>> > > developers, especially when the underlying problem comes from your
>> > > misunderstanding of how floating point arithmetic works.
>> >
>> > I was given this response many times, and I think it's condescending
>> > (no offense). My favorite permabug:
>> >
>> > sage: A = matrix([[-3, 2, 1 ],
>> > ....: [ 2,-4, 4 ],
>> > ....: [ 1, 2,-5 ]])
>> > sage: B = (2 * 0.5 * A)
>> > sage: B == A
>> > True
>> > sage: B.rank() == A.rank()
>> > False
>> >
>>
>> that's a bug in B.rank() - in my book at least. It's perfectly
>> possible to either reliably derive that rank(B)=2,
>> as far as it makes sense in the given precision, or throw an error.
>> It's just not implemented.
>>
>>
>> > I promise you that I know what a floating point number is, and that
>> > they aren't the problem. The problem is that reasonable expectations
>> > are not met by the Sage user interface. It shouldn't be that easy to
>> > get the computer to lie to me. An explanation is of course possible,
>> > but only after the fact, and only with a level of knowledge about the
>> > preprocessor that is beyond most users.
>> >
>> > --
>> > 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/c8531f5211ebfe590ed2b38390b33ef26df1d1eb.camel%40orlitzky.com.
>>
>>
> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sage-devel/cc5a27a3-e855-43e1-a494-b411c613497dn%40googlegroups.com
> <https://groups.google.com/d/msgid/sage-devel/cc5a27a3-e855-43e1-a494-b411c613497dn%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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-devel/CAAWYfq37dLd0chRwMefufgt4n4Tq69f-2B9nwhgR_%3DfMu5Bh5Q%40mail.gmail.com.

Reply via email to