Chapter 2	Graphs of Functions,  Limits, and Continuity

2.1 Plotting Graphs

Students should read Chapter 1 of Rogawski's Calculus [1] for a detailed discussion of the material presented in this section.

2.1.1  Basic Plot

In this section, we will discuss how to plot graphs of functions using Mathematica and how to utilize its various plot options.  We will discuss in detail several options that will be useful in our study of calculus.  The basic syntax for plotting the graph of a function y=f(x) with x ranging in value from a to b is Plot[f,{x,a,b}]. On the other hand, Plot[{(Subscript[f, 1]),(Subscript[f, 2]),...,(Subscript[f, N])},{x,a,b}] plots the graphs of (Subscript[f, 1]),(Subscript[f, 2]),...,(Subscript[f, N]) on the same set of axes.

Example 2.1.  Plot the graph of  f(x)=(x^2)-3x+1 along the interval [-2,5].

Solution:

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

Example 2.2.  Plot the graph of y=cos (3x) along the interval [-4,4].

Solution:

Plot[Cos[3x],{x,-4,4}]

Example 2.3.  Plot the graphs of the two functions given in Examples 2.1 and 2.2 prior on the same set of axes to show their points of intersection.

Solution:

Plot[{ (x^2)-3x+1,Cos[x]},{x,-3,6}]

Example 2.4.  Plot the graphs of f(x)=(((x^2)+x+1)/(x+1)) and g(x)=((sin (4x))/4) on the same set of axes.

Solution:

Plot[{(x^2+x+2)/(x+1),Sin[4x]/4},{x,-4,4}]

Note that the graph of y=(sin 4x)/4 is displayed poorly in output above since its range (from -1 to 1) is too small compared to the range of y=((x^2)+x+2)/(x+1).  We can zoom in using the PlotRange option. The syntax for PlotRange is PlotRange->{c,d} (the arrow is generated by entering a minus sign (-) followed by greater than sign) where [c,d] is the interval on the y-axis to be displayed.  More generally, PlotRange ->{{a,b},{c,d}}   specifies the interval [a, b] on the x-axis while [c,d] specifies the interval on the y-axis.

Plot[{(x^2+x+1)/(x+1),Sin[4x]/4},{x,-4,4},PlotRange->{-4,4}]

Example 2.5.    Plot the graphs of the following functions.
a)   f(x)=((x^2)/((x^2)-4))	b) f(x)=sin x +cos x	c)f(x)=x (e^x)+ln x 	d) f(x)=((x^2)/((x^2)+4))

Solution: We recall that the natural base e is entered as E or e (from the Basic Math Assistant Palette) and that ln x is Log[x]. Note also that sin x and cos x are to be entered as Sin[x] and Cos[x] (see Chapter 1 of this text for a discussion of Mathematica's notation).  We leave it to the reader to experiment with different intervals for the domain of each graph so as to capture its salient features.

a)

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

b)

Plot[Sin[x]+Cos[x],{x,-2Pi,2Pi}]

c)

Plot[x (E^x)-Log[x],{x,-3,3}]

NOTE:  The above graph needs to be read carefully. First of all, it is clear from the graph above that f(x)=x (e^x)-ln x tends to ∞ as x tends to 0.  It is also clear from the graph that f(x) tends to ∞ as x tends to ∞.  Note, however, that the graph suggests (incorrectly) that the domain is [0, ∞).  If we zoom in on the graph near x=0, then we see that the domain does NOT include the point x=0.

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

2.1.2  Plot Options

Next, we will introduce various options that can be specified within the Plot command.  To begin with, evaluating the command Options[Plot] displays the following options:

Options[Plot]

PlotStyle

PlotStyle is an option for Plot that specifies the style of lines or points to be plotted. Among other things, one can use this option to specify a color of the graph and the thickness of  the curve.  PlotStyle  should be followed by an arrow and then the option: PlotStyle -> {option}. For example, if we want to plot a graph colored in red, we evaluate

Plot[(x^2),{x,-3,3},PlotStyle->Red]

The next example shows how to use PlotStyle to specify two styles: a color and thickness.

Plot[(x^2),{x,-3,3}, PlotStyle->{ Blue, Thickness[0.02]}]

PlotStyle can also be used to specify options for two or more graphs.  Here are two examples to demonstrate this:

Plot[{(x^2),(x^3)-x-1},{x,-3,3},PlotStyle->{Green,Yellow }]

Plot[{(x^2),(x^3)-x-1},{x,-3,3},PlotStyle->{{Magenta,Thickness[0.01]},{Cyan,Thickness[0.001],Dashing[{0.01,0.01,0.01}]}}]

PlotRange

We have already used the PlotRange option in Section 2.1 of this text (see Example 2.4 prior).  This option specifies the range of y-values on the graph that should be plotted. As observed in the same example in Section 2.1, some points of a graph may not be plotted unless we specify the y-range of the plot. The option PlotRange -> All  includes all y-values corresponding to the specified values of x.  Here is an example.

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

