Updating configure.ac with new version number
[maxima/cygwin.git] / interfaces / emacs / imaxima / rtest_imaxima.mac
blobafcd7ebe05aac5ccb1a2e81fdfafaaccceb680b0
1 /* -*- mode: maxima -*- */
2 /* Regression tests for imaxima.lisp */
3 /*
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/.
25 Usage:
26 batch("rtest_imaxima.mac",'test);
29 wximplicit_plot (x^2 = y^3 - 3*y + 1, [x, -4, 4], [y, -4, 4]);
30 'implicit_plot;
32 wxplot2d (sin(x), [x, -%pi, %pi])$
33 plot2d$
35 wxplot2d (sec(x), [x, -2, 2], [y, -20, 20])$
36 plot2d$
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"])$
42 plot2d$
44 wxplot2d (exp(3*s), [s, -2, 2], logy)$
45 plot2d$
47 block([F,G,H],
48   local(F,G,H),
49   F(x) := x^2,
50   G(x) := x^3,
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]))$
53 plot2d$
55 block([r],
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]]))$
58 plot2d$
60 wxplot2d([[parametric, cos(t), sin(t), [t,0,2*%pi]], -abs(x)],
61                    [x, -sqrt(2), sqrt(2)], same_xy)$
62 plot2d$
64 wxplot2d ([discrete, makelist ( random(10), 200)])$
65 plot2d$
67 wxplot2d ([discrete, makelist(i*%pi, i, 1, 5),
68   [0.6, 0.9, 0.2, 1.3, 1]])$
69 plot2d$
71 block([data],
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]))$
75 plot2d$
77 block([xy],
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)"]))$
85 plot2d$
87 wxplot3d (u^2 - v^2, [u, -2, 2], [v, -3, 3], [grid, 100, 100],
88   [mesh_lines_color,false])$
89 plot3d$
91 wxplot3d ( log ( x^2*y^2 ), [x, -2, 2], [y, -2, 2], [z, -8, 4],
92                    [palette, false], [color, magenta])$
93 plot3d$
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],
98                  [color_bar_tics, 4])$
99 plot3d$
102 wxmandelbrot ([iterations, 30], [x, -2, 1], [y, -1.2, 1.2],
103                       [grid,400,400])$
104 mandelbrot $
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])$
108 julia $
110 listp(wxdraw2d(color=red,  explicit(x^2,x,-1,1))) $
111 true $
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 ) ) )) $
114 true $
116 listp(wxdraw3d(axis_3d = false, explicit(sin(x^2+y^2),x,-2,2,y,-2,2) ))$
117 true $
119 listp(wxdraw3d(colorbox="Magnitude",enhanced3d=true,explicit(x^2+y^2,x,-1,1,y,-1,1)))$
120 true $
122 (load(drawdf), wxdrawdf(x+t,[t,x],[t,0,1],[x,0,1])) $
123 0 $
125 block([m], load(descriptive), m : read_matrix (file_search ("biomed.data")),
126   wxbarsplot(
127     col(m,2),
128     title        = "Ages",
129     xlabel       = "years",
130     box_width    = 1/2,
131     fill_density = 3/4))$
132 [gr2d(points,bars,label)] $
134 block([s2:read_matrix(file_search("wind.data"))],
135   wxboxplot(s2,
136     box_width  = 0.2,
137     title      = "Windspeed in knots",
138     xlabel     = "Stations",
139     color      = red,
140     line_width = 2))$
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)]$
145           
146 block([s1:read_list (file_search ("pidigits.data"))],
147   wxhistogram (
148     s1,
149     nclasses     = 8,
150     title        = "pi digits",
151     xlabel       = "digits",
152     ylabel       = "Absolute frequency",
153     fill_color   = grey,
154     fill_density = 0.6))$
155 [gr2d(bars)] $
157 block([s1 : read_list (file_search ("pidigits.data"))],
158   wxpiechart(
159     s1,
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,
164   ellipse,ellipse)]$
166 block([s2 : read_matrix (file_search ("wind.data"))],
167   wxscatterplot(
168     submatrix(s2, 1,2,3),
169     title      = "Data from stations #4 and #5",
170     point_type = diamant,
171     point_size = 2,
172     color      = blue))$
173 [gr2d(points)]$
175 block([l1: makelist(random(10),k,1,50),
176   l2: makelist(random(10),k,1,200)],
177   wxstarplot(
178     l1, l2,
179     stars_colors = [blue,red],
180     sample_keys = ["1st sample", "2nd sample"],
181     star_center = [1,2],
182     star_radius = 4,
183     proportional_axes = xy,
184     line_width = 2 )) $
185 [gr2d(points,points,points,points,points,points,points,points,points,
186   points,label,points,points)]$
189 /* end of rtest_imaxima.mac */