2011-10-01 21:37:14 -04:00
|
|
|
#+Title: a collection of examples for ob-maxima tests
|
|
|
|
#+OPTIONS: ^:nil
|
|
|
|
|
|
|
|
* Simple tests
|
|
|
|
:PROPERTIES:
|
|
|
|
:ID: b5842ed4-8e8b-4b18-a1c9-cef006b6a6c8
|
|
|
|
:END:
|
2011-11-08 15:36:25 -05:00
|
|
|
#+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
|
2011-10-01 21:37:14 -04:00
|
|
|
print(diff(fun, x, q))$
|
2011-11-08 15:36:25 -05:00
|
|
|
#+end_src
|
|
|
|
|
2011-10-01 21:37:14 -04:00
|
|
|
* Graphic output
|
2011-11-08 15:36:25 -05:00
|
|
|
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
|
2011-10-01 21:37:14 -04:00
|
|
|
* Output to a file
|
2011-11-08 15:36:25 -05:00
|
|
|
Output to a file
|
|
|
|
#+begin_src maxima :file maxima-test-ouput.out
|
|
|
|
for i:1 thru 10 do print(i)$
|
|
|
|
#+end_src
|
2011-10-01 21:37:14 -04:00
|
|
|
* 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)$
|
2011-11-08 15:36:25 -05:00
|
|
|
#+end_src
|
|
|
|
|
2011-10-01 21:37:14 -04:00
|
|
|
#+begin_src maxima :var a=(list 1 (list 1 2) 3) :results silent :results verbatim
|
2011-11-08 15:36:25 -05:00
|
|
|
print(a+1);
|
|
|
|
#+end_src
|
|
|
|
|
2011-10-01 21:37:14 -04:00
|
|
|
* Table input
|
|
|
|
:PROPERTIES:
|
|
|
|
:ID: 400ee228-6b12-44fd-8097-7986f0f0db43
|
|
|
|
:END:
|
2016-02-03 18:06:08 -05:00
|
|
|
#+name: test_tbl_col
|
2011-11-08 15:36:25 -05:00
|
|
|
| 1.0 |
|
|
|
|
| 2.0 |
|
|
|
|
|
2016-02-03 18:06:08 -05:00
|
|
|
#+name: test_tbl_row
|
2011-11-08 15:36:25 -05:00
|
|
|
| 1.0 | 2.0 |
|
|
|
|
|
2011-10-01 21:37:14 -04:00
|
|
|
#+begin_src maxima :var s=test_tbl_col :results silent :results verbatim
|
2011-11-08 15:36:25 -05:00
|
|
|
print(s+1.0);
|
|
|
|
#+end_src
|
|
|
|
|
2011-10-01 21:37:14 -04:00
|
|
|
#+begin_src maxima :var s=test_tbl_row :results silent :results verbatim
|
2011-11-08 15:36:25 -05:00
|
|
|
print(s+1.0);
|
|
|
|
#+end_src
|
|
|
|
|
|
|
|
Matrix
|
2016-02-03 18:06:08 -05:00
|
|
|
#+name: test_tbl_mtr
|
2011-11-08 15:36:25 -05:00
|
|
|
| 1.0 | 1.0 |
|
|
|
|
|
2011-10-01 21:37:14 -04:00
|
|
|
#+begin_src maxima :var s=test_tbl_mtr :results silent :results verbatim
|
2011-11-08 15:36:25 -05:00
|
|
|
ms: apply(matrix, s);
|
2011-10-01 21:37:14 -04:00
|
|
|
print(ms);
|
2011-11-08 15:36:25 -05:00
|
|
|
#+end_src
|
|
|
|
|
2011-10-01 21:37:14 -04:00
|
|
|
* Construct a table from the output
|
|
|
|
:PROPERTIES:
|
|
|
|
:ID: cc158527-b867-4b1d-8ae0-b8c713a90fd7
|
|
|
|
:END:
|
2016-08-20 13:33:16 -04:00
|
|
|
#+begin_src maxima :results silent
|
2011-10-01 21:37:14 -04:00
|
|
|
m: genmatrix (lambda([i,j], i+j-1), 3, 3)$
|
|
|
|
write_data(m, "/dev/stdout")$
|
2011-11-08 15:36:25 -05:00
|
|
|
#+end_src
|
2011-10-01 21:37:14 -04:00
|
|
|
|
|
|
|
* 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
|