Plot[(x^5)-2x-1 ,{x,-5,5},PlotRange->All]

Axes

There are several options regarding axes of plots. We consider four of them.

1. Axes:    The specification Axes -> True  draws both axes, whereas  Axes -> False  draws no axes and Axes->{True,False} draws the x-axis only. An example of the last case  is given below.

Plot[ x Sin[3x],{x,-10,10},Axes->{True,False}]

2. AxesLabel:	The default specification AxesLabel -> None leaves the axes unlabeled.  On the other hand, AxesLabel -> expr  will only label the y-axis as expr and AxesLabel -> { "expr1", "expr2" } labels both the x-axis and y-axis as expr1 and expr2, respectively.  Examples of both cases are given below.

Plot[x Cos[x],{ x,-10,10},AxesLabel->y]

Plot[x Cos[x],{ x,-10,10},AxesLabel->{"x","y"}]

3.  AxisOrigin:	 The option AxesOrigin  specifies the location where the two axes should intersect. The default value given by AxesOrigin -> Automatic chooses the intersection point of the axes based on an internal (Mathematica) algorithm. It usually chooses (0,0). The option AxesOrigin -> {a,b}  allows the user to specify the intersection point as (a,b).

4.  AxesStyle:  This option specifies the style of the axes. Here is an example where we specify the thickness of the x-axis and color (blue) of the y-axis. We also use the AxesOrigin option.

Plot[x Cos[x],{ x,-10,10},AxesOrigin->{-10,10},
	AxesStyle->{ Blue,Thickness[0.01]},
	AxesLabel->{"x","y"}]

Frame

There are several options regarding the frame (border) of a plot. We show these options in the following examples:

Plot[x Cos[x],{ x,-10,10},Frame->True ]

Plot[x Cos[x],{ x,-10,10},Frame->True,FrameLabel->{"The graph of y = x cos x", "y-axis",None,None}]

Plot[x Cos[x] ,{ x,-10,10}, PlotStyle->Red,Frame->True, FrameLabel->{"The graph of  y = x cos x","y-axis",None,None},FrameStyle->{{Blue,Thickness[0.005]},{Yellow,Thickness[0.005]},{Green, Thickness[0.013]},{Orange} }]

We encourage the reader to experiment with this example by changing the color specifications to see which option controls which edge color of the frame.

Show

The command Show[graphics, options]  displays graphics (consisting of possibly many different graphics objects) using the options specified by options. Also Show[ plot1,plot2, ....] displays the graphics plot1, plot2, ... on one coordinate system.

plot1=Plot[Sin[x],{x,-Pi,Pi} ];

plot2=ListPlot[ {{0,0}, {Pi/2,1}, {Pi,0}}, PlotStyle->  {Red,PointSize[.02]}];

Show[plot1,plot2]

Here is an option we can use to identify the sine curve by inserting the expression y=sin x near its graph.

Show[plot1,plot2, 
 Epilog->Text["y=sin x",{2.7,1},{0,1}]]

Animation

Animate[expr, {t, a,b}] generates an animation of expr in which the parameter t varies from a to b. 
Animate[expr, {t, a,b, dt}] generates an animation of expr in which t varies from a to b in steps of dt. 
Animate[expr, {t,(Subscript[a, 1]),(Subscript[a, 2]), (Subscript[a, 3]),... ,(Subscript[a, n])}] generates an animation of expr in which t takes on the discrete set of values (Subscript[a, 1]), (Subscript[a, 2,])(Subscript[a, 3,])...,(Subscript[a, n]). 
Animate[expr, {t, a,b}, {s, c, d}, .... ] generates an animation of expr in which t varies from a to b,  s varies from c to d,  and so on.

Important Note: If you are reading the printed version of this publication, then you will not be able to view any of the animations generated from the Animate command in this chapter.  If you are reading the electronic version of this publication formatted as a Mathematica Notebook, then evaluate each Animate command to view the corresponding animation.  Just click on the arrow button to start the animation.  To control the animation just click at various points on the sliding bar or else manually drag the bar.

Example 2.6.  Analyze the effect of the shift f(x+a), f(x)+a,  f(b x) , and b f(x) for various values of a and b for the fucntion f(x)= cos x.

Solution:

f[x_]:=Cos[x]

Animate[Plot[{Cos[x],Cos[x+a]},{x,-2Pi,2Pi},PlotStyle->{Black ,Red},PlotRange->{-2,2}],{a,0,8 }]

Next, we will animate the graphs of f(x+a) (in red) and f(x)+a (in blue):

Animate[Plot[{Cos[x],Cos[x+a],Cos[x]+a},{x,-2Pi,2Pi},PlotStyle->{Black,Red,Blue},PlotRange->{-1,5}],{a,0,6 }]

Here is the animation for the graphs of f(b x) and b f(x).

