Chapter 4 	Applications of the Derivative

We have seen how the derivative of a function is itself a function. This idea leads to many possible applications, some of which we will now explore with Mathematica to demonstrate its ability to manipulate and calculate complicated or tedious expressions.

4.1   Related Rates

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

Example 4.1.  Let us assume a rubber ball is sitting out in the sun and that the heat causes its surface area to increase at the rate of 1.5 square centimeters per hour.  How fast is the radius increasing when the radius is 2 centimeters?

Solution: To solve this problem, we will need the formula for the surface area of a sphere: S = 4π(r^2).  Here, the surface area S and the radius r are expressed as functions of t (time).

Clear[S]
sa = S[t] == 4 π r[t]^2

dsa = D[sa,t]

Now differentiate this formula and solve for r'(t):

sol= Solve[dsa,r'[t]]

Since the output above is a nested list (each set of curly braces denotes a list; see Chapter 1 of this manual for a description of nested lists) and our solution, ((S'(t))/(8π r(t))), represents the second element of the first (inner) list, we can extract it in order to define r'(t) as follows:

r'[t]=sol[[1,1,2]]

Since we are given that S'(t)=1.5 and r(t)=2, we substitute these into the formula for r'(t):

r'[t]/. {S'[t]->1.5, r[t]->2}

Therefore, when the radius is 2 cm, it is increasing at the rate of about .0298 cm per hour.

Exercises

1.  If the volume of a cube is increasing at the rate of 2 cubic inches per minute, how fast is the length of one of its sides increasing when that side is 8 inches?

2.  A particle is moving along a parabola y=2(x^2)+3x-1 in such a way that the rate of change of its x-coordinate is constant, namely x'(t)=3.  Find the rate of change of its y-coordinate when the position of the particle is (1,4).

3.  The radius r and height h of a circular cone change at a rate of 2 cm/s.  How fast is the volume of the cone increasing when r = 10 and h = 20? (Recall that the volume of a cone is π(r^2)h/3.)

4.2  Extrema

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

Next, let us consider finding critical points and inflection points to determine extrema.  Remember that critical points of a function are those for which f'(x) = 0 or for which f'(x) does not exist. Similarly, inflection points occur where either f''(x) = 0 or where f''(x) does not exist.  Extrema occur at critical points, but not all critical points are extrema (consult your calculus text).  An inflection point is a point (c, f(c)) where concavity changes; this occurs where f''(c) = 0 or where f''(x) does not exist, and like critical points, not all points where f''(x) = 0 (or where f''(x) does not exist) are inflection points.

Example 4.2.  Find all local extrema and inflection points of f(x)=1/((x^2)+3).

Solution: We first define f in Mathematica:

Clear [f,x]

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

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

To find extrema of f, we locate its critical points, that is, those points where f'(x)=0 or f'(x) is undefined.  We can solve the first case using Mathematica:

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

Since f'(x) is defined everywhere, it follows that there is exactly one critical point at x = 0, and at that point, there is a maximum, as can be seen from the graph above.  We could also have used the second derivative test to confirm this:

f''[0]

Since the second derivative is negative at  x = 0, the curve is concave down there. This, of course, means that we have a local maximum at x = 0.

To find the points of inflection, we locate zeros of the second derivative:

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

To determine if these solutions are indeed inflection points, we need to check if there is a sign change in f''(x)  on either side of each (at x=-1 and x=1):

Plot[f''[x], {x, -2, 2}]

Notice from the graph above that f''(x) changes from positive to negative at x = -1 and from negative to positive at x=1. Thus both points (-1,f(-1)) and (1,f(1)) are inflection points.

Exercises

In Exercises 1through 5, find all critical points and inflection points for:
1. f(x)=(x^3) - 3 (x^2)+ 1		2. f(x)=((x^2) -3) (e^x) 		3. f(x)=sin x on [0, 2π]
4. f(x)=2(x^5)-5(x^4)+5		5. f(x)=(((x^2)+4)/x)

6. Consider the function f(x)=(x^n) where n is a positive integer. For what values of n do we have 
a) a relative minimum but not a point of inflection at the origin?
b)  a point of inflection at the origin but not a relative minimum?
Sketch the graph of several power functions to support your reasoning.

4.3   Optimization

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

Extreme values of a function occur where f'(x) = 0 or where f'(x) does not exist.  This idea allows us to find maxima and minima, concepts that are crucial in many applications.  For instance, in business, one wants to minimize costs or maximize profits.  In government, one wants to track the flow of money in an economy, and when that flow is a minimum or a maximum. In engineering design, we may want to know what shape of a conduit will generate  maximum flow.  Similar problems exist in many other fields.  We will now look at some of these applications.

