Calling Maxima from Java



On 5/18/07, Mario Rodriguez <biomates at telefonica.net> wrote:

> She wants to build a graphical interface in Java to make some circuit
> computations and graphics (Bode diagrams). The idea is to use Java as
> the graphical interface and Maxima to make the mathematics and the
> graphics to be displayed by her program.

About Bode diagrams specifically, there is a small add-on package
for that. ?? bode should find some info and load(bode) loads it.

About combining Java + Maxima in general. There are various
possibilities here, which range from the almost-satisfactory to nearly-
impossible.

(1) Running Maxima as an external process and capturing the output.
Main problems here are parsing the output, and handling interactive
queries (asksign, ask-prop, maybe others) somehow.
The command line argument --very-quiet (to suppress input and output
labels) may be helpful.

(1a) Instead of writing a stand-alone Java program, it should be
possible for an Eclipse plug-in to manage the Maxima interaction.
That would be a big win because Eclipse provides lots of built-in
graphical features. I was corresponding with someone about that;
if anyone is interested, I'll dig out those emails.

(2) Generating expressions in Maxima and compiling them with
Java's compiler. E.g.
(divide (x^5 + x^2 + 1, x^2 - 1), map (fortran, [a = first (%%), b =
second (%%)]));
 =>
      a = x**3+x+1
      b = x+2
and then running that stuff through javac (command line) or the
javax.tools.JavaCompiler class (new in Java 1.6).
Maybe someone can write a java function to emit Java-appropriate
notation; I don't think that would be very difficult.

(3) Running Maxima from CL implemented in Java. Theoretically
that could allow direct function calls. The only such CL that I know
about is ABCL, which is apparently unfinished and dormant, and
slow, and when compiled with ABCL, Maxima fails its testsuite.
But if someone wants to finish ABCL that could be very useful.

(4) Running Maxima from a CL compiled to Java VM instructions.
Again the goal is to make direct function calls. The candidate
CL is Clisp; theoretically one could replace the Clisp code
generator, which generates instructions for Clisp's own VM.
This item is on the Clisp wish list but no progress has been made.

Hope this brain-dump is helpful in some way.

Robert