Calculus I:  Mathematica Practice 5

Syntax Checks

Clear[f,g,h]

The following Mathematica commands have syntax errors. Fix the errors so the commands will work.

Problem 1: Limits

We want to calculate the limit as x approaches 1 from the left of (1/(1-x)):

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

Problem 2: l'Hospital's Rule

We want to calculate the limit as x approaches 0 from the right of (x^x):

f[x_]=x
g[x_]=x
limit[f^g,x->0+]

Problem 3: Linear Approximation

We want to calculate the linear approximation to  (x^x) about x=1/2:

normal[series[x^x,{x,1,1/2}]]

Example Basedon 4.2 The Mean Value Theorem

(a) In the viewing rectangle [-3,3] by [-5,5], graph the function f(x)=(x^3)-2x and its secant line through the points (-2,-4) and (2,4). Use the graph to estimate the points where the tangent line is parallel to the secant line.

(b) Find the exact values of the numbers c that satisfy the conclusion of the Mean Value Theorem for the interval [-2,2] and compare your answers to part (a).

(c) Sketch the function, the secant line, and the tangent lines at these values of c on the same axes.

Barry's Solution

Let's define the function we are working with:

f[x_]=x^3-2x

The secant line through the points given is defined using the point-point equation of a line:

((y-(Subscript[y, 0]))/(x-(Subscript[x, 0])))=(((Subscript[y, 1])-(Subscript[y, 0]))/((Subscript[x, 1])-(Subscript[x, 0])))
((y-(-4))/(x-(-2)))=(((4)-(-4))/((2)-(-2)))
((y+4)/(x+2))=2
y=2(x+2)-4
y=2x

secant[x_]=2x

Here are the plots:

Plot[{f[x],secant[x]},{x,-2,2},PlotStyle->{Black,Blue},PlotRange->{{-3,3},{-5,5}}]

It looks like there are two places in the interval where the tangent line to the curve has the same slope as the secant line (this is what the Mean Value Theorem says), around x=c=-1,1.

Using the Mean Value Theorem, we can determine the exact c values for which this occurs. Here is the MVT

f'(c)=((f(b)-f(a))/(b-a))

In this case, a=-2, b=2, and c is what we want to find. We can use Mathematica to solve the equation:

a=-2;
b=2;
equation=f'[c]==(f[b]-f[a])/(b-a)

Solve[equation,c]

Let's convert to decimals:

N[%]

Looks good! Let's get the equations of the tangent lines at these values of x and plot them as well.

tangent1[x_]=f'[-(2/(Sqrt[3]))](x-(-(2/(Sqrt[3]))))+f[-(2/(Sqrt[3]))]
tangent2[x_]=f'[(2/(Sqrt[3]))](x-((2/(Sqrt[3]))))+f[(2/(Sqrt[3]))]

Plot[{f[x],secant[x],tangent1[x],tangent2[x]},{x,-2,2},PlotStyle->{Black,Blue,Red,Red},PlotRange->{{-3,3},{-5,5}}]

Perfect! Here is a slightly more informative plot, that only includes the important tick marks:

Plot[{f[x],secant[x],tangent1[x],tangent2[x]},{x,-2,2},PlotStyle->{Black,Blue,Red,Red},PlotRange->{{-3,3},{-5,5}},Ticks->{{-2,-(2/(Sqrt[3])),(2/(Sqrt[3])),2},None},AxesLabel->{"x","y"}]

Example Based on 4.3 How Derivatives Affect Shape of a Graph

Estimate the intervals of concavity to one decimal place by using Mathematica to compute and graph f'' for the function f(x)=(((x^3)-10x+5)/(Sqrt[(x^2)+4]))

Barry's Solution

Let's define the function we are working with, and see what the derivative looks like just for fun:

f[x_]=(x^3-10x+5)/Sqrt[x^2+4]

f''[x]

Let's get an initial plot of the second derivative to see what is happening:

Plot[f''[x],{x,-10,10},AxesLabel->{"x","f''(x)"}]

It look slike the curve is concave down in the intervals (-∞,0.1) and concave up for (0.1,∞). Let's plot the function and see if this makes sense:

Plot[f[x],{x,-10,10},AxesLabel->{"x","f(x)"}]

Yep, this looks correct. To refine our guess, we should zoom in on the sketch of the second derivative and locate where it crosses the x-axis to one decimal of accuracy.

Plot[f''[x],{x,0,0.2},AxesLabel->{"x","f''(x)"}]

Hey--our initial guess was already accurate to one decimal! We rock.

Example

Use Mathematica to graph f(x)=((1-(e^(1/x)))/(1+(e^(1/x))))and find f' and f''. Determine as best as possible intervals of increase/decrease, the location of any exrema, intervals of concavity, and location of inflection points.

Barry's Solution

Let's define the function we are working with, and see what the derivative looks like just for fun:

f[x_]=(1-Exp[1/x])/(1+Exp[1/x])

f'[x]

f''[x]

Yuck! Good thing we have a computer to work these out for us!

Let's get an initial plot of the function to see what is happening:

Plot[f[x],{x,-5,5},AxesLabel->{"x","f(x)"},PlotRange->All]

Let's zoom in a bit.

Plot[f[x],{x,-1.5,1.5},AxesLabel->{"x","f(x)"},PlotRange->All]

Something interesting is happening at x=0. Ignoring that for the moment, my inital guesses are the following:

f(x) approaches 1 when x approaches zero from left, but -1when x approaches zero from the right. So no extrema.
f(x) is increasing on the interval (-∞,0), and increasing again on the interval (0,∞). 
f(x) is concave up on the intervals (-∞,-0.3) and (0,0.3), and concave down on the intervals (-0.3,0) and (0.3,0). 
f(x) has a point of inflection near x=-0.3,0.3.

Let's get more accurate answers by using calculus. The first derivative tells us about increasing decreasing and extrema. Let's plot it.

Plot[f'[x],{x,-2.5,2.5},AxesLabel->{"x","f'(x)"},PlotRange->All]

Plot[f'[x],{x,-0.05,0.05},AxesLabel->{"x","f'(x)"},PlotRange->All]

The function never crosses the x axis, which we can verify in the following manner:

Solve[f'[x]==0,x]

since there is no solution, there is no extrema. Since the first derivative is always positive, the function is increasing.

The second derivative tells us aboutconcavity and points of inflection. Let's plot it.

Plot[f''[x],{x,-2.5,2.5},AxesLabel->{"x","f''(x)"},PlotRange->All]

Where the second derivative crosses the x axis we have points of inflection.

Solve[f''[x]==0,x]

Look s like we will have to resort to zooming in on the graph.

d2f[x_]=Simplify[f''[x]]

Plot[d2f[x],{x,-1,0},AxesLabel->{"x","f''(x)"},PlotRange->All]

Looks like there is a point of inflection around x=-0.4. The function is concave up in the interval (-∞,-0.4), and looks like it is concave down in the interval (-0.4,0).

Plot[d2f[x],{x,0,1},AxesLabel->{"x","f''(x)"},PlotRange->All]

Looks like there is a point of inflection around x=0.4. The function is concave down in the interval (0.4,∞), and looks like it is concave down in the interval (0,0.4).

This was a tricky function to investigate, and teh answer in teh back of the text is incorrect. There are no inflection points at ±0.8.