4.3.1  Traffic Flow

Example 4.3.  Traffic flow along a major highway in Boston between 6 AM and 10 AM can be modeled by the function f(t)=20t-40(Sqrt[t])+50 (in miles per hour), where t=0 corresponds to 6 AM.  Determine when the minimum traffic flow occurs.

Solution: Let us first plot the graph of f(t).

Clear[f,t]

f[t_] := 20 t - 40 (Sqrt[t]) + 50

Plot[f[t],{t,0,4}]

Note from the plot above that the average speed is decreasing between 6 AM and 7 AM and increasing after 7 AM.

At 6 AM the average speed is

f[0]

or 50 mph. At 6:30 AM the average speed is

f[.5]

or 31.7 mph. To see how the average speed varies throughout the day we make a table of these values at each half hour from 6 AM to 10 AM:

TableForm[ Table[{t, f[t]},{t,0,4,.5}]]

You can see from the table that the average speed quickly drops from 50 mph to 30 mph in the first hour and then gradually increases back up to 50 mph during the next 3 hours.  If we want to verify that the minimum occurs at 7 AM (or t=1), we can use calculus. Since extrema occur where the derivative is 0, we set the derivative equal to zero and solve for t:

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

Therefore the minimum does occur when t=1 (7 AM) and from the table we see that the minimum average speed at this time is 30 mph.

4.3.2  Minimum Cost

Example 4.4.  A friend of one of the authors owns some land on Long Island off the coast of Portland, Maine.  He wants to build a house there, but there is no electricity.  He is considering laying an underwater cable to connect up with the mainland.  After a while I convince him of the ridiculousness of that idea.  The cost is far more than he can afford, but it does get me thinking about mathematics.  What would be the cheapest way of hooking up a cable to the municipal electrical system?   Let us consider the following scenario:

Imagine the island connection point at (0,3000) and the mainline connection point at (10000,0) where the units are in meters.  Assume it costs $36 per meter to lay cable underwater and $24 per meter to lay cable on land.  You can lay cable underwater from (0,3000) to (x,0) and then lay cable on land from (x,0) to (10000,0).  The variable x can vary between 0 and 10000.  What value of x would minimize the cost for laying this cable and what would that minimum cost be?

Solution: First, we need to determine the cost.  There are two parts: the underwater part and the overland part.  The cost of the underwater part is just $36 times the distance D1 from (0,3000) to (x,0).  We will call that cost c1:

c1[x_] := 36*(Sqrt[(3000^2)+(x^2)])

The overland cost is $24 times the distance D2 from (x,0) to (10000,0).  We will call that cost c2:

c2[x_] := 24*(10000-x)

The total cost is then

cost[x_]= c1[x] + c2[x]

We need to minimize this cost function.  First, we graph it to see if it has a minimum:

Plot[cost[x],{x,0,10000}]

Notice that this cost function has its minimum somewhere between 2000 and 4000.  Also, you will note that as x gets close to that minimum the tangent lines of cost (x) are getting close to horizontal. In other words, the minimum will occur at a point x for which the derivative is zero or horizontal (i.e., the derivative at a point gives the slope of the tangent line at that point). This is a calculus problem that we can solve.

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

N[cost[1200(Sqrt[5])]]

Therefore, the minimum occurs  at x=1200(Sqrt[5])≈ 2683.28 meters and the minimum cost is approximately $320,498.

NOTE: Another method in finding the minimum is to use the command FindMinimum. We will start our search near x=2000:

FindMinimum[cost[x],{x,2000},WorkingPrecision->8]

Again, we get an answer that corroborates the previous answer.

4.3.3  Packaging (Minimum Surface Area)

Example 4.5.  A major concern in business is to minimize the cost of packaging.  This cost is related to the surface area of the package.  If we can minimize that surface area, then we can minimize the cost.  Let us assume that a company has a certain product that needs to be packaged in a rectangular box having a square base.  If the volume of the box is required to be 1 cubic meter, then find the dimensions of the box that will minimize its surface area.

Solution: If the length of the sides of the square base is x and the height of the box is y, then the volume of the box is given by (x^2)y and must equal 1 cubic meter (this is our constraint):

Clear[x, y,S]

constraint=x^2*y==1

The surface area of our package (box) is S=4x y + 2 ((x^2)) and is the quantity that must be minimized (recall that the top and bottom sides each have area (x^2) and the 4 sides each have area x y).  Using our volume constraint, (x^2)y = 1, we can solve for y in terms of x:

y = (1/(x^2))

sol=Solve[constraint,y]

The surface area function can then be expressed as a function of x only:

