2 ((face (maxima-eval 2416 2436 3485 3523 3902 4053 4258 4408 4509 4510 4964 5068 5090 5318 5332 5460 5504 5564 6064 6167 6735 7191 7604 7760 8363 8414) (book-shell-eval 2107 2126 2170 2185) (dfplot-eval 1761 1789 1959 2005) (book-result 1274 1275 1447 1626 3013 3177 6534 6561 7393 7411 8057 8118 8541 8600) (maxima-eval-insert 1257 1260 1415 1437 2987 2999 6474 6522 7340 7384 7972 8047 8475 8530) (book-elisp-eval 536 563) (bold 26 39 5567 5579)) (book-command-arg ("xv /d19/staff/wfs/izic-maxima/moebius.gif" 2170 2185) ("xv /d19/staff/wfs/izic-maxima/klein.gif" 2107 2126) ((write-file "~/408c-1.bk") 536 563)))
\f
5 The highlighted regions of this tutorial are sensitive to clicking
6 with the mouse with the right button. Use the arrow keys to move
7 up or down in the tutorial.
9 For this assignment you should find the following:
11 1) integral of sec(x)^5
12 2) upper sum for x^3+2*x on the interval [2,4] using
13 partition [2,2.3,2.5,2.8,3.2,4].
15 [Notation: x^2 means "x to the power 2" and a*b means "a times b"]
17 Please type your name on the next line:
22 Once you are finished click here: <write file to ~/408c-1.bk>
23 to record what you have done.
25 You should modify the integrate command below, and the upper_sum
26 command to do what you are asked to do. Note for the upper_sum
27 you must click on the definitions preceding it, so the system
28 will have them available. Otherwise you will not get an answer.
30 This mode allows expressions in the editor to be evaluated in a
31 symbolic algebra system such as Maxima, or to otherwise cause an
32 action. You may cause the action by moving to a highlighted region
33 and either clicking with the right button, or if you prefer
34 you may type the two character sequence `Ctrl-c e'. All special
35 key sequences in this mode begin with Control C.
37 For example if you do this for 2+3 then the box 5 will have
38 its value set to 5. If you edit the 3 to become a 4, and reclick,
39 then the value will change to 6.
42 A more complex example is integrate(1/(1+x^3),x) yields
46 LOG(X - X + 1) SQRT(3) LOG(X + 1)
47 - --------------- + ------------- + ----------
50 Try changing the input from 1/(1+..) to be x/(1+..) and click again!
52 An example of plotting trajectories and direction fields is
54 ode{d[x,t]=y,d[y,t]=-sin(x)}
56 where mouse-2 on the plot window computes an orbit. Typing any character
57 does a quit, and records the plot in ~/dfplot.ps.
59 An xrange or yrange may be specified:
61 ode{d[x,t]=y,d[y,t]=-sin(x)};set xrange [-4,4]
64 It is also possible to view pictures. To see a bottle with no
65 interior or exterior by clicking on <view klein bottle> or to see a
66 surface with only one side see <moebeius band>.
68 These are images produced by MAXIMA, and then saved to a gif file.
69 The mathematical formula for this image is a few paragraphs down.
71 An example of a simple 3d plot using the system defaults
76 This uses the default plotter izic. When the graph comes up you may
77 use the mouse to scale the image, and also to rotate it.
79 Scale objects: mouse left, move up to grow image, down to shrink.
80 Move object: mouse middle, move up to grow image, down to shrink.
81 Rotate objects: mouse right and move to rotate.
83 Most things can be done with menus in izic. Look at the help, but if
84 you have a colour display, then do ctrl-z after you have found a nice
85 orientation of your object. This will bring up a nicely shaded image.
87 For Maxima the value plot_options evaluates to
88 [[X, - 3, 3], [Y, - 3, 3], [GRID, 30, 30], [VIEW_DIRECTION, 1, 1, 1],
90 [COLOUR_Z, FALSE], [TRANSFORM_XY, FALSE], [RUN_VIEWER, TRUE],
94 affects the default behaviour. One can also use GEOMVIEW and PS as
95 output formats instead of zic. In every case a file
96 maxout.{plot_format} is created in your current directory.
98 To view the plot with other options, these are supplied after the
99 expression to be plotted. For example
101 plot3d(2^(x^2-y^2),[x,-1,1],[y,-2,2])
103 will plot the expression 2^(x^2-y^2) for x in the interval [-1,1] and
104 for y in [-2,2]. The second and third arguments to plot3d must always be
105 the first variable range and the second variable range. These ranges
106 determine the names of the variables which are used for the first and
107 second coordinates respectively.
108 The other options may occur in any order. For example:
110 plot3d(r^.33*cos(th/3),[r,0,1],[th,0,6*%pi],['grid,12,80],['plot_format,zic],
111 ['transform_xy,polar_to_xy],['view_direction,1,1,1.4],['colour_z,true])
113 This transforms to polar coordinates the first 2 variables. It uses
114 a grid of 12 x 80. The other options dont affect the ZIC plot, but
115 would be significant if we changed the format to postscript.
117 plot3d(r^.33*cos(th/3),[r,0,1],[th,0,6*%pi],['grid,12,80],['plot_format,ps],
118 ['transform_xy,polar_to_xy],['view_direction,1,1,1.4],['colour_z,true])
120 To get ghostscript to go away you need to do M-x book-maxima-interrupt
121 or click on the control-c:
\x03. If you are viewing with ghostview just
122 use the menu provided.
124 While we are doing the plots, we can still use the editor. It is not
125 waiting for the plot to complete. This is because we are not wanting
126 to insert a result. The face for the above command is 'maxima-eval'
127 which does not wait, or try to insert a result. 'maxima-eval-insert'
128 evaluates the expression and inserts the result in the next result
131 Another example is a moebius band:
133 plot3d([cos(x)*(3+y*cos(x/2)),sin(x)*(3+y*cos(x/2)),y*sin(x/2)],
134 [x,-%pi,%pi],[y,-1,1],['grid,50,15])
138 plot3d([5*cos(x)*(cos(x/2)*cos(y)+sin(x/2)*sin(2*y)+3.0) - 10.0,
139 -5*sin(x)*(cos(x/2)*cos(y)+sin(x/2)*sin(2*y)+3.0),
140 5*(-sin(x/2)*cos(y)+cos(x/2)*sin(2*y))],[x,-%pi,%pi],[y,-%pi,%pi],
145 plot3d([cos(y)*(10.0+6*cos(x)),
146 sin(y)*(10.0+6*cos(x)),
147 -6*sin(x)], [x,0,2*%pi],[y,0,2*%pi],['grid,40,40])
149 We can output to gnplot too:
151 plot3d(2^(x^2-y^2),[x,-1,1],[y,-2,2],[plot_format,gnuplot])
156 Let f(x) be a continous function of one variable, then we wish to
157 study the upper and lower riemann sums for a partition. A partition
158 is a subdivision of an interval into a number of subintervals, and can
159 be specified by the list of end points of the subintervals.
161 To calculate an upper sum we must find the maximum of a function
162 on a closed interval. We know how to do this if the function is
163 differentiable. [Click on the following definitions so that they
166 critical_points(expr,var):= block([numer:true,f:diff(expr,var)],
167 realroots(num(f)*denom(f),10^-7));
170 where realroots finds the real roots of a single variable polynomial
171 to a given precision, and diff takes the derivative. The above will work
172 for rational functions, since in general we need to include as critical points
173 roots of the numerator and denominator.
175 An example of the realroots function is
176 block([numer:true],realroots(x^5+3*x^1+1,10^-7)) returns
177 [X = - 0.33198902010917664]
179 The numer flag says give a numerical (floating point) answer. Now the
180 maximum must occur either at a critical point or at an end point of
181 the interval, so we can write
183 function_max(expr,var,a,b,critical_points):=
184 block([y:max(at(expr,var=a),at(expr,var=b)) ],
185 for v in critical_points
187 if a<v and v<b and at(expr,var=v) > y then y:at(expr,var=v)),
189 upper_sum(expr,var,partition):=
190 block([crit:critical_points(expr,var)],
191 sum(function_max(expr,var,partition[i],partition[i+1],crit)*
192 (partition[i+1]-partition[i]),i,1,length(partition)-1));
194 In the above at(x^2+3,x=5) gives 28 .
196 We can now compute the upper riemann sum for the expression x^2
197 for a partition of the interval [0,2]
199 upper_sum(x^2,x,[0,.3,.5,.8,.9,1.8,1.9,2.0]) returns 4.0270000000000001
202 We wish to form the lower riemann sum as well and to compare it to
203 the upper riemman_sum. The next function returns a list containing
204 the upper sum, the lower sum, and their difference.
206 upper_and_lower_sums(expr,var,partition):=
207 block([up:upper_sum(expr,var,partition),
208 low:-upper_sum(-expr,var,partition)],
211 You can try refining the partition by adding more items to it. Each
212 time you add an item the two sums get closer, with the upper one
213 getting smaller and the lower one getting bigger. Can you explain
216 upper_and_lower_sums(x^2,x,[0,.3,.35,.4,.7,.8,1.0,1.2,1.3,1.5,1.7,1.9,2.0])
218 yields [3.0591249999999999, 2.3066249999999999, 0.75249999999999995]
220 They are still quite far apart. It is tedious to add the partition
221 elements by hand, and it also will give an incorrect answer if we
222 accidentally misorder them!. The following function makes a partition
223 into n evenly spaced sub intervals.
225 make_partition(a,b,n):=makelist(a+(b-a)*i/n,i,0,n);
227 Trying with a partition with a larger number of elements,
229 upper_and_lower_sums(x^2,x,make_partition(0.0,2.0,60));
231 returns [2.733703703703704, 2.6003703703703707, 0.1333333333333333]