Skip to content
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

Maxima from the OS #35615

Closed
wants to merge 11 commits into from
Closed

Maxima from the OS #35615

wants to merge 11 commits into from

Conversation

dimpase
Copy link
Member

@dimpase dimpase commented May 5, 2023

This will take care of #32867 (the rebased branch is from there)

fchapoton and others added 10 commits May 3, 2023 08:58
<!-- Please provide a concise, informative and self-explanatory title.
-->
<!-- Don't put issue numbers in the title. Put it in the Description
below. -->
<!-- For example, instead of "Fixes sagemath#12345", use "Add a new method to
multiply two integers" -->

### 📚 Description

Fixing the linter workflow

<!-- Describe your changes here in detail. -->
<!-- Why is this change required? What problem does it solve? -->
<!-- If this PR resolves an open issue, please link to it here. For
example "Fixes sagemath#12345". -->
<!-- If your change requires a documentation PR, please link it
appropriately. -->

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. It should be `[x]` not `[x
]`. -->

- [x] The title is concise, informative, and self-explanatory.
- [x] The description explains in detail what this PR is about.
- [ ] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation accordingly.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on
- sagemath#12345: short description why this is a dependency
- sagemath#34567: ...
-->

<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
This should work automatically, and the previous behavior is
incorrect if we intend to use the system copy of maxima.
This new spkg-configure.m4 checks for both a "maxima" executable, and
the usability of a "maxima" package by ECL. (The latter requires a
patched maxima until a new release with commit a0d7a43e523 is made.)
Notably absent for the moment is a version check, but that should be
okay: at the moment, the only system copies of maxima that support
being used as an ECL library are those that are patched, and the only
reason to patch them is if you intend to use them with SageMath. So in
short, if a distro patches their maxima to use it with sage, we expect
it to work with sage.

This commit also moves the SAGE_MAXIMA_FAS variable handling from
ECL's spkg-configure.m4 to maxima's (where it would have belonged in
the first place, if maxima had an spkg-configure.m4 at the time.)
This patch won't be present in a system copy of maxima (at least for
now), so we disable these tests to avoid spurious failures once we
start accepting maxima from the system.
We have some old code and an old test for a memory limit that was
present in ECL 12 years ago, worked around in ticket 6772. The memory
limit is no longer in place, and would not have applied to a non-ECL
maxima from the system anyway. Since the test itself is purposely
wasteful (to ensure that we can use lots of RAM), we take this
opportunity to remove it and speed up the test suite a bit.
… directory.

This just fixes a test. The problem was noticed on Arch where, due to
some other circumstances, maxima was executed from within /usr/sbin.
But all we know for sure is that maxima will live in PATH. So we
modify the test to look only for "maxima", and not its parent
directory.
The ECL library is now contained in a separate maxima-fas package that
will pull in maxima itself.
@antonio-rojas
Copy link
Contributor

As mentioned in #32867 (comment) we should deal with the 5.46 update first. The release is over a year old and many distros are shipping it by now, this will make a few tests fail in those

@dimpase
Copy link
Member Author

dimpase commented May 5, 2023

On Gentoo with system maxima 5.46.0 I get few test errors. One of them is "noise" from 5.46 apparently converting floats in integrals to rationals:

File "src/sage/symbolic/integration/integral.py", line 750, in sage.symbolic.integration.integral.integrate
Failed example:
    res = integral(f,x,0.0001414, 1.); res
Expected:
    2*y*arctan(1.0/y) - 2*y*arctan(0.0001414/y) + 1.0*log(1.0*y^2 + 1.0) - 0.0001414*log(1.0*y^2 + 1.9993959999999997e-08) - 1.9997172
Got:
    -2*y*arctan(1/196559360927*sqrt(196559360927)*sqrt(3930)/y) + 2*y*arctan(1/y) - 1/196559360927*sqrt(196559360927)*sqrt(3930)*log(y^2 + 3930/196559360927) + 2/196559360927*sqrt(196559360927)*sqrt(3930) + log(y^2 + 1) - 2

similarly, one can't use floats in limit computations:

File "src/sage/calculus/calculus.py", line 1190, in sage.calculus.calculus.limit
Failed example:
    f.limit(x=1.2)
Expected:
    2.06961575467...
Got:
    und 

But it's actually a regression of sorts, as

sage: f.limit(x=12/10)
und

On the other hand, some limits done better than before:

File "src/sage/calculus/calculus.py", line 1219, in sage.calculus.calculus.limit
Failed example:
    limit(x^a,x=0)
Expected:
    Traceback (most recent call last):
    ...
    ValueError: Computation failed since Maxima requested additional
    constraints; using the 'assume' command before evaluation *may* help
    (example of legal syntax is 'assume(a>0)', see `assume?` for
     more details)
    Is a an integer?
