Analyzing a Parametric CurveProgrammers: Robert Hunt & Tessa BronezMath 253 Honors Section 202Fall 2012Instructor: Philip Yasskinrestart:with(Maplets[Tools]):
with(Maplets[Elements]):
with(plots):
StartEngine();randomize():e:=exp(1):randC:=rand(-15..15):PositionVectors:=[
[t+c,t^2,2/3*t^3],
[6*t+c,3*sqrt(2)*t^2,2*t^3],
[t^2,2*t+c,ln(t)],
[3*t^2,4*t^3,3*t^4],
[4*cos(t),4*sin(t),3*t+c],
[3*cos(t),3*sin(t),4*t+c],
[5*cos(t),5*sin(t),12*t+c],
[12*cos(t),12*sin(t),5*t+c],
[7*cos(t),7*sin(t),24*t+c],
[24*cos(t),24*sin(t),7*t+c],
[4*cosh(t),3*sinh(t),4*t+c],
[3*cosh(t),4*sinh(t),3*t+c],
[e^t,sqrt(2)*t+c,e^(-t)]
]:randVec:=rand(1..nops(PositionVectors)):ask:=proc()
global position1ans, position2ans, position3ans,
velocity1ans, velocity2ans, velocity3ans,
acceleration1ans, acceleration2ans, acceleration3ans,
jerk1ans, jerk2ans, jerk3ans,
speedans, That1ans, That2ans, That3ans, c;
local randNeg1,randNeg2,whichvec,Vecperm;
whichvec:=randVec();
Vecperm:=combinat:-randperm(3);
position1ans:=PositionVectors[whichvec][Vecperm[1]];
position2ans:=PositionVectors[whichvec][Vecperm[2]];
position3ans:=PositionVectors[whichvec][Vecperm[3]];
Set(position1=position1ans);
Set(position2=position2ans);
Set(position3=position3ans);
velocity1ans:=simplify(diff(position1ans,t));
velocity2ans:=simplify(diff(position2ans,t));
velocity3ans:=simplify(diff(position3ans,t));
acceleration1ans:=simplify(diff(velocity1ans,t));
acceleration2ans:=simplify(diff(velocity2ans,t));
acceleration3ans:=simplify(diff(velocity3ans,t));
jerk1ans:=simplify(diff(acceleration1ans,t));
jerk2ans:=simplify(diff(acceleration2ans,t));
jerk3ans:=simplify(diff(acceleration3ans,t));
speedans:=simplify(sqrt(factor(velocity1ans^2+velocity2ans^2+velocity3ans^2))) assuming positive;
That1ans:=simplify(velocity1ans/speedans);
That2ans:=simplify(velocity2ans/speedans);
That3ans:=simplify(velocity3ans/speedans);
Set(velocity1=""):
Set(velocity2=""):
Set(velocity3=""):
Set(velocityReply="");
Set(acceleration1="");
Set(acceleration2="");
Set(acceleration3="");
Set(accelerationReply="");
Set(jerk1="");
Set(jerk2="");
Set(jerk3="");
Set(jerkReply="");
Set(speed="");
Set(speedReply="");
Set(That1="");
Set(That2="");
Set(That3="");
Set(ThatReply="");
Set(hintBox="");
c:=randC();
end proc:velocityHint:=proc()
Set(hintBox="The velocity, v, is the derivative of position, r.");
end proc:velocityCheck:=proc()
global velocity1ans, velocity2ans, velocity3ans;
local user1, user2, user3;
user1:=Get(velocity1::algebraic, corrections=true, update=true):
user2:=Get(velocity2::algebraic, corrections=true, update=true):
user3:=Get(velocity3::algebraic, corrections=true, update=true):
if simplify(user1-velocity1ans)=0 and simplify(user2-velocity2ans)=0 and simplify(user3-velocity3ans)=0 then
Set(velocityReply="Correct!");
Set(hintBox="Nice job! You are a math wiz!");
else
Set(velocityReply="Incorrect.");
Set(hintBox="Try again, you can do it! Click the hint button if you need help.");
end if;
end proc:velocityShow:=proc()
global velocity1ans, velocity2ans, velocity3ans;
Set(velocity1=velocity1ans):
Set(velocity2=velocity2ans):
Set(velocity3=velocity3ans):
Set(velocityReply="Shown");
Set(hintBox="Read the textbook and try again.");
end proc:accelerationHint:=proc()
Set(hintBox="The acceleration, a, is the derivative of velocity, v.");
end proc:accelerationCheck:=proc()
global acceleration1ans, acceleration2ans, acceleration3ans;
local user1, user2, user3;
user1:=Get(acceleration1::algebraic, corrections=true, update=true):
user2:=Get(acceleration2::algebraic, corrections=true, update=true):
user3:=Get(acceleration3::algebraic, corrections=true, update=true):
if(user1=acceleration1ans) and (user2=acceleration2ans) and (user3=acceleration3ans) then
Set(accelerationReply="Correct!");
Set(hintBox="Nice job! You are a math wiz!");
else
Set(accelerationReply="Incorrect.");
Set(hintBox="Try again, you can do it! Click the hint button if you need help.");
end if;
end proc:accelerationShow:=proc()
global acceleration1ans, acceleration2ans, acceleration3ans;
Set(acceleration1=acceleration1ans):
Set(acceleration2=acceleration2ans):
Set(acceleration3=acceleration3ans):
Set(accelerationReply="Shown");
Set(hintBox="Read the textbook and try again.");
end proc:jerkHint:=proc()
Set(hintBox="The jerk, j, is the derivative of acceleration, a.");
end proc:jerkCheck:=proc()
global jerk1ans, jerk2ans, jerk3ans;
local user1, user2, user3;
user1:=Get(jerk1::algebraic, corrections=true, update=true):
user2:=Get(jerk2::algebraic, corrections=true, update=true):
user3:=Get(jerk3::algebraic, corrections=true, update=true):
if(user1=jerk1ans) and (user2=jerk2ans) and (user3=jerk3ans) then
Set(jerkReply="Correct!");
Set(hintBox="Nice job! You are a math wiz!");
else
Set(jerkReply="Incorrect.");
Set(hintBox="Try again, you can do it! Click the hint button if you need help.");
end if;
end proc:jerkShow:=proc()
global jerk1ans, jerk2ans, jerk3ans;
Set(jerk1=jerk1ans):
Set(jerk2=jerk2ans):
Set(jerk3=jerk3ans):
Set(jerkReply="Shown");
Set(hintBox="Read the textbook and try again.");
end proc:speedHint:=proc()
Set(hintBox="The speed, ds/dt, is the length of the velocity, v, which is the square root of the sum of the squares of the velocity components.");
end proc:speedCheck:=proc()
global speedans;
local user1;
user1:=Get(speed::algebraic, corrections=true, update=true):
if(user1=speedans) then
Set(speedReply="Correct!");
Set(hintBox="Nice job! You are a math wiz!");
else
Set(speedReply="Incorrect.");
Set(hintBox="Try again, you can do it! Click the hint button if you need help.");
end if;
end proc:speedShow:=proc()
global speedans;
Set(speed=speedans):
Set(speedReply="Shown");
Set(hintBox="Read the textbook and try again.");
end proc:ThatHint:=proc()
Set(hintBox="The unit tangent vector, T, is the velocity vector divided by it's magnitude.");
end proc:ThatCheck:=proc()
global That1ans, That2ans, That3ans;
local user1, user2, user3;
user1:=Get(That1::algebraic, corrections=true, update=true):
user2:=Get(That2::algebraic, corrections=true, update=true):
user3:=Get(That3::algebraic, corrections=true, update=true):
if(user1=That1ans) and (user2=That2ans) and (user3=That3ans) then
Set(ThatReply="Correct!");
Set(hintBox="Nice job! You are a math wiz!");
else
Set(ThatReply="Incorrect.");
Set(hintBox="Try again, you can do it! Click the hint button if you need help.");
end if;
end proc:ThatShow:=proc()
global That1ans, That2ans, That3ans;
Set(That1=That1ans):
Set(That2=That2ans):
Set(That3=That3ans):
Set(ThatReply="Shown");
Set(hintBox="Read the textbook and try again.");
end proc:CurveAnalysis:=Maplet(onstartup = RunWindow(MAIN),
Window[MAIN](title="Analyzing a Parametric Curve",
[ valign=none, inset=0, spacing=0,
[ halign=none,
Button("New Curve", Evaluate(function = "ask"), background=magenta),
HorizontalGlue(),
BoxRow( halign=none, border=true,
caption="Compute the following quantities, given the position vector:",
"r = <",
TextField[position1](width=15, background=white, editable=false),
",",
TextField[position2](width=15, background=white, editable=false),
",",
TextField[position3](width=15, background=white, editable=false),
">"
),
HorizontalGlue(),
Button("Quit", Shutdown(), background=pink)
],
[ halign=none, border=true,
caption="Velocity vector:",
"v = <",
TextField[velocity1](width=15, background=cyan),
",",
TextField[velocity2](width=15, background=cyan),
",",
TextField[velocity3](width=15, background=cyan),
">",
HorizontalGlue(),
Button("Hint", Evaluate(function = "velocityHint"), background="Orange"),
Button("Check", Evaluate(function = "velocityCheck"), background=green),
TextField[velocityReply](width=7, editable=false, background=white),
Button("Show", Evaluate(function = "velocityShow"), background=yellow)
],
[ halign=none,border=true,
caption="Acceleration vector:",
"a = <",
TextField[acceleration1](width=15, background=cyan),
",",
TextField[acceleration2](width=15, background=cyan),
",",
TextField[acceleration3](width=15, background=cyan),
">",
HorizontalGlue(),
Button("Hint", Evaluate(function = "accelerationHint"), background="Orange"),
Button("Check", Evaluate(function = "accelerationCheck"), background=green),
TextField[accelerationReply](width=7, editable=false, background=white),
Button("Show", Evaluate(function = "accelerationShow"), background=yellow)
],
[ halign=none,border=true,
caption="Jerk vector:",
"j = <",
TextField[jerk1](width=15, background=cyan),
",",
TextField[jerk2](width=15, background=cyan),
",",
TextField[jerk3](width=15, background=cyan),
">",
HorizontalGlue(),
Button("Hint", Evaluate(function = "jerkHint"), background="Orange"),
Button("Check", Evaluate(function = "jerkCheck"), background=green),
TextField[jerkReply](width=7, editable=false, background=white),
Button("Show", Evaluate(function = "jerkShow"), background=yellow)
],
[ halign=none,border=true,
caption="Speed:",
"ds/dt =",
TextField[speed](width=15, background=cyan),
HorizontalGlue(),
Button("Hint", Evaluate(function = "speedHint"), background="Orange"),
Button("Check", Evaluate(function = "speedCheck"), background=green),
TextField[speedReply](width=7, editable=false, background=white),
Button("Show", Evaluate(function = "speedShow"), background=yellow)
],
[ halign=none,border=true,
caption="Unit Tangent Vector:",
"T = <",
TextField[That1](width=15, background=cyan),
",",
TextField[That2](width=15, background=cyan),
",",
TextField[That3](width=15, background=cyan),
">",
HorizontalGlue(),
Button("Hint", Evaluate(function = "ThatHint"), background="Orange"),
Button("Check", Evaluate(function = "ThatCheck"), background=green),
TextField[ThatReply](width=7, editable=false, background=white),
Button("Show", Evaluate(function = "ThatShow"), background=yellow)
],
[
TextBox[hintBox](width=60, height=2, background=white, editable=false)
],
[ inset=0, spacing=0,
"Instructor: Philip Yasskin",
"Programmers: Robert Hunt & Tessa Bronez",
"Copyright: Yasskin 2012"
]
]
),
ButtonGroup[BG1]()
):Maplets[Display]( CurveAnalysis ):