On 4/20/07, Ondrej Certik <[EMAIL PROTECTED]> wrote:
> > (2) There's the view command which I just mentioned.
>
> I'll try it, thanks.

Let me know if you have trouble.  I haven't used view much in the last year
(I use the notebook more), so it might be somehow broken (??), as its
hard to automatically test.

> > > My idea is to work from a regular python and use some kind of a
> > > console for the graphic stuff.
> >
> > Do you mean ASCII art, e.g., which will look good or not depending
> > on what your email client does to mangle this message:
> >
> > sage: f = sin(x^2)
> > sage: print f.integral(x)        # this is SAGE-2.5 !!
> >                                              (sqrt(2)  I + sqrt(2)) x
> >        sqrt( Pi) ((sqrt(2)  I + sqrt(2)) erf(------------------------)
> >                                                         2
> >                                                    (sqrt(2)  I - sqrt(2)) x
> >                       + (sqrt(2)  I - sqrt(2)) 
> > erf(------------------------))/8
> >                                                               2
>
> We also have and ascii art, written in python directly. We however
> decided that the sympy.core (probably the same as your sage.calculus)
> should only know a "linear mess" and a mathml, and all the other
> formats should be converted from mathml. And we didn't yet write a
> mathml -> ascii art conversion.
>
> f you want to look at our ascii art printer:
>
> http://code.google.com/p/sympy/issues/detail?id=53
>
> it's not yet integrated into the newest sympy, but if you look at the
> attached file, it should work - it contains an old version of sympy,
> that should work with the pretty printer. And the pretty printing code
> was contributed by Jurjen Bos and is is written in a general way, thus
> it can easily be used in sage as well.

Many thanks for pointing this out.

> But I meant a graphic console. I think the view(x) is just what I want
> - I'll install sage and try it. I think it's better to show a xdvi (or
> evince) with the latex dvi/ps file, rather than my pygame window.

That sympy depends on pygame is painful, since pygame isn't
trivial to install.  When somebody recently was installing sympy
into SAGE, they biggest issue was first installing pygame into SAGE
(they did it, but it wasn't completely trivial).

> Do you have some standard for exchanging expressions?
> I think the
> mathml is just for it. But I didn't try it with maple/mathematica, we
> only tried the SymPy's generated mathml with a mathml -> latex
> conversion using a xsl, that can be found on the web, and that works
> fine.

SAGE makes no nontrivial use of either mathml or openmath.

For latex output, all SAGE objects have an  _latex_ method, sort
of like Python's __repr__ method; every object can thus output
itself in latex format directly -- there is no mathml intermediate.
Likewise, to export an object to maxima, every SAGE object
has a _maxima_init_ method that outputs a string that, when
interpreted by Maxima, gives a corresponding object.  Also,
objects have a _maxima_ method that takes an instance of
maxima and returns a Python classes of type MaximaElement
that is a pointer to an actual object in a running instance
of Maxima (and that object is cached, so subsequent calls
return the same object -- moreover if the maxima session crashes
the object is automatically recreated).    All the statements above
about maxima apply to the other dozen or so SAGE interfaces, e.g.,
to Maple, Magma, GAP, Singular, etc.  (there are defaults for
the various .._init_ methods in the base class...).

To convert an arbitrary symbolic expression as output by maxima back to
SAGE there is a function (new in SAGE-2.5) that sets up some variables,
does some minimal preparsing, then uses Python's eval command on
a string.  Thus the conversion from maxima to Python is:

  maxima string repr --> slightly parsed version
            --> Python interpreter's eval --> Python object

We have not written something like this (that works in general) for
Maple or Mathematica yet, but Bobby Moretti is working on it right now.

-- 
William Stein
Associate Professor of Mathematics
University of Washington
http://www.williamstein.org

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://sage.scipy.org/sage/ and http://modular.math.washington.edu/sage/
-~----------~----~----~----~------~----~------~--~---

Reply via email to