emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
blob c7847d9594b481d8b062f237dcbc2feb849f3d4c 3306 bytes (raw)
name: testing/examples/ob-maxima-test.org 	 # note: path name is non-authoritative(*)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
 
#+Title: a collection of examples for ob-maxima tests
#+OPTIONS: ^:nil

* Simple tests
  :PROPERTIES:
  :ID:       b5842ed4-8e8b-4b18-a1c9-cef006b6a6c8
  :END:
#+begin_src maxima :var s=4 :results silent
print(s);
#+end_src

Pass a string
#+begin_src maxima :var fun="sin(x)" :var q=2 :results silent
print(diff(fun, x, q))$
#+end_src

* Graphic output
Graphic output
#+begin_src maxima  :var a=0.5 :results graphics :file maxima-test-sin.png
plot2d(sin(a*x), [x, 0, 2*%pi])$
#+end_src

#+begin_src maxima  :results graphics :file maxima-test-3d.png
plot3d (2^(-u^2 + v^2), [u, -3, 3], [v, -2, 2])$
#+end_src

** Use the ~draw~ package
This test exercises the ~:graphics-pkg~ header argument.
#+name: ob-maxima/draw
#+begin_src maxima  :var a=0.5 :results graphics file :file ./maxima-test-cos.png :graphics-pkg draw
draw2d(explicit(cos(a*x), x, -%pi, %pi))$
#+end_src

* Output to a file
Output to a file
#+begin_src maxima :file maxima-test-ouput.out
for i:1 thru 10 do print(i)$
#+end_src
* List input
  :PROPERTIES:
  :ID:       b5561c6a-73cd-453a-ba5e-62ad84844de6
  :END:
Simple list as an input
#+begin_src maxima :var a=(list 1 2 3) :results silent :results verbatim
print(a)$
#+end_src

#+begin_src maxima :var a=(list 1 (list 1 2) 3) :results silent :results verbatim
print(a+1);
#+end_src

* Table input
  :PROPERTIES:
  :ID:       400ee228-6b12-44fd-8097-7986f0f0db43
  :END:
#+name: test_tbl_col
| 1.0 |
| 2.0 |

#+name: test_tbl_row
| 1.0 | 2.0 |

#+begin_src maxima :var s=test_tbl_col :results silent :results verbatim
print(s+1.0);
#+end_src

#+begin_src maxima :var s=test_tbl_row :results silent :results verbatim
print(s+1.0);
#+end_src

Matrix
#+name: test_tbl_mtr
| 1.0 | 1.0 |

#+begin_src maxima :var s=test_tbl_mtr :results silent :results verbatim
ms: apply(matrix, s);
print(ms);
#+end_src

* Construct a table from the output
  :PROPERTIES:
  :ID:       cc158527-b867-4b1d-8ae0-b8c713a90fd7
  :END:
#+begin_src maxima :results silent
with_stdout("/dev/null", load(numericalio))$
m: genmatrix (lambda([i,j], i+j-1), 3, 3)$
write_data(m, "/dev/stdout")$
#+end_src

* LaTeX output
#+begin_src maxima  :exports both :results latex :results verbatim
assume(x>0);
tex(ratsimp(diff(%e^(a*x), x)));
#+end_src

#+results:
#+BEGIN_LaTeX
$$a\,e^{a\,x}$$
#+END_LaTeX

* Batch
:PROPERTIES:
:header-args:maxima: :exports both :results verbatim :batch batch
:END:

Exercise the ~:batch~ header argument. These tests are also defined in
~testing/lisp/test-ob-maxima.el~. The test name is name of the ~ert~
test.

#+name: ob-maxima/batch+verbatim
#+begin_src maxima
(assume(z>0),
integrate(exp(-t)*t^z, t, 0, inf));
#+end_src

#+name: ob-maxima/batch+verbatim+quiet
#+begin_src maxima :cmdline --quiet
(assume(z>0),
integrate(exp(-t)*t^z, t, 0, inf));
#+end_src

#+name: ob-maxima/batch+verbatim+:lisp
#+begin_src maxima :cmdline --quiet
:lisp #$(assume(z>0),integrate(exp(-t)*t^z, t, 0, inf));#$
#+end_src

#+name: ob-maxima/batch+verbatim+empty-string
#+begin_src maxima :cmdline --quiet
"";
#+end_src

#+name: ob-maxima/batch+verbatim+whitespace-string
#+begin_src maxima :cmdline --quiet
" ";
#+end_src

#+name: ob-maxima/batch+verbatim+syntax-error
#+begin_src maxima :cmdline --quiet
;
#+end_src

#+name: ob-maxima/batch+verbatim+eof-error
#+begin_src maxima :cmdline --quiet
x:
#+end_src

debug log:

solving c7847d959 ...
found c7847d959 in https://git.savannah.gnu.org/cgit/emacs/org-mode.git

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).