Mini - Project
for 
Calculus and Mathematica
Workshop

Graph of y < 1/2 x +3 and y ¾ x - 1

Name : Paul Yu

Title : Graphing Systems of Linear Inequalites and more!

Description : The following notebook allow you to graph various systems of inequalities and linear equations. Students should be able to recognize the difference between linear equation and linear inequalities and graph both.

Graphing Systems of Linear Equations

Introduction to Linear Equations

A Linear equation is any equation in which the degree of each term is not two or more.  For example, y = x + 1, x - z = 5, m = 3, and 1/3y + 3 = x are all examples of linear equations.  In each of the preceding equations, the power of each term is one.  On the other hand, xy = 3, x2 - y = 4, 
x - z3 = 5 are not linear equations, why? 
    	A solution to a linear equation is any group of numbers which make the equation true.  Some solutions to the equation y = x + 1 are (1,2),(2,3), (6,7).... and the list goes on!  
    	Now a system of equations is any collection of two or more equations grouped together.  The following is a system of two linear equations.
    	y = x + 1
    	y = -x - 1
A solution to a system of equations is any set of numbers which make all the equations in the system true.  The solution to the above system would be (-1,0).  Try it out and see!

Linear Inequalities

Here are some examples of linear inequalities: y > x + 3, a - b É 4, and 
z - 3/4x > 5.  From these examples you can see that a linear inquality is a mathematical sentence with inequality signs and all the terms are of degree not greater than one.   Although they look the same as linear equations they are not.  Let's take a look at these two examples.  
	    y = x + 1
	    y < x + 1
Both have identical terms, however, the second statement has a "less than sign" in stead of an equal sign.  To best illustrate the difference, let's look at the graphs....
First, let's look at y = x + 1 from x = -10 to x = 10.

Clear[f,g,h,x,y,a,b,c,d]
f[x_] := x + 1
a = -10
b = 10

plotequal[E_] := Plot[E,{x,a,b},PlotStyle->Thickness[.008],
                 DisplayFunction->Identity]

axes= {Graphics[Line[{{0,f[a]},{0,f[b]}}]],
       Graphics[Line[{{a,0},{b,0}}]]}

Show[plotequal[f[x]],
				  
				  axes,
      DisplayFunction->$DisplayFunction,
      AspectRatio->Automatic,
      AxesLabel->{"X","Y"},
      Ticks->{{-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,
      								1,2,3,4,5,6,7,8,9,10},
      								{-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,
      								1,2,3,4,5,6,7,8,9,10}},
      PlotRange->{-10,10}]

Now let's take a look at y < x + 1 also from x = -10 to x = 10.

Clear[f,g,h,x,y,a,b,c,d]
f[x_] := x + 1 
a = -10
b = 10

plotinequal[F_] := ListPlot[Table[{x,F},{x,a,b,.25}],
									PlotStyle->PointSize[.01],
									DisplayFunction->Identity,
									AspectRatio->Automatic]

less[h_,c_,d_]   := Table[Graphics[{RGBColor[1,0,0],
                          Thickness[.001],
                          Line[{{d,(h/.x-> d) - i},
																																{c,(h/.x-> c) - i}}]}],
																							   {i,.25,20,.25}];

axes= {Graphics[Line[{{0,f[a]},{0,f[b]}}]],
       Graphics[Line[{{a,0},{b,0}}]]}

Show[less[f[x],a,b],
     plotinequal[f[x]],
				  
				  axes,
      DisplayFunction->$DisplayFunction,
      AspectRatio->Automatic,
      AxesLabel->{"X","Y"},
      Ticks->{{-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,
      								1,2,3,4,5,6,7,8,9,10},
      								{-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,
      								1,2,3,4,5,6,7,8,9,10}},
      PlotRange->{-10,10}]

Do you see the difference a little "<" sign can make?  With the linear equation 
y = x + 1, the solution set is made up from all the point along the line that was graphed. So if you take any point from the line and plug it into the "mathematical statement" , y = x + 1, the statement will be true.  However, with the linear inquality, the solution set is any point is the entire region below the dotted line.  The dotted line represents the boundary which closes off the region of the solution set.  Think of the dotted line as an electrical fence.  You can roam up and down and all around the region, but once you touch the fence, you get ZAPPED!

Systems of Linear Inequalities

We learned that a solution set of a system of linear equations must satisfy all the equations in the system.  For systems of linear inequalities the idea is similar.  But instead of looking for intersections in lines, as in a system of linear equations, we look at intersection of regions.  For and example, let's look at this system of linear equations:
    y < 1/2 x + 3
    y ¾ -x - 1
Okay, here's our system, let's look at each individual graph first.

Here's y < 1/2 x + 3

Clear[f,g,h,x,y,a,b,c,d]
f[x_] := 1/2 x - 4