Animate[Plot[{Cos[x],Cos[b*x],b*Cos[x]},{x,-2Pi,2Pi},PlotStyle->{Black , Red, Blue}],{b,0,8 }]

Here is an animation that shows all four shifts at once. We can fix as many parameters as we want (just click on their pause buttons) and analyze the behavior due to the remaining parameters.

Animate[Plot[{Cos[ x] ,Cos[x+a], Cos[x]+b,Cos[c x], d *Cos[x] },{x,0,10},
PlotStyle->{Black,Red, Blue, Green, Brown, Yellow},PlotRange->{-5,5}],
{a,0,5},{b,0,5}, {c,0,5},{d,0,5}]

Example 2.7.  Here is an animated example of a graph that shows the behavior of a general quadratic polynomial as we vary its coefficients.

Solution:

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

We suggest that you pause two of the parameters and vary the third one manually to see the change in the location of the zeros, the vertex, the regions of concavity, and the regions on which the graph increases and decreases. Then make the necessary changes to redo this problem for polynomials of higher degree.

Contour Plot

To end our discussion on graphics, we now consider plotting graphs of equations in two variables.  Among such equations are the famous family of elliptic curves that arise in number theory: (y^2)=(x^3)+a x+b, where a and b are parameters. The command for graphing equations implicitly in two variables x and y is ContourPlot[eqn, {x,a,b},{y,c,d}], which displays the graph of eqn for which x varies from a to b and y varies from c to d.

Example 2.8.	Plot the graphs of curves given by the equation (y^2)=(x^3)+a x+b for various values of a and b.

Solution: First, we define a function f[x,a,b] to represent the right-hand side of the equation (y^2)=(x^3)+a x+b so that f is a function of x as well as a and b. We then plot the equation (y^2)=f[x,a,b], where we consider three different sets of values: a=1, b=1; a=-4, b=0; and a=-3, b=3.

f[x_,a_,b_]:=(x^3)+a x+b

ContourPlot[ (y^2)==f[x,1,1],{x,-10,10},{y,-10,10},Axes->True, Frame->False]

ContourPlot[ (y^2)==f[x,-4,0],{x,-10,10},{y,-10,10},Axes->True, Frame->False]

ContourPlot[ (y^2)==f[x,-3,3],{x,-10,10},{y,-10,10},Axes->True, Frame->False]

Discovery Exercise: Evaluate the following table and discuss which pararemeters produce curves that are familiar. Make sure to delete the semicolon at the end of the command.

Table[ContourPlot[ (y^2)==f[x,a,b],{x,-10,10},{y,-10,10},Axes->True, Frame->False]  ,{a,-4,4},{b,-3,3}];

Exercises

In Exercises 1 through 8, plot the graphs of the given functions on the specified interval:
1. f(x)=(x^2)+1 on [-5,5]			2. g(x)=(1/(x-2)) on [0,4]		
3. h(x)=((sin x)/x) on [-π,π]			4.  f(x)=(x^3)-5(x^2)+10 on  [-5,5]		
5. f(x)=(Sqrt[32-2(x^2)]) on  [-4,4] 		6. f(x)=x+(1/x)  for [-10,10]
7. f(x)=(x^3)-x+1 on [-3,3]		8. g(x)=((1-cos x)/x) on [-π,π]

9.  Plot the graphs of f(x)=x(x-3)(x+3) and g(x)=cos 2x  together on the same set of axes and over the interval [-20,20].  Use the PlotRange option to adjust the range of the viewing window so that their points of intersection are visible.

In Exercises 10 through 13,  plot the graphs of the given functions using at least one plot option discussed in this section.
NOTE: ln x is one of the built-in Mathematica functions and is entered as Log[x].   The logarithmic function (Subscript[log , a]) x is entered as Log[a,x].  For the natural base e you either type E or you can obtain e from the Basic Math Assistant Palette.
10. f(x)=(x^4)+2(x^3)+1 for   -3≤x≤3		11. f(x)=x ln x  for   0≤x≤4 
12. f(x)=1-(1/(x^3))+(1/x)      for  -20≤x≤20		13. f(x)=x (e^x) for -4≤x≤4

In Exercises 14 through 18, plot the graphs of the given pairs of functions on the same axes. Use the PlotStyle option to distinguish the graphs.
14. f(x)=(e^x) and g(x)=ln x	 		15. f(x)=((2x)/(x-5)) and g(x)=((x-5)/(2x))   
16. f(x)=   (x^2)-sin x   and   g(x)=(Sqrt[(x^4)+1])- (Sqrt[(x^2)+1])	
17. f(x)=3x+1 and g(x)=((x-1)/3)     		18. f(x)=((x+1)^(1/3))and g(x)=(((x-1))^3)

