1 #+TITLE: Org-babel-mathomatic
3 #+EMAIL: papoanaya[at]hotmail[dot]com
4 #+HTML_LINK_UP: index.html
5 #+HTML_LINK_HOME: https://orgmode.org/worg/
6 #+OPTIONS: H:3 num:nil toc:2 \n:nil ::t |:t ^:{} -:t f:t *:t tex:t 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)
13 <div id="subtitle" style="float: center; text-align: center;">
16 <a href="https://github.com/mfillpot/mathomatic/">Mathomatic</a>
21 =org-babel-mathomatic= allows Mathomatic statements to be executed directly
22 within embedded code blocks in Org-mode documents. These code blocks and
23 its results can be included as the document is exported to documentation
26 The following provides instructions and some examples of Mathomatic
27 usage. Since babel is simply allowing native code to run inside of
28 Org-mode, all Mathomatic documentation is applicable and valid.
29 * Requirements and Setup
30 Mathomatic is a small Computer Algebra System (CAS) written in C. The
31 program is quite portable and useful, and quite suitable for small
34 To get Mathomatic up and running, you need the =mathomatic= program
35 installed in your system. You can obtain and compile =mathomatic= from
36 [[https://github.com/mfillpot/mathomatic][GitHub]], or perhaps install it with a package manager.
38 To enable support for Mathomatic, it must be enabled as part of your
39 initialization script. For example:
41 #+begin_src emacs-lisp
42 ;; set up babel support
44 (require 'ob-mathomatic)
45 ;; add additional languages with (require 'ob-language)
48 Babel block headers are used to pass various arguments to control the
49 results of the executed code. The complete list of header arguments
50 is covered in the Org-mode manual; for now, some options frequently used for
52 - =:exports {code, results, both, none}=
53 - When the code is run and the document exported (e.g. to HTML or
54 \LaTeX PDF), what should appear? Just the code block itself? Only
55 the produced output (in this case a plot of some sort)? Both the
56 code and the accompanying results? Or nothing?
57 - =:results {value, output}=
58 - Controls the results of the output. Only two alternatives are
60 - /value/ :: Returns the value of the last =return= statement in the
61 code. and places in =#+RESULTS:=.
62 - /output/ :: Returns the value of the =puts= or =write= statement and
63 places those in =#+RESULTS:=.
64 - =:file foo.{png,eps,etc.}=
65 - Mathomatic uses gnuplot as its plotting engine. Using the =:file=
66 option specifies where the resulting output should be put. If
67 no option is given, a Gnuplot window will open with the
69 *NOTE:* Certain plot options may /not/ output
70 properly to Gnuplot directly and thus /must/ have the =:file
71 filename= option in the header. If the error "Code block produced
72 no output" recurs, try outputting to a file.
75 Mathomatic is a comprehensive CAS that includes many options and
77 Describing these are beyond the scope of this
78 manual. However, the examples provided in this guide should
79 be easy enough to follow to
80 those that have used similar programs in the past.
81 interested in learning about Mathomatic, please refer to the official documents
83 Through this overview, Any of the commands
84 typed in =code= font below should be assumed to reside in a babel
85 code block (between =#+begin_src mathomatic= and =#+end_src=).
87 To run a Mathomatic block and produce a result from the babel block
88 move the cursor anywhere in the code
89 block and press =C-c C-c= (Ctrl+C followed by Ctrl+C) and type "yes"
90 in the minibuffer when asked about executing the code.
93 An example of a Mathomatic block in Org-babel is as follows:
96 #+begin_src mathomatic :results output
104 : Eliminating variable x using solved equation #1...
108 Using =:results output= describes all the steps executed in the
109 code. using =:results value= will write the results in a table. For
113 #+begin_src mathomatic :results value
121 | #1: | x | = | 0 | | | |
122 | #2: | x | + | 2 | | | |
123 | Eliminating | variable | x | using | solved | equation | #1... |
124 | #2: | 2 | | | | | |
125 | #3: | ans | = | x | | | |
130 Graphical output is supported in Mathomatic which can be stored using
131 the =:file= header option. The following output formats are supported
132 within Mathomatic: [fn:1]
133 - Encapsulated Postscript =.eps=
134 - Portable Network Graphics =.png=
139 #+begin_src mathomatic :results graphics :file sine.png
147 In order to get graphical output during evaluation use the Mathomatic =plot=
148 command within Mathomatic. The file suffix will configure Gnuplot to
149 write the right file format.
152 The Babel Mathomatic plugin supports the use of named procedures and calls
153 operations. The use of these are detailed in the /Org Manual/. This
154 manual will describe how they are used within the context of a Mathomatic
157 A variable can be passed to a Mathomatic script which can be used to call the
158 aforementioned program later on in your org document. The following
159 example is a program that evaluates X+2.
162 #+name: mathotest(x=0)
163 #+begin_src mathomatic :results output
171 : Eliminating variable x using solved equation #1...
175 Calling the named script with a different value will result in a
176 different execution. For example:
179 #+call: mathotest(x=30)
181 #+RESULTS: mathotest(x=30)
184 : Eliminating variable x using solved equation #1...
188 Note that table processing is not supported. This is because Mathomatic
189 does not have support for matrixes. However there are
190 plans to provide this in the future through the use of simulated
191 arrays. A simulated array is a syntactic sugar in Mathomatic to enclose
192 indexes in square brackets (/[]/).
196 [fn:1] Mathomatic uses Gnuplot as its plot engine. All plot modes are
197 supported in Mathomatic. However, for convenience, only these are
198 supported in the =:file= option.