a = -10

b = 10

less[h_,c_,d_]   := Table[Graphics[{RGBColor[1,0,0],
                          Thickness[.001],
                          Line[{{d,(h/.x-> d) - i},
																																{c,(h/.x-> c) - i}}]}],
																							   {i,.25,10,.25}];

less2[h_,c_,d_]  := Table[Graphics[{RGBColor[0,0,1],
                          Thickness[.001],
                          Line[{{d,(h/.x-> d) - i},
																																{c,(h/.x-> c) - i}}]}],
																							   {i,.25,10,.25}];

great[h_,c_,d_]  := Table[Graphics[{RGBColor[1,0,0],
                          Thickness[.001],
                          Line[{{d,(h/.x-> d) + i},
																																{c,(h/.x-> c) + i}}]}],
																							   {i,.25,10,.25}];

great2[h_,c_,d_] := Table[Graphics[{RGBColor[0,0,1],
                          Thickness[.001],                             
                          Line[{{d,(h/.x-> d) + i},
																																{c,(h/.x-> c) + i}}]}],
																							   {i,.25,10,.25}];

plotequal[E_] := Plot[E,{x,a,b},PlotStyle->Thickness[.008],
																	DisplayFunction->Identity]

plotinequal[F_] := ListPlot[Table[{x,F},{x,a,b,.25}],
									PlotStyle->PointSize[.01],
									DisplayFunction->Identity,
									AspectRatio->Automatic]

axes= {Graphics[Line[{{0,f[a]},{0,f[b]}}]],
       Graphics[Line[{{a,0},{b,0}}]]}

Let's Graph!

Show[less[f[x],a,b],
      plotinequal[f[x]],
				  
				  axes,
      DisplayFunction->$DisplayFunction,
      AspectRatio->Automatic,
      AxesLabel->{"X","Y"},
      Ticks->{{-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,
      								1,2,3,4,5,6,7,8,9,10},
      								{-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,
      								1,2,3,4,5,6,7,8,9,10}},
      PlotRange->{-10,10}]

This is y < 1/2 x - 4

Now here's y ¾ -x - 1

Clear[f,g,h,x,y,a,b,c,d]
f[x_] := - x - 1

a = -10

b = 10

less[h_,c_,d_]   := Table[Graphics[{RGBColor[1,0,0],
                          Thickness[.001],
                          Line[{{d,(h/.x-> d) - i},
																																{c,(h/.x-> c) - i}}]}],
																							   {i,.25,10,.25}];

less2[h_,c_,d_]  := Table[Graphics[{RGBColor[0,0,1],
                          Thickness[.001],
                          Line[{{d,(h/.x-> d) - i},
																																{c,(h/.x-> c) - i}}]}],
																							   {i,.25,10,.25}];

great[h_,c_,d_]  := Table[Graphics[{RGBColor[1,0,0],
                          Thickness[.001],
                          Line[{{d,(h/.x-> d) + i},
																																{c,(h/.x-> c) + i}}]}],
																							   {i,.25,10,.25}];

great2[h_,c_,d_] := Table[Graphics[{RGBColor[0,0,1],
                          Thickness[.001],                             
                          Line[{{d,(h/.x-> d) + i},
																																{c,(h/.x-> c) + i}}]}],
																							   {i,.25,10,.25}];

plotequal[E_] := Plot[E,{x,a,b},PlotStyle->Thickness[.008],
																	DisplayFunction->Identity]

plotinequal[F_] := ListPlot[Table[{x,F},{x,a,b,.25}],
									PlotStyle->PointSize[.01],
									DisplayFunction->Identity,
									AspectRatio->Automatic]

axes= {Graphics[Line[{{0,f[a]},{0,f[b]}}]],
       Graphics[Line[{{a,0},{b,0}}]]}

Let's see this one

Show[great2[f[x],a,b],
      plotequal[f[x]],
				  
				  axes,
      DisplayFunction->$DisplayFunction,
      AspectRatio->Automatic,
      AxesLabel->{"X","Y"},
      Ticks->{{-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,
      								1,2,3,4,5,6,7,8,9,10},
      								{-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,
      								1,2,3,4,5,6,7,8,9,10}},
      PlotRange->{-10,10}]

And this is the inequality y ¾ -x - 1.

Now that we've seen the two graphs, let's put them together!

Clear[f,g,h,x,y,a,b,c,d]
f[x_] := 1/2 x + 3

g[x_] := -x - 1

a = -10

b = 10

less[h_,c_,d_]   := Table[Graphics[{RGBColor[1,0,0],
                          Thickness[.001],
                          Line[{{d,(h/.x-> d) - i},
																																{c,(h/.x-> c) - i}}]}],
																							   {i,.25,20,.25}];

