rtoy / maxima

A Clone of Maxima's repo
Other
0 stars 0 forks source link

Odd interplay between eigenvalues() and numer #2505

Open rtoy opened 2 months ago

rtoy commented 2 months ago

Imported from SourceForge on 2024-07-06 10:06:26 Created by ejbarth on 2022-02-21 16:11:32 Original: https://sourceforge.net/p/maxima/bugs/3947


A student in my class noticed

ee:eigenvalues(matrix([-3,2],[-4,3]));
ee,numer;

(both of the above return [[-1,1],[1,1]])

but

eigenvalues(matrix([-3,2],[-4,3])),numer;

(returns [[%e^(1.0*%i*%pi),%e^(2.0*%i*%pi)],[1,1]])

similarly strange behavior for

ff:eigenvalues(matrix([−1,1],[−4,−4]));
ff,numer

and

eigenvalues(matrix([−1,1],[−4,−4])),numer;

wxMaxima version: 19.05.7 using wxWidgets version: wxWidgets 3.1.2 Maxima version: 5.43.0 Maxima build date: 2019-06-05 13:14:43 Host type: x86_64-apple-darwin13.4.0 System type: Darwin 18.7.0 X86-64 Lisp implementation type: SBCL Lisp implementation version: 1.5.3 wxMaxima's idea of the directory layout is: User configuration dir: /Users/barth/.maxima/


rtoy commented 2 months ago

Imported from SourceForge on 2024-07-06 10:06:27 Created by robert_dodier on 2022-02-21 18:14:57 Original: https://sourceforge.net/p/maxima/bugs/3947/#3c7c


solve is eventually called to solve an equation equivalent tox^2 - 1 to find the eigenvalues (you can see this via trace(solve) and then calling eigenvalues). In the presence of the numer flag, that comes out differently.

A lot of built-in functions don't handle float numbers consistently. My advice to the user is to postpone numerical evaluation as long as possible, and apply it only at the end. I know that's not always easy to follow, and since Maxima doesn't prohibit doing otherwise, the user can't know that something is going wrong from the outset.

I am inclined to think solve or at least eigenvalues (and maybe other callers) should disable numer, float, and keepfloat before proceeding. If anyone else has an opinion, I would be interested to hear about it.

rtoy commented 2 months ago

Imported from SourceForge on 2024-07-06 10:06:30 Created by robert_dodier on 2022-02-21 18:15:41 Original: https://sourceforge.net/p/maxima/bugs/3947/#08fb


I encountered a different solve + numer bug while investigating; see #3948.