19. Let f(x)=((((x^2)-1))^(2/3)). 
a) Define f in Mathematica  as it appears above and plot its graph.
b) Rewrite f as f(x)=(((((x^2)-1))^2)^(1/3))plots its graph as it appears here. 
c) Explain why the graphs are not identical. Generalize this remark to general functions with rational exponents.

20. Let f(x)=((2c x-(x^2) )/(c^2)), c>0. 
a)  Graph f for various values of c.  (You may use the Animate command.)
b)  Use the graph in part a) to sketch the curve traced out by the vertices of the highest point as c varies. Can you guess what this curve is?

21.  Use the Animate command to plot the graph of f(x)  by varying the parameters a,b,c,d, and e for each of the following functions.   Discuss how each parameter affects the shape of the graph.
a)  f(x)=a (x^3)+b (x^2)+c x+d 
b)  f(x)=a (x^4)+b (x^3)+c (x^2)+d x +e

22. a) Use ContourPlot to plot the graph of the curve defined by the equation y ((y^2) - c) (y-d) = x (x-a) (x-b) for various values of a, b, c, d.  (Hint: You may want to define g[y,c,d] as the left hand side and f[x,a,b] as the right hand side and then use the command ContourPlot[f[x, a, b] == g[y, c, d], {x, -5, 5}, {y, -5, 5}, Frame -> False, Axes -> True].)
b)  For the parameters you selected in part a, at how many points is the slope of this curve equal to zero?  Estimate the x-coordinates of these points.

2.2	Limits

Students should read Chapter 2 of Rogawski's Calculus [1] for a detailed discussion of the material presented in this section.

2.2.1  Evaluating Limits

Limit[f,x->a,Direction->1] computes the limit as x as approaches a from the left (i.e., x increases to a).

Limit[f,x->a,Direction->-1] computes the limit as x approaches a from the right (i.e., x decreases to a).

Limit[f,x->a] finds the limiting value of f as x approaches a.

NOTE: Mathematica will use the right-hand limit when evaluating Limit.  If the limit does not exist, then Mathematica will attempt to explain why or else return the limit expression unevaluated if it has insufficient information about the function.

Example 2.9.  Evaluate (Underscript[lim , x->1])((((x^2)+x+2)/(x+1))).

Solution: Here is a table of values of the function f(x)=(((x^2)+x+2)/(x+1)) when x is sufficiently close to 1.

f[x_]:=(((x^2)+x+2)/(x+1))

(*From the left*)
Table[{x,f[x]},{x,0.8,0.99,0.01}]//TableForm

(*From the right*)
Table[{x,f[x]},{x,1.2,1.01,-0.01}]//TableForm

From the tables, it is reasonable to expect that the limit is 2. Here is the graph of the function together with the point (1,2).

plot1=Plot[(x^2+x+2)/(x+1),{x,-1,2},PlotRange->{0,3}];
plot2= Graphics[{Green, PointSize[Large],Point[{1,2}] } ];
plot3=Graphics[{Red, Line[{{1,0},{1,2},{0,2}}]}];
Show[plot1, plot2, plot3]

Evaluating the limit confirms this:

Limit[(x^2+x+2)/(x+1),x->1]

Example 2.10.  The height of a projectile, fired in the air with initial velocity 32 ft/s, is given by y(t)=-16(t^2)+64t+3. Find the average velocity of the projectile over the interval [1,t] for various values of t.  Then find the instantaneous velocity at t=1.

Solution: We define

y[t_]=-16(t^2)+64t+3
v[t_]=((y[t]-y[1])/(t-1))

tt={2,1.5, 1.01,1.001,1.0001,1.00001};
Table[{tt[[k]],v[tt[[k]]]},{k,1,Length[tt]}]//TableForm

Here tt is the list of values for t and tt[[k]] refers to the kth element in the list tt (see Chapter 1 of this text for an explanation of lists).  Also, Length[t] gives the number of elements in the list tt, which is 6 for our example.

The above table clearly suggests that the instantaneous velocity at t=1 is 32 ft/s. The graph below also verifies this.

plot1=Plot[v[t],{t,0,2}, PlotRange->{0,50}];
 y=Simplify[v[t]]/.t-> 1;
plot2= Graphics[{ PointSize[Large],Point[{1,y}] } ];
plot3=Graphics[{Red, Line[{{1,0},{1,y},{0,y}}]}];

Show[plot1, plot2, plot3]

Example 2.11.  Show that f(x)=cos(1/x) does not have a limiting value as x approaches 0.

Solution: We define

f[x_]:=Cos[1/x]
f[{0.1,.05,0.001,.0001,.000001}]

These values suggest that the limit does NOT exist. To make this clear, we consider the following two tables.  The first table uses values of the form x=2/(2n+1)π, where n is a positive integer, while the second table uses x=1/(2n+1)π.  Each of these sets of values for x approach 0 as n->∞.

t1=Table[(2./(Pi(2n+1))),{n,1,100,10}];
f[t1]

t2=Table[(1./(Pi(2n+1))),{n,1,100,10}];
f[t2]