Got:
    0

File "src/sage/calculus/calculus.py", line 1228, in sage.calculus.calculus.limit
Failed example:
    limit(x^a, x=0)
Expected:
    Traceback (most recent call last):
    ...
    ValueError: Computation failed since Maxima requested additional
    constraints; using the 'assume' command before evaluation *may* help
    (example of legal syntax is 'assume(a>0)', see `assume?` for
     more details)
    Is a an even number?
Got:
    0

some output formats got better:

**********************************************************************
File "src/sage/calculus/calculus.py", line 2255, in sage.calculus.calculus.symbolic_expression_from_maxima_string
Failed example:
    solve([x != 5], x)
Expected:
    [[x - 5 != 0]]
Got:
    [[x < 5], [5 < x]]
**********************************************************************
File "src/sage/calculus/calculus.py", line 2257, in sage.calculus.calculus.symbolic_expression_from_maxima_string
Failed example:
    solve([2*x==3, x != 5], x)
Expected:
    [[x == (3/2), (-7/2) != 0]]
Got:
    [[x == (3/2)]]

some outputs are equivalent, but swapped around:

File "src/sage/symbolic/relation.py", line 1790, in sage.symbolic.relation.solve_ineq_fourier
Failed example:
    solve_ineq_fourier([x+y<9,x-y>4],[y,x])
Expected:
    [[y < min(x - 4, -x + 9)]]
Got:
    [[y < min(-x + 9, x - 4)]]

as above, but in another file:

sage -t --warn-long 66.5 --random-seed=238159399368936496605278695210462135284 src/sage/interfaces/maxima_lib.py
**********************************************************************
File "src/sage/interfaces/maxima_lib.py", line 937, in sage.interfaces.maxima_lib.MaximaLib.sr_limit
Failed example:
    limit(f,x = 1.2)
Expected:
    2.06961575467...
Got:
    und
**********************************************************************
File "src/sage/interfaces/maxima_lib.py", line 950, in sage.interfaces.maxima_lib.MaximaLib.sr_limit
Failed example:
    limit(x^a,x=0)
Expected:
    Traceback (most recent call last):
    ...
    ValueError: Computation failed ...
    Is a an integer?
Got:
    0

A format change:

File "src/sage/functions/exp_integral.py", line 604, in sage.functions.exp_integral.Function_log_integral_offset
Failed example:
    Li(x).integrate(x,2.0,4.5)
Expected:
    -2.5*log_integral(2) + 5.799321147411334
Got:
    -Ei(2*log(9/2)) + Ei(2*log(2)) + 9/2*log_integral(9/2) - 4.5*log_integral(2)

(can just test the numerical value)

@dimpase
Copy link
Member Author

dimpase commented May 5, 2023

Should we just merge this, and would on updating Sage's maxima to 5.46.0 ?

@dimpase
Copy link
Member Author

dimpase commented May 5, 2023

File "src/sage/calculus/calculus.py", line 1190, in sage.calculus.calculus.limit
Failed example:
    f.limit(x=1.2)
Expected:
    2.06961575467...
Got:
    und 

is a regression in Sage interface to maxima - computing this limit at maxima console works just fine.

@dimpase
Copy link
Member Author

dimpase commented May 5, 2023

@nbruin - do you have any idea why with maxima 5.46.0 the following breaks

sage: f(x)=(1+1/x)^x
sage: f.limit(x=6/5)
L= [<ECL: ((MEXPT) ((MPLUS) ((MEXPT) |$_SAGE_VAR_x| -1) 1) |$_SAGE_VAR_x|)>, <ECL: |$_SAGE_VAR_x|>, <ECL: ((RAT) 6 5)>]
   eval result:  $UND 

x |--> und

