1 #+TITLE:Org-babel-mathomatic
3 #+EMAIL: papoanaya[at]hotmail[dot]com
4 #+LINK_UP: ../languages.html
5 #+LINK_HOME: http://orgmode.org/worg/
6 #+OPTIONS: H:3 num:nil toc:2 \n:nil @:t ::t |:t ^:{} -:t f:t *:t TeX:t LaTeX:t skip:nil d:(HIDE) tags:not-in-toc
7 #+STARTUP: align fold nodlcheck hidestars oddeven lognotestate hideblocks
8 #+SEQ_TODO: TODO(t) INPROGRESS(i) WAITING(w@) | DONE(d) CANCELED(c@)
9 #+TAGS: Write(w) Update(u) Fix(f) Check(c) noexport(n)
11 #+STYLE: <style type="text/css">#outline-container-introduction{ clear:both; }</style>
14 <div id="subtitle" style="float: center; text-align: center;">
17 <a href="http://www.mathomatic.org/">Mathomatic</a>
23 =org-babel-mathomatic= allows Mathomatic statements to be executed directly
24 within embedded code blocks in Org-mode documents. These code blocks and
25 its results can be included as the document is exported to documentation
28 The following provides instructions and some examples of Mathomatic
29 usage. Since babel is simply allowing native code to run inside of
30 Org-mode, all Mathomatic documentation is applicable and valid.
31 * Requirements and Setup
32 Mathomatic is a small Computer Algebra System (CAS) written in C. The
33 program is quite portable and useful, and quite suitable for small
36 To get Mathomatic up and running, you need the =mathomatic= program
37 installed in your system. You can obtain and compile =mathomatic= from [[
40 To enable support for Mathomatic, it must be enabled as part of your
41 initialization script. For example:
44 ;; set up babel support
45 (require 'org-install)
46 (require 'ob-mathomatic)
47 ;; add additional languages with (require 'ob-language)
50 Babel block headers are used to pass various arguments to control the
51 results of the executed code. The complete list of header arguments
52 is covered in the Org-mode manual; for now, some options frequently used for
54 - =:exports {code, results, both, none}=
55 - When the code is run and the document exported (e.g. to HTML or
56 \LaTeX PDF), what should appear? Just the code block itself? Only
57 the produced output (in this case a plot of some sort)? Both the
58 code and the accompanying results? Or nothing?
59 - =:results {value, output}=
60 - Controls the results of the output. Only two alternatives are
62 - /value/ :: Returns the value of the last =return= statement in the
63 code. and places in =#+RESULTS:=.
64 - /output/ :: Returns the value of the =puts= or =write= statement and
65 places those in =#+RESULTS:=.
66 - =:file foo.{png,eps,etc.}=
67 - Mathomatic uses gnuplot as its plotting engine. Using the =:file=
68 option specifies where the resulting output should be put. If
69 no option is given, a Gnuplot window will open with the
71 *NOTE:* Certain plot options may /not/ output
72 properly to Gnuplot directly and thus /must/ have the =:file
73 filename= option in the header. If the error "Code block produced
74 no output" recurs, try outputting to a file.
77 Mathomatic is a comprehensive CAS that includes many options and
79 Describing these are beyond the scope of this
80 manual. However, the examples provided in this guide should
81 be easy enough to follow to
82 those that have used similar programs in the past.
83 interested in learning about Mathomatic, please refer to the official documents
84 or books on the subject. [fn:1]
86 Through this overview, Any of the commands
87 typed in =code= font below should be assumed to reside in a babel
88 code block (between =#+begin_src mathomatic= and =#+end_src=).
90 To run a Mathomatic block and produce a result from the babel block
91 move the cursor anywhere in the code
92 block and press =C-c C-c= (Ctrl+C followed by Ctrl+C) and type "yes"
93 in the minibuffer when asked about executing the code.
96 An example of a Mathomatic block in Org-babel is as follows:
99 #+begin_src mathomatic :results output
107 : Eliminating variable x using solved equation #1...
111 Using =:results output= describes all the steps executed in the
112 code. using =:results value= will write the results in a table. For
116 #+begin_src mathomatic :results value
124 | #1: | x | = | 0 | | | |
125 | #2: | x | + | 2 | | | |
126 | Eliminating | variable | x | using | solved | equation | #1... |
127 | #2: | 2 | | | | | |
128 | #3: | ans | = | x | | | |
133 Graphical output is supported in Mathomatic which can be stored using
134 the =:file= header option. The following output formats are supported
135 within Mathomatic: [fn:2]
136 - Encapsulated Postscript =.eps=
137 - Portable Network Graphics =.png=
142 #+begin_src mathomatic :results graphics :file sine.png
150 In order to get graphical output during evaluation use the Mathomatic =plot=
151 command within Mathomatic. The file suffix will configure Gnuplot to
152 write the right file format.
155 The Babel Mathomatic plugin supports the use of named procedures and calls
156 operations. The use of these are detailed in the /Org Manual/. This
157 manual will describe how they are used within the context of a Mathomatic
160 A variable can be passed to a Mathomatic script which can be used to call the
161 aforementioned program later on in your org document. The following
162 example is a program that evaluates X+2.
165 #+name: mathotest(x=0)
166 #+begin_src mathomatic :results output
174 : Eliminating variable x using solved equation #1...
178 Calling the named script with a different value will result in a
179 different execution. For example:
182 #+call: mathotest(x=30)
184 #+RESULTS: mathotest(x=30)
187 : Eliminating variable x using solved equation #1...
191 Note that table processing is not supported. This is because Mathomatic
192 does not have support for matrixes. However there are
193 plans to provide this in the future through the use of simulated
194 arrays. A simulated array is a syntactic sugar in Mathomatic to enclose
195 indexes in square brackets (/[]/).
199 [fn:1] Mathomatic manual downloads and further information can be obtained
200 from: [[http://www.mathomatic.org/math/doc/index.html]]
202 [fn:2] Mathomatic uses Gnuplot as its plot engine. All plot modes are
203 supported in Mathomatic. However, for convenience, only these are
204 supported in the =:file= option.