Jump to content

User talk:Mafs/Computer algebra

Add topic
From Meta, a Wikimedia project coordination wiki
Latest comment: 18 years ago by Mafs in topic kudos and help

ultra cool ! --Wikinaut (mail) 23:06, 3 February 2006 (UTC)Reply

any wikis using the algebra plugin?

[edit]

Hello Mafs, this is really interesting. Are there any wikis using the algebra plugin? If so I'll add them to the list of related projects on the Maxima web site.

For the time being it is just my wiki on localhost.

Where is the rendering handled -- is Maxima's tex function used to create TeX output which is then rendered, or are Maxima expressions parsed by something else and then rendered? (Is TeX the display format?) Thanks for any info.

The script roughly works as follows
  1. The extension takes all the lines terminating with a semicolon and creates a sting. Placeholders are insterted into the original text.
  2. The semicolons at the end of a line are replaced by "; tex(%);"
  3. The string containing the maxima expressions is passed to maxima.
  4. From the answer of maxima the script extracts the tex expressions which are reinserted into the original text. Additionally <math> tags are added.
  5. Finally, the modified text is passed to the wiki parser which renders the tex expressions.

By the way I am working on the Maxima project so if you run into problems with Maxima maybe I could help. Best, Rdodier 17:21, 8 February 2006 (UTC)Reply

Robert, thanks for your interest. Two questions: As a simple measure for security the script disregards any expression containing the words "load", "save", "plot" and "lisp". Which maxima commands invoke file handling and script execution? Are there other commands which should not be executed when called by a web server?

Greetings Markus ( Mafs 21:45, 9 February 2006 (UTC) )Reply

Hi Markus, thanks for the info. Maxima functions which might execute file i/o include batch, tex, stringout, translation/compilation functions (including compile, compile_file, translate_file, maybe some others I've forgotten), in addition to load, save, plot2d/plot3d. (There are probably other functions as well.) Aside from file i/o, it might be desirable to put limits on cpu time and memory use, since even simple things like expand ((a + b)^1000000); could take lots of time and space .... I guess the general solution that would suggest is to arrange for the web server to run the Maxima module in a read-only environment with time and memory limits; I think that would be a lot more workable than trying to anticipate all possible sources of trouble. [2] I don't know much about web servers so I don't know if that's practical.
There are some other issues that we might address. One is that Maxima sometimes wants to read a response from the user. This can arise in places you wouldn't expect it. For example if you enter integrate (exp (-a*x), x, 0, inf); then Maxima asks the user if a is positive, negative, or zero. If there is no user there to enter something, Maxima might wait forever. The general problem is that at present it cannot be guaranteed that Maxima operates in a strict batch mode with no input from the user. This is a known problem and I am working on it. [1]
Another question for you -- is Maxima executed anew for every <Algebra> block, or can some kind of "warm start" be arranged? [3]
Anyway I hope these comments are helpful to you. Keep up the good work! Rdodier 02:01, 10 February 2006 (UTC)Reply

update

[edit]

Hi Robert, I could address at least some of your suggestions.

[1] I added a basic process control, such that the script terminates the maxima process after some seconds and the question is displayed on the wiki page. However, a real batch mode would be fine.

[2] Agreed. Unfortunately, I am also not that competent in this area.

[3] Yes, due to the extension handling, maxima is executed anew for every <Algebra> block. However, this happens only when the wiki page is saved. In case the page is just displayed the already rendered page is feteched from an internal cache.

Mafs 18:39, 14 February 2006 (UTC)Reply


kudos and help

[edit]

This is a fantastic plugin that will save me a lot of time copying derivations into <math>...</math> blocks!

However, I'm having some trouble getting it to work with the demo example you provide. When I save the page, I just get the "Maximas error message or question" message with empty text in the message block. When I comment out line 198 (where the intermediate files are generated) and view the files, it looks like maxima is running fine:

$ ls /tmp/maxima
total 8
-rw-r--r--  1 wwwrun www  85 2006-03-16 07:08 maxima_30a065fc23b0457aa567b008f5fd3c09.in
-rw-r--r--  1 wwwrun www 738 2006-03-16 07:08 maxima_30a065fc23b0457aa567b008f5fd3c09.out
-rw-r--r--  1 wwwrun www   0 2006-03-16 07:08 maxima_30a065fc23b0457aa567b008f5fd3c09.pid
$ cat maxima_30a065fc23b0457aa567b008f5fd3c09.in
 eq1: x^2 + 3*x*y + y^2 = 0; tex(%); maxima_session_30a065fc23b0457aa567b008f5fd3c09;
$ cat maxima_30a065fc23b0457aa567b008f5fd3c09.out
Maxima 5.9.2.99rc3 http://maxima.sourceforge.net
Using Lisp CLISP 2.30 (released 2002-09-15)
Distributed under the GNU Public License. See the file COPYING.
Dedicated to the memory of William Schelter.
This is a development version of Maxima. The function bug_report()
provides bug reporting information.
(%i1)    batch(/tmp/maxima/maxima_30a065fc23b0457aa567b008f5fd3c09.in)

batching /tmp/maxima/maxima_30a065fc23b0457aa567b008f5fd3c09.in
                                  2            2
(%i2)                      eq1 : y  + 3 x y + x  = 0
                               2            2
(%o2)                         y  + 3 x y + x  = 0
(%i3)                               tex(%)
$$y^2+3\,x\,y+x^2=0$$
(%o3)                                false
(%i4)           maxima_session_30a065fc23b0457aa567b008f5fd3c09
(%o4)           maxima_session_30a065fc23b0457aa567b008f5fd3c09

I'm running on SuSE Linux Enterprise 9, apache2, MediaWiki 1.5rc4

Any ideas?

--Metasim 13:21, 16 March 2006 (UTC)Reply

Answer:
Hi, obviously maxima runs pretty well, but I guess the php function cannot access the created file.
Which php version do you use? There might be a setting in php.in dealing with this issue.
I would suggest that you create a tmp directory which must be accessible by your web server within your document root and that you set the variable $temp_path = "/tmp/maxima/"; accordingly.
I hope this helps Mafs 20:29, 17 March 2006 (UTC)Reply


Another Solution:
I has the same problem with PHP-5.1.0. But I remove all the handle for "pid"

part. And it works. Actually, I wrote a small test PHP code for "jobs -l >..." and the message can not be retrieved.

Problem Using both Math and Algebra Plugins in the same page

[edit]

I have installed your very nice Maxima plugin at our site. I have found a problem in using both <math> and <algebra> on the same page. If we include require_once("extensions/Maxima.php"); on LocalSettings.php the <math> on the same page becomes like the example.

Is <algebra> somehow replacing all <math> tags in the page?

Calling the math parser in the same page as maxima

[edit]

There is appearently a problem in the maxima parser introducing the <math> and calling the math parser again.