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rand(1..10):
randpq:=rand(1..10):
randK:=rand(1..10):
rand2:=rand(1..2):
randprop:=rand(1..8):
randc:=rand(1..10):
randm:=rand(-5..5):
randM:=rand(1..10):
rand8:=rand(1..8):
rand4:=rand(1..4):
post:=proc()
global prop, answer, which, smallanswer;
local Padd,Psubt,Pmult,Plincomb,Porder,Psubint,Pineq,Pbnds,props,
a,b,K1,K2,p,q,c,bigM,smallM;
Set(reply="");
Padd:=Get(CBadd);
Psubt:=Get(CBsubt);
Pmult:=Get(CBmult);
Plincomb:=Get(CBlincomb);
Porder:=Get(CBorder);
Psubint:=Get(CBsubint);
Pineq:=Get(CBineq);
Pbnds:=Get(CBbnds);
props:=[Padd,Psubt,Pmult,Plincomb,Porder,Psubint,Pineq,Pbnds]:
if not (props[1] or props[2] or props[3] or props[4] or props[5] or props[6] or props[7] or props[8]) then
Set(CBadd=true);
prop:=1;
else
prop:=randprop();
while not props[prop] do
prop:=randprop();
end do;
end if;
if prop=1 then (*sum*)
Set(EqualSign(visible)=true);
Set(MMLi(visible)=false);
Set(TFanswer(visible)=true);
Set(Land(visible)=true);
Set(GreatThan(visible)=false);
Set(LessThan(visible)=false);
Set(thennn(visible)=false);
Set(RBgreat(visible)=false);
Set(RBless(visible)=false);
Set(RBgrequal(visible)=false);
Set(RBlequal(visible)=false);
Set(TFsmallanswer(visible)=false);
Set(compute(visible)=true);
a:=randa();
b:=a+randb();
K1:=(-1)^rand2()*randK();
K2:=(-1)^rand2()*randK();
Set(MMLf(value)=(Int(f(x),x=a..b)=K1));
Set(Land(visible)=true);
Set(MMLg(visible)=true);
Set(MMLg(value)=(Int(g(x),x=a..b)=K2));
Set(MMLh(value)=(Int(f(x)+g(x),x=a..b)));
answer:=K1+K2;
elif prop=2 then (*subtraction*)
Set(EqualSign(visible)=true);
Set(MMLi(visible)=false);
Set(TFanswer(visible)=true);
Set(Land(visible)=true);
Set(GreatThan(visible)=false);
Set(LessThan(visible)=false);
Set(thennn(visible)=false);
Set(RBgreat(visible)=false);
Set(RBless(visible)=false);
Set(RBgrequal(visible)=false);
Set(RBlequal(visible)=false);
Set(TFsmallanswer(visible)=false);
Set(compute(visible)=true);
a:=randa();
b:=a+randb();
K1:=(-1)^rand2()*randK();
K2:=(-1)^rand2()*randK();
Set(MMLf(value)=(Int(f(x),x=a..b)=K1));
Set(Land(visible)=true);
Set(MMLg(visible)=true);
Set(MMLg(value)=(Int(g(x),x=a..b)=K2));
Set(MMLh(value)=(Int(f(x)-g(x),x=a..b)));
answer:=K1-K2;
elif prop=3 then (*mult*)
Set(EqualSign(visible)=true);
Set(MMLi(visible)=false);
Set(TFanswer(visible)=true);
Set(Land(visible)=false);
Set(GreatThan(visible)=false);
Set(LessThan(visible)=false);
Set(thennn(visible)=false);
Set(RBgreat(visible)=false);
Set(RBless(visible)=false);
Set(RBgrequal(visible)=false);
Set(RBlequal(visible)=false);
Set(TFsmallanswer(visible)=false);
Set(compute(visible)=true);
a:=randa();
b:=a+randb();
K1:=(-1)^rand2()*randK();
p:=(-1)^rand2()*randpq();
while p=1 do
p:=(-1)^rand2()*randpq(); (* Multiple of 1 is not interesting.*)
end do;
Set(MMLf(value)=(Int(f(x),x=a..b)=K1));
Set(Land(visible)=false);
Set(MMLg(visible)=false);
Set(MMLh(value)=(Int(p*f(x),x=a..b)));
answer:=p*K1;
elif prop=4 then (*lincomb*)
Set(EqualSign(visible)=true);
Set(MMLi(visible)=false);
Set(TFanswer(visible)=true);
Set(Land(visible)=true);
Set(GreatThan(visible)=false);
Set(LessThan(visible)=false);
Set(thennn(visible)=false);
Set(RBgreat(visible)=false);
Set(RBless(visible)=false);
Set(RBgrequal(visible)=false);
Set(RBlequal(visible)=false);
Set(TFsmallanswer(visible)=false);
Set(compute(visible)=true);
a:=randa();
b:=a+randb();
K1:=(-1)^rand2()*randK();
K2:=(-1)^rand2()*randK();
p:=(-1)^rand2()*randpq();
q:=(-1)^rand2()*randpq();
Set(MMLf(value)=(Int(f(x),x=a..b)=K1));
Set(Land(visible)=true);
Set(MMLg(visible)=true);
Set(MMLg(value)=(Int(g(x),x=a..b)=K2));
Set(MMLh(value)=(Int(p*f(x)+q*g(x),x=a..b)));
answer:=p*K1+q*K2;
elif prop=5 then (*order*)
Set(EqualSign(visible)=true);
Set(MMLi(visible)=false);
Set(GreatThan(visible)=false);
Set(LessThan(visible)=false);
Set(thennn(visible)=false);
Set(RBgreat(visible)=false);
Set(RBless(visible)=false);
Set(RBgrequal(visible)=false);
Set(RBlequal(visible)=false);
Set(TFsmallanswer(visible)=false);
Set(compute(visible)=true);
a:=randa();
b:=a+randb();
K1:=(-1)^rand2()*randK();
Set(MMLf(value)=(Int(f(x),x=a..b)=K1));
Set(Land(visible)=false);
Set(MMLg(visible)=false);
which:=rand8();
if which=1 then
Set(MMLh(value)=(Int(f(x),x=a..a)));
answer:=0;
elif which=2 then
Set(MMLh(value)=(Int(f(x),x=b..b)));
answer:=0;
else (*Note 6/8 of the time a and b are reversed.*)
Set(MMLh(value)=(Int(f(x),x=b..a)));
answer:=-K1;
end if;
elif prop=6 then (*subint*)
Set(EqualSign(visible)=true);
Set(MMLi(visible)=false);
Set(TFanswer(visible)=true);
Set(EqualSign(visible)=true);
Set(GreatThan(visible)=false);
Set(LessThan(visible)=false);
Set(thennn(visible)=false);
Set(RBgreat(visible)=false);
Set(RBless(visible)=false);
Set(RBgrequal(visible)=false);
Set(RBlequal(visible)=false);
Set(TFsmallanswer(visible)=false);
Set(compute(visible)=true);
a:=randa();
b:=a+randb();
c:=b+randc();
K1:=(-1)^rand2()*randK();
K2:=(-1)^rand2()*randK();
Set(Land(visible)=true);
Set(MMLg(visible)=true);
which:=rand8();
if which in {1,2,3,4} then
Set(MMLf(value)=(Int(f(x),x=a..b)=K1));
Set(MMLg(value)=(Int(f(x),x=b..c)=K2));
Set(MMLh(value)=(Int(f(x),x=a..c)));
answer:=K1+K2;
elif which in {5,6} then
Set(MMLf(value)=(Int(f(x),x=a..c)=K1));
Set(MMLg(value)=(Int(f(x),x=a..b)=K2));
Set(MMLh(value)=(Int(f(x),x=b..c)));
answer:=K1-K2;
else
Set(MMLf(value)=(Int(f(x),x=a..c)=K1));
Set(MMLg(value)=(Int(f(x),x=b..c)=K2));
Set(MMLh(value)=(Int(f(x),x=a..b)));
answer:=K1-K2;
end if;
elif prop=7 then (*ineq*)
Set(Land(visible)=false);
Set(GreatThan(visible)=false);
Set(LessThan(visible)=false);
Set(compute(visible)=false);
Set(EqualSign(visible)=false);
Set(thennn(visible)=true);
Set(TFanswer(visible)=false);
Set(RBgreat(visible)=true,RBgreat=false); (*Blank out the radio buttons*)
Set(RBless(visible)=true,RBless=false);
Set(RBgrequal(visible)=true,RBgrequal=false);
Set(RBlequal(visible)=true,RBlequal=false);
Set(Land(visible)=false);
Set(MMLg(visible)=false);
Set(MMLi(visible)=true);
Set(TFsmallanswer(visible)=false);
a:=randa();
b:=a+randb();
Set(MMLh(value)=Int(f(x),x=a..b));
Set(MMLi(value)=Int(g(x),x=a..b));
which:=rand4():
if which = 1 then
Set(MMLf(value)=(f(x)<g(x)));
elif which = 2 then
Set(MMLf(value)=(f(x)>g(x)));
elif which = 3 then
Set(MMLf(value)=(f(x)<=g(x)));
else
Set(MMLf(value)=(f(x)>=g(x)));
end if;
elif prop=8 then (*bounds*)
Set(Land(visible)=true);
Set(GreatThan(visible)=true);
Set(LessThan(visible)=true);
Set(RBgreat(visible)=false);
Set(RBless(visible)=false);
Set(RBgrequal(visible)=false);
Set(RBlequal(visible)=false);
Set(TFsmallanswer(visible)=true);
Set(compute(visible)=false);
Set(thennn(visible)=true);
Set(EqualSign(visible)=false);
Set(TFanswer(visible)=true);
Set(MMLg(visible)=true);
Set(MMLi(visible)=false);
a:=randa();
b:=a+randb();
smallM:=randm();
bigM:=smallM+randM();
Set(MMLf(value)=(smallM<f(x)));
Set(MMLg(value)=(bigM>f(x)));
Set(MMLh(value)=Int(f(x),x=a..b));
smallanswer:=smallM*(b-a);
answer:=bigM*(b-a);
end if;
Set(TFsmallanswer="");
Set(TFanswer="");
end proc:
check:=proc()
global prop, answer, which, smallanswer;
local useranswer, usersmallanswer;
if prop>=1 and prop<=6 then
useranswer:=Get(TFanswer::integer, corrections=true, update=true);
if useranswer=answer then
Set(reply="Great Job!")
else
Set(reply="Bummer, try again.")
end if;
elif prop=7 then (*Eliminated useranswer*)
if which = 1 then
if Get(RBless) then
Set(reply="AWESOME");
else
Set(reply="BOO!");
end if
elif which=2 then
if Get(RBgreat) then
Set(reply="AWESOME");
else
Set(reply="BOO!");
end if
elif which=3 then
if Get(RBlequal) then
Set(reply="AWESOME");
else
Set(reply="BOO!");
end if
else
if Get(RBgrequal) then
Set(reply="AWESOME");
else
Set(reply="BOO!");
end if;
end if;
elif prop=8 then
usersmallanswer:=Get(TFsmallanswer::integer, corrections=true, update=true);
useranswer:=Get(TFanswer::integer, corrections=true, update=true);
if usersmallanswer=smallanswer and useranswer=answer then
Set(reply="You are so smart!!");
else
Set(reply="Keep on trying!", reply(background)=red);
end if;
end if;
end proc:
show:=proc()
global prop, answer, which, smallanswer;
Set(reply="Figure it out kid!");
if prop>=1 and prop<=6 then
Set(TFanswer=answer);
elif prop = 7 then
if which = 1 then
Set(RBless(value)=true);
elif which=2 then
Set(RBgreat(value)=true);
elif which=3 then
Set(RBlequal(value)=true);
else
Set(RBgrequal(value)=true);
end if;
elif prop = 8 then
Set(TFsmallanswer=smallanswer);
Set(TFanswer=answer);
end if;
end proc:
IntProp:=Maplet(onstartup = RunWindow(MAIN),
Window[MAIN](title="Properties of Integrals",
[ [ halign=none,
Button("New Question", Evaluate( function= "post"), background = magenta),
HorizontalGlue(),
[ valign=none, inset=0, spacing=0,
[ halign=none,
CheckBox[CBadd]("addition", value=true),
HorizontalGlue()
],
[ halign=none,
CheckBox[CBsubt]("subtraction"),
HorizontalGlue()
]
],
[ valign=none, inset=0, spacing=0,
[ halign=none,
CheckBox[CBmult]("multiple"),
HorizontalGlue()
],
[ halign=none,
CheckBox[CBlincomb]("linear combination"),
HorizontalGlue()
]
],
[ valign=none, inset=0, spacing=0,
[ halign=none,
CheckBox[CBorder]("changing limits"),
HorizontalGlue()
],
[ halign=none,
CheckBox[CBsubint]("subintervals"),
HorizontalGlue()
]
],
[ valign=none, inset=0, spacing=0,
[ halign=none,
CheckBox[CBineq]("inequality"),
HorizontalGlue()
],
[ halign=none,
CheckBox[CBbnds]("bounds"),
HorizontalGlue()
]
],
HorizontalGlue(),
Button("Quit",Shutdown(), background=pink)
],
[ halign=none,
"Given that",
MathMLViewer[MMLf](value=(Int(f(x),x=a..b)=""), width=200,height=70),
Label[Land]("and", visible=true),
MathMLViewer[MMLg](value=(Int(g(x),x=c..d)=""), width=200,height=70, visible=true)
],
[ halign=none,
Label[compute]("Compute:",visible=true),
Label[thennn]("Then:",visible=false),
TextField[TFsmallanswer](width=10, background=turquoise,visible=false),
Label[LessThan]("<",visible=false),
MathMLViewer[MMLh](value=(Int(f(x),x=e..f)), width=200,height=70),
[ valign=none, inset=0, spacing=0,
RadioButton[RBgreat](">", group=comparisons,visible=false),
RadioButton[RBless]("<", group=comparisons,visible=false)
],
Label[EqualSign]("=",visible=true),
Label[GreatThan]("<",visible=false),
TextField[TFanswer](width=10, background=turquoise),
[ valign=none, inset=0, spacing=0,
RadioButton[RBgrequal](">=", group=comparisons,visible=false),
RadioButton[RBlequal]("<=", group=comparisons,visible=false)
],
MathMLViewer[MMLi](width=200, height=70, visible=false),
HorizontalGlue(),
Button("Check", Evaluate( function= "check"), background = green),
Button("Show", Evaluate( function = "show"), background = yellow)
],
TextField[reply](width=40),
[ halign=none,
"Instructor: Philip Yasskin",
HorizontalGlue(),
"Programmers: Hassan Daramsis & Grant Bellamy",
HorizontalGlue(),
"Copyright 2012, P. Yasskin"
]
]
),
ButtonGroup[comparisons]()
):
Maplets[Display]( IntProp );