Tangents and Limits
Tangents
	 Imagine that we wish to find a tangent line for a function without a nice clean closed form.  While we may be more used to dealing with polynomials and trigonometric function, they do not represent an exhaustive list of all possible curves. (Under certain resriction they are “dense” in the set of all possible curves, but that’s a whole different class.) For example, a common special function that arises in the study of radially symetric waves (electromagnetic, acoustic, pressure) are the Bessel functions.

f[x_]:= BesselJ[0,x]
(*This the Bessel function of the first kind of order 0.*)

To get some intuition on what a Bessel function looks like, we can use the Plot function.

BesselPlot = Plot[f[x],{x,0,14},PlotStyle->{Red, Thick}] ;(*Because the independent variable is usually a radius in application the plot ranges only over positive values of x. Also the plot itself has been saved to the variable BesselPlot for future use.*)

Using Mathematica, we can automate all the steps for finding a tangent line at x = 8. To create a nice picture to go along with this, we use ListPlot along with the Show function to add an achor point to the plot.

TangentPoint = ListPlot[{{8,f[8]}},PlotStyle->{PointSize[.03],Purple}] ;(*ListPlot[] can plot a list of points in the form {{(Subscript[x, 1]),(Subscript[y, 1])}, {(Subscript[x, 2]),(Subscript[y, 2])}, {(Subscript[x, 3]),(Subscript[y, 3])},... }*)

Show[BesselPlot, TangentPoint] (*Show[] stacks plots on top of each other.*)

The first step towards finding a tagent line, is to find the slope of a secant line through an arbitrary second point, (a,f(a)).

SecantSlope = ((f[a]-f[8])/(a-8));(*This is the expression for the slope of a line through the two points.*)

Making the picture is a little bit more inolved, since we must subsitute in a value for a so that the plotting function has explicit numbers to work with. In Mathematica, subsitution is accomplished with the /. command followed by something like {a-> 7} which tells the computer to replace a with 7.

SecantLine = SecantSlope*(x-8)+ f[8]; (*This is the equation of that line written in something close to *)

Plot[SecantLine, {x, 0, 14}];

SecLinePlot = Plot[SecantLine/. {a-> 7}, {x,0,16},PlotStyle->{Green,Dotted, Thick}];

(*Plot for the example secant line through the point a=7.*)

SecantPoint = ListPlot[{{a,f[a]}}/. {a-> 7},PlotStyle->{PointSize[.03],Green}];(*The point through which the secant line passes.*)

Show[BesselPlot,SecLinePlot, TangentPoint,SecantPoint]

Now, the tangent line comes from taking the limit as a approaches 8. There’s a clever rule for reducing the Bessel function algebraicly to do this on paper, but that’s beyond the scope of this course. There is, however, a built in Mathematica function to do this for us. The notation for limits translates farily staight forwardly into the code for using the Limit[] function.

TangentSlope = Limit[SecantSlope, a-> 8];

(*Calculate the tangent slope.*)

All that remains then is to produce a plot with the fruits of our labor.

TangentLine = TangentSlope *(x-8)+f[8];

(*The expression for the tangent line.*)

N[Expand[TangentLine]](*The exact answer isn't very pretty but the N[] function produces a neat approximation.*)

TanLinePlot = Plot[TangentLine,{x,0,14},PlotStyle->{Purple,Dotted, Thick}];

(*Plot of the tangent line*)

Show[BesselPlot, TanLinePlot, TangentPoint]

Show[ Plot[f[x],{x,7.6,8.4},PlotStyle->{Red, Thick}] , TanLinePlot, TangentPoint](*Here's a zoomed in plot.*)

In one line a code, finding the slope might be accomplished in a compact form.

OneLineSlope = Limit[((f[a]-f[8])/(a-8)),a-> 8];

OneLineSlope ==TangentSlope (*Check that the same answer is arrived at.*)

(*This last line of code is a bit advanced...*)

Manipulate[Show[ Plot[f[x],{x,0,14},PlotStyle->{Red, Thick}] ,TanLinePlot,Plot[BesselJ[0,8]+(((-8+x) (-BesselJ[0,8]+BesselJ[0,a]))/(-8+a)), {x,0,16},PlotStyle->{Green,Dotted, Thick}],
ListPlot[ {{a,f[a]}},PlotStyle->{PointSize[.03],Green}], 
TangentPoint],{a,6,10}]

Limits
Note: This section will use a few advanced techniques, and is more important for illustrative purposes than to learn all the code.

One of the most famous and important limits has to do with the relationship between trigonometric functions and polynomials. It essentially compares the two simplest cases, a sin and a linear polynomial, x. Without proof, we wish to show numerically that 
				     (Subscript[Limit, x-> 0])((sin(x))/x) = 1
using a very proper definition of a limit. The basic idea is this: no matter how close to 1 we want to make ((sin(x))/x) , there’s a way to bound x so that ((sin(x))/x) stays within that range. These are commonly refered to as ϵ-δ proofs.

SinPlot =Plot[((Sin[x])/x),{x,-20,20},PlotRange->{-0.4 ,1.4},PlotStyle->{Red,Thick}]

No matter how tight the bounds in the y direction (the green box), a bound in the x direction (the blue box) may be choosen in such a way that the red curve stays within the green box. The green box represents the ϵ and the blue box represents the δ of the proofs names sake.

Manipulate[Show[Plot[((Sin[x])/x),{x,-10,10},PlotRange->{-0.4 ,1.4},PlotStyle->{Red,Thick}],Graphics[{Opacity[0.2],Green,Rectangle[{-20,1-ϵ},{20,1+ϵ}]}],
  Graphics[{Opacity[0.2],Blue,Rectangle[{-δ,-20},{δ, 20}]}]],{ϵ,0.3,0},{δ,2,0}]

A closer inspection.

Manipulate[Show[Plot[((Sin[x])/x),{x,-1.1,1.1},PlotRange->{0.8,1.1},PlotStyle->{Red,Thick}],Graphics[{Opacity[0.2],Green,Rectangle[{-20,1-ϵ},{20,1+ϵ}]}],
  Graphics[{Opacity[0.2],Blue,Rectangle[{-δ,-20},{δ, 20}]}]],{ϵ,0.05,0},{δ,0.8,0}]

If the wrong limit were choosen, say (lim_(x-> 0))((sin x)/x)=1.05, then the green box can be tighten so much that red curve can no longer be contained within it.

Manipulate[Show[Plot[((Sin[x])/x),{x,-1.1,1.1},PlotRange->{0.8,1.3},PlotStyle->{Red,Thick}],Graphics[{Opacity[0.2],Green,Rectangle[{-20,1.05-ϵ},{20,1.05+ϵ}]}],
  Graphics[{Opacity[0.2],Blue,Rectangle[{-δ,-20},{δ, 20}]}]],{ϵ,0.08,0},{δ,0.8,0}]