S(x) = 4 x y  + 2 (x^2) = 4 x (1/(x^2))  +  2 (x^2) =  4/x + 2(x^2)

S[x_]=4x*y+2x^2/.y->sol[[1,1,2]]

Using the idea again that extrema occur at points where the derivative is zero, we calculate:

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

This equation has 1 real and 2 imaginary solutions. We need only the real solution of x = 1. To see that this corresponds to an actual minimum, we plot the curve:

Plot[S[x], {x,0 ,5}]

Alternatively, we could have used the second derivative test to show that a minimum occurs at x = 1:

S''[1]

Since f''(1)>0, we know that the graph is concave up at x=1 and hence must have a minimum there.  Since y=1 when x=1, we conclude that the box with minimum surface area is a cube with sides of 1 meter.

4.3.4  Maximize Revenue

The following application concerns optimizing group fares for charter flights.

Example 4.6.  Suppose a travel agency charges $600 per person for a charter flight if exactly 100 people sign up.  However, if more than 100 people sign up, then the fare is reduced by $2 per person for each additional person over the initial 100.  The travel agency wants to know how many people they should book to maximize revenue.  Also, determine what that maximum revenue is and what the corresponding fare is for each person.

We let x denote the number of passengers above 100.  Keep in mind that revenue is the product of the number of people multiplied by the cost (fare) per person.  If R(x) is defined as the revenue function, then R(x) = (100 +x) (600 - 2x).  To determine the maximum value of R(x) for x≥0, let us first examine its graph:

R[x_] := (100+ x) (600 - 2x)

Plot[R[x], {x,0,200}]

From the plot above, we see that a maximum occurs at about x = 100.  To confirm this, we first solve for the critical points:

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

Therefore the maximum does indeed occur at x = 100, and the maximum revenue is

R[100]

or  $80,000.  Since 100 + x represents the number of customers, this occurs when 200 customers sign up for the flight.  In this case, the cost per person is

600 - 2x /. x ->100

or $400 per person.

Exercises

1. Assume traffic flow is given by a speed function f(t) = 25 t - 45 (Sqrt[t]) + 55.  Analyze speed changes between 6 AM and 10 AM and calculate when traffic flow is minimized.  What is that minimum speed?

2. Find the minimum value of f(x)=3(x^4)+4(x^3).

3. Assume that the average cost of producing compact discs is given by  c(x) = -.0002 x + 3 + 2000/x.  Show that the average cost is always decreasing for x between 0 and 4000.

4. Suppose the population of a city is modeled by

p(t) = 4456 (t^3)  + 8939  (t^2)+ 23463 t + 25528

where t is measured in years from 1990 to 2000.

a)  Show that the population was always increasing in this decade.

b)  Show that the population was increasing at its slowest rate in August of 1990.  Hint:  The population is increasing at its slowest rate when p''(t) = 0.

5.  Given that the total cost for manufacturing x units of a particular product is described by the function C(x)=0.0025(x^2)+80x+10000, find the level of production that minimizes the total cost of manufacturing.

6. The total population of the planet is forecast by the function P(t)=0.00074(t^3)-0.07(t^2)+0.89t+6.04 where t is measured in decades,  t=0 corresponds to the year 2000, and P(t) is measured in billions of people.  In what year will the population peak over the next 200 years?

7. A book designer has decided that the pages of a book are to have 1.5 inch margins top and bottom and 1 inch margins on each side.  If each page is to have an area of 100 square inches, what are the dimensions of this page if its printed area is to be a maximum?

8. The owner of a farm wants to enclose a rectangular region with 3000 m of fencing while dividing the region into two parts, each of which is rectangular, by using part of the fencing to subdivide it and running a fence parallel to the sides (see figure that follows).   What should be the dimensions of the region in order to maximize its area?

9. The owner of a cruise ship charges groups as follows:  For a group of 40 people, the charge is $1,000 per person per day.  If more than 40 people sign up, the fare is reduced by $8 for each addtional person.

a) Assuming at least 40 people sign up, determine the number necessary to maximize revenue.

b) What is the maximum revenue?

c) What would be the cost per person in this case?

4.4   Newton's Method

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

4.4.1  Programming Newton's Method

Newton's Method is a technique for calculating zeros of a function based on the direction of its tangent lines.  It is a recursive routine that is rather tedious to do by hand or even with a calculator, but simple with Mathematica. To start the procedure one should have an idea about the general location of each zero.  This is because an initial approximation (Subscript[x, 0]) for that zero, say at x=r, is needed to start the recursion.  For example, one can specify (Subscript[x, 0]) by examining the graph of the function to see where the zeros are approximately.   Then the next approximation (Subscript[x, 1]) can be found by the recursive formula (Subscript[x, 1])=(Subscript[x, 0])-f((Subscript[x, 0]))/f'((Subscript[x, 0])).   This process can be iterated using the general formula

(Subscript[x, n+1])=(Subscript[x, n])-f((Subscript[x, n]))/f'((Subscript[x, n]))

Under suitable conditions, the sequence of approximations {(Subscript[x, 0]),(Subscript[x, 1]),(Subscript[x, 2]),...} (called the Newton sequence) will converge to r.

Example 4.7. Approximate the zeros of the function f(x)=ln(9-(x^2))-x.

f[x_] := Log[9-(x^2)]-x

Plot[f[x], {x,0,3}]

Clearly, there is one zero between 1.5 and 2 based on the plot above.  To approximate this zero, we define a function newtn to perform the recursion:

newtn[x_] := x - f[x]/f'[x]

To generate the corresponding Newton sequence, we compute 8 iterates of this function starting with an initial guess of x = 1.6.  This iteration can be performed efficiently using the NestList[f,x,n] function, which is a recursive routine that outputs a list with x as its first value, followed by f[x], f[f[x]], f[f[f[x]]], etc., up to n iterates as shown in the example below:

approx=NestList[newtn,1.6, 8]

From this we see that the root, accurate to 4 decimal places, is 1.7696.  If greater accuracy is desired, say 12 decimal places, we can redisplay the values of approx if it is already accurate to 12 decimal places or else recalculate it using a higher number of iterations if necessary.

NumberForm[approx//TableForm,13]

Discovery Exercise: The function f(x)=ln(9-(x^2))-x discussed above has a second zero.  Locate it on the graph of f(x) and use Newton's method to approximate it to 12 decimal places.  Hint: First, plot the graph over a wide interval to locate the zero, and then zoom in to obtain an initial approximation.

Warning: Be sure that your initial approximation is sufficiently close to your zero; otherwise the Newton sequence may diverge or converge to another zero.

4.4.2  Divergence

One interesting point about Newton's Method is that it does not always work. For instance, the function y = (x^(1/3)) clearly has a root at x = 0:

Plot[(x^(1/3)) , {x,0,1}]

Yet, Newton's Method fails for any guess x ≠ 0:

Clear[f]
f[x_]:=(x^(1/3))

NestList[newtn,0.6,6]

NOTE: The extremely small imaginary values that appear in the answers earlier should be ignored (or treated as zero) since we expect our answers to be entirely real.  This is due to Mathematica's default algorithm for computing radicals in the domain of complex numbers, which may introduce extremely small numerical errors.  To eliminate these imaginary parts, we use the Re[expr] command to extract the real part of expr.

Re[NestList[newtn,0.6,6]]

Question: Can you explain why Newton's Method fails in the above example?

4.4.3  Slow Convergence

Even when Newton's Method works, sometimes the Newton sequence converges very slowly to the answer.  Consider the following function:

Clear[ f]
f[x_] := (x^3) - x - 1

Plot[f[x], {x, -3,2}]

Clearly, there is a root between 1.2 and 1.4.  If  we use the newtn function with our guess as x = 1, we get quick convergence to the root:

NestList[newtn,1.0,6]

But if we choose our initial guess near 0.6, the convergence is much slower as discussed in the following exercises.

Exercises

1.  Compare the convergence in the above example (Section 4.4.3) for initial guesses of 0.5 and 0.6.  Why does Newton's Method converge so slowly for these values?  (Hint: Consider the tangent lines to the curve f(x).)

2.  Synthesizing the discussion in Sections 4.4.1 and 4.4.2 on the flaws in Newton's Method, can you come up with any general criteria that will tell us when Newton's Method will converge or diverge?

3. Use Newton's Method to find the postive zero of f(x)=(x^2)-2 accurate to 5 decimal places.   Note: This demonstrates how Newton's Method can be used to approximate (Sqrt[2]).

4. Consider the polynomial function p(x)=(x^4)-8(x^2)+15.
a) Find all the roots of this function.
b) Graph this function over the interval [-5,5].
c) Explain why at x=2 is not a good starting approximation for the root in the interval
d) Use Newton’s Method to approximate the other three roots in the appropriate intervals.
e) Which other values of are not good seed (starting) values and why? (Hint : Consider points of horizontal tangency.)

5. Use Newton's Method to find a solution (accurate to 5 decimal places) to the following equations:

a)  sin x = cos(2x) in the interval [0, π/2] (Hint: Define f(x)=sin x-cos(2x).)		b)  (e^x)= 5x		c)   cos x = x