(this is with prints() added:

--- a/src/sage/interfaces/maxima_lib.py
+++ b/src/sage/interfaces/maxima_lib.py
@@ -993,8 +993,12 @@ class MaximaLib(MaximaAbstract):
                 L.append(max_plus)
             elif dir == "minus":
                 L.append(max_minus)
+            print("L=", L)
+            eva=maxima_eval(([max_limit], L))
+            print("   eval result: ", eva,"\n")
             return max_to_sr(maxima_eval(([max_limit], L)))
         except RuntimeError as error:
+            print("oops, error:", str(error))
             s = str(error)
             if "Is" in s: # Maxima asked for a condition
                 self._missing_assumption(s)

for integer values the limit is computed just fine

sage: f.limit(x=6)
L= [<ECL: ((MEXPT) ((MPLUS) ((MEXPT) |$_SAGE_VAR_x| -1) 1) |$_SAGE_VAR_x|)>, <ECL: |$_SAGE_VAR_x|>, <ECL: 6>]
   eval result:  ((RAT SIMP) 117649 46656) 

x |--> 117649/46656

as well as in maxima console it's all just fine:

$ maxima
;;; Loading #P"/usr/lib64/ecl-21.2.1/sb-bsd-sockets.fas"
;;; Loading #P"/usr/lib64/ecl-21.2.1/sockets.fas"
Maxima 5.46.0 https://maxima.sourceforge.io
using Lisp ECL 21.2.1
Distributed under the GNU Public License. See the file COPYING.
Dedicated to the memory of William Schelter.
The function bug_report() provides bug reporting information.
(%i1) f:(1+1/x)^x
;
                                    1     x
(%o1)                              (- + 1)
                                    x
(%i2) limit(f,x,6/5);
                                   6 log(11/6)
                                   -----------
                                        5
(%o2)                            %e

@nbruin
Copy link
Contributor

nbruin commented May 6, 2023

By the looks of it, the expression that sage passes to maxima is the same as what should ressult from entering it directly into maxima. Hence, any differences probably arise from the different options that maxima_calculus sets. Hence, in order to identify the regression in maxima, you should run the example with the environment options that maxima_calculus uses. It's very conceivable that maxima development introduced a regression in the behaviour with those options activated, since their testing mainly takes place with the standard options in force.

@dimpase
Copy link
Member Author

dimpase commented May 6, 2023

ah, right, it's that kind of thing again.

$ maxima
;;; Loading #P"/usr/lib64/ecl-21.2.1/sb-bsd-sockets.fas"
;;; Loading #P"/usr/lib64/ecl-21.2.1/sockets.fas"
Maxima 5.46.0 https://maxima.sourceforge.io
using Lisp ECL 21.2.1
Distributed under the GNU Public License. See the file COPYING.
Dedicated to the memory of William Schelter.
The function bug_report() provides bug reporting information.
(%i1) f:(1+1/x)^x;
                                    1     x
(%o1)                              (- + 1)
                                    x
(%i2) domain: complex;
(%o2)                               complex
(%i3) limit(f,x,6/5);
(%o3)                                 und
(%i4) limit(f,x,4/3);
                                   4 log(7/4)
                                   ----------
                                       3
(%o4)                            %e
(%i8) domain: real;
(%o8)                                real
(%i9) limit(f,x,6/5);
                                   6 log(11/6)
                                   -----------
                                        5
(%o9)                            %e

Reported upstream : https://sourceforge.net/p/maxima/bugs/4138/

@dimpase
Copy link
Member Author

dimpase commented May 6, 2023

@thierry-FreeBSD - is ed729a9 OK?

@mkoeppe
Copy link
Contributor

mkoeppe commented May 6, 2023

@dimpase Is no version check needed at all?
Debian 10 (buster) has 5.42.1, Ubuntu trusty has 5.32.1
https://repology.org/project/maxima/versions

@thierry-FreeBSD
Copy link

@thierry-FreeBSD - is ed729a9 OK?

Yes it is!

@thierry-FreeBSD
Copy link

Is no version check needed at all? Debian 10 (buster) has 5.42.1, Ubuntu trusty has 5.32.1 https://repology.org/project/maxima/versions

ATM FreeBSD has 5.46.0. It is usually kept up-to-date.

@github-actions
Copy link

github-actions bot commented May 6, 2023

Documentation preview for this PR is ready! 🎉
Built with commit: ed729a9

@dimpase dimpase mentioned this pull request May 6, 2023
5 tasks
@tobiasdiez tobiasdiez added the s: run conda ci Run the conda workflow on this PR. label May 7, 2023
@dimpase
Copy link
Member Author

dimpase commented May 9, 2023

let's review this as a part of #35619 and close after it's merged.

@dimpase
Copy link
Member Author

dimpase commented May 10, 2023

this will be completed in #35619

@dimpase dimpase closed this May 10, 2023
vbraun pushed a commit that referenced this pull request May 28, 2023
    
### 📚 upgrade Maxima to 5.46.0

Our 5.45.0 is getting old. This will fix #32898 as well.

We have one mild regression found while working on #35615 (already
reported upstream),
 but number of improvements in a number of places. As #35615 is a part
of this PR branch,
I propose to review them all here.

We also promote `info` spkg to standard, and make it install
`makeinfo/texi2any`, to deal with Maxima docs.
This allows us to simplify configuration/installation of Maxima and ECL.

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. It should be `[x]` not `[x
]`. -->

- [x] The title is concise, informative, and self-explanatory.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation accordingly.

### ⌛ Dependencies

#35615 - provide `spkg-configure.m4` for Maxima


<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
    
URL: #35619
Reported by: Dima Pasechnik
Reviewer(s): Dima Pasechnik, François Bissey, Gonzalo Tornaría, Matthias Köppe, Mauricio Collares, Michael Orlitzky
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants