Low Stress Coding for High Impact Teaching Tools

Rob Morris
Business Analysis
Wolfram Research

“Exploratory” Math

Computers allow us to do computations quickly and efficiently.

But sometimes this pigeonholes computers as glorified calculators.

I want to advocate that this ability to solve known problems can be leveraged to create an environment where students can experiment/explore/play with concepts in math.

Exploratory Math

This learning strategy employs a two-pronged approach:

1) Focus on targetting new skill development and extending cognitive abilities, rather than re-treading well-worn ground.

2) Introduce data and evidence into learning math.

Exploratory Math

In this talk I will introduce three simple “exploratory” tools for math learning.

A tool to explore properties of polygons

A tool to visualize series expansions

A tool to understand the effects of polynomial coefficients

Exploratory Math

The core message is that there is a lack of experience and intuition in the math classroom. Concepts are often presented in ways very different from how they are discovered and developed.

The tools presented here allow students to build their intuition before they are faced with formal topics.

They provide an environment where students can take data and analyze trends before attempting direct proofs.

This exploratory phase introduces and reinforces evidence as the foundation for understanding math.

Polygon Explorer

Create a tool that enables students to explore basic properties of polygons. Students can “take data” from these properties to build their intuition, which gives them a solid foundation for formal proofs and derivations.

Polygon Explorer

Start with a triangle

Graphics[{Thick,RandomColor[],Line[#]}&/@Partition[CirclePoints[3],2,1,1]]

Find the perimeter

Total@N[EuclideanDistance@@@Partition[ CirclePoints[3],2,1,1]]

Polygon Explorer

Change the size

Graphics[Flatten[{{Thick,RandomColor[],Line[#]}&/@Partition[CirclePoints[3],2,1,1],{Thick,RandomColor[],Line[#]}&/@Partition[2CirclePoints[3],2,1,1]}]]

Find the new perimeters

{Total@N[EuclideanDistance@@@Partition[ CirclePoints[3],2,1,1]],Total@N[EuclideanDistance@@@Partition[2 CirclePoints[3],2,1,1]]}

Polygon Explorer

Create a tool that gives you the perimeter for a specified polygon

DynamicModule[{rad=1,sides=3},

Panel[

Grid[{
{Labeled[Slider[Dynamic@rad,{0.5,5},Appearance->"Labeled",ImageSize->Small],Style["Radius",12,FontFamily->"Helvetica"],Top],
Labeled[Slider[Dynamic@sides,{3,10,1},Appearance->"Labeled",ImageSize->Small],Style["Number of sides",12,FontFamily->"Helvetica"],Top]},
{Dynamic@Labeled[Graphics[{Thick,RandomColor[],Line[#]}&/@Partition[rad CirclePoints[sides],2,1,1],PlotRange->5+1],Style["Perimeter = "<>ToString[Total@N[EuclideanDistance@@@Partition[ rad CirclePoints[sides],2,1,1]]],12,FontFamily->"Helvetica",Darker@Purple]
],SpanFromLeft}
}
]
], SaveDefinitions->True

]

Ask students to just explore!

What might they find?

How should they approach the exploration?

Will they apply a scientific method?

Polygon Explorer

Have them “take data”: plot it, analyze it, see if they can develop intuition about it.

Manipulate[Quiet@ListPlot[Table[{i,Total@N[EuclideanDistance@@@Partition[rad CirclePoints[i],2,1,1]]},{i,3,n}],Epilog->{Dashed,Lighter@Blue,Line[{{-100,2π rad},{1000,2π rad}}],Text[Style[N[2π rad,5],12,FontColor->Purple],{4,N[2π rad,5]+1}]},PlotRange->{{0,11},{0,2π 5 +2}}],

{{rad,1,"radius"},0.5,5,Appearance->"Labeled"},
{{n,3,"number of sides"},3,10,1,Appearance->"Labeled"},

SaveDefinitions->True

]

This sets a strong foundation for formal proofs.

Polygon Explorer

There are many tools like this available for free on the Wolfram Demonstrations Project

http://demonstrations.wolfram.com/ApproximatingPiWithInscribedPolygons/

Manipulate[If[n<3,n=3];Grid[{{Graphics[{Opacity[.3],Gray,Disk[{0,0},1],Opacity[1],{ColorData["BrightBands"][n/25],EdgeForm[Black],Polygon[Table[{Sin[t],Cos[t]},{t,0,2 Pi,2 Pi/n}]]},Table[{If[showtri,Black,ColorData["BrightBands"][n/25]],Line[{{Sin[t],Cos[t]},{0,0}}]},{t,0,2 Pi,2 Pi/n}]},ImageSize->{240,240},AspectRatio->1,PlotLabel->Style["area = "<>ToString[b[n]],14]],Show[{Plot[Pi,{x,0,25}, PlotStyle->Directive[Opacity[0.6],Purple]],ListPlot[Drop[Join[{#,b[#]}&/@ Range[2,n,1],{{0,0}}],1],Filling->0]},ImageSize->{240,240},AxesLabel->{Style["number\nof sides",12,RGBColor[.33,.26,.78]],Style["area",12,Orange]},PlotRangePadding->{{0,.25},{0,.1}},PlotRange->{{0,20},{0,3.5}},Ticks->{Range[3,n,2],Join[{#,If[Mod[#,.5]==0,ToString[#],""]}& /@ Range[0,3.5,.1],{{Pi,Style["",Purple],0}}]},Epilog->{Text[Style["π = 3.14159...",12,FontColor->Purple],{13,3.35}]}]}}],{{showtri,False,Style["show triangles",12]},{True,False}},{{n,7,Style["number of sides",12]},3,20,1 },SaveDefinitions->True,Initialization:> {b[n_]:=N[n(1^2)Sin[Pi/n]Cos[Pi/n]]}]

Taylor Series

As the math concepts get more advanced, the intuition behind the concepts lags more and more. This shows you how to build a simple tool to visually explore what series expansions actually do.

Taylor Series

Start with a sine wave

Plot[Sin[x],{x,0,2π}]

Compute a Taylor series expansion

Normal@Series[Sin[x],{x,0,4}]

Taylor Series

Plot the two together

Plot[{Sin[x],x-((x^3)/6)},{x,0,2π},PlotRange->{Automatic,{-1.1,1.1}}]

Taylor Series

But what if I choose a different expansion point?

Plot[{Sin[x],Evaluate[Normal@Series[Sin[xx],{xx,7π/4,4}]/.xx->x]},{x,0,2π},PlotRange->{Automatic,{-1.1,1.1}},PlotLabel->Style[Row[{"Expansion point = ",π/4}],FontFamily->"Helvetica"]
]

Taylor Series

Or if I choose a different number of terms?

Plot[{Sin[x],Evaluate[Normal@Series[Sin[xx],{xx,7π/4,8}]/.xx->x]},{x,0,2π},PlotRange->{Automatic,{-1.1,1.1}},PlotLabel->Style[Row[{"Expansion point = ",π/4}],FontFamily->"Helvetica"]
]

Taylor Series

We can combine all of these explorations into a single interactive tool

Manipulate[Column[{Style[Row[{"series degree = ",deg}],"Label",12],Plot[Evaluate@{func/.x->t,MakeSeriesFunction[func,x,deg,pt]},{t,0, 2Pi},PlotRange->{{0,2Pi},{-2,2}},PlotStyle-> {{GrayLevel[.25,.85]},{RGBColor[0,0,.9,.8]}},Filling-> {1-> {{2},Directive[{Opacity[.1],Green}]}},Epilog->{Red,PointSize[.02],Point[{pt,func/.x->pt}],Blue,Point[{pt,0}],Dashing[{.01}],Line[{{pt,func/.x->pt},{pt,0}}]},ImageSize->{500,350}]},Center],{{deg,10,"series degree"},1,24,1},{{pt,0.,"expansion point"},0,2Pi},{{func,Sin[x],"function"},{Sin[x]->TraditionalForm[Sin[x]],Cos[x*2]/(x+1)->TraditionalForm[Cos[x*2]/(x+1)],1/(1+x)->TraditionalForm[1/(1+x)],E^x/100->TraditionalForm[E^x/100],2 (E^(-(((-3+x))^2)))->TraditionalForm[2 (E^(-(((-3+x))^2)))]}},SaveDefinitions->True,Initialization:>{MakeSeriesFunction[fn_,var_,deg_,pt_]:=Module[{wrkfn},
wrkfn[tt_]=If[Head[fn]===Symbol&&fn=!=var,fn[tt],fn/.var:>tt];
 Normal@Series[wrkfn[t],{t,pt,deg}]
]},SaveDefinitions->True]

This again is based on code which is freely-available on the Demonstrations Project

http://demonstrations.wolfram.com/TaylorPolynomials/

Polynomial Fitter

Exploratory learning is predicated on self-motivation. One method for increasing motivation is “gamification”.

Start with a simple polynomial

Plot[3(x^2)-2x+5,{x,-5,5}]

Polynomial Fitter

Change some parameters to see how they affect the function

Plot[3(x^2)-2x-50,{x,-5,5}]

Plot[2(x^2)-2x-50,{x,-5,5}]

Polynomial Fitter

Use Dynamic to change these parameters on the fly

Manipulate[
Plot[a (x^2)+b x+c,{x,-10,10},PlotRange->{{-10,10},{-100,100}}],

{{a,3,"A"},-10,10,Appearance->"Labeled"},

{{b,0,"B"},-10,10,Appearance->"Labeled"},

{{c,-5,"C"},-10,10,Appearance->"Labeled"},SaveDefinitions->True

]

Polynomial Fitter

This is compelling but let’s extend it to higher order polynomials. To make it even more interesting, let’s turn it into a game!

Manipulate[With[{poly=Plus@@{var0,var1*x,var2*x^2,var3*x^3},randpoly=Plus@@Table[(SeedRandom[ToString[N[s+i,3]]];RandomReal)[{-10,10},WorkingPrecision->3] x^i,{i,0,3}]},Text@Column[{Row[{Style["Guess: ",14,Black,"Label"],TraditionalForm@Text@Style[PolynomialForm[Plus@@MapThread[#1*x^#2&,{Evaluate[NumberForm[#,{4,2},NumberPadding->{"","0"},ExponentFunction->(Null&)]&/@{var0,var1,var2,var3}],Range[0,3]}]],12,GrayLevel[.3]]}],"",Row[{Text@Style["Actual: ",14,Black,"Label"],If[showans,TraditionalForm@Text@Style[PolynomialForm[randpoly],12],""]}],Plot[Evaluate[{poly,randpoly}],{x,-10,10},PlotRange->{{-10,10},{-100,100}},FillingStyle->Directive[{Opacity[.3],Blue}],Filling->{2},ImageSize->350]}]],{{var0,0,Superscript[x,0]},-10,10,.01,ImageSize->Small},{{var1,0,Superscript[x,1]},-10,10,.01,ImageSize->Small},{{var2,0,Superscript[x,2]},-10,10,.01,ImageSize->Small},{{var3,0,Superscript[x,3]},-10,10,.01,ImageSize->Small},
{{showans,False,"show answer"},{True,False}},
{{s,1,"new polynomial"},1,10},TrackedSymbols->True,SaveDefinitions->True,
ControlPlacement->{Left,Left,Left,Left,Top,Top},AutorunSequencing->{1,2,3,4,5}]

And, of course, this is based on a program available on the Demonstrations Project

http://demonstrations.wolfram.com/PolynomialFitter/