TeX or not TeX



Here is a tex- based solution. Set up a big set of
macro definitions in the TeX language that actually
understand something about math (precedence, etc.)

Then send to TeX something that is the moral equivalent
of the internal form of mathematics in Maxima.

(or the MathML form...)

Then let the TeX macros, which would know the line length,
font size, and the situation (in-line or display), figure
out whether to do
(a+b+c)/(d+e+f)  or

   a+b+c
   ------
   d+e+f

The problem here is that writing TeX macros is rather
uncomfortable for most people.
Another is the size of the macros, which would have to
somehow be input to the TeX processing of expressions.

This approach was actually used by Dan Zwillinger to
simultaneously typeset formulas for Gradshteyn & Rhyzik
and make it possible to input the forms to computer
algebra programs.

RJF

PS, I agree there are more important issues, but
this one is so tempting to discuss..



Stavros Macrakis wrote:
> I have not looked at the Maxima display algorithms for a long time.  On
> the other hand, not too long ago, I did a little work on a Lisp
> pretty-printer, which is a related, though different, problem.
> 
> A classic Lisp pretty-printer ("grind" is the traditional function name)
> does a branch-and-bound tree search of alternative layouts, minimizing
> some objective function (badness).  The simplest and most usual
> objective function is length in lines (for a given width).  Though this
> is an exponential search in theory, in practice it is fast (even in
> interpreted Emacs Lisp...).
> 
> I don't know if TeX is set up to do this kind of search.  Can Tex be
> programmed to try both the linear form of a/b and the built-up form
> without having both alternatives in the source?  (Which would create the
> exponential blowup Richard mentioned.)  If I remember correctly, the Tex
> language (as opposed to the layout engine) is a horrible (and unpleasant
> to debug) macro-based thing which would not really be suitable for
> programming algorithms like this.  But I may be wrong or out of date on
> that.
> 
> It would certainly need more information about the structure of the
> expression than we're currently giving it.  For example, currently
> tex(a.b+c) => $$C+a\cdot b$$.  How is Tex supposed to know that cdot
> binds more closely than plus?
> 
> 
> 
> _______________________________________________
> Maxima mailing list
> Maxima@www.math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima