A05-NumberlineGraphs.mws

High School Modules > Algebra by Gregory A. Moore

     Intervals and Number Line Graphs [Algebra I]


The number line graphs of finite and infinite intervals.

[Directions : Execute the Code Resource section first. Although there will be no output immediately, these definitions are used later in this worksheet.]

Code

>    restart: with(plottools): with(plots):

Warning, the names arrow and changecoords have been redefined

>    intfin := proc( a, b, leq, req )
          #description "plot a finite interval on a number line";
local r, M, v1, v2, wid, bar, Axesplot, leftpt, rightpt, pt_color,
      leftend, rightend, LT, RT, textpos;
 
r := b-a ;
M := evalf( 1.2 * max( b-a, abs(a), abs(b) ) );
v1 := [a, 0];
v2 := [b, 0];
wid := ceil( M/15) ;

bar := arrow( v1, v2,
    shape = double_arrow, color = red , difference = true,
    width = wid, head_width = 0, head_length = 0):

textpos := max(wid, 2) ;
LT := textplot( [a, textpos, a] ):
RT := textplot( [b, textpos, b] ):

leftend  := min( a - 2*wid, 0);
rightend := max( b + 2*wid, 0);

Axesplot := plot( 0, x = leftend..rightend ,
                     y = (-wid)..(2*wid), axes = none, thickness = 2,
                     scaling = constrained, tickmarks = [1,1] ):


if( leq ) then pt_color := red; else pt_color := white; fi;
leftpt := disk([ a, 0], wid/2, color=pt_color):
if( req ) then pt_color := red; else pt_color := white; fi;
rightpt := disk([ b, 0], wid/2, color=pt_color ):

display(  leftpt, rightpt, bar, Axesplot, LT, RT );

end proc:

>    intinfr := proc(a, leq  )
#        description "plot an infinite interval going to +inf";
local    bb, r, M, v1, v2, wid, bar, Axesplot, textpos,
         leftpt, rightpt, pt_color, leftend, rightend, LT, RT;

bb := 3*abs(a);

r := bb-a;
M := evalf(1.2* max( abs(r), abs(a) ));
v1 := [a, 0];
v2 := [bb, 0];
wid := ceil( M/15);
bar := arrow( v1, v2,
    shape = double_arrow, color = red , difference = true,
   width = wid, head_width = 1.8*wid, head_length = 1.2*wid):

textpos := max(wid, 3) ;
LT := textplot( [a, textpos, a] ):
RT := textplot( [bb, textpos, `Infinity`] ):

leftend := min( 0, a*1.5);
rightend := max( 0, bb);

Axesplot := plot( 0, x = leftend..rightend ,
                     y = (-wid)..(3*wid), axes = none, thickness = 2,
                     scaling = constrained, tickmarks = [1,1] ):


if( leq ) then pt_color := red; else pt_color := white; fi;
leftpt := disk([ a, 0], wid/2, color=pt_color):

display(  leftpt,  bar, Axesplot, LT, RT );

end proc:

>    intinfl := proc( b, req  )
#        description "plot a infinite interval going to -inf";
local    aa, bb, r, M, v1, v2, wid, bar, Axesplot,textpos,
         leftpt, rightpt, pt_color, leftend, rightend, LT, RT;

aa := -3*abs(b);

r := b-aa;
M := evalf(1.2*max( abs(r), abs(b) ));
v1 := [aa, 0];
v2 := [b, 0];
wid := ceil( M/15);
bar := arrow( v2, v1,
    shape = double_arrow, color = red , difference = true,
   width = wid, head_width = 1.8*wid, head_length = 1.2*wid):

textpos := max(wid, 3) ;
LT := textplot( [aa, textpos, `-Infinity`] ):
RT := textplot( [b, textpos, b] ):

leftend := min( 0, aa);
rightend := max( 0, b*1.5);

Axesplot := plot( 0, x = leftend..rightend ,
                     y = (-wid)..(3*wid), axes = none, thickness = 2,
                     scaling = constrained, tickmarks = [1,1] ):


if( req ) then pt_color := red; else pt_color := white; fi;
rightpt := disk([ b, 0], wid/2, color=pt_color):

display(  rightpt,  bar, Axesplot, LT, RT );

end proc:

>    intall := proc()
          #description "plot a infinite interval of all real numbers ";
local    a, b, v1, v2, wid, bar1, bar2, LT, RT, Axesplot ;
a := -25; b := 25;

v1 := [a, 0];
v2 := [b, 0];
wid := ceil( (b-a)/15);
bar1 := arrow( v1,
    shape = double_arrow, color = red , difference = false,
   width = wid, head_width = 1.8*wid, head_length = 1.2*wid):

bar2 := arrow( v2,
          shape = double_arrow, color = red , difference = false,
          width = wid, head_width = 1.8*wid, head_length = 1.2*wid):

LT := textplot( [a, max( wid, 6), `-Infinity`] ):
RT := textplot( [b, max( wid, 6), `Infinity`] ):


Axesplot := plot( 0, x = a..b ,
                     y = (-wid)..(3*wid), axes = none, thickness = 2,
                     scaling = constrained, tickmarks = [1,1] ):

display(  bar1, bar2, Axesplot, LT, RT );
end proc:

>    intv := proc( expr1, expr2  )
        # description "plot a infinite interval going to -inf";
local    a, b, leq, req;

if type( expr1, `<=`) then leq := true; else leq := false; fi;
if type( expr2, `<=`) then req := true; else req := false; fi;
a := lhs( expr1);     b := rhs( expr2);

if( abs(a) <> infinity)
  then if( abs(b) <> infinity) then intfin( a,b, leq, req );
       else intinfr( a, leq);  fi;
  else if( abs(b) <> infinity) then intinfl( b, req);
       else intall(); fi;

fi;

end proc:

Finite Intervals

Finite intervals may include one, both, or neither endpoint - depending on whether the inequalities are "less than", or "less than an equal". This example is open on both endpoints.

>    intv( 3 < x, x < 17 );

[Maple Plot]

While this example is closed on both endpoints ...

>    intv( 10 <= x, x <= 200 );

[Maple Plot]



Its also possible to have half-open  intervals (or half-closed if you're a pessimist rather than an optimist).

>    intv( -30 <= x, x < 7);

[Maple Plot]

>    intv( -140 < x,x <=  -110 );

[Maple Plot]

Infinite Intervals

There are also infinite intervals. These occur when there is only a single inequality, and no bound in the other direction.

>    intv( -4 <  x, x < infinity );

[Maple Plot]

>    intv( -infinity < x, x < 10 );

[Maple Plot]


Its also possible to have infinite sets with closed endpoint

>    intv( 10 <= x, x <  infinity );

[Maple Plot]

>    intv( -infinity < x, x <= 100 );

[Maple Plot]


And all real numbers can be represented as an interval too....a really big interval.

>    intv( -infinity < x, x < infinity );

[Maple Plot]


         © 2002 Waterloo Maple Inc