Experimenting with Lines

Initialization

Needs["Graphics`Colors`"];

Building a Line.

The following will explain to students how to form a line by plotting points.

Let's make a table of eleven points by finding y when x goes from 0 to 10.

Clear[f,x]
f[x_]=2x;
coord1=Table[{x,f[x]},{x,0,10}]

Now we will graph these coordinate pairs to see what they look like.

grcoord1=ListPlot[coord1,
			PlotStyle->{PointSize[.02],RGBColor[0,1,0]}];

Now lets find more points by solving for y as x goes from 0 to 10, but this time by going up by 0.5.  This will give us 20 points from 0 to 10.

coord2=Table[{x,f[x]},{x,0,10,0.5}]

Again, we will graph to see what is happening.

grcoord2=ListPlot[coord2,
			PlotStyle->{PointSize[.008],RGBColor[1,0,0]}];

We can now combine the two graphs and see if they are related.

Show[grcoord1,grcoord2];

Now let's make even more points from 0 to 10!!  First look at the table, then look at the graph.

coord3=Table[{x,f[x]},{x,0,10,0.25}]

grcoord3=ListPlot[coord3,
			PlotStyle->{PointSize[.006],RGBColor[0,0,1]}];

Again, we want to look at all three graphs together.

Show[grcoord1,grcoord2,grcoord3];

Lastly, we want to look at more points.  We will make a table of coordinates as x goes from -40 to 40.  First look at the table then look at the graph.

coord4=Table[{x,f[x]},{x,-40,40}]

grcoord4=ListPlot[coord4,
			PlotStyle->{PointSize[.006],RGBColor[0,0,1]}];

Finally, we want to combine all of the graphs together.  Can we make any predictions based on the graphs we have seen?

Show[grcoord4,grcoord1,grcoord2,grcoord3];

Exploring Slope

We want to start with a simple line equation y=x.  Let's see what it looks like.

Clear[f,x]
f[x_]=x;
line1=Show[Plot[f[x],{x,-10,10},
	            PlotStyle->Green,
	            PlotRange->{{-10,10},{-10,10}},
	            AxesLabel->{"x","y"},
	            AspectRatio->Automatic,
        		Ticks->{{-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,
        		  		 0,1,2,3,4,5,6,7,8,9,10},
        	    		{-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,
        		  		 0,1,2,3,4,5,6,7,8,9,10}},
		        DisplayFunction->Identity],
		   Graphics[{Green,Text["y = x",{11,10.5}, {1,0}]}],
	  DisplayFunction->$DisplayFunction];

Now see what happens when we double x.  (y = 2x)

f[x_]=2x;
line2=Show[Plot[f[x],{x,-10,10},
	            PlotStyle->VioletRed,
	            PlotRange->{{-10,10},{-10,10}},
	            AxesLabel->{"x","y"},
	            AspectRatio->Automatic,
        		Ticks->{{-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,
        		  		 0,1,2,3,4,5,6,7,8,9,10},
        	    		{-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,
        		  		 0,1,2,3,4,5,6,7,8,9,10}},
		        DisplayFunction->Identity],
		   Graphics[{VioletRed,Text["y = 2x",{7,10.5}, {1,0}]}],
	  DisplayFunction->$DisplayFunction];

Let's look at both graphs together.

Show[line1,line2];

Now, double the x value again.  (y = 4x)

f[x_]=4x;
line3=Show[Plot[f[x],{x,-10,10},
	            PlotStyle->Blue,
	            PlotRange->{{-10,10},{-10,10}},
	            AxesLabel->{"x","y"},
	            AspectRatio->Automatic,
        		Ticks->{{-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,
        		  		 0,1,2,3,4,5,6,7,8,9,10},
        	    		{-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,
        		  		 0,1,2,3,4,5,6,7,8,9,10}},
		        DisplayFunction->Identity],
		   Graphics[{Blue,Text["y = 4x",{3.5,10.5}, {1,0}]}],
	  DisplayFunction->$DisplayFunction];

We will now look at all three graphs.  Can you make any general comments about why the graphs are different by looking at the graphs and the equations?

Show[line1,line2,line3];

Now we can look at many lines going through the origin.  We will start with y = 0.5 x, and increase the slope in increments of 0.5 to see what happens.

Clear[f,x,c]
f[x_,c_]:= c x
Do[Show[Plot[f[x,c],{x,-5,5}, 
        PlotRange->{{-6,6},{-6,6}},
        DisplayFunction->Identity],
       Graphics[{Text["Slope = ",{-1,5}, {1,0}],
                 Text[c,{-1,5},{-1,0}]}],
   DisplayFunction->$DisplayFunction],     
  {c,0.5,4,0.5}];

Select the cell and annimate these graphs.

Lastly, we will use the same line but this time give it a negative slope.  We will decrease the slope in increments of -0.5.

Clear[f,x,c]
f[x_,c_]:= c x
Do[Show[Plot[f[x,c],{x,-5,5},
	    PlotStyle->Magenta, 
        PlotRange->{{-6,6},{-6,6}},
        DisplayFunction->Identity],
       Graphics[{Text["Slope = ",{2,5}, {1,0}],
                 Text[c,{2,5},{-1,0}]}],
   DisplayFunction->$DisplayFunction],     
  {c,-0.5,-4,-0.5}];

Again, select the cells and annimate these graphs.

Experimenting with y-intercepts.

We will be looking at how changing the constant term (y-intercept) in an equation will change the graph.

Clear[f,x,c]
f[x_,c_]:= x + c
Do[Show[Plot[f[x,c],{x,-10,10}, 
        PlotRange->{{-10,10},{-10,10}},
        DisplayFunction->Identity,
        AspectRatio->Automatic,
        Ticks->{{-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,
        		  0,1,2,3,4,5,6,7,8,9,10},
        	    {-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,
        		  0,1,2,3,4,5,6,7,8,9,10}}],
       Graphics[{Text["y = x + ",{-3,7}, {1,0}],
                 Text[c,{-3,7},{-1,0}],
       			 Text["y-int = ",{-3,6}, {1,0}],
                 Text[c,{-3,6},{-1,0}]}],
   DisplayFunction->$DisplayFunction],     
  {c,0,5}];

Now try negative y-intercepts™™™™.

Clear[f,x,c]
f[x_,c_]:= x + c
Do[Show[Plot[f[x,c],{x,-10,10}, 
        PlotRange->{{-10,10},{-10,10}},
        AxesLabel->{"x","y"},
        DisplayFunction->Identity,
        AspectRatio->Automatic,
        Ticks->{{-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,
        		  0,1,2,3,4,5,6,7,8,9,10},
        	    {-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,
        		  0,1,2,3,4,5,6,7,8,9,10}}],
       Graphics[{Text["y = x + ",{-3,7}, {1,0}],
                 Text[c,{-3,7},{-1,0}],
       			 Text["y-int = ",{-3,6}, {1,0}],
                 Text[c,{-3,6},{-1,0}]}],
   DisplayFunction->$DisplayFunction],     
  {c,0,-5,-1}];