Assignment-5 using MAPLE

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.
> restart;
> with(plots):
Warning, the name changecoords has been redefined
> y:=A*2*cos(f*theta);
> subs(A=1, f=1, y);
> p1:=plot(subs(A=1, f=1, y), theta=0..2*Pi, colour=red, legend="f=1"): p1;

p2:=plot(subs(A=.5, f=3, y), theta=0..2*Pi, colour=brown,

> p3:=plot(subs(A=1, f=5, y), theta=0..2*Pi, colour=yellow, legend="f=5"):p3;

> p4:=plot(subs(A=2, f=2.5, y), theta=0..2*Pi, colour=pink, legend="f=2.5"): p4;

> p5:=plot(subs(A=1, f=1.5, y), theta=0..2*Pi,colour=red, legend="f=1.5"):p5;

> display({p1,p2,p3,p4,p5});

> animate(subs(A=1, y), theta=0..3*Pi, f=0.5..5);

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.
> plot([sin(2*t^3), cos(4*t^3), t=0..2*Pi], axes=NONE);

"Under Lover's Bleeding Lane"

> restart;
> with(plots):
> plot3d( 3*cos(2*x-y), x=-15..15, y=-5..5, axes=NONE, scaling=constrained);

"Extra Crispy Please"

> plot( [cos(5*t)+cos(3*t), sin(3*t)-sin(2*t), t=0..2*Pi], axes=NONE);

>
"Open Umbrella

> restart: with(plots):
Warning, the name changecoords has been redefined
> plot3d([2*sin(4*s), 3*cos(10*s), sin(3*t*s)], s=0..Pi, t=0..2*Pi, scaling=constrained);
"Mr. No-Way-Out-Maze"

> restart; with(plottools):
vrml(plot3d([2*sin(4*s), 3*cos(10*s), sin(3*t*s)], s=0..Pi, t=0..2*Pi, scaling=constrained),
`maze.wrl`);

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.
> with(plots):
Warning, the names arrow and changecoords have been redefined
> animate( sin(x-2*phi+2*x), x=-2..10, phi=0..2*Pi, frames=40);

> animate3d( cos(2*(sqrt(3*x+3*y)+3*phi)), x=-15..15, y=-15..15, phi=-Pi/2..Pi/2, style=patch, frames=30);

The Twisted Tongue


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(x,a)
local y:
if x>=-a and x<=0 then
y:=7*ex+x+5:
elif
x>=0 and x<=a then
y:=x+5:
else
y:=0
fi:
end;
> f(3,2);
> f(4,5);
> f(-4,4);

6.Write a Maple procedure (proc) called Grade(marks), which will accept a student's exam mark and returns his grade.
> restart;
> y:=proc(m)
local n:
if m>90 then
n:="A+":
elif m>80 then
n:="A":
elif m>70 then
n:="B+":
elif m>60 then
n:="B":
elif m>50 then
n:="C":
elif m>40 then
n:="D":
else
n:=FAIL:
fi:
end;
> y(98);
> y(76);
> y(55);
> y(64);
> y(95);

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.
b) Eqsolver maplet which will accept any equation in one variable and give its solutions.
c) 3Dplotter maplet which accept any equation in two variables and draw a 3D plot.
Include necessary titles, comments and buttons in all the above maplets
a) Grader maplet which will accept a student's exam mark and returns his grade
> with(Maplets[Elements]):
> GradeMaplet:=Maplet ([
[" What's your grade? "],
[" Enter your marks here : ",TextField
['TF1']()],
TextBox['TB1'](not editable, width='50',
height='4'),
[Button("Grade?", Evaluate('TB1'='f(TF1)')),
Button("Grade please!", Shutdown(['TF1','TB1']))]
]):
Maplets[Display](GradeMaplet);


b) Eqsolver maplet which will accept any equation in one variable and give its solution
> with(Maplets[Elements]):
> EqMaplet:=Maplet ([
[" We Solve Equations"],
[" What is your equation? : ", TextField ['TF1']()],
[" What is the variable? :",TextField ['TF2'](3)],
TextBox['TB1'](not editable,width='40', height='3'),
[Button ( "Solve! ", Evaluate ('TB1' = 'solve(TF1,TF2)')),
Button ( " Done! ", Shutdown (['TF1','TF2', 'TB1']))]]):
Maplets[Display](EqMaplet);


c)3D plotter maple.Accept equation with 2 variables.Draw 3D plot.
> restart;
> with(Maplets[Elements]):
> maplet3d:=Maplet([["Enter the function of 'f' and 'k':", TextField['TF3d']()],
Plotter['PL1'](),
[Button("Plot Please..", Evaluate('PL1'='plot3d(TF3d, f=-10..10,k=-10..10)')),
Button("OK!", Shutdown(['TF3d']))]]):
result:= Maplets[Display](maplet3d);
Home...Where the heart is