less2[h_,c_,d_]  := Table[Graphics[{RGBColor[0,0,1],
                          Thickness[.001],
                          Line[{{d,(h/.x-> d) - i},
																																{c,(h/.x-> c) - i}}]}],
																							   {i,.25,20,.25}];

great[h_,c_,d_]  := Table[Graphics[{RGBColor[1,0,0],
                          Thickness[.001],
                          Line[{{d,(h/.x-> d) + i},
																																{c,(h/.x-> c) + i}}]}],
																							   {i,.25,20,.25}];

great2[h_,c_,d_] := Table[Graphics[{RGBColor[0,0,1],
                          Thickness[.001],                             
                          Line[{{d,(h/.x-> d) + i},
																																{c,(h/.x-> c) + i}}]}],
																							   {i,.25,20,.25}];

plotequal[E_] := Plot[E,{x,a,b},PlotStyle->Thickness[.008],
																	DisplayFunction->Identity]

plotinequal[F_] := ListPlot[Table[{x,F},{x,a,b,.25}],
									PlotStyle->PointSize[.01],
									DisplayFunction->Identity,
									AspectRatio->Automatic]

axes= {Graphics[Line[{{0,f[a]},{0,f[b]}}]],
       Graphics[Line[{{a,0},{b,0}}]]}

Here's what you've been waiting for!

Show[great2[g[x],a,b],less[f[x],a,b],
      plotequal[g[x]],plotinequal[f[x]],
				  
				  axes,
      DisplayFunction->$DisplayFunction,
      AspectRatio->Automatic,
      AxesLabel->{"X","Y"},
      Ticks->{{-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,
      								1,2,3,4,5,6,7,8,9,10},
      								{-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,
      								1,2,3,4,5,6,7,8,9,10}},
      PlotRange->{-10,10}]

And here is the solution set for the system of inequalities y < 1/2x + 3 and 
                                                    y ¾ x - 1
Again, notice that the solution is the entire region.  To test this,pick a point from the region, plug it into both equations,a  see if it works!

Try some for yourself!

Here are the functions to graph you own systems of linear inequalities, plug in a couple linear equalities and watch them run!

Clear[f,g,h,x,y,a,b,c,d]
f[x_] :=1/4 x - 1

g[x_] :=3 x +2

a = -10

b = 10

Shading commands

less[h_,c_,d_]   := Table[Graphics[{RGBColor[1,0,0],
                          Thickness[.001],
                          Line[{{d,(h/.x-> d) - i},
																																{c,(h/.x-> c) - i}}]}],
																							   {i,.25,10,.25}];

less2[h_,c_,d_]  := Table[Graphics[{RGBColor[0,0,1],
                          Thickness[.001],
                          Line[{{d,(h/.x-> d) - i},
																																{c,(h/.x-> c) - i}}]}],
																							   {i,.25,10,.25}];

great[h_,c_,d_]  := Table[Graphics[{RGBColor[1,0,0],
                          Thickness[.001],
                          Line[{{d,(h/.x-> d) + i},
																																{c,(h/.x-> c) + i}}]}],
																							   {i,.25,10,.25}];

great2[h_,c_,d_] := Table[Graphics[{RGBColor[0,0,1],
                          Thickness[.001],                             
                          Line[{{d,(h/.x-> d) + i},
																																{c,(h/.x-> c) + i}}]}],
																							   {i,.25,10,.25}];

Plotting line commands

plotequal[E_] := Plot[E,{x,a,b},PlotStyle->Thickness[.008],
																	DisplayFunction->Identity]

plotinequal[F_] := ListPlot[Table[{x,F},{x,a,b,.25}],
									PlotStyle->PointSize[.01],
									DisplayFunction->Identity,
									AspectRatio->Automatic]

axes= {Graphics[Line[{{0,f[a]},{0,f[b]}}]],
       Graphics[Line[{{a,0},{b,0}}]]}

Graphing command

Show[great2[g[x],a,b],less[f[x],a,b],
      plotequal[f[x]],plotinequal[g[x]],
				  
				  axes,
      DisplayFunction->$DisplayFunction,
      AspectRatio->Automatic,
      AxesLabel->{"X","Y"},
      Ticks->{{-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,
      								1,2,3,4,5,6,7,8,9,10},
      								{-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,
      								1,2,3,4,5,6,7,8,9,10}},
      
      PlotRange->{-10,10}]

User's guide

Here is a list of the commands and what they do
1.  less,less2,great,great2 are the commands which shade the region. The 2 denotes different color so you can distinguish the graphs.
2.  plotequal plots a solid line, and plotinequal plots a dotted line.
Its up to you to decide what command is used for any given graph.

This program may be revised to show all types of linear graphs.  Please feel free to add to it and change it according to your needs.