Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to embed Maxima in Common Lisp?

26 views
Skip to first unread message

Yigal

unread,
Aug 18, 2007, 7:42:58 AM8/18/07
to
Hi,

I'm learning Lisp (clisp) with purpose to build a site for interactive
solving school math problems.

My question is, how can I call Maxima from within a Lisp program?

In "Maxima tutorial" they say: "The Lisp function mfuncall calls a
Maxima function", but when I try it in my clisp, I get "mfuncall is
undefined". I think I need to load some Maxima's library but I don't
know what exactly, Maxima consist of many .lisp files...

Thanks for the help in advance.

Yigal Asnis.

Xah Lee

unread,
Aug 18, 2007, 5:03:50 PM8/18/07
to
Not a answer to your question, but a piece of info i think you'll be
interested:

«Maxima does not include any of the numerous enhancements made to the
commercial version of Macsyma between 1982-1999 (at least 50 man-years
of work). Due to this, extensive effort may be required to port code
from Macsyma to Maxima.»

above is a quote from:
http://en.wikipedia.org/wiki/Macsyma

If you have about 3 thousand dollars to spare, you might want to buy
Mathematica instead. Goto:
http://wolfram.com/

If you have no money to spare, it is my feeling that there are better
free packages than maxima.

Wikipedia has a page that list computer algebra software.

Xah
x...@xahlee.org
http://xahlee.org/

Alan Shutko

unread,
Aug 18, 2007, 8:13:29 PM8/18/07
to
Xah Lee <x...@xahlee.org> writes:

> «Maxima does not include any of the numerous enhancements made to the
> commercial version of Macsyma between 1982-1999 (at least 50 man-years
> of work). Due to this, extensive effort may be required to port code
> from Macsyma to Maxima.»

So what? Yigal never mentioned Macsyma and most likely doesn't have a
pile of code to reuse.

--
Alan Shutko <a...@acm.org> - I am the rocks.
Cat bathing is a martial art.

Xah Lee

unread,
Aug 19, 2007, 2:23:35 AM8/19/07
to
2007-08-18

Xah Lee wrote:
«Maxima does not include any of the numerous enhancements made to the
commercial version of Macsyma between 1982-1999 (at least 50 man-years
of work). Due to this, extensive effort may be required to port code
from Macsyma to Maxima.»

Alan Shutko wrote:
«So what? Yigal never mentioned Macsyma and most likely doesn't have
a pile of code to reuse.»

A forum is used to facilitate communication and exchange of
information. I passed a information that is reasonably useful.

Your post, considered as it is, is of the nature censuring, and has
nothing to do with contributing lisp related info. (a large portion of
off-topic posts, are in fact of this type)

But basically, you know and i know, the nature of your post (in this
case) and most other lisper's post here, have a basis on Common Lisp
advocacy. This stance, occationally conflicts with exchanging
information about lisp. That is why, whenever some information or
discussion, that might slightly be constructed as bad publicity for
Common Lisp, will garner a great bag of common lisping moron's wrath.

e.g.
How Purely Nested Notation Limits The Language's Utility
http://xahlee.org/UnixResource_dir/writ/notations.html

In the past couple of years, i refrained from answering or
participating in threads that have become off-topic in a strict sense.
(e.g. many posts about me, about netiquette, angry denials, spun-off
arguments) But i think my moral attitude and posting mannerism is too
stringent. So, in this year, i'll more freely participate in the
discussion, which many have accused me of not doing.

Further readings:
Philosophies of Netiquette (ranting essay)
http://xahlee.org/UnixResource_dir/writ/phil_netiquette.html

Xah
x...@xahlee.org
http://xahlee.org/

Yigal

unread,
Aug 19, 2007, 3:52:23 AM8/19/07
to
I know about Mathematica, Macsyma, Wikipedia (and Google too btw).

I have a very specific question: How can I embed Maxima's functions in
CL code? Just it.
Thank you.

Martin Rubey

unread,
Aug 19, 2007, 10:50:08 AM8/19/07
to
Dear Yigal,

I think the easiest way to do it is to start maxima, and then use the
underlying lisp to do your stuff. I did that some time ago to write a (very
buggy and very small) graph theory package in common lisp, usable from maxima.

As far as I know, you can then save the lisp image, that then bundles all the
stuff together.

Since I do not use maxima anymore, here is how to do it in axiom, which is also
written in common lisp:

-------------------------------------------------------------------------------
rubey@aquin:~$ axiom
GCL (GNU Common Lisp) 2.6.8 CLtL1 Mar 1 2007 16:42:04
Source License: LGPL(gcl,gmp), GPL(unexec,bfd,xgcl)
Binary License: GPL due to GPL'ed components: (READLINE BFD UNEXEC)
Modifications of this banner must retain notice of a compatible license
Dedicated to the memory of W. Schelter

Use (help) to get some basic information on how to use GCL.
Temporary directory for compiler files set to /tmp/
AXIOM Computer Algebra System
Version: Axiom build-improvements branch 2006-11-26
Timestamp: Wednesday March 14, 2007 at 02:25:47
-----------------------------------------------------------------------------
Issue )copyright to view copyright notices.
Issue )summary for a summary of useful system commands.
Issue )quit to leave AXIOM and return to shell.
-----------------------------------------------------------------------------

(HyperDoc) Cannot connect to the X11 server!
(1) ->
(1) -> )lisp (defun hi () (format t "hi"))

Value = HI
(1) -> HI()$Lisp
hi
(1) ()
Type: SExpression
(2) -> )fin

BOOT>(defun ho () (format t "ho"))

HO

BOOT>(ho)
ho
NIL