The first table indicates that the values of f(x) approach 0, while the second table indicates the values approach -1.  Recall that if the limit exists, then it must be unique.  Thus, our limit does not exist because the values of f do not converge to a single value.  Next, we analyze the graph of the function.

Plot[f[x],{x,-1,1}]

This indicates that there is too much oscillation around x=0.  Let us try zooming in around this point.

Plot[Cos[1/x],{x,-0.1,0.1}]

Note how zooming in on this graph does not help. This indicates that the limit does not exist.

Example 2.12. Consider the function f(x)=(((2^(1/x))-(2^(-1/x)))/((2^(1/x))+(2^(-1/x)))).  Find (lim_(x->0))f(x).

Solution:

Limit[(((2^(1/x))-(2^(-1/x)))/((2^(1/x))+(2^(1/x)))),x->0]

It may appear that the limit is (1/2), but the simplified form of f(x) (using the Simplify command) shows this not to be the case.  Instead we shall consider one-sided limits.

Simplify[(((2^(1/x))-(2^(-1/x)))/((2^(1/x))+(2^(1/x))))]

Limit[(((2^(1/x))-(2^(-1/x)))/((2^(1/x))+(2^(1/x)))),x->0,Direction->1]
Limit[(((2^(1/x))-(2^(-1/x)))/((2^(1/x))+(2^(1/x)))),x->0,Direction->-1]

Since the left- and right-hand limits are not the same, we conclude that the limit does not exist.

Plot[(((2^(1/x))-(2^(-1/x)))/((2^(1/x))+(2^(1/x)))),{x,-1,1}, PlotRange->{-30,1}]

NOTE: One needs to be careful when using Mathematica to find limits. If you are not certain that the limit exists, use one-sided limits:

Example 2.13.  Evaluate (Underscript[lim , x->(SuperPlus[5])])((|x-5|)/(x-5)).

Solution:

Limit[Abs[x-5]/(x-5),x->5,Direction->-1]

Note that Mathematica's convention for right-hand limits is "going in the negative direction." Thus, the standard notation (Underscript[lim , x->(SuperPlus[5])]) should be evaluated as Limit[f[x],x->5, Direction-> -1].  A similar remark applies to the left-hand limit.

Again, we can check the answer by plotting the graph of the function:

Plot[Abs[x-5]/(x-5),{x,3,7}]

Warning: This plot does not show the true graph of f(x) near x=5.  It may appear that f is continuous at x=5 because of the vertical line there but this is not the case since f is undefined at x=5 and its one-sided limits do not agree:

Abs[x-5]/(x-5)/.x->5
Limit[Abs[x-5]/(x-5),x->5,Direction->1]
Limit[Abs[x-5]/(x-5),x->5,Direction->-1]

Below is the true graph of f, which shows the (non-removable) discontinuity at x=5.

2.2.2  Limits Involving Trigonometric Functions

For trigonometric functions, Mathematica uses the same traditional notation in calculus except that the first letter of the trigonometric function must be capitalized. Thus, Sin[x] is Mathematica's notation for sin x (see Appendix A of this text for a description of notational differences).

Example 2.14.  Evaluate (Underscript[lim , x->0])((sin (4x))/x).

Solution:

Limit[Sin[4x]/x,x->0]

Let us check the answer by graphing the function up close in the neighborhood of x=0:

Plot[Sin[4x]/x,{x,-1,1}]

Example 2.15.  Evaluate (Underscript[lim , t->0])((sin t)/(|t|)).

Solution: We will consider both the left- and right-hand limits.

Limit[(( Sin[t])/(Abs[t])),t->0, Direction->-1]

Limit[(( Sin[t])/(Abs[t])),t->0, Direction->1]

Thus, the limit does not exist. This can be clearly seen from the graph of the function below.

Plot[((Sin[x])/(Abs[x])), {x,-2Pi,2Pi}]

Example 2.16. Find
a)	 (lim_(x->0 ))((cos x-1)/(sin x)) 		b) 	(lim_(x->0 ))tan x cos(sin 1/x)

Solution:

a=Limit[(Cos[x]-1)/Sin[x],x->0]

b=Limit[Tan[x] Cos[Sin[1/x]],x->0]

NOTE: In your textbook, it is proven that (lim_(x->0 ))((cos x-1)/x)=0 and (lim_(x->0 ))((sin x)/x)=1. Writing ((cos x-1)/(sin x))=(((cos x-1)/(x  )))/(((sin x)/x)), we see that the answer for part a) is valid by applying the quotient rule for limits. For the second limit in part b), we note that -1≤cos (sin(1/x))≤1and hence -|tan x|≤tan x cos (sin (1/x))≤|tan x|.  Since (lim_(x->0))tan x=(lim_(x->0))(-tan x)=0 we call upon the Squeeze Theorem to conclude that (lim_(x->0))tan x cos (sin (1/x))=0.

