KOS 1110 Computers in Science
Assignment 5 - Maple graphics and maplets
Due date Monday, 10-10-2005, 10:00am
Instructions: All the answers should be done in Maple work sheet. Use the text mode to type the questions, explanations and any comments. After you have answered all the questions, export your file as 5emailname.rtf. Open this file in MS Word and save this file as 5emailname.doc file. For Q7, after displaying the maplets, use the alt+printscreen command to copy the maplets and paste them in to your MS-Word file in the appropriate place. Now your .doc file would contain both the maplets and the command used to create the maplets. Publish all the graphs, artwork and animations along with the equations in your home page. Print the view from your website along with the print out the 5emailname.doc file. Send me the printed form and the electronic form (softcopy) of the doc file through the email.
1. Multiplot: During your laboratory class, you have created multiplots (one figure containing several plots) and animations using these multiplots. Using your own function, create at least one set of multiplot (static) and animation. Use as many options as possible to make your plot look like textbook quality plots.
> | with (plots); |
> | y:=A*sin(f*x); |
> | a1:=plot(subs(A=1,f=1,y),x=-Pi..Pi,colour=green,legend="f= 1",axes=boxed):a1: |
> | a2:=plot(subs(A=1,f=1.5,y),x=-Pi..Pi,colour=blue,legend="f = 1.5",axes=boxed):a2: |
> | a3:=plot(subs(A=1,f=2,y),x=-Pi..Pi,colour=brown,legend="f= 2",axes=boxed):a3: |
> | display(a1,a2,a3); |
> | animate(subs(A=1,y),x=-Pi..Pi,f=1..2); |
2. Scientific graph: Select any one graph and the corresponding equation used to create this graph from your text/reference books. Plot this graph using maple. Use as many options as possible to make your plot look like textbook quality plots.
> | y:=A*sin(f*x)+cos(f*x)+sinh(A*x); |
> | a1:=plot(subs(A=1,f=1,y),x=-Pi..Pi,colour=green,legend="f= 1",axes=boxed):a1; |
> | y:=A*sin(f*x)+34*sinh(f*x); |
> | a2:=plot(subs(A=1,f=1,y),x=-Pi..Pi,colour=blue,legend="f= 1",axes=boxed):a2; |
3. Your artistic skills: Draw at least one unique picture each in 2D and 3D using Maple. Convert the 3D picture into VRML format and visualise using Cortona player.
> | restart; |
> |
> | with (plots); |
> | plot([45*cosh(5*t),7*sin(6*t),t=-10..10],title="Flower",axes=none); |
> | plot([1/2*sin(t)+cos(t),cos(2*t),t=0..100],title="Butterfly",axes=none); |
> |
> | restart; |
> | with(plots); |
> | plot3d([sin(phi)*cos(theta),sin(phi)*sin(theta),cos(phi)],theta=0..2*Pi,phi=0..Pi/2): plot3d([cos(theta)/2,sin(theta)/2,z],theta=0..2*Pi,z=-1..0): display3d({%,%%},scaling=CONSTRAINED); |
> | plottools[vrml](%,"MUSHROOM.vrml"); |
> |
4. 3D animation: Make at least one unique animation in 3D.
Give names to all the above pictures. Publish these pictures and the animations in your home page along with the details, such as the equations that are used to create the animations.
> | restart; |
> | with(plots); |
> | animate3d(sin(x)*sin(t*u)+cos(t),x=1..3,t=1..4,u=1/4..7/2,coords=cylindrical,title="SNAKE"); |
5. Write a Maple procedure (proc) called function(x), which will accept the value of a and x to calculate a function which has a value of 7*ex+x+5 in the range of x=-a to 0 and a value of x+5 in the range of x=0 to a. The value of this function is zero everywhere else. Check your procedure by calling this proc using different values of x and a.
> | restart; |
> | f:=proc(a,x) local z: if x>=-a and x<=0 then z:=7*e^x+x+5: elif x>=0 and x<=a then z:=x+5: else z:=0: fi: end: |
> | f(200,185); |
> | f(-89,-68); |
> | f(156,-100); |
> | f(-20,90); |
6. Write a Maple procedure (proc) called Grade(marks), which will accept a student's exam mark and returns his grade.
> | restart; |
> | f:=proc(x) local z: |
> | if x>=80 then z:=A: elif x>=70 then z:=B: elif x>=60 then z:=C: elif x>=50 then elif x>=40 then z:=D: else z:=Fail: fi: end: |
> | f(78); |
> | f(90); |
> | f(48); |
> | f(24); |
> | f(62); |
7. Write the commands necessary to produce the following maplets:
a) Grader maplet which will accept a student's exam mark and returns his grade.
> | restart; |
> | f:=proc(mark) local a: if mark>79 then a:=A; elif mark>69 then a:=B; elif mark>59 then a:=C; elif mark>49 then a:=D; elif mark>39 then a:=E; else a:=Fail; fi; end; |
> | with(Maplets[Elements]): |
> | Grader:=Maplet([ ["STUDENTS'MARK"], ["Enter the mark"], ["Mark:",TextField['TF1']()], TextBox['TF2'](not editable,width='40',height='5'), [Button("Your Grade",Evaluate('TF2'='f('TF1')')), Button("Ok",Shutdown(['TF1','TF2']))] ]): |
> | Maplets[Display](Grader); |
b) Eqsolver maplet which will accept any equation in one variable and give its solutions.
restart;
> | restart; |
> | with(Maplets[Elements]): |
> | EqMaplet:= Maplet([ ["Equation"], ["Enter the equation:", TextField['TF1']()], ["Enter the variable:",TextField['TF2'](1)], TextBox['TB1'](not editable, width='40' ,height='5'), [Button("Solve",Evaluate('TB1'='solve('TF1,TF2')')), Button("OK",Shutdown(['TF1','TF2','TB1']))] ]): |
> | Maplets[Display](EqMaplet); |
c) 3Dplotter maplet which accept any equation in two variables and draw a 3D plot.
> | restart; |
> | with(Maplets[Elements]): PlottingMaplet:=Maplet( Window('title'="PLOTTING WITH 3D",'layout'='L', BoxLayout['L']( BoxColumn( BoxRow("Enter the equation to be plotted:"), BoxRow(TextField['TF1']()), BoxRow("Start Plotting"), BoxRow(Plotter['P']()), BoxRow(Button("Plot",Evaluate('P'='plot3d(TF1,x=-8..8,y=-8..8)')), Button("OK",Shutdown(['TF1']))))))): |
> | Maplets[Display](PlottingMaplet); |
> |