BOOT>(hi)
hi
NIL

BOOT>(spad)

(2) -> 2+2

(2) 4
Type: PositiveInteger

-------------------------------------------------------------------------------
of course, (load "filename") also works.

In some ways, axiom is superiour to maxima, in others it is a little behind,
however. It really depends what you want to do.

To get axiom, google for "mathaction". There are meanwhile several (entirely
compatible) versions of axiom around, it depends a bit on what you need.
Mathematically, Waldek Hebisch' version is most advanced, its the version I
use.

To get help on maxima I suppose it is better to ask on the maxima list.

Hope this helps,

Martin

Robert Dodier

unread,
Aug 19, 2007, 1:40:21 PM8/19/07
to
Yigal wrote:

Yigal, I think a useful approach here is to create a Lisp
binary image which contains your function or functions to
run the web stuff plus all of Maxima. That is easy to do:
launch Maxima, load your Lisp and/or Maxima functions,
and save the current Lisp state. Then you can launch Clisp
and tell it to run the saved image. This method works
with other Lisp implementations as well.

e.g. Here is my replacement for CL-USER::RUN. You will want
to write a function to read and write a socket, I guess.

$ cat /tmp/foo-run.lisp
(defun cl-user::run ()
(in-package :maxima)
(format t "HELLO FROM REPLACEMENT CL-USER::RUN~%")
(let (($display2d nil))
(displa (mfuncall '$foo 123 '$abc)))
(bye))

Here is a Maxima function called from CL-USER::RUN.

$ cat /tmp/foo-function.mac
foo (x, y) := (x - y)^(y - x);

Now I'll create the saved image. I'm running an already-built
Maxima here; it is not necessary to rebuild Maxima to
incorporate your new functions. I'll tell Clisp to call my
replacement CL-USER::RUN.

$ maxima -q -l clisp
load ("/tmp/foo-function.mac");
load ("/tmp/foo-run.lisp");
:lisp (ext:saveinitmem "/tmp/foo-maxima.mem" :init-function 'cl-
user::run)
quit ();

Now I'll run Clisp with the saved image.

$ clisp -q -M /tmp/foo-maxima.mem
HELLO FROM REPLACEMENT CL-USER::RUN
(123-abc)^(abc-123)


By the way, if you are working with web servers or whatever,
there are Lisp libraries for that. But first you need to get
comfortable with Lisp + Maxima. Hope this helps, & good luck.

Robert Dodier

rjf

unread,
Aug 19, 2007, 4:04:18 PM8/19/07
to
On Aug 18, 2:03 pm, Xah Lee <x...@xahlee.org> wrote:
> Not a answer to your question, but a piece of info i think you'll be
> interested:
>
> «Maxima does not include any of the numerous enhancements made to the
> commercial version of Macsyma between 1982-1999 (at least 50 man-years
> of work). Due to this, extensive effort may be required to port code
> from Macsyma to Maxima.»
>
> above is a quote from:http://en.wikipedia.org/wiki/Macsyma

Do you believe everything you read in wikipedia?
It turns out that Macsyma does not include any of the numerous
enhancements made to the open-source Maxima.

In spite of these differences, vast quantities of code can run
interchangeably on each platform since they are each implemented in
(more or less standard) ANSI Common Lisp.

> If you have about 3 thousand dollars to spare, you might want to buy
> Mathematica instead. Goto:http://wolfram.com/
>

I can't imagine why the original poster, who apparently wants to link
his CL code with Maxima, should consider this as an alternative.

> If you have no money to spare, it is my feeling that there are better
> free packages than maxima.

Do you often have such feelings?

<snip>

Yigal

unread,
Aug 20, 2007, 4:40:44 PM8/20/07
to
Thank you Robert for the detailed answer.

Finally I succeed to follow your instructions.
On my box Maxima was installed as debian package so it worked with GCL
only. When it came to this row:
>:lisp (ext:saveinitmem "/tmp/foo-maxima.mem" :init-function 'cl-user::run),
GCL said "no such package "ext"".
I installed Maxima from source with clisp and now it worked as you
wrote.

Apropos web server, I tested "lisp-cgi-utils" and mod_lisp for Apache,
it's work.

Thanks again,
Yigal

Xah Lee

unread,
Aug 28, 2007, 8:36:58 PM8/28/07
to
Dear Richard Fateman,

you (aka rjf) wrote:
«Do you believe everything you read in wikipedia?»

Encyclopedia, My Experiences
Xah Lee, 2007-08
http://xahlee.org/Periodic_dosage_dir/encyclopedia.html

The last paragraph of the first section, address your question in the
affirmative. I quote:

«I assert today, that wikipedia as a encyclopedia, with respect to
quality, all things considered, has surpassed all major general
encyclopedias as well as specialized encyclopedias in mathematics and
computer science. If this is not true for humanity at large, it is at
least for me. Specifically, if i can only choose to have one
encyclopedia now of existing encyclopedias as they are currently, i
choose Wikipedia.»

You, or the readers, might have general concern about the correctness
of wikipedia. Of which, is addresss at the second section of this
essay:

The Engine of Wikipedia (and On Wikipedia's Misinformation)
Xah Lee, 2007-08-28
http://xahlee.org/Periodic_dosage_dir/t2/wikipedia_engine.html

I quote the first paragraph:

«There is a common conception and worry, especially among
academecians, that Wikipedia is filled with misinformation. That, we
will often see among online forums, that these people outright
disclaim the reliability of wikipedia, in fact will disparage it out
of proportions especially when some error got broadcasted in the news
media.

...
»

Xah
x...@xahlee.org
http://xahlee.org/

0 new messages