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 interface severely broken for large input, etc. #17388

Open
williamstein opened this issue Nov 24, 2014 · 2 comments
Open

maxima interface severely broken for large input, etc. #17388

williamstein opened this issue Nov 24, 2014 · 2 comments

Comments

@williamstein
Copy link
Contributor

This doesn't work

~/tmp$ sage
│ Sage Version 6.4, Release Date: 2014-11-14                         │
...
sage: maxima.eval("""RedGauss(A,variable):=block([q,var,listeD,listeQ,i,a,l,D],
                            quad:expand(transpose(variable).A.variable),
                            q:quad,var:variable,listeD:[],listeQ:[],D:zeromatrix(length(A),length(A)),
                            while var#[] do (
                            a:diff(q,var[1],2)/2,l:subst(0,var[1],diff(q,var[1])),
    if a=0 and l=0 then var:rest(var)
    elseif a#0 then (
                   listeD:append(listeD,[a]),listeQ:append(listeQ,[var[1]+l/(2*a)=0]),
                   q:subst(0,var[1],q)-l^2/(4*a),var:rest(var))
    else (
        i:2,while subst(0,var[i],diff(l,var[i]))=0 do i:i+1,
        a:diff(q,var[i],2)/2,
        if a#0 then (
        listeD:append(liste,[a]),listeQ:append(listeQ,[var[i]+l/(2*a)=0]),q:subst(0,var[i],q)-l^2/(4*a),
        var:append(rest(var,i-1-length(var)),rest(var,i)))
    else (
        a:diff(q,var[1],1,var[i],1),
        l1:subst([var[1]=0,var[i]=0],diff(q,var[1])),li:subst([var[1]=0,var[i]=0],diff(q,var[i])),
        listeD:append(listeD,[a/4,-a/4]),
        listeQ:append(listeQ,[var[1]+var[i]+(l1+li)/a=0,var[1]-var[i]+(li-l1)/a=0]),
        q:subst([var[1]=0,var[i]=0],q)-l1*li/a,
        var:append(rest(rest(var,i-1-length(var))),rest(var,i))))),
    for k:1 thru length(listeD) do D[k,k]:listeD[k],
            return([D,transpose(coefmatrix(listeQ,variable))]))$""") 

But I guess it should:

Maxima 5.34.1 http://maxima.sourceforge.net
using Lisp ECL 13.5.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) RedGauss(A,variable):=block([q,var,listeD,listeQ,i,a,l,D],
                            quad:expand(transpose(variable).A.variable),
                            q:quad,var:variable,listeD:[],listeQ:[],D:zeromatrix(length(A),length(A)),
                            while var#[] do (
                            a:diff(q,var[1],2)/2,l:subst(0,var[1],diff(q,var[1])),
    if a=0 and l=0 then var:rest(var)
    elseif a#0 then (
                   listeD:append(listeD,[a]),listeQ:append(listeQ,[var[1]+l/(2*a)=0]),
                   q:subst(0,var[1],q)-l^2/(4*a),var:rest(var))
    else (
        i:2,while subst(0,var[i],diff(l,var[i]))=0 do i:i+1,
        a:diff(q,var[i],2)/2,
        if a#0 then (
        listeD:append(liste,[a]),listeQ:append(listeQ,[var[i]+l/(2*a)=0]),q:subst(0,var[i],q)-l^2/(4*a),
        var:append(rest(var,i-1-length(var)),rest(var,i)))
    else (
        a:diff(q,var[1],1,var[i],1),
        l1:subst([var[1]=0,var[i]=0],diff(q,var[1])),li:subst([var[1]=0,var[i]=0],diff(q,var[i])),
        listeD:append(listeD,[a/4,-a/4]),
        listeQ:append(listeQ,[var[1]+var[i]+(l1+li)/a=0,var[1]-var[i]+(li-l1)/a=0]),
        q:subst([var[1]=0,var[i]=0],q)-l1*li/a,
        var:append(rest(rest(var,i-1-length(var))),rest(var,i))))),
    for k:1 thru length(listeD) do D[k,k]:listeD[k],
            return([D,transpose(coefmatrix(listeQ,variable))]))$
 
(%i2)

Issues: maxima._read_in_file_command isn't implemented.

sage: maxima._read_in_file_command('x')
...
NotImplementedError:

But even if you don't use that (instead hard coding the eval cutoff to something large), things are still broken.

This might be related to #1660. This was first reported here:

http://ask.sagemath.org/question/24955/maxima-on-sagecloud/

since people are starting to use SageMathCloud as a Maxima notebook, which it would be quite good for, if only the maxima interface actually worked for large input. (It's very robust for small input -- just not large input.)

Component: interfaces

Issue created by migration from https://trac.sagemath.org/ticket/17388

@nbruin
Copy link
Contributor

nbruin commented Nov 24, 2014

comment:1

Adding

    def _read_in_file_command(self, filename):
        return 'batchload("%s");'%filename

into maxima_abstract seems to do the trick. It returns the temporary filename, so perhaps something should be consumed from the output. I don't know what "load" is supposed to consume.

Also, perhaps it's better to put it in maxima.py, because maxima_lib.py has very little business using this (indeed, the example mentioned in the ticket seems to work for maxima_lib out of the box--I don't think maxima_lib ever reverts to using files). Of course, we do so many non-standard things to maxima_lib that using that to interface with "maxima" is probably not a good idea.

Finally, someone should probably doctest this properly when implementing it.

@nbruin
Copy link
Contributor

nbruin commented Jun 23, 2015

comment:2

Incidentally, if you want to use SMC as a maxima notebook, it might be nice to run maxima/SBCL (or some other lisp that performs better than ECL) as the backend. SBCL doesn't fit the sage distribution/dependency model, so for shipping sage it's better to use ECL (also because it allows us to have a library interface), but for a web service it should be straightforward to drive an expect interface to maxima/SBCL.

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

No branches or pull requests

3 participants