The following graphs verify both answers.

Plot[((Cos[x]-1)/(Sin[x])), {x,-2Pi, 2Pi}]

Plot[Tan[x]*Cos[Sin[1/x]],{x, -2Pi,2 Pi}]

Example 2.17.  Find  (lim_(x->c ))((cos x-cos c)/(x-c)) for  values of c=0, π/6, π/4, π/3, π/2.

Solution: We  will use the substitution command /. to evaluate the limit for different values of c.

Limit[((Cos[x]-Cos[c])/(x-c)), x->c]/. c->{0,Pi/6, Pi/4, Pi/3, Pi/2}

Can you guess a general formula for the answer in terms of c?  (Hint: What trigonometric function takes on these values?)

Example 2.18. Find  (lim_(x->0 ))((cos (m x)-1)/(x^2))for various values of m.  Then make a general statement about this limit and prove your assertion.

Solution: Here is a table of limits for integer values of m ranging from 1 to 10.

Table[Limit[((Cos[m x]-1)/(x^2)), x->0], {m, 1, 10}]

A reasonable guess at a general formula for the answer would be (lim_(x->0))(cos m x-1)/(x^2)=-(m^2)/2.  We can check this with values of m ranging from 10 to 20.

Table[{Limit[((Cos[m x]-1)/(x^2)), x->0],-m^2/2}, {m, 10, 20}]

For a mathematical proof, first take m=1 and plot the graph

Plot[((Cos[x]-1)/(x^2)),{x,-Pi,Pi}, AxesOrigin->{0,0}]

The graph above confirms that the limit is -1/2.

For the general case, let t=m x so that (x^2)=((t^2)/(m^2)).  Then note that x-> 0  if and only if t->0.  Thus, the limit can be evaluated in terms of t as

(lim_(x->0))((cos m x-1)/(x^2))=(lim_(t->0))((cos t-1)/((t^2)/(m^2)))=(m^2)(lim_(t->0))((cos t-1)/(t^2))=-((m^2)/2).

2.2.3 Limits Involving Infinity

Example 2.19.  Evaluate (Underscript[lim , x->∞])(3x -2)/(Sqrt[2(x^2)+1]) and  (Underscript[lim , x->-∞])(3x -2)/(Sqrt[2(x^2)+1]).

Solution:

Limit[(3x-2)/Sqrt[2x^2+1],x->Infinity]

N[%]

Limit[(3x-2)/Sqrt[2x^2+1],x->-Infinity]

Observe how the two limits differ. The following graph confirms this.

Plot[(3x-2)/Sqrt[2x^2+1], {x,-30,30}]

NOTE: Can you explain the cusp on the graph near x=0?

Example 2.20.  Evaluate (Underscript[lim , x->(SuperMinus[2])])((Sqrt[4-(x^2)])/(x-2)).

Solution:

Limit[Sqrt[4-x^2]/(x-2),x->2,Direction->1]

We plot the function over two different ranges to visually understand why the answer is -∞.  Notice how the first range fails to show this.

Plot[((Sqrt[4-x^2])/(x-2)),{x,1,3}]

Plot[((Sqrt[4-x^2])/(x-2)),{x,1,3},PlotRange->{-100,10}]

NOTE: The plot domain is specified to be [1,3], but observe that this function is undefined for values of x greater than 2 because this results in taking the square root of a negative number.

Example 2.21.  Evaluate (Underscript[lim , x->∞])sin x.

Solution:

Limit[Sin[x],x->Infinity]

Here, Mathematica is telling us that the limit does not exist by returning the range of values for sin x as x approaches infinity.

Example 2.22. Find  (lim_(x->∞ ))((sin x)/x) .

Solution:

Limit[((Sin[x])/x), x->Infinity]

We can verify this limit by using the Squeeze Theorem.  In our case, we take f(x)=-1/|x|, g(x)=((sin x  )/x)and h(x)=1/|x|.  Then f(x)≤g(x)≤h(x) (recall that -1≤sin x≤1 for all x).

Plot[{-1/Abs[x], Sin[x]/x,1/Abs[x]}, {x,0,30}, PlotStyle->{Red,Green,  Blue}]

Since 1/|x| and -1/|x| both approach 0 as x->∞, we conclude that (sin x)/x approaches zero as well.

Example 2.23.	Evaluate (lim_(x->∞))(((e^x)/(x^n))), where n is any integer.

Solution:

Table[Limit[E^x/(x^n), x-> Infinity], {n, 1, 200, 10}]

This table suggests that the limit is infinity. We confirm this with Mathematica:

Limit[((E^x)/(x^n)),x-> ∞]

NOTE: This example reveals that exponential functions grow more quickly than polynomial functions.

Example 2.24.  Evaluate 	(lim_(x->(SuperPlus[1])))((1/(ln x))-(1/(x-1))).

Solution:

Limit[(1/Log[x])-(1/(x-1)),x->1,Direction->1]

