1 /* -*- mode: maxima -*- */
2 /* Regression tests for imaxima.lisp */
5 * Author: Leo Butler (leo.butler@umanitoba.ca)
6 * Credit: These tests are adapted from the Maxima manual
8 * This file is Maxima code (http://maxima.sourceforge.net/)
10 * It is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 3 of the License, or (at your
13 * option) any later version.
15 * This software is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
17 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
18 * License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this file. If not, see http://www.gnu.org/licenses/.
26 batch("rtest_imaxima.mac",'test);
29 wxplot2d (x^2 = y^3 - 3*y + 1, [x, -4, 4], [y, -4, 4]);
32 wxplot2d (sin(x), [x, -%pi, %pi])$
35 wxplot2d (sec(x), [x, -2, 2], [y, -20, 20])$
38 wxplot2d ( x^2 - 1, [x, -3, 3], [box, false], grid2d,
39 [yx_ratio, 1], [axes, solid], [xtics, -2, 4, 2],
40 [ytics, 2, 2, 6], [label, ["x", 2.9, -0.3],
41 ["x^2-1", 0.1, 8]], [title, "A parabola"])$
44 wxplot2d (exp(3*s), [s, -2, 2], logy)$
51 H(x) := if x < 0 then x^4 - 1 else 1 - x^5,
52 wxplot2d ([F, G, H], [u, -1, 1], [y, -1.5, 1.5]))$
56 r: (exp(cos(t))-2*cos(4*t)-sin(t/12)^5),
57 wxplot2d([parametric, r*sin(t), r*cos(t), [t, -8*%pi, 8*%pi]]))$
60 wxplot2d([[parametric, cos(t), sin(t), [t,0,2*%pi]], -abs(x)],
61 [x, -sqrt(2), sqrt(2)], same_xy)$
64 wxplot2d ([discrete, makelist ( random(10), 200)])$
67 wxplot2d ([discrete, makelist(i*%pi, i, 1, 5),
68 [0.6, 0.9, 0.2, 1.3, 1]])$
72 data : genmatrix(lambda([x,i], x^i),10,3),
73 wxplot2d ([discrete, transpose(data)[2], transpose(data)[3]],
74 [style,points], [point_type,diamond], [color,red]))$
78 xy: [[10, .6], [20, .9], [30, 1.1], [40, 1.3], [50, 1.4]],
79 wxplot2d([[discrete, xy], 2*%pi*sqrt(l/980)], [l,0,50],
80 [style, points, lines], [color, red, blue],
81 [point_type, asterisk],
82 [legend, "experiment", "theory"],
83 [xlabel, "pendulum's length (cm)"],
84 [ylabel, "period (s)"]))$
87 wxplot3d (u^2 - v^2, [u, -2, 2], [v, -3, 3], [grid, 100, 100],
88 [mesh_lines_color,false])$
91 wxplot3d ( log ( x^2*y^2 ), [x, -2, 2], [y, -2, 2], [z, -8, 4],
92 [palette, false], [color, magenta])$
95 wxplot3d (log (x^2*y^2), [x, -2, 2], [y, -2, 2],[grid, 29, 29],
96 [palette, [gradient, red, orange, yellow, green]],
97 color_bar, [xtics, 1], [ytics, 1], [ztics, 4],
102 wxmandelbrot ([iterations, 30], [x, -2, 1], [y, -1.2, 1.2],
106 wxjulia (-0.55, 0.6, [iterations, 36], [x, -0.3, 0.2],
107 [y, 0.3, 0.9], [grid, 400, 400], [color_bar_tics, 0, 6, 36])$
110 listp(wxdraw2d(color=red, explicit(x^2,x,-1,1))) $
113 listp(wxdraw( gr2d( key="sin (x)",grid=[2,2], explicit( sin(x), x,0,2*%pi ) ), gr2d( key="cos (x)",grid=[2,2], explicit( cos(x), x,0,2*%pi ) ) )) $
116 listp(wxdraw3d(axis_3d = false, explicit(sin(x^2+y^2),x,-2,2,y,-2,2) ))$
119 listp(wxdraw3d(colorbox="Magnitude",enhanced3d=true,explicit(x^2+y^2,x,-1,1,y,-1,1)))$
122 (load(drawdf), wxdrawdf(x+t,[t,x],[t,0,1],[x,0,1])) $
125 block([m], load(descriptive), m : read_matrix (file_search ("biomed.data")),
131 fill_density = 3/4))$
132 [gr2d(?points,?bars,?label)] $
134 block([s2:read_matrix(file_search("wind.data"))],
137 title = "Windspeed in knots",
141 [gr2d(?points,?points,?points,?points,?points,?points,?points,?points,?points,
142 ?points,?points,?points,?points,?points,?points,?points,?points,?points,
143 ?points,?points,?points,?points,?points,?points,?points,?points,?points,
144 ?points,?points,?points)]$
146 block([s1:read_list (file_search ("pidigits.data"))],
152 ylabel = "Absolute frequency",
154 fill_density = 0.6))$
157 block([s1 : read_list (file_search ("pidigits.data"))],
160 xrange = [-1.1, 1.3],
161 yrange = [-1.1, 1.1],
162 title = "Digit frequencies in pi"))$
163 [gr2d(?ellipse,?ellipse,?ellipse,?ellipse,?ellipse,?ellipse,?ellipse,?ellipse,
166 block([s2 : read_matrix (file_search ("wind.data"))],
168 submatrix(s2, 1,2,3),
169 title = "Data from stations #4 and #5",
170 point_type = diamant,
175 block([l1: makelist(random(10),k,1,50),
176 l2: makelist(random(10),k,1,200)],
179 stars_colors = [blue,red],
180 sample_keys = ["1st sample", "2nd sample"],
183 proportional_axes = xy,
185 [gr2d(?points,?points,?points,?points,?points,?points,?points,?points,?points,
186 ?points,?label,?points,?points)]$
189 /* end of rtest_imaxima.mac */