[OS X TeX] Binomial Expansion

Ross Moore ross at ics.mq.edu.au
Wed Nov 22 23:27:17 EST 2006


Hello Alain,

On 23/11/2006, at 1:52 PM, Alain Schremmer wrote:

> If the following is OT, I would very much appreciate being  
> redirected to some more appropriate list.
>
> If only to learn a little bit about how LaTeX works, I thought I  
> would try over the Christmas break to work on defining something like
>
>    \Evaluate{Polynomial in x}{some number}
>
> and/or
>
>    \Expand{a}{b}{some degree}              (i.e. binomial expansions)
>
> Of course I have no hope whatsoever to succeed with either one but  
> I started to read Appendix 1 of Companion 2ed and that doesn't look  
> like very relevant.

TeX was not designed to do symbolic algebra; though,
in principle, it has enough features to be able to.
Some packages have been written to do a bit, but they
are hardly efficient beyond simple calculations.

Do you have packages like  Mathematica, or Maple ?
These can be run from the command-line, and programmed
to write their output into a file.
Indeed, there's usually a TeXForm, which is designed
for use within (La)TeX jobs.

This means that you can use (La)TeX to write programming
code into a file, then:
  a.  using TeX's  \write18  feature
   (provided  --shell-escape  is enabled )
      launch an external program to run, and read that file,
      writing the result into a different file;
  b.  pause the TeX job until the external job is finished;
  c.  read in and process the result.

All of these steps are do-able, but none are particularly
easy to program correctly in TeX, without some experience.


As an example of such interactive programming with TeX,
I have written coding that performs the following task:

  a.  locates the bibliography of a maths article;

  b.  writes it into an external file; then

  c.  re-reads the external file, with the macros having
      altered meanings, to do the following:
   (i) build up an XML file including information from
        the bibliography for each bibitem;
   (ii) prepares a data-base query including ...
  (iii) ... the author, title, etc. in a loosely
        formatted LaTeX form, as might be used to typeset it;
   (iv) add lines for some extra fields, initially empty.

  d.  invokes a Perl program to submit the XML file to
      MathSciNet  at www.ams.org  as a batched-MRef query;

  e.  awaits the result of the query, which is written into
      another file;

  f.  calls up the command-line  'grep' utility to locate
      and store the values of the previously empty fields;
      (which are the data-base codes for the articles themselves)

  g.  then uses more TeX programming to read and parse the
      new information, for use in typesetting the article.

The result of all this is to include an active hyperlink to the
MathSciNet record of each referenced bib-item as part of the
typeset presentation of the bibliography.
(The information found this way is also used to create a web-site
for the article, including the bibliography hyperlinked to
MathSciNet, as above.)


Many different programs are involved in this example.
In your case, it can be something simpler using just
Mathematica or Maple (or whatever); but you still need
to learn how to make TeX write to external files, and
read back the results from other files.

>
> Is there something readable on the subject? For instance, something  
> that would help me read the awesome polynom.sty?

It may take years of practice before that becomes readable.
At some point you will have to read parts of The TeX Book,
or other books about programming in TeX.
Only then do you have any real chance of understanding what
each line of such coding is actually doing.

>
> Hopeful regards
> --schremmer

Best of luck,

	Ross

------------------------------------------------------------------------
Ross Moore                                         ross at maths.mq.edu.au
Mathematics Department                             office: E7A-419
Macquarie University                               tel: +61 +2 9850 8955
Sydney, Australia  2109                            fax: +61 +2 9850 8114
------------------------------------------------------------------------


------------------------- Info --------------------------
Mac-TeX Website: http://www.esm.psu.edu/mac-tex/
          & FAQ: http://latex.yauh.de/faq/
TeX FAQ: http://www.tex.ac.uk/faq
List Archive: http://tug.org/pipermail/macostex-archives/




More information about the MacOSX-TeX mailing list