Again, we can graph the function near  x=1 to visually understand why the answer is 1/2 (we leave this to the student).  Note, however, that this example shows that 1/ln x and 1/(x-1) both grow to ∞ at the same rate as x->(SuperPlus[1]).

Example 2.25. Let  f(x)=(((x^n)-1)/((x^m)-1)).  Evaluate (Subscript[limit, x->1])f(x) by substituting in various values of m and n.

Solution:

Table[Limit[((x^n)-1)/((x^m)-1), x->1],{m,1,10},{n,1,10}]//TableForm

Can you guess a formula for (Subscript[limit, x->1])f(x) in terms of m and n?  Enter the command Limit[((x^n)-1)/((x^m)-1),x->1] into an input box and evaluate it to verify your conjecture.

Let us end this section with an example where the Limit command is used to evaluate the derivative of a function (in anticipation of commands introduced in the next chapter for computing derivatives).

By definition, the derivative of a function f at x (i.e., the slope of its tangent line at x) is

f '(x)=(Underscript[lim , Δ x->0])((f(x+Δ x)-f(x))/(Δ x)).

Example 2.26.  Find the derivative of f(x) =(1/x) according to the limit definition.

Solution: We first examine the derivative by tabulating values of the difference quotient, ((f(x+Δ x)-f(x))/(Δ x)), for  some arbitrarily chosen values of Δ x:

f[x_]:=1/x
delta={0.1,0.01,.0001,.00001,.000001,.00000001};
Table[{delta[[k]],Simplify[((f[x+delta[[k]]]-f[x])/(delta[[k]]))]},{k,1,Length[delta]}]//TableForm

This table suggests that f'(x)=-1/(x^2) in the limit as Δ x->0.  We confirm this with Mathematica:

Limit[(f[x+Deltax]-f[x])/Deltax,Deltax->0]

Exercises

In Exercises 1 through 8, compute the limits:
1. (Underscript[lim , x->1])(((x^2)-1)/(x-1))		2. (Underscript[lim , x->-5])(100/(x+5))		3.(Underscript[lim , x->∞])((1+x+(x^2))/(((x^10)-x)^(1/3)))	4. (Underscript[lim , x->0]) ((sin x)/x)	
5. (Underscript[lim , x->0]) ((sin 5x)/(3x))  	6. (Underscript[lim , x->0]) ((1-cos x)/(4x))  	7. (Underscript[lim , x->3]) (((x^3)-27)/((x^2)-9))  	8.  (Underscript[lim , x->-∞]) (((x^3)-27)/((x^2)-6))

In Exercises 9 through 13,  evaluate each of the limits. Verify your answers by plotting the graph of each function in the neighborhood of the limit point. 
9. (lim_(x-> 2))(((2x-1)/(4-3x)))			10. (lim_(x->(SuperPlus[0])))(((1-ln x)/(e^(1/x ))) )		11. (lim_(x->(SuperPlus[0])))((1/x)-ln (x^( )) )		
12. (lim_(x→(SuperMinus[((π/2))])))  ( sec 3x cos 5x) 	13.(lim_(x-> 0))( sin  x)cos((1/x))

14. Use various values of a to find the following limits.  Confirm your answers by plotting the graph of each function corresponding to your chosen values for a.  Make a conjecture for a general formula.  Then verify your conjecture by using Mathematica to evaluate the limits but keeping the constant a  unassigned.
a)  (Underscript[lim , x->a]) (((x^3)-(a^3))/(x-a))		b)   (Underscript[lim , x->1]) (((x^3)-a (x^2)+a x-1)/(x-1))

15. Consider the quadratic function f(x)=a (x^2)-x+1.  Plot the graph of f using small values of a.  What do you observe about the roots of f? What is the limit of the roots of f as a-> 0?  Hint: Use the command Animate[Plot[a (x^2)-x+1,{x,0,50},PlotRange->{-50,50}], {a, 0, .1, .01}]  to help you analyze the root and then change the values of a as well as the plot domain. Then use the quadratic formula to prove your assertion.  NOTE: One can also use the Solve or Roots commands to determine the roots of f.

2.3 Continuity

Students should read Section 2.4 of Rogawski's Calculus [1] for a detailed discussion of the material presented in this section.

Recall that a function is continuous at x=a if and only if (lim_(x->a))f(x)=f(a).  Graphically, this means that there is no break (or jump) in the graph of f at the point (a, f(a)). It is not possible to indicate this discontinuity using computer graphics for the situation where the limit exists and the function is defined at a but the limit is not equal to f(a).  For other cases of discontinuity, computer graphics are very helpful.

To verify if a given function is continuous at a point, we evaluate its limit there and check if this limit is equal to the value of the function.

Example 2.27. Show that the function f(x)=(x^3)-1 is continuous everywhere.

Solution: We could draw the graph and observe this fact. On the other hand, we can get Mathematica to check continuity:

f[x_]:=(x^3)-1
Limit[f[x], x-> c]==f[c]

This means that (lim_(x-> c))f(x)=f(c) and hence f is continuous everywhere.

Example 2.28.  Find points of discontinuity for each of the following functions:
a) Let  f(x)= {({{(((x^2)-1)/(x-1)), if x≠1}, {2,     if x=1.}}).
b) Let  g(x)= {({{(((x^2)-1)/(x-1)), if x≠1}, {6,     if x=1.}}).

Solution: The command If[cond, true, false] evaluates true if cond is satisfied and gives false if cond  is not satisfied. This command can be used to define piece-wise functions such as those in this example.

a) We first check continuity of f at x=1.

f[x_]:=If[x≠1, (((x^2)-1)/(x-1)),2]

Limit[f[x], x->1]==f[1]

Hence, the function is continuous at x=1.  For continuity at other points, we observe that the rational function (((x^2)- 1 )/(x-1)) simplifies to x+1 in this case (factor the numerator!)  and thus is continuous at any point except x=1.  Thus, f is continuous everywhere. We can also confirm this by examining the graph of f below.

Plot[f[x], {x,-6,6}]

b) As in part a, we first consider continuity of g at x=1.

g[x_]:=If[x≠1, (((x^2)-1)/(x-1)),6]

Limit[g[x], x->1]==g[1]

Thus, g is NOT continuous at x=1. For continuity at other points, we again observe that the rational function (((x^2)- 1 )/(x-1))=x+1 and thus is continuous for x≠1.

Caution: The plot of the graph of g given below indicates (incorrectly) that g is continuous everywhere! Care must be taken when examining Mathematica plots to draw conclusions about continuity.

Plot[g[x], {x,-6,6}]

Example 2.29. 		 Let  f(x)={({{2x+c,            if x≥2}, {(x^2)+c x -1,  if x<2.}})  
For what values of c is f continuous over its entire domain?

Solution: For x>2, we have f(x)=2x+c. Hence, f is continuous on the interval (2,∞) since the interval is open.  For x<2, f(x)=(x^2)+c x -1 . Thus, f is continuous on (-∞,2) for the same reason.  For f to be continuous at x=2, we must have (lim_(x->2))f(x)=f(2).  But the limit exists if and only if

(lim_(x->(SuperMinus[2])))f(x)=(lim_(x->(SuperPlus[2])))f(x)

Note that (lim_(x->(SuperPlus[2])))f(x)=4 +c=f(2). Thus, it suffices to find all values of c for which the left-hand limit and the right-hand limit are equal. This can be done using Mathematica's Solve command.

Clear[c,f]
f[x_]:=If[x<2, (x^2)+c x-1,2x+c]

lhs= Limit[f[x], x->2, Direction->1]
rhs=Limit[f[x], x->2, Direction->-1]

Solve[lhs==rhs  ,c]

Thus, f is continuous if c=1. We confirm this by plotting the graph of f corresponding to this c value.

Plot[f[x]/.c->1, {x, -5,7}]

Example 2.30. 	Let  f(x)={({{sin((1/x)), if x≠0}, {0,            if x=0}}).  Prove that for any number k between -1 and 1 there exists a value for c such that f(c)=k.

NOTE: Observe that f is not continuous at x=0 so the converse of the Intermediate Value Theorem does not hold.

Solution: For k=0, we choose c=0 so that f(0)=0.  For any nonzero k between -1 and 1, define y=(sin^(-1)) k (using the principal domain of the sine function) and let c=1/y. Then f(c)=sin (1/c)=sin y=k. The  graph of f following shows that there are in fact infinitely many choices for c.

f[x_]:=Sin[1/x]
Plot[f[x], {x,-Pi,Pi}]

Exercises

1.   Let   f(x)={({{(e^x), if x≤0}, {ln x,if x>0}}).

a)  Graph the above function and discuss the type of discontiniuty at x=0.

b)   Repeat part a. for the function

f(x)={({{cos(((π x)/2)), if |x|≤1}, {|x-1|,if |x|>1}}).

2. Find values for c in which f (defined below) is continuous over its entire domain:

f(x)={({{ (x^2)+c, x<1,}, {c (e^x),    x≥1}})

Plot the graph of f corresponding to these c values.

3. Let

f(x)={({{x+1, if |x|≤2}, {(x^2)-c, if |x|>2}}).

a)  For what value(s) of c is the function  continuous at x=2? With this choice of c does f have a discontinuity at any other point? Plot the graph of the function.

b)  For what value(s) of c is the function  continuous at x=-2? With this choice of c does f have a discontinuity at any other point? Plot the graph of the function.

4. Find values of a and b such that the function f is continuous everywhere where f(x)={({{2a x +b, x<-5}, {6b, -5≤ x<1
 3, x≥ 1}})  .  HINT: Solve first for b by equating